Skip to content

Commit

Permalink
Added EVM CANCUN hard fork support. Changed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrLSD committed Apr 8, 2024
1 parent bca2394 commit ab47925
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 31 deletions.
33 changes: 16 additions & 17 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.39.1", default-features = false }
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.39.1", default-features = false, features = ["std"] }
evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.39.1", default-features = false, features = ["std", "tracing"] }
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.39.1", default-features = false, features = ["std", "tracing"] }
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "22b8129", default-features = false }
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "22b8129", default-features = false, features = ["std"] }
evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "22b8129", default-features = false, features = ["std", "tracing"] }
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "22b8129", default-features = false, features = ["std", "tracing"] }
fixed-hash = { version = "0.8", default-features = false }
function_name = "0.3"
git2 = "0.18"
Expand Down
4 changes: 2 additions & 2 deletions engine-tests/src/tests/repro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: 210,
near_gas_used: 211,
});
}

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: 170,
near_gas_used: 171,
});
}

Expand Down
6 changes: 2 additions & 4 deletions engine-tests/src/tests/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,8 @@ fn test_total_supply_accounting() {
})
.unwrap();
#[cfg(not(feature = "ext-connector"))]
assert_eq!(
get_total_supply(&mut runner),
INITIAL_BALANCE - TRANSFER_AMOUNT
);
// For CANCUN hard fork `total_supply` can't change
assert_eq!(get_total_supply(&mut runner), INITIAL_BALANCE);
}

#[test]
Expand Down
4 changes: 3 additions & 1 deletion engine-tests/src/tests/self_destruct_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use crate::utils::solidity::self_destruct::{

/// Check that account state should be properly removed after calling selfdestruct
#[test]
// For CANCUN hard fork SELFDESCTRUCT disabled
#[ignore]
fn test_self_destruct_reset_state() {
let mut signer = utils::Signer::random();
let mut runner = utils::deploy_runner();
Expand All @@ -29,7 +31,7 @@ fn test_self_destruct_reset_state() {
assert_eq!(counter_value, Some(1));
sd.finish(&mut runner);
let counter_value = sd.counter(&mut runner, &mut signer);
assert!(counter_value.is_none());
assert!(counter_value.is_some());

let sd_contract_addr1 = sd_factory.deploy(&mut runner, &mut signer);
assert_eq!(sd_contract_addr, sd_contract_addr1);
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/utils/solidity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ where
&source_mount_arg,
"-v",
&output_mount_arg,
"ethereum/solc:0.8.24", // TODO: 0.8.25 introduces support of the Dencun hard fork.
"ethereum/solc:0.8.25", // TODO: 0.8.25 introduces support of the Dencun hard fork.
"--allow-paths",
"/contracts/",
"-o",
Expand Down
12 changes: 10 additions & 2 deletions engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl EngineErrorKind {
Self::EvmError(ExitError::CallTooDeep) => errors::ERR_CALL_TOO_DEEP,
Self::EvmError(ExitError::CreateCollision) => errors::ERR_CREATE_COLLISION,
Self::EvmError(ExitError::CreateContractLimit) => errors::ERR_CREATE_CONTRACT_LIMIT,
Self::EvmError(ExitError::InvalidCode(_)) => errors::ERR_INVALID_OPCODE,
Self::EvmError(ExitError::InvalidCode(opcode)) => errors::ERR_INVALID_OPCODE,
Self::EvmError(ExitError::OutOfOffset) => errors::ERR_OUT_OF_OFFSET,
Self::EvmError(ExitError::OutOfGas) => errors::ERR_OUT_OF_GAS,
Self::EvmError(ExitError::OutOfFund) => errors::ERR_OUT_OF_FUND,
Expand Down Expand Up @@ -396,7 +396,7 @@ pub struct Engine<'env, I: IO, E: Env, M = AuroraModExp> {
modexp_algorithm: PhantomData<M>,
}

pub(crate) const CONFIG: &Config = &Config::shanghai();
pub(crate) const CONFIG: &Config = &Config::cancun();

impl<'env, I: IO + Copy, E: Env, M: ModExpAlgorithm> Engine<'env, I, E, M> {
pub fn new(
Expand Down Expand Up @@ -1918,6 +1918,14 @@ impl<'env, I: IO + Copy, E: Env, M: ModExpAlgorithm> Backend for Engine<'env, I,
fn original_storage(&self, address: H160, index: H256) -> Option<H256> {
Some(self.storage(address, index))
}

fn blob_gasprice(&self) -> Option<u128> {
Some(1)
}

fn get_blob_hash(&self, _index: usize) -> Result<U256, ExitError> {
Ok(U256::default())
}
}

impl<'env, J: IO + Copy, E: Env, M: ModExpAlgorithm> ApplyBackend for Engine<'env, J, E, M> {
Expand Down

0 comments on commit ab47925

Please sign in to comment.