-
Notifications
You must be signed in to change notification settings - Fork 275
sync: coreth PR #963,981,1009: sync package extension and related items #1679
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
base: master
Are you sure you want to change the base?
Changes from 42 commits
01053b3
f3fd073
d04a7fc
239a3b5
52e4d26
34e3c48
ae531aa
38ecb7e
08bf133
a759870
912b506
892379e
c7c0c9a
4719758
434fb4f
936aacc
0edb94f
af00a05
3cb3808
728620c
52aba0c
eb25788
6ba1bd6
59a0ccc
07edff7
2564286
fa8a32d
5d911d5
14c8028
8fa7586
94c2b46
5b7d576
8426e2a
24e0ae0
7e55ada
ac0b665
2a46756
40abb33
ba927d5
0cc7e3b
cced3ca
291003a
e84bf4a
2356b60
9e4a453
509e349
33837af
55f46e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import ( | |
"fmt" | ||
"time" | ||
|
||
"github.com/ava-labs/avalanchego/utils/constants" | ||
"github.com/ava-labs/libevm/common" | ||
"github.com/ava-labs/libevm/common/hexutil" | ||
"github.com/spf13/cast" | ||
|
@@ -129,7 +130,7 @@ type Config struct { | |
MaxOutboundActiveRequests int64 `json:"max-outbound-active-requests"` | ||
|
||
// Sync settings | ||
StateSyncEnabled bool `json:"state-sync-enabled"` | ||
StateSyncEnabled *bool `json:"state-sync-enabled"` // Pointer distinguishes false (no state sync) and not set (state sync only at genesis). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why have we changed this? This is a substantial change for default value, we should have a separate PR for that if we want to align them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have changed this because this was a change that Darioush made years ago to See ava-labs/coreth@cd3a14e#diff-6c4b2fd34f767685bfc35038a59ea4fbfadaa6060d70031002e3b008e73a06e7. I have created a targeted PR for this change (and this change does need to be synced): |
||
StateSyncSkipResume bool `json:"state-sync-skip-resume"` // Forces state sync to use the highest available summary block | ||
StateSyncServerTrieCache int `json:"state-sync-server-trie-cache"` | ||
StateSyncIDs string `json:"state-sync-ids"` | ||
|
@@ -236,7 +237,18 @@ func (d Duration) MarshalJSON() ([]byte, error) { | |
} | ||
|
||
// validate returns an error if this is an invalid config. | ||
func (c *Config) validate(_ uint32) error { | ||
func (c *Config) validate(networkID uint32) error { | ||
// Ensure that non-standard commit interval is not allowed for production networks | ||
if constants.ProductionNetworkIDs.Contains(networkID) { | ||
defaultConfig := NewDefaultConfig() | ||
if c.CommitInterval != defaultConfig.CommitInterval { | ||
return fmt.Errorf("cannot start non-local network with commit interval %d different than %d", c.CommitInterval, defaultConfig.CommitInterval) | ||
} | ||
if c.StateSyncCommitInterval != defaultConfig.StateSyncCommitInterval { | ||
return fmt.Errorf("cannot start non-local network with syncable interval %d different than %d", c.StateSyncCommitInterval, defaultConfig.StateSyncCommitInterval) | ||
} | ||
} | ||
Comment on lines
+242
to
+250
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. simirlay we should not change these here(I don't think we ever change this in those sync PRs) |
||
|
||
if c.PopulateMissingTries != nil && (c.OfflinePruning || c.Pruning) { | ||
return fmt.Errorf("cannot enable populate missing tries while offline pruning (enabled: %t)/pruning (enabled: %t) are enabled", c.OfflinePruning, c.Pruning) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package message | ||
|
||
import ( | ||
"context" | ||
"encoding/base64" | ||
"testing" | ||
|
||
"github.com/ava-labs/avalanchego/snow/engine/snowman/block" | ||
"github.com/ava-labs/libevm/common" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMarshalBlockSyncSummary(t *testing.T) { | ||
blockSyncSummary, err := NewBlockSyncSummary(common.Hash{1}, 2, common.Hash{3}) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, common.Hash{1}, blockSyncSummary.GetBlockHash()) | ||
require.Equal(t, uint64(2), blockSyncSummary.Height()) | ||
require.Equal(t, common.Hash{3}, blockSyncSummary.GetBlockRoot()) | ||
|
||
expectedBase64Bytes := "AAAAAAAAAAAAAgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" | ||
require.Equal(t, expectedBase64Bytes, base64.StdEncoding.EncodeToString(blockSyncSummary.Bytes())) | ||
|
||
parser := NewBlockSyncSummaryParser() | ||
called := false | ||
acceptImplTest := func(Syncable) (block.StateSyncMode, error) { | ||
called = true | ||
return block.StateSyncSkipped, nil | ||
} | ||
s, err := parser.Parse(blockSyncSummary.Bytes(), acceptImplTest) | ||
require.NoError(t, err) | ||
require.Equal(t, blockSyncSummary.GetBlockHash(), s.GetBlockHash()) | ||
require.Equal(t, blockSyncSummary.Height(), s.Height()) | ||
require.Equal(t, blockSyncSummary.GetBlockRoot(), s.GetBlockRoot()) | ||
require.Equal(t, blockSyncSummary.Bytes(), s.Bytes()) | ||
|
||
mode, err := s.Accept(context.TODO()) | ||
require.NoError(t, err) | ||
require.Equal(t, block.StateSyncSkipped, mode) | ||
require.True(t, called) | ||
} |
Uh oh!
There was an error while loading. Please reload this page.