Skip to content

Commit

Permalink
Adds const and default token to basic fee
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Dec 30, 2022
1 parent db0cac3 commit d5cb262
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions apps/src/lib/client/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use namada::types::address::{Address, ImplicitAddress};
use namada::types::key::*;
use namada::types::storage::Epoch;
use namada::types::token::Amount;
use namada::types::transaction::{hash_tx, Fee, WrapperTx};
use namada::types::transaction::{hash_tx, Fee, WrapperTx, MIN_FEE};

use super::rpc;
use crate::cli::context::{WalletAddress, WalletKeypair};
Expand Down Expand Up @@ -175,7 +175,7 @@ pub async fn sign_wrapper(
let tx = {
WrapperTx::new(
Fee {
amount: Amount::from(100),
amount: Amount::from(MIN_FEE),
token: ctx.get(&args.fee_token),
},
keypair,
Expand Down
15 changes: 7 additions & 8 deletions apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use namada::ledger::storage::write_log::StorageModification;
use namada::ledger::storage_api::StorageRead;
use namada::types::storage::{BlockHash, BlockResults, Header};
use namada::types::token::Amount;
use namada::types::transaction::MIN_FEE;

use super::governance::execute_governance_proposals;
use super::*;
Expand Down Expand Up @@ -142,10 +143,8 @@ where
address::masp()
};

let balance_key = token::balance_key(
&self.storage.native_token,
&fee_payer,
);
let balance_key =
token::balance_key(&wrapper.fee.token, &fee_payer);
let balance: Amount =
match self.write_log.read(&balance_key).0 {
Some(wal_mod) => {
Expand Down Expand Up @@ -177,7 +176,7 @@ where
};

let balance: u64 = balance.into();
match balance.checked_sub(100) {
match balance.checked_sub(MIN_FEE) {
Some(v) => {
self.write_log
.write(
Expand Down Expand Up @@ -441,7 +440,7 @@ mod test_finalize_block {
);
let wrapper = WrapperTx::new(
Fee {
amount: 100.into(),
amount: MIN_FEE.into(),
token: shell.storage.native_token.clone(),
},
&keypair,
Expand Down Expand Up @@ -640,7 +639,7 @@ mod test_finalize_block {
);
let wrapper_tx = WrapperTx::new(
Fee {
amount: 100.into(),
amount: MIN_FEE.into(),
token: shell.storage.native_token.clone(),
},
&keypair,
Expand Down Expand Up @@ -671,7 +670,7 @@ mod test_finalize_block {
);
let wrapper_tx = WrapperTx::new(
Fee {
amount: 100.into(),
amount: MIN_FEE.into(),
token: shell.storage.native_token.clone(),
},
&keypair,
Expand Down
8 changes: 4 additions & 4 deletions apps/src/lib/node/ledger/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use namada::types::time::{DateTimeUtc, TimeZone, Utc};
use namada::types::token::{self, Amount};
use namada::types::transaction::{
hash_tx, process_tx, verify_decrypted_correctly, AffineCurve, DecryptedTx,
EllipticCurve, PairingEngine, TxType, WrapperTx,
EllipticCurve, PairingEngine, TxType, WrapperTx, MIN_FEE,
};
use namada::vm::wasm::{TxCache, VpCache};
use namada::vm::WasmCacheRwAccess;
Expand Down Expand Up @@ -585,10 +585,10 @@ where
masp()
};
// check that the fee payer has sufficient balance
let balance = self
.get_balance(&self.storage.native_token, &fee_payer);
let balance =
self.get_balance(&wrapper.fee.token, &fee_payer);

if Amount::from(100) > balance {
if Amount::from(MIN_FEE) > balance {
response.code = 1;
response.log = String::from(
"The address given does not have sufficient \
Expand Down
8 changes: 3 additions & 5 deletions apps/src/lib/node/ledger/shell/process_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,10 @@ where
masp()
};
// check that the fee payer has sufficient balance
let balance = self.get_balance(
&self.storage.native_token,
&fee_payer,
);
let balance =
self.get_balance(&tx.fee.token, &fee_payer);

if Amount::from(100) <= balance {
if Amount::from(MIN_FEE) <= balance {
TxResult {
code: ErrorCodes::Ok.into(),
info: "Process proposal accepted this \
Expand Down
2 changes: 2 additions & 0 deletions core/src/types/transaction/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub mod wrapper_tx {
hash_tx, EncryptionKey, Hash, TxError, TxType,
};

/// Minimum fee amount in micro NAMs
pub const MIN_FEE: u64 = 100;
/// TODO: Determine a sane number for this
const GAS_LIMIT_RESOLUTION: u64 = 1_000_000;

Expand Down

0 comments on commit d5cb262

Please sign in to comment.