-
Notifications
You must be signed in to change notification settings - Fork 182
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(katana): starknet messaging L1-L2
and L2-L3
#914
Conversation
L1-L2
and L2-Appchain
L1-L2
and L2-L3
With rust fmt, I have a strange behavior. Everytime I run it, I have new spaces on the lines indicated in red. Not sure how to fix it. I have to rework my indentation due to the escaped string? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initial review.. i've only been looking thru the Rust code for now, haven't yet looked into the contracts and test the whole flow.
i have some nitpicks but will leave that at the end and focus on the design for now
personally, i prefer if can have it under a feature |
bbd2b6e
to
6b53297
Compare
1b0bde0
to
cf8e0c1
Compare
unit test focus on core function to parse messages generated locally to compute the hash. Or the parse a log/event from the settlement chain in order to build the L1HandlerTransaction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good so far...
the starknet-messaging
is very opinionated but should be a good experiment to play around with katana <-> katana messaging. it is hidden under a feature and isn't enable by default.
we can keep the scripts and the foundry project to help setting up the messaging system quickly.
03ff224
to
1a14b8d
Compare
lgtm happy to merge this if there's no more necessary updates |
On my side it's all good. |
This is the rework for the messaging inside Katana.
L1-L2
To test
L1-L2
messaging, Katana implements the same logic as the production sequencer: when a message is logged from L1 by the Starknet Core contract, this log is processed and aL1HandlerTransaction
is fired internally.In the case of testing as we are, the Starknet Core contract were slightly modified to directly register the message hash to be consumed (instead of waiting a block to be proven as it's one in production).
Remember, the messaging is totally asynchronous and asymmetric. If you send a message
L1->L2
, the log is consumed automatically by the sequencer, and theL1HandlerTransaction
is fired automatically.Howerver, sending a message
L2->L1
sends actually only the hash of the message. Then you have to consume it manually.L2-L3
By modifying a bit how the messaging works, Katana is now capable of communicating with Starknet. Which unlock the possibility of using Katana as a L3 with messaging features.
This modification is that, as the messaging is only accepting
EthAddress
as theto_address
field of the message, we need to passContractAddress
. To do so, theto_address
field is reused to indicate Katana (L3) that we want to send a message, or if we want to execute a call on Starknet.Yes, execute. Because in
L1-L2
the messaging is asymmetric. But here, betweenL2
and an appchain, were costs are very low, Katana offers the possibility to directly execute a message on Starknet!How to test the messaging
With some Makefile, it's easy to test the flow. But if you modify the contracts, then
you'll have to modify the files or directly use
starkli
orcast
to interact with the chains.Please ensure you have those tools installed before continuing:
v0.7.0
.If it's the first time you run the scripts, please go into
crates/katana/core/contracts/messaging/solidity
and runforge install
.L1-L2
L2-L3
In this example, we need two Katana. One for playing the role of Starknet, and an other one being a L3/appchain.
You can monitor Katana logs to see messages being settled on the settlement layer (eth or sn) and the
L1HandlerTransaction
being generated.@kariy as this feature is importing
ether-rs
which is a consequent library, do you think we need to do amessaging
feature to be enabled/disabled? Or do we want the fully featured katana by default with messaging?As always, thank you for every comment/feedback/review. 🙏