Skip to content

Commit

Permalink
Merge branch 'nightly' into dependabot/cargo/wiremock-0.5.22
Browse files Browse the repository at this point in the history
  • Loading branch information
bkolad authored Dec 5, 2023
2 parents f4ebbea + 6ac3fdf commit 7de6f99
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 45 deletions.
3 changes: 2 additions & 1 deletion examples/demo-rollup/tests/evm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ async fn execute(client: &TestClient) -> Result<(), Box<dyn std::error::Error>>
requests.push(set_value_req);
}
client.send_publish_batch_request().await;
sleep(Duration::from_millis(1000)).await;
}
sleep(Duration::from_millis(2000)).await;
sleep(Duration::from_millis(6000)).await;
// get gas price
let latest_gas_price = client.eth_gas_price().await;

Expand Down
30 changes: 13 additions & 17 deletions module-system/module-implementations/sov-evm/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,19 @@ impl<C: sov_modules_api::Context> Evm<C> {
error: None,
}
}
Err(err) => Receipt {
receipt: reth_primitives::Receipt {
tx_type: evm_tx_recovered.tx_type(),
success: false,
cumulative_gas_used: previous_transaction_cumulative_gas_used,
logs: vec![],
},
// TODO: Do we want failed transactions to use all gas?
// https://github.com/Sovereign-Labs/sovereign-sdk/issues/505
gas_used: 0,
log_index_start,
error: Some(match err {
EVMError::Transaction(err) => EVMError::Transaction(err),
EVMError::Header(e) => EVMError::Header(e),
EVMError::Database(_) => EVMError::Database(0u8),
}),
},
// Adopted from https://github.com/paradigmxyz/reth/blob/main/crates/payload/basic/src/lib.rs#L884
Err(err) => {
match err {
EVMError::Transaction(_) => {
// This is a transactional error, so we can skip it without doing anything.
return Ok(CallResponse::default());
}
err => {
// This is a fatal error, so we need to return it.
return Err(err.into());
}
}
}
};

let pending_transaction = PendingTransaction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use reth_primitives::{Address, Bytes, TransactionKind};
use revm::primitives::{SpecId, KECCAK_EMPTY, U256};
use sov_modules_api::default_context::DefaultContext;
use sov_modules_api::utils::generate_address;
use sov_modules_api::{Context, Module, StateMapAccessor, StateVecAccessor};
use sov_modules_api::{Context, Module, StateMapAccessor, StateValueAccessor, StateVecAccessor};

use crate::call::CallMessage;
use crate::evm::primitive_types::Receipt;
Expand Down Expand Up @@ -102,35 +102,23 @@ fn failed_transaction_test() {
{
let sender_address = generate_address::<C>("sender");
let context = C::new(sender_address, 1);
let messages = vec![create_contract_message(&dev_signer, 0)];

for tx in messages {
evm.call(tx, &context, working_set).unwrap();
}
let message = create_contract_message(&dev_signer, 0);
evm.call(message, &context, working_set).unwrap();
}

// assert no pending transaction
let pending_txs = evm.pending_transactions.iter(working_set);
assert_eq!(pending_txs.len(), 0);

evm.end_slot_hook(working_set);

assert_eq!(
evm.receipts
.iter(&mut working_set.accessory_state())
.collect::<Vec<_>>(),
[Receipt {
receipt: reth_primitives::Receipt {
tx_type: reth_primitives::TxType::EIP1559,
success: false,
cumulative_gas_used: 0,
logs: vec![]
},
gas_used: 0,
log_index_start: 0,
error: Some(revm::primitives::EVMError::Transaction(
revm::primitives::InvalidTransaction::LackOfFundForMaxFee {
fee: 1_000_000u64,
balance: U256::ZERO
}
))
}]
)
// Assert block does not have any transaction
let block = evm
.pending_head
.get(&mut working_set.accessory_state())
.unwrap();
assert_eq!(block.transactions.start, 0);
assert_eq!(block.transactions.end, 0);
}

fn create_contract_message(dev_signer: &TestSigner, nonce: u64) -> CallMessage {
Expand Down

0 comments on commit 7de6f99

Please sign in to comment.