-
Notifications
You must be signed in to change notification settings - Fork 197
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 75.26% 75.11% -0.16%
==========================================
Files 140 141 +1
Lines 16842 17198 +356
==========================================
+ Hits 12676 12918 +242
- Misses 3335 3419 +84
- Partials 831 861 +30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Even though the PR is approved, I'm adding the |
Relevant blockifier PR #2397 |
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 putting a blocking comment here to make sure it doesn't get merged by accident during this release process.
I would also like to give a final review before moving ahead with the PR.
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's a very big PR so I left a lot of comments. Nonetheless, my general thoughts are that it is very good quality and the quantity of the comments is just due it's size.
@@ -39,3 +40,50 @@ func AdaptOrderedEvents(events []vm.OrderedEvent) []*core.Event { | |||
}) | |||
return utils.Map(events, AdaptOrderedEvent) | |||
} | |||
|
|||
func AdaptStateDiff(fromStateDiff *vm.StateDiff) core.StateDiff { | |||
var result core.StateDiff |
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.
rename result
to stateDiff
. If you follow the upcoming suggestions we don't need this Var
if fromStateDiff == nil { | ||
return result | ||
} |
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 know this pattern is what it's generally used but I prefer not to handle nil cases implicitly in the code. I think they should be handled explicitly. I believe they sum up for better readability for the long term (projects such as this) even if you have to write a bit more code.
For example, the caller of this function should check that it's input parameter is not nil and the function. The function instead will assume if it gets called, there will be always something to adapt.
Of course, I think this are among the most subjective things so feel free to ignore. The idea is that nil
is an edge case that you should handle explicitly: "this function adapts from one to the other, it is not the role of this function to adapt nothing" (again, very subjective)
Finally, if you are staying with this approach, I think is better to just return core.StateDiff{}
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: