diff --git a/plugin/evm/message/block_sync_summary.go b/plugin/evm/message/block_sync_summary.go index 45f80052b1..ad7c28fecf 100644 --- a/plugin/evm/message/block_sync_summary.go +++ b/plugin/evm/message/block_sync_summary.go @@ -21,6 +21,7 @@ type BlockSyncSummary struct { BlockNumber uint64 `serialize:"true"` BlockHash common.Hash `serialize:"true"` BlockRoot common.Hash `serialize:"true"` + // ADD A FIELD FOR FIREWOOD IF NEEDED summaryID ids.ID bytes []byte diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 2f3a36793b..07c57a9dd3 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -643,6 +643,7 @@ func (vm *VM) initializeStateSync(lastAcceptedHeight uint64) error { // Initialize the state sync client vm.Client = vmsync.NewClient(&vmsync.ClientConfig{ + // Static or Dynamic StateSyncDone: vm.stateSyncDone, Chain: vm.eth, State: vm.State, @@ -864,7 +865,7 @@ func (vm *VM) WaitForEvent(ctx context.Context) (commonEng.Message, error) { case <-ctx.Done(): return 0, ctx.Err() case <-vm.stateSyncDone: - return commonEng.StateSyncDone, nil + return commonEng.StateSyncDone, nil // modify to return a height/block hash case <-vm.shutdownChan: return commonEng.Message(0), errShuttingDownVM } diff --git a/plugin/evm/vmsync/client.go b/plugin/evm/vmsync/client.go index 99f98d787c..8aaf798f00 100644 --- a/plugin/evm/vmsync/client.go +++ b/plugin/evm/vmsync/client.go @@ -284,6 +284,26 @@ func (client *client) acceptSyncSummary(proposedSummary message.Syncable) (block return block.StateSyncStatic, nil } +func (client *Client) UpdateSyncTarget(t T/* per block info */) error { + client.lock.Lock() + defer client.lock.Unlock() + if !currentlySyncing { + return err + } + if currentlyFinalizing { + return nil + // will only work if we tell the engine where to bootstrap from + // Otherwise, we add to queue + } + If t.Height % interval == 0 { + client.t == t + return registry.UpdateTarget(t) + } + + return nil +} + + func (client *client) Shutdown() error { if client.cancel != nil { client.cancel() diff --git a/plugin/evm/wrapped_block.go b/plugin/evm/wrapped_block.go index 06d081ad7b..6a93f95bd3 100644 --- a/plugin/evm/wrapped_block.go +++ b/plugin/evm/wrapped_block.go @@ -94,6 +94,9 @@ func (b *wrappedBlock) ID() ids.ID { return b.id } // Accept implements the snowman.Block interface func (b *wrappedBlock) Accept(context.Context) error { vm := b.vm + if currentlyDynamicSyncing() { + return vm.client.UpdateSyncTarget( /* WHAT IS THIS*/ ) + } // Although returning an error from Accept is considered fatal, it is good // practice to cleanup the batch we were modifying in the case of an error. defer vm.versiondb.Abort() @@ -248,6 +251,9 @@ func (b *wrappedBlock) VerifyWithContext(_ context.Context, proposerVMBlockCtx * // Enforces that the predicates are valid within [predicateContext]. // Writes the block details to disk and the state to the trie manager iff writes=true. func (b *wrappedBlock) verify(predicateContext *precompileconfig.PredicateContext, writes bool) error { + if currentlyDynamicSyncing() { + return nil + } if predicateContext.ProposerVMBlockCtx != nil { log.Debug("Verifying block with context", "block", b.ID(), "height", b.Height()) } else {