Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

gadget for CREATE(2) #981

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
3896366
wip
Dec 5, 2022
3dda45d
tests pass
Dec 5, 2022
76cb869
Add stack constraints
Dec 6, 2022
9f7263f
tx_id
Dec 6, 2022
58d98f8
reversion
Dec 6, 2022
59715be
wip
Dec 6, 2022
f601aa2
wip
Dec 6, 2022
3ba7f53
wip
Dec 6, 2022
3b39762
wip
Dec 6, 2022
e8a00f5
fmt
Dec 6, 2022
1483f22
wip
Dec 6, 2022
15e63ac
wip
Dec 6, 2022
db6653f
wip
Dec 6, 2022
ae69417
wip
Dec 6, 2022
f272a81
wip
Dec 6, 2022
979d293
fmt
Dec 6, 2022
6cae76c
memory_expansion
Dec 7, 2022
866af29
gas_left
Dec 7, 2022
74adabb
memory word size
Dec 7, 2022
0325130
reversible write counter
Dec 7, 2022
0696b8d
wip
Dec 8, 2022
fca1db2
wip
Dec 8, 2022
2691f83
wip
Dec 8, 2022
af5c53b
fix and fmt
Dec 8, 2022
65d70f6
wip
Dec 10, 2022
e843549
Add memory word size function
Dec 13, 2022
f214f57
Merge branch 'main' into feat/create
z2trillion Dec 13, 2022
42f1710
Add init code copy lookup
Dec 15, 2022
ea76327
cleanup
Dec 15, 2022
c262f59
wip
Dec 15, 2022
8fcd1c0
convert to rlcs
Dec 17, 2022
dd190f5
wip
Dec 17, 2022
2745b50
wip
Dec 19, 2022
b36697e
Fix gas cost
Dec 19, 2022
6a266cc
Merge branch 'feat/create' into feat/create_sha
Dec 19, 2022
e80f90d
wip
Dec 19, 2022
75b4603
wip
Dec 19, 2022
f1bcf93
fix endianess
Dec 19, 2022
905a2a3
Add constraint between hash and address
Dec 19, 2022
272d2b3
fix
Dec 19, 2022
2ed8eb7
bus_mapping
Dec 22, 2022
1989af0
wip
Dec 22, 2022
be585cb
kecak input for CREATE
Dec 22, 2022
8167354
wip rlpu64
Dec 22, 2022
e3c7ca6
wip
Dec 22, 2022
1c3b819
use rlc
Dec 23, 2022
5a88e19
rlp length
Dec 23, 2022
b656f6d
rlp length
Dec 23, 2022
0082bf1
wip
Dec 23, 2022
cc45cbd
wip
Dec 25, 2022
0e3418e
wip
Dec 25, 2022
0c124e3
wip
Dec 25, 2022
26b1a53
wip
Dec 25, 2022
ee32bed
wip
Dec 25, 2022
cab77db
Re-add gas constraint
Dec 25, 2022
191be69
Merge branch 'main' into feat/create
z2trillion Dec 25, 2022
d6fb607
undo
Dec 25, 2022
a1dd2c4
cleanup
Dec 25, 2022
a99c3d2
Remove dummy
Dec 25, 2022
204f670
cleanup
Dec 25, 2022
4717164
cleanup
Dec 25, 2022
3518929
Remove redundant address cells
Dec 26, 2022
19bb1d8
Simplify tests
Jan 5, 2023
170ec3b
Add rlp nonce test
Jan 5, 2023
5a36174
Handle case of empty initilization code
Jan 6, 2023
9a83513
Constraint step state transition for empty initilization code
Jan 6, 2023
ee08efb
Fix clippy
Jan 6, 2023
f15ffa7
Add 127 and 128 to nonce test cases
Jan 6, 2023
2aeb344
Minimize changes to other files
Jan 6, 2023
049b94e
Undo state circuit change
Jan 6, 2023
3373ce9
Simplify logic and add comments
Jan 9, 2023
5331113
Add reversion info constraints and call information lookups
Jan 9, 2023
2fa4cb5
Merge branch 'main' into feat/create
z2trillion Jan 9, 2023
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
7 changes: 7 additions & 0 deletions bus-mapping/src/circuit_input_builder/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ pub struct CallContext {
pub return_data: Vec<u8>,
}

impl CallContext {
/// Memory size in words, rounded up
pub fn memory_word_size(&self) -> u64 {
u64::try_from(self.memory.len()).expect("failed to convert usize to u64") / 32
}
}

/// A reversion group is the collection of calls and the operations which are
/// [`Operation::reversible`](crate::operation::Operation::reversible) that
/// happened in them, that will be reverted at once when the call that initiated
Expand Down
31 changes: 31 additions & 0 deletions bus-mapping/src/circuit_input_builder/input_state_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,25 @@ impl<'a> CircuitInputStateRef<'a> {
Ok(())
}

/// Add address to access list for the current transaction.
pub fn tx_access_list_write(
&mut self,
step: &mut ExecStep,
address: Address,
) -> Result<(), Error> {
let is_warm = self.sdb.check_account_in_access_list(&address);
self.push_op_reversible(
step,
RW::WRITE,
TxAccessListAccountOp {
tx_id: self.tx_ctx.id(),
address,
is_warm: true,
is_warm_prev: is_warm,
},
)
}

/// Push a write type [`TxAccessListAccountOp`] into the
/// [`OperationContainer`](crate::operation::OperationContainer) with the
/// next [`RWCounter`](crate::operation::RWCounter), and then
Expand Down Expand Up @@ -571,6 +590,18 @@ impl<'a> CircuitInputStateRef<'a> {
))
}

pub(crate) fn reversion_info_read(&mut self, step: &mut ExecStep, call: &Call) {
for (field, value) in [
(
CallContextField::RwCounterEndOfReversion,
call.rw_counter_end_of_reversion.to_word(),
),
(CallContextField::IsPersistent, call.is_persistent.to_word()),
] {
self.call_context_read(step, call.call_id, field, value);
}
}

/// Check if address is a precompiled or not.
pub fn is_precompiled(&self, address: &Address) -> bool {
address.0[0..19] == [0u8; 19] && (1..=9).contains(&address.0[19])
Expand Down
12 changes: 3 additions & 9 deletions bus-mapping/src/evm/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ use callop::CallOpcode;
use callvalue::Callvalue;
use codecopy::Codecopy;
use codesize::Codesize;
use create::DummyCreate;
use create::Create;
use dup::Dup;
use error_invalid_jump::ErrorInvalidJump;
use error_oog_call::OOGCall;
Expand Down Expand Up @@ -234,19 +234,13 @@ fn fn_gen_associated_ops(opcode_id: &OpcodeId) -> FnGenAssociatedOps {
OpcodeId::LOG4 => Log::gen_associated_ops,
OpcodeId::CALL | OpcodeId::CALLCODE => CallOpcode::<7>::gen_associated_ops,
OpcodeId::DELEGATECALL | OpcodeId::STATICCALL => CallOpcode::<6>::gen_associated_ops,
OpcodeId::CREATE => Create::<false>::gen_associated_ops,
OpcodeId::CREATE2 => Create::<true>::gen_associated_ops,
OpcodeId::RETURN | OpcodeId::REVERT => ReturnRevert::gen_associated_ops,
OpcodeId::SELFDESTRUCT => {
warn!("Using dummy gen_selfdestruct_ops for opcode SELFDESTRUCT");
DummySelfDestruct::gen_associated_ops
}
OpcodeId::CREATE => {
warn!("Using dummy gen_create_ops for opcode {:?}", opcode_id);
DummyCreate::<false>::gen_associated_ops
}
OpcodeId::CREATE2 => {
warn!("Using dummy gen_create_ops for opcode {:?}", opcode_id);
DummyCreate::<true>::gen_associated_ops
}
_ => {
warn!("Using dummy gen_associated_ops for opcode {:?}", opcode_id);
Dummy::gen_associated_ops
Expand Down
Loading