starknet-docs icon indicating copy to clipboard operation
starknet-docs copied to clipboard

docs: Updates to Messaging mechanism

Open stoobie opened this issue 9 months ago • 19 comments

Description of the Changes

Updates implemented in PR #857, minus questions/comments that are still unanswered or TBD.

PR Preview URL

L1-L2 Messaging mechanism

Check List

  • [x] Changes have been done against main branch, and PR does not conflict
  • [x] PR title follows the convention: <docs/feat/fix/chore>(optional scope): <description>, e.g: fix: minor typos in code

This change is Reviewable

stoobie avatar May 02 '24 11:05 stoobie

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

github-actions[bot] avatar May 02 '24 11:05 github-actions[bot]

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

github-actions[bot] avatar May 02 '24 11:05 github-actions[bot]

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

github-actions[bot] avatar May 02 '24 12:05 github-actions[bot]

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

github-actions[bot] avatar May 02 '24 12:05 github-actions[bot]

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 06 '24 07:05 starknet-bot

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 06 '24 07:05 starknet-bot

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 06 '24 10:05 starknet-bot

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 06 '24 12:05 starknet-bot

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 06 '24 15:05 starknet-bot

components/Starknet/modules/architecture_and_concepts/pages/Network_Architecture/messaging-mechanism.adoc line 23 at r3 (raw file):


. During the execution of a transaction, a contract on Starknet sends a message from L2 to L1 by calling the `send_message_to_L1` syscall.
. The sequencer attaches the message parameters to the state update that includes the syscall invocation. The message parameters include the address of the recipient contract on L1 and the message data.

Suggestion:

. The sequencer attaches the message parameters to the state update that includes the syscall invocation. The message parameters include the address of the sender on L2, the address of the recipient contract on L1, and the message data.

avi-starkware avatar May 07 '24 09:05 avi-starkware

components/Starknet/modules/architecture_and_concepts/pages/Network_Architecture/messaging-mechanism.adoc line 23 at r3 (raw file):


. During the execution of a transaction, a contract on Starknet sends a message from L2 to L1 by calling the `send_message_to_L1` syscall.
. The sequencer attaches the message parameters to the state update that includes the syscall invocation. The message parameters include the address of the recipient contract on L1 and the message data.

Oh wait, do you mean the parameters of the send_message_to_l1_syscall(as in the example below), or the parameters of the message itself as it appears in the block? From the first sentence of this bullet, it seems you mean the block / state update and it does include the sender address as well.

avi-starkware avatar May 07 '24 09:05 avi-starkware

components/Starknet/modules/architecture_and_concepts/pages/Network_Architecture/messaging-mechanism.adoc line 23 at r3 (raw file):

Previously, avi-starkware wrote…

Oh wait, do you mean the parameters of the send_message_to_l1_syscall(as in the example below), or the parameters of the message itself as it appears in the block? From the first sentence of this bullet, it seems you mean the block / state update and it does include the sender address as well.

I'm am not sure about your terminology, but to be more exact, only the block contains the L2 -> L1 messages. The state update only contains the root, storage diffs, nonces, and deployed classes. Here's an example for a state update that has messages, and this is the corresponding block. You can see the messages appear in the json of the block in this example, but not in the corresponding state update. (Use a chrome extension such as JSON Formatting, to see the json in a readable format in the browser.)

avi-starkware avatar May 07 '24 09:05 avi-starkware

components/Starknet/modules/architecture_and_concepts/pages/Network_Architecture/messaging-mechanism.adoc line 54 at r3 (raw file):

[#diagram_l2-l1_messaging_mechanism]
.L2->L1 Messaging mechanism
image::l2l1.png[L2->L1 message mechanism]

Should the numbers in red circles refer to the items above? I think they are mismatched.

Code quote:

xref:#diagram_l2-l1_messaging_mechanism[] illustrates this flow:

[#diagram_l2-l1_messaging_mechanism]
.L2->L1 Messaging mechanism
image::l2l1.png[L2->L1 message mechanism]

avi-starkware avatar May 07 '24 09:05 avi-starkware

components/Starknet/modules/architecture_and_concepts/pages/Network_Architecture/messaging-mechanism.adoc line 63 at r3 (raw file):


[horizontal,labelwidth="30",role="stripes-odd"]
from_address (`felt252`):: The address of the L2 contract sending the message.

Suggestion:

`from_address` (`felt252`):: The address of the L2 contract sending the message.

avi-starkware avatar May 07 '24 09:05 avi-starkware

components/Starknet/modules/architecture_and_concepts/pages/Network_Architecture/messaging-mechanism.adoc line 105 at r3 (raw file):

. The L1 Handler transaction that was created in the previous step is added to a proof.
. The Core Contract receives the state update.
. The message is cleared from the Core Contract's storage. At this point, the message is handled.

This step also incurs a fee that is similar to the fee charged for L2 -> L1 messages (this is mentioned for L2 -> L1 messages in the NOTE above):

  • 5000 gas for clearing the L1 storage to consume the message (instead of the 20000 charged for L2 -> L1 messages).
  • This also emits an L1 event logging this consumption.

I think these costs are not actually being charged, though... @ArielElp, what exactly happens when charging L1 handler fees?

Code quote:

. The message is cleared from the Core Contract's storage. At this point, the message is handled.

avi-starkware avatar May 07 '24 11:05 avi-starkware

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 07 '24 12:05 starknet-bot

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 07 '24 14:05 starknet-bot

components/Starknet/modules/architecture_and_concepts/pages/Network_Architecture/messaging-mechanism.adoc line 23 at r3 (raw file):

Previously, avi-starkware wrote…

I'm am not sure about your terminology, but to be more exact, only the block contains the L2 -> L1 messages. The state update only contains the root, storage diffs, nonces, and deployed classes. Here's an example for a state update that has messages, and this is the corresponding block. You can see the messages appear in the json of the block in this example, but not in the corresponding state update. (Use a chrome extension such as JSON Formatting, to see the json in a readable format in the browser.)

Sorry, this is the block I meant to refer you to, and this is the corresponding state update.

Look at transaction 0xecd259e52ef5061081559c80c0b5f1560caaca7f198a6bf90a74d866593b1 to find a non-empty message.

avi-starkware avatar May 08 '24 06:05 avi-starkware

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 08 '24 11:05 starknet-bot

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 19 '24 10:05 starknet-bot

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 20 '24 12:05 starknet-bot

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 26 '24 10:05 starknet-bot

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 26 '24 15:05 starknet-bot

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 27 '24 08:05 starknet-bot

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar May 30 '24 15:05 starknet-bot

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar Jun 06 '24 09:06 starknet-bot

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-1244/documentation/ .

starknet-bot avatar Jun 06 '24 12:06 starknet-bot