-
Notifications
You must be signed in to change notification settings - Fork 184
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
implement logic to build genesis state for the sequencer #2371
base: main
Are you sure you want to change the base?
Conversation
wip - fix test fix stuff
fb11e07
to
459db5d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2371 +/- ##
==========================================
- Coverage 74.70% 74.54% -0.16%
==========================================
Files 110 112 +2
Lines 12021 12407 +386
==========================================
+ Hits 8980 9249 +269
- Misses 2349 2435 +86
- Partials 692 723 +31 ☔ View full report in Codecov by Sentry. |
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 have finished reviewing everything except vm logic. Everything is good, just small changes and questions. I'll continue reviewing vm logic.
for classHash, class := range newClasses { | ||
// Sets pending.newClasses, DeclaredV0Classes, (not DeclaredV1Classes) | ||
if err = genesisState.SetContractClass(&classHash, class); err != nil { | ||
return nil, nil, fmt.Errorf("declare v0 class: %v", err) | ||
} | ||
|
||
if cairo1Class, isCairo1 := class.(*core.Cairo1Class); isCairo1 { | ||
if err = genesisState.SetCompiledClassHash(&classHash, cairo1Class.Compiled.Hash()); err != nil { | ||
return nil, nil, fmt.Errorf("set compiled class hash: %v", err) | ||
} | ||
} | ||
} |
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.
Could we use descriptive variable names instead of this comment?
// Sets pending.newClasses, DeclaredV0Classes, (not DeclaredV1Classes)
I don't quite understand why only DeclaredV0Classes
in newClasses
.
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.
Could we use descriptive variable names instead of this comment?
Not sure I understand sorry. Could you give me an example?
I don't quite understand why only DeclaredV0Classes in newClasses.
Good question! Basically we inherit this structure from blockifier / starknet. To allow blockifier to make changes to the pending state we need to implement a certain interface (see impl State for JunoStateReader
). We use that interface here to declare classes. Note this is how it seems to be done in blockifier / starknet, it first calls set_contract_class
then if its a CairoV1 class, set_compiled_class_hash
.
This PR implements the
genesis
pkg that builds astate diff
from declaring classes, deploying contracts and invoking functions. The sequencer can then commit thisstate diff
to state, so that upon startup, a set of account contracts have already been deployed and funded (it is not possible to achieve this from an empty state by submitting transactions, since Starknet requires accounts to be funded to perform any actions on the state - originally this wasn't a requirement in Starknet). This is particularly useful as it allows users to start the sequencer with any number of accounts pre-deployed, and pre-funded, etc, and opens up the possibility of using Juno as a devnetIn essence: