Skip to content

Commit

Permalink
fix: use shanghai config instead of london (#773)
Browse files Browse the repository at this point in the history
<!--
Thanks for submitting a pull request! Here are some helpful tips:

* Always create branches on and target the `develop` branch.
* Run all the tests locally and ensure that they are passing.
* Run `make format` to ensure that the code is formatted.
* Run `make check` to ensure that all checks passed successfully.
* Small commits and contributions that attempt one single goal is
preferable.
* If the idea changes or adds anything functional which will affect
users, an
AIP discussion is required first on the Aurora forum: 

https://forum.aurora.dev/discussions/AIPs%20(Aurora%20Improvement%20Proposals).
* Avoid breaking the public API (namely in engine/src/lib.rs) unless
required.
* If your PR is a WIP, ensure that you enable "draft" mode.
* Your first PRs won't use the CI automatically unless a maintainer
starts.
If this is not your first PR, please do NOT abuse the CI resources.

Checklist:
- [ ] I have performed a self-review of my code
- [ ] I have documented my code, particularly in the hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests to prove my fix or new feature is effective and
works
- [ ] Any dependent changes have been merged
- [ ] The PR is targeting the `develop` branch and not `master`
- [ ] I have pre-squashed my commits into a single commit and rebased.
-->

## Description

Engine is configured with Shanghai hardfork now. No other changes.

## Performance / NEAR gas cost considerations
N/A
<!--
Performance regressions are not ideal, though we welcome performance 
improvements. Any PR must be completely mindful of any gas cost
increases. The
CI will fail if the gas costs change at all. Do update these tests to 
accommodate for the new gas changes. It is good to explain 
this change, if necessary.
-->

## Testing
N/A
<!--
Please describe the tests that you ran to verify your changes.
-->

## How should this be reviewed
N/A
<!--
Include any recommendations of areas to be careful of to ensure that the
reviewers use extra attention.
-->

## Additional information
N/A
<!--
Include any additional information which you think should be in this PR,
such
as prior arts, future extensions, unresolved problems, or a TODO list
which
should be followed up.
-->

---------

Co-authored-by: Oleksandr Anyshchenko <oleksandr.anyshchenko@aurora.dev>
  • Loading branch information
2 people authored and joshuajbouw committed Jul 21, 2023
1 parent e928c8d commit 064e353
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions engine-tests/src/tests/erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn erc20_mint_out_of_gas() {

// not enough gas to cover intrinsic cost
let intrinsic_gas = test_utils::erc20::legacy_into_normalized_tx(mint_tx.clone())
.intrinsic_gas(&evm::Config::istanbul())
.intrinsic_gas(&evm::Config::shanghai())
.unwrap();
mint_tx.gas_limit = (intrinsic_gas - 1).into();
let error = runner
Expand Down Expand Up @@ -214,7 +214,7 @@ fn deploy_erc_20_out_of_gas() {

// not enough gas to cover intrinsic cost
let intrinsic_gas = test_utils::erc20::legacy_into_normalized_tx(deploy_transaction.clone())
.intrinsic_gas(&evm::Config::istanbul())
.intrinsic_gas(&evm::Config::shanghai())
.unwrap();
deploy_transaction.gas_limit = (intrinsic_gas - 1).into();
let error = runner
Expand Down
15 changes: 14 additions & 1 deletion engine-transactions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl NormalizedEthTransaction {
let is_contract_creation = self.to.is_none();

let base_gas = if is_contract_creation {
config.gas_transaction_create
config.gas_transaction_create + init_code_cost(config, &self.data)?
} else {
config.gas_transaction_call
};
Expand Down Expand Up @@ -185,6 +185,19 @@ impl NormalizedEthTransaction {
}
}

fn init_code_cost(config: &evm::Config, data: &[u8]) -> Result<u64, Error> {
// As per EIP-3860:
// > We define initcode_cost(initcode) to equal INITCODE_WORD_COST * ceil(len(initcode) / 32).
// where INITCODE_WORD_COST is 2.
let init_code_cost = if config.max_initcode_size.is_some() {
2 * ((u64::try_from(data.len()).map_err(|_| Error::IntegerConversion)? + 31) / 32)
} else {
0
};

Ok(init_code_cost)
}

#[derive(Debug, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
pub enum Error {
Expand Down
2 changes: 1 addition & 1 deletion engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ pub struct Engine<'env, I: IO, E: Env, M = AuroraModExp> {
modexp_algorithm: PhantomData<M>,
}

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

impl<'env, I: IO + Copy, E: Env, M: ModExpAlgorithm> Engine<'env, I, E, M> {
pub fn new(
Expand Down

0 comments on commit 064e353

Please sign in to comment.