Skip to content

Commit 8b3dfcc

Browse files
committed
feat: add total mana used to header
1 parent 5246251 commit 8b3dfcc

File tree

42 files changed

+262
-177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+262
-177
lines changed

barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@
3232
#define PUBLIC_INNER_CALL_REQUEST_LENGTH 13
3333
#define STATE_REFERENCE_LENGTH 8
3434
#define TOTAL_FEES_LENGTH 1
35-
#define HEADER_LENGTH 24
36-
#define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 866
37-
#define PUBLIC_CONTEXT_INPUTS_LENGTH 41
35+
#define HEADER_LENGTH 25
36+
#define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 867
37+
#define PUBLIC_CONTEXT_INPUTS_LENGTH 42
3838
#define AVM_ACCUMULATED_DATA_LENGTH 318
3939
#define AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS 86
4040
#define AVM_PROOF_LENGTH_IN_FIELDS 4176
4141
#define AVM_PUBLIC_COLUMN_MAX_SIZE 1024
42-
#define AVM_PUBLIC_INPUTS_FLATTENED_SIZE 2914
42+
#define AVM_PUBLIC_INPUTS_FLATTENED_SIZE 2915
4343
#define MEM_TAG_FF 0
4444
#define MEM_TAG_U1 1
4545
#define MEM_TAG_U8 2

barretenberg/cpp/src/barretenberg/world_state/world_state.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,8 @@ bb::fr WorldState::compute_initial_archive(const StateReference& initial_state_r
676676
0,
677677
0,
678678
// total fees
679+
0,
680+
// total mana used
679681
0 });
680682
}
681683

barretenberg/cpp/src/barretenberg/world_state/world_state.test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ TEST_F(WorldStateTest, GetInitialTreeInfoForAllTrees)
168168
EXPECT_EQ(info.meta.size, 1);
169169
EXPECT_EQ(info.meta.depth, tree_heights.at(MerkleTreeId::ARCHIVE));
170170
// this is the expected archive tree root at genesis
171-
EXPECT_EQ(info.meta.root, bb::fr("0x1200a06aae1368abe36530b585bd7a4d2ba4de5037b82076412691a187d7621e"));
171+
EXPECT_EQ(info.meta.root, bb::fr("0x0237797d6a2c04d20d4fa06b74482bd970ccd51a43d9b05b57e9b91fa1ae1cae"));
172172
}
173173
}
174174

docs/docs/protocol-specs/gas-and-fees/specifying-gas-fee-info.md

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ classDiagram
7878
class Header {
7979
+GlobalVariables globalVariables
8080
+Fr totalFees
81+
+Fr totalManaUsed
8182
}
8283
8384
class GlobalVariables {
@@ -100,6 +101,8 @@ The `feePerGas` is presently held constant at `1` for both dimensions, but may b
100101

101102
`totalFees` is the total fees collected in the block in FPA.
102103

104+
`totalManaUsed` is the total mana used in the block and used to update the base fee.
105+
103106
`coinbase` is the L1 address that receives the fees.
104107

105108
## Transaction Fee

l1-contracts/src/core/libraries/ConstantsGen.sol

+15-14
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ library Constants {
9696
uint256 internal constant BLOB_SIZE_IN_BYTES = 126976;
9797
uint256 internal constant AZTEC_MAX_EPOCH_DURATION = 32;
9898
uint256 internal constant GENESIS_ARCHIVE_ROOT =
99-
19007378675971183768036762391356802220352606103602592933942074152320327194720;
99+
1002640778211850180189505934749257244705296832326768971348723156503780793518;
100100
uint256 internal constant FEE_JUICE_INITIAL_MINT = 20000000000;
101101
uint256 internal constant PUBLIC_DISPATCH_SELECTOR = 3578010381;
102102
uint256 internal constant MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 3000;
@@ -202,11 +202,12 @@ library Constants {
202202
uint256 internal constant TX_CONTEXT_LENGTH = 9;
203203
uint256 internal constant TX_REQUEST_LENGTH = 13;
204204
uint256 internal constant TOTAL_FEES_LENGTH = 1;
205-
uint256 internal constant HEADER_LENGTH = 24;
206-
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 500;
207-
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 866;
208-
uint256 internal constant PRIVATE_CONTEXT_INPUTS_LENGTH = 38;
209-
uint256 internal constant PUBLIC_CONTEXT_INPUTS_LENGTH = 41;
205+
uint256 internal constant TOTAL_MANA_USED_LENGTH = 1;
206+
uint256 internal constant HEADER_LENGTH = 25;
207+
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 501;
208+
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 867;
209+
uint256 internal constant PRIVATE_CONTEXT_INPUTS_LENGTH = 39;
210+
uint256 internal constant PUBLIC_CONTEXT_INPUTS_LENGTH = 42;
210211
uint256 internal constant FEE_RECIPIENT_LENGTH = 2;
211212
uint256 internal constant AGGREGATION_OBJECT_LENGTH = 16;
212213
uint256 internal constant SCOPED_READ_REQUEST_LEN = 3;
@@ -216,21 +217,21 @@ library Constants {
216217
uint256 internal constant PUBLIC_VALIDATION_REQUESTS_LENGTH = 834;
217218
uint256 internal constant PUBLIC_DATA_UPDATE_REQUEST_LENGTH = 3;
218219
uint256 internal constant COMBINED_ACCUMULATED_DATA_LENGTH = 547;
219-
uint256 internal constant TX_CONSTANT_DATA_LENGTH = 35;
220-
uint256 internal constant COMBINED_CONSTANT_DATA_LENGTH = 44;
220+
uint256 internal constant TX_CONSTANT_DATA_LENGTH = 36;
221+
uint256 internal constant COMBINED_CONSTANT_DATA_LENGTH = 45;
221222
uint256 internal constant PRIVATE_ACCUMULATED_DATA_LENGTH = 1064;
222-
uint256 internal constant PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1878;
223+
uint256 internal constant PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1879;
223224
uint256 internal constant PUBLIC_ACCUMULATED_DATA_LENGTH = 1023;
224225
uint256 internal constant NUM_PUBLIC_ACCUMULATED_DATA_ARRAYS = 8;
225226
uint256 internal constant PRIVATE_TO_PUBLIC_ACCUMULATED_DATA_LENGTH = 578;
226227
uint256 internal constant PRIVATE_TO_AVM_ACCUMULATED_DATA_LENGTH = 160;
227228
uint256 internal constant NUM_PRIVATE_TO_AVM_ACCUMULATED_DATA_ARRAYS = 3;
228-
uint256 internal constant PRIVATE_TO_PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1199;
229-
uint256 internal constant PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2932;
230-
uint256 internal constant VM_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2341;
231-
uint256 internal constant KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 601;
229+
uint256 internal constant PRIVATE_TO_PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1200;
230+
uint256 internal constant PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2933;
231+
uint256 internal constant VM_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2342;
232+
uint256 internal constant KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 602;
232233
uint256 internal constant CONSTANT_ROLLUP_DATA_LENGTH = 13;
233-
uint256 internal constant BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 30;
234+
uint256 internal constant BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 31;
234235
uint256 internal constant BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH = 90;
235236
uint256 internal constant ROOT_ROLLUP_PUBLIC_INPUTS_LENGTH = 76;
236237
uint256 internal constant GET_NOTES_ORACLE_RETURN_LENGTH = 674;

l1-contracts/src/core/libraries/HeaderLib.sol

+8-3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {Errors} from "@aztec/core/libraries/Errors.sol";
5252
* | | | }
5353
* | | | }
5454
* | 0x0248 | 0x20 | total_fees
55+
* | 0x0268 | 0x20 | total_mana_used
5556
* | --- | --- | ---
5657
*/
5758
library HeaderLib {
@@ -102,9 +103,10 @@ library HeaderLib {
102103
StateReference stateReference;
103104
GlobalVariables globalVariables;
104105
uint256 totalFees;
106+
uint256 totalManaUsed;
105107
}
106108

107-
uint256 private constant HEADER_LENGTH = 0x268; // Header byte length
109+
uint256 private constant HEADER_LENGTH = 0x288; // Header byte length
108110

109111
/**
110112
* @notice Decodes the header
@@ -158,11 +160,14 @@ library HeaderLib {
158160
// Reading totalFees
159161
header.totalFees = uint256(bytes32(_header[0x0248:0x0268]));
160162

163+
// Reading totalManaUsed
164+
header.totalManaUsed = uint256(bytes32(_header[0x0268:0x0288]));
165+
161166
return header;
162167
}
163168

164169
function toFields(Header memory _header) internal pure returns (bytes32[] memory) {
165-
bytes32[] memory fields = new bytes32[](24);
170+
bytes32[] memory fields = new bytes32[](25);
166171

167172
// must match the order in the Header.getFields
168173
fields[0] = _header.lastArchive.root;
@@ -195,7 +200,7 @@ library HeaderLib {
195200
fields[21] = bytes32(_header.globalVariables.gasFees.feePerDaGas);
196201
fields[22] = bytes32(_header.globalVariables.gasFees.feePerL2Gas);
197202
fields[23] = bytes32(_header.totalFees);
198-
203+
fields[24] = bytes32(_header.totalManaUsed);
199204
// fail if the header structure has changed without updating this function
200205
require(
201206
fields.length == Constants.HEADER_LENGTH,

l1-contracts/test/decoders/Base.sol

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ contract DecoderBase is TestBase {
5151
GlobalVariables globalVariables;
5252
AppendOnlyTreeSnapshot lastArchive;
5353
StateReference stateReference;
54+
uint256 totalFees;
55+
uint256 totalManaUsed;
5456
}
5557

5658
struct GasFees {

l1-contracts/test/fixtures/empty_block_1.json

+10-8
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"l2ToL1Messages": []
99
},
1010
"block": {
11-
"archive": "0x01c96319c544c46399dcc0f48c344210ae5bf846507a202512d3aaa4768aad7f",
12-
"blockHash": "0x1e273844400064424f4b091fd7944446a32bb7a96d8bf69a05e32f01a1a40cde",
11+
"archive": "0x1dc739468245c6d33b9e82026677997b13f58d9f425064daaadb8e419f9124d9",
12+
"blockHash": "0x0b0f8a9eaf46c51bccc1c17ea83917432236129f64b485b254ac3bc93eceaedc",
1313
"body": "0x00000000",
1414
"txsEffectsHash": "0x00e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d6",
1515
"decodedHeader": {
@@ -23,18 +23,20 @@
2323
"blockNumber": 1,
2424
"slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000012",
2525
"chainId": 31337,
26-
"timestamp": 1731107199,
26+
"timestamp": 1731179999,
2727
"version": 1,
28-
"coinbase": "0x8a914126f71d7c294a01833665b9a9019347d6a2",
29-
"feeRecipient": "0x1d2bd70d60e15b1148d6c5590d5ed3dd0427419f862ee389b12abf25481ffd26",
28+
"coinbase": "0xab9d40790d335aaf7b1f06c27d8aa45bdaf8a124",
29+
"feeRecipient": "0x180a31c8c30ff21d55649698c0a5a87b44bcadc1407f0f6bd5382ca04ae2929d",
3030
"gasFees": {
3131
"feePerDaGas": 0,
3232
"feePerL2Gas": 0
3333
}
3434
},
35+
"totalFees": "0x0000000000000000000000000000000000000000000000000000000000000000",
36+
"totalManaUsed": "0x0000000000000000000000000000000000000000000000000000000000000000",
3537
"lastArchive": {
3638
"nextAvailableLeafIndex": 1,
37-
"root": "0x2a05cb8aeefe9b9797f90650eae072f5ab7437807e62f9724ce1900467779860"
39+
"root": "0x0237797d6a2c04d20d4fa06b74482bd970ccd51a43d9b05b57e9b91fa1ae1cae"
3840
},
3941
"stateReference": {
4042
"l1ToL2MessageTree": {
@@ -57,8 +59,8 @@
5759
}
5860
}
5961
},
60-
"header": "0x2a05cb8aeefe9b9797f90650eae072f5ab7437807e62f9724ce190046777986000000001000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d6000000101fd848aa69e1633722fe249a5b7f53b094f1c9cef9f5c694b073fd1cc5850dfb000000800c499b373a1f0fe1b510a63563546d2d39e206895056a5af0143c5f30d6390730000010023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001000000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000672e997f8a914126f71d7c294a01833665b9a9019347d6a21d2bd70d60e15b1148d6c5590d5ed3dd0427419f862ee389b12abf25481ffd26000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
61-
"publicInputsHash": "0x00fc461dff8a8b9e2397bb5d40053b87281dd9fd28e77834a2749bfc5f32bfb9",
62+
"header": "0x0237797d6a2c04d20d4fa06b74482bd970ccd51a43d9b05b57e9b91fa1ae1cae00000001000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d6000000101fd848aa69e1633722fe249a5b7f53b094f1c9cef9f5c694b073fd1cc5850dfb000000800c499b373a1f0fe1b510a63563546d2d39e206895056a5af0143c5f30d6390730000010023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001000000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000672fb5dfab9d40790d335aaf7b1f06c27d8aa45bdaf8a124180a31c8c30ff21d55649698c0a5a87b44bcadc1407f0f6bd5382ca04ae2929d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
63+
"publicInputsHash": "0x000cf00d10cbffdead1f054f5531afd820d9287bc4fdda7b36f84c6f90537378",
6264
"numTxs": 0
6365
}
6466
}

l1-contracts/test/fixtures/empty_block_2.json

+10-8
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"l2ToL1Messages": []
99
},
1010
"block": {
11-
"archive": "0x19b0447418d0e86728db9266ecf57b26b3e4a47388c4241e16f5f9e4b2d20492",
12-
"blockHash": "0x07effa5ee44661e8167d238e02729e739543aa4cfbf619878850a440e021ce72",
11+
"archive": "0x0fdd3d4dbff9b14f5b2f0ee2e9fe160b4dea41622ceeb1f83258d3c47e4fb026",
12+
"blockHash": "0x0aec0680a3fc21d813abd51da419317a033fb68f58cd7a805d18524fc1e08553",
1313
"body": "0x00000000",
1414
"txsEffectsHash": "0x00e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d6",
1515
"decodedHeader": {
@@ -23,18 +23,20 @@
2323
"blockNumber": 2,
2424
"slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000013",
2525
"chainId": 31337,
26-
"timestamp": 1731107223,
26+
"timestamp": 1731180023,
2727
"version": 1,
28-
"coinbase": "0x8a914126f71d7c294a01833665b9a9019347d6a2",
29-
"feeRecipient": "0x1d2bd70d60e15b1148d6c5590d5ed3dd0427419f862ee389b12abf25481ffd26",
28+
"coinbase": "0xab9d40790d335aaf7b1f06c27d8aa45bdaf8a124",
29+
"feeRecipient": "0x180a31c8c30ff21d55649698c0a5a87b44bcadc1407f0f6bd5382ca04ae2929d",
3030
"gasFees": {
3131
"feePerDaGas": 0,
3232
"feePerL2Gas": 0
3333
}
3434
},
35+
"totalFees": "0x0000000000000000000000000000000000000000000000000000000000000000",
36+
"totalManaUsed": "0x0000000000000000000000000000000000000000000000000000000000000000",
3537
"lastArchive": {
3638
"nextAvailableLeafIndex": 2,
37-
"root": "0x01c96319c544c46399dcc0f48c344210ae5bf846507a202512d3aaa4768aad7f"
39+
"root": "0x1dc739468245c6d33b9e82026677997b13f58d9f425064daaadb8e419f9124d9"
3840
},
3941
"stateReference": {
4042
"l1ToL2MessageTree": {
@@ -57,8 +59,8 @@
5759
}
5860
}
5961
},
60-
"header": "0x01c96319c544c46399dcc0f48c344210ae5bf846507a202512d3aaa4768aad7f00000002000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d6000000201fd848aa69e1633722fe249a5b7f53b094f1c9cef9f5c694b073fd1cc5850dfb000001000c499b373a1f0fe1b510a63563546d2d39e206895056a5af0143c5f30d6390730000018023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001800000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001300000000000000000000000000000000000000000000000000000000672e99978a914126f71d7c294a01833665b9a9019347d6a21d2bd70d60e15b1148d6c5590d5ed3dd0427419f862ee389b12abf25481ffd26000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
61-
"publicInputsHash": "0x006d28d243077e67b4570884f2b6d0b30aba890a326b21308690d5f279e47ab9",
62+
"header": "0x1dc739468245c6d33b9e82026677997b13f58d9f425064daaadb8e419f9124d900000002000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d6000000201fd848aa69e1633722fe249a5b7f53b094f1c9cef9f5c694b073fd1cc5850dfb000001000c499b373a1f0fe1b510a63563546d2d39e206895056a5af0143c5f30d6390730000018023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001800000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001300000000000000000000000000000000000000000000000000000000672fb5f7ab9d40790d335aaf7b1f06c27d8aa45bdaf8a124180a31c8c30ff21d55649698c0a5a87b44bcadc1407f0f6bd5382ca04ae2929d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
63+
"publicInputsHash": "0x00879d193be782fe7b6d2555f2ab28dce64e06c932117a46433a4f6b241d5a98",
6264
"numTxs": 0
6365
}
6466
}

l1-contracts/test/fixtures/mixed_block_1.json

+10-8
Large diffs are not rendered by default.

l1-contracts/test/fixtures/mixed_block_2.json

+16-46
Large diffs are not rendered by default.

noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/base_or_merge_rollup_public_inputs.nr

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub struct BaseOrMergeRollupPublicInputs {
2828
out_hash: Field,
2929

3030
accumulated_fees: Field,
31+
accumulated_mana_used: Field,
3132
}
3233

3334
impl Empty for BaseOrMergeRollupPublicInputs {
@@ -41,6 +42,7 @@ impl Empty for BaseOrMergeRollupPublicInputs {
4142
txs_effects_hash: 0,
4243
out_hash: 0,
4344
accumulated_fees: 0,
45+
accumulated_mana_used: 0,
4446
}
4547
}
4648
}
@@ -55,6 +57,7 @@ impl Eq for BaseOrMergeRollupPublicInputs {
5557
& (self.txs_effects_hash == other.txs_effects_hash)
5658
& (self.out_hash == other.out_hash)
5759
& (self.accumulated_fees == other.accumulated_fees)
60+
& (self.accumulated_mana_used == other.accumulated_mana_used)
5861
}
5962
}
6063

@@ -70,7 +73,7 @@ impl Serialize<BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH> for BaseOrMergeRollupPublicIn
7073
fields.push(self.txs_effects_hash as Field);
7174
fields.push(self.out_hash as Field);
7275
fields.push(self.accumulated_fees as Field);
73-
76+
fields.push(self.accumulated_mana_used as Field);
7477
assert_eq(fields.len(), BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH);
7578

7679
fields.storage()
@@ -91,6 +94,7 @@ impl Deserialize<BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH> for BaseOrMergeRollupPublic
9194
txs_effects_hash: reader.read(),
9295
out_hash: reader.read(),
9396
accumulated_fees: reader.read(),
97+
accumulated_mana_used: reader.read(),
9498
};
9599

96100
reader.finish();

noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ impl BaseRollupInputs {
168168
txs_effects_hash: tx_effects_hash,
169169
out_hash,
170170
accumulated_fees: self.transaction_fee,
171+
accumulated_mana_used: self.kernel_data.public_inputs.end.gas_used.l2_gas as Field,
171172
}
172173
}
173174

noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ impl BlockRootRollupInputs {
9797

9898
let total_fees = components::accumulate_fees(left, right);
9999

100+
let total_mana_used = components::accumulate_mana_used(left, right);
101+
100102
// unsafe {
101103
// debug_log_format("Assembling header in block root rollup", []);
102104
// debug_log_format(
@@ -113,13 +115,15 @@ impl BlockRootRollupInputs {
113115
// left.constants.global_variables.serialize()
114116
// );
115117
// debug_log_format("header.total_fees={0}", [total_fees]);
118+
// debug_log_format("header.total_mana_used={0}", [total_mana_used]);
116119
// }
117120
let header = Header {
118121
last_archive: left.constants.last_archive,
119122
content_commitment,
120123
state,
121124
global_variables: left.constants.global_variables,
122125
total_fees,
126+
total_mana_used,
123127
};
124128

125129
// Build the block hash for this by hashing the header and then insert the new leaf to archive tree.

noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr

+7
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ pub fn accumulate_fees(
140140
left.accumulated_fees + right.accumulated_fees
141141
}
142142

143+
pub fn accumulate_mana_used(
144+
left: BaseOrMergeRollupPublicInputs,
145+
right: BaseOrMergeRollupPublicInputs,
146+
) -> Field {
147+
left.accumulated_mana_used + right.accumulated_mana_used
148+
}
149+
143150
pub fn accumulate_blocks_fees(
144151
left: BlockRootOrBlockMergePublicInputs,
145152
right: BlockRootOrBlockMergePublicInputs,

0 commit comments

Comments
 (0)