Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions crates/op-revm/src/transaction/abstraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,15 @@ impl<TX: Transaction + SystemCallTx> SystemCallTx for OpTransaction<TX> {
system_contract_address: Address,
data: Bytes,
) -> Self {
OpTransaction::new(TX::new_system_tx_with_caller(
let mut tx = OpTransaction::new(TX::new_system_tx_with_caller(
caller,
system_contract_address,
data,
))
));

tx.enveloped_tx = Some(Bytes::default());

tx
Comment on lines -92 to +100
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need to be checking if this is pre-regolith here actually. I didn't find out how revm performs the actual eip2718 encoding since it seems alloy's impl can't be used here as revm has its own transaction trait ? @rakita

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revm does not perform eip2718 encoding, it is a field.

Calling replay on system "tx" is an undefined behaviour (as fields for this tx are undefined), so having empty bytes for envelop seems appropriate.

}
}

Expand Down
17 changes: 17 additions & 0 deletions crates/op-revm/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
//! Integration tests for the `op-revm` crate.
mod common;

use alloy_primitives::bytes;
use common::compare_or_save_testdata;
use op_revm::{
precompiles::bn128_pair::GRANITE_MAX_INPUT_SIZE, DefaultOp, L1BlockInfo, OpBuilder,
OpHaltReason, OpSpecId, OpTransaction,
};
use revm::SystemCallEvm;
use revm::{
bytecode::opcode,
context::{
Expand Down Expand Up @@ -1072,3 +1074,18 @@ fn test_log_inspector() {

compare_or_save_testdata("test_log_inspector.json", &output);
}

#[test]
fn test_system_call() {
let ctx = Context::op();

let mut evm = ctx.build_op();

evm.transact_system_call(BENCH_TARGET, bytes!("0x0001"))
.unwrap();

// Run evm.
let output = evm.replay().unwrap();

compare_or_save_testdata("test_system_call.json", &output);
}
165 changes: 165 additions & 0 deletions crates/op-revm/tests/testdata/test_system_call.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{
"result": {
"Success": {
"reason": "Stop",
"gas_used": 21020,
"gas_refunded": 0,
"logs": [],
"output": {
"Call": "0x"
}
}
},
"state": {
"0x420000000000000000000000000000000000001b": {
"info": {
"balance": "0x0",
"nonce": 0,
"code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"code": {
"LegacyAnalyzed": {
"bytecode": "0x00",
"original_len": 0,
"jump_table": {
"order": "bitvec::order::Lsb0",
"head": {
"width": 8,
"index": 0
},
"bits": 0,
"data": []
}
}
}
},
"transaction_id": 1,
"storage": {},
"status": "Touched | LoadedAsNotExisting"
},
"0x4200000000000000000000000000000000000019": {
"info": {
"balance": "0x0",
"nonce": 0,
"code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"code": {
"LegacyAnalyzed": {
"bytecode": "0x00",
"original_len": 0,
"jump_table": {
"order": "bitvec::order::Lsb0",
"head": {
"width": 8,
"index": 0
},
"bits": 0,
"data": []
}
}
}
},
"transaction_id": 1,
"storage": {},
"status": "Touched | LoadedAsNotExisting"
},
"0xfffffffffffffffffffffffffffffffffffffffe": {
"info": {
"balance": "0x0",
"nonce": 1,
"code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"code": {
"LegacyAnalyzed": {
"bytecode": "0x00",
"original_len": 0,
"jump_table": {
"order": "bitvec::order::Lsb0",
"head": {
"width": 8,
"index": 0
},
"bits": 0,
"data": []
}
}
}
},
"transaction_id": 1,
"storage": {},
"status": "Touched | LoadedAsNotExisting"
},
"0x0000000000000000000000000000000000000000": {
"info": {
"balance": "0x0",
"nonce": 0,
"code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"code": {
"LegacyAnalyzed": {
"bytecode": "0x00",
"original_len": 0,
"jump_table": {
"order": "bitvec::order::Lsb0",
"head": {
"width": 8,
"index": 0
},
"bits": 0,
"data": []
}
}
}
},
"transaction_id": 1,
"storage": {},
"status": "Touched | LoadedAsNotExisting"
},
"0xffffffffffffffffffffffffffffffffffffffff": {
"info": {
"balance": "0x0",
"nonce": 0,
"code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"code": {
"LegacyAnalyzed": {
"bytecode": "0x00",
"original_len": 0,
"jump_table": {
"order": "bitvec::order::Lsb0",
"head": {
"width": 8,
"index": 0
},
"bits": 0,
"data": []
}
}
}
},
"transaction_id": 1,
"storage": {},
"status": "Touched | LoadedAsNotExisting"
},
"0x420000000000000000000000000000000000001a": {
"info": {
"balance": "0x0",
"nonce": 0,
"code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"code": {
"LegacyAnalyzed": {
"bytecode": "0x00",
"original_len": 0,
"jump_table": {
"order": "bitvec::order::Lsb0",
"head": {
"width": 8,
"index": 0
},
"bits": 0,
"data": []
}
}
}
},
"transaction_id": 1,
"storage": {},
"status": "Touched | LoadedAsNotExisting"
}
}
}
Loading