Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-kothari committed Jul 28, 2023
1 parent 3da4337 commit 18b522f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 3 additions & 0 deletions l1-contracts/src/core/libraries/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ library Constants {
KERNELS_PER_ROLLUP * CONTRACTS_PER_TX * 0x20;
uint256 internal constant CONTRACT_DATA_NUM_BYTES_PER_ROLLUP =
KERNELS_PER_ROLLUP * CONTRACTS_PER_TX * 0x40; //aztec address + eth address (padded to 0x20)
uint256 internal constant CONTRACT_DATA_NUM_BYTES_PER_ROLLUP_UNPADDED =
KERNELS_PER_ROLLUP * CONTRACTS_PER_TX * 0x34; // same as prev except doesn't pad eth address. So 0x20 (aztec address) + 0x14 (eth address)
uint256 internal constant L2_TO_L1_MSGS_NUM_BYTES_PER_ROLLUP =
KERNELS_PER_ROLLUP * L2_TO_L1_MSGS_PER_TX * 0x20;
uint256 internal constant LOGS_HASHES_NUM_BYTES_PER_ROLLUP = KERNELS_PER_ROLLUP * 4 * 0x20; // encrypted and unencrypted log hashes occupy 2 field elements each. Hence "4 x 0x20"
}
19 changes: 12 additions & 7 deletions l1-contracts/src/core/libraries/Decoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ library Decoder {
// log hash is 4 * 0x20 since each log hash is divided into two field elements. And there are two kinds of logs - enrypted, unencrypted. Hence "4 * 0x20"

vars.baseLeaf =
new bytes(Constants.COMMITMENTS_NUM_BYTES_PER_ROLLUP + Constants.NULLIFIERS_NUM_BYTES_PER_ROLLUP + Constants.PUBLIC_DATA_WRITES_NUM_BYTES_PER_ROLLUP + Constants.CONTRACTS_NUM_BYTES_PER_ROLLUP + Constants.CONTRACT_DATA_NUM_BYTES_PER_ROLLUP + 2 * 4 * 0x20);
new bytes(Constants.COMMITMENTS_NUM_BYTES_PER_ROLLUP + Constants.NULLIFIERS_NUM_BYTES_PER_ROLLUP + Constants.PUBLIC_DATA_WRITES_NUM_BYTES_PER_ROLLUP + Constants.CONTRACTS_NUM_BYTES_PER_ROLLUP + Constants.CONTRACT_DATA_NUM_BYTES_PER_ROLLUP + Constants.LOGS_HASHES_NUM_BYTES_PER_ROLLUP);

for (uint256 i = 0; i < vars.baseLeaves.length; i++) {
/*
Expand Down Expand Up @@ -417,6 +417,11 @@ library Decoder {
calldatacopy(dstPtr, add(_l2Block.offset, add(contractDataOffset, 0x54)), 0x14)
}

// bytes32[4] memory hashes = [vars.unencryptedLogsHashKernel1, vars.unencryptedLogsHashKernel2, vars.encrypedLogsHashKernel1, vars.encrypedLogsHashKernel2];
// assembly {
// calldatacopy(dstPtr, hashes, 0x80)
// }

// encryptedLogsHashKernel1
dstPtr += 0x14;
bytes32 hash = vars.encrypedLogsHashKernel1;
Expand Down Expand Up @@ -445,12 +450,12 @@ library Decoder {
mstore(dstPtr, hash)
}

offsets.commitmentOffset += 2 * Constants.COMMITMENTS_PER_TX * 0x20;
offsets.nullifierOffset += 2 * Constants.NULLIFIERS_PER_TX * 0x20;
offsets.publicDataOffset += 2 * Constants.PUBLIC_DATA_WRITES_PER_TX * 0x40;
offsets.l2ToL1MsgsOffset += 2 * Constants.L2_TO_L1_MSGS_PER_TX * 0x20;
offsets.contractOffset += 2 * 0x20;
offsets.contractDataOffset += 2 * 0x34;
offsets.commitmentOffset += Constants.COMMITMENTS_NUM_BYTES_PER_ROLLUP;
offsets.nullifierOffset += Constants.NULLIFIERS_NUM_BYTES_PER_ROLLUP;
offsets.publicDataOffset += Constants.PUBLIC_DATA_WRITES_NUM_BYTES_PER_ROLLUP;
offsets.l2ToL1MsgsOffset += Constants.L2_TO_L1_MSGS_NUM_BYTES_PER_ROLLUP;
offsets.contractOffset += Constants.CONTRACTS_NUM_BYTES_PER_ROLLUP;
offsets.contractDataOffset += Constants.CONTRACT_DATA_NUM_BYTES_PER_ROLLUP_UNPADDED;

vars.baseLeaves[i] = sha256(vars.baseLeaf);
}
Expand Down

0 comments on commit 18b522f

Please sign in to comment.