Skip to content

Commit

Permalink
feat: add total mana used to header
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Nov 9, 2024
1 parent 5246251 commit 8b3dfcc
Show file tree
Hide file tree
Showing 42 changed files with 262 additions and 177 deletions.
8 changes: 4 additions & 4 deletions barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
#define PUBLIC_INNER_CALL_REQUEST_LENGTH 13
#define STATE_REFERENCE_LENGTH 8
#define TOTAL_FEES_LENGTH 1
#define HEADER_LENGTH 24
#define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 866
#define PUBLIC_CONTEXT_INPUTS_LENGTH 41
#define HEADER_LENGTH 25
#define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 867
#define PUBLIC_CONTEXT_INPUTS_LENGTH 42
#define AVM_ACCUMULATED_DATA_LENGTH 318
#define AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS 86
#define AVM_PROOF_LENGTH_IN_FIELDS 4176
#define AVM_PUBLIC_COLUMN_MAX_SIZE 1024
#define AVM_PUBLIC_INPUTS_FLATTENED_SIZE 2914
#define AVM_PUBLIC_INPUTS_FLATTENED_SIZE 2915
#define MEM_TAG_FF 0
#define MEM_TAG_U1 1
#define MEM_TAG_U8 2
Expand Down
2 changes: 2 additions & 0 deletions barretenberg/cpp/src/barretenberg/world_state/world_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@ bb::fr WorldState::compute_initial_archive(const StateReference& initial_state_r
0,
0,
// total fees
0,
// total mana used
0 });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ TEST_F(WorldStateTest, GetInitialTreeInfoForAllTrees)
EXPECT_EQ(info.meta.size, 1);
EXPECT_EQ(info.meta.depth, tree_heights.at(MerkleTreeId::ARCHIVE));
// this is the expected archive tree root at genesis
EXPECT_EQ(info.meta.root, bb::fr("0x1200a06aae1368abe36530b585bd7a4d2ba4de5037b82076412691a187d7621e"));
EXPECT_EQ(info.meta.root, bb::fr("0x0237797d6a2c04d20d4fa06b74482bd970ccd51a43d9b05b57e9b91fa1ae1cae"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ classDiagram
class Header {
+GlobalVariables globalVariables
+Fr totalFees
+Fr totalManaUsed
}
class GlobalVariables {
Expand All @@ -100,6 +101,8 @@ The `feePerGas` is presently held constant at `1` for both dimensions, but may b

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

`totalManaUsed` is the total mana used in the block and used to update the base fee.

`coinbase` is the L1 address that receives the fees.

## Transaction Fee
Expand Down
29 changes: 15 additions & 14 deletions l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ library Constants {
uint256 internal constant BLOB_SIZE_IN_BYTES = 126976;
uint256 internal constant AZTEC_MAX_EPOCH_DURATION = 32;
uint256 internal constant GENESIS_ARCHIVE_ROOT =
19007378675971183768036762391356802220352606103602592933942074152320327194720;
1002640778211850180189505934749257244705296832326768971348723156503780793518;
uint256 internal constant FEE_JUICE_INITIAL_MINT = 20000000000;
uint256 internal constant PUBLIC_DISPATCH_SELECTOR = 3578010381;
uint256 internal constant MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 3000;
Expand Down Expand Up @@ -202,11 +202,12 @@ library Constants {
uint256 internal constant TX_CONTEXT_LENGTH = 9;
uint256 internal constant TX_REQUEST_LENGTH = 13;
uint256 internal constant TOTAL_FEES_LENGTH = 1;
uint256 internal constant HEADER_LENGTH = 24;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 500;
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 866;
uint256 internal constant PRIVATE_CONTEXT_INPUTS_LENGTH = 38;
uint256 internal constant PUBLIC_CONTEXT_INPUTS_LENGTH = 41;
uint256 internal constant TOTAL_MANA_USED_LENGTH = 1;
uint256 internal constant HEADER_LENGTH = 25;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 501;
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 867;
uint256 internal constant PRIVATE_CONTEXT_INPUTS_LENGTH = 39;
uint256 internal constant PUBLIC_CONTEXT_INPUTS_LENGTH = 42;
uint256 internal constant FEE_RECIPIENT_LENGTH = 2;
uint256 internal constant AGGREGATION_OBJECT_LENGTH = 16;
uint256 internal constant SCOPED_READ_REQUEST_LEN = 3;
Expand All @@ -216,21 +217,21 @@ library Constants {
uint256 internal constant PUBLIC_VALIDATION_REQUESTS_LENGTH = 834;
uint256 internal constant PUBLIC_DATA_UPDATE_REQUEST_LENGTH = 3;
uint256 internal constant COMBINED_ACCUMULATED_DATA_LENGTH = 547;
uint256 internal constant TX_CONSTANT_DATA_LENGTH = 35;
uint256 internal constant COMBINED_CONSTANT_DATA_LENGTH = 44;
uint256 internal constant TX_CONSTANT_DATA_LENGTH = 36;
uint256 internal constant COMBINED_CONSTANT_DATA_LENGTH = 45;
uint256 internal constant PRIVATE_ACCUMULATED_DATA_LENGTH = 1064;
uint256 internal constant PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1878;
uint256 internal constant PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1879;
uint256 internal constant PUBLIC_ACCUMULATED_DATA_LENGTH = 1023;
uint256 internal constant NUM_PUBLIC_ACCUMULATED_DATA_ARRAYS = 8;
uint256 internal constant PRIVATE_TO_PUBLIC_ACCUMULATED_DATA_LENGTH = 578;
uint256 internal constant PRIVATE_TO_AVM_ACCUMULATED_DATA_LENGTH = 160;
uint256 internal constant NUM_PRIVATE_TO_AVM_ACCUMULATED_DATA_ARRAYS = 3;
uint256 internal constant PRIVATE_TO_PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1199;
uint256 internal constant PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2932;
uint256 internal constant VM_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2341;
uint256 internal constant KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 601;
uint256 internal constant PRIVATE_TO_PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1200;
uint256 internal constant PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2933;
uint256 internal constant VM_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2342;
uint256 internal constant KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 602;
uint256 internal constant CONSTANT_ROLLUP_DATA_LENGTH = 13;
uint256 internal constant BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 30;
uint256 internal constant BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 31;
uint256 internal constant BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH = 90;
uint256 internal constant ROOT_ROLLUP_PUBLIC_INPUTS_LENGTH = 76;
uint256 internal constant GET_NOTES_ORACLE_RETURN_LENGTH = 674;
Expand Down
11 changes: 8 additions & 3 deletions l1-contracts/src/core/libraries/HeaderLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {Errors} from "@aztec/core/libraries/Errors.sol";
* | | | }
* | | | }
* | 0x0248 | 0x20 | total_fees
* | 0x0268 | 0x20 | total_mana_used
* | --- | --- | ---
*/
library HeaderLib {
Expand Down Expand Up @@ -102,9 +103,10 @@ library HeaderLib {
StateReference stateReference;
GlobalVariables globalVariables;
uint256 totalFees;
uint256 totalManaUsed;
}

uint256 private constant HEADER_LENGTH = 0x268; // Header byte length
uint256 private constant HEADER_LENGTH = 0x288; // Header byte length

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

// Reading totalManaUsed
header.totalManaUsed = uint256(bytes32(_header[0x0268:0x0288]));

return header;
}

function toFields(Header memory _header) internal pure returns (bytes32[] memory) {
bytes32[] memory fields = new bytes32[](24);
bytes32[] memory fields = new bytes32[](25);

// must match the order in the Header.getFields
fields[0] = _header.lastArchive.root;
Expand Down Expand Up @@ -195,7 +200,7 @@ library HeaderLib {
fields[21] = bytes32(_header.globalVariables.gasFees.feePerDaGas);
fields[22] = bytes32(_header.globalVariables.gasFees.feePerL2Gas);
fields[23] = bytes32(_header.totalFees);

fields[24] = bytes32(_header.totalManaUsed);
// fail if the header structure has changed without updating this function
require(
fields.length == Constants.HEADER_LENGTH,
Expand Down
2 changes: 2 additions & 0 deletions l1-contracts/test/decoders/Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ contract DecoderBase is TestBase {
GlobalVariables globalVariables;
AppendOnlyTreeSnapshot lastArchive;
StateReference stateReference;
uint256 totalFees;
uint256 totalManaUsed;
}

struct GasFees {
Expand Down
18 changes: 10 additions & 8 deletions l1-contracts/test/fixtures/empty_block_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x01c96319c544c46399dcc0f48c344210ae5bf846507a202512d3aaa4768aad7f",
"blockHash": "0x1e273844400064424f4b091fd7944446a32bb7a96d8bf69a05e32f01a1a40cde",
"archive": "0x1dc739468245c6d33b9e82026677997b13f58d9f425064daaadb8e419f9124d9",
"blockHash": "0x0b0f8a9eaf46c51bccc1c17ea83917432236129f64b485b254ac3bc93eceaedc",
"body": "0x00000000",
"txsEffectsHash": "0x00e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d6",
"decodedHeader": {
Expand All @@ -23,18 +23,20 @@
"blockNumber": 1,
"slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000012",
"chainId": 31337,
"timestamp": 1731107199,
"timestamp": 1731179999,
"version": 1,
"coinbase": "0x8a914126f71d7c294a01833665b9a9019347d6a2",
"feeRecipient": "0x1d2bd70d60e15b1148d6c5590d5ed3dd0427419f862ee389b12abf25481ffd26",
"coinbase": "0xab9d40790d335aaf7b1f06c27d8aa45bdaf8a124",
"feeRecipient": "0x180a31c8c30ff21d55649698c0a5a87b44bcadc1407f0f6bd5382ca04ae2929d",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
}
},
"totalFees": "0x0000000000000000000000000000000000000000000000000000000000000000",
"totalManaUsed": "0x0000000000000000000000000000000000000000000000000000000000000000",
"lastArchive": {
"nextAvailableLeafIndex": 1,
"root": "0x2a05cb8aeefe9b9797f90650eae072f5ab7437807e62f9724ce1900467779860"
"root": "0x0237797d6a2c04d20d4fa06b74482bd970ccd51a43d9b05b57e9b91fa1ae1cae"
},
"stateReference": {
"l1ToL2MessageTree": {
Expand All @@ -57,8 +59,8 @@
}
}
},
"header": "0x2a05cb8aeefe9b9797f90650eae072f5ab7437807e62f9724ce190046777986000000001000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d6000000101fd848aa69e1633722fe249a5b7f53b094f1c9cef9f5c694b073fd1cc5850dfb000000800c499b373a1f0fe1b510a63563546d2d39e206895056a5af0143c5f30d6390730000010023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001000000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000672e997f8a914126f71d7c294a01833665b9a9019347d6a21d2bd70d60e15b1148d6c5590d5ed3dd0427419f862ee389b12abf25481ffd26000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00fc461dff8a8b9e2397bb5d40053b87281dd9fd28e77834a2749bfc5f32bfb9",
"header": "0x0237797d6a2c04d20d4fa06b74482bd970ccd51a43d9b05b57e9b91fa1ae1cae00000001000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d6000000101fd848aa69e1633722fe249a5b7f53b094f1c9cef9f5c694b073fd1cc5850dfb000000800c499b373a1f0fe1b510a63563546d2d39e206895056a5af0143c5f30d6390730000010023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001000000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000672fb5dfab9d40790d335aaf7b1f06c27d8aa45bdaf8a124180a31c8c30ff21d55649698c0a5a87b44bcadc1407f0f6bd5382ca04ae2929d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x000cf00d10cbffdead1f054f5531afd820d9287bc4fdda7b36f84c6f90537378",
"numTxs": 0
}
}
18 changes: 10 additions & 8 deletions l1-contracts/test/fixtures/empty_block_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x19b0447418d0e86728db9266ecf57b26b3e4a47388c4241e16f5f9e4b2d20492",
"blockHash": "0x07effa5ee44661e8167d238e02729e739543aa4cfbf619878850a440e021ce72",
"archive": "0x0fdd3d4dbff9b14f5b2f0ee2e9fe160b4dea41622ceeb1f83258d3c47e4fb026",
"blockHash": "0x0aec0680a3fc21d813abd51da419317a033fb68f58cd7a805d18524fc1e08553",
"body": "0x00000000",
"txsEffectsHash": "0x00e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d6",
"decodedHeader": {
Expand All @@ -23,18 +23,20 @@
"blockNumber": 2,
"slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000013",
"chainId": 31337,
"timestamp": 1731107223,
"timestamp": 1731180023,
"version": 1,
"coinbase": "0x8a914126f71d7c294a01833665b9a9019347d6a2",
"feeRecipient": "0x1d2bd70d60e15b1148d6c5590d5ed3dd0427419f862ee389b12abf25481ffd26",
"coinbase": "0xab9d40790d335aaf7b1f06c27d8aa45bdaf8a124",
"feeRecipient": "0x180a31c8c30ff21d55649698c0a5a87b44bcadc1407f0f6bd5382ca04ae2929d",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
}
},
"totalFees": "0x0000000000000000000000000000000000000000000000000000000000000000",
"totalManaUsed": "0x0000000000000000000000000000000000000000000000000000000000000000",
"lastArchive": {
"nextAvailableLeafIndex": 2,
"root": "0x01c96319c544c46399dcc0f48c344210ae5bf846507a202512d3aaa4768aad7f"
"root": "0x1dc739468245c6d33b9e82026677997b13f58d9f425064daaadb8e419f9124d9"
},
"stateReference": {
"l1ToL2MessageTree": {
Expand All @@ -57,8 +59,8 @@
}
}
},
"header": "0x01c96319c544c46399dcc0f48c344210ae5bf846507a202512d3aaa4768aad7f00000002000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d6000000201fd848aa69e1633722fe249a5b7f53b094f1c9cef9f5c694b073fd1cc5850dfb000001000c499b373a1f0fe1b510a63563546d2d39e206895056a5af0143c5f30d6390730000018023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001800000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001300000000000000000000000000000000000000000000000000000000672e99978a914126f71d7c294a01833665b9a9019347d6a21d2bd70d60e15b1148d6c5590d5ed3dd0427419f862ee389b12abf25481ffd26000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x006d28d243077e67b4570884f2b6d0b30aba890a326b21308690d5f279e47ab9",
"header": "0x1dc739468245c6d33b9e82026677997b13f58d9f425064daaadb8e419f9124d900000002000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d6000000201fd848aa69e1633722fe249a5b7f53b094f1c9cef9f5c694b073fd1cc5850dfb000001000c499b373a1f0fe1b510a63563546d2d39e206895056a5af0143c5f30d6390730000018023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001800000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001300000000000000000000000000000000000000000000000000000000672fb5f7ab9d40790d335aaf7b1f06c27d8aa45bdaf8a124180a31c8c30ff21d55649698c0a5a87b44bcadc1407f0f6bd5382ca04ae2929d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00879d193be782fe7b6d2555f2ab28dce64e06c932117a46433a4f6b241d5a98",
"numTxs": 0
}
}
18 changes: 10 additions & 8 deletions l1-contracts/test/fixtures/mixed_block_1.json

Large diffs are not rendered by default.

62 changes: 16 additions & 46 deletions l1-contracts/test/fixtures/mixed_block_2.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct BaseOrMergeRollupPublicInputs {
out_hash: Field,

accumulated_fees: Field,
accumulated_mana_used: Field,
}

impl Empty for BaseOrMergeRollupPublicInputs {
Expand All @@ -41,6 +42,7 @@ impl Empty for BaseOrMergeRollupPublicInputs {
txs_effects_hash: 0,
out_hash: 0,
accumulated_fees: 0,
accumulated_mana_used: 0,
}
}
}
Expand All @@ -55,6 +57,7 @@ impl Eq for BaseOrMergeRollupPublicInputs {
& (self.txs_effects_hash == other.txs_effects_hash)
& (self.out_hash == other.out_hash)
& (self.accumulated_fees == other.accumulated_fees)
& (self.accumulated_mana_used == other.accumulated_mana_used)
}
}

Expand All @@ -70,7 +73,7 @@ impl Serialize<BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH> for BaseOrMergeRollupPublicIn
fields.push(self.txs_effects_hash as Field);
fields.push(self.out_hash as Field);
fields.push(self.accumulated_fees as Field);

fields.push(self.accumulated_mana_used as Field);
assert_eq(fields.len(), BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH);

fields.storage()
Expand All @@ -91,6 +94,7 @@ impl Deserialize<BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH> for BaseOrMergeRollupPublic
txs_effects_hash: reader.read(),
out_hash: reader.read(),
accumulated_fees: reader.read(),
accumulated_mana_used: reader.read(),
};

reader.finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ impl BaseRollupInputs {
txs_effects_hash: tx_effects_hash,
out_hash,
accumulated_fees: self.transaction_fee,
accumulated_mana_used: self.kernel_data.public_inputs.end.gas_used.l2_gas as Field,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ impl BlockRootRollupInputs {

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

let total_mana_used = components::accumulate_mana_used(left, right);

// unsafe {
// debug_log_format("Assembling header in block root rollup", []);
// debug_log_format(
Expand All @@ -113,13 +115,15 @@ impl BlockRootRollupInputs {
// left.constants.global_variables.serialize()
// );
// debug_log_format("header.total_fees={0}", [total_fees]);
// debug_log_format("header.total_mana_used={0}", [total_mana_used]);
// }
let header = Header {
last_archive: left.constants.last_archive,
content_commitment,
state,
global_variables: left.constants.global_variables,
total_fees,
total_mana_used,
};

// Build the block hash for this by hashing the header and then insert the new leaf to archive tree.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ pub fn accumulate_fees(
left.accumulated_fees + right.accumulated_fees
}

pub fn accumulate_mana_used(
left: BaseOrMergeRollupPublicInputs,
right: BaseOrMergeRollupPublicInputs,
) -> Field {
left.accumulated_mana_used + right.accumulated_mana_used
}

pub fn accumulate_blocks_fees(
left: BlockRootOrBlockMergePublicInputs,
right: BlockRootOrBlockMergePublicInputs,
Expand Down
Loading

0 comments on commit 8b3dfcc

Please sign in to comment.