-
Notifications
You must be signed in to change notification settings - Fork 142
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
move node types and handlings to separate packages #729
base: move-atomic-sync
Are you sure you want to change the base?
Conversation
…reth into move-atomic-network-handlers
…reth into move-atomic-network-handlers
return nil | ||
} | ||
|
||
func (vm *VM) RegisterLeafRequestHandler(nodeType message.NodeType, metricName string, trieDB *triedb.Database, trieKeyLen int, useSnapshot bool) error { |
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.
Hmm I wonder if we should register an interface rather than nodeType directly. I feel like there is definitely room to improve this PR in general, but did not want to break it anything further.
@@ -1218,15 +1226,41 @@ func (vm *VM) setAppRequestHandlers() { | |||
}, | |||
}, | |||
) | |||
if err := vm.RegisterLeafRequestHandler(message.StateTrieNode, "sync_state_trie_leaves", evmTrieDB, message.StateTrieKeyLength, true); err != nil { | |||
return 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.
nit
return err | |
return fmt.Errorf("failed registering state trie database: %s", err) |
maybe %w
is needed though
} | ||
// Register atomic trieDB for serving atomic leafs requests. | ||
if err := vm.RegisterLeafRequestHandler(atomic.AtomicTrieNode, "sync_atomic_trie_leaves", vm.atomicTrie.TrieDB(), atomic.AtomicTrieKeyLength, false); err != nil { | ||
return 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.
nit
return err | |
return fmt.Errorf("failed registering atomic trie database: %s", err) |
maybe %w
is needed though
@@ -34,7 +34,7 @@ State sync code is structured as follows: | |||
- `plugin/evm/`: The engine expects the VM to implement `StateSyncableVM` interface, | |||
- `StateSyncServer`: Contains methods executed on nodes _serving_ state sync requests. | |||
- `StateSyncClient`: Contains methods executed on nodes joining the network via state sync, and orchestrates the top level steps of the sync. | |||
- `peer`: Contains abstractions used by `sync/statesync` to send requests to peers (`AppRequest`) and receive responses from peers (`AppResponse`). | |||
- `peer`: Contains abstractions used by `sync/statesync` to send requests to peers (`AppRequest`) and receive responses from peers (`AppResponse`). |
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 revert this, the trailing space is a bit out of scope 😄 Although we probably want to setup CI markdown checks at some point to have consistent markdown.
if len(leafsRequest.Start) != 0 && len(leafsRequest.Start) != lrh.trieKeyLength || | ||
len(leafsRequest.End) != 0 && len(leafsRequest.End) != lrh.trieKeyLength { |
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.
shouldnt' we use parentheses in those conditions?? 🤔
Why this should be merged
Moves declaration of message.NodeType to separate pkgs
How this works
This pull request includes several changes to the
plugin/evm
package, primarily focusing on the atomic trie synchronization and request handling.Atomic Trie Synchronization:
plugin/evm/atomic/atomic_syncer.go
: IntroducedAtomicTrieNode
constant and replacedatomicKeyLength
withAtomicTrieKeyLength
throughout the file. [1] [2] [3] [4]Request Handling:
plugin/evm/message/handler.go
: Simplified theRequestHandler
interface by mergingHandleStateTrieLeafsRequest
andHandleAtomicTrieLeafsRequest
into a singleHandleLeafsRequest
method. [1] [2]plugin/evm/message/leafs_request.go
: UpdatedLeafsRequest
to use a singleNodeType
field and removed the distinction between state and atomic trie nodes. [1] [2]plugin/evm/vm.go
: IntroducedRegisterLeafRequestHandler
that can register differentmessage.NodeType
s and passes configs tonetworkHandler
to handle registered NodeTypes accordingly by creating leaf request handlers for each type.Test Updates:
plugin/evm/atomic/atomic_syncer_test.go
: Updated tests to useAtomicTrieKeyLength
instead ofatomicKeyLength
. [1] [2] [3] [4]plugin/evm/message/leafs_request_test.go
: Removed tests that validated the old node type-specific request handling.Additional Changes:
plugin/evm/atomic/atomic_trie.go
: ReplacedatomicKeyLength
withAtomicTrieKeyLength
. [1] [2]plugin/evm/atomic/atomic_trie_iterator.go
: Removed theatomicTrieKeyLen
constant and replaced its usage withAtomicTrieKeyLength
. [1] [2]These changes collectively simplify the codebase and improve the maintainability of the atomic trie synchronization and request handling logic.
How this was tested
Existing UTs
Need to be documented?
No
Need to update RELEASES.md?
No