Skip to content

Commit

Permalink
fix: Remove tx.origin
Browse files Browse the repository at this point in the history
Fixes #5756
  • Loading branch information
spalladino committed Apr 16, 2024
1 parent 95eadd6 commit a175961
Show file tree
Hide file tree
Showing 18 changed files with 7 additions and 70 deletions.
2 changes: 0 additions & 2 deletions barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_opcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const std::unordered_map<OpCode, size_t> Bytecode::OPERANDS_NUM = {
//// Execution Environment
//{OpCode::ADDRESS, },
//{OpCode::STORAGEADDRESS, },
//{OpCode::ORIGIN, },
//{OpCode::SENDER, },
//{OpCode::PORTAL, },
//{OpCode::FEEPERL1GAS, },
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ enum class OpCode : uint8_t {
// Execution Environment
ADDRESS,
STORAGEADDRESS,
ORIGIN,
SENDER,
PORTAL,
FEEPERL1GAS,
Expand Down
14 changes: 7 additions & 7 deletions docs/docs/protocol-specs/circuits/private-kernel-initial.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
1 change: 0 additions & 1 deletion docs/docs/protocol-specs/public-vm/_nested-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
1 change: 0 additions & 1 deletion docs/docs/protocol-specs/public-vm/avm-circuit.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions docs/docs/protocol-specs/public-vm/context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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` | |
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 0 additions & 18 deletions docs/src/preprocess/InstructionSet/InstructionSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`",
Expand Down
6 changes: 0 additions & 6 deletions noir-projects/aztec-nr/aztec/src/context/avm_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ impl AvmContext {
AvmContext { inputs }
}

pub fn origin(self) -> AztecAddress {
origin()
}
pub fn storage_address(self) -> AztecAddress {
storage_address()
}
Expand Down Expand Up @@ -235,9 +232,6 @@ fn address() -> AztecAddress {}
#[oracle(avmOpcodeStorageAddress)]
fn storage_address() -> AztecAddress {}

#[oracle(avmOpcodeOrigin)]
fn origin() -> AztecAddress {}

#[oracle(avmOpcodeSender)]
fn sender() -> AztecAddress {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 0 additions & 4 deletions yarn-project/simulator/src/avm/avm_execution_environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -57,7 +56,6 @@ export class AvmExecutionEnvironment {
return new AvmExecutionEnvironment(
targetAddress,
/*storageAddress=*/ targetAddress,
this.origin,
this.address,
this.portal,
this.feePerL1Gas,
Expand All @@ -83,7 +81,6 @@ export class AvmExecutionEnvironment {
return new AvmExecutionEnvironment(
address,
/*storageAddress=*/ address,
this.origin,
this.sender,
this.portal,
this.feePerL1Gas,
Expand All @@ -109,7 +106,6 @@ export class AvmExecutionEnvironment {
return new AvmExecutionEnvironment(
address,
this.storageAddress,
this.origin,
this.sender,
this.portal,
this.feePerL1Gas,
Expand Down
1 change: 0 additions & 1 deletion yarn-project/simulator/src/avm/avm_gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const GasCosts: Record<Opcode, Gas | typeof DynamicGasCost> = {
// Execution environment
[Opcode.ADDRESS]: TemporaryDefaultGasCost,
[Opcode.STORAGEADDRESS]: TemporaryDefaultGasCost,
[Opcode.ORIGIN]: TemporaryDefaultGasCost,
[Opcode.SENDER]: TemporaryDefaultGasCost,
[Opcode.PORTAL]: TemporaryDefaultGasCost,
[Opcode.FEEPERL1GAS]: TemporaryDefaultGasCost,
Expand Down
5 changes: 0 additions & 5 deletions yarn-project/simulator/src/avm/avm_simulator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 0 additions & 1 deletion yarn-project/simulator/src/avm/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export function initExecutionEnvironment(overrides?: Partial<AvmExecutionEnviron
return new AvmExecutionEnvironment(
overrides?.address ?? AztecAddress.zero(),
overrides?.storageAddress ?? AztecAddress.zero(),
overrides?.origin ?? AztecAddress.zero(),
overrides?.sender ?? AztecAddress.zero(),
overrides?.portal ?? EthAddress.ZERO,
overrides?.feePerL1Gas ?? Fr.zero(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
FeePerDAGas,
FeePerL1Gas,
FeePerL2Gas,
Origin,
Portal,
Sender,
StorageAddress,
Expand All @@ -21,7 +20,6 @@ type EnvInstruction =
| typeof FeePerL1Gas
| typeof FeePerL2Gas
| typeof FeePerDAGas
| typeof Origin
| typeof Sender
| typeof StorageAddress
| typeof Address;
Expand All @@ -30,7 +28,6 @@ describe.each([
[FeePerL1Gas, 'feePerL1Gas'],
[FeePerL2Gas, 'feePerL2Gas'],
[FeePerDAGas, 'feePerDaGas'],
[Origin, 'origin'],
[Sender, 'sender'],
[StorageAddress, 'storageAddress'],
[Address, 'address'],
Expand Down
9 changes: 0 additions & 9 deletions yarn-project/simulator/src/avm/opcodes/environment_getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ export class Sender extends EnvironmentGetterInstruction {
}
}

export class Origin extends EnvironmentGetterInstruction {
static type: string = 'ORIGIN';
static readonly opcode: Opcode = Opcode.ORIGIN;

protected getEnvironmentValue(env: AvmExecutionEnvironment) {
return env.origin;
}
}

export class FeePerL1Gas extends EnvironmentGetterInstruction {
static type: string = 'FEEPERL1GAS';
static readonly opcode: Opcode = Opcode.FEEPERL1GAS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
NoteHashExists,
NullifierExists,
Or,
Origin,
Portal,
Return,
Revert,
Expand Down Expand Up @@ -82,7 +81,6 @@ const INSTRUCTION_SET = () =>
[Cast.opcode, Cast],
[Address.opcode, Address],
[StorageAddress.opcode, StorageAddress],
[Origin.opcode, Origin],
[Sender.opcode, Sender],
[Portal.opcode, Portal],
[FeePerL1Gas.opcode, FeePerL1Gas],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export enum Opcode {
// Execution environment
ADDRESS,
STORAGEADDRESS,
ORIGIN,
SENDER,
PORTAL,
FEEPERL1GAS,
Expand Down
1 change: 0 additions & 1 deletion yarn-project/simulator/src/public/transitional_adaptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a175961

Please sign in to comment.