Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bus-mapping/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ serde_json = "1.0.66"
hex = "0.4.3"
mock = { path = "../mock" }
pretty_assertions = "1.0.0"
rand = "0.8"
tokio = { version = "1.13", features = ["macros"] }
url = "2.2.2"
4 changes: 3 additions & 1 deletion bus-mapping/src/evm/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use log::warn;

mod call;
mod calldatacopy;
mod calldataload;
mod calldatasize;
mod caller;
mod callvalue;
Expand All @@ -39,6 +40,7 @@ mod swap;

use call::Call;
use calldatacopy::Calldatacopy;
use calldataload::Calldataload;
use calldatasize::Calldatasize;
use caller::Caller;
use callvalue::Callvalue;
Expand Down Expand Up @@ -118,7 +120,7 @@ fn fn_gen_associated_ops(opcode_id: &OpcodeId) -> FnGenAssociatedOps {
OpcodeId::CALLER => Caller::gen_associated_ops,
OpcodeId::CALLVALUE => Callvalue::gen_associated_ops,
OpcodeId::CALLDATASIZE => Calldatasize::gen_associated_ops,
OpcodeId::CALLDATALOAD => StackOnlyOpcode::<1, 1>::gen_associated_ops,
OpcodeId::CALLDATALOAD => Calldataload::gen_associated_ops,
OpcodeId::CALLDATACOPY => Calldatacopy::gen_associated_ops,
// OpcodeId::CODESIZE => {},
OpcodeId::GASPRICE => GasPrice::gen_associated_ops,
Expand Down
13 changes: 6 additions & 7 deletions bus-mapping/src/evm/opcodes/calldatacopy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,18 @@ mod calldatacopy_tests {
operation::{CallContextField, CallContextOp, MemoryOp, StackOp, RW},
};
use eth_types::{
address, bytecode,
bytecode,
evm_types::{OpcodeId, StackAddress},
geth_types::GethData,
Address, ToWord, Word,
ToWord, Word,
};

use mock::test_ctx::{helpers::*, TestContext};
use pretty_assertions::assert_eq;

#[test]
fn calldatacopy_opcode_internal() {
let addr_a = address!("0x000000000000000000000000000000000cafe00a");
let addr_b = address!("0x000000000000000000000000000000000cafe00b");
let (addr_a, addr_b) = (mock::MOCK_ACCOUNTS[0], mock::MOCK_ACCOUNTS[1]);

// code B gets called by code A, so the call is an internal call.
let dst_offset = 0x00usize;
Expand Down Expand Up @@ -246,13 +245,13 @@ mod calldatacopy_tests {
accs[0].address(addr_b).code(code_b);
accs[1].address(addr_a).code(code_a);
accs[2]
.address(Address::random())
.address(mock::MOCK_ACCOUNTS[2])
.balance(Word::from(1u64 << 30));
},
|mut txs, accs| {
txs[0].to(accs[1].address).from(accs[2].address);
},
|block, _tx| block.number(0xcafeu64),
|block, _tx| block,
)
.unwrap()
.into();
Expand Down Expand Up @@ -384,7 +383,7 @@ mod calldatacopy_tests {
None,
account_0_code_account_1_no_code(code),
tx_from_1_to_0,
|block, _tx| block.number(0xcafeu64),
|block, _tx| block,
)
.unwrap()
.into();
Expand Down
Loading