Skip to content

Commit

Permalink
feat: use actual resource cost (keep-starknet-strange#1139)
Browse files Browse the repository at this point in the history
  • Loading branch information
trbutler4 authored Oct 3, 2023
1 parent 4874045 commit 6d0d5f7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next release

- feat: use actual vm resource costs
- fix: add setup and run for rpc tests
- fix: fix clap for run command
- fix: add `madara_path` flag for setup command
Expand Down
2 changes: 1 addition & 1 deletion crates/pallets/starknet/src/tests/deploy_account_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn given_contract_run_deploy_account_tx_works() {
data: EventData(vec![
address.0.0, // From
StarkFelt::try_from("0xdead").unwrap(), // To
StarkFelt::try_from("0xa582").unwrap(), // Amount low
StarkFelt::try_from("0x195a").unwrap(), // Amount low
StarkFelt::from(0u128), // Amount high
]),
},
Expand Down
4 changes: 2 additions & 2 deletions crates/pallets/starknet/src/tests/erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn given_erc20_transfer_when_invoke_then_it_works() {
sender_account.0.0, // From
StarkFelt::try_from("0x000000000000000000000000000000000000000000000000000000000000dead")
.unwrap(), // Sequencer address
StarkFelt::try_from("0x0000000000000000000000000000000000000000000000000000000000028942")
StarkFelt::try_from("0x00000000000000000000000000000000000000000000000000000000000198de")
.unwrap(), // Amount low
StarkFelt::from(0u128), // Amount high
]),
Expand Down Expand Up @@ -198,7 +198,7 @@ fn given_erc20_transfer_when_invoke_then_it_works() {
data: EventData(vec![
sender_account.0.0, // From
StarkFelt::try_from("0xdead").unwrap(), // Sequencer address
StarkFelt::try_from("0x1b85a").unwrap(), // Amount low
StarkFelt::try_from("0xf118").unwrap(), // Amount low
StarkFelt::from(0u128), // Amount high
])},
from_address: Starknet::fee_token_address(),
Expand Down
4 changes: 2 additions & 2 deletions crates/pallets/starknet/src/tests/invoke_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn given_hardcoded_contract_run_invoke_tx_then_it_works() {
StarkFelt::try_from(BLOCKIFIER_ACCOUNT_ADDRESS).unwrap(),
StarkFelt::try_from("0x000000000000000000000000000000000000000000000000000000000000dead")
.unwrap(),
StarkFelt::try_from("0x000000000000000000000000000000000000000000000000000000000000a136")
StarkFelt::try_from("0x00000000000000000000000000000000000000000000000000000000000001a4")
.unwrap(),
StarkFelt::from(0u128),
]),
Expand Down Expand Up @@ -142,7 +142,7 @@ fn given_hardcoded_contract_run_invoke_tx_then_event_is_emitted() {
StarkFelt::try_from("0x01a3339ec92ac1061e3e0f8e704106286c642eaf302e94a582e5f95ef5e6b4d0")
.unwrap(), // From
StarkFelt::try_from("0xdead").unwrap(), // To
StarkFelt::try_from("0xa334").unwrap(), // Amount low
StarkFelt::try_from("0x1a4").unwrap(), // Amount low
StarkFelt::from(0u128), // Amount high
]),
},
Expand Down
17 changes: 7 additions & 10 deletions crates/primitives/fee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,14 @@ pub const FEE_TRANSFER_N_STORAGE_CHANGES: u8 = 2; // Sender and sequencer balanc
/// Number of storage updates to actually charge for the fee transfer tx.
pub const FEE_TRANSFER_N_STORAGE_CHANGES_TO_CHARGE: u8 = FEE_TRANSFER_N_STORAGE_CHANGES - 1; // Exclude the sequencer balance update, since it's charged once throughout the batch.

// TODO: add real values here.
// FIXME: https://github.com/keep-starknet-strange/madara/issues/330
static VM_RESOURCE_FEE_COSTS: phf::Map<&'static str, f64> = phf_map! {
"n_steps" => 1_f64,
"pedersen_builtin" => 1_f64,
"range_check_builtin" => 1_f64,
"ecdsa_builtin" => 1_f64,
"bitwise_builtin" => 1_f64,
"poseidon_builtin" => 1_f64,
"output_builtin" => 1_f64,
"ec_op_builtin" => 1_f64,
"n_steps" => 0.01_f64,
"pedersen_builtin" => 0.32_f64,
"range_check_builtin" => 0.16_f64,
"ecdsa_builtin" => 20.48_f64,
"bitwise_builtin" => 0.64_f64,
"poseidon_builtin" => 0.32_f64,
"ec_op_builtin" => 10.24_f64,
};

/// Gets the transaction resources.
Expand Down

0 comments on commit 6d0d5f7

Please sign in to comment.