-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Initial definition and plumbing of messages for separating cont…
…ract distribution from witness (#12224) This PR introduced basic data structures and does some basic plumbing of the data. We cover the chunk producer part of the flow and do not implement the message handling on the chunk validator side. Also we do not handle the handling of requesting and responding to code requests. The high-level flow: - Chunk producer: - Identifies the contracts accessed (ie. called) when applying the previous chunk, and saves them as part of state transition data. - Sends the hashes of accessed contracts separately to chunk validators, when sending the state witness. - Chunk validator: - Upon receiving the code hashes, checks which contracts are missing. - Requests the missing contracts (by code hash) from the chunk producer. - Chunk producer: - Responds to requests for retrieving missing contracts by sending raw code bytes to chunk validators. - Chunk validator: - Upon receiving the missing code, includes them in the partial storage and starts validating the witness (note that the runtime will compile the code if missing from compiled-contract cache). Also starts comping the code in parallel. Changes in this PR: Add 3 messages: - `ChunkContractAccesses`: Contains the code-hashes of the contracts accessed while applying the chunk. Sent from chunk producer to chunk validators (the same set of validators as state witness). - `ContractCodeRequest`: Contains a list of code-hashes that chunk validators request from chunk producer. Sent from a chunk validator to the chunk producer that sent a state witness. - `ContractCodeResponse`: Contains a list of code bytes as response to a `ContractCodeRequest`. Sent from a chunk producer to a chunk validator. Introduce a new feature flag `contract_distribution` to guard some changes that should not yet be included in the main binary (eg. new field to database column and sending new messages). Added some plumbing to pass a list of code-hashes from chunk application up to the point we send state witness. - Return the code-hashes from `TrieUpdate::finalize`. Also contain the return values from `finalize` in a new struct called `TrieUpdateResult` for readability. - Pass the code-hashes from `TrieUpdateResult` to `ApplyResult` and `ApplyChunkResult` in `validate_apply_state_update`. - Pass the code-hashes from `ApplyChunkResult` to `StoredChunkStateTransitionData` in `ChainUpdate::save_state_transition_data`(currently guarded by feature flag, since this needs a database migration). - Read `StoredChunkStateTransitionData` in `create_state_witness` and return a pair of state witness and list of code-hashes. This also includes a database migration that converts StoredChunkStateTransitionData to an enum and adds a new field to the first version (V1).
- Loading branch information
1 parent
fef9ddf
commit cc3a3ce
Showing
44 changed files
with
816 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.