Skip to content

Commit

Permalink
feat: change native token to nam
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianmarco Fraccaroli authored and tzemanovic committed Oct 25, 2022
1 parent 836a6de commit 3b530c5
Show file tree
Hide file tree
Showing 28 changed files with 121 additions and 121 deletions.
2 changes: 1 addition & 1 deletion apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ pub mod args {
const FEE_AMOUNT: ArgDefault<token::Amount> =
arg_default("fee-amount", DefaultFn(|| token::Amount::from(0)));
const FEE_TOKEN: ArgDefaultFromCtx<WalletAddress> =
arg_default_from_ctx("fee-token", DefaultFn(|| "XAN".into()));
arg_default_from_ctx("fee-token", DefaultFn(|| "NAM".into()));
const FORCE: ArgFlag = flag("force");
const DONT_PREFETCH_WASM: ArgFlag = flag("dont-prefetch-wasm");
const GAS_LIMIT: ArgDefault<token::Amount> =
Expand Down
6 changes: 3 additions & 3 deletions apps/src/lib/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use itertools::Either::*;
use namada::ledger::governance::storage as gov_storage;
use namada::ledger::pos::{BondId, Bonds, Unbonds};
use namada::proto::Tx;
use namada::types::address::{xan as m1t, Address};
use namada::types::address::{nam, Address};
use namada::types::governance::{
OfflineProposal, OfflineVote, Proposal, ProposalVote,
};
Expand Down Expand Up @@ -639,7 +639,7 @@ pub async fn submit_init_proposal(mut ctx: Context, args: args::InitProposal) {
safe_exit(1)
};

let balance = rpc::get_token_balance(&client, &m1t(), &proposal.author)
let balance = rpc::get_token_balance(&client, &nam(), &proposal.author)
.await
.unwrap_or_default();
if balance
Expand Down Expand Up @@ -911,7 +911,7 @@ pub async fn submit_bond(ctx: Context, args: args::Bond) {
// Check bond's source (source for delegation or validator for self-bonds)
// balance
let bond_source = source.as_ref().unwrap_or(&validator);
let balance_key = token::balance_key(&address::xan(), bond_source);
let balance_key = token::balance_key(&address::nam(), bond_source);
let client = HttpClient::new(args.tx.ledger_address.clone()).unwrap();
match rpc::query_storage_value::<token::Amount>(&client, &balance_key).await
{
Expand Down
12 changes: 6 additions & 6 deletions apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ where
/// are covered by the e2e tests.
#[cfg(test)]
mod test_finalize_block {
use namada::types::address::xan;
use namada::types::address::nam;
use namada::types::storage::Epoch;
use namada::types::transaction::{EncryptionKey, Fee};

Expand Down Expand Up @@ -349,7 +349,7 @@ mod test_finalize_block {
let wrapper = WrapperTx::new(
Fee {
amount: i.into(),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down Expand Up @@ -420,7 +420,7 @@ mod test_finalize_block {
let wrapper = WrapperTx::new(
Fee {
amount: 0.into(),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down Expand Up @@ -472,7 +472,7 @@ mod test_finalize_block {
let wrapper = WrapperTx {
fee: Fee {
amount: 0.into(),
token: xan(),
token: nam(),
},
pk: keypair.ref_to(),
epoch: Epoch(0),
Expand Down Expand Up @@ -538,7 +538,7 @@ mod test_finalize_block {
let wrapper_tx = WrapperTx::new(
Fee {
amount: 0.into(),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down Expand Up @@ -569,7 +569,7 @@ mod test_finalize_block {
let wrapper_tx = WrapperTx::new(
Fee {
amount: 0.into(),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down
4 changes: 2 additions & 2 deletions apps/src/lib/node/ledger/shell/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use namada::ledger::governance::vp::ADDRESS as gov_address;
use namada::ledger::slash_fund::ADDRESS as slash_fund_address;
use namada::ledger::storage::types::encode;
use namada::ledger::storage::{DBIter, StorageHasher, DB};
use namada::types::address::{xan as m1t, Address};
use namada::types::address::{nam, Address};
use namada::types::governance::TallyResult;
use namada::types::storage::Epoch;
use namada::types::token;
Expand Down Expand Up @@ -179,7 +179,7 @@ where
// transfer proposal locked funds
shell
.storage
.transfer(&m1t(), funds, &gov_address, &transfer_address);
.transfer(&nam(), funds, &gov_address, &transfer_address);
}

Ok(proposals_result)
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/node/ledger/shell/init_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ where
// Account balance (tokens no staked in PoS)
self.storage
.write(
&token::balance_key(&address::xan(), addr),
&token::balance_key(&address::nam(), addr),
validator
.non_staked_balance
.try_to_vec()
Expand Down
4 changes: 2 additions & 2 deletions apps/src/lib/node/ledger/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ mod test_utils {

use namada::ledger::storage::mockdb::MockDB;
use namada::ledger::storage::{BlockStateWrite, MerkleTree, Sha256Hasher};
use namada::types::address::{xan, EstablishedAddressGen};
use namada::types::address::{nam, EstablishedAddressGen};
use namada::types::chain::ChainId;
use namada::types::hash::Hash;
use namada::types::key::*;
Expand Down Expand Up @@ -861,7 +861,7 @@ mod test_utils {
let wrapper = WrapperTx::new(
Fee {
amount: 0.into(),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down
6 changes: 3 additions & 3 deletions apps/src/lib/node/ledger/shell/prepare_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub(super) mod record {
#[cfg(test)]
mod test_prepare_proposal {
use borsh::BorshSerialize;
use namada::types::address::xan;
use namada::types::address::nam;
use namada::types::storage::Epoch;
use namada::types::transaction::{Fee, WrapperTx};

Expand Down Expand Up @@ -189,7 +189,7 @@ mod test_prepare_proposal {
WrapperTx::new(
Fee {
amount: 0.into(),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down Expand Up @@ -244,7 +244,7 @@ mod test_prepare_proposal {
let wrapper_tx = WrapperTx::new(
Fee {
amount: 0.into(),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down
18 changes: 9 additions & 9 deletions apps/src/lib/node/ledger/shell/process_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ where
mod test_process_proposal {
use borsh::BorshDeserialize;
use namada::proto::SignedTxData;
use namada::types::address::xan;
use namada::types::address::nam;
use namada::types::hash::Hash;
use namada::types::key::*;
use namada::types::storage::Epoch;
Expand Down Expand Up @@ -217,7 +217,7 @@ mod test_process_proposal {
let wrapper = WrapperTx::new(
Fee {
amount: 0.into(),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down Expand Up @@ -264,7 +264,7 @@ mod test_process_proposal {
let mut wrapper = WrapperTx::new(
Fee {
amount: 100.into(),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down Expand Up @@ -346,7 +346,7 @@ mod test_process_proposal {
let wrapper = WrapperTx::new(
Fee {
amount: 1.into(),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down Expand Up @@ -399,7 +399,7 @@ mod test_process_proposal {
let wrapper = WrapperTx::new(
Fee {
amount: Amount::whole(1_000_100),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down Expand Up @@ -447,7 +447,7 @@ mod test_process_proposal {
let wrapper = WrapperTx::new(
Fee {
amount: i.into(),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down Expand Up @@ -511,7 +511,7 @@ mod test_process_proposal {
let wrapper = WrapperTx::new(
Fee {
amount: 0.into(),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down Expand Up @@ -570,7 +570,7 @@ mod test_process_proposal {
let mut wrapper = WrapperTx::new(
Fee {
amount: 0.into(),
token: xan(),
token: nam(),
},
&keypair,
Epoch(0),
Expand Down Expand Up @@ -623,7 +623,7 @@ mod test_process_proposal {
let wrapper = WrapperTx {
fee: Fee {
amount: 0.into(),
token: xan(),
token: nam(),
},
pk: keypair.ref_to(),
epoch: Epoch(0),
Expand Down
4 changes: 2 additions & 2 deletions documentation/dev/src/explore/design/actors.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Actors and Incentives

Namada consists of various actors fulfilling various roles in the network. They are all incentivized to act for the good of the network. The native Namada token `XAN` is used to settle transaction fees and pay for the incentives in Namada.
Namada consists of various actors fulfilling various roles in the network. They are all incentivized to act for the good of the network. The native Namada token `NAM` is used to settle transaction fees and pay for the incentives in Namada.

## Fees associated with a transaction

Expand All @@ -9,7 +9,7 @@ Users of Namada can
- transfer private assets they hold to other users and
- barter assets with other users.

Each transaction may be associated with the following fees, paid in `XAN`:
Each transaction may be associated with the following fees, paid in `NAM`:

- **Execution fees** to compensate for computing, storage and memory costs, charges at 2 stages:
- **initial fee (init_f)**: charged before the transaction is settled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ All [the data relevant to the PoS system](https://specs.namada.net/economics/pro
- `validator/{validator_address}/address_raw_hash` (required): raw hash of validator's address associated with the address is used for look-up of validator address from a raw hash
- TBA (e.g. alias, website, description, delegation commission rate, etc.)

Only XAN tokens can be staked in bonds. The tokens being staked (bonds and unbonds amounts) are kept in the PoS account under `{xan_address}/balance/{pos_address}` until they are withdrawn.
Only NAM tokens can be staked in bonds. The tokens being staked (bonds and unbonds amounts) are kept in the PoS account under `{nam_address}/balance/{pos_address}` until they are withdrawn.

## Initialization

Expand All @@ -39,7 +39,7 @@ Staking rewards for validators are rewarded in Tendermint's method `BeginBlock`

To a validator who proposed a block (`block.header.proposer_address`), the system rewards tokens based on the `block_proposer_reward` PoS parameter and each validator that voted on a block (`block.last_commit_info.validator` who `signed_last_block`) receives `block_vote_reward`.

All the fees that are charged in a transaction execution (DKG transaction wrapper fee and transactions applied in a block) are transferred into a fee pool, which is another special account controlled by the PoS module. Note that the fee pool account may contain tokens other than the staking token XAN.
All the fees that are charged in a transaction execution (DKG transaction wrapper fee and transactions applied in a block) are transferred into a fee pool, which is another special account controlled by the PoS module. Note that the fee pool account may contain tokens other than the staking token NAM.

- TODO describe the fee pool, related to <https://github.com/anomanetwork/anoma/issues/48>, <https://github.com/anomanetwork/anoma/issues/51> and <https://github.com/anomanetwork/anoma/issues/72>

Expand Down
4 changes: 2 additions & 2 deletions documentation/dev/src/explore/design/ledger/vp.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ The Proof-of-Stake slash pool is a simple account with a native VP which can rec

The [fungible token VP](https://github.com/anoma/anoma/tree/master/wasm/wasm_source) allows to associate accounts balances of a specific token under its account.

For illustration, users `Albert` and `Bertha` might hold some amount of token with the address `XAN`. Their balances would be stored in the `XAN`'s storage sub-space under the storage keys `@XAN/balance/@Albert` and `@XAN/balance/@Bertha`, respectively. When `Albert` or `Bertha` attempt to transact with their `XAN` tokens, its validity predicate would be triggered to check:
For illustration, users `Albert` and `Bertha` might hold some amount of token with the address `NAM`. Their balances would be stored in the `NAM`'s storage sub-space under the storage keys `@NAM/balance/@Albert` and `@NAM/balance/@Bertha`, respectively. When `Albert` or `Bertha` attempt to transact with their `NAM` tokens, its validity predicate would be triggered to check:

- the total supply of `XAN` token is preserved (i.e. inputs = outputs)
- the total supply of `NAM` token is preserved (i.e. inputs = outputs)
- the senders (users whose balance has been deducted) are checked that their validity predicate has also been triggered

Note that the fungible token VP doesn't need to know whether any of involved users accepted or rejected the transaction, because if any of the involved users rejects it, the whole transaction will be rejected.
Expand Down
4 changes: 2 additions & 2 deletions documentation/dev/src/specs/ledger/default-transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ Attach [UpdateVp](../encoding.md#updatevp) to the `data`.

### tx_bond

Self-bond `amount` of XAN token from `validator` (without `source`) or delegate to `validator` from `source`.
Self-bond `amount` of NAM token from `validator` (without `source`) or delegate to `validator` from `source`.

Attach [Bond](../encoding.md#bond) to the `data`.

### tx_unbond

Unbond self-bonded `amount` of XAN token from the `validator` (without `source`) or unbond delegation from the `source` to the `validator`.
Unbond self-bonded `amount` of NAM token from the `validator` (without `source`) or unbond delegation from the `source` to the `validator`.

Attach [Bond](../encoding.md#bond) to the `data`.

Expand Down
6 changes: 3 additions & 3 deletions genesis/dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ net_address = "127.0.0.1:26656"

# Some tokens present at genesis.

[token.xan]
[token.nam]
address = "atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5"
vp = "vp_token"
[token.xan.balances]
[token.nam.balances]
# In token balances, we can use:
# 1. An address any account
a1qyqzsqqqqqcyvvf5xcu5vd6rg4z5233hg9pn23pjgdryzdjy8pz52wzxxscnvvjxx3rryvzz8y5p6mtz = 1000000
Expand Down Expand Up @@ -168,7 +168,7 @@ light_client_attack_slash_rate = 500

# Governance parameters.
[gov_params]
# minimum amount of xan token to lock
# minimum amount of nam token to lock
min_proposal_fund = 500
# proposal code size in bytes
max_proposal_code_size = 300000
Expand Down
8 changes: 4 additions & 4 deletions genesis/e2e-tests-single-node.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
genesis_time = "2021-09-30T10:00:00Z"

[validator.validator-0]
# Validator's staked XAN at genesis.
# Validator's staked NAM at genesis.
tokens = 200000
# Amount of the validator's genesis token balance which is not staked.
non_staked_balance = 1000000000000
Expand All @@ -20,10 +20,10 @@ net_address = "127.0.0.1:27656"

# Some tokens present at genesis.

[token.XAN]
[token.NAM]
address = "atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5"
vp = "vp_token"
[token.XAN.balances]
[token.NAM.balances]
Albert = 1000000
"Albert.public_key" = 100
Bertha = 1000000
Expand Down Expand Up @@ -168,7 +168,7 @@ light_client_attack_slash_rate = 500

# Governance parameters.
[gov_params]
# minimum amount of xan token to lock
# minimum amount of nam token to lock
min_proposal_fund = 500
# proposal code size in bytes
max_proposal_code_size = 300000
Expand Down
4 changes: 2 additions & 2 deletions proof_of_stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub trait PosReadOnly {
const POS_ADDRESS: Self::Address;

/// Address of the staking token
/// TODO: this should be `const`, but in the ledger `address::xan` is not a
/// TODO: this should be `const`, but in the ledger `address::nam` is not a
/// `const fn`
fn staking_token_address() -> Self::Address;

Expand Down Expand Up @@ -577,7 +577,7 @@ pub trait PosBase {
/// Address of the PoS account
const POS_ADDRESS: Self::Address;
/// Address of the staking token
/// TODO: this should be `const`, but in the ledger `address::xan` is not a
/// TODO: this should be `const`, but in the ledger `address::nam` is not a
/// `const fn`
fn staking_token_address() -> Self::Address;
/// Address of the slash pool, into which slashed tokens are transferred.
Expand Down
4 changes: 2 additions & 2 deletions shared/src/ledger/governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub use vp::Result;
use self::storage as gov_storage;
use crate::ledger::native_vp::{Ctx, NativeVp};
use crate::ledger::storage::{self as ledger_storage, StorageHasher};
use crate::types::address::{xan as m1t, Address, InternalAddress};
use crate::types::address::{nam, Address, InternalAddress};
use crate::types::storage::Key;
use crate::types::token as token_storage;
use crate::vm::WasmCacheAccess;
Expand Down Expand Up @@ -235,7 +235,7 @@ where
KeyType::COUNTER(vp::validate_counter_key)
} else if gov_storage::is_parameter_key(value) {
KeyType::PARAMETER(vp::validate_parameter_key)
} else if token_storage::is_balance_key(&m1t(), value).is_some() {
} else if token_storage::is_balance_key(&nam(), value).is_some() {
KeyType::BALANCE(vp::validate_balance_key)
} else if gov_storage::is_governance_key(value) {
KeyType::UNKNOWN_GOVERNANCE(vp::validate_unknown_governance_key)
Expand Down
Loading

0 comments on commit 3b530c5

Please sign in to comment.