Skip to content

Commit

Permalink
rename reverted to revertCode
Browse files Browse the repository at this point in the history
  • Loading branch information
just-mitch committed Mar 19, 2024
1 parent 3e52e95 commit c67412f
Show file tree
Hide file tree
Showing 38 changed files with 243 additions and 145 deletions.
22 changes: 11 additions & 11 deletions l1-contracts/slither_output.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,41 +50,34 @@ src/core/Rollup.sol#L57-L96
Impact: Medium
Confidence: High
- [ ] ID-4
Dubious typecast in [TxsDecoder.decode(bytes)](src/core/libraries/decoders/TxsDecoder.sol#L78-L192):
bytes => bytes32 casting occurs in [vars.baseLeaf = bytes.concat(bytes32(slice(_body,offsets.reverted,0x20)),bytes.concat(sliceAndPad(_body,offsets.noteHash,counts.noteHash * 0x20,Constants.NOTE_HASHES_NUM_BYTES_PER_BASE_ROLLUP),sliceAndPad(_body,offsets.nullifier,counts.nullifier * 0x20,Constants.NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP),sliceAndPad(_body,offsets.l2ToL1Msgs,counts.l2ToL1Msgs * 0x20,Constants.L2_TO_L1_MSGS_NUM_BYTES_PER_BASE_ROLLUP),sliceAndPad(_body,offsets.publicData,counts.publicData * 0x40,Constants.PUBLIC_DATA_WRITES_NUM_BYTES_PER_BASE_ROLLUP)),bytes.concat(vars.encryptedLogsHash,vars.unencryptedLogsHash))](src/core/libraries/decoders/TxsDecoder.sol#L156-L185)

src/core/libraries/decoders/TxsDecoder.sol#L78-L192


- [ ] ID-5
Dubious typecast in [MessagesDecoder.read4(bytes,uint256)](src/core/libraries/decoders/MessagesDecoder.sol#L164-L166):
bytes => bytes4 casting occurs in [uint256(uint32(bytes4(_data)))](src/core/libraries/decoders/MessagesDecoder.sol#L165)

src/core/libraries/decoders/MessagesDecoder.sol#L164-L166


- [ ] ID-6
- [ ] ID-5
Dubious typecast in [Outbox.sendL1Messages(bytes32[])](src/core/messagebridge/Outbox.sol#L38-L46):
uint256 => uint32 casting occurs in [version = uint32(REGISTRY.getVersionFor(msg.sender))](src/core/messagebridge/Outbox.sol#L40)

src/core/messagebridge/Outbox.sol#L38-L46


- [ ] ID-7
- [ ] ID-6
Dubious typecast in [TxsDecoder.read1(bytes,uint256)](src/core/libraries/decoders/TxsDecoder.sol#L322-L324):
bytes => bytes1 casting occurs in [uint256(uint8(bytes1(slice(_data,_offset,1))))](src/core/libraries/decoders/TxsDecoder.sol#L323)

src/core/libraries/decoders/TxsDecoder.sol#L322-L324


- [ ] ID-8
- [ ] ID-7
Dubious typecast in [TxsDecoder.read4(bytes,uint256)](src/core/libraries/decoders/TxsDecoder.sol#L332-L334):
bytes => bytes4 casting occurs in [uint256(uint32(bytes4(slice(_data,_offset,4))))](src/core/libraries/decoders/TxsDecoder.sol#L333)

src/core/libraries/decoders/TxsDecoder.sol#L332-L334


- [ ] ID-9
- [ ] ID-8
Dubious typecast in [HeaderLib.decode(bytes)](src/core/libraries/HeaderLib.sol#L143-L184):
bytes => bytes32 casting occurs in [header.lastArchive = AppendOnlyTreeSnapshot(bytes32(_header),uint32(bytes4(_header)))](src/core/libraries/HeaderLib.sol#L151-L153)
bytes => bytes4 casting occurs in [header.lastArchive = AppendOnlyTreeSnapshot(bytes32(_header),uint32(bytes4(_header)))](src/core/libraries/HeaderLib.sol#L151-L153)
Expand All @@ -110,6 +103,13 @@ Dubious typecast in [HeaderLib.decode(bytes)](src/core/libraries/HeaderLib.sol#L
src/core/libraries/HeaderLib.sol#L143-L184


- [ ] ID-9
Dubious typecast in [TxsDecoder.decode(bytes)](src/core/libraries/decoders/TxsDecoder.sol#L78-L192):
bytes => bytes32 casting occurs in [vars.baseLeaf = bytes.concat(bytes32(slice(_body,offsets.revertCode,0x20)),bytes.concat(sliceAndPad(_body,offsets.noteHash,counts.noteHash * 0x20,Constants.NOTE_HASHES_NUM_BYTES_PER_BASE_ROLLUP),sliceAndPad(_body,offsets.nullifier,counts.nullifier * 0x20,Constants.NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP),sliceAndPad(_body,offsets.l2ToL1Msgs,counts.l2ToL1Msgs * 0x20,Constants.L2_TO_L1_MSGS_NUM_BYTES_PER_BASE_ROLLUP),sliceAndPad(_body,offsets.publicData,counts.publicData * 0x40,Constants.PUBLIC_DATA_WRITES_NUM_BYTES_PER_BASE_ROLLUP)),bytes.concat(vars.encryptedLogsHash,vars.unencryptedLogsHash))](src/core/libraries/decoders/TxsDecoder.sol#L156-L185)

src/core/libraries/decoders/TxsDecoder.sol#L78-L192


- [ ] ID-10
Dubious typecast in [MessagesDecoder.read1(bytes,uint256)](src/core/libraries/decoders/MessagesDecoder.sol#L154-L156):
bytes => bytes1 casting occurs in [uint256(uint8(bytes1(_data)))](src/core/libraries/decoders/MessagesDecoder.sol#L155)
Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/src/core/libraries/decoders/MessagesDecoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {Hash} from "../Hash.sol";
* | 0x4 | a * 0x20 | newL1ToL2Msgs
* | 0x4 + a * 0x20 = tx0Start | 0x4 | len(numTxs) (denoted t)
* | | | TxEffect 0 {
* | tx0Start | 0x20 | reverted
* | tx0Start | 0x20 | revertCode
* | tx0Start + 0x20 | 0x1 | len(newNoteHashes) (denoted b)
* | tx0Start + 0x20 + 0x1 | b * 0x20 | newNoteHashes
* | tx0Start + 0x20 + 0x1 + b * 0x20 | 0x1 | len(newNullifiers) (denoted c)
Expand Down Expand Up @@ -90,7 +90,7 @@ library MessagesDecoder {

// Now we iterate over the tx effects
for (uint256 i = 0; i < numTxs; i++) {
// reverted
// revertCode
offset += 0x20;

// Note hashes
Expand Down
12 changes: 6 additions & 6 deletions l1-contracts/src/core/libraries/decoders/TxsDecoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {Hash} from "../Hash.sol";
* | 0x4 | a * 0x20 | newL1ToL2Msgs
* | 0x4 + a * 0x20 = tx0Start | 0x4 | len(numTxs) (denoted t)
* | | | TxEffect 0 {
* | tx0Start | 0x20 | reverted
* | tx0Start | 0x20 | revertCode
* | tx0Start + 0x20 | 0x1 | len(newNoteHashes) (denoted b)
* | tx0Start + 0x20 + 0x1 | b * 0x20 | newNoteHashes
* | tx0Start + 0x20 + 0x1 + b * 0x20 | 0x1 | len(newNullifiers) (denoted c)
Expand All @@ -48,7 +48,7 @@ import {Hash} from "../Hash.sol";
*/
library TxsDecoder {
struct ArrayOffsets {
uint256 reverted;
uint256 revertCode;
uint256 noteHash;
uint256 nullifier;
uint256 l2ToL1Msgs;
Expand Down Expand Up @@ -98,7 +98,7 @@ library TxsDecoder {
/*
* Compute the leaf to insert.
* Leaf_i = (
* reverted,
* revertCode,
* newNoteHashesKernel,
* newNullifiersKernel,
* newPublicDataWritesKernel,
Expand All @@ -113,8 +113,8 @@ library TxsDecoder {
* Zero values.
*/

// Reverted flag
offsets.reverted = offset;
// Revert Code
offsets.revertCode = offset;
offset += 0x20;

// Note hashes
Expand Down Expand Up @@ -154,7 +154,7 @@ library TxsDecoder {

// Insertions are split into multiple `bytes.concat` to work around stack too deep.
vars.baseLeaf = bytes.concat(
bytes32(slice(_body, offsets.reverted, 0x20)),
bytes32(slice(_body, offsets.revertCode, 0x20)),
bytes.concat(
sliceAndPad(
_body,
Expand Down
10 changes: 5 additions & 5 deletions l1-contracts/test/fixtures/empty_block_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
]
},
"block": {
"archive": "0x14345eef7234d61a1403a56854ef0a953650e79ddc8d1ee771fc3e428f6c0e23",
"archive": "0x156e00a72ef2bf8d50fa744fed195025ae5a0b182afdc800494626b9b7238c82",
"body": "0x000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"txsEffectsHash": "0xf0712fd0e716f7d0c3ce0986086fcf5ade6d8205e8ffa2c84160ae2dca4fd0cc",
"decodedHeader": {
Expand All @@ -32,8 +32,8 @@
"chainId": 31337,
"timestamp": 0,
"version": 1,
"coinbase": "0x45da7d2a1360d29fe02868ea452f003ffe5fe473",
"feeRecipient": "0x1d11262e821f3b332c893a0ad83ccdf067e527b048991a613f50b3d442e33c14"
"coinbase": "0xdd78513c160d791bb947bc0737fc7718658d4441",
"feeRecipient": "0x253ce4ebffc257c0eacb455b83c6305f101cc7b563fb0639f5fa84200d9fc9cd"
},
"lastArchive": {
"nextAvailableLeafIndex": 1,
Expand All @@ -60,7 +60,7 @@
}
}
},
"header": "0x012a86560737adb075e12af8253fb09abf17aa841fb56d180bc89f0d2d473c7f000000010000000000000000000000000000000000000000000000000000000000000002f0712fd0e716f7d0c3ce0986086fcf5ade6d8205e8ffa2c84160ae2dca4fd0cc536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123cc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c1864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000001016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000001000bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000001800572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000000c00000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000045da7d2a1360d29fe02868ea452f003ffe5fe4731d11262e821f3b332c893a0ad83ccdf067e527b048991a613f50b3d442e33c14",
"publicInputsHash": "0x10e5e11ede174b4d60657ca758d1efca1f861518c703a011a20c54f9b791eacd"
"header": "0x012a86560737adb075e12af8253fb09abf17aa841fb56d180bc89f0d2d473c7f000000010000000000000000000000000000000000000000000000000000000000000002f0712fd0e716f7d0c3ce0986086fcf5ade6d8205e8ffa2c84160ae2dca4fd0cc536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123cc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c1864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000001016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000001000bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000001800572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000000c00000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000dd78513c160d791bb947bc0737fc7718658d4441253ce4ebffc257c0eacb455b83c6305f101cc7b563fb0639f5fa84200d9fc9cd",
"publicInputsHash": "0x272ebb2fa6aebcec2969fe27b8948c781032832b945621c277eec2dcbfcfa1ff"
}
}
14 changes: 7 additions & 7 deletions l1-contracts/test/fixtures/empty_block_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
]
},
"block": {
"archive": "0x2ab6d91473f2a41ffc92d876d308e6ebb960d97ced19ad649672ea84b2af13de",
"archive": "0x0cbdcb213f0c0381a73452266d0f7efce24516106c3629ae37d6a263a3adb46a",
"body": "0x000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"txsEffectsHash": "0xf0712fd0e716f7d0c3ce0986086fcf5ade6d8205e8ffa2c84160ae2dca4fd0cc",
"decodedHeader": {
Expand All @@ -30,14 +30,14 @@
"globalVariables": {
"blockNumber": 2,
"chainId": 31337,
"timestamp": 1710872994,
"timestamp": 1710873581,
"version": 1,
"coinbase": "0x45da7d2a1360d29fe02868ea452f003ffe5fe473",
"feeRecipient": "0x1d11262e821f3b332c893a0ad83ccdf067e527b048991a613f50b3d442e33c14"
"coinbase": "0xdd78513c160d791bb947bc0737fc7718658d4441",
"feeRecipient": "0x253ce4ebffc257c0eacb455b83c6305f101cc7b563fb0639f5fa84200d9fc9cd"
},
"lastArchive": {
"nextAvailableLeafIndex": 2,
"root": "0x14345eef7234d61a1403a56854ef0a953650e79ddc8d1ee771fc3e428f6c0e23"
"root": "0x156e00a72ef2bf8d50fa744fed195025ae5a0b182afdc800494626b9b7238c82"
},
"stateReference": {
"l1ToL2MessageTree": {
Expand All @@ -60,7 +60,7 @@
}
}
},
"header": "0x14345eef7234d61a1403a56854ef0a953650e79ddc8d1ee771fc3e428f6c0e23000000020000000000000000000000000000000000000000000000000000000000000002f0712fd0e716f7d0c3ce0986086fcf5ade6d8205e8ffa2c84160ae2dca4fd0cc536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123cc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c1864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000002016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000002000bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000002800572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000001400000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000065f9d9a245da7d2a1360d29fe02868ea452f003ffe5fe4731d11262e821f3b332c893a0ad83ccdf067e527b048991a613f50b3d442e33c14",
"publicInputsHash": "0x265e77b67873aecee684fa1f79eac2ea86fff57b96f9e407a2974e30774105a1"
"header": "0x156e00a72ef2bf8d50fa744fed195025ae5a0b182afdc800494626b9b7238c82000000020000000000000000000000000000000000000000000000000000000000000002f0712fd0e716f7d0c3ce0986086fcf5ade6d8205e8ffa2c84160ae2dca4fd0cc536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123cc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c1864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000002016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000002000bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000002800572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000001400000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000065f9dbeddd78513c160d791bb947bc0737fc7718658d4441253ce4ebffc257c0eacb455b83c6305f101cc7b563fb0639f5fa84200d9fc9cd",
"publicInputsHash": "0x0919a172aab1f0c00f608ebc32fdce81744c7f15701e30f19f7aff31e01bb1cf"
}
}
16 changes: 8 additions & 8 deletions l1-contracts/test/fixtures/mixed_block_0.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 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 @@ -465,7 +465,7 @@ impl PrivateContext {
unencrypted_log_preimages_length: 0,
historical_header: Header::empty(),
prover_address: AztecAddress::zero(),
reverted: 0
revert_code: 0
},
is_execution_request: true
};
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/context/public_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl PublicContext {
unencrypted_log_preimages_length,
historical_header: self.inputs.historical_header,
prover_address: self.prover_address,
reverted: 0
revert_code: 0
};
pub_circuit_pub_inputs
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ pub fn validate_inputs(public_call: PublicCallData) {
}

pub fn validate_public_call_non_revert(public_call: PublicCallData) {
assert(public_call.call_stack_item.public_inputs.reverted == 0, "Public call cannot be reverted");
assert(public_call.call_stack_item.public_inputs.revert_code == 0, "Public call cannot be reverted");
}

pub fn initialize_reverted_flag(
pub fn initialize_revert_code(
previous_kernel: PublicKernelData,
public_call: PublicCallData,
circuit_outputs: &mut PublicKernelCircuitPublicInputsBuilder
) {
if previous_kernel.public_inputs.end_non_revertible.reverted != 0 {
circuit_outputs.end_non_revertible.reverted = previous_kernel.public_inputs.end_non_revertible.reverted;
} else if public_call.call_stack_item.public_inputs.reverted != 0 {
circuit_outputs.end_non_revertible.reverted = public_call.call_stack_item.public_inputs.reverted;
if previous_kernel.public_inputs.end_non_revertible.revert_code != 0 {
circuit_outputs.end_non_revertible.revert_code = previous_kernel.public_inputs.end_non_revertible.revert_code;
} else if public_call.call_stack_item.public_inputs.revert_code != 0 {
circuit_outputs.end_non_revertible.revert_code = public_call.call_stack_item.public_inputs.revert_code;
}
}

Expand All @@ -59,7 +59,7 @@ pub fn initialize_emitted_end_values(
) {
circuit_outputs.constants = previous_kernel.public_inputs.constants;

if circuit_outputs.end_non_revertible.reverted == 0 {
if circuit_outputs.end_non_revertible.revert_code == 0 {
let start = previous_kernel.public_inputs.end;
circuit_outputs.end.new_note_hashes = array_to_bounded_vec(start.new_note_hashes);
circuit_outputs.end.new_nullifiers = array_to_bounded_vec(start.new_nullifiers);
Expand Down Expand Up @@ -89,7 +89,7 @@ pub fn initialize_end_values(
) {
initialize_emitted_end_values(previous_kernel, circuit_outputs);

if circuit_outputs.end_non_revertible.reverted == 0 {
if circuit_outputs.end_non_revertible.revert_code == 0 {
let start = previous_kernel.public_inputs.end;
// circuit_outputs.end.private_call_stack = array_to_bounded_vec(start.private_call_stack); // This is enforced in the private tail to always be empty.
circuit_outputs.end.public_call_stack = array_to_bounded_vec(start.public_call_stack);
Expand Down
Loading

0 comments on commit c67412f

Please sign in to comment.