Skip to content

Commit

Permalink
switch to shanghai hardfork
Browse files Browse the repository at this point in the history
  • Loading branch information
zjb0807 committed Jan 22, 2024
1 parent 3b80a3d commit b283c51
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 39 deletions.
4 changes: 2 additions & 2 deletions modules/asset-registry/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ pub fn deploy_contracts() {
H256::from_slice(&buf).as_bytes().to_vec()
},
}],
used_gas: 1235081,
used_gas: 1235455,
used_storage: 5131,
}));

Expand Down Expand Up @@ -242,7 +242,7 @@ pub fn deploy_contracts_same_prefix() {
H256::from_slice(&buf).as_bytes().to_vec()
},
}],
used_gas: 1235081,
used_gas: 1235455,
used_storage: 5131,
}));

Expand Down
2 changes: 1 addition & 1 deletion modules/currencies/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ pub fn deploy_contracts() {
H256::from_slice(&buf).as_bytes().to_vec()
},
}],
used_gas: 1235081,
used_gas: 1235455,
used_storage: 5131,
}));

Expand Down
6 changes: 3 additions & 3 deletions modules/evm-bridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub fn deploy_contracts() {
H256::from_slice(&buf).as_bytes().to_vec()
},
}],
used_gas: 1235081,
used_gas: 1235455,
used_storage: 5131,
}));

Expand All @@ -230,7 +230,7 @@ pub fn deploy_liquidation_ok_contracts() {
from: alice_evm_addr(),
contract: erc20_address(),
logs: vec![],
used_gas: 235274,
used_gas: 235330,
used_storage: 844,
}));

Expand All @@ -257,7 +257,7 @@ pub fn deploy_liquidation_err_contracts() {
from: alice_evm_addr(),
contract: erc20_address(),
logs: vec![],
used_gas: 228284,
used_gas: 228338,
used_storage: 818,
}));

Expand Down
8 changes: 7 additions & 1 deletion modules/evm/src/bench/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ fn whitelist_keys(b: &mut Bencher, from: H160, code: Vec<u8>) -> H160 {
let state = SubstrateStackState::<Runtime>::new(&vicinity, metadata);
let mut executor = StackExecutor::new_with_precompiles(state, config, &());

let mut runtime = EVMRuntime::new(Rc::new(code.clone()), Rc::new(Vec::new()), context, config);
let mut runtime = EVMRuntime::new(
Rc::new(code.clone()),
Rc::new(Vec::new()),
context,
config.stack_limit,
config.memory_limit,
);
let reason = executor.execute(&mut runtime);

assert!(reason.is_succeed(), "{:?}", reason);
Expand Down
6 changes: 3 additions & 3 deletions modules/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ pub type NegativeImbalanceOf<T> =
pub const RESERVE_ID_STORAGE_DEPOSIT: ReserveIdentifier = ReserveIdentifier::EvmStorageDeposit;
pub const RESERVE_ID_DEVELOPER_DEPOSIT: ReserveIdentifier = ReserveIdentifier::EvmDeveloperDeposit;

// Initially based on London hard fork configuration.
// Initially based on shanghai hard fork configuration.
static ACALA_CONFIG: EvmConfig = EvmConfig {
refund_sstore_clears: 0, // no gas refund
sstore_gas_metering: false, // no gas refund
sstore_revert_under_stipend: false, // ignored
create_contract_limit: Some(MaxCodeSize::get() as usize),
..module_evm_utility::evm::Config::london()
..module_evm_utility::evm::Config::shanghai()
};

/// Create an empty contract `contract Empty { }`.
pub const BASE_CREATE_GAS: u64 = 67_066;
pub const BASE_CREATE_GAS: u64 = 67_072;
/// Call function that just set a storage `function store(uint256 num) public { number = num; }`.
pub const BASE_CALL_GAS: u64 = 43_702;

Expand Down
2 changes: 1 addition & 1 deletion modules/evm/src/runner/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// Synchronize with https://github.com/rust-blockchain/evm/blob/6534c1dd/src/executor/stack/executor.rs
// Synchronize with https://github.com/rust-blockchain/evm/blob/d543f10/src/executor/stack/executor.rs

use crate::{
encode_revert_message,
Expand Down
22 changes: 11 additions & 11 deletions modules/evm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ fn publish_factory() {
)
.unwrap();
assert_eq!(result.exit_reason, ExitReason::Succeed(ExitSucceed::Returned));
assert_eq!(result.used_gas.as_u64(), 155_879u64);
assert_eq!(result.used_gas.as_u64(), 155925);
assert_eq!(result.used_storage, 461);
assert_eq!(
balance(alice()),
Expand Down Expand Up @@ -818,7 +818,7 @@ fn create_nft_contract_works() {
from: NetworkContractSource::get(),
contract: MIRRORED_TOKENS_ADDRESS_START | H160::from_low_u64_be(MIRRORED_NFT_ADDRESS_START),
logs: vec![],
used_gas: 93183,
used_gas: 93197,
used_storage: 284,
}));
assert_eq!(EVM::network_contract_index(), MIRRORED_NFT_ADDRESS_START + 1);
Expand Down Expand Up @@ -888,7 +888,7 @@ fn create_predeploy_contract_works() {
from: NetworkContractSource::get(),
contract: addr,
logs: vec![],
used_gas: 93183,
used_gas: 93197,
used_storage: 284,
}));

Expand Down Expand Up @@ -1877,7 +1877,7 @@ fn evm_execute_mode_should_work() {
CallInfo {
exit_reason: ExitReason::Succeed(ExitSucceed::Stopped),
value: vec![],
used_gas: U256::from(142_445),
used_gas: U256::from(142451),
used_storage: expected_used_storage,
logs: vec![]
}
Expand All @@ -1904,7 +1904,7 @@ fn evm_execute_mode_should_work() {
CallInfo {
exit_reason: ExitReason::Succeed(ExitSucceed::Stopped),
value: vec![],
used_gas: U256::from(259_561),
used_gas: U256::from(259573),
used_storage: expected_used_storage,
logs: vec![]
}
Expand Down Expand Up @@ -1964,7 +1964,7 @@ fn evm_execute_mode_should_work() {
CallInfo {
exit_reason: ExitReason::Succeed(ExitSucceed::Stopped),
value: vec![],
used_gas: U256::from(110_469),
used_gas: U256::from(110475),
used_storage: expected_used_storage,
logs: vec![]
}
Expand Down Expand Up @@ -2007,7 +2007,7 @@ fn evm_execute_mode_should_work() {
CallInfo {
exit_reason: ExitReason::Succeed(ExitSucceed::Stopped),
value: vec![],
used_gas: U256::from(93_369),
used_gas: U256::from(93375),
used_storage: expected_used_storage,
logs: vec![]
}
Expand Down Expand Up @@ -2293,7 +2293,7 @@ fn auto_publish_works() {
from: alice(),
contract: factory,
logs: vec![],
used_gas: 593209,
used_gas: 593369,
used_storage: 2609,
}));

Expand Down Expand Up @@ -2328,7 +2328,7 @@ fn auto_publish_works() {
data: vec![],
},
],
used_gas: 387664,
used_gas: 387768,
used_storage: 1530,
}));

Expand Down Expand Up @@ -2398,7 +2398,7 @@ fn auto_publish_works() {
data: vec![],
},
],
used_gas: 370564,
used_gas: 370668,
used_storage: 1466,
}));

Expand Down Expand Up @@ -2455,7 +2455,7 @@ fn auto_publish_works() {
],
data: vec![],
}],
used_gas: 147214,
used_gas: 147228,
used_storage: 407,
}));

Expand Down
2 changes: 1 addition & 1 deletion modules/honzon-bridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pub fn deploy_contracts() {
H256::from_slice(&buf).as_bytes().to_vec()
},
}],
used_gas: 1235081,
used_gas: 1235455,
used_storage: 5131,
}));

Expand Down
19 changes: 11 additions & 8 deletions runtime/common/src/bench/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
pub use crate::{precompile::mock::*, DEXPrecompile, EVMPrecompile, OraclePrecompile};
use frame_support::assert_ok;
use hex_literal::hex;
use module_evm::{precompiles::Precompile, Context};
use module_evm::{
precompiles::{tests::MockPrecompileHandle, Precompile},
Context,
};
use module_support::AddressMapping;
use orml_traits::DataFeeder;
use primitives::currency::{AssetMetadata, TokenInfo};
Expand Down Expand Up @@ -121,7 +124,7 @@ fn oracle_get_price(b: &mut Bencher) {
"};

let resp = b
.bench(|| OraclePrecompile::<Test>::execute(&input, None, &context, false))
.bench(|| OraclePrecompile::<Test>::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)))
.unwrap();

assert_eq!(resp.output, expected_output);
Expand All @@ -148,7 +151,7 @@ fn evm_query_new_contract_extra_bytes(b: &mut Bencher) {
"};

let resp = b
.bench(|| EVMPrecompile::<Test>::execute(&input, None, &context, false))
.bench(|| EVMPrecompile::<Test>::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)))
.unwrap();

assert_eq!(resp.output, expected_output);
Expand All @@ -175,7 +178,7 @@ fn evm_query_storage_deposit_per_byte(b: &mut Bencher) {
"};

let resp = b
.bench(|| EVMPrecompile::<Test>::execute(&input, None, &context, false))
.bench(|| EVMPrecompile::<Test>::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)))
.unwrap();

assert_eq!(resp.output, expected_output);
Expand Down Expand Up @@ -216,7 +219,7 @@ fn evm_query_maintainer(b: &mut Bencher) {
"};

let resp = b
.bench(|| EVMPrecompile::<Test>::execute(&input, None, &context, false))
.bench(|| EVMPrecompile::<Test>::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)))
.unwrap();

assert_eq!(resp.output, expected_output);
Expand All @@ -243,7 +246,7 @@ fn evm_query_developer_deposit(b: &mut Bencher) {
"};

let resp = b
.bench(|| EVMPrecompile::<Test>::execute(&input, None, &context, false))
.bench(|| EVMPrecompile::<Test>::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)))
.unwrap();
assert_eq!(resp.output, expected_output);
}
Expand All @@ -269,7 +272,7 @@ fn evm_query_publication_fee(b: &mut Bencher) {
"};

let resp = b
.bench(|| EVMPrecompile::<Test>::execute(&input, None, &context, false))
.bench(|| EVMPrecompile::<Test>::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)))
.unwrap();
assert_eq!(resp.output, expected_output);
}
Expand Down Expand Up @@ -297,7 +300,7 @@ fn evm_query_developer_status(b: &mut Bencher) {
"};

let resp = b
.bench(|| EVMPrecompile::<Test>::execute(&input, None, &context, false))
.bench(|| EVMPrecompile::<Test>::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)))
.unwrap();
assert_eq!(resp.output, expected_output);
}
Expand Down
8 changes: 4 additions & 4 deletions runtime/integration-tests/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn deploy_erc20_contracts() {
H256::from_slice(&buf).as_bytes().to_vec()
},
}],
used_gas: 1235081,
used_gas: 1235455,
used_storage: 15130,
}));

Expand Down Expand Up @@ -143,7 +143,7 @@ pub fn deploy_erc20_contracts() {
H256::from_slice(&buf).as_bytes().to_vec()
},
}],
used_gas: 1235081,
used_gas: 1235455,
used_storage: 15130,
}));

Expand Down Expand Up @@ -349,7 +349,7 @@ fn test_evm_module() {
from: alice_address,
contract,
logs: vec![],
used_gas: 132199,
used_gas: 132225,
used_storage: 10367,
}));

Expand Down Expand Up @@ -1136,7 +1136,7 @@ fn create_contract_use_none_native_token_to_charge_storage() {
from: EvmAddress::from_str("0x414d1f1c39e8357acfa07e8aac63cc5da8f9ca4d").unwrap(),
contract: EvmAddress::from_str("0xa764c25fe7641aeb21ac08118fa343093b9cb30d").unwrap(),
logs: vec![],
used_gas: 132199,
used_gas: 132225,
used_storage: 10367,
}));
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/integration-tests/src/honzon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub fn deploy_liquidation_contracts() {
from: repayment_evm_addr(),
contract: mock_liquidation_address_0(),
logs: vec![],
used_gas: 473252,
used_gas: 473376,
used_storage: 11949,
}));

Expand All @@ -117,7 +117,7 @@ pub fn deploy_liquidation_contracts() {
from: repayment_evm_addr(),
contract: mock_liquidation_address_1(),
logs: vec![],
used_gas: 473252,
used_gas: 473376,
used_storage: 11949,
}));

Expand Down
4 changes: 2 additions & 2 deletions runtime/mandala/src/benchmarking/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ fn deploy_contract(caller: AccountId) -> Result<H160, DispatchError> {
from: module_evm_accounts::EvmAddressMapping::<Runtime>::get_evm_address(&caller).unwrap(),
contract: contract_addr(),
logs: vec![],
used_gas: 132_199,
used_storage: 10_367,
used_gas: 132225,
used_storage: 10367,
}));
Ok(contract_addr())
}
Expand Down

0 comments on commit b283c51

Please sign in to comment.