Skip to content

Commit

Permalink
fix EIP1153: is_static check and reversion
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc committed Apr 26, 2024
1 parent 3eebe88 commit 53a5bd7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
9 changes: 9 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 @@ -1179,6 +1179,14 @@ impl<'a> CircuitInputStateRef<'a> {
None
}
}
OperationRef(Target::TransientStorage, idx) => {
let operation = &self.block.container.transient_storage[*idx];
if operation.rw().is_write() && operation.reversible() {
Some(OpEnum::TransientStorage(operation.op().reverse()))
} else {
None
}
}
OperationRef(Target::TxAccessListAccount, idx) => {
let operation = &self.block.container.tx_access_list_account[*idx];
if operation.rw().is_write() && operation.reversible() {
Expand Down Expand Up @@ -1698,6 +1706,7 @@ impl<'a> CircuitInputStateRef<'a> {
OpcodeId::RETURNDATACOPY => Some(ExecError::ReturnDataOutOfBounds),
// Break write protection (CALL with value will be handled below)
OpcodeId::SSTORE
| OpcodeId::TSTORE
| OpcodeId::CREATE
| OpcodeId::CREATE2
| OpcodeId::SELFDESTRUCT
Expand Down
1 change: 1 addition & 0 deletions bus-mapping/src/evm/opcodes/error_write_protection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ impl Opcode for ErrorWriteProtection {
// assert op code can only be following codes
assert!([
OpcodeId::SSTORE,
OpcodeId::TSTORE,
OpcodeId::CREATE,
OpcodeId::CREATE2,
OpcodeId::CALL,
Expand Down
7 changes: 5 additions & 2 deletions bus-mapping/src/operation/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ impl OperationContainer {
OperationRef::from((Target::Storage, self.storage.len() - 1))
}
OpEnum::TransientStorage(op) => {
// removed rwc_inner_chunk here... does that matter?
self.transient_storage.push(Operation::new(rwc, rw, op));
self.transient_storage.push(if reversible {
Operation::new_reversible(rwc, rw, op)
} else {
Operation::new(rwc, rw, op)
});
OperationRef::from((Target::TransientStorage, self.transient_storage.len() - 1))
}
OpEnum::TxAccessListAccount(op) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ impl<F: Field> ExecutionGadget<F> for ErrorWriteProtectionGadget<F> {
// max_degree. otherwise need to do fixed lookup for these opcodes
// checking.
cb.require_in_set(
"ErrorWriteProtection only happens in [CALL, SSTORE, CREATE, CREATE2, SELFDESTRUCT, LOG0..4 ]",
"ErrorWriteProtection only happens in [CALL, SSTORE, TSTORE, CREATE, CREATE2, SELFDESTRUCT, LOG0..4 ]",
opcode.expr(),
vec![
OpcodeId::CALL.expr(),
OpcodeId::SSTORE.expr(),
OpcodeId::TSTORE.expr(),
OpcodeId::CREATE.expr(),
OpcodeId::CREATE2.expr(),
OpcodeId::SELFDESTRUCT.expr(),
Expand Down

0 comments on commit 53a5bd7

Please sign in to comment.