starknet-io / starknet-docs

The repo for Starknet's developer documentation. Includes contribution guidelines and the Starknet documentation supplementary style guide
https://docs.starknet.io/
112 stars 158 forks source link

docs: Updates to Messaging mechanism #1244

Closed stoobie closed 4 weeks ago

stoobie commented 2 months ago

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


This change is Reviewable

github-actions[bot] commented 2 months ago

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] commented 2 months ago

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] commented 2 months ago

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] commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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

avi-starkware commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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):

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.
starknet-bot commented 1 month ago

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 commented 1 month ago

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

avi-starkware commented 1 month ago

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](https://alpha-mainnet.starknet.io/feeder_gateway/get_state_update?blockHash=0xb2bb557e370ac3dbc5bb41e76c4ce0a02a3afe45a4bc4d9e603fb7645df08d) an example for a state update that has messages, and [this](https://alpha-mainnet.starknet.io/feeder_gateway/get_block?blockHash=0xb2bb557e370ac3dbc5bb41e76c4ce0a02a3afe45a4bc4d9e603fb7645df08d) 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.

starknet-bot commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 4 weeks ago

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 commented 4 weeks ago

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