diff --git a/avm-transpiler/src/opcodes.rs b/avm-transpiler/src/opcodes.rs index 1ee44d1210c..ca41eba9674 100644 --- a/avm-transpiler/src/opcodes.rs +++ b/avm-transpiler/src/opcodes.rs @@ -1,5 +1,5 @@ /// All AVM opcodes -/// Keep updated with TS and docs protocol specs! +/// Keep updated with TS, cpp, and docs protocol specs! #[derive(PartialEq, Copy, Clone, Debug)] pub enum AvmOpcode { // Compute @@ -21,7 +21,6 @@ pub enum AvmOpcode { // Execution environment ADDRESS, STORAGEADDRESS, - ORIGIN, SENDER, PORTAL, FEEPERL1GAS, @@ -102,7 +101,6 @@ impl AvmOpcode { // Execution Environment AvmOpcode::ADDRESS => "ADDRESS", AvmOpcode::STORAGEADDRESS => "STORAGEADDRESS", - AvmOpcode::ORIGIN => "ORIGIN", AvmOpcode::SENDER => "SENDER", AvmOpcode::PORTAL => "PORTAL", AvmOpcode::FEEPERL1GAS => "FEEPERL1GAS", diff --git a/avm-transpiler/src/transpile.rs b/avm-transpiler/src/transpile.rs index 581438c2ccb..0de09a5793c 100644 --- a/avm-transpiler/src/transpile.rs +++ b/avm-transpiler/src/transpile.rs @@ -744,7 +744,6 @@ fn handle_getter_instruction( let opcode = match function { "avmOpcodeAddress" => AvmOpcode::ADDRESS, "avmOpcodeStorageAddress" => AvmOpcode::STORAGEADDRESS, - "avmOpcodeOrigin" => AvmOpcode::ORIGIN, "avmOpcodeSender" => AvmOpcode::SENDER, "avmOpcodePortal" => AvmOpcode::PORTAL, "avmOpcodeFeePerL1Gas" => AvmOpcode::FEEPERL1GAS, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_opcode.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_opcode.cpp index 9ce4baf73dd..05caf1ace28 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_opcode.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_opcode.cpp @@ -31,7 +31,6 @@ const std::unordered_map Bytecode::OPERANDS_NUM = { //// Execution Environment //{OpCode::ADDRESS, }, //{OpCode::STORAGEADDRESS, }, - //{OpCode::ORIGIN, }, //{OpCode::SENDER, }, //{OpCode::PORTAL, }, //{OpCode::FEEPERL1GAS, }, @@ -116,7 +115,6 @@ bool Bytecode::has_in_tag(OpCode const op_code) switch (op_code) { case OpCode::ADDRESS: case OpCode::STORAGEADDRESS: - case OpCode::ORIGIN: case OpCode::SENDER: case OpCode::PORTAL: case OpCode::FEEPERL1GAS: diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_opcode.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_opcode.hpp index 8f04ddcd2d3..98adf14ab29 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_opcode.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_opcode.hpp @@ -40,7 +40,6 @@ enum class OpCode : uint8_t { // Execution Environment ADDRESS, STORAGEADDRESS, - ORIGIN, SENDER, PORTAL, FEEPERL1GAS, diff --git a/docs/docs/protocol-specs/circuits/private-kernel-initial.mdx b/docs/docs/protocol-specs/circuits/private-kernel-initial.mdx index 9770bd2de90..f1815a556e5 100644 --- a/docs/docs/protocol-specs/circuits/private-kernel-initial.mdx +++ b/docs/docs/protocol-specs/circuits/private-kernel-initial.mdx @@ -714,13 +714,13 @@ TransientAccumulatedData --* PublicInputs: transient_accumulated_data Data that represents the caller's intent. -| Field | Type | Description | -| --------------- | ------------------------------------------- | -------------------------------------------- | -| `origin` | `AztecAddress` | The Aztec address of the transaction sender. | -| `function_data` | [`FunctionData`](#functiondata) | Data of the function being called. | -| `args_hash` | `field` | Hash of the function arguments. | -| `tx_context` | [`TransactionContext`](#transactioncontext) | Information about the transaction. | -| `gas_settings` | [`GasSettings`](#gassettings) | User-defined gas limits and max fees. | +| Field | Type | Description | +| --------------- | ------------------------------------------- | ------------------------------------- | +| `origin` | `AztecAddress` | Address of the entrypoint contract. | +| `function_data` | [`FunctionData`](#functiondata) | Data of the function being called. | +| `args_hash` | `field` | Hash of the function arguments. | +| `tx_context` | [`TransactionContext`](#transactioncontext) | Information about the transaction. | +| `gas_settings` | [`GasSettings`](#gassettings) | User-defined gas limits and max fees. | ### `PrivateCall` diff --git a/docs/docs/protocol-specs/public-vm/_nested-context.md b/docs/docs/protocol-specs/public-vm/_nested-context.md index 5de8badab2f..aa081d17a38 100644 --- a/docs/docs/protocol-specs/public-vm/_nested-context.md +++ b/docs/docs/protocol-specs/public-vm/_nested-context.md @@ -14,7 +14,6 @@ nestedContext = deriveContext(context, instr.args, isStaticCall, isDelegateCall) Nested context derivation is defined as follows: ```jsx nestedExecutionEnvironment = ExecutionEnvironment { - origin: context.origin, sender: isDelegateCall ? context.sender : context.address, address: M[addrOffset], storageAddress: isDelegateCall ? context.storageAddress : M[addrOffset], diff --git a/docs/docs/protocol-specs/public-vm/avm-circuit.md b/docs/docs/protocol-specs/public-vm/avm-circuit.md index 57eee866234..b5c3d1ab215 100644 --- a/docs/docs/protocol-specs/public-vm/avm-circuit.md +++ b/docs/docs/protocol-specs/public-vm/avm-circuit.md @@ -178,7 +178,6 @@ The VM circuit's I/O (`AvmPublicInputs`) is defined below: ``` AvmSessionInputs { // Initializes Execution Environment - origin: AztecAddress, feePerL1Gas: field, feePerL2Gas: field, feePerDaGas: field, diff --git a/docs/docs/protocol-specs/public-vm/context.mdx b/docs/docs/protocol-specs/public-vm/context.mdx index 5b17027b07f..7b2d8847c25 100644 --- a/docs/docs/protocol-specs/public-vm/context.mdx +++ b/docs/docs/protocol-specs/public-vm/context.mdx @@ -25,7 +25,6 @@ A context's **execution environment** remains constant throughout a contract cal | --- | --- | --- | | address | `AztecAddress` | | | storageAddress | `AztecAddress` | | -| origin | `AztecAddress` | | | sender | `AztecAddress` | | | portal | `EthAddress` | | | feePerL1Gas | `field` | | @@ -73,7 +72,6 @@ Given a [`PublicCallRequest`](../transactions/tx-object#public-call-request) and INITIAL_EXECUTION_ENVIRONMENT = ExecutionEnvironment { address: PublicCallRequest.contractAddress, storageAddress: PublicCallRequest.CallContext.storageContractAddress, - origin: TxRequest.origin, sender: PublicCallRequest.CallContext.msgSender, portal: PublicCallRequest.CallContext.portalContractAddress, feePerL1Gas: TxRequest.feePerL1Gas, diff --git a/docs/docs/protocol-specs/public-vm/gen/_instruction-set.mdx b/docs/docs/protocol-specs/public-vm/gen/_instruction-set.mdx index 0467dcd11df..d1f4fa379c3 100644 --- a/docs/docs/protocol-specs/public-vm/gen/_instruction-set.mdx +++ b/docs/docs/protocol-specs/public-vm/gen/_instruction-set.mdx @@ -133,154 +133,147 @@ Click on an instruction name to jump to its section. } - 0x11 [`ORIGIN`](#isa-section-origin) - Get the transaction's origination address - { - `M[dstOffset] = context.environment.origin` - } - - - 0x12 [`SENDER`](#isa-section-sender) + 0x11 [`SENDER`](#isa-section-sender) Get the address of the sender (caller of the current context) { `M[dstOffset] = context.environment.sender` } - 0x13 [`PORTAL`](#isa-section-portal) + 0x12 [`PORTAL`](#isa-section-portal) Get the address of the l1 portal contract { `M[dstOffset] = context.environment.portal` } - 0x14 [`FEEPERL1GAS`](#isa-section-feeperl1gas) + 0x13 [`FEEPERL1GAS`](#isa-section-feeperl1gas) Get the fee to be paid per "L1 gas" - constant for entire transaction { `M[dstOffset] = context.environment.feePerL1Gas` } - 0x15 [`FEEPERL2GAS`](#isa-section-feeperl2gas) + 0x14 [`FEEPERL2GAS`](#isa-section-feeperl2gas) Get the fee to be paid per "L2 gas" - constant for entire transaction { `M[dstOffset] = context.environment.feePerL2Gas` } - 0x16 [`FEEPERDAGAS`](#isa-section-feeperdagas) + 0x15 [`FEEPERDAGAS`](#isa-section-feeperdagas) Get the fee to be paid per "DA gas" - constant for entire transaction { `M[dstOffset] = context.environment.feePerDaGas` } - 0x17 [`CONTRACTCALLDEPTH`](#isa-section-contractcalldepth) + 0x16 [`CONTRACTCALLDEPTH`](#isa-section-contractcalldepth) Get how many contract calls deep the current call context is { `M[dstOffset] = context.environment.contractCallDepth` } - 0x18 [`CHAINID`](#isa-section-chainid) + 0x17 [`CHAINID`](#isa-section-chainid) Get this rollup's L1 chain ID { `M[dstOffset] = context.environment.globals.chainId` } - 0x19 [`VERSION`](#isa-section-version) + 0x18 [`VERSION`](#isa-section-version) Get this rollup's L2 version ID { `M[dstOffset] = context.environment.globals.version` } - 0x1a [`BLOCKNUMBER`](#isa-section-blocknumber) + 0x19 [`BLOCKNUMBER`](#isa-section-blocknumber) Get this L2 block's number { `M[dstOffset] = context.environment.globals.blocknumber` } - 0x1b [`TIMESTAMP`](#isa-section-timestamp) + 0x1a [`TIMESTAMP`](#isa-section-timestamp) Get this L2 block's timestamp { `M[dstOffset] = context.environment.globals.timestamp` } - 0x1c [`COINBASE`](#isa-section-coinbase) + 0x1b [`COINBASE`](#isa-section-coinbase) Get the block's beneficiary address { `M[dstOffset] = context.environment.globals.coinbase` } - 0x1d [`BLOCKL1GASLIMIT`](#isa-section-blockl1gaslimit) + 0x1c [`BLOCKL1GASLIMIT`](#isa-section-blockl1gaslimit) Total amount of "L1 gas" that a block can consume { `M[dstOffset] = context.environment.globals.l1GasLimit` } - 0x1e [`BLOCKL2GASLIMIT`](#isa-section-blockl2gaslimit) + 0x1d [`BLOCKL2GASLIMIT`](#isa-section-blockl2gaslimit) Total amount of "L2 gas" that a block can consume { `M[dstOffset] = context.environment.globals.l2GasLimit` } - 0x1f [`BLOCKDAGASLIMIT`](#isa-section-blockdagaslimit) + 0x1e [`BLOCKDAGASLIMIT`](#isa-section-blockdagaslimit) Total amount of "DA gas" that a block can consume { `M[dstOffset] = context.environment.globals.daGasLimit` } - 0x20 [`CALLDATACOPY`](#isa-section-calldatacopy) + 0x1f [`CALLDATACOPY`](#isa-section-calldatacopy) Copy calldata into memory { `M[dstOffset:dstOffset+copySize] = context.environment.calldata[cdOffset:cdOffset+copySize]` } - 0x21 [`L1GASLEFT`](#isa-section-l1gasleft) + 0x20 [`L1GASLEFT`](#isa-section-l1gasleft) Remaining "L1 gas" for this call (after this instruction) { `M[dstOffset] = context.machineState.l1GasLeft` } - 0x22 [`L2GASLEFT`](#isa-section-l2gasleft) + 0x21 [`L2GASLEFT`](#isa-section-l2gasleft) Remaining "L2 gas" for this call (after this instruction) { `M[dstOffset] = context.MachineState.l2GasLeft` } - 0x23 [`DAGASLEFT`](#isa-section-dagasleft) + 0x22 [`DAGASLEFT`](#isa-section-dagasleft) Remaining "DA gas" for this call (after this instruction) { `M[dstOffset] = context.machineState.daGasLeft` } - 0x24 [`JUMP`](#isa-section-jump) + 0x23 [`JUMP`](#isa-section-jump) Jump to a location in the bytecode { `context.machineState.pc = loc` } - 0x25 [`JUMPI`](#isa-section-jumpi) + 0x24 [`JUMPI`](#isa-section-jumpi) Conditionally jump to a location in the bytecode { `context.machineState.pc = M[condOffset] > 0 ? loc : context.machineState.pc` } - 0x26 [`INTERNALCALL`](#isa-section-internalcall) + 0x25 [`INTERNALCALL`](#isa-section-internalcall) Make an internal call. Push the current PC to the internal call stack and jump to the target location. {`context.machineState.internalCallStack.push(context.machineState.pc) @@ -288,49 +281,49 @@ context.machineState.pc = loc`} - 0x27 [`INTERNALRETURN`](#isa-section-internalreturn) + 0x26 [`INTERNALRETURN`](#isa-section-internalreturn) Return from an internal call. Pop from the internal call stack and jump to the popped location. { `context.machineState.pc = context.machineState.internalCallStack.pop()` } - 0x28 [`SET`](#isa-section-set) + 0x27 [`SET`](#isa-section-set) Set a memory word from a constant in the bytecode { `M[dstOffset] = const` } - 0x29 [`MOV`](#isa-section-mov) + 0x28 [`MOV`](#isa-section-mov) Move a word from source memory location to destination { `M[dstOffset] = M[srcOffset]` } - 0x2a [`CMOV`](#isa-section-cmov) + 0x29 [`CMOV`](#isa-section-cmov) Move a word (conditionally chosen) from one memory location to another (`d = cond > 0 ? a : b`) { `M[dstOffset] = M[condOffset] > 0 ? M[aOffset] : M[bOffset]` } - 0x2b [`SLOAD`](#isa-section-sload) + 0x2a [`SLOAD`](#isa-section-sload) Load a word from this contract's persistent public storage. Zero is loaded for unwritten slots. {`M[dstOffset] = S[M[slotOffset]]`} - 0x2c [`SSTORE`](#isa-section-sstore) + 0x2b [`SSTORE`](#isa-section-sstore) Write a word to this contract's persistent public storage {`S[M[slotOffset]] = M[srcOffset]`} - 0x2d [`NOTEHASHEXISTS`](#isa-section-notehashexists) + 0x2c [`NOTEHASHEXISTS`](#isa-section-notehashexists) Check whether a note hash exists in the note hash tree (as of the start of the current block) {`exists = context.worldState.noteHashes.has({ @@ -341,7 +334,7 @@ M[existsOffset] = exists`} - 0x2e [`EMITNOTEHASH`](#isa-section-emitnotehash) + 0x2d [`EMITNOTEHASH`](#isa-section-emitnotehash) Emit a new note hash to be inserted into the note hash tree {`context.worldState.noteHashes.append( @@ -350,7 +343,7 @@ M[existsOffset] = exists`} - 0x2f [`NULLIFIEREXISTS`](#isa-section-nullifierexists) + 0x2e [`NULLIFIEREXISTS`](#isa-section-nullifierexists) Check whether a nullifier exists in the nullifier tree (including nullifiers from earlier in the current transaction or from earlier in the current block) {`exists = pendingNullifiers.has(M[addressOffset], M[nullifierOffset]) || context.worldState.nullifiers.has( @@ -360,7 +353,7 @@ M[existsOffset] = exists`} - 0x30 [`EMITNULLIFIER`](#isa-section-emitnullifier) + 0x2f [`EMITNULLIFIER`](#isa-section-emitnullifier) Emit a new nullifier to be inserted into the nullifier tree {`context.worldState.nullifiers.append( @@ -369,7 +362,7 @@ M[existsOffset] = exists`} - 0x31 [`L1TOL2MSGEXISTS`](#isa-section-l1tol2msgexists) + 0x30 [`L1TOL2MSGEXISTS`](#isa-section-l1tol2msgexists) Check if a message exists in the L1-to-L2 message tree {`exists = context.worldState.l1ToL2Messages.has({ @@ -379,7 +372,7 @@ M[existsOffset] = exists`} - 0x32 [`HEADERMEMBER`](#isa-section-headermember) + 0x31 [`HEADERMEMBER`](#isa-section-headermember) Check if a header exists in the [archive tree](../state/archive) and retrieve the specified member if so {`exists = context.worldState.header.has({ @@ -392,7 +385,7 @@ if exists: - 0x33 [`GETCONTRACTINSTANCE`](#isa-section-getcontractinstance) + 0x32 [`GETCONTRACTINSTANCE`](#isa-section-getcontractinstance) Copies contract instance data to memory {`M[dstOffset:dstOffset+CONTRACT_INSTANCE_SIZE+1] = [ @@ -407,7 +400,7 @@ if exists: - 0x34 [`EMITUNENCRYPTEDLOG`](#isa-section-emitunencryptedlog) + 0x33 [`EMITUNENCRYPTEDLOG`](#isa-section-emitunencryptedlog) Emit an unencrypted log {`context.accruedSubstate.unencryptedLogs.append( @@ -420,7 +413,7 @@ if exists: - 0x35 [`SENDL2TOL1MSG`](#isa-section-sendl2tol1msg) + 0x34 [`SENDL2TOL1MSG`](#isa-section-sendl2tol1msg) Send an L2-to-L1 message {`context.accruedSubstate.sentL2ToL1Messages.append( @@ -433,7 +426,7 @@ if exists: - 0x36 [`CALL`](#isa-section-call) + 0x35 [`CALL`](#isa-section-call) Call into another contract {`// instr.args are { gasOffset, addrOffset, argsOffset, retOffset, retSize } @@ -448,7 +441,7 @@ updateContextAfterNestedCall(context, instr.args, nestedContext)`} - 0x37 [`STATICCALL`](#isa-section-staticcall) + 0x36 [`STATICCALL`](#isa-section-staticcall) Call into another contract, disallowing World State and Accrued Substate modifications {`// instr.args are { gasOffset, addrOffset, argsOffset, retOffset, retSize } @@ -463,7 +456,7 @@ updateContextAfterNestedCall(context, instr.args, nestedContext)`} - 0x38 [`DELEGATECALL`](#isa-section-delegatecall) + 0x37 [`DELEGATECALL`](#isa-section-delegatecall) Call into another contract, but keep the caller's `sender` and `storageAddress` {`// instr.args are { gasOffset, addrOffset, argsOffset, retOffset, retSize } @@ -478,7 +471,7 @@ updateContextAfterNestedCall(context, instr.args, nestedContext)`} - 0x39 [`RETURN`](#isa-section-return) + 0x38 [`RETURN`](#isa-section-return) Halt execution within this context (without revert), optionally returning some data {`context.contractCallResults.output = M[retOffset:retOffset+retSize] @@ -486,7 +479,7 @@ halt`} - 0x3a [`REVERT`](#isa-section-revert) + 0x39 [`REVERT`](#isa-section-revert) Halt execution within this context as `reverted`, optionally returning some data {`context.contractCallResults.output = M[retOffset:retOffset+retSize] @@ -849,29 +842,12 @@ Get the _storage_ address of the currently executing context [![](/img/protocol-specs/public-vm/bit-formats/STORAGEADDRESS.png)](/img/protocol-specs/public-vm/bit-formats/STORAGEADDRESS.png) -### `ORIGIN` -Get the transaction's origination address - -[See in table.](#isa-table-origin) - -- **Opcode**: 0x11 -- **Category**: Execution Environment -- **Flags**: - - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. -- **Args**: - - **dstOffset**: memory offset specifying where to store operation's result -- **Expression**: `M[dstOffset] = context.environment.origin` -- **Tag updates**: `T[dstOffset] = u32` -- **Bit-size**: 56 - -[![](/img/protocol-specs/public-vm/bit-formats/ORIGIN.png)](/img/protocol-specs/public-vm/bit-formats/ORIGIN.png) - ### `SENDER` Get the address of the sender (caller of the current context) [See in table.](#isa-table-sender) -- **Opcode**: 0x12 +- **Opcode**: 0x11 - **Category**: Execution Environment - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -888,7 +864,7 @@ Get the address of the l1 portal contract [See in table.](#isa-table-portal) -- **Opcode**: 0x13 +- **Opcode**: 0x12 - **Category**: Execution Environment - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -905,7 +881,7 @@ Get the fee to be paid per "L1 gas" - constant for entire transaction [See in table.](#isa-table-feeperl1gas) -- **Opcode**: 0x14 +- **Opcode**: 0x13 - **Category**: Execution Environment - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -922,7 +898,7 @@ Get the fee to be paid per "L2 gas" - constant for entire transaction [See in table.](#isa-table-feeperl2gas) -- **Opcode**: 0x15 +- **Opcode**: 0x14 - **Category**: Execution Environment - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -939,7 +915,7 @@ Get the fee to be paid per "DA gas" - constant for entire transaction [See in table.](#isa-table-feeperdagas) -- **Opcode**: 0x16 +- **Opcode**: 0x15 - **Category**: Execution Environment - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -956,7 +932,7 @@ Get how many contract calls deep the current call context is [See in table.](#isa-table-contractcalldepth) -- **Opcode**: 0x17 +- **Opcode**: 0x16 - **Category**: Execution Environment - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -974,7 +950,7 @@ Get this rollup's L1 chain ID [See in table.](#isa-table-chainid) -- **Opcode**: 0x18 +- **Opcode**: 0x17 - **Category**: Execution Environment - Globals - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -991,7 +967,7 @@ Get this rollup's L2 version ID [See in table.](#isa-table-version) -- **Opcode**: 0x19 +- **Opcode**: 0x18 - **Category**: Execution Environment - Globals - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1008,7 +984,7 @@ Get this L2 block's number [See in table.](#isa-table-blocknumber) -- **Opcode**: 0x1a +- **Opcode**: 0x19 - **Category**: Execution Environment - Globals - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1025,7 +1001,7 @@ Get this L2 block's timestamp [See in table.](#isa-table-timestamp) -- **Opcode**: 0x1b +- **Opcode**: 0x1a - **Category**: Execution Environment - Globals - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1042,7 +1018,7 @@ Get the block's beneficiary address [See in table.](#isa-table-coinbase) -- **Opcode**: 0x1c +- **Opcode**: 0x1b - **Category**: Execution Environment - Globals - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1059,7 +1035,7 @@ Total amount of "L1 gas" that a block can consume [See in table.](#isa-table-blockl1gaslimit) -- **Opcode**: 0x1d +- **Opcode**: 0x1c - **Category**: Execution Environment - Globals - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1076,7 +1052,7 @@ Total amount of "L2 gas" that a block can consume [See in table.](#isa-table-blockl2gaslimit) -- **Opcode**: 0x1e +- **Opcode**: 0x1d - **Category**: Execution Environment - Globals - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1093,7 +1069,7 @@ Total amount of "DA gas" that a block can consume [See in table.](#isa-table-blockdagaslimit) -- **Opcode**: 0x1f +- **Opcode**: 0x1e - **Category**: Execution Environment - Globals - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1110,7 +1086,7 @@ Copy calldata into memory [See in table.](#isa-table-calldatacopy) -- **Opcode**: 0x20 +- **Opcode**: 0x1f - **Category**: Execution Environment - Calldata - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1130,7 +1106,7 @@ Remaining "L1 gas" for this call (after this instruction) [See in table.](#isa-table-l1gasleft) -- **Opcode**: 0x21 +- **Opcode**: 0x20 - **Category**: Machine State - Gas - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1147,7 +1123,7 @@ Remaining "L2 gas" for this call (after this instruction) [See in table.](#isa-table-l2gasleft) -- **Opcode**: 0x22 +- **Opcode**: 0x21 - **Category**: Machine State - Gas - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1164,7 +1140,7 @@ Remaining "DA gas" for this call (after this instruction) [See in table.](#isa-table-dagasleft) -- **Opcode**: 0x23 +- **Opcode**: 0x22 - **Category**: Machine State - Gas - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1181,7 +1157,7 @@ Jump to a location in the bytecode [See in table.](#isa-table-jump) -- **Opcode**: 0x24 +- **Opcode**: 0x23 - **Category**: Machine State - Control Flow - **Args**: - **loc**: target location to jump to @@ -1196,7 +1172,7 @@ Conditionally jump to a location in the bytecode [See in table.](#isa-table-jumpi) -- **Opcode**: 0x25 +- **Opcode**: 0x24 - **Category**: Machine State - Control Flow - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1214,7 +1190,7 @@ Make an internal call. Push the current PC to the internal call stack and jump t [See in table.](#isa-table-internalcall) -- **Opcode**: 0x26 +- **Opcode**: 0x25 - **Category**: Machine State - Control Flow - **Args**: - **loc**: target location to jump/call to @@ -1232,7 +1208,7 @@ Return from an internal call. Pop from the internal call stack and jump to the p [See in table.](#isa-table-internalreturn) -- **Opcode**: 0x27 +- **Opcode**: 0x26 - **Category**: Machine State - Control Flow - **Expression**: `context.machineState.pc = context.machineState.internalCallStack.pop()` - **Bit-size**: 16 @@ -1244,7 +1220,7 @@ Set a memory word from a constant in the bytecode [See in table.](#isa-table-set) -- **Opcode**: 0x28 +- **Opcode**: 0x27 - **Category**: Machine State - Memory - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1264,7 +1240,7 @@ Move a word from source memory location to destination [See in table.](#isa-table-mov) -- **Opcode**: 0x29 +- **Opcode**: 0x28 - **Category**: Machine State - Memory - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1282,7 +1258,7 @@ Move a word (conditionally chosen) from one memory location to another (`d = con [See in table.](#isa-table-cmov) -- **Opcode**: 0x2a +- **Opcode**: 0x29 - **Category**: Machine State - Memory - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1303,7 +1279,7 @@ Load a word from this contract's persistent public storage. Zero is loaded for u [See in table.](#isa-table-sload) -- **Opcode**: 0x2b +- **Opcode**: 0x2a - **Category**: World State - Public Storage - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1348,7 +1324,7 @@ Write a word to this contract's persistent public storage [See in table.](#isa-table-sstore) -- **Opcode**: 0x2c +- **Opcode**: 0x2b - **Category**: World State - Public Storage - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1388,7 +1364,7 @@ Check whether a note hash exists in the note hash tree (as of the start of the c [See in table.](#isa-table-notehashexists) -- **Opcode**: 0x2d +- **Opcode**: 0x2c - **Category**: World State - Notes & Nullifiers - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1426,7 +1402,7 @@ Emit a new note hash to be inserted into the note hash tree [See in table.](#isa-table-emitnotehash) -- **Opcode**: 0x2e +- **Opcode**: 0x2d - **Category**: World State - Notes & Nullifiers - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1458,7 +1434,7 @@ Check whether a nullifier exists in the nullifier tree (including nullifiers fro [See in table.](#isa-table-nullifierexists) -- **Opcode**: 0x2f +- **Opcode**: 0x2e - **Category**: World State - Notes & Nullifiers - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1495,7 +1471,7 @@ Emit a new nullifier to be inserted into the nullifier tree [See in table.](#isa-table-emitnullifier) -- **Opcode**: 0x30 +- **Opcode**: 0x2f - **Category**: World State - Notes & Nullifiers - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1527,7 +1503,7 @@ Check if a message exists in the L1-to-L2 message tree [See in table.](#isa-table-l1tol2msgexists) -- **Opcode**: 0x31 +- **Opcode**: 0x30 - **Category**: World State - Messaging - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1566,7 +1542,7 @@ Check if a header exists in the [archive tree](../state/archive) and retrieve th [See in table.](#isa-table-headermember) -- **Opcode**: 0x32 +- **Opcode**: 0x31 - **Category**: World State - Archive Tree & Headers - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1609,7 +1585,7 @@ Copies contract instance data to memory [See in table.](#isa-table-getcontractinstance) -- **Opcode**: 0x33 +- **Opcode**: 0x32 - **Category**: Other - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1639,7 +1615,7 @@ Emit an unencrypted log [See in table.](#isa-table-emitunencryptedlog) -- **Opcode**: 0x34 +- **Opcode**: 0x33 - **Category**: Accrued Substate - Logging - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1666,7 +1642,7 @@ Send an L2-to-L1 message [See in table.](#isa-table-sendl2tol1msg) -- **Opcode**: 0x35 +- **Opcode**: 0x34 - **Category**: Accrued Substate - Messaging - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1692,7 +1668,7 @@ Call into another contract [See in table.](#isa-table-call) -- **Opcode**: 0x36 +- **Opcode**: 0x35 - **Category**: Control Flow - Contract Calls - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1740,7 +1716,7 @@ Call into another contract, disallowing World State and Accrued Substate modific [See in table.](#isa-table-staticcall) -- **Opcode**: 0x37 +- **Opcode**: 0x36 - **Category**: Control Flow - Contract Calls - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1785,7 +1761,7 @@ Call into another contract, but keep the caller's `sender` and `storageAddress` [See in table.](#isa-table-delegatecall) -- **Opcode**: 0x38 +- **Opcode**: 0x37 - **Category**: Control Flow - Contract Calls - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1830,7 +1806,7 @@ Halt execution within this context (without revert), optionally returning some d [See in table.](#isa-table-return) -- **Opcode**: 0x39 +- **Opcode**: 0x38 - **Category**: Control Flow - Contract Calls - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. @@ -1852,7 +1828,7 @@ Halt execution within this context as `reverted`, optionally returning some data [See in table.](#isa-table-revert) -- **Opcode**: 0x3a +- **Opcode**: 0x39 - **Category**: Control Flow - Contract Calls - **Flags**: - **indirect**: Toggles whether each memory-offset argument is an indirect offset. Rightmost bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`. diff --git a/docs/src/preprocess/InstructionSet/InstructionSet.js b/docs/src/preprocess/InstructionSet/InstructionSet.js index c6c3721963d..496b2a8128d 100644 --- a/docs/src/preprocess/InstructionSet/InstructionSet.js +++ b/docs/src/preprocess/InstructionSet/InstructionSet.js @@ -529,24 +529,6 @@ const INSTRUCTION_SET_RAW = [ "Tag checks": "", "Tag updates": "`T[dstOffset] = u32`", }, - { - id: "origin", - Name: "`ORIGIN`", - Category: "Execution Environment", - Flags: [{ name: "indirect", description: INDIRECT_FLAG_DESCRIPTION }], - Args: [ - { - name: "dstOffset", - description: - "memory offset specifying where to store operation's result", - }, - ], - Expression: "`M[dstOffset] = context.environment.origin`", - Summary: "Get the transaction's origination address", - Details: "", - "Tag checks": "", - "Tag updates": "`T[dstOffset] = u32`", - }, { id: "sender", Name: "`SENDER`", diff --git a/noir-projects/aztec-nr/aztec/src/context/avm_context.nr b/noir-projects/aztec-nr/aztec/src/context/avm_context.nr index 504dec77522..0446511184d 100644 --- a/noir-projects/aztec-nr/aztec/src/context/avm_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/avm_context.nr @@ -20,9 +20,6 @@ impl AvmContext { AvmContext { inputs } } - pub fn origin(self) -> AztecAddress { - origin() - } pub fn storage_address(self) -> AztecAddress { storage_address() } @@ -235,9 +232,6 @@ fn address() -> AztecAddress {} #[oracle(avmOpcodeStorageAddress)] fn storage_address() -> AztecAddress {} -#[oracle(avmOpcodeOrigin)] -fn origin() -> AztecAddress {} - #[oracle(avmOpcodeSender)] fn sender() -> AztecAddress {} diff --git a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr index 2989e32a9f6..0102de54324 100644 --- a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -206,11 +206,6 @@ contract AvmTest { context.msg_sender() } - #[aztec(public-vm)] - fn get_origin() -> pub AztecAddress { - context.origin() - } - #[aztec(public-vm)] fn get_portal() -> pub EthAddress { context.this_portal_address() diff --git a/yarn-project/simulator/src/avm/avm_execution_environment.ts b/yarn-project/simulator/src/avm/avm_execution_environment.ts index a3dbb81f660..def966f15ed 100644 --- a/yarn-project/simulator/src/avm/avm_execution_environment.ts +++ b/yarn-project/simulator/src/avm/avm_execution_environment.ts @@ -23,7 +23,6 @@ export class AvmExecutionEnvironment { constructor( public readonly address: AztecAddress, public readonly storageAddress: AztecAddress, - public readonly origin: AztecAddress, public readonly sender: AztecAddress, public readonly portal: EthAddress, public readonly feePerL1Gas: Fr, @@ -57,7 +56,6 @@ export class AvmExecutionEnvironment { return new AvmExecutionEnvironment( targetAddress, /*storageAddress=*/ targetAddress, - this.origin, this.address, this.portal, this.feePerL1Gas, @@ -83,7 +81,6 @@ export class AvmExecutionEnvironment { return new AvmExecutionEnvironment( address, /*storageAddress=*/ address, - this.origin, this.sender, this.portal, this.feePerL1Gas, @@ -109,7 +106,6 @@ export class AvmExecutionEnvironment { return new AvmExecutionEnvironment( address, this.storageAddress, - this.origin, this.sender, this.portal, this.feePerL1Gas, diff --git a/yarn-project/simulator/src/avm/avm_gas.ts b/yarn-project/simulator/src/avm/avm_gas.ts index 5a80d70baf9..77ee6173996 100644 --- a/yarn-project/simulator/src/avm/avm_gas.ts +++ b/yarn-project/simulator/src/avm/avm_gas.ts @@ -78,7 +78,6 @@ export const GasCosts: Record = { // Execution environment [Opcode.ADDRESS]: TemporaryDefaultGasCost, [Opcode.STORAGEADDRESS]: TemporaryDefaultGasCost, - [Opcode.ORIGIN]: TemporaryDefaultGasCost, [Opcode.SENDER]: TemporaryDefaultGasCost, [Opcode.PORTAL]: TemporaryDefaultGasCost, [Opcode.FEEPERL1GAS]: TemporaryDefaultGasCost, diff --git a/yarn-project/simulator/src/avm/avm_simulator.test.ts b/yarn-project/simulator/src/avm/avm_simulator.test.ts index 58d451ab0b6..051c3432de3 100644 --- a/yarn-project/simulator/src/avm/avm_simulator.test.ts +++ b/yarn-project/simulator/src/avm/avm_simulator.test.ts @@ -201,11 +201,6 @@ describe('AVM simulator: transpiled Noir contracts', () => { await testEnvGetter('sender', sender, 'get_sender'); }); - it('origin', async () => { - const origin = AztecAddress.fromField(new Fr(1)); - await testEnvGetter('origin', origin, 'get_origin'); - }); - it('portal', async () => { const portal = EthAddress.fromField(new Fr(1)); await testEnvGetter('portal', portal, 'get_portal'); diff --git a/yarn-project/simulator/src/avm/fixtures/index.ts b/yarn-project/simulator/src/avm/fixtures/index.ts index c3f775c484d..c03fa818166 100644 --- a/yarn-project/simulator/src/avm/fixtures/index.ts +++ b/yarn-project/simulator/src/avm/fixtures/index.ts @@ -61,7 +61,6 @@ export function initExecutionEnvironment(overrides?: Partial [Cast.opcode, Cast], [Address.opcode, Address], [StorageAddress.opcode, StorageAddress], - [Origin.opcode, Origin], [Sender.opcode, Sender], [Portal.opcode, Portal], [FeePerL1Gas.opcode, FeePerL1Gas], diff --git a/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts b/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts index c2e092e1a5b..6f5bb70eb41 100644 --- a/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts +++ b/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts @@ -3,7 +3,7 @@ import { strict as assert } from 'assert'; import { BufferCursor } from './buffer_cursor.js'; /** - * All AVM opcodes. (Keep in sync with cpp counterpart code avm_opcode.hpp). + * All AVM opcodes. (Keep in sync with cpp counterpart code avm_opcode.hpp and rs in opcodes.rs). * Source: https://yp-aztec.netlify.app/docs/public-vm/instruction-set */ export enum Opcode { @@ -26,7 +26,6 @@ export enum Opcode { // Execution environment ADDRESS, STORAGEADDRESS, - ORIGIN, SENDER, PORTAL, FEEPERL1GAS, diff --git a/yarn-project/simulator/src/public/transitional_adaptors.ts b/yarn-project/simulator/src/public/transitional_adaptors.ts index 00519f933a6..81bd36011e6 100644 --- a/yarn-project/simulator/src/public/transitional_adaptors.ts +++ b/yarn-project/simulator/src/public/transitional_adaptors.ts @@ -41,7 +41,6 @@ export function createAvmExecutionEnvironment( return new AvmExecutionEnvironment( current.contractAddress, current.callContext.storageContractAddress, - current.callContext.msgSender, // TODO: origin is not available current.callContext.msgSender, current.callContext.portalContractAddress, globalVariables.gasFees.feePerL1Gas,