Skip to content

Commit

Permalink
chore: use cached nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksuss committed Feb 8, 2023
1 parent ee56b0a commit 9c91d91
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 99 deletions.
2 changes: 1 addition & 1 deletion engine-precompiles/src/promise_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub mod costs {
use crate::prelude::types::EthGas;

/// This cost is always charged for calling this precompile.
pub const PROMISE_RESULT_BASE_COST: EthGas = EthGas::new(105);
pub const PROMISE_RESULT_BASE_COST: EthGas = EthGas::new(53);
/// This is the cost per byte of promise result data.
pub const PROMISE_RESULT_BYTE_COST: EthGas = EthGas::new(1);
}
Expand Down
2 changes: 1 addition & 1 deletion engine-standalone-storage/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ fn non_submit_execute<'db>(

if env.predecessor_account_id == env.current_account_id {
connector::EthConnectorContract::init_instance(io)?
.ft_on_transfer(&engine, args)?;
.ft_on_transfer(&mut engine, args)?;
} else {
engine.receive_erc20_tokens(
&env.predecessor_account_id,
Expand Down
4 changes: 3 additions & 1 deletion engine-tests/src/test_utils/standalone/mocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ pub fn mint_evm_account<I: IO + Copy, E: Env>(
hex::encode(address.as_bytes())
),
};
connector.ft_on_transfer(&engine, &transfer_args).unwrap();
connector
.ft_on_transfer(&mut engine, &transfer_args)
.unwrap();

engine.apply(std::iter::once(state_change), std::iter::empty(), false);
}
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/tests/one_inch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn test_1inch_liquidity_protocol() {
},
);
assert!(result.gas_used >= 302_000); // more than 302k EVM gas used
assert_gas_bound(profile.all_gas(), 23);
assert_gas_bound(profile.all_gas(), 22);

// Same here
helper.runner.context.block_timestamp += 10_000_000 * 1_000_000_000;
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/tests/repro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn repro_FRcorNv() {
block_timestamp: 1650960438774745116,
input_path: "src/tests/res/input_FRcorNv.hex",
evm_gas_used: 1239721,
near_gas_used: 181,
near_gas_used: 180,
});
}

Expand Down
12 changes: 8 additions & 4 deletions engine/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,15 @@ impl<I: IO + Copy> EthConnectorContract<I> {
}

/// Mint ETH tokens
fn mint_eth_on_aurora(
fn mint_eth_on_aurora<'env, E: Env>(
&mut self,
engine: &mut Engine<'env, I, E>,
owner_id: Address,
amount: Wei,
) -> Result<(), fungible_token::error::DepositError> {
sdk::log!("Mint {} ETH tokens for: {}", amount, owner_id.encode());
self.ft.internal_deposit_eth_to_aurora(owner_id, amount)
self.ft
.internal_deposit_eth_to_aurora(engine, owner_id, amount)
}

/// Burn ETH tokens
Expand Down Expand Up @@ -575,7 +577,7 @@ impl<I: IO + Copy> EthConnectorContract<I> {
/// ft_on_transfer callback function
pub fn ft_on_transfer<'env, E: Env>(
&mut self,
engine: &Engine<'env, I, E>,
engine: &mut Engine<'env, I, E>,
args: &NEP141FtOnTransferArgs,
) -> Result<(), error::FtTransferCallError> {
sdk::log!("Call ft_on_transfer");
Expand All @@ -590,12 +592,14 @@ impl<I: IO + Copy> EthConnectorContract<I> {
match (wei_fee, relayer) {
(fee, Some(evm_relayer_address)) if fee > ZERO_WEI => {
self.mint_eth_on_aurora(
engine,
message_data.recipient,
Wei::new(U256::from(args.amount.as_u128())) - fee,
)?;
self.mint_eth_on_aurora(evm_relayer_address, fee)?;
self.mint_eth_on_aurora(engine, evm_relayer_address, fee)?;
}
_ => self.mint_eth_on_aurora(
engine,
message_data.recipient,
Wei::new(U256::from(args.amount.as_u128())),
)?,
Expand Down
Loading

0 comments on commit 9c91d91

Please sign in to comment.