From 556d9036b2540911d1f5578f461329a82e3f8f2b Mon Sep 17 00:00:00 2001 From: "Leo Zhang (zhangchiqing)" Date: Wed, 27 Nov 2024 06:43:35 -0800 Subject: [PATCH] keep ReplayBlock unchanged --- fvm/evm/offchain/sync/replayer.go | 11 ++++++++++- fvm/evm/offchain/sync/replayer_test.go | 8 +------- fvm/evm/offchain/utils/replay.go | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/fvm/evm/offchain/sync/replayer.go b/fvm/evm/offchain/sync/replayer.go index 33411b7c133..96df01d58a0 100644 --- a/fvm/evm/offchain/sync/replayer.go +++ b/fvm/evm/offchain/sync/replayer.go @@ -45,6 +45,15 @@ func NewReplayer( } // ReplayBlock replays the execution of the transactions of an EVM block +func (cr *Replayer) ReplayBlock( + transactionEvents []events.TransactionEventPayload, + blockEvent *events.BlockEventPayload, +) (types.ReplayResultCollector, error) { + res, _, err := cr.ReplayBlockEvents(transactionEvents, blockEvent) + return res, err +} + +// ReplayBlockEvents replays the execution of the transactions of an EVM block // using the provided transactionEvents and blockEvents, // which include all the context data for re-executing the transactions, and returns // the replay result and the result of each transaction. @@ -57,7 +66,7 @@ func NewReplayer( // Warning! the list of transaction events has to be sorted based on their // execution, sometimes the access node might return events out of order // it needs to be sorted by txIndex and eventIndex respectively. -func (cr *Replayer) ReplayBlock( +func (cr *Replayer) ReplayBlockEvents( transactionEvents []events.TransactionEventPayload, blockEvent *events.BlockEventPayload, ) (types.ReplayResultCollector, []*types.Result, error) { diff --git a/fvm/evm/offchain/sync/replayer_test.go b/fvm/evm/offchain/sync/replayer_test.go index 3668e445c84..06262b5811e 100644 --- a/fvm/evm/offchain/sync/replayer_test.go +++ b/fvm/evm/offchain/sync/replayer_test.go @@ -164,7 +164,7 @@ func TestChainReplay(t *testing.T) { sp := NewTestStorageProvider(snapshot, 1) cr := sync.NewReplayer(chainID, rootAddr, sp, bp, zerolog.Logger{}, nil, true) - res, results, err := cr.ReplayBlock(txEventPayloads, blockEventPayload) + res, results, err := cr.ReplayBlockEvents(txEventPayloads, blockEventPayload) require.NoError(t, err) require.Len(t, results, totalTxCount) @@ -173,12 +173,6 @@ func TestChainReplay(t *testing.T) { err = bp.OnBlockExecuted(blockEventPayload.Height, res, proposal) require.NoError(t, err) - - // for k, v := range bpStorage.StorageRegisterUpdates() { - // ret, err := backend.GetValue([]byte(k.Owner), []byte(k.Key)) - // require.NoError(t, err) - // require.Equal(t, ret[:], v[:]) - // } }) }) }) diff --git a/fvm/evm/offchain/utils/replay.go b/fvm/evm/offchain/utils/replay.go index d6cb222fa73..5aba8affcd1 100644 --- a/fvm/evm/offchain/utils/replay.go +++ b/fvm/evm/offchain/utils/replay.go @@ -38,7 +38,7 @@ func ReplayEVMEventsToStore( sp := testutils.NewTestStorageProvider(store, evmBlockEvent.Height) cr := sync.NewReplayer(chainID, rootAddr, sp, bp, log, nil, true) - res, results, err := cr.ReplayBlock(evmTxEvents, evmBlockEvent) + res, results, err := cr.ReplayBlockEvents(evmTxEvents, evmBlockEvent) if err != nil { return nil, nil, err }