Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add EIP-7702 - new type transaction #960

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ byte-slice-cast = { version = "1", default-features = false }
criterion = "0.5"
digest = "0.10"
ethabi = { version = "18", default-features = false }
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.45.4-aurora", default-features = false }
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.45.4-aurora", default-features = false, features = ["std"] }
evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.45.4-aurora", default-features = false, features = ["std", "tracing"] }
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.45.4-aurora", default-features = false, features = ["std", "tracing"] }
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v1.0-opt.8", default-features = false }
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v1.0-opt.8", default-features = false, features = ["std"] }
evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v1.0-opt.8", default-features = false, features = ["std", "tracing"] }
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v1.0-opt.8", default-features = false, features = ["std", "tracing"] }
fixed-hash = { version = "0.8", default-features = false }
function_name = "0.3"
git2 = "0.19"
Expand Down
10 changes: 3 additions & 7 deletions engine-precompiles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ use aurora_engine_sdk::env::Env;
use aurora_engine_sdk::io::IO;
use aurora_engine_sdk::promise::ReadOnlyPromiseHandler;
use aurora_engine_types::{account_id::AccountId, types::Address, vec, BTreeMap, BTreeSet, Box};
use evm::backend::Log;
use evm::executor::{
self,
stack::{PrecompileFailure, PrecompileHandle},
};
use evm::{backend::Log, executor::stack::IsPrecompileResult};
use evm::{Context, ExitError, ExitFatal, ExitSucceed};
use promise_result::PromiseResult;
use xcc::cross_contract_call;
Expand Down Expand Up @@ -156,12 +156,8 @@ impl<'a, I: IO + Copy, E: Env, H: ReadOnlyPromiseHandler> executor::stack::Preco
Some(result.and_then(|output| post_process(output, handle)))
}

fn is_precompile(&self, address: prelude::H160, _remaining_gas: u64) -> IsPrecompileResult {
let is_precompile = self.all_precompiles.contains_key(&Address::new(address));
IsPrecompileResult::Answer {
is_precompile,
extra_cost: 0,
}
fn is_precompile(&self, address: prelude::H160) -> bool {
self.all_precompiles.contains_key(&Address::new(address))
}
}

Expand Down
8 changes: 8 additions & 0 deletions engine-standalone-storage/src/sync/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ impl TransactionKind {
value,
data,
access_list: Vec::new(),
authorization_list: Vec::new(),
}
}
Self::Deploy(data) => {
Expand All @@ -236,6 +237,7 @@ impl TransactionKind {
value: Wei::zero(),
data,
access_list: Vec::new(),
authorization_list: Vec::new(),
}
}
Self::DeployErc20(_) => {
Expand All @@ -254,6 +256,7 @@ impl TransactionKind {
value: Wei::zero(),
data,
access_list: Vec::new(),
authorization_list: Vec::new(),
}
}
Self::FtOnTransfer(args) => {
Expand All @@ -275,6 +278,7 @@ impl TransactionKind {
value,
data: Vec::new(),
access_list: Vec::new(),
authorization_list: Vec::new(),
}
} else {
let from = Self::get_implicit_address(engine_account);
Expand Down Expand Up @@ -311,6 +315,7 @@ impl TransactionKind {
value: Wei::zero(),
data,
access_list: Vec::new(),
authorization_list: Vec::new(),
}
}
}
Expand Down Expand Up @@ -343,6 +348,7 @@ impl TransactionKind {
value,
data: Vec::new(),
access_list: Vec::new(),
authorization_list: Vec::new(),
}
},
|erc20_address| {
Expand Down Expand Up @@ -370,6 +376,7 @@ impl TransactionKind {
value: Wei::zero(),
data,
access_list: Vec::new(),
authorization_list: Vec::new(),
}
},
)
Expand Down Expand Up @@ -468,6 +475,7 @@ impl TransactionKind {
value: Wei::zero(),
data: method_name.as_bytes().to_vec(),
access_list: Vec::new(),
authorization_list: Vec::new(),
}
}

Expand Down
12 changes: 6 additions & 6 deletions engine-tests/src/tests/repro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn repro_GdASJ3KESs() {
block_timestamp: 1_645_717_564_644_206_730,
input_path: "src/tests/res/input_GdASJ3KESs.hex",
evm_gas_used: 706_713,
near_gas_used: 115,
near_gas_used: 113,
});
}

Expand All @@ -51,7 +51,7 @@ fn repro_8ru7VEA() {
block_timestamp: 1_648_829_935_343_349_589,
input_path: "src/tests/res/input_8ru7VEA.hex",
evm_gas_used: 1_732_181,
near_gas_used: 206,
near_gas_used: 202,
});
}

Expand All @@ -71,7 +71,7 @@ fn repro_FRcorNv() {
block_timestamp: 1_650_960_438_774_745_116,
input_path: "src/tests/res/input_FRcorNv.hex",
evm_gas_used: 1_239_721,
near_gas_used: 168,
near_gas_used: 163,
});
}

Expand All @@ -88,7 +88,7 @@ fn repro_5bEgfRQ() {
block_timestamp: 1_651_073_772_931_594_646,
input_path: "src/tests/res/input_5bEgfRQ.hex",
evm_gas_used: 6_414_105,
near_gas_used: 650,
near_gas_used: 508,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's always nice to see the gas costs go down when we move to a newer version of sputnikVM.

});
}

Expand All @@ -106,7 +106,7 @@ fn repro_D98vwmi() {
block_timestamp: 1_651_753_443_421_003_245,
input_path: "src/tests/res/input_D98vwmi.hex",
evm_gas_used: 1_035_348,
near_gas_used: 169,
near_gas_used: 164,
});
}

Expand All @@ -125,7 +125,7 @@ fn repro_Emufid2() {
block_timestamp: 1_662_118_048_636_713_538,
input_path: "src/tests/res/input_Emufid2.hex",
evm_gas_used: 1_156_364,
near_gas_used: 294,
near_gas_used: 293,
});
}

Expand Down
10 changes: 5 additions & 5 deletions engine-tests/src/tests/uniswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn test_uniswap_input_multihop() {

let (_amount_out, _evm_gas, profile) = context.exact_input(&tokens, INPUT_AMOUNT.into());

assert_eq!(108, profile.all_gas() / 1_000_000_000_000);
assert_eq!(107, profile.all_gas() / 1_000_000_000_000);
}

#[test]
Expand All @@ -53,17 +53,17 @@ fn test_uniswap_exact_output() {
utils::assert_gas_bound(profile.all_gas(), 32);
let wasm_fraction = 100 * profile.wasm_gas() / profile.all_gas();
assert!(
(40..=50).contains(&wasm_fraction),
"{wasm_fraction}% is not between 40% and 50%",
(37..=47).contains(&wasm_fraction),
"{wasm_fraction}% is not between 37% and 47%",
);

let (_amount_in, profile) =
context.exact_output_single(&token_a, &token_b, OUTPUT_AMOUNT.into());
utils::assert_gas_bound(profile.all_gas(), 17);
let wasm_fraction = 100 * profile.wasm_gas() / profile.all_gas();
assert!(
(40..=50).contains(&wasm_fraction),
"{wasm_fraction}% is not between 40% and 50%",
(37..=47).contains(&wasm_fraction),
"{wasm_fraction}% is not between 37% and 47%",
);
}

Expand Down
1 change: 1 addition & 0 deletions engine-tests/src/utils/solidity/erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,6 @@ pub fn legacy_into_normalized_tx(tx: TransactionLegacy) -> NormalizedEthTransact
value: tx.value,
data: tx.data,
access_list: Vec::new(),
authorization_list: Vec::new(),
}
}
3 changes: 3 additions & 0 deletions engine-transactions/src/backwards_compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ impl EthTransactionKindAdapter {
tx.transaction.to = None;
}
}
EthTransactionKind::Eip7702(_) => {
unreachable!();
}
}
}

Expand Down
Loading
Loading