Skip to content

Commit

Permalink
chore: rename reverted to revertCode (#5301)
Browse files Browse the repository at this point in the history
Please read [contributing guidelines](CONTRIBUTING.md) and remove this line.
  • Loading branch information
just-mitch authored Mar 20, 2024
1 parent 40ecc02 commit 950a96d
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": "0x1a64e04b5fd97f6cabe5329c623586a75bba4a3a4c739cf57feb32f7a5f3734d",
"archive": "0x22a4368b7d42b4ebf203743d85952b5ef975d9531fc08dbe27acada3f1f8626a",
"body": "0x000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"txsEffectsHash": "0xf0712fd0e716f7d0c3ce0986086fcf5ade6d8205e8ffa2c84160ae2dca4fd0cc",
"decodedHeader": {
Expand All @@ -32,8 +32,8 @@
"chainId": 31337,
"timestamp": 0,
"version": 1,
"coinbase": "0x1a75db87652c7dc5749657c0cc3907011488e620",
"feeRecipient": "0x1a9c20fa140d7ad7fb605779ad684fe73b0328af31dcdc560c73ffb9b5857ff6"
"coinbase": "0x778497dc2ad84181559aa6a20a861eae7094f904",
"feeRecipient": "0x0e8537c44a5a807ff75d1e1f00ebbdbf4c6334c4d7e1f38290f1f9b7d41ac3ba"
},
"lastArchive": {
"nextAvailableLeafIndex": 1,
Expand All @@ -60,7 +60,7 @@
}
}
},
"header": "0x012a86560737adb075e12af8253fb09abf17aa841fb56d180bc89f0d2d473c7f000000010000000000000000000000000000000000000000000000000000000000000002f0712fd0e716f7d0c3ce0986086fcf5ade6d8205e8ffa2c84160ae2dca4fd0cc536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123cc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c1864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000001016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000001000bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000001800572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000000c00000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001a75db87652c7dc5749657c0cc3907011488e6201a9c20fa140d7ad7fb605779ad684fe73b0328af31dcdc560c73ffb9b5857ff6",
"publicInputsHash": "0x0fe507f5da6435ff499d248b75e8496d92f82df1d07591eac8b314dd52b2a3d0"
"header": "0x012a86560737adb075e12af8253fb09abf17aa841fb56d180bc89f0d2d473c7f000000010000000000000000000000000000000000000000000000000000000000000002f0712fd0e716f7d0c3ce0986086fcf5ade6d8205e8ffa2c84160ae2dca4fd0cc536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123cc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c1864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000001016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000001000bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000001800572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000000c00000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000778497dc2ad84181559aa6a20a861eae7094f9040e8537c44a5a807ff75d1e1f00ebbdbf4c6334c4d7e1f38290f1f9b7d41ac3ba",
"publicInputsHash": "0x27c0b3d5a31631c3ac1afbe66ec9d320ab601fe69973dfb6d9ed95dd08ee4e06"
}
}
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": "0x2ac6036a87dcfff631664b92eb324b14a9858975e4b23db4636f8b0d05b6eb41",
"archive": "0x2b24009cd38ed013a0937cda25a9a6159b0c0eea5e44f1217bb9d8d2ce134dd5",
"body": "0x000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"txsEffectsHash": "0xf0712fd0e716f7d0c3ce0986086fcf5ade6d8205e8ffa2c84160ae2dca4fd0cc",
"decodedHeader": {
Expand All @@ -30,14 +30,14 @@
"globalVariables": {
"blockNumber": 2,
"chainId": 31337,
"timestamp": 1710934975,
"timestamp": 1710935662,
"version": 1,
"coinbase": "0x1a75db87652c7dc5749657c0cc3907011488e620",
"feeRecipient": "0x1a9c20fa140d7ad7fb605779ad684fe73b0328af31dcdc560c73ffb9b5857ff6"
"coinbase": "0x778497dc2ad84181559aa6a20a861eae7094f904",
"feeRecipient": "0x0e8537c44a5a807ff75d1e1f00ebbdbf4c6334c4d7e1f38290f1f9b7d41ac3ba"
},
"lastArchive": {
"nextAvailableLeafIndex": 2,
"root": "0x1a64e04b5fd97f6cabe5329c623586a75bba4a3a4c739cf57feb32f7a5f3734d"
"root": "0x22a4368b7d42b4ebf203743d85952b5ef975d9531fc08dbe27acada3f1f8626a"
},
"stateReference": {
"l1ToL2MessageTree": {
Expand All @@ -60,7 +60,7 @@
}
}
},
"header": "0x1a64e04b5fd97f6cabe5329c623586a75bba4a3a4c739cf57feb32f7a5f3734d000000020000000000000000000000000000000000000000000000000000000000000002f0712fd0e716f7d0c3ce0986086fcf5ade6d8205e8ffa2c84160ae2dca4fd0cc536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123cc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c1864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000002016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000002000bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000002800572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000001400000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000065facbbf1a75db87652c7dc5749657c0cc3907011488e6201a9c20fa140d7ad7fb605779ad684fe73b0328af31dcdc560c73ffb9b5857ff6",
"publicInputsHash": "0x1e4eb2d56b3952bb8345d5696e9d3455e093ee712378bcecc219334bbd8e389d"
"header": "0x22a4368b7d42b4ebf203743d85952b5ef975d9531fc08dbe27acada3f1f8626a000000020000000000000000000000000000000000000000000000000000000000000002f0712fd0e716f7d0c3ce0986086fcf5ade6d8205e8ffa2c84160ae2dca4fd0cc536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123cc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c1864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000002016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000002000bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278000002800572c8db882674dd026b8877fbba1b700a4407da3ae9ce5fa43215a28163362b000001400000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000065face6e778497dc2ad84181559aa6a20a861eae7094f9040e8537c44a5a807ff75d1e1f00ebbdbf4c6334c4d7e1f38290f1f9b7d41ac3ba",
"publicInputsHash": "0x099c9c03bde27fcaa897e641fbe80172085813407a63f46909a230d94f272072"
}
}
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 @@ -143,7 +143,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 950a96d

Please sign in to comment.