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

merge upstream #42

Merged
merged 58 commits into from
Sep 23, 2022
Merged
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
d80c5fe
Avoid Extra Allocation (#764)
AurevoirXavier Jul 7, 2022
87baadf
fix wrong error convertion (#762)
nanocryk Jul 7, 2022
f472dae
Bump serde from 1.0.137 to 1.0.138 (#759)
dependabot[bot] Jul 7, 2022
8732ea3
Bump moment from 2.29.2 to 2.29.4 in /template/utils (#766)
dependabot[bot] Jul 7, 2022
241bb8e
Use named structs for pallet event (#765)
koushiro Jul 8, 2022
b8bf64b
add with-rocksdb-weights (#769)
brunopgalvao Jul 11, 2022
d3cd866
Bump serde from 1.0.138 to 1.0.139 (#770)
dependabot[bot] Jul 12, 2022
44a2903
Dispatch precompile: decode call with depth limit (#748)
nanocryk Jul 15, 2022
a02de39
Bump libsecp256k1 from 0.7.0 to 0.7.1 (#773)
dependabot[bot] Jul 15, 2022
9981a1f
Remove schema cache (#763)
tgmichel Jul 15, 2022
cb041f1
Update substrate to 4ea2ac87de6cd66ca1e6038d10212c7c4e07a86a (#743)
koushiro Jul 18, 2022
d623569
Bump terser from 4.8.0 to 4.8.1 in /docs (#783)
dependabot[bot] Jul 21, 2022
7f138fe
Bump serde from 1.0.139 to 1.0.140 (#782)
dependabot[bot] Jul 21, 2022
93c57cf
Bump lru from 0.7.7 to 0.7.8 (#781)
dependabot[bot] Jul 21, 2022
55a4fcc
Update substrate to polkadot-v0.9.26 (#779)
koushiro Jul 21, 2022
4316915
Bump clap from 3.2.12 to 3.2.14 (#788)
dependabot[bot] Jul 22, 2022
bee98fd
Bump cranelift-codegen from 0.85.1 to 0.85.3 (#785)
dependabot[bot] Jul 22, 2022
b222683
Bump wasmtime from 0.38.1 to 0.38.3 (#784)
dependabot[bot] Jul 22, 2022
8c44872
`type` field for rpc `Receipt` response payload (#776)
tgmichel Jul 22, 2022
bfc9070
Do not validate transaction cost on non-transactional context (#758)
tgmichel Jul 22, 2022
9318023
fix evm benchmarks (#789)
Jul 24, 2022
660779b
Add runtime-benchmarks feature check into CI (#793)
koushiro Jul 25, 2022
e23bb9a
Bump parity-db from 0.3.14 to 0.3.16 (#791)
dependabot[bot] Jul 25, 2022
a490ef1
pallet-evm: use u32::MAX instead of deprecated u32::max_value() (#796)
koushiro Jul 26, 2022
09b2fca
Bump clap from 3.2.14 to 3.2.15 (#795)
dependabot[bot] Jul 26, 2022
780d115
Add tests tx check pre_dispatch (#800)
librelois Aug 1, 2022
efe1866
Bump clap from 3.2.15 to 3.2.16 (#798)
dependabot[bot] Aug 1, 2022
cf0fae7
Add `evm-chain-id` pallet (#804)
koushiro Aug 3, 2022
f2eba05
Add pallet storage item to primitives (#807)
boundless-forest Aug 8, 2022
574e284
Bump serde_json from 1.0.82 to 1.0.83 (#806)
dependabot[bot] Aug 8, 2022
65610bb
Bump serde from 1.0.140 to 1.0.142 (#805)
dependabot[bot] Aug 8, 2022
7ac29f2
Bump thiserror from 1.0.31 to 1.0.32 (#803)
dependabot[bot] Aug 8, 2022
6d6d9cc
Bump async-trait from 0.1.56 to 0.1.57 (#802)
dependabot[bot] Aug 8, 2022
e86c0c5
Bump serde from 1.0.142 to 1.0.143 (#810)
dependabot[bot] Aug 10, 2022
ddcf843
Allow larger gas limit in non-transactional execution (#799)
nanocryk Aug 10, 2022
a2dc0ff
pallet-base-fee: remove IsActive config (#794)
koushiro Aug 11, 2022
083c073
Geth pool error formatter (#739)
nanocryk Aug 12, 2022
5067a8d
Export the format module (#817)
koushiro Aug 15, 2022
fdbe44e
Fix panic in pending_runtime_api with Aura consensus env (#814)
icodezjb Aug 15, 2022
ef75c42
Bump clap from 3.2.16 to 3.2.17 (#818)
dependabot[bot] Aug 15, 2022
fff8cc4
Fix length checking overflow in EVM revert reason parsing (#820)
sorpaas Aug 15, 2022
d03b236
Bump serde_json from 1.0.83 to 1.0.85 (#824)
dependabot[bot] Aug 24, 2022
b098d31
Bump serde from 1.0.143 to 1.0.144 (#823)
dependabot[bot] Aug 24, 2022
f636d6c
allow to adapt an estimate_gas request (#738)
nanocryk Aug 24, 2022
db91fe2
Update README.md (#825)
joshuacheong Aug 25, 2022
9a930ec
Update substrate to polkadot-v0.9.27 (#809)
koushiro Aug 26, 2022
59c2460
Add script for releasing polkadot branch (#829)
koushiro Aug 29, 2022
b5f49f7
Public visibility for `validate_common` (#833)
tgmichel Sep 1, 2022
233173e
Support `ExitError::InvalidCode` in gas estimation (#840)
tgmichel Sep 4, 2022
7c96d95
Remove unwraps in RPC `pending_runtime_api` (#842)
tgmichel Sep 6, 2022
06eb4f2
Handle `earliest` tag for `BlockNumber` (#836)
tgmichel Sep 8, 2022
02ae871
Bump thiserror from 1.0.32 to 1.0.34 (#845)
dependabot[bot] Sep 9, 2022
8cc0755
Bump clap from 3.2.17 to 3.2.20 (#844)
dependabot[bot] Sep 9, 2022
96ba32a
Bump futures from 0.3.21 to 0.3.24 (#831)
dependabot[bot] Sep 9, 2022
d3beddc
Fix post dispatch weight (#851)
notlesh Sep 20, 2022
fe12fdd
Add `safe` and `finalized` block tags support (#853)
tgmichel Sep 20, 2022
817bdfb
Bump clap from 3.2.20 to 3.2.22 (#858)
dependabot[bot] Sep 20, 2022
e8dbed1
Bump lru from 0.7.8 to 0.8.0 (#850)
dependabot[bot] Sep 20, 2022
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
Prev Previous commit
Next Next commit
Do not validate transaction cost on non-transactional context (polkad…
…ot-evm#758)

* Do not validate transaction cost on non-transactional context

* fmt
  • Loading branch information
tgmichel committed Jul 22, 2022
commit bfc907017e9392ab702b9faddc87a34d6c683f06
70 changes: 46 additions & 24 deletions primitives/evm/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,27 +179,28 @@ impl<'config, E: From<InvalidEvmTransactionError>> CheckEvmTransaction<'config,
}

fn validate_common(&self) -> Result<&Self, E> {
// We must ensure a transaction can pay the cost of its data bytes.
// If it can't it should not be included in a block.
let mut gasometer = evm::gasometer::Gasometer::new(
self.transaction.gas_limit.unique_saturated_into(),
self.config.evm_config,
);
let transaction_cost = if self.transaction.to.is_some() {
evm::gasometer::call_transaction_cost(
&self.transaction.input,
&self.transaction.access_list,
)
} else {
evm::gasometer::create_transaction_cost(
&self.transaction.input,
&self.transaction.access_list,
)
};
if gasometer.record_transaction(transaction_cost).is_err() {
return Err(InvalidEvmTransactionError::GasLimitTooLow.into());
if self.config.is_transactional {
// We must ensure a transaction can pay the cost of its data bytes.
// If it can't it should not be included in a block.
let mut gasometer = evm::gasometer::Gasometer::new(
self.transaction.gas_limit.unique_saturated_into(),
self.config.evm_config,
);
let transaction_cost = if self.transaction.to.is_some() {
evm::gasometer::call_transaction_cost(
&self.transaction.input,
&self.transaction.access_list,
)
} else {
evm::gasometer::create_transaction_cost(
&self.transaction.input,
&self.transaction.access_list,
)
};
if gasometer.record_transaction(transaction_cost).is_err() {
return Err(InvalidEvmTransactionError::GasLimitTooLow.into());
}
}

// Transaction gas limit is within the upper bound block gas limit.
if self.transaction.gas_limit > self.config.block_gas_limit {
return Err(InvalidEvmTransactionError::GasLimitTooHigh.into());
Expand Down Expand Up @@ -322,9 +323,12 @@ mod tests {
test_env(input)
}

fn transaction_gas_limit_low<'config>() -> CheckEvmTransaction<'config, TestError> {
fn transaction_gas_limit_low<'config>(
is_transactional: bool,
) -> CheckEvmTransaction<'config, TestError> {
let mut input = TestCase::default();
input.gas_limit = U256::from(1u8);
input.is_transactional = is_transactional;
test_env(input)
}

Expand Down Expand Up @@ -461,13 +465,14 @@ mod tests {
}

#[test]
// Gas limit too low fails in pool and in block.
fn validate_in_pool_and_block_fails_gas_limit_too_low() {
// Gas limit too low transactional fails in pool and in block.
fn validate_in_pool_and_block_transactional_fails_gas_limit_too_low() {
let who = Account {
balance: U256::from(1_000_000u128),
nonce: U256::zero(),
};
let test = transaction_gas_limit_low();
let is_transactional = true;
let test = transaction_gas_limit_low(is_transactional);
// Pool
let res = test.validate_in_pool_for(&who);
assert!(res.is_err());
Expand All @@ -478,6 +483,23 @@ mod tests {
assert_eq!(res.unwrap_err(), TestError::GasLimitTooLow);
}

#[test]
// Gas limit too low non-transactional succeeds in pool and in block.
fn validate_in_pool_and_block_non_transactional_succeeds_gas_limit_too_low() {
let who = Account {
balance: U256::from(1_000_000u128),
nonce: U256::zero(),
};
let is_transactional = false;
let test = transaction_gas_limit_low(is_transactional);
// Pool
let res = test.validate_in_pool_for(&who);
assert!(res.is_ok());
// Block
let res = test.validate_in_block_for(&who);
assert!(res.is_ok());
}

#[test]
// Gas limit too high fails in pool and in block.
fn validate_in_pool_for_fails_gas_limit_too_high() {
Expand Down