diff --git a/CHANGELOG.md b/CHANGELOG.md index c180bb05e..056a1117b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## OpenEthereum v3.3.2 + +Enhancements: +* London hardfork block: Sokol (24114400) + +Bug fixes: +* Fix for maxPriorityFeePerGas overflow + ## OpenEthereum v3.3.1 Enhancements: diff --git a/Cargo.lock b/Cargo.lock index a93fe9493..26d95cddd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2932,7 +2932,7 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "openethereum" -version = "3.3.1" +version = "3.3.2" dependencies = [ "ansi_term 0.10.2", "atty", @@ -3282,7 +3282,7 @@ dependencies = [ [[package]] name = "parity-version" -version = "3.3.1" +version = "3.3.2" dependencies = [ "parity-bytes", "rlp", diff --git a/Cargo.toml b/Cargo.toml index 974e1fea6..740f27fea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ description = "OpenEthereum" name = "openethereum" # NOTE Make sure to update util/version/Cargo.toml as well -version = "3.3.1" +version = "3.3.2" license = "GPL-3.0" authors = [ "OpenEthereum developers", diff --git a/crates/ethcore/res/chainspec/poasokol.json b/crates/ethcore/res/chainspec/poasokol.json index 891b7312d..1de52e2fb 100644 --- a/crates/ethcore/res/chainspec/poasokol.json +++ b/crates/ethcore/res/chainspec/poasokol.json @@ -52,7 +52,16 @@ "eip1884Transition": 12095200, "eip2028Transition": 12095200, "eip2929Transition": 21050600, - "eip2930Transition": 21050600 + "eip2930Transition": 21050600, + "eip3198Transition": 24114400, + "eip3529Transition": 24114400, + "eip3541Transition": 24114400, + "eip1559Transition": 24114400, + "eip1559BaseFeeMaxChangeDenominator": "0x8", + "eip1559ElasticityMultiplier": "0x2", + "eip1559BaseFeeInitialValue": "0x3b9aca00", + "eip1559FeeCollector": "0xE8DDc5c7A2d2F0D7a9798459c0104fDf5E987ACA", + "eip1559FeeCollectorTransition": 24114400 }, "genesis": { "seal": { diff --git a/crates/ethcore/src/executive.rs b/crates/ethcore/src/executive.rs index b918ec05f..94f036cd8 100644 --- a/crates/ethcore/src/executive.rs +++ b/crates/ethcore/src/executive.rs @@ -2760,6 +2760,127 @@ mod tests { } } + evm_test! {test_too_big_max_priority_fee_with_not_enough_cash: test_too_big_max_priority_fee_with_not_enough_cash_int} + fn test_too_big_max_priority_fee_with_not_enough_cash(factory: Factory) { + let keypair = Random.generate(); + let max_priority_fee_per_gas /* 2**256 - 1 */ = U256::from(340282366920938463463374607431768211455u128) + * U256::from(340282366920938463463374607431768211455u128) + + U256::from(340282366920938463463374607431768211455u128) + + U256::from(340282366920938463463374607431768211455u128); + let t = TypedTransaction::EIP1559Transaction(EIP1559TransactionTx { + transaction: AccessListTx::new( + Transaction { + action: Action::Create, + value: U256::from(17), + data: "3331600055".from_hex().unwrap(), + gas: U256::from(100_000), + gas_price: max_priority_fee_per_gas, + nonce: U256::zero(), + }, + vec![ + ( + H160::from_low_u64_be(10), + vec![H256::from_low_u64_be(102), H256::from_low_u64_be(103)], + ), + (H160::from_low_u64_be(400), vec![]), + ], + ), + max_priority_fee_per_gas, + }) + .sign(keypair.secret(), None); + + let sender = t.sender(); + + let mut state = get_temp_state_with_factory(factory); + state + .add_balance(&sender, &U256::from(15000017), CleanupMode::NoEmpty) + .unwrap(); + let mut info = EnvInfo::default(); + info.gas_limit = U256::from(100_000); + info.base_fee = Some(U256::from(100)); + let machine = make_london_machine(0); + let schedule = machine.schedule(info.number); + + let res = { + let mut ex = Executive::new(&mut state, &info, &machine, &schedule); + let opts = TransactOptions::with_no_tracing(); + ex.transact(&t, opts) + }; + + match res { + Err(ExecutionError::NotEnoughCash { required, got }) + if required + == U512::from(max_priority_fee_per_gas) * U512::from(100_000) + + U512::from(17) + && got == U512::from(15000017) => + { + () + } + _ => assert!(false, "Expected not enough cash error. {:?}", res), + } + } + + evm_test! {test_too_big_max_priority_fee_with_less_max_fee_per_gas: test_too_big_max_priority_fee_with_less_max_fee_per_gas_int} + fn test_too_big_max_priority_fee_with_less_max_fee_per_gas(factory: Factory) { + let keypair = Random.generate(); + let max_priority_fee_per_gas /* 2**256 - 1 */ = U256::from(340282366920938463463374607431768211455u128) + * U256::from(340282366920938463463374607431768211455u128) + + U256::from(340282366920938463463374607431768211455u128) + + U256::from(340282366920938463463374607431768211455u128); + let t = TypedTransaction::EIP1559Transaction(EIP1559TransactionTx { + transaction: AccessListTx::new( + Transaction { + action: Action::Create, + value: U256::from(17), + data: "3331600055".from_hex().unwrap(), + gas: U256::from(100_000), + gas_price: U256::from(150), + nonce: U256::zero(), + }, + vec![ + ( + H160::from_low_u64_be(10), + vec![H256::from_low_u64_be(102), H256::from_low_u64_be(103)], + ), + (H160::from_low_u64_be(400), vec![]), + ], + ), + max_priority_fee_per_gas, + }) + .sign(keypair.secret(), None); + + let sender = t.sender(); + + let mut state = get_temp_state_with_factory(factory); + state + .add_balance(&sender, &U256::from(15000017), CleanupMode::NoEmpty) + .unwrap(); + let mut info = EnvInfo::default(); + info.gas_limit = U256::from(100_000); + info.base_fee = Some(U256::from(100)); + let machine = make_london_machine(0); + let schedule = machine.schedule(info.number); + + let res = { + let mut ex = Executive::new(&mut state, &info, &machine, &schedule); + let opts = TransactOptions::with_no_tracing(); + ex.transact(&t, opts) + }; + + match res { + Err(ExecutionError::TransactionMalformed(err)) + if err.contains("maxPriorityFeePerGas higher than maxFeePerGas") => + { + () + } + _ => assert!( + false, + "Expected maxPriorityFeePerGas higher than maxFeePerGas error. {:?}", + res + ), + } + } + evm_test! {test_keccak: test_keccak_int} fn test_keccak(factory: Factory) { let code = "6064640fffffffff20600055".from_hex().unwrap(); diff --git a/crates/ethcore/types/src/transaction/transaction.rs b/crates/ethcore/types/src/transaction/transaction.rs index 7f6d1a234..49d9afa69 100644 --- a/crates/ethcore/types/src/transaction/transaction.rs +++ b/crates/ethcore/types/src/transaction/transaction.rs @@ -634,10 +634,16 @@ impl TypedTransaction { pub fn effective_gas_price(&self, block_base_fee: Option) -> U256 { match self { - Self::EIP1559Transaction(tx) => min( - self.tx().gas_price, - tx.max_priority_fee_per_gas + block_base_fee.unwrap_or_default(), - ), + Self::EIP1559Transaction(tx) => { + let (v2, overflow) = tx + .max_priority_fee_per_gas + .overflowing_add(block_base_fee.unwrap_or_default()); + if overflow { + self.tx().gas_price + } else { + min(self.tx().gas_price, v2) + } + } Self::AccessList(_) => self.tx().gas_price, Self::Legacy(_) => self.tx().gas_price, } @@ -1337,4 +1343,41 @@ mod tests { test_vector("f867088504a817c8088302e2489435353535353535353535353535353535353535358202008025a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10", "9bddad43f934d313c2b79ca28a432dd2b7281029"); test_vector("f867098504a817c809830334509435353535353535353535353535353535353535358202d98025a052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afba052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb", "3c24d7329e92f84f08556ceb6df1cdb0104ca49f"); } + + #[test] + fn should_not_panic_on_effective_gas_price_overflow() { + use self::publickey::{Generator, Random}; + let key = Random.generate(); + let gas_price /* 2**256 - 1 */ = U256::from(340282366920938463463374607431768211455u128) + * U256::from(340282366920938463463374607431768211455u128) + + U256::from(340282366920938463463374607431768211455u128) + + U256::from(340282366920938463463374607431768211455u128); + let t = TypedTransaction::EIP1559Transaction(EIP1559TransactionTx { + transaction: AccessListTx::new( + Transaction { + action: Action::Create, + nonce: U256::from(42), + gas_price, + gas: U256::from(50_000), + value: U256::from(1), + data: b"Hello!".to_vec(), + }, + vec![ + ( + H160::from_low_u64_be(10), + vec![H256::from_low_u64_be(102), H256::from_low_u64_be(103)], + ), + (H160::from_low_u64_be(400), vec![]), + ], + ), + max_priority_fee_per_gas: gas_price, + }) + .sign(&key.secret(), Some(69)); + + let result = t.transaction.effective_gas_price(Some(124.into())); + assert_eq!( + gas_price, result, + "Invalid effective gas price, when max_priority_fee_per_gas is U256::max" + ); + } } diff --git a/crates/util/version/Cargo.toml b/crates/util/version/Cargo.toml index 1408b64f0..3efd789e0 100644 --- a/crates/util/version/Cargo.toml +++ b/crates/util/version/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "parity-version" # NOTE: this value is used for OpenEthereum version string (via env CARGO_PKG_VERSION) -version = "3.3.1" +version = "3.3.2" authors = ["Parity Technologies "] build = "build.rs"