From 2e10c6e87712047d6a476bdd0ea18f7e87277ea3 Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Thu, 5 Sep 2024 17:59:03 +0000 Subject: [PATCH] choreremove coinbase and block gas limit opcodes from AVM --- avm-transpiler/src/opcodes.rs | 6 - barretenberg/cpp/pil/avm/constants_gen.pil | 1 - barretenberg/cpp/pil/avm/kernel.pil | 5 +- barretenberg/cpp/pil/avm/main.pil | 2 - .../vm/avm/tests/execution.test.cpp | 44 ++--- .../barretenberg/vm/avm/tests/kernel.test.cpp | 60 ------ .../vm/avm/trace/deserialization.cpp | 5 +- .../barretenberg/vm/avm/trace/execution.cpp | 4 - .../barretenberg/vm/avm/trace/fixed_gas.cpp | 3 - .../vm/avm/trace/kernel_trace.cpp | 14 -- .../vm/avm/trace/kernel_trace.hpp | 2 - .../src/barretenberg/vm/avm/trace/opcode.cpp | 6 - .../src/barretenberg/vm/avm/trace/opcode.hpp | 3 - .../src/barretenberg/vm/avm/trace/trace.cpp | 13 -- .../src/barretenberg/vm/avm/trace/trace.hpp | 1 - .../src/barretenberg/vm/aztec_constants.hpp | 7 - .../cpp/src/barretenberg/vm/constants.hpp | 1 - .../public-vm/gen/_instruction-set.mdx | 185 ++++++------------ .../InstructionSet/InstructionSet.js | 54 ----- .../crates/types/src/constants.nr | 6 - yarn-project/circuits.js/src/constants.gen.ts | 6 - .../circuits.js/src/scripts/constants.in.ts | 2 - yarn-project/simulator/src/avm/avm_gas.ts | 6 - .../serialization/bytecode_serialization.ts | 3 - .../instruction_serialization.ts | 3 - 25 files changed, 69 insertions(+), 373 deletions(-) diff --git a/avm-transpiler/src/opcodes.rs b/avm-transpiler/src/opcodes.rs index f75508bd33a..a33abd4855e 100644 --- a/avm-transpiler/src/opcodes.rs +++ b/avm-transpiler/src/opcodes.rs @@ -29,11 +29,8 @@ pub enum AvmOpcode { VERSION, BLOCKNUMBER, TIMESTAMP, - COINBASE, FEEPERL2GAS, FEEPERDAGAS, - BLOCKL2GASLIMIT, - BLOCKDAGASLIMIT, CALLDATACOPY, // Gas L2GASLEFT, @@ -116,11 +113,8 @@ impl AvmOpcode { AvmOpcode::VERSION => "VERSION", AvmOpcode::BLOCKNUMBER => "BLOCKNUMBER", AvmOpcode::TIMESTAMP => "TIMESTAMP", - AvmOpcode::COINBASE => "COINBASE", AvmOpcode::FEEPERL2GAS => "FEEPERL2GAS", AvmOpcode::FEEPERDAGAS => "FEEPERDAGAS", - AvmOpcode::BLOCKL2GASLIMIT => "BLOCKL2GASLIMIT", - AvmOpcode::BLOCKDAGASLIMIT => "BLOCKDAGASLIMIT", // Execution Environment - Calldata AvmOpcode::CALLDATACOPY => "CALLDATACOPY", diff --git a/barretenberg/cpp/pil/avm/constants_gen.pil b/barretenberg/cpp/pil/avm/constants_gen.pil index 9adc7a542c8..c2a17b1d7ec 100644 --- a/barretenberg/cpp/pil/avm/constants_gen.pil +++ b/barretenberg/cpp/pil/avm/constants_gen.pil @@ -20,7 +20,6 @@ namespace constants(256); pol VERSION_SELECTOR = 30; pol BLOCK_NUMBER_SELECTOR = 31; pol TIMESTAMP_SELECTOR = 33; - pol COINBASE_SELECTOR = 34; pol FEE_PER_DA_GAS_SELECTOR = 36; pol FEE_PER_L2_GAS_SELECTOR = 37; pol END_GLOBAL_VARIABLES = 38; diff --git a/barretenberg/cpp/pil/avm/kernel.pil b/barretenberg/cpp/pil/avm/kernel.pil index d04a5fa13ff..fce9aec35be 100644 --- a/barretenberg/cpp/pil/avm/kernel.pil +++ b/barretenberg/cpp/pil/avm/kernel.pil @@ -111,9 +111,6 @@ namespace main(256); #[TIMESTAMP_KERNEL] sel_op_timestamp * (kernel_in_offset - constants.TIMESTAMP_SELECTOR) = 0; - #[COINBASE_KERNEL] - sel_op_coinbase * (kernel_in_offset - constants.COINBASE_SELECTOR) = 0; - // CONTEXT - ENVIRONMENT - GLOBALS - FEES #[FEE_DA_GAS_KERNEL] sel_op_fee_per_da_gas * (kernel_in_offset - constants.FEE_PER_DA_GAS_SELECTOR) = 0; @@ -170,7 +167,7 @@ namespace main(256); //===== LOOKUPS INTO THE PUBLIC INPUTS =========================================== pol KERNEL_INPUT_SELECTORS = sel_op_address + sel_op_storage_address + sel_op_sender + sel_op_function_selector + sel_op_transaction_fee + sel_op_chain_id - + sel_op_version + sel_op_block_number + sel_op_coinbase + sel_op_timestamp + + sel_op_version + sel_op_block_number + sel_op_timestamp + sel_op_fee_per_l2_gas + sel_op_fee_per_da_gas; // Ensure that only one kernel lookup is active when the kernel_in_offset is active #[KERNEL_INPUT_ACTIVE_CHECK] diff --git a/barretenberg/cpp/pil/avm/main.pil b/barretenberg/cpp/pil/avm/main.pil index 198f6f6d8cb..b4debf47049 100644 --- a/barretenberg/cpp/pil/avm/main.pil +++ b/barretenberg/cpp/pil/avm/main.pil @@ -51,7 +51,6 @@ namespace main(256); pol commit sel_op_chain_id; pol commit sel_op_version; pol commit sel_op_block_number; - pol commit sel_op_coinbase; pol commit sel_op_timestamp; // CONTEXT - ENVIRONMENT - GLOBALS - FEES pol commit sel_op_fee_per_l2_gas; @@ -224,7 +223,6 @@ namespace main(256); 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; - sel_op_coinbase * (1 - sel_op_coinbase) = 0; sel_op_timestamp * (1 - sel_op_timestamp) = 0; sel_op_fee_per_l2_gas * (1 - sel_op_fee_per_l2_gas) = 0; sel_op_fee_per_da_gas * (1 - sel_op_fee_per_da_gas) = 0; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp index 8a776a123e9..6093a547760 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp @@ -1418,20 +1418,16 @@ TEST_F(AvmExecutionTests, kernelInputOpcodes) + to_hex(OpCode::TIMESTAMP) + // opcode TIMESTAMP "00" // Indirect flag "00000009" // dst_offset - // Not in simulator - // + to_hex(OpCode::COINBASE) + // opcode COINBASE - // "00" // Indirect flag - // "00000009" // dst_offset - + to_hex(OpCode::FEEPERL2GAS) + // opcode FEEPERL2GAS - "00" // Indirect flag - "0000000a" // dst_offset - + to_hex(OpCode::FEEPERDAGAS) + // opcode FEEPERDAGAS - "00" // Indirect flag - "0000000b" // dst_offset - + to_hex(OpCode::RETURN) + // opcode RETURN - "00" // Indirect flag - "00000001" // ret offset 1 - "0000000b"; // ret size 11 + + to_hex(OpCode::FEEPERL2GAS) + // opcode FEEPERL2GAS + "00" // Indirect flag + "0000000a" // dst_offset + + to_hex(OpCode::FEEPERDAGAS) + // opcode FEEPERDAGAS + "00" // Indirect flag + "0000000b" // dst_offset + + to_hex(OpCode::RETURN) + // opcode RETURN + "00" // Indirect flag + "00000001" // ret offset 1 + "0000000b"; // ret size 11 auto bytecode = hex_to_bytes(bytecode_hex); auto instructions = Deserialization::parse(bytecode); @@ -1483,13 +1479,6 @@ TEST_F(AvmExecutionTests, kernelInputOpcodes) AllOf(Field(&Instruction::op_code, OpCode::TIMESTAMP), Field(&Instruction::operands, ElementsAre(VariantWith(0), VariantWith(9))))); - // COINBASE - // Not in simulator - // EXPECT_THAT(instructions.at(8), - // AllOf(Field(&Instruction::op_code, OpCode::COINBASE), - // Field(&Instruction::operands, ElementsAre(VariantWith(0), - // VariantWith(10))))); - // FEEPERL2GAS EXPECT_THAT(instructions.at(9), AllOf(Field(&Instruction::op_code, OpCode::FEEPERL2GAS), @@ -1514,15 +1503,14 @@ TEST_F(AvmExecutionTests, kernelInputOpcodes) FF version = 7; FF blocknumber = 8; FF timestamp = 9; - // FF coinbase = 10; // Not in simulator FF feeperl2gas = 10; FF feeperdagas = 11; // The return data for this test should be a the opcodes in sequence, as the opcodes dst address lines up with // this array The returndata call above will then return this array std::vector const expected_returndata = { - address, storage_address, sender, function_selector, transaction_fee, chainid, version, - blocknumber, /*coinbase,*/ timestamp, feeperl2gas, feeperdagas, + address, storage_address, sender, function_selector, transaction_fee, chainid, + version, blocknumber, timestamp, feeperl2gas, feeperdagas, }; // Set up public inputs to contain the above values @@ -1540,8 +1528,6 @@ TEST_F(AvmExecutionTests, kernelInputOpcodes) public_inputs_vec[VERSION_OFFSET] = version; public_inputs_vec[BLOCK_NUMBER_OFFSET] = blocknumber; public_inputs_vec[TIMESTAMP_OFFSET] = timestamp; - // Not in the simulator yet - // public_inputs_vec[COINBASE_OFFSET] = coinbase; // Global variables - Gas public_inputs_vec[FEE_PER_DA_GAS_OFFSET] = feeperdagas; public_inputs_vec[FEE_PER_L2_GAS_OFFSET] = feeperl2gas; @@ -1597,12 +1583,6 @@ TEST_F(AvmExecutionTests, kernelInputOpcodes) std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.main_sel_op_timestamp == 1; }); EXPECT_EQ(timestamp_row->main_ia, timestamp); - // // Check coinbase - // Not in simulator - // auto coinbase_row = - // std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.main_sel_op_coinbase == 1; }); - // EXPECT_EQ(coinbase_row->main_ia, coinbase); - // Check feeperdagas auto feeperdagas_row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.main_sel_op_fee_per_da_gas == 1; }); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/kernel.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/kernel.test.cpp index cc80b967fcd..e0b277b344d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/kernel.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/kernel.test.cpp @@ -525,40 +525,6 @@ TEST_F(AvmKernelPositiveTests, kernelBlockNumber) test_kernel_lookup(true, indirect_apply_opcodes, checks); } -TEST_F(AvmKernelPositiveTests, kernelCoinbase) -{ - uint32_t dst_offset = 42; - uint32_t indirect_dst_offset = 69; - auto direct_apply_opcodes = [=](AvmTraceBuilder& trace_builder) { - trace_builder.op_coinbase(/*indirect*/ false, dst_offset); - }; - auto indirect_apply_opcodes = [=](AvmTraceBuilder& trace_builder) { - trace_builder.op_set( - /*indirect*/ false, - /*value*/ dst_offset, - /*dst_offset*/ indirect_dst_offset, - AvmMemoryTag::U32); - trace_builder.op_coinbase(/*indirect*/ true, indirect_dst_offset); - }; - - auto checks = [=](bool indirect, const std::vector& trace) { - auto fee_row = - std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.main_sel_op_coinbase == FF(1); }); - EXPECT_TRUE(fee_row != trace.end()); - - expect_row(fee_row, - /*kernel_in_offset=*/COINBASE_SELECTOR, - /*ia=*/COINBASE_SELECTOR + - 1, // Note the value generated above for public inputs is the same as the index read + 1 - /*ind_a*/ indirect ? indirect_dst_offset : 0, - /*mem_addr_a*/ dst_offset, - /*w_in_tag=*/AvmMemoryTag::FF); - }; - - test_kernel_lookup(false, direct_apply_opcodes, checks); - test_kernel_lookup(true, indirect_apply_opcodes, checks); -} - TEST_F(AvmKernelPositiveTests, kernelTimestamp) { uint32_t dst_offset = 42; @@ -913,32 +879,6 @@ TEST_F(AvmKernelNegativeTests, incorrectIaTimestamp) negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP); } -TEST_F(AvmKernelNegativeTests, incorrectIaCoinbase) -{ - uint32_t dst_offset = 42; - FF incorrect_ia = FF(69); - - // We test that the sender opcode is inlcuded at index x in the public inputs - auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { - trace_builder.op_coinbase(/*indirect*/ false, dst_offset); - }; - auto checks = [=](bool indirect, const std::vector& trace) { - auto row = - std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.main_sel_op_coinbase == FF(1); }); - EXPECT_TRUE(row != trace.end()); - - expect_row( - row, - /*kernel_in_offset=*/COINBASE_SELECTOR, - /*ia=*/incorrect_ia, // Note the value generated above for public inputs is the same as the index read + 1 - /*ind_a*/ indirect, - /*mem_addr_a=*/dst_offset, - /*w_in_tag=*/AvmMemoryTag::FF); - }; - - negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP); -} - // KERNEL OUTPUTS class AvmKernelOutputPositiveTests : public AvmKernelTests { protected: diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/deserialization.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/deserialization.cpp index bade655927c..189409b2409 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/deserialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/deserialization.cpp @@ -68,14 +68,11 @@ const std::unordered_map> OPCODE_WIRE_FORMAT = { OpCode::CHAINID, getter_format }, { OpCode::VERSION, getter_format }, { OpCode::BLOCKNUMBER, getter_format }, - // COINBASE, -- not in simulator { OpCode::TIMESTAMP, getter_format }, // Execution Environment - Globals - Gas { OpCode::FEEPERL2GAS, getter_format }, { OpCode::FEEPERDAGAS, getter_format }, - // BLOCKL2GASLIMIT, -- not in simulator - // BLOCKDAGASLIMIT, -- not in simulator - // + // Execution Environment - Calldata { OpCode::CALLDATACOPY, { OperandType::INDIRECT, OperandType::UINT32, OperandType::UINT32, OperandType::UINT32 } }, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp index 8ae88df7bc9..e7759e5d7fb 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp @@ -214,7 +214,6 @@ VmPublicInputs Execution::convert_public_inputs(std::vector const& public_in kernel_inputs[VERSION_SELECTOR] = public_inputs_vec[VERSION_OFFSET]; // Version kernel_inputs[BLOCK_NUMBER_SELECTOR] = public_inputs_vec[BLOCK_NUMBER_OFFSET]; // Block Number kernel_inputs[TIMESTAMP_SELECTOR] = public_inputs_vec[TIMESTAMP_OFFSET]; // Timestamp - kernel_inputs[COINBASE_SELECTOR] = public_inputs_vec[COINBASE_OFFSET]; // Coinbase // PublicCircuitPublicInputs - GlobalVariables - GasFees kernel_inputs[FEE_PER_DA_GAS_SELECTOR] = public_inputs_vec[FEE_PER_DA_GAS_OFFSET]; kernel_inputs[FEE_PER_L2_GAS_SELECTOR] = public_inputs_vec[FEE_PER_L2_GAS_OFFSET]; @@ -548,9 +547,6 @@ std::vector Execution::gen_trace(std::vector const& instructio case OpCode::TIMESTAMP: trace_builder.op_timestamp(std::get(inst.operands.at(0)), std::get(inst.operands.at(1))); break; - case OpCode::COINBASE: - trace_builder.op_coinbase(std::get(inst.operands.at(0)), std::get(inst.operands.at(1))); - break; case OpCode::FEEPERL2GAS: trace_builder.op_fee_per_l2_gas(std::get(inst.operands.at(0)), std::get(inst.operands.at(1))); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/fixed_gas.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/fixed_gas.cpp index 76004cfa3d4..749a913feb6 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/fixed_gas.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/fixed_gas.cpp @@ -42,11 +42,8 @@ const std::unordered_map GAS_COST_TABLE = { { OpCode::VERSION, make_cost(AVM_VERSION_BASE_L2_GAS, 0, AVM_VERSION_DYN_L2_GAS, 0) }, { OpCode::BLOCKNUMBER, make_cost(AVM_BLOCKNUMBER_BASE_L2_GAS, 0, AVM_BLOCKNUMBER_DYN_L2_GAS, 0) }, { OpCode::TIMESTAMP, make_cost(AVM_TIMESTAMP_BASE_L2_GAS, 0, AVM_TIMESTAMP_DYN_L2_GAS, 0) }, - { OpCode::COINBASE, make_cost(AVM_COINBASE_BASE_L2_GAS, 0, AVM_COINBASE_DYN_L2_GAS, 0) }, { OpCode::FEEPERL2GAS, make_cost(AVM_FEEPERL2GAS_BASE_L2_GAS, 0, AVM_FEEPERL2GAS_DYN_L2_GAS, 0) }, { OpCode::FEEPERDAGAS, make_cost(AVM_FEEPERDAGAS_BASE_L2_GAS, 0, AVM_FEEPERDAGAS_DYN_L2_GAS, 0) }, - { OpCode::BLOCKL2GASLIMIT, make_cost(AVM_BLOCKL2GASLIMIT_BASE_L2_GAS, 0, AVM_BLOCKL2GASLIMIT_DYN_L2_GAS, 0) }, - { OpCode::BLOCKDAGASLIMIT, make_cost(AVM_BLOCKDAGASLIMIT_BASE_L2_GAS, 0, AVM_BLOCKDAGASLIMIT_DYN_L2_GAS, 0) }, { OpCode::CALLDATACOPY, make_cost(AVM_CALLDATACOPY_BASE_L2_GAS, 0, AVM_CALLDATACOPY_DYN_L2_GAS, 0) }, { OpCode::L2GASLEFT, make_cost(AVM_L2GASLEFT_BASE_L2_GAS, 0, AVM_L2GASLEFT_DYN_L2_GAS, 0) }, { OpCode::DAGASLEFT, make_cost(AVM_DAGASLEFT_BASE_L2_GAS, 0, AVM_DAGASLEFT_DYN_L2_GAS, 0) }, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/kernel_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/kernel_trace.cpp index f953f7b8489..d646b2e51b4 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/kernel_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/kernel_trace.cpp @@ -124,16 +124,6 @@ FF AvmKernelTraceBuilder::op_block_number(uint32_t clk) return perform_kernel_input_lookup(BLOCK_NUMBER_SELECTOR); } -FF AvmKernelTraceBuilder::op_coinbase(uint32_t clk) -{ - KernelTraceEntry entry = { - .clk = clk, - .operation = KernelTraceOpType::COINBASE, - }; - kernel_trace.push_back(entry); - return perform_kernel_input_lookup(COINBASE_SELECTOR); -} - FF AvmKernelTraceBuilder::op_timestamp(uint32_t clk) { KernelTraceEntry entry = { @@ -393,10 +383,6 @@ void AvmKernelTraceBuilder::finalize(std::vector>& main_trace) dest.main_kernel_in_offset = BLOCK_NUMBER_SELECTOR; dest.main_sel_q_kernel_lookup = 1; break; - case KernelTraceOpType::COINBASE: - dest.main_kernel_in_offset = COINBASE_SELECTOR; - dest.main_sel_q_kernel_lookup = 1; - break; case KernelTraceOpType::TIMESTAMP: dest.main_kernel_in_offset = TIMESTAMP_SELECTOR; dest.main_sel_q_kernel_lookup = 1; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/kernel_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/kernel_trace.hpp index 773d68bba3f..71a5bb77d79 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/kernel_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/kernel_trace.hpp @@ -24,7 +24,6 @@ class AvmKernelTraceBuilder { CHAIN_ID, VERSION, BLOCK_NUMBER, - COINBASE, TIMESTAMP, FEE_PER_DA_GAS, FEE_PER_L2_GAS, @@ -78,7 +77,6 @@ class AvmKernelTraceBuilder { FF op_chain_id(uint32_t clk); FF op_version(uint32_t clk); FF op_block_number(uint32_t clk); - FF op_coinbase(uint32_t clk); FF op_timestamp(uint32_t clk); // Globals - Gas FF op_fee_per_da_gas(uint32_t clk); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.cpp index 4fcbf7aea51..5a80d3ec678 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.cpp @@ -79,16 +79,10 @@ std::string to_string(OpCode opcode) return "BLOCKNUMBER"; case OpCode::TIMESTAMP: return "TIMESTAMP"; - case OpCode::COINBASE: - return "COINBASE"; case OpCode::FEEPERL2GAS: return "FEEPERL2GAS"; case OpCode::FEEPERDAGAS: return "FEEPERDAGAS"; - case OpCode::BLOCKL2GASLIMIT: - return "BLOCKL2GASLIMIT"; - case OpCode::BLOCKDAGASLIMIT: - return "BLOCKDAGASLIMIT"; // Execution Environment - Calldata case OpCode::CALLDATACOPY: return "CALLDATACOPY"; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.hpp index 885d2020cca..bb880e22a41 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.hpp @@ -52,11 +52,8 @@ enum class OpCode : uint8_t { VERSION, BLOCKNUMBER, TIMESTAMP, - COINBASE, FEEPERL2GAS, FEEPERDAGAS, - BLOCKL2GASLIMIT, - BLOCKDAGASLIMIT, // Execution Environment - Calldata CALLDATACOPY, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp index 3dc1d434db8..4bf4688ff6d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp @@ -1381,19 +1381,6 @@ void AvmTraceBuilder::op_timestamp(uint8_t indirect, uint32_t dst_offset) main_trace.push_back(row); } -void AvmTraceBuilder::op_coinbase(uint8_t indirect, uint32_t dst_offset) -{ - auto const clk = static_cast(main_trace.size()) + 1; - FF ia_value = kernel_trace_builder.op_coinbase(clk); - Row row = create_kernel_lookup_opcode(indirect, dst_offset, ia_value, AvmMemoryTag::FF); - row.main_sel_op_coinbase = FF(1); - - // Constrain gas cost - gas_trace_builder.constrain_gas(static_cast(row.main_clk), OpCode::COINBASE); - - main_trace.push_back(row); -} - void AvmTraceBuilder::op_fee_per_l2_gas(uint8_t indirect, uint32_t dst_offset) { auto const clk = static_cast(main_trace.size()) + 1; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp index a301b637b73..996ee4e1d46 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp @@ -94,7 +94,6 @@ class AvmTraceBuilder { void op_version(uint8_t indirect, uint32_t dst_offset); void op_block_number(uint8_t indirect, uint32_t dst_offset); void op_timestamp(uint8_t indirect, uint32_t dst_offset); - void op_coinbase(uint8_t indirect, uint32_t dst_offset); void op_fee_per_l2_gas(uint8_t indirect, uint32_t dst_offset); void op_fee_per_da_gas(uint8_t indirect, uint32_t dst_offset); diff --git a/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp b/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp index 919d02fae1d..68c5ce65516 100644 --- a/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp @@ -43,7 +43,6 @@ #define VERSION_SELECTOR 30 #define BLOCK_NUMBER_SELECTOR 31 #define TIMESTAMP_SELECTOR 33 -#define COINBASE_SELECTOR 34 #define FEE_PER_DA_GAS_SELECTOR 36 #define FEE_PER_L2_GAS_SELECTOR 37 #define END_GLOBAL_VARIABLES 38 @@ -85,11 +84,8 @@ #define AVM_VERSION_BASE_L2_GAS 200 #define AVM_BLOCKNUMBER_BASE_L2_GAS 200 #define AVM_TIMESTAMP_BASE_L2_GAS 200 -#define AVM_COINBASE_BASE_L2_GAS 200 #define AVM_FEEPERL2GAS_BASE_L2_GAS 200 #define AVM_FEEPERDAGAS_BASE_L2_GAS 200 -#define AVM_BLOCKL2GASLIMIT_BASE_L2_GAS 200 -#define AVM_BLOCKDAGASLIMIT_BASE_L2_GAS 200 #define AVM_CALLDATACOPY_BASE_L2_GAS 290 #define AVM_L2GASLEFT_BASE_L2_GAS 180 #define AVM_DAGASLEFT_BASE_L2_GAS 180 @@ -150,11 +146,8 @@ #define AVM_VERSION_DYN_L2_GAS 0 #define AVM_BLOCKNUMBER_DYN_L2_GAS 0 #define AVM_TIMESTAMP_DYN_L2_GAS 0 -#define AVM_COINBASE_DYN_L2_GAS 0 #define AVM_FEEPERL2GAS_DYN_L2_GAS 0 #define AVM_FEEPERDAGAS_DYN_L2_GAS 0 -#define AVM_BLOCKL2GASLIMIT_DYN_L2_GAS 0 -#define AVM_BLOCKDAGASLIMIT_DYN_L2_GAS 0 #define AVM_CALLDATACOPY_DYN_L2_GAS 50 #define AVM_L2GASLEFT_DYN_L2_GAS 0 #define AVM_DAGASLEFT_DYN_L2_GAS 0 diff --git a/barretenberg/cpp/src/barretenberg/vm/constants.hpp b/barretenberg/cpp/src/barretenberg/vm/constants.hpp index ec2f0e9ac7f..c7024d89587 100644 --- a/barretenberg/cpp/src/barretenberg/vm/constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/constants.hpp @@ -26,7 +26,6 @@ inline const uint32_t CHAIN_ID_OFFSET = PCPI_GLOBALS_START; inline const uint32_t VERSION_OFFSET = PCPI_GLOBALS_START + 1; inline const uint32_t BLOCK_NUMBER_OFFSET = PCPI_GLOBALS_START + 2; inline const uint32_t TIMESTAMP_OFFSET = PCPI_GLOBALS_START + 3; -inline const uint32_t COINBASE_OFFSET = PCPI_GLOBALS_START + 4; // Global Variables - fees inline const uint32_t FEE_PER_DA_GAS_OFFSET = PCPI_GLOBALS_START + 6; inline const uint32_t FEE_PER_L2_GAS_OFFSET = PCPI_GLOBALS_START + 7; 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 a59bee534e5..8e97a5ce0a8 100644 --- a/docs/docs/protocol-specs/public-vm/gen/_instruction-set.mdx +++ b/docs/docs/protocol-specs/public-vm/gen/_instruction-set.mdx @@ -207,14 +207,6 @@ Click on an instruction name to jump to its section. 0x18 - \[\`COINBASE\`\](#isa-section-coinbase) - (UNIMPLEMENTED) Get the block's beneficiary address - { - `M[dstOffset] = context.environment.globals.coinbase` - } - - - 0x19 \[\`FEEPERL2GAS\`\](#isa-section-feeperl2gas) Get the fee to be paid per "L2 gas" - constant for entire transaction { @@ -222,7 +214,7 @@ Click on an instruction name to jump to its section. } - 0x1a + 0x19 \[\`FEEPERDAGAS\`\](#isa-section-feeperdagas) Get the fee to be paid per "DA gas" - constant for entire transaction { @@ -230,23 +222,7 @@ Click on an instruction name to jump to its section. } - 0x1b - \[\`BLOCKL2GASLIMIT\`\](#isa-section-blockl2gaslimit) - (UNIMPLEMENTED) Total amount of "L2 gas" that a block can consume - { - `M[dstOffset] = context.environment.globals.l2GasLimit` - } - - - 0x1c - \[\`BLOCKDAGASLIMIT\`\](#isa-section-blockdagaslimit) - (UNIMPLEMENTED) Total amount of "DA gas" that a block can consume - { - `M[dstOffset] = context.environment.globals.daGasLimit` - } - - - 0x1d + 0x1a \[\`CALLDATACOPY\`\](#isa-section-calldatacopy) Copy calldata into memory { @@ -254,7 +230,7 @@ Click on an instruction name to jump to its section. } - 0x1e + 0x1b \[\`L2GASLEFT\`\](#isa-section-l2gasleft) Remaining "L2 gas" for this call (after this instruction) { @@ -262,7 +238,7 @@ Click on an instruction name to jump to its section. } - 0x1f + 0x1c \[\`DAGASLEFT\`\](#isa-section-dagasleft) Remaining "DA gas" for this call (after this instruction) { @@ -270,7 +246,7 @@ Click on an instruction name to jump to its section. } - 0x20 + 0x1d \[\`JUMP\`\](#isa-section-jump) Jump to a location in the bytecode { @@ -278,7 +254,7 @@ Click on an instruction name to jump to its section. } - 0x21 + 0x1e \[\`JUMPI\`\](#isa-section-jumpi) Conditionally jump to a location in the bytecode { @@ -286,7 +262,7 @@ Click on an instruction name to jump to its section. } - 0x22 + 0x1f \[\`INTERNALCALL\`\](#isa-section-internalcall) Make an internal call. Push the current PC to the internal call stack and jump to the target location. @@ -295,7 +271,7 @@ context.machineState.pc = loc`} - 0x23 + 0x20 \[\`INTERNALRETURN\`\](#isa-section-internalreturn) Return from an internal call. Pop from the internal call stack and jump to the popped location. { @@ -303,7 +279,7 @@ context.machineState.pc = loc`} } - 0x24 + 0x21 \[\`SET\`\](#isa-section-set) Set a memory word from a constant in the bytecode { @@ -311,7 +287,7 @@ context.machineState.pc = loc`} } - 0x25 + 0x22 \[\`MOV\`\](#isa-section-mov) Move a word from source memory location to destination { @@ -319,7 +295,7 @@ context.machineState.pc = loc`} } - 0x26 + 0x23 \[\`CMOV\`\](#isa-section-cmov) Move a word (conditionally chosen) from one memory location to another (`d = cond > 0 ? a : b`) { @@ -327,7 +303,7 @@ context.machineState.pc = loc`} } - 0x27 + 0x24 \[\`SLOAD\`\](#isa-section-sload) Load a word from this contract's persistent public storage. Zero is loaded for unwritten slots. @@ -335,7 +311,7 @@ context.machineState.pc = loc`} - 0x28 + 0x25 \[\`SSTORE\`\](#isa-section-sstore) Write a word to this contract's persistent public storage @@ -343,7 +319,7 @@ context.machineState.pc = loc`} - 0x29 + 0x26 \[\`NOTEHASHEXISTS\`\](#isa-section-notehashexists) Check whether a note hash exists in the note hash tree (as of the start of the current block) @@ -355,7 +331,7 @@ M[existsOffset] = exists`} - 0x2a + 0x27 \[\`EMITNOTEHASH\`\](#isa-section-emitnotehash) Emit a new note hash to be inserted into the note hash tree @@ -365,7 +341,7 @@ M[existsOffset] = exists`} - 0x2b + 0x28 \[\`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) @@ -376,7 +352,7 @@ M[existsOffset] = exists`} - 0x2c + 0x29 \[\`EMITNULLIFIER\`\](#isa-section-emitnullifier) Emit a new nullifier to be inserted into the nullifier tree @@ -386,7 +362,7 @@ M[existsOffset] = exists`} - 0x2d + 0x2a \[\`L1TOL2MSGEXISTS\`\](#isa-section-l1tol2msgexists) Check if a message exists in the L1-to-L2 message tree @@ -397,7 +373,7 @@ M[existsOffset] = exists`} - 0x2e + 0x2b \[\`GETCONTRACTINSTANCE\`\](#isa-section-getcontractinstance) Copies contract instance data to memory @@ -413,7 +389,7 @@ M[existsOffset] = exists`} - 0x2f + 0x2c \[\`EMITUNENCRYPTEDLOG\`\](#isa-section-emitunencryptedlog) Emit an unencrypted log @@ -426,7 +402,7 @@ M[existsOffset] = exists`} - 0x30 + 0x2d \[\`SENDL2TOL1MSG\`\](#isa-section-sendl2tol1msg) Send an L2-to-L1 message @@ -440,7 +416,7 @@ M[existsOffset] = exists`} - 0x31 + 0x2e \[\`CALL\`\](#isa-section-call) Call into another contract @@ -455,7 +431,7 @@ updateContextAfterNestedCall(context, instr.args, nestedContext)`} - 0x32 + 0x2f \[\`STATICCALL\`\](#isa-section-staticcall) Call into another contract, disallowing World State and Accrued Substate modifications @@ -470,7 +446,7 @@ updateContextAfterNestedCall(context, instr.args, nestedContext)`} - 0x33 + 0x30 \[\`DELEGATECALL\`\](#isa-section-delegatecall) (UNIMPLEMENTED) Call into another contract, but keep the caller's `sender` and `storageAddress` @@ -485,7 +461,7 @@ updateContextAfterNestedCall(context, instr.args, nestedContext)`} - 0x34 + 0x31 \[\`RETURN\`\](#isa-section-return) Halt execution within this context (without revert), optionally returning some data @@ -494,7 +470,7 @@ halt`} - 0x35 + 0x32 \[\`REVERT\`\](#isa-section-revert) Halt execution within this context as `reverted`, optionally returning some data @@ -504,7 +480,7 @@ halt`} - 0x36 + 0x33 \[\`TORADIXLE\`\](#isa-section-to_radix_le) Convert a word to an array of limbs in little-endian radix form TBD: Storage of limbs and if T[dstOffset] is constrained to U8 @@ -981,29 +957,12 @@ Get this L2 block's timestamp [![](/img/protocol-specs/public-vm/bit-formats/TIMESTAMP.png)](/img/protocol-specs/public-vm/bit-formats/TIMESTAMP.png) -### `COINBASE` -(UNIMPLEMENTED) Get the block's beneficiary address - -[See in table.](#isa-table-coinbase) - -- **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]`. -- **Args**: - - **dstOffset**: memory offset specifying where to store operation's result -- **Expression**: `M[dstOffset] = context.environment.globals.coinbase` -- **Tag updates**: `T[dstOffset] = field` -- **Bit-size**: 56 - -[![](/img/protocol-specs/public-vm/bit-formats/COINBASE.png)](/img/protocol-specs/public-vm/bit-formats/COINBASE.png) - ### `FEEPERL2GAS` Get the fee to be paid per "L2 gas" - constant for entire transaction [See in table.](#isa-table-feeperl2gas) -- **Opcode**: 0x19 +- **Opcode**: 0x18 - **Category**: Execution Environment - Globals - 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]`. @@ -1020,7 +979,7 @@ Get the fee to be paid per "DA gas" - constant for entire transaction [See in table.](#isa-table-feeperdagas) -- **Opcode**: 0x1a +- **Opcode**: 0x19 - **Category**: Execution Environment - Globals - 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]`. @@ -1032,46 +991,12 @@ Get the fee to be paid per "DA gas" - constant for entire transaction [![](/img/protocol-specs/public-vm/bit-formats/FEEPERDAGAS.png)](/img/protocol-specs/public-vm/bit-formats/FEEPERDAGAS.png) -### `BLOCKL2GASLIMIT` -(UNIMPLEMENTED) Total amount of "L2 gas" that a block can consume - -[See in table.](#isa-table-blockl2gaslimit) - -- **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]`. -- **Args**: - - **dstOffset**: memory offset specifying where to store operation's result -- **Expression**: `M[dstOffset] = context.environment.globals.l2GasLimit` -- **Tag updates**: `T[dstOffset] = field` -- **Bit-size**: 56 - -[![](/img/protocol-specs/public-vm/bit-formats/BLOCKL2GASLIMIT.png)](/img/protocol-specs/public-vm/bit-formats/BLOCKL2GASLIMIT.png) - -### `BLOCKDAGASLIMIT` -(UNIMPLEMENTED) Total amount of "DA gas" that a block can consume - -[See in table.](#isa-table-blockdagaslimit) - -- **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]`. -- **Args**: - - **dstOffset**: memory offset specifying where to store operation's result -- **Expression**: `M[dstOffset] = context.environment.globals.daGasLimit` -- **Tag updates**: `T[dstOffset] = field` -- **Bit-size**: 56 - -[![](/img/protocol-specs/public-vm/bit-formats/BLOCKDAGASLIMIT.png)](/img/protocol-specs/public-vm/bit-formats/BLOCKDAGASLIMIT.png) - ### `CALLDATACOPY` Copy calldata into memory [See in table.](#isa-table-calldatacopy) -- **Opcode**: 0x1d +- **Opcode**: 0x1a - **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]`. @@ -1091,7 +1016,7 @@ Remaining "L2 gas" for this call (after this instruction) [See in table.](#isa-table-l2gasleft) -- **Opcode**: 0x1e +- **Opcode**: 0x1b - **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]`. @@ -1108,7 +1033,7 @@ Remaining "DA gas" for this call (after this instruction) [See in table.](#isa-table-dagasleft) -- **Opcode**: 0x1f +- **Opcode**: 0x1c - **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]`. @@ -1125,7 +1050,7 @@ Jump to a location in the bytecode [See in table.](#isa-table-jump) -- **Opcode**: 0x20 +- **Opcode**: 0x1d - **Category**: Machine State - Control Flow - **Args**: - **loc**: target location to jump to @@ -1140,7 +1065,7 @@ Conditionally jump to a location in the bytecode [See in table.](#isa-table-jumpi) -- **Opcode**: 0x21 +- **Opcode**: 0x1e - **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]`. @@ -1158,7 +1083,7 @@ Make an internal call. Push the current PC to the internal call stack and jump t [See in table.](#isa-table-internalcall) -- **Opcode**: 0x22 +- **Opcode**: 0x1f - **Category**: Machine State - Control Flow - **Args**: - **loc**: target location to jump/call to @@ -1176,7 +1101,7 @@ Return from an internal call. Pop from the internal call stack and jump to the p [See in table.](#isa-table-internalreturn) -- **Opcode**: 0x23 +- **Opcode**: 0x20 - **Category**: Machine State - Control Flow - **Expression**: `context.machineState.pc = context.machineState.internalCallStack.pop()` - **Bit-size**: 16 @@ -1188,7 +1113,7 @@ Set a memory word from a constant in the bytecode [See in table.](#isa-table-set) -- **Opcode**: 0x24 +- **Opcode**: 0x21 - **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]`. @@ -1208,7 +1133,7 @@ Move a word from source memory location to destination [See in table.](#isa-table-mov) -- **Opcode**: 0x25 +- **Opcode**: 0x22 - **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]`. @@ -1226,7 +1151,7 @@ Move a word (conditionally chosen) from one memory location to another (`d \= co [See in table.](#isa-table-cmov) -- **Opcode**: 0x26 +- **Opcode**: 0x23 - **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]`. @@ -1247,7 +1172,7 @@ Load a word from this contract's persistent public storage. Zero is loaded for u [See in table.](#isa-table-sload) -- **Opcode**: 0x27 +- **Opcode**: 0x24 - **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]`. @@ -1292,7 +1217,7 @@ Write a word to this contract's persistent public storage [See in table.](#isa-table-sstore) -- **Opcode**: 0x28 +- **Opcode**: 0x25 - **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]`. @@ -1332,7 +1257,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**: 0x29 +- **Opcode**: 0x26 - **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]`. @@ -1370,7 +1295,7 @@ Emit a new note hash to be inserted into the note hash tree [See in table.](#isa-table-emitnotehash) -- **Opcode**: 0x2a +- **Opcode**: 0x27 - **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]`. @@ -1402,7 +1327,7 @@ Check whether a nullifier exists in the nullifier tree (including nullifiers fro [See in table.](#isa-table-nullifierexists) -- **Opcode**: 0x2b +- **Opcode**: 0x28 - **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]`. @@ -1439,7 +1364,7 @@ Emit a new nullifier to be inserted into the nullifier tree [See in table.](#isa-table-emitnullifier) -- **Opcode**: 0x2c +- **Opcode**: 0x29 - **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]`. @@ -1471,7 +1396,7 @@ Check if a message exists in the L1-to-L2 message tree [See in table.](#isa-table-l1tol2msgexists) -- **Opcode**: 0x2d +- **Opcode**: 0x2a - **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]`. @@ -1510,7 +1435,7 @@ Copies contract instance data to memory [See in table.](#isa-table-getcontractinstance) -- **Opcode**: 0x2e +- **Opcode**: 0x2b - **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]`. @@ -1540,7 +1465,7 @@ Emit an unencrypted log [See in table.](#isa-table-emitunencryptedlog) -- **Opcode**: 0x2f +- **Opcode**: 0x2c - **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]`. @@ -1565,7 +1490,7 @@ Send an L2-to-L1 message [See in table.](#isa-table-sendl2tol1msg) -- **Opcode**: 0x30 +- **Opcode**: 0x2d - **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]`. @@ -1591,7 +1516,7 @@ Call into another contract [See in table.](#isa-table-call) -- **Opcode**: 0x31 +- **Opcode**: 0x2e - **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]`. @@ -1638,7 +1563,7 @@ Call into another contract, disallowing World State and Accrued Substate modific [See in table.](#isa-table-staticcall) -- **Opcode**: 0x32 +- **Opcode**: 0x2f - **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]`. @@ -1682,7 +1607,7 @@ T[retOffset:retOffset+retSize] = field`} [See in table.](#isa-table-delegatecall) -- **Opcode**: 0x33 +- **Opcode**: 0x30 - **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]`. @@ -1726,7 +1651,7 @@ Halt execution within this context (without revert), optionally returning some d [See in table.](#isa-table-return) -- **Opcode**: 0x34 +- **Opcode**: 0x31 - **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]`. @@ -1748,7 +1673,7 @@ Halt execution within this context as `reverted`, optionally returning some data [See in table.](#isa-table-revert) -- **Opcode**: 0x35 +- **Opcode**: 0x32 - **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]`. @@ -1771,7 +1696,7 @@ Convert a word to an array of limbs in little-endian radix form [See in table.](#isa-table-to_radix_le) -- **Opcode**: 0x36 +- **Opcode**: 0x33 - **Category**: Conversions - **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 1dab654b9fd..be0a6c174ca 100644 --- a/docs/src/preprocess/InstructionSet/InstructionSet.js +++ b/docs/src/preprocess/InstructionSet/InstructionSet.js @@ -658,24 +658,6 @@ const INSTRUCTION_SET_RAW = [ "Tag checks": "", "Tag updates": "`T[dstOffset] = u64`", }, - { - id: "coinbase", - Name: "`COINBASE`", - Category: "Execution Environment - Globals", - 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.globals.coinbase`", - Summary: "(UNIMPLEMENTED) Get the block's beneficiary address", - Details: "", - "Tag checks": "", - "Tag updates": "`T[dstOffset] = field`", - }, { id: "feeperl2gas", Name: "`FEEPERL2GAS`", @@ -714,42 +696,6 @@ const INSTRUCTION_SET_RAW = [ "Tag checks": "", "Tag updates": "`T[dstOffset] = field`", }, - { - id: "blockl2gaslimit", - Name: "`BLOCKL2GASLIMIT`", - Category: "Execution Environment - Globals", - 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.globals.l2GasLimit`", - Summary: '(UNIMPLEMENTED) Total amount of "L2 gas" that a block can consume', - Details: "", - "Tag checks": "", - "Tag updates": "`T[dstOffset] = field`", - }, - { - id: "blockdagaslimit", - Name: "`BLOCKDAGASLIMIT`", - Category: "Execution Environment - Globals", - 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.globals.daGasLimit`", - Summary: '(UNIMPLEMENTED) Total amount of "DA gas" that a block can consume', - Details: "", - "Tag checks": "", - "Tag updates": "`T[dstOffset] = field`", - }, { id: "calldatacopy", Name: "`CALLDATACOPY`", diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index a0c586fa911..c436e4a9bb9 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -432,11 +432,8 @@ global AVM_CHAINID_BASE_L2_GAS: u16 = 200; global AVM_VERSION_BASE_L2_GAS: u16 = 200; global AVM_BLOCKNUMBER_BASE_L2_GAS: u16 = 200; global AVM_TIMESTAMP_BASE_L2_GAS: u16 = 200; -global AVM_COINBASE_BASE_L2_GAS: u16 = 200; global AVM_FEEPERL2GAS_BASE_L2_GAS: u16 = 200; global AVM_FEEPERDAGAS_BASE_L2_GAS: u16 = 200; -global AVM_BLOCKL2GASLIMIT_BASE_L2_GAS: u16 = 200; -global AVM_BLOCKDAGASLIMIT_BASE_L2_GAS: u16 = 200; global AVM_CALLDATACOPY_BASE_L2_GAS: u16 = 290; global AVM_L2GASLEFT_BASE_L2_GAS: u16 = 180; global AVM_DAGASLEFT_BASE_L2_GAS: u16 = 180; @@ -498,11 +495,8 @@ global AVM_CHAINID_DYN_L2_GAS: u16 = 0; global AVM_VERSION_DYN_L2_GAS: u16 = 0; global AVM_BLOCKNUMBER_DYN_L2_GAS: u16 = 0; global AVM_TIMESTAMP_DYN_L2_GAS: u16 = 0; -global AVM_COINBASE_DYN_L2_GAS: u16 = 0; global AVM_FEEPERL2GAS_DYN_L2_GAS: u16 = 0; global AVM_FEEPERDAGAS_DYN_L2_GAS: u16 = 0; -global AVM_BLOCKL2GASLIMIT_DYN_L2_GAS: u16 = 0; -global AVM_BLOCKDAGASLIMIT_DYN_L2_GAS: u16 = 0; global AVM_CALLDATACOPY_DYN_L2_GAS: u16 = 50; global AVM_L2GASLEFT_DYN_L2_GAS: u16 = 0; global AVM_DAGASLEFT_DYN_L2_GAS: u16 = 0; diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index 989f1ce75e4..f2f9cf6e267 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -258,11 +258,8 @@ export const AVM_CHAINID_BASE_L2_GAS = 200; export const AVM_VERSION_BASE_L2_GAS = 200; export const AVM_BLOCKNUMBER_BASE_L2_GAS = 200; export const AVM_TIMESTAMP_BASE_L2_GAS = 200; -export const AVM_COINBASE_BASE_L2_GAS = 200; export const AVM_FEEPERL2GAS_BASE_L2_GAS = 200; export const AVM_FEEPERDAGAS_BASE_L2_GAS = 200; -export const AVM_BLOCKL2GASLIMIT_BASE_L2_GAS = 200; -export const AVM_BLOCKDAGASLIMIT_BASE_L2_GAS = 200; export const AVM_CALLDATACOPY_BASE_L2_GAS = 290; export const AVM_L2GASLEFT_BASE_L2_GAS = 180; export const AVM_DAGASLEFT_BASE_L2_GAS = 180; @@ -323,11 +320,8 @@ export const AVM_CHAINID_DYN_L2_GAS = 0; export const AVM_VERSION_DYN_L2_GAS = 0; export const AVM_BLOCKNUMBER_DYN_L2_GAS = 0; export const AVM_TIMESTAMP_DYN_L2_GAS = 0; -export const AVM_COINBASE_DYN_L2_GAS = 0; export const AVM_FEEPERL2GAS_DYN_L2_GAS = 0; export const AVM_FEEPERDAGAS_DYN_L2_GAS = 0; -export const AVM_BLOCKL2GASLIMIT_DYN_L2_GAS = 0; -export const AVM_BLOCKDAGASLIMIT_DYN_L2_GAS = 0; export const AVM_CALLDATACOPY_DYN_L2_GAS = 50; export const AVM_L2GASLEFT_DYN_L2_GAS = 0; export const AVM_DAGASLEFT_DYN_L2_GAS = 0; diff --git a/yarn-project/circuits.js/src/scripts/constants.in.ts b/yarn-project/circuits.js/src/scripts/constants.in.ts index d2e7f347643..819f7da934f 100644 --- a/yarn-project/circuits.js/src/scripts/constants.in.ts +++ b/yarn-project/circuits.js/src/scripts/constants.in.ts @@ -64,7 +64,6 @@ const CPP_CONSTANTS = [ 'VERSION_SELECTOR', 'BLOCK_NUMBER_SELECTOR', 'TIMESTAMP_SELECTOR', - 'COINBASE_SELECTOR', 'FEE_PER_DA_GAS_SELECTOR', 'FEE_PER_L2_GAS_SELECTOR', 'END_GLOBAL_VARIABLES', @@ -103,7 +102,6 @@ const PIL_CONSTANTS = [ 'VERSION_SELECTOR', 'BLOCK_NUMBER_SELECTOR', 'TIMESTAMP_SELECTOR', - 'COINBASE_SELECTOR', 'FEE_PER_DA_GAS_SELECTOR', 'FEE_PER_L2_GAS_SELECTOR', 'END_GLOBAL_VARIABLES', diff --git a/yarn-project/simulator/src/avm/avm_gas.ts b/yarn-project/simulator/src/avm/avm_gas.ts index f7d4787885f..da55b3f8c8a 100644 --- a/yarn-project/simulator/src/avm/avm_gas.ts +++ b/yarn-project/simulator/src/avm/avm_gas.ts @@ -83,9 +83,6 @@ const BaseGasCosts: Record = { [Opcode.VERSION]: makeCost(c.AVM_VERSION_BASE_L2_GAS, 0), [Opcode.BLOCKNUMBER]: makeCost(c.AVM_BLOCKNUMBER_BASE_L2_GAS, 0), [Opcode.TIMESTAMP]: makeCost(c.AVM_TIMESTAMP_BASE_L2_GAS, 0), - [Opcode.COINBASE]: makeCost(c.AVM_COINBASE_BASE_L2_GAS, 0), - [Opcode.BLOCKL2GASLIMIT]: makeCost(c.AVM_BLOCKL2GASLIMIT_BASE_L2_GAS, 0), - [Opcode.BLOCKDAGASLIMIT]: makeCost(c.AVM_BLOCKDAGASLIMIT_BASE_L2_GAS, 0), [Opcode.CALLDATACOPY]: makeCost(c.AVM_CALLDATACOPY_BASE_L2_GAS, 0), [Opcode.L2GASLEFT]: makeCost(c.AVM_L2GASLEFT_BASE_L2_GAS, 0), [Opcode.DAGASLEFT]: makeCost(c.AVM_DAGASLEFT_BASE_L2_GAS, 0), @@ -151,9 +148,6 @@ const DynamicGasCosts: Record = { [Opcode.VERSION]: makeCost(c.AVM_VERSION_DYN_L2_GAS, 0), [Opcode.BLOCKNUMBER]: makeCost(c.AVM_BLOCKNUMBER_DYN_L2_GAS, 0), [Opcode.TIMESTAMP]: makeCost(c.AVM_TIMESTAMP_DYN_L2_GAS, 0), - [Opcode.COINBASE]: makeCost(c.AVM_COINBASE_DYN_L2_GAS, 0), - [Opcode.BLOCKL2GASLIMIT]: makeCost(c.AVM_BLOCKL2GASLIMIT_DYN_L2_GAS, 0), - [Opcode.BLOCKDAGASLIMIT]: makeCost(c.AVM_BLOCKDAGASLIMIT_DYN_L2_GAS, 0), [Opcode.CALLDATACOPY]: makeCost(c.AVM_CALLDATACOPY_DYN_L2_GAS, 0), [Opcode.L2GASLEFT]: makeCost(c.AVM_L2GASLEFT_DYN_L2_GAS, 0), [Opcode.DAGASLEFT]: makeCost(c.AVM_DAGASLEFT_DYN_L2_GAS, 0), diff --git a/yarn-project/simulator/src/avm/serialization/bytecode_serialization.ts b/yarn-project/simulator/src/avm/serialization/bytecode_serialization.ts index 034588db6e3..48a29f21bbc 100644 --- a/yarn-project/simulator/src/avm/serialization/bytecode_serialization.ts +++ b/yarn-project/simulator/src/avm/serialization/bytecode_serialization.ts @@ -94,11 +94,8 @@ const INSTRUCTION_SET = () => [Version.opcode, Version], [BlockNumber.opcode, BlockNumber], [Timestamp.opcode, Timestamp], - //[Coinbase.opcode, Coinbase], [FeePerL2Gas.opcode, FeePerL2Gas], [FeePerDAGas.opcode, FeePerDAGas], - //[Blockl2gaslimit.opcode, Blockl2gaslimit], - //[Blockdagaslimit.opcode, Blockdagaslimit], // Execution Environment - Calldata [CalldataCopy.opcode, CalldataCopy], diff --git a/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts b/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts index e906fb04309..6208161ecc7 100644 --- a/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts +++ b/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts @@ -33,11 +33,8 @@ export enum Opcode { VERSION, BLOCKNUMBER, TIMESTAMP, - COINBASE, FEEPERL2GAS, FEEPERDAGAS, - BLOCKL2GASLIMIT, - BLOCKDAGASLIMIT, CALLDATACOPY, // Gas L2GASLEFT,