Skip to content

Commit

Permalink
fix: manually correct totalfees pil constants (#6457)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 authored and just-mitch committed May 16, 2024
1 parent aad4349 commit b5a573e
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 65 deletions.
22 changes: 11 additions & 11 deletions barretenberg/cpp/pil/avm/constants.pil
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ namespace constants(256);
pol PORTAL_SELECTOR = 2;

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

// Global Variables
pol CHAIN_ID_SELECTOR = 28;
pol VERSION_SELECTOR = 29;
pol BLOCK_NUMBER_SELECTOR = 30;
pol TIMESTAMP_SELECTOR = 31;
pol COINBASE_SELECTOR = 32;
pol CHAIN_ID_SELECTOR = 29;
pol VERSION_SELECTOR = 30;
pol BLOCK_NUMBER_SELECTOR = 31;
pol TIMESTAMP_SELECTOR = 32;
pol COINBASE_SELECTOR = 33;

pol END_GLOBAL_VARIABLES = 28 + 8; // We only use the first 5 of 8 global variables for now
pol END_GLOBAL_VARIABLES = 28 + 10; // We only use the first 5 of 10 global variables for now

pol START_SIDE_EFFECT_COUNTER = 36;
pol START_SIDE_EFFECT_COUNTER = 38;

// Gas
pol FEE_PER_DA_GAS_SELECTOR = 37;
pol FEE_PER_L2_GAS_SELECTOR = 38;
pol FEE_PER_DA_GAS_SELECTOR = 39;
pol FEE_PER_L2_GAS_SELECTOR = 40;

pol TRANSACTION_FEE_SELECTOR = 39;
pol TRANSACTION_FEE_SELECTOR = 41;

Original file line number Diff line number Diff line change
Expand Up @@ -915,63 +915,63 @@ template <typename FF_> class avm_mainImpl {
{
Avm_DECLARE_VIEWS(83);

auto tmp = (avm_main_sel_op_fee_per_da_gas * (avm_kernel_kernel_sel - FF(37)));
auto tmp = (avm_main_sel_op_fee_per_da_gas * (avm_kernel_kernel_sel - FF(39)));
tmp *= scaling_factor;
std::get<83>(evals) += tmp;
}
// Contribution 84
{
Avm_DECLARE_VIEWS(84);

auto tmp = (avm_main_sel_op_fee_per_l2_gas * (avm_kernel_kernel_sel - FF(38)));
auto tmp = (avm_main_sel_op_fee_per_l2_gas * (avm_kernel_kernel_sel - FF(40)));
tmp *= scaling_factor;
std::get<84>(evals) += tmp;
}
// Contribution 85
{
Avm_DECLARE_VIEWS(85);

auto tmp = (avm_main_sel_op_transaction_fee * (avm_kernel_kernel_sel - FF(39)));
auto tmp = (avm_main_sel_op_transaction_fee * (avm_kernel_kernel_sel - FF(41)));
tmp *= scaling_factor;
std::get<85>(evals) += tmp;
}
// Contribution 86
{
Avm_DECLARE_VIEWS(86);

auto tmp = (avm_main_sel_op_chain_id * (avm_kernel_kernel_sel - FF(28)));
auto tmp = (avm_main_sel_op_chain_id * (avm_kernel_kernel_sel - FF(29)));
tmp *= scaling_factor;
std::get<86>(evals) += tmp;
}
// Contribution 87
{
Avm_DECLARE_VIEWS(87);

auto tmp = (avm_main_sel_op_version * (avm_kernel_kernel_sel - FF(29)));
auto tmp = (avm_main_sel_op_version * (avm_kernel_kernel_sel - FF(30)));
tmp *= scaling_factor;
std::get<87>(evals) += tmp;
}
// Contribution 88
{
Avm_DECLARE_VIEWS(88);

auto tmp = (avm_main_sel_op_block_number * (avm_kernel_kernel_sel - FF(30)));
auto tmp = (avm_main_sel_op_block_number * (avm_kernel_kernel_sel - FF(31)));
tmp *= scaling_factor;
std::get<88>(evals) += tmp;
}
// Contribution 89
{
Avm_DECLARE_VIEWS(89);

auto tmp = (avm_main_sel_op_coinbase * (avm_kernel_kernel_sel - FF(32)));
auto tmp = (avm_main_sel_op_coinbase * (avm_kernel_kernel_sel - FF(33)));
tmp *= scaling_factor;
std::get<89>(evals) += tmp;
}
// Contribution 90
{
Avm_DECLARE_VIEWS(90);

auto tmp = (avm_main_sel_op_timestamp * (avm_kernel_kernel_sel - FF(31)));
auto tmp = (avm_main_sel_op_timestamp * (avm_kernel_kernel_sel - FF(32)));
tmp *= scaling_factor;
std::get<90>(evals) += tmp;
}
Expand Down
2 changes: 0 additions & 2 deletions l1-contracts/src/core/libraries/HeaderLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ pragma solidity >=0.8.18;

// Libraries
import {Errors} from "./Errors.sol";
import {Constants} from "./ConstantsGen.sol";
import {Hash} from "./Hash.sol";

/**
* @title Header Library
Expand Down
12 changes: 6 additions & 6 deletions l1-contracts/test/fixtures/empty_block_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x28db6a7d7f6d68e8eae12643769246709897c59c72fc94b5b6ce00655b245e42",
"archive": "0x0eae14b1cf1ec4c1de308458307f3e710c14ecba32f0a0d59289273401d3c7f7",
"body": "0x00000000",
"txsEffectsHash": "0x00f6922770c8d944eb7b03abaad695fa06ad1c395d3fbe216dfb508691d16a2f",
"decodedHeader": {
Expand All @@ -23,8 +23,8 @@
"chainId": 31337,
"timestamp": 0,
"version": 1,
"coinbase": "0x4fdc8e41d48477a1e7f9b7a5de5dc36546fdd89e",
"feeRecipient": "0x2aa0b5a2607f90e00553c29ce8bf75a8a453bc167be277fdcbe7c0ff284852fd",
"coinbase": "0xe75949a3b041f25a72023aacd4eafc63c80cfd17",
"feeRecipient": "0x27162d84578334dd9ed9fa3a2809e4861d07b669b7c2f074d59e64d61a847ecf",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
Expand Down Expand Up @@ -55,8 +55,8 @@
}
}
},
"header": "0x067a48e3140b6f15d71751ededfa0cccde3d436bb71aa7fec226b0bfe51dc5cf00000001000000000000000000000000000000000000000000000000000000000000000100f6922770c8d944eb7b03abaad695fa06ad1c395d3fbe216dfb508691d16a2f00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000001016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000000800bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000001000572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000000800000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000004fdc8e41d48477a1e7f9b7a5de5dc36546fdd89e2aa0b5a2607f90e00553c29ce8bf75a8a453bc167be277fdcbe7c0ff284852fd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00f30a1da4a60be604e620ab3c0e4f960d0d47b647cde7c460e64a6c7e667e33",
"header": "0x05b0b6df52f1d47d0406318558052c89a174fbc9d615def82b3cc9ccc1937db800000001000000000000000000000000000000000000000000000000000000000000000100f6922770c8d944eb7b03abaad695fa06ad1c395d3fbe216dfb508691d16a2f00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000001016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000000800bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000001000572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000000800000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000e75949a3b041f25a72023aacd4eafc63c80cfd1727162d84578334dd9ed9fa3a2809e4861d07b669b7c2f074d59e64d61a847ecf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00953b88e136179ec39a68510c649f5aa1f9cb1b2ae541b327116c3a967f32e2",
"numTxs": 0
}
}
}
16 changes: 8 additions & 8 deletions l1-contracts/test/fixtures/empty_block_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x133f7fd0f4773b3d206b02f672a0fdd1e1a1ea9e562063c758ce4ddf6d92d079",
"archive": "0x19913c1d1ae0902cb33ef13d9419cdadba57fd3bfd33306cbe8beb48f46778a3",
"body": "0x00000000",
"txsEffectsHash": "0x00f6922770c8d944eb7b03abaad695fa06ad1c395d3fbe216dfb508691d16a2f",
"decodedHeader": {
Expand All @@ -21,18 +21,18 @@
"globalVariables": {
"blockNumber": 2,
"chainId": 31337,
"timestamp": 1715590033,
"timestamp": 1715882341,
"version": 1,
"coinbase": "0x4fdc8e41d48477a1e7f9b7a5de5dc36546fdd89e",
"feeRecipient": "0x2aa0b5a2607f90e00553c29ce8bf75a8a453bc167be277fdcbe7c0ff284852fd",
"coinbase": "0xe75949a3b041f25a72023aacd4eafc63c80cfd17",
"feeRecipient": "0x27162d84578334dd9ed9fa3a2809e4861d07b669b7c2f074d59e64d61a847ecf",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
}
},
"lastArchive": {
"nextAvailableLeafIndex": 2,
"root": "0x28db6a7d7f6d68e8eae12643769246709897c59c72fc94b5b6ce00655b245e42"
"root": "0x0eae14b1cf1ec4c1de308458307f3e710c14ecba32f0a0d59289273401d3c7f7"
},
"stateReference": {
"l1ToL2MessageTree": {
Expand All @@ -55,8 +55,8 @@
}
}
},
"header": "0x28db6a7d7f6d68e8eae12643769246709897c59c72fc94b5b6ce00655b245e4200000002000000000000000000000000000000000000000000000000000000000000000100f6922770c8d944eb7b03abaad695fa06ad1c395d3fbe216dfb508691d16a2f00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000002016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000001000bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000001800572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000000c00000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000006641d3914fdc8e41d48477a1e7f9b7a5de5dc36546fdd89e2aa0b5a2607f90e00553c29ce8bf75a8a453bc167be277fdcbe7c0ff284852fd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00dacc45bae55cf4217a7a66cd1ff9c2fb65726a10c8d4835a8a7c7a9ac0f18c",
"header": "0x0eae14b1cf1ec4c1de308458307f3e710c14ecba32f0a0d59289273401d3c7f700000002000000000000000000000000000000000000000000000000000000000000000100f6922770c8d944eb7b03abaad695fa06ad1c395d3fbe216dfb508691d16a2f00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000002016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000001000bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000001800572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000000c00000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000066464965e75949a3b041f25a72023aacd4eafc63c80cfd1727162d84578334dd9ed9fa3a2809e4861d07b669b7c2f074d59e64d61a847ecf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00d8e57e1de54e9d686e874e5870342ab7cb48f0c1210f16c7752ccc73f3a280",
"numTxs": 0
}
}
}
12 changes: 6 additions & 6 deletions l1-contracts/test/fixtures/mixed_block_0.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions l1-contracts/test/fixtures/mixed_block_1.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ fn empty_hash() {
let hash = item.hash();

// Value from private_call_stack_item.test.ts "computes empty item hash" test
let test_data_empty_hash = 0x23e9b31fb9659181d8e6d941e95cc88a6d4d43c6b6ee316351528db772f419c0;
let test_data_empty_hash = 0x0ef77c97e9e0d650dd3f4cf79504b784c2401ef53b32a807ef761e66d1224030;
assert_eq(hash, test_data_empty_hash);
}
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,6 @@ fn empty_hash() {
let inputs = PrivateCircuitPublicInputs::empty();
let hash = inputs.hash();
// Value from private_circuit_public_inputs.test.ts "computes empty item hash" test
let test_data_empty_hash = 0x04f513d6a85e9d0c994d3c3764732e4486264190b3bf285257f41180f09a0b58;
let test_data_empty_hash = 0x042ab4f13b8cfc7d90a897a7e9b402c8af00a30259eea346cff49fc5e34b0530;
assert_eq(hash, test_data_empty_hash);
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ mod tests {
let call_stack_item = PublicCallStackItem { contract_address, public_inputs, is_execution_request: true, function_data };

// Value from public_call_stack_item.test.ts "Computes a callstack item request hash" test
let test_data_call_stack_item_request_hash = 0x23066ad690c088120f8397cfeb2ef5608d4517342c7ff9fcb713009933ef1c61;
let test_data_call_stack_item_request_hash = 0x006b66fcdc599cbba7e8aae1d18343a577e38ad4cd1ed3e1df593f057ea6b93f;
assert_eq(call_stack_item.hash(), test_data_call_stack_item_request_hash);
}

Expand All @@ -87,7 +87,7 @@ mod tests {
let call_stack_item = PublicCallStackItem { contract_address, public_inputs, is_execution_request: false, function_data };

// Value from public_call_stack_item.test.ts "Computes a callstack item hash" test
let test_data_call_stack_item_hash = 0x1236612a9ec71bcc83af597d523f1d05df071565067bc23276a4e64b72882c22;
let test_data_call_stack_item_hash = 0x2747ec3e86d62375928e5f57c3b8908e7859b092f4dd174c7358648aa6461439;
assert_eq(call_stack_item.hash(), test_data_call_stack_item_hash);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,6 @@ fn empty_hash() {
let hash = inputs.hash();

// Value from public_circuit_public_inputs.test.ts "computes empty item hash" test
let test_data_empty_hash = 0x2d91debc43bd6354caef4fd152975e7c6dd44e8623b6b62c21b9f547f2fabd32;
let test_data_empty_hash = 0x08a0821851999ce70ebfd071427faa310b79579688d12b06795cb0bfd4b7972a;
assert_eq(hash, test_data_empty_hash);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PrivateCallStackItem computes empty item hash 1`] = `Fr<0x23e9b31fb9659181d8e6d941e95cc88a6d4d43c6b6ee316351528db772f419c0>`;
exports[`PrivateCallStackItem computes empty item hash 1`] = `Fr<0x0ef77c97e9e0d650dd3f4cf79504b784c2401ef53b32a807ef761e66d1224030>`;

exports[`PrivateCallStackItem computes hash 1`] = `Fr<0x03716c2dd42af2c14e1a871ef725775bd2ee0e7a606bb7882f15dc8cc49c2ad5>`;
exports[`PrivateCallStackItem computes hash 1`] = `Fr<0x257bd7dc5f3f886fbba77bbaf96cb12d9aaf534326f7c056e2ff3751009e25ee>`;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PrivateCircuitPublicInputs computes empty inputs hash 1`] = `Fr<0x04f513d6a85e9d0c994d3c3764732e4486264190b3bf285257f41180f09a0b58>`;
exports[`PrivateCircuitPublicInputs computes empty inputs hash 1`] = `Fr<0x042ab4f13b8cfc7d90a897a7e9b402c8af00a30259eea346cff49fc5e34b0530>`;

exports[`PrivateCircuitPublicInputs hash matches snapshot 1`] = `Fr<0x0e2af4cfdb7eb8df296c5ca7c88141f821ef45800bd240026f151f7fa7bebba6>`;
exports[`PrivateCircuitPublicInputs hash matches snapshot 1`] = `Fr<0x254aae686d0b52564a42f5acc9a2019509dd7cd3e400bec815fc44887f958df6>`;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PublicCallStackItem Computes a callstack item hash 1`] = `"0x1236612a9ec71bcc83af597d523f1d05df071565067bc23276a4e64b72882c22"`;
exports[`PublicCallStackItem Computes a callstack item hash 1`] = `"0x2747ec3e86d62375928e5f57c3b8908e7859b092f4dd174c7358648aa6461439"`;

exports[`PublicCallStackItem Computes a callstack item request hash 1`] = `"0x23066ad690c088120f8397cfeb2ef5608d4517342c7ff9fcb713009933ef1c61"`;
exports[`PublicCallStackItem Computes a callstack item request hash 1`] = `"0x006b66fcdc599cbba7e8aae1d18343a577e38ad4cd1ed3e1df593f057ea6b93f"`;

exports[`PublicCallStackItem computes empty item hash 1`] = `Fr<0x0eef6f20d1f73de870f781dad46a843966eb560e2b684752c82cd2bd45f97a34>`;
exports[`PublicCallStackItem computes empty item hash 1`] = `Fr<0x1cbe90222105ed0a06fa4d9c8384a94dc08cbcbe426e47661894195b5205b730>`;

exports[`PublicCallStackItem computes hash 1`] = `Fr<0x14dc282fc24629bcc16eab0264ce0bfffc01e433f307e3578c89d95337bc42b3>`;
exports[`PublicCallStackItem computes hash 1`] = `Fr<0x12ee9741bcdcf418078c550677cc2973e9ef6e759819487aef41ac44087bca2f>`;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PublicCircuitPublicInputs computes empty inputs hash 1`] = `Fr<0x048912d56248af479f8d7ecedbba7092d27741b10075a989e040f8e3242a7a3f>`;
exports[`PublicCircuitPublicInputs computes empty inputs hash 1`] = `Fr<0x08a0821851999ce70ebfd071427faa310b79579688d12b06795cb0bfd4b7972a>`;

exports[`PublicCircuitPublicInputs hash matches snapshot 1`] = `Fr<0x28a405c25dfa4ae5823506f7ad48e804d81b9f0fa57dc8fc43fbc0f804ee4514>`;
exports[`PublicCircuitPublicInputs hash matches snapshot 1`] = `Fr<0x2ad94c0a2215e039cf74155e594e34bd2640426e437d9c65d6aa9a8b9dc8029c>`;
2 changes: 1 addition & 1 deletion yarn-project/ethereum/src/deploy_l1_contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export const deployL1Contracts = async (

logger.info(`Deployed Gas Portal at ${gasPortalAddress}`);

// fund the rollup contract with gas tokens
// fund the rollup contract with gas tokens so it can pay transaction fees to block producers
const gasToken = getContract({
address: gasTokenAddress.toString(),
abi: contractsToDeploy.gasToken.contractAbi,
Expand Down

0 comments on commit b5a573e

Please sign in to comment.