Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: outgoing messages to any address #4512

Merged
merged 50 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
80e2100
feat: outgoing messages to any address
benesjan Feb 8, 2024
c01f90a
WIP
benesjan Feb 8, 2024
5ec38c0
WIP
benesjan Feb 9, 2024
a60bc45
WIP
benesjan Feb 9, 2024
00ca423
WIP
benesjan Feb 9, 2024
ed7418a
WIP
benesjan Feb 9, 2024
b6857dd
WIP
benesjan Feb 9, 2024
d8ce03d
test fix
benesjan Feb 9, 2024
c459552
WIP
benesjan Feb 9, 2024
8e6cbc1
fix 5
benesjan Feb 9, 2024
dc59f91
fixes
benesjan Feb 12, 2024
b2150ec
fixes 2
benesjan Feb 12, 2024
734e98f
updated slither output
benesjan Feb 12, 2024
837cac0
fix
benesjan Feb 12, 2024
6179bf8
updated snaps
benesjan Feb 12, 2024
474272c
nuked duplicate jest config
benesjan Feb 12, 2024
0eaca06
fmt fix
benesjan Feb 12, 2024
ddb0edc
streamline cross-chain harness syntax
benesjan Feb 12, 2024
790bbb8
fmt
benesjan Feb 12, 2024
8141672
WIP
benesjan Feb 12, 2024
3ac3372
Revert "fmt"
benesjan Feb 12, 2024
d547932
WIP
benesjan Feb 13, 2024
06a08c4
WIP
benesjan Feb 13, 2024
dcb1765
WIP
benesjan Feb 13, 2024
dda9aeb
passing test
benesjan Feb 14, 2024
34ddd0b
WIP
benesjan Feb 14, 2024
14a5fd4
testing from private
benesjan Feb 14, 2024
6dfacce
fmt
benesjan Feb 14, 2024
47cbee2
Merge branch 'master' into 02-08-feat_outgoing_messages_to_any_address
benesjan Feb 14, 2024
ed83bc5
WIP
benesjan Feb 14, 2024
9bd2b13
command fix
benesjan Feb 14, 2024
4e1069a
fix command 2
benesjan Feb 14, 2024
d28842c
updated test data
benesjan Feb 14, 2024
97946b3
diff cleanup
benesjan Feb 14, 2024
3ae852c
Merge branch 'master' into 02-08-feat_outgoing_messages_to_any_address
benesjan Feb 14, 2024
e9ccf70
updated slither output
benesjan Feb 14, 2024
1884d11
streamling e2e test
benesjan Feb 14, 2024
2328e68
cleanup
benesjan Feb 14, 2024
b71deb0
Merge branch 'master' into 02-08-feat_outgoing_messages_to_any_address
benesjan Feb 14, 2024
db2122e
fixes after merge
benesjan Feb 14, 2024
f2f4f11
comment
benesjan Feb 14, 2024
ec23cb8
updated comment
benesjan Feb 14, 2024
32344d0
Merge branch 'master' into 02-08-feat_outgoing_messages_to_any_address
benesjan Feb 14, 2024
24ee4df
Merge branch 'master' into 02-08-feat_outgoing_messages_to_any_address
benesjan Feb 15, 2024
22c54ce
making function actually private
benesjan Feb 15, 2024
e2aa37e
clarified test description
benesjan Feb 15, 2024
461f6d4
no message_recipient func
benesjan Feb 15, 2024
6d5c87b
clarifying comments
benesjan Feb 15, 2024
d2ca624
Merge branch 'master' into 02-08-feat_outgoing_messages_to_any_address
benesjan Feb 15, 2024
f54ef2d
cleanup
benesjan Feb 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions l1-contracts/slither_output.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Summary
- [dead-code](#dead-code) (13 results) (Informational)
- [solc-version](#solc-version) (1 results) (Informational)
- [low-level-calls](#low-level-calls) (1 results) (Informational)
- [similar-names](#similar-names) (1 results) (Informational)
- [similar-names](#similar-names) (2 results) (Informational)
- [unused-state](#unused-state) (2 results) (Informational)
- [constable-states](#constable-states) (1 results) (Optimization)
- [pess-multiple-storage-read](#pess-multiple-storage-read) (2 results) (Optimization)
Expand Down Expand Up @@ -193,12 +193,12 @@ src/core/Rollup.sol#L27-L103


- [ ] ID-19
The following public functions could be turned into external in [Outbox](src/core/messagebridge/Outbox.sol#L21-L149) contract:
The following public functions could be turned into external in [Outbox](src/core/messagebridge/Outbox.sol#L21-L148) contract:
[Outbox.constructor(address)](src/core/messagebridge/Outbox.sol#L29-L31)
[Outbox.get(bytes32)](src/core/messagebridge/Outbox.sol#L78-L85)
[Outbox.contains(bytes32)](src/core/messagebridge/Outbox.sol#L92-L94)
[Outbox.get(bytes32)](src/core/messagebridge/Outbox.sol#L77-L84)
[Outbox.contains(bytes32)](src/core/messagebridge/Outbox.sol#L91-L93)

src/core/messagebridge/Outbox.sol#L21-L149
src/core/messagebridge/Outbox.sol#L21-L148


- [ ] ID-20
Expand Down Expand Up @@ -271,9 +271,9 @@ src/core/libraries/decoders/Decoder.sol#L401-L407


- [ ] ID-29
[Outbox._errNothingToConsume(bytes32)](src/core/messagebridge/Outbox.sol#L115-L117) is never used and should be removed
[Outbox._errNothingToConsume(bytes32)](src/core/messagebridge/Outbox.sol#L114-L116) is never used and should be removed

src/core/messagebridge/Outbox.sol#L115-L117
src/core/messagebridge/Outbox.sol#L114-L116


- [ ] ID-30
Expand Down Expand Up @@ -325,9 +325,9 @@ src/core/libraries/decoders/Decoder.sol#L132-L134


- [ ] ID-38
[Outbox._errIncompatibleEntryArguments(bytes32,uint64,uint64,uint32,uint32,uint32,uint32)](src/core/messagebridge/Outbox.sol#L130-L148) is never used and should be removed
[Outbox._errIncompatibleEntryArguments(bytes32,uint64,uint64,uint32,uint32,uint32,uint32)](src/core/messagebridge/Outbox.sol#L129-L147) is never used and should be removed

src/core/messagebridge/Outbox.sol#L130-L148
src/core/messagebridge/Outbox.sol#L129-L147


## solc-version
Expand All @@ -350,6 +350,12 @@ src/core/messagebridge/Inbox.sol#L148-L153
Impact: Informational
Confidence: Medium
- [ ] ID-41
Variable [Constants.L1_TO_L2_MESSAGE_LENGTH](src/core/libraries/ConstantsGen.sol#L80) is too similar to [Constants.L2_TO_L1_MESSAGE_LENGTH](src/core/libraries/ConstantsGen.sol#L81)

src/core/libraries/ConstantsGen.sol#L80


- [ ] ID-42
Variable [Rollup.AVAILABILITY_ORACLE](src/core/Rollup.sol#L30) is too similar to [Rollup.constructor(IRegistry,IAvailabilityOracle)._availabilityOracle](src/core/Rollup.sol#L39)

src/core/Rollup.sol#L30
Expand All @@ -358,13 +364,13 @@ src/core/Rollup.sol#L30
## unused-state
Impact: Informational
Confidence: High
- [ ] ID-42
- [ ] ID-43
[Decoder.END_TREES_BLOCK_HEADER_OFFSET](src/core/libraries/decoders/Decoder.sol#L103-L104) is never used in [Decoder](src/core/libraries/decoders/Decoder.sol#L72-L418)

src/core/libraries/decoders/Decoder.sol#L103-L104


- [ ] ID-43
- [ ] ID-44
[Decoder.BLOCK_HEADER_OFFSET](src/core/libraries/decoders/Decoder.sol#L107-L108) is never used in [Decoder](src/core/libraries/decoders/Decoder.sol#L72-L418)

src/core/libraries/decoders/Decoder.sol#L107-L108
Expand All @@ -373,7 +379,7 @@ src/core/libraries/decoders/Decoder.sol#L107-L108
## constable-states
Impact: Optimization
Confidence: High
- [ ] ID-44
- [ ] ID-45
[Rollup.lastWarpedBlockTs](src/core/Rollup.sol#L37) should be constant

src/core/Rollup.sol#L37
Expand All @@ -382,13 +388,13 @@ src/core/Rollup.sol#L37
## pess-multiple-storage-read
Impact: Optimization
Confidence: High
- [ ] ID-45
- [ ] ID-46
In a function [FrontierMerkle.root()](src/core/messagebridge/frontier_tree/Frontier.sol#L39-L72) variable [FrontierMerkle.DEPTH](src/core/messagebridge/frontier_tree/Frontier.sol#L8) is read multiple times

src/core/messagebridge/frontier_tree/Frontier.sol#L39-L72


- [ ] ID-46
- [ ] ID-47
In a function [FrontierMerkle.root()](src/core/messagebridge/frontier_tree/Frontier.sol#L39-L72) variable [FrontierMerkle.frontier](src/core/messagebridge/frontier_tree/Frontier.sol#L13) is read multiple times

src/core/messagebridge/frontier_tree/Frontier.sol#L39-L72
Expand Down
7 changes: 4 additions & 3 deletions l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ library Constants {
uint256 internal constant DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE =
0x85864497636cf755ae7bde03f267ce01a520981c21c3682aaf82a631;
uint256 internal constant L1_TO_L2_MESSAGE_LENGTH = 8;
uint256 internal constant L2_TO_L1_MESSAGE_LENGTH = 2;
uint256 internal constant L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 25;
uint256 internal constant MAX_NOTE_FIELDS_LENGTH = 20;
uint256 internal constant GET_NOTE_ORACLE_RETURN_LENGTH = 23;
Expand All @@ -90,11 +91,11 @@ library Constants {
uint256 internal constant HEADER_LENGTH = 20;
uint256 internal constant FUNCTION_DATA_LENGTH = 4;
uint256 internal constant CONTRACT_DEPLOYMENT_DATA_LENGTH = 6;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 207;
uint256 internal constant PRIVATE_CALL_STACK_ITEM_LENGTH = 212;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 209;
uint256 internal constant PRIVATE_CALL_STACK_ITEM_LENGTH = 214;
uint256 internal constant CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH = 2;
uint256 internal constant CONTRACT_STORAGE_READ_LENGTH = 2;
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 187;
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 189;
uint256 internal constant GET_NOTES_ORACLE_RETURN_LENGTH = 674;
uint256 internal constant COMMITMENTS_NUM_BYTES_PER_BASE_ROLLUP = 2048;
uint256 internal constant NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP = 2048;
Expand Down
1 change: 0 additions & 1 deletion l1-contracts/src/core/messagebridge/Outbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ contract Outbox is IOutbox {

/**
* @notice Consumes an entry from the Outbox
* @dev Only meaningfully callable by portals, otherwise should never hit an entry
* @dev Emits the `MessageConsumed` event when consuming messages
* @param _message - The L2 to L1 message
* @return entryKey - The key of the entry removed
Expand Down
20 changes: 14 additions & 6 deletions noir-projects/aztec-nr/aztec/src/context/private_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ use dep::protocol_types::{
RETURN_VALUES_LENGTH
},
contrakt::{storage_read::StorageRead, storage_update_request::StorageUpdateRequest},
grumpkin_private_key::GrumpkinPrivateKey, hash::hash_args, header::Header, utils::reader::Reader
grumpkin_private_key::GrumpkinPrivateKey, hash::hash_args, header::Header,
messaging::l2_to_l1_message::L2ToL1Message, utils::reader::Reader
};
use dep::std::option::Option;

Expand All @@ -52,7 +53,7 @@ struct PrivateContext {

private_call_stack_hashes : BoundedVec<Field, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL>,
public_call_stack_hashes : BoundedVec<Field, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL>,
new_l2_to_l1_msgs : BoundedVec<Field, MAX_NEW_L2_TO_L1_MSGS_PER_CALL>,
new_l2_to_l1_msgs : BoundedVec<L2ToL1Message, MAX_NEW_L2_TO_L1_MSGS_PER_CALL>,
// docs:end:private-context

// Header of a block whose state is used during private execution (not the block the transaction is included in).
Expand Down Expand Up @@ -80,7 +81,7 @@ impl PrivateContext {
historical_header: inputs.historical_header,
private_call_stack_hashes: BoundedVec::new(0),
public_call_stack_hashes: BoundedVec::new(0),
new_l2_to_l1_msgs: BoundedVec::new(0),
new_l2_to_l1_msgs: BoundedVec::new(L2ToL1Message::empty()),
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)
// encrypted_logs_preimages: Vec::new(),
// unencrypted_logs_preimages: Vec::new(),
Expand Down Expand Up @@ -203,8 +204,15 @@ impl PrivateContext {

// docs:start:context_message_portal
pub fn message_portal(&mut self, content: Field) {
benesjan marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message_portal as a name seems weird. As is, it is a noun, but maybe we want it to be more conveying of an action ?
Like, send_message_to_portal ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk, I am not a native speaker but saying for example "message Esau" sounds totally fine to me and send_message_to_portal is just too long.

Copy link
Contributor

@sklppy88 sklppy88 Feb 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the difference is that "Message Esau", or "Message Jan" cannot be misconstrued as a singular object, as the separation between action and verb are more pronounced and these are not often used together, but "message portal" can be misunderstood. Especially when it was message_recipient (I know it is has been nuked now but just to make my point clear) i.e. if I call x.message_recipient(), I'll have an initial wonder if I'm grabbing a prop on the object named message_recipient, even if it doesn't make too much sense in the context.

But definitely if we're trying to optimize for terseness then this is the way to go for sure. And this is super nit anyways, I mainly wanted to just give more background on my precious comment 🙃 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok, got it. You have a point. Maybe renaming it as send_message would be the best. It's short and it really can't mean anything else.

// docs:end:context_message_portal
self.new_l2_to_l1_msgs.push(content);
// docs:end:context_message_portal {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The { don't need to be here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in f54ef2d

let recipient = self.this_portal_address();
self.message_recipient(recipient, content);
}

// Message can be send to arbitrary recipient on L1 and not only to the registered portal address
pub fn message_recipient(&mut self, recipient: EthAddress, content: Field) {
benesjan marked this conversation as resolved.
Show resolved Hide resolved
let message = L2ToL1Message { recipient, content };
self.new_l2_to_l1_msgs.push(message);
}

// PrivateContextInputs must be temporarily passed in to prevent too many unknowns
Expand Down Expand Up @@ -388,7 +396,7 @@ impl PrivateContext {
public_call_stack_hashes: [0; MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL],
new_commitments: [SideEffect::empty(); MAX_NEW_COMMITMENTS_PER_CALL],
new_nullifiers: [SideEffectLinkedToNoteHash::empty(); MAX_NEW_NULLIFIERS_PER_CALL],
new_l2_to_l1_msgs: [0; MAX_NEW_L2_TO_L1_MSGS_PER_CALL],
new_l2_to_l1_msgs: [L2ToL1Message::empty(); MAX_NEW_L2_TO_L1_MSGS_PER_CALL],
unencrypted_logs_hash: [0; NUM_FIELDS_PER_SHA256],
unencrypted_log_preimages_length: 0,
historical_header: Header::empty(),
Expand Down
15 changes: 11 additions & 4 deletions noir-projects/aztec-nr/aztec/src/context/public_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use dep::protocol_types::{
RETURN_VALUES_LENGTH
},
contrakt::{storage_read::StorageRead, storage_update_request::StorageUpdateRequest},
hash::hash_args, header::Header, utils::reader::Reader
hash::hash_args, header::Header, messaging::l2_to_l1_message::L2ToL1Message, utils::reader::Reader
};

struct PublicContext {
Expand All @@ -35,7 +35,7 @@ struct PublicContext {
new_commitments: BoundedVec<SideEffect, MAX_NEW_COMMITMENTS_PER_CALL>,
new_nullifiers: BoundedVec<SideEffectLinkedToNoteHash, MAX_NEW_NULLIFIERS_PER_CALL>,

new_l2_to_l1_msgs: BoundedVec<Field, MAX_NEW_L2_TO_L1_MSGS_PER_CALL>,
new_l2_to_l1_msgs: BoundedVec<L2ToL1Message, MAX_NEW_L2_TO_L1_MSGS_PER_CALL>,

unencrypted_logs_hash: BoundedVec<Field, NUM_FIELDS_PER_SHA256>,
unencrypted_logs_preimages_length: Field,
Expand All @@ -60,7 +60,7 @@ impl PublicContext {
public_call_stack_hashes: BoundedVec::new(0),
new_commitments: BoundedVec::new(SideEffect::empty()),
new_nullifiers: BoundedVec::new(SideEffectLinkedToNoteHash::empty()),
new_l2_to_l1_msgs: BoundedVec::new(0),
new_l2_to_l1_msgs: BoundedVec::new(L2ToL1Message::empty()),
unencrypted_logs_hash: BoundedVec::new(0),
unencrypted_logs_preimages_length: 0,
historical_header: inputs.historical_header,
Expand Down Expand Up @@ -151,7 +151,14 @@ impl PublicContext {
}

pub fn message_portal(&mut self, content: Field) {
benesjan marked this conversation as resolved.
Show resolved Hide resolved
self.new_l2_to_l1_msgs.push(content);
let recipient = self.this_portal_address();
self.message_recipient(recipient, content);
}

// Message can be send to arbitrary recipient on L1 and not only to the registered portal address
pub fn message_recipient(&mut self, recipient: EthAddress, content: Field) {
let message = L2ToL1Message { recipient, content };
self.new_l2_to_l1_msgs.push(message);
}

// PrivateContextInputs must be temporarily passed in to prevent too many unknowns
Expand Down
12 changes: 12 additions & 0 deletions noir-projects/noir-contracts/contracts/test_contract/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ contract Test {
context.message_portal(note.get_commitment());
}

#[aztec(public)]
fn create_l2_to_l1_message_arbitrary_recipient_public(content: Field, recipient: EthAddress) {
// Public oracle call to emit new commitment.
context.message_recipient(recipient, content);
}

#[aztec(public)]
benesjan marked this conversation as resolved.
Show resolved Hide resolved
fn create_l2_to_l1_message_arbitrary_recipient_private(content: Field, recipient: EthAddress) {
// Public oracle call to emit new commitment.
context.message_recipient(recipient, content);
}

// Purely exists for testing
#[aztec(public)]
fn create_nullifier_public(amount: Field, secret_hash: Field) {
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/noir-protocol-circuits/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build": "yarn clean && yarn noir:build",
"clean": "rm -rf ./dest src/target",
"noir:build": "cd src && ../../../noir/target/release/nargo compile --silence-warnings",
"test": "cd src && ../../../../noir/target/release/nargo test"
"test": "cd src && ../../../noir/target/release/nargo test"
benesjan marked this conversation as resolved.
Show resolved Hide resolved
},
"files": [
"dest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,16 @@ pub fn update_end_values(
public_inputs.end.public_call_stack.extend_from_bounded_vec(public_call_stack);

// new l2 to l1 messages
let portal_contract_address = private_call.portal_contract_address;
let new_l2_to_l1_msgs = private_call_public_inputs.new_l2_to_l1_msgs;
let mut new_l2_to_l1_msgs_to_insert : BoundedVec<Field, MAX_NEW_L2_TO_L1_MSGS_PER_CALL> = BoundedVec::new(0);
for i in 0..MAX_NEW_L2_TO_L1_MSGS_PER_CALL {
let msg_is_zero = new_l2_to_l1_msgs[i] == 0;
if msg_is_zero == false {
let msg = new_l2_to_l1_msgs[i];
if !is_empty(msg) {
let new_l2_to_l1_msgs = compute_l2_to_l1_hash(
storage_contract_address,
private_call_public_inputs.version,
portal_contract_address,
private_call_public_inputs.chain_id,
new_l2_to_l1_msgs[i]
msg
);
new_l2_to_l1_msgs_to_insert.push(new_l2_to_l1_msgs)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,18 @@ impl PrivateKernelInitCircuitPrivateInputs {

mod tests {
use crate::private_kernel_init::PrivateKernelInitCircuitPrivateInputs;
use dep::types::constants::{MAX_READ_REQUESTS_PER_CALL};
use dep::types::{
abis::{
kernel_circuit_public_inputs::PrivateKernelInnerCircuitPublicInputs,
nullifier_key_validation_request::NullifierKeyValidationRequest,
private_kernel::private_call_data::PrivateCallData,
side_effect::{SideEffect, SideEffectLinkedToNoteHash}
},
grumpkin_point::GrumpkinPoint, grumpkin_private_key::GrumpkinPrivateKey,
address::{AztecAddress, compute_initialization_hash},
address::{AztecAddress, EthAddress, compute_initialization_hash},
constants::MAX_READ_REQUESTS_PER_CALL, grumpkin_point::GrumpkinPoint,
grumpkin_private_key::GrumpkinPrivateKey,
hash::{compute_constructor_hash, compute_logs_hash, stdlib_recursion_verification_key_compress_native_vk},
messaging::l2_to_l1_message::L2ToL1Message,
tests::private_call_data_builder::PrivateCallDataBuilder, transaction::request::TxRequest,
utils::arrays::array_length
};
Expand Down Expand Up @@ -322,7 +323,12 @@ mod tests {
fn input_validation_malformed_arrays_new_l2_to_l1_msgs() {
let mut builder = PrivateKernelInitInputsBuilder::new_constructor();

builder.private_call.public_inputs.new_l2_to_l1_msgs.extend_from_array([0, 9123]);
builder.private_call.public_inputs.new_l2_to_l1_msgs.extend_from_array(
[
L2ToL1Message::empty(),
L2ToL1Message { recipient: EthAddress::from_field(6), content: 9123 }
]
);

builder.failed();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ mod tests {
kernel_circuit_public_inputs::PrivateKernelInnerCircuitPublicInputs,
side_effect::{SideEffect, SideEffectLinkedToNoteHash}
},
tests::{kernel_data_builder::PreviousKernelDataBuilder, private_call_data_builder::PrivateCallDataBuilder},
address::AztecAddress, hash::compute_logs_hash, utils::{arrays::array_length}
address::{AztecAddress, EthAddress}, hash::compute_logs_hash,
messaging::l2_to_l1_message::L2ToL1Message, utils::{arrays::array_length},
tests::{kernel_data_builder::PreviousKernelDataBuilder, private_call_data_builder::PrivateCallDataBuilder}
};

struct PrivateKernelInnerInputsBuilder {
Expand Down Expand Up @@ -500,7 +501,12 @@ mod tests {
fn input_validation_malformed_arrays_new_l2_to_l1_msgs() {
let mut builder = PrivateKernelInnerInputsBuilder::new();

builder.private_call.public_inputs.new_l2_to_l1_msgs.extend_from_array([0, 888]);
builder.private_call.public_inputs.new_l2_to_l1_msgs.extend_from_array(
[
L2ToL1Message::empty(),
L2ToL1Message { recipient: EthAddress::from_field(6), content: 888 }
]
);

builder.failed();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use dep::types::{
MAX_PUBLIC_DATA_READS_PER_CALL, NUM_FIELDS_PER_SHA256
},
hash::{silo_commitment, silo_nullifier, compute_l2_to_l1_hash, accumulate_sha256},
utils::{arrays::{array_length, array_to_bounded_vec}}, traits::is_empty_array
utils::{arrays::{array_length, array_to_bounded_vec}}, traits::{is_empty, is_empty_array}
};
use crate::hash::{compute_public_data_tree_index, compute_public_data_tree_value};

Expand Down Expand Up @@ -240,14 +240,13 @@ fn propagate_new_l2_to_l1_messages(public_call: PublicCallData, public_inputs: &
let new_l2_to_l1_msgs = public_call_public_inputs.new_l2_to_l1_msgs;
let mut new_l2_to_l1_msgs_to_insert : BoundedVec<Field, MAX_NEW_L2_TO_L1_MSGS_PER_CALL> = BoundedVec::new(0);
for i in 0..MAX_NEW_L2_TO_L1_MSGS_PER_CALL {
let msg_is_zero = new_l2_to_l1_msgs[i] == 0;
if msg_is_zero == false {
let msg = new_l2_to_l1_msgs[i];
if !is_empty(msg) {
let new_l2_to_l1_msgs = compute_l2_to_l1_hash(
storage_contract_address,
public_inputs.constants.tx_context.version,
portal_contract_address,
public_inputs.constants.tx_context.chain_id,
new_l2_to_l1_msgs[i]
msg
);
new_l2_to_l1_msgs_to_insert.push(new_l2_to_l1_msgs)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ mod tests {
side_effect::{SideEffect, SideEffectLinkedToNoteHash}
},
hash::{compute_l2_to_l1_hash, compute_logs_hash, silo_commitment, silo_nullifier},
messaging::l2_to_l1_message::L2ToL1Message,
tests::{kernel_data_builder::PreviousKernelDataBuilder, public_call_data_builder::PublicCallDataBuilder},
utils::{arrays::array_eq}
};
Expand Down Expand Up @@ -250,12 +251,12 @@ mod tests {

builder.previous_kernel.end.new_l2_to_l1_msgs.extend_from_array(previous);
// Setup 1 new l2 to l1 message on the current public inputs.
let current = [67890];
let current = [L2ToL1Message { recipient: portal_contract_address, content: 67890 }];
builder.public_call.public_inputs.new_l2_to_l1_msgs.extend_from_array(current);
let tx_context = builder.previous_kernel.tx_context;
let version = tx_context.version;
let chain_id = tx_context.chain_id;
let siloed = current.map(|c| compute_l2_to_l1_hash(contract_address, version, portal_contract_address, chain_id, c));
let siloed = current.map(|c| compute_l2_to_l1_hash(contract_address, version, chain_id, c));
let new_l2_to_l1_msgs = [previous[0], siloed[0]];

let public_inputs = builder.execute();
Expand Down
Loading
Loading