[Storehouse] 006 Payloadless execution builder#8577
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
5d35e82 to
d4f7065
Compare
d7dea94 to
fcc22e5
Compare
d4f7065 to
a66eeaa
Compare
fcc22e5 to
f138980
Compare
| // ledger storage. | ||
| func NewExecutionState( | ||
| ls ledger.Ledger, | ||
| ls LedgerStateChecker, |
There was a problem hiding this comment.
I'm not a fan of this signature!
I think I would just keep snapshotLedger ledger.Ledger, then inside of the method check if snapshotLedger is the type of ledger that has state or not when this is relevant.
There was a problem hiding this comment.
Good question.
The reason we introduce the LedgerStateChecker interface is because payloadless ledger does not implement the ledger.Ledger interface, instead, it implement ledger.PayloadlessLedger interface.
We tried to be more strict by creating more interface and types for the payloadless feature in order to leverage the static compiler checks. The approach you suggest could work, but relies on runtime type check, so we would have to give up the safety from static type check.
The ledger.Ledger can query register value by key, and ledger.PayloadlessLedger can only query register leaf hash by key, because it does not store payload, but only the hash. But they can both support checking if they have a certain trie root hash.
However, we don't want to create a NewPayloadlessExecutionState, because that would duplicate lots of code. In order to reuse the NewExecutionState for both full node and payloadless node, we would have to change the ledger.Ledger input. And I found that interface is mostly used to check if the ledger has certain trie root hash, which ledger.PayloadlessLedger also supports. And the only case specifically for the ledger.Ledger interface is the NewLedgerStorageSnapshot function where the ledger.Ledger is only needed when storehouse is enabled. Since we know payloadless mode must work with storehouse, it's ok that if storehouse is not enabled, then we don't use payloadless interface, but only the ledger.Ledger.
That's why it's better take two inputs (ledger.Ledger and LedgerStateChecker): the ledger.Ledger (snapshotLedger) is only used by NewPayloadlessExecutionState, whereas LedgerStateChecker is used everywhere else.
a66eeaa to
553a243
Compare
f138980 to
fc173be
Compare
--payloadless=true|falseflag to execution node (not working when payloadless=true yet, only works for the default valuefalse)