Skip to content

Commit

Permalink
Merge branch 'songbird-support' into songbird-support-js-tracers-enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mboben committed Jul 25, 2024
2 parents e289a2d + ef60586 commit d1f906a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions coreth/plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ func (vm *VM) initializeStateSyncClient(lastAcceptedHeight uint64) error {
Stats: stats.NewClientSyncerStats(),
StateSyncNodeIDs: stateSyncIDs,
BlockParser: vm,
IsSongbirdCode: vm.chainConfig.IsSongbirdCode(),
},
),
enabled: vm.config.StateSyncEnabled,
Expand Down
14 changes: 13 additions & 1 deletion coreth/sync/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ var (
Minor: 7,
Patch: 13,
}
StateSyncVersionSgb = &version.Application{
Major: 0,
Minor: 6,
Patch: 6,
}
errEmptyResponse = errors.New("empty response")
errTooManyBlocks = errors.New("response contains more blocks than requested")
errHashMismatch = errors.New("hash does not match expected value")
Expand Down Expand Up @@ -82,6 +87,7 @@ type client struct {
stateSyncNodeIdx uint32
stats stats.ClientSyncerStats
blockParser EthBlockParser
isSongbirdCode bool
}

type ClientConfig struct {
Expand All @@ -90,6 +96,7 @@ type ClientConfig struct {
Stats stats.ClientSyncerStats
StateSyncNodeIDs []ids.NodeID
BlockParser EthBlockParser
IsSongbirdCode bool
}

type EthBlockParser interface {
Expand All @@ -103,6 +110,7 @@ func NewClient(config *ClientConfig) *client {
stats: config.Stats,
stateSyncNodes: config.StateSyncNodeIDs,
blockParser: config.BlockParser,
isSongbirdCode: config.IsSongbirdCode,
}
}

Expand Down Expand Up @@ -325,7 +333,11 @@ func (c *client) get(ctx context.Context, request message.Request, parseFn parse
start time.Time = time.Now()
)
if len(c.stateSyncNodes) == 0 {
response, nodeID, err = c.networkClient.RequestAny(StateSyncVersion, requestBytes)
minVersion := StateSyncVersion
if c.isSongbirdCode {
minVersion = StateSyncVersionSgb
}
response, nodeID, err = c.networkClient.RequestAny(minVersion, requestBytes)
} else {
// get the next nodeID using the nodeIdx offset. If we're out of nodes, loop back to 0
// we do this every attempt to ensure we get a different node each time if possible.
Expand Down

0 comments on commit d1f906a

Please sign in to comment.