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

Identity (dataCopy) precompile #1628

Merged
Show file tree
Hide file tree
Changes from 169 commits
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
9f661a3
prerequisite for handling precompile gadgets
roynalnaruto May 8, 2023
3381421
identity gadget config
roynalnaruto May 9, 2023
70259ca
copy table lookups for identity precompile
roynalnaruto May 9, 2023
eac7209
Merge branch 'main' into feat/precompile-identity
roynalnaruto May 18, 2023
6911fdc
structure for verifying precompile call
roynalnaruto May 18, 2023
335c14b
connect bus-mapping of precompile to callop
roynalnaruto May 18, 2023
76cf3d2
copy events for identity precompile
roynalnaruto May 18, 2023
7a1ef55
minor refactor
roynalnaruto May 19, 2023
24de2d2
witness assignment
roynalnaruto May 19, 2023
5aefc1d
Merge branch 'main' into feat/precompile-identity
roynalnaruto May 19, 2023
63572f2
err: debugging precomp identity
roynalnaruto May 20, 2023
778ff12
Merge branch 'main' into feat/precompile-identity
roynalnaruto May 20, 2023
07775fd
some fixes
roynalnaruto May 21, 2023
6c6c8e1
wip debugging
roynalnaruto May 21, 2023
d389a9f
more fixes
roynalnaruto May 21, 2023
4cc0780
more fixes
roynalnaruto May 21, 2023
86f0a41
refactoring
roynalnaruto May 22, 2023
7d713f2
busmapping precompile call test failure fix
roynalnaruto May 22, 2023
a2818b5
fix order of operation (rw counter issue)
roynalnaruto May 22, 2023
3df95c2
more tests
roynalnaruto May 22, 2023
3818d8b
merge in rohit's changes
darth-cy Sep 22, 2023
8141d52
add gas cost constants in evm_types using Scroll's main
darth-cy Sep 22, 2023
0597442
correct typo and type mismatch
darth-cy Sep 22, 2023
fac0570
correct call op dependencies in bus mapping
darth-cy Sep 23, 2023
334236a
restore tests
darth-cy Sep 23, 2023
a3587bc
feature flag
darth-cy Sep 24, 2023
f0fe1a0
reconcile with head precompile execution
darth-cy Sep 24, 2023
77ed99f
reconcile bus mapping callop test pattern
darth-cy Sep 24, 2023
1cd63ce
remove unnecessary import
darth-cy Sep 24, 2023
68ca06c
allow common call ctx to throw err
darth-cy Sep 24, 2023
8ae5953
add result unwrapping
darth-cy Sep 24, 2023
af5af33
reconcile precompile mod
darth-cy Sep 24, 2023
9b67377
add dependencies
darth-cy Sep 25, 2023
55157bf
correct call op imports
darth-cy Sep 25, 2023
47123f7
add additional precompile fields on call op:
darth-cy Sep 25, 2023
01e7a64
add expression conversion to word utility. correct types
darth-cy Sep 25, 2023
2bd9c57
resolve names
darth-cy Sep 25, 2023
4f6d6c5
add rw_delta utility
darth-cy Sep 25, 2023
3f54c97
resolve rw_delta
darth-cy Sep 25, 2023
632021d
remove h160 for address assignment
darth-cy Sep 25, 2023
3065f77
resolve conditional
darth-cy Sep 25, 2023
265732c
correct precompile variable names
darth-cy Sep 25, 2023
15d3de3
add constraints for precompile code and address warm
darth-cy Sep 25, 2023
753efc3
add constraints for return data from precompile
darth-cy Sep 25, 2023
450cd2d
add constraint
darth-cy Sep 25, 2023
5387b8f
reconcile address data type
darth-cy Sep 25, 2023
c89c7d6
add rw accounting for call op exec assign
darth-cy Sep 25, 2023
9078936
correct precompile return length calculation
darth-cy Sep 25, 2023
9ead8c7
fix data mismatch
darth-cy Sep 25, 2023
9e9badf
adjust import
darth-cy Sep 25, 2023
6031b9c
add base gas cost in step
darth-cy Sep 25, 2023
c3130c8
add additional field on identity
darth-cy Sep 25, 2023
16308fd
Merge branch 'main' into feat/precompile-identity
darth-cy Sep 25, 2023
7765b97
Merge branch 'main' into feat/precompile-identity
darth-cy Sep 28, 2023
9db7eed
add precompile gadget next step constraints
darth-cy Sep 28, 2023
2c6969c
adjust imports
darth-cy Sep 28, 2023
3daa45a
correct construction arguments
darth-cy Sep 28, 2023
182e40d
fix compile
darth-cy Sep 28, 2023
e226322
fix compile
darth-cy Sep 28, 2023
d7e2aed
fix compile
darth-cy Sep 28, 2023
54da2f8
fix compile
darth-cy Sep 28, 2023
562dce8
Merge branch 'main' into feat/precompile-identity
darth-cy Oct 2, 2023
cb36ddf
debug assert eq on next step gas
darth-cy Oct 2, 2023
d475ec8
modify return reversion
darth-cy Oct 2, 2023
d986bc0
match new error states
darth-cy Oct 2, 2023
5f52ee0
leave out precompile evt and aux capturing
darth-cy Oct 2, 2023
4a19469
add precompile error states to execution
darth-cy Oct 2, 2023
e134275
cont fixing err states
darth-cy Oct 2, 2023
8fb7c5d
correct precompiled failed error:
darth-cy Oct 2, 2023
4ec5ebd
fix precompile error states
darth-cy Oct 2, 2023
e5fa5d1
add gas cost to identity gadget
darth-cy Oct 2, 2023
34d418a
add precompile errors to execution
darth-cy Oct 2, 2023
a3aec93
add bytes rlc to callop
darth-cy Oct 2, 2023
5c79991
complete callop
darth-cy Oct 3, 2023
ae5e1d5
fix callop transfer gadget code hash
darth-cy Oct 3, 2023
719c924
fix callop assignment
darth-cy Oct 3, 2023
7e11cd3
assign bytes rlc
darth-cy Oct 3, 2023
88e1c73
Merge branch 'main' into feat/precompile-identity
darth-cy Oct 4, 2023
74e5caa
precompile gadget input bytes for padding only
darth-cy Oct 4, 2023
7160d84
inspect callop
darth-cy Oct 4, 2023
0f7e4d1
add copy event generation utility to input state ref
darth-cy Oct 5, 2023
fb12b7e
add copy steps generation for precompile returndata
darth-cy Oct 5, 2023
83789e4
change call op copy event generation
darth-cy Oct 5, 2023
5ef23be
Merge branch 'main' into feat/precompile-identity
darth-cy Oct 5, 2023
eefd90f
remove import
darth-cy Oct 5, 2023
7584d20
unused memory read
darth-cy Oct 5, 2023
4e02fc7
change execution
darth-cy Oct 9, 2023
01917ae
fix hi lo discrepancy
darth-cy Oct 9, 2023
3ebcb83
correct call context query order
darth-cy Oct 10, 2023
4c1ce7c
remove import
darth-cy Oct 10, 2023
049a54f
unused variable
darth-cy Oct 10, 2023
1cff02f
remove constant
darth-cy Oct 10, 2023
6a6a6a7
ignore log
darth-cy Oct 10, 2023
653e981
correct common gadgte
darth-cy Oct 11, 2023
04d8d0e
adjust end tx
darth-cy Oct 11, 2023
2418e81
remove import
darth-cy Oct 11, 2023
f22ab15
Merge branch 'main' into feat/precompile-identity
darth-cy Oct 12, 2023
0dda7f4
Merge branch 'main' into feat/precompile-identity
darth-cy Oct 14, 2023
74cdd46
remove restore
darth-cy Oct 14, 2023
dcc407f
remove restore
darth-cy Oct 14, 2023
c8320e1
disable precompile result
darth-cy Oct 14, 2023
097a3df
restore gadget
darth-cy Oct 15, 2023
17dbad4
remove precompile constraints
darth-cy Oct 15, 2023
3c71d88
resolve read disalignment
darth-cy Oct 15, 2023
d6e2c78
fix gas left constraint
darth-cy Oct 15, 2023
a3b6edc
resolve rw_indices
darth-cy Oct 16, 2023
88faac0
assign restore gadget
darth-cy Oct 16, 2023
bf438f3
correct is_err
darth-cy Oct 16, 2023
62f4d95
fix rw_delta counting for transfer
darth-cy Oct 16, 2023
0239b87
remove debug expression in begin_tx
darth-cy Oct 16, 2023
5027ca3
correct rw delta
darth-cy Oct 16, 2023
add9e65
fix memory sizing transition
darth-cy Oct 16, 2023
99b2cfa
fix memory sizing transition
darth-cy Oct 16, 2023
92fabee
fix memory sizing
darth-cy Oct 16, 2023
7c1049b
remove flag
darth-cy Oct 16, 2023
5fd5ff3
add back debug tx_id
darth-cy Oct 16, 2023
89b44be
reset test
darth-cy Oct 17, 2023
3c84662
add debugging utility
darth-cy Oct 19, 2023
5b8fdb2
adjust copy table debug
darth-cy Oct 19, 2023
5215866
debug markup
darth-cy Oct 19, 2023
b1fab36
remove copy events generation
darth-cy Oct 20, 2023
5f658aa
remove copy lookup
darth-cy Oct 20, 2023
798ce55
copy event gen for input output
darth-cy Oct 21, 2023
d44a1f3
finish one copy
darth-cy Oct 21, 2023
dd88f01
remove debug flags
darth-cy Oct 21, 2023
adce1cf
remove copy steps builder
darth-cy Oct 21, 2023
61c3dad
remove word align utiltiy
darth-cy Oct 21, 2023
9041ef7
remove import
darth-cy Oct 21, 2023
05ac075
remove import
darth-cy Oct 21, 2023
bc69839
resolve second copy
darth-cy Oct 21, 2023
e71356c
correct return bytes
darth-cy Oct 22, 2023
dd0ebf1
correct return bytes
darth-cy Oct 22, 2023
9526464
remove debug flags
darth-cy Oct 22, 2023
1e257de
recover all valid test cases on identity precompile
darth-cy Oct 22, 2023
8898942
Merge branch 'main' into feat/precompile-identity
lispc Oct 23, 2023
e78704e
fix precompile oog
darth-cy Oct 23, 2023
c10cbda
recover tests
darth-cy Oct 23, 2023
9ed9f5b
Merge branch 'main' into feat/precompile-identity
lispc Oct 24, 2023
dbf57bf
add begin_tx precompile block
darth-cy Oct 25, 2023
1322c10
Revert "add begin_tx precompile block"
darth-cy Oct 25, 2023
7f39d86
Merge branch 'main' into feat/precompile-identity
darth-cy Oct 25, 2023
c7564a4
fmt
darth-cy Oct 25, 2023
40da273
remove debug flag
darth-cy Oct 26, 2023
6f91b51
remove import
darth-cy Oct 26, 2023
bbf2252
remove unnecessary option
darth-cy Oct 26, 2023
8781c30
add handle_return callop data
darth-cy Oct 26, 2023
fe2f979
resolve conflict
darth-cy Oct 26, 2023
074c263
resolve enumiter
darth-cy Oct 26, 2023
06f8f8b
resolve unused
darth-cy Oct 26, 2023
7eec62d
resolve unused
darth-cy Oct 26, 2023
ad45589
resolve unused
darth-cy Oct 26, 2023
63c2263
resolve unused
darth-cy Oct 26, 2023
38ca9eb
resolve merge failure
darth-cy Oct 26, 2023
8036663
recover tests
darth-cy Oct 26, 2023
951295d
fmt
darth-cy Oct 26, 2023
1e9e03f
remove prt
darth-cy Oct 26, 2023
bb737b6
resolve lint
darth-cy Oct 26, 2023
c7538f1
Merge branch 'main' into feat/precompile-identity
roynalnaruto Oct 26, 2023
9c1322f
remove unnecessary code
darth-cy Oct 26, 2023
5524805
Merge branch 'feat/precompile-identity' of https://github.com/darth-c…
darth-cy Oct 26, 2023
bab03a1
Merge branch 'main' into feat/precompile-identity
darth-cy Oct 27, 2023
fadf10e
resolve debug issues
darth-cy Oct 30, 2023
db8de95
remove import
darth-cy Oct 30, 2023
552f02a
remove word aligned memory
darth-cy Oct 30, 2023
e093bc2
remove input state copy
darth-cy Oct 30, 2023
6130109
add revm overwrite
darth-cy Oct 30, 2023
32828aa
Revert "add revm overwrite"
darth-cy Oct 30, 2023
e983f88
ci task
darth-cy Oct 30, 2023
fe1d55e
remove debug flag
darth-cy Oct 30, 2023
f68af91
add comments'
darth-cy Nov 6, 2023
ac558d9
fmt
darth-cy Nov 6, 2023
1439501
add comments
darth-cy Nov 6, 2023
fd4ec33
fmt
darth-cy Nov 6, 2023
d9a5394
resolve conflict
darth-cy Dec 11, 2023
0e4fbd5
remove conflict section
darth-cy Dec 11, 2023
510c2e0
remove unnecessary value
darth-cy Dec 11, 2023
980ae46
update documentation
darth-cy Dec 11, 2023
a10ad74
pattern
darth-cy Dec 11, 2023
a54daa6
pattern
darth-cy Dec 11, 2023
21faf7f
remove import
darth-cy Dec 11, 2023
08180b0
remove unnecessary code:
darth-cy Dec 11, 2023
df24217
use precompile success indicator flag
darth-cy Dec 11, 2023
1458122
move test, refactor dir
darth-cy Dec 11, 2023
528a223
remove unnecessary variable
darth-cy Dec 11, 2023
0823061
add comments
darth-cy Dec 11, 2023
72c738f
add comment
darth-cy Dec 11, 2023
82d1a97
add comment
darth-cy Dec 11, 2023
9c97b2a
adjust naming
darth-cy Dec 11, 2023
57b070f
remove future recoverable tests
darth-cy Dec 11, 2023
648600b
fmt
darth-cy Dec 11, 2023
c8b1148
fmt
darth-cy Dec 11, 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
*.png
.DS_Store
.vscode
.idea
.idea
*.log
22 changes: 19 additions & 3 deletions bus-mapping/src/circuit_input_builder/execution.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
//! Execution step related module.

use crate::{
circuit_input_builder::CallContext, error::ExecError, exec_trace::OperationRef,
circuit_input_builder::CallContext,
error::{ExecError, OogError},
exec_trace::OperationRef,
operation::RWCounter,
precompile::PrecompileCalls,
};
use eth_types::{evm_types::OpcodeId, GethExecStep, Word, H256};
use gadgets::impl_expr;
Expand Down Expand Up @@ -60,6 +63,7 @@ impl ExecStep {
ExecStep {
exec_state: ExecState::Op(step.op),
pc: step.pc,

stack_size: step.stack.0.len(),
memory_size: call_ctx.memory.len(),
gas_left: step.gas,
Expand Down Expand Up @@ -117,13 +121,25 @@ impl ExecStep {
assert_eq!(memory_size % n_bytes_word, 0);
memory_size / n_bytes_word
}

/// Returns `true` if this is an execution step of Precompile.
pub fn is_precompiled(&self) -> bool {
matches!(self.exec_state, ExecState::Precompile(_))
}

/// Returns `true` if `error` is oog in precompile calls
pub fn is_precompile_oog_err(&self) -> bool {
matches!(self.error, Some(ExecError::OutOfGas(OogError::Precompile)))
}
}

/// Execution state
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ExecState {
/// EVM Opcode ID
Op(OpcodeId),
/// Precompile call
Precompile(PrecompileCalls),
/// Virtual step Begin Tx
BeginTx,
/// Virtual step End Tx
Expand Down Expand Up @@ -277,14 +293,14 @@ impl CopyEvent {
// increase in rw counter from the start of the copy event to step index
fn rw_counter_increase(&self, step_index: usize) -> u64 {
let source_rw_increase = match self.src_type {
CopyDataType::Bytecode | CopyDataType::TxCalldata => 0,
CopyDataType::Bytecode | CopyDataType::TxCalldata | CopyDataType::RlcAcc => 0,
CopyDataType::Memory => std::cmp::min(
u64::try_from(step_index + 1).unwrap() / 2,
self.src_addr_end
.checked_sub(self.src_addr)
.unwrap_or_default(),
),
CopyDataType::RlcAcc | CopyDataType::TxLog | CopyDataType::Padding => unreachable!(),
CopyDataType::TxLog | CopyDataType::Padding => unreachable!(),
};
let destination_rw_increase = match self.dst_type {
CopyDataType::RlcAcc | CopyDataType::Bytecode => 0,
Expand Down
Loading
Loading