Skip to content

Commit

Permalink
feat(avm): add storage address kernel opcode (#6863)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasRidhuan committed Jun 4, 2024
1 parent f3234f1 commit 19aba3e
Show file tree
Hide file tree
Showing 15 changed files with 483 additions and 355 deletions.
7 changes: 6 additions & 1 deletion barretenberg/cpp/pil/avm/avm_main.pil
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace avm_main(256);
// CALL CONTEXT
pol commit sel_op_sender;
pol commit sel_op_address;
pol commit sel_op_storage_address;

// FEES
pol commit sel_op_fee_per_l2_gas;
Expand Down Expand Up @@ -230,6 +231,7 @@ namespace avm_main(256);
// opcode decomposition.
sel_op_sender * (1 - sel_op_sender) = 0;
sel_op_address * (1 - sel_op_address) = 0;
sel_op_storage_address * (1 - sel_op_storage_address) = 0;
sel_op_chain_id * (1 - sel_op_chain_id) = 0;
sel_op_version * (1 - sel_op_version) = 0;
sel_op_block_number * (1 - sel_op_block_number) = 0;
Expand Down Expand Up @@ -361,7 +363,7 @@ namespace avm_main(256);

//===== KERNEL LOOKUPS =======================================================
pol KERNEL_INPUT_SELECTORS = (
sel_op_sender + sel_op_address + sel_op_chain_id + sel_op_version + sel_op_block_number + sel_op_coinbase +
sel_op_sender + sel_op_address + sel_op_storage_address + sel_op_chain_id + sel_op_version + sel_op_block_number + sel_op_coinbase +
sel_op_timestamp + sel_op_fee_per_l2_gas + sel_op_fee_per_da_gas + sel_op_transaction_fee
);
// Ensure that only one kernel lookup is active when the kernel_in_offset is active
Expand Down Expand Up @@ -510,6 +512,9 @@ namespace avm_main(256);
#[ADDRESS_KERNEL]
sel_op_address * (avm_kernel.kernel_in_offset - constants.ADDRESS_SELECTOR) = 0;

#[STORAGE_ADDRESS_KERNEL]
sel_op_storage_address * (avm_kernel.kernel_in_offset - constants.STORAGE_ADDRESS_SELECTOR) = 0;

// FEES
#[FEE_DA_GAS_KERNEL]
sel_op_fee_per_da_gas * (avm_kernel.kernel_in_offset - constants.FEE_PER_DA_GAS_SELECTOR) = 0;
Expand Down
1 change: 1 addition & 0 deletions barretenberg/cpp/pil/avm/constants.pil
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace constants(256);
// From Public Context Inputs
pol SENDER_SELECTOR = 0;
pol ADDRESS_SELECTOR = 1;
pol STORAGE_ADDRESS_SELECTOR = 2;

// NOTE: constant expression evaluation does not seem to be supported yet in pil
// pol START_GLOBAL_VARIABLES = CALL_CONTEXT_LENGTH + HEADER_LENGTH = 6 + 23 = 29
Expand Down
Loading

0 comments on commit 19aba3e

Please sign in to comment.