-
Notifications
You must be signed in to change notification settings - Fork 0
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
Merkle proof verification #25
base: integration
Are you sure you want to change the base?
Conversation
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.
I haven't run the devnet to test this yet, but it looks good! Mostly nit comments.
@@ -189,9 +189,16 @@ var ( | |||
EspressoUrlFlag = &cli.StringFlag{ | |||
Name: "espresso-url", | |||
Usage: "", | |||
Value: "", // should be larger than the builder's max-l2-tx-size to prevent endlessly throttling some txs |
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.
Just for my understanding, is this comment no longer applicable?
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.
It wasn't actually applicable in the first place, it was a copy-paste artifact
EnvVars: prefixEnvVars("ESPRESSO_URL"), | ||
} | ||
|
||
EspressoLCAddrFlag = &cli.StringFlag{ |
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.
Nit: Not sure about Go naming conventions, but if it's similar to Rust, maybe it's better to use Lc
rather than LC
.
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.
Another nit: Can we pick either address
or url
for both the Espresso URL above and the light client URL here, for naming consistency?
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.
Nit: Not sure about Go naming conventions, but if it's similar to Rust, maybe it's better to use Lc rather than LC.
Go actually does the opposite, i.e. either "lc" or "LC" but never "Lc": https://go.dev/wiki/CodeReviewComments#initialisms
Another nit: Can we pick either address or url for both the Espresso URL above and the light client URL here, for naming consistency?
Those refer to different things though, one is an URL of an HTTP endpoint and another one is address of a contract on L1
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.
Go actually does the opposite, i.e. either "lc" or "LC" but never "Lc": https://go.dev/wiki/CodeReviewComments#initialisms
TIL!
} | ||
|
||
if snapshot.Height <= height { | ||
return fmt.Errorf("snapshot height is less than or equal to the requested height") |
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.
I was wondering whether this could be a warning or info rather than an error. Should we wait for a snapshot with a larger height in this case?
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.
We explicitly requested snapshot for this height though, so this would indicate a malicious/bugged lc contract.
|
||
blockMerkleTreeRoot := nextHeader.Header.GetBlockMerkleTreeRoot() | ||
|
||
log.Info("Verifying merkle proof", "height", height) |
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.
Here we log height
, but in most function calls we use snapshot.Height
. Should we check whether they are the same?
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.
Follow-up question: If they are not the same, i.e., snapshot.Height
is larger (since the smaller case has been checked), what should we do?
I was thinking we should make sure each finalized height is properly handled without skipping. If so, we may need extra handling here.
transaction := Transaction{ | ||
Namespace: 42, | ||
TeeAttn: []byte{1, 2, 3, 4}, | ||
CallData: txdata.CallData(), | ||
}.toEspresso() |
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.
Nit: It's fine as a proof of concept, but could we define this transaction
somewhere at the beginning of this file and make it a const like TestTransaction
? Just so we know we are going to replace it.
timer := time.NewTimer(2 * time.Minute) | ||
defer timer.Stop() | ||
|
||
ticker := time.NewTicker(100 * time.Millisecond) | ||
defer ticker.Stop() |
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.
Nit: Similar to the comment above, can we make timer
and ticker
consts too?
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.
Not really, they're started at the moment of creation
The durations indeed should be declared as separate consts though, I'll address that
Devnet could run smoothly with this branch. |
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.
This is cool! I left some questions for checking my understanding.
// TODO: Generate a real attestation | ||
teeAttestation := []byte{1, 2, 3, 4} |
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.
Here is the attestation we want to send to L1 right? Am I understanding correctly that: by this step, we know the transaction we sent to Espresso is finalized, and we'll use the espComm
to form the data we sent to L1 later. ?
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.
Wait a sec, we only want to send out attestation once to L1 iiuc, and later it will be signature on signing this TxHash(?) using the same key. I might raise up a discussion on this in zullip.
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.
I'll go with this if that also sounds reasonable for you: Ignore the teeAttestation here and generate it right before sending a transaction to espresso (line 103 where you have TeeAttn: []byte{1, 2, 3, 4},
). And I'll do the initial attestation for signer registration somewhere else.
func (l *BatchSubmitter) submitToEspresso(txdata txData) (*EspressoCommitment, error) { | ||
transaction := Transaction{ | ||
Namespace: 42, | ||
TeeAttn: []byte{1, 2, 3, 4}, |
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.
Here is the attestation we want to send to Espresso right? This is related to one of my another comment.
EspressoLCAddrFlag = &cli.StringFlag{ | ||
Name: "espresso-light-client-addr", | ||
Usage: "", | ||
Value: "0x422a3492e218383753d8006c7bfa97815b44373f", |
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.
Is this the real light client address? Does that mean when running kurtosis devnet, it's already connected to real lightclient, send real tx to hotshot and verify real merkleproof? If so, that's amazing! If not, I'm wondering how does it pass the merkle proof verification when running a virtual light client.
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.
A separate thing: IIUC, Escape Hatch Functionality has been automatically served with using light client, is that correct?
Got this when running Upd: The error message is fine actually. I see there's some new things need to be installed from the dockerfile change: gcc, espresso-sequencer-go etc. if we want to do it locally, would be good if @QuentinI already had instructions on that, but also fine if you don't. As these Dockerfiles should suffice. |
Closes #11
This PR:
espresso.go
This PR does not:
Key places to review:
How to test this PR:
Running devnet as usual should suffice