Skip to content

Commit

Permalink
Updates gas scale, parameters and default. Updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Oct 28, 2024
1 parent 2107072 commit 0a867a1
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 53 deletions.
9 changes: 5 additions & 4 deletions crates/node/src/shell/prepare_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ mod test_prepare_proposal {
assert!(rsp.code != 0.into(), "{}", rsp.log);
}

const GAS_LIMIT: u64 = 300_000;
const GAS_LIMIT: u64 = 50_000;

/// Test that if a tx from the mempool is not a
/// WrapperTx type, it is not included in the
Expand Down Expand Up @@ -811,7 +811,7 @@ mod test_prepare_proposal {
let mut wrapper =
Tx::from_type(TxType::Wrapper(Box::new(WrapperTx::new(
Fee {
amount_per_gas_unit: DenominatedAmount::native(1.into()),
amount_per_gas_unit: DenominatedAmount::native(100.into()),
token: shell.state.in_mem().native_token.clone(),
},
keypair.ref_to(),
Expand Down Expand Up @@ -881,10 +881,11 @@ mod test_prepare_proposal {
let mut wrapper =
Tx::from_type(TxType::Wrapper(Box::new(WrapperTx::new(
Fee {
amount_per_gas_unit: DenominatedAmount::native(1.into()),
amount_per_gas_unit: DenominatedAmount::native(100.into()),
token: shell.state.in_mem().native_token.clone(),
},
keypair.ref_to(),
// FIXME: review all these gas limits in the tests
GAS_LIMIT.into(),
))));
wrapper.header.chain_id = shell.chain_id.clone();
Expand All @@ -897,7 +898,7 @@ mod test_prepare_proposal {

new_wrapper.update_header(TxType::Wrapper(Box::new(WrapperTx::new(
Fee {
amount_per_gas_unit: DenominatedAmount::native(1.into()),
amount_per_gas_unit: DenominatedAmount::native(100.into()),
token: shell.state.in_mem().native_token.clone(),
},
keypair_2.ref_to(),
Expand Down
10 changes: 4 additions & 6 deletions crates/node/src/shell/process_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,9 +1017,7 @@ mod test_process_proposal {
let mut outer_tx =
Tx::from_type(TxType::Wrapper(Box::new(WrapperTx::new(
Fee {
amount_per_gas_unit: DenominatedAmount::native(
Amount::from_uint(1, 0).expect("Test failed"),
),
amount_per_gas_unit: DenominatedAmount::native(100.into()),
token: shell.state.in_mem().native_token.clone(),
},
keypair.ref_to(),
Expand Down Expand Up @@ -1230,7 +1228,7 @@ mod test_process_proposal {
let mut wrapper =
Tx::from_type(TxType::Wrapper(Box::new(WrapperTx::new(
Fee {
amount_per_gas_unit: DenominatedAmount::native(1.into()),
amount_per_gas_unit: DenominatedAmount::native(100.into()),
token: shell.state.in_mem().native_token.clone(),
},
keypair.ref_to(),
Expand Down Expand Up @@ -1333,7 +1331,7 @@ mod test_process_proposal {
let mut wrapper =
Tx::from_type(TxType::Wrapper(Box::new(WrapperTx::new(
Fee {
amount_per_gas_unit: DenominatedAmount::native(1.into()),
amount_per_gas_unit: DenominatedAmount::native(100.into()),
token: shell.state.in_mem().native_token.clone(),
},
keypair.ref_to(),
Expand All @@ -1347,7 +1345,7 @@ mod test_process_proposal {

new_wrapper.update_header(TxType::Wrapper(Box::new(WrapperTx::new(
Fee {
amount_per_gas_unit: DenominatedAmount::native(1.into()),
amount_per_gas_unit: DenominatedAmount::native(100.into()),
token: shell.state.in_mem().native_token.clone(),
},
keypair_2.ref_to(),
Expand Down
2 changes: 1 addition & 1 deletion crates/sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub use {namada_io as io, namada_wallet as wallet};
use crate::masp::ShieldedContext;

/// Default gas-limit
pub const DEFAULT_GAS_LIMIT: u64 = 250_000;
pub const DEFAULT_GAS_LIMIT: u64 = 50_000;

/// An interface for high-level interaction with the Namada SDK
#[cfg_attr(feature = "async-send", async_trait::async_trait)]
Expand Down
6 changes: 3 additions & 3 deletions crates/tests/src/e2e/ibc_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ fn transfer(
"--port-id",
&port_id,
"--gas-limit",
"250000",
"60000",
"--node",
&rpc,
]);
Expand Down Expand Up @@ -1385,7 +1385,7 @@ fn propose_inflation(test: &Test) -> Result<Epoch> {
"--data-path",
proposal_json_path.to_str().unwrap(),
"--gas-limit",
"10000000",
"2000000",
"--node",
&rpc,
]);
Expand Down Expand Up @@ -1498,7 +1498,7 @@ fn propose_gas_token(test: &Test) -> Result<Epoch> {
"--data-path",
proposal_json_path.to_str().unwrap(),
"--gas-limit",
"10000000",
"2000000",
"--node",
&rpc,
]);
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/src/e2e/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,7 @@ fn proposal_change_shielded_reward() -> Result<()> {
"--data-path",
valid_proposal_json_path.to_str().unwrap(),
"--gas-limit",
"10000000",
"2000000",
"--node",
&validator_one_rpc,
]);
Expand Down
4 changes: 2 additions & 2 deletions crates/tests/src/integration/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ fn proposal_submission() -> Result<()> {
"--data-path",
valid_proposal_json_path.to_str().unwrap(),
"--gas-limit",
"11000000",
"2200000",
"--node",
&validator_one_rpc,
]);
Expand Down Expand Up @@ -1477,7 +1477,7 @@ fn implicit_account_reveal_pk() -> Result<()> {
"--signing-keys",
source,
"--gas-limit",
"11000000",
"2200000",
"--node",
&validator_one_rpc,
]
Expand Down
38 changes: 14 additions & 24 deletions crates/tests/src/integration/masp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,6 @@ fn masp_incentives() -> Result<()> {
CHRISTEL,
"--token",
NAM,
"--gas-limit",
"300000",
"--amount",
"1.451732",
"--signing-keys",
Expand Down Expand Up @@ -1193,7 +1191,7 @@ fn masp_txs_and_queries() -> Result<()> {
"--amount",
"20",
"--gas-limit",
"300000",
"60000",
"--gas-payer",
CHRISTEL_KEY,
"--node",
Expand Down Expand Up @@ -1530,7 +1528,7 @@ fn multiple_unfetched_txs_same_block() -> Result<()> {
let mut tx = Tx::try_from_json_bytes(&bytes).unwrap();
tx.add_wrapper(
tx::data::wrapper::Fee {
amount_per_gas_unit: DenominatedAmount::native(1.into()),
amount_per_gas_unit: DenominatedAmount::native(100.into()),
token: native_token.clone(),
},
pk.clone(),
Expand Down Expand Up @@ -1672,7 +1670,7 @@ fn expired_masp_tx() -> Result<()> {
tx.header.expiration = None;
tx.add_wrapper(
namada_sdk::tx::data::wrapper::Fee {
amount_per_gas_unit: DenominatedAmount::native(1.into()),
amount_per_gas_unit: DenominatedAmount::native(100.into()),
token: native_token.clone(),
},
pk.clone(),
Expand Down Expand Up @@ -2652,7 +2650,7 @@ fn masp_fee_payment() -> Result<()> {
)
});
assert!(captured.result.is_ok());
assert!(captured.contains("nam: 240000"));
assert!(captured.contains("nam: 440000"));
let captured = CapturedOutput::of(|| {
run(
&node,
Expand Down Expand Up @@ -2784,8 +2782,6 @@ fn masp_fee_payment_gas_limit() -> Result<()> {
NAM,
"--amount",
"1",
"--gas-limit",
"500000",
"--gas-price",
"1",
"--disposable-gas-payer",
Expand Down Expand Up @@ -2952,10 +2948,10 @@ fn masp_fee_payment_with_non_disposable() -> Result<()> {
NAM,
"--amount",
"1",
"--gas-limit",
"300000",
"--gas-price",
"1",
"--gas-limit",
"60000",
"--gas-payer",
ALBERT_KEY,
"--ledger-address",
Expand Down Expand Up @@ -2991,7 +2987,7 @@ fn masp_fee_payment_with_non_disposable() -> Result<()> {
)
});
assert!(captured.result.is_ok());
assert!(captured.contains("nam: 1699999"));
assert!(captured.contains("nam: 1939999"));

let captured = CapturedOutput::of(|| {
run(
Expand Down Expand Up @@ -3169,7 +3165,7 @@ fn masp_fee_payment_with_custom_spending_key() -> Result<()> {
"--amount",
"9000",
"--gas-limit",
"300000",
"60000",
"--gas-price",
"1",
"--gas-spending-key",
Expand Down Expand Up @@ -3226,7 +3222,7 @@ fn masp_fee_payment_with_custom_spending_key() -> Result<()> {
)
});
assert!(captured.result.is_ok());
assert!(captured.contains("nam: 1000"));
assert!(captured.contains("nam: 241000"));

let captured = CapturedOutput::of(|| {
run(
Expand Down Expand Up @@ -3439,10 +3435,10 @@ fn masp_fee_payment_with_different_token() -> Result<()> {
NAM,
"--amount",
"1",
"--gas-limit",
"60000",
"--gas-token",
BTC,
"--gas-limit",
"300000",
"--gas-price",
"1",
"--gas-spending-key",
Expand Down Expand Up @@ -3535,7 +3531,7 @@ fn masp_fee_payment_with_different_token() -> Result<()> {
)
});
assert!(captured.result.is_ok());
assert!(captured.contains("btc: 1000"));
assert!(captured.contains("btc: 241000"));

Ok(())
}
Expand Down Expand Up @@ -3584,8 +3580,6 @@ fn identical_output_descriptions() -> Result<()> {
NAM,
"--amount",
"1000",
"--gas-limit",
"300000",
"--gas-payer",
BERTHA_KEY,
"--output-folder-path",
Expand Down Expand Up @@ -3876,7 +3870,7 @@ fn masp_batch() -> Result<()> {
"--amount",
"1000",
"--gas-limit",
"300000",
"60000",
"--gas-payer",
CHRISTEL_KEY,
"--output-folder-path",
Expand Down Expand Up @@ -4111,7 +4105,7 @@ fn masp_atomic_batch() -> Result<()> {
"--amount",
"1000",
"--gas-limit",
"300000",
"60000",
"--gas-payer",
CHRISTEL_KEY,
"--output-folder-path",
Expand Down Expand Up @@ -4341,8 +4335,6 @@ fn tricky_masp_txs() -> Result<()> {
NAM,
"--amount",
"1000",
"--gas-limit",
"300000",
"--gas-payer",
CHRISTEL_KEY,
"--output-folder-path",
Expand Down Expand Up @@ -4438,8 +4430,6 @@ fn tricky_masp_txs() -> Result<()> {
NAM,
"--amount",
"1000",
"--gas-limit",
"300000",
"--gas-payer",
CHRISTEL_KEY,
"--output-folder-path",
Expand Down
8 changes: 4 additions & 4 deletions genesis/hardware/parameters.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ epochs_per_year = 31_536_000
# The multiplier for masp epochs
masp_epoch_multiplier = 2
# Max gas for block
max_block_gas = 15_000_000
max_block_gas = 3_000_000
# Masp fee payment gas limit
masp_fee_payment_gas_limit = 250_000
masp_fee_payment_gas_limit = 50_000
# Gas scale
gas_scale = 10_000
gas_scale = 50_000

# Map of the cost per gas unit for every token allowed for fee payment
[parameters.minimum_gas_price]
nam = "0.000001"
nam = "0.00001"

# Proof of stake parameters.
[pos_params]
Expand Down
8 changes: 4 additions & 4 deletions genesis/localnet/parameters.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ epochs_per_year = 31_536_000
# The multiplier for masp epochs
masp_epoch_multiplier = 2
# Max gas for block
max_block_gas = 15_000_000
max_block_gas = 3_000_000
# Masp fee payment gas limit
masp_fee_payment_gas_limit = 250_000
masp_fee_payment_gas_limit = 50_000
# Gas scale
gas_scale = 10_000
gas_scale = 50_000

# Map of the cost per gas unit for every token allowed for fee payment
[parameters.minimum_gas_price]
nam = "0.000001"
nam = "0.00001"

# Proof of stake parameters.
[pos_params]
Expand Down
8 changes: 4 additions & 4 deletions genesis/starter/parameters.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ epochs_per_year = 31_536_000
# The multiplier for masp epochs
masp_epoch_multiplier = 2
# Max gas for block
max_block_gas = 15_000_000
max_block_gas = 3_000_000
# Masp fee payment gas limit
masp_fee_payment_gas_limit = 250_000
masp_fee_payment_gas_limit = 50_000
# Gas scale
gas_scale = 10_000
gas_scale = 50_000

# Map of the cost per gas unit for every token allowed for fee payment
[parameters.minimum_gas_price]
nam = "0.000001"
nam = "0.00001"

# Proof of stake parameters.
[pos_params]
Expand Down

0 comments on commit 0a867a1

Please sign in to comment.