From 13816c443e5e8dff7c330bf776b50d899b364019 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 6 Jan 2025 11:30:17 +0100 Subject: [PATCH] feat(rollback): add rollback support (#1300) --- block/block.go | 4 +- block/executor.go | 2 +- block/executor_test.go | 4 +- block/manager.go | 12 +-- block/state.go | 9 ++- .../dymint/block/mock_ExecutorI.go | 33 ++++---- .../dymint/block/mock_FraudHandler.go | 4 +- .../dymint/da/avail/mock_SubstrateApiI.go | 22 +++--- .../celestia/types/mock_CelestiaRPCClient.go | 2 +- .../da/mock_DataAvailabilityLayerClient.go | 16 ++-- .../dymint/p2p/mock_StateGetter.go | 6 +- .../settlement/dymension/mock_CosmosClient.go | 14 ++-- .../dymint/settlement/mock_ClientI.go | 24 +++--- .../dymensionxyz/dymint/store/mock_Store.go | 76 ++++++++++++++++--- .../dymension/rollapp/mock_QueryClient.go | 2 +- .../dymension/sequencer/mock_QueryClient.go | 2 +- .../tendermint/abci/types/mock_Application.go | 4 +- .../tendermint/proxy/mock_AppConnConsensus.go | 8 +- .../tendermint/proxy/mock_AppConns.go | 32 ++++---- store/pruning.go | 4 +- store/storeIface.go | 2 + 21 files changed, 171 insertions(+), 111 deletions(-) diff --git a/block/block.go b/block/block.go index 75f935322..3adc83a12 100644 --- a/block/block.go +++ b/block/block.go @@ -68,7 +68,7 @@ func (m *Manager) applyBlock(block *types.Block, commit *types.Commit, blockMeta // In case the following true, it means we crashed after the app commit but before updating the state // In that case we'll want to align the state with the app commit result, as if the block was applied. if isBlockAlreadyApplied { - err := m.UpdateStateFromApp(block.Header.Hash()) + err := m.UpdateStateFromApp(block) if err != nil { return fmt.Errorf("update state from app: %w", err) } @@ -125,7 +125,7 @@ func (m *Manager) applyBlock(block *types.Block, commit *types.Commit, blockMeta } // Update the state with the new app hash, and store height from the commit. // Every one of those, if happens before commit, prevents us from re-executing the block in case failed during commit. - m.Executor.UpdateStateAfterCommit(m.State, responses, appHash, block.Header.Height, block.Header.Hash()) + m.Executor.UpdateStateAfterCommit(m.State, responses, appHash, block) } diff --git a/block/executor.go b/block/executor.go index ae04398d9..dfb4d0af3 100644 --- a/block/executor.go +++ b/block/executor.go @@ -30,7 +30,7 @@ type ExecutorI interface { ExecuteBlock(block *types.Block) (*tmstate.ABCIResponses, error) UpdateStateAfterInitChain(s *types.State, res *abci.ResponseInitChain) UpdateMempoolAfterInitChain(s *types.State) - UpdateStateAfterCommit(s *types.State, resp *tmstate.ABCIResponses, appHash []byte, height uint64, lastHeaderHash [32]byte) + UpdateStateAfterCommit(s *types.State, resp *tmstate.ABCIResponses, appHash []byte, block *types.Block) UpdateProposerFromBlock(s *types.State, seqSet *types.SequencerSet, block *types.Block) bool /* Consensus Messages */ diff --git a/block/executor_test.go b/block/executor_test.go index 369b38016..ab377c7b9 100644 --- a/block/executor_test.go +++ b/block/executor_test.go @@ -340,7 +340,7 @@ func TestApplyBlock(t *testing.T) { require.NotNil(resp) appHash, _, err := executor.Commit(state, block, resp) require.NoError(err) - executor.UpdateStateAfterCommit(state, resp, appHash, block.Header.Height, block.Header.Hash()) + executor.UpdateStateAfterCommit(state, resp, appHash, block) assert.Equal(uint64(1), state.Height()) assert.Equal(mockAppHash, state.AppHash) @@ -390,7 +390,7 @@ func TestApplyBlock(t *testing.T) { require.NotNil(resp) _, _, err = executor.Commit(state, block, resp) require.NoError(err) - executor.UpdateStateAfterCommit(state, resp, appHash, block.Header.Height, block.Header.Hash()) + executor.UpdateStateAfterCommit(state, resp, appHash, block) assert.Equal(uint64(2), state.Height()) // check rollapp params update diff --git a/block/manager.go b/block/manager.go index 00407c122..b4d2170fa 100644 --- a/block/manager.go +++ b/block/manager.go @@ -192,12 +192,6 @@ func NewManager( return nil, err } - // update dymint state with next revision info - err = m.updateStateForNextRevision() - if err != nil { - return nil, err - } - // validate configuration params and rollapp consensus params are in line err = m.ValidateConfigWithRollappParams() if err != nil { @@ -222,6 +216,12 @@ func (m *Manager) Start(ctx context.Context) error { } } + // update dymint state with next revision info + err := m.updateStateForNextRevision() + if err != nil { + return err + } + // Check if a proposer on the rollapp is set. In case no proposer is set on the Rollapp, fallback to the hub proposer (If such exists). // No proposer on the rollapp means that at some point there was no available proposer. // In case there is also no proposer on the hub to our current height, it means that the chain is halted. diff --git a/block/state.go b/block/state.go index 7b1991bc2..5c39dc915 100644 --- a/block/state.go +++ b/block/state.go @@ -74,7 +74,7 @@ func NewStateFromGenesis(genDoc *tmtypes.GenesisDoc) (*types.State, error) { } // UpdateStateFromApp is responsible for aligning the state of the store from the abci app -func (m *Manager) UpdateStateFromApp(blockHeaderHash [32]byte) error { +func (m *Manager) UpdateStateFromApp(block *types.Block) error { proxyAppInfo, err := m.Executor.GetAppInfo() if err != nil { return errorsmod.Wrap(err, "get app info") @@ -87,7 +87,7 @@ func (m *Manager) UpdateStateFromApp(blockHeaderHash [32]byte) error { } // update the state with the app hashes created on the app commit - m.Executor.UpdateStateAfterCommit(m.State, resp, proxyAppInfo.LastBlockAppHash, appHeight, blockHeaderHash) + m.Executor.UpdateStateAfterCommit(m.State, resp, proxyAppInfo.LastBlockAppHash, block) return nil } @@ -116,12 +116,13 @@ func (e *Executor) UpdateMempoolAfterInitChain(s *types.State) { } // UpdateStateAfterCommit updates the state with the app hash and last results hash -func (e *Executor) UpdateStateAfterCommit(s *types.State, resp *tmstate.ABCIResponses, appHash []byte, height uint64, lastHeaderHash [32]byte) { +func (e *Executor) UpdateStateAfterCommit(s *types.State, resp *tmstate.ABCIResponses, appHash []byte, block *types.Block) { copy(s.AppHash[:], appHash[:]) copy(s.LastResultsHash[:], tmtypes.NewResults(resp.DeliverTxs).Hash()) + lastHeaderHash := block.Header.Hash() copy(s.LastHeaderHash[:], lastHeaderHash[:]) - s.SetHeight(height) + s.SetHeight(block.Header.Height) if resp.EndBlock.ConsensusParamUpdates != nil { s.ConsensusParams.Block.MaxGas = resp.EndBlock.ConsensusParamUpdates.Block.MaxGas s.ConsensusParams.Block.MaxBytes = resp.EndBlock.ConsensusParamUpdates.Block.MaxBytes diff --git a/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go b/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go index 2ba9eee27..ac526a983 100644 --- a/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go +++ b/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package block @@ -71,7 +71,7 @@ func (_c *MockExecutorI_AddConsensusMsgs_Call) Return() *MockExecutorI_AddConsen } func (_c *MockExecutorI_AddConsensusMsgs_Call) RunAndReturn(run func(...proto.Message)) *MockExecutorI_AddConsensusMsgs_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -253,7 +253,7 @@ func (_c *MockExecutorI_ExecuteBlock_Call) RunAndReturn(run func(*types.Block) ( return _c } -// GetAppInfo provides a mock function with given fields: +// GetAppInfo provides a mock function with no fields func (_m *MockExecutorI) GetAppInfo() (*abcitypes.ResponseInfo, error) { ret := _m.Called() @@ -310,7 +310,7 @@ func (_c *MockExecutorI_GetAppInfo_Call) RunAndReturn(run func() (*abcitypes.Res return _c } -// GetConsensusMsgs provides a mock function with given fields: +// GetConsensusMsgs provides a mock function with no fields func (_m *MockExecutorI) GetConsensusMsgs() []proto.Message { ret := _m.Called() @@ -446,7 +446,7 @@ func (_c *MockExecutorI_UpdateMempoolAfterInitChain_Call) Return() *MockExecutor } func (_c *MockExecutorI_UpdateMempoolAfterInitChain_Call) RunAndReturn(run func(*types.State)) *MockExecutorI_UpdateMempoolAfterInitChain_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -498,9 +498,9 @@ func (_c *MockExecutorI_UpdateProposerFromBlock_Call) RunAndReturn(run func(*typ return _c } -// UpdateStateAfterCommit provides a mock function with given fields: s, resp, appHash, height, lastHeaderHash -func (_m *MockExecutorI) UpdateStateAfterCommit(s *types.State, resp *state.ABCIResponses, appHash []byte, height uint64, lastHeaderHash [32]byte) { - _m.Called(s, resp, appHash, height, lastHeaderHash) +// UpdateStateAfterCommit provides a mock function with given fields: s, resp, appHash, _a3 +func (_m *MockExecutorI) UpdateStateAfterCommit(s *types.State, resp *state.ABCIResponses, appHash []byte, _a3 *types.Block) { + _m.Called(s, resp, appHash, _a3) } // MockExecutorI_UpdateStateAfterCommit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateStateAfterCommit' @@ -512,15 +512,14 @@ type MockExecutorI_UpdateStateAfterCommit_Call struct { // - s *types.State // - resp *state.ABCIResponses // - appHash []byte -// - height uint64 -// - lastHeaderHash [32]byte -func (_e *MockExecutorI_Expecter) UpdateStateAfterCommit(s interface{}, resp interface{}, appHash interface{}, height interface{}, lastHeaderHash interface{}) *MockExecutorI_UpdateStateAfterCommit_Call { - return &MockExecutorI_UpdateStateAfterCommit_Call{Call: _e.mock.On("UpdateStateAfterCommit", s, resp, appHash, height, lastHeaderHash)} +// - _a3 *types.Block +func (_e *MockExecutorI_Expecter) UpdateStateAfterCommit(s interface{}, resp interface{}, appHash interface{}, _a3 interface{}) *MockExecutorI_UpdateStateAfterCommit_Call { + return &MockExecutorI_UpdateStateAfterCommit_Call{Call: _e.mock.On("UpdateStateAfterCommit", s, resp, appHash, _a3)} } -func (_c *MockExecutorI_UpdateStateAfterCommit_Call) Run(run func(s *types.State, resp *state.ABCIResponses, appHash []byte, height uint64, lastHeaderHash [32]byte)) *MockExecutorI_UpdateStateAfterCommit_Call { +func (_c *MockExecutorI_UpdateStateAfterCommit_Call) Run(run func(s *types.State, resp *state.ABCIResponses, appHash []byte, _a3 *types.Block)) *MockExecutorI_UpdateStateAfterCommit_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*types.State), args[1].(*state.ABCIResponses), args[2].([]byte), args[3].(uint64), args[4].([32]byte)) + run(args[0].(*types.State), args[1].(*state.ABCIResponses), args[2].([]byte), args[3].(*types.Block)) }) return _c } @@ -530,8 +529,8 @@ func (_c *MockExecutorI_UpdateStateAfterCommit_Call) Return() *MockExecutorI_Upd return _c } -func (_c *MockExecutorI_UpdateStateAfterCommit_Call) RunAndReturn(run func(*types.State, *state.ABCIResponses, []byte, uint64, [32]byte)) *MockExecutorI_UpdateStateAfterCommit_Call { - _c.Call.Return(run) +func (_c *MockExecutorI_UpdateStateAfterCommit_Call) RunAndReturn(run func(*types.State, *state.ABCIResponses, []byte, *types.Block)) *MockExecutorI_UpdateStateAfterCommit_Call { + _c.Run(run) return _c } @@ -565,7 +564,7 @@ func (_c *MockExecutorI_UpdateStateAfterInitChain_Call) Return() *MockExecutorI_ } func (_c *MockExecutorI_UpdateStateAfterInitChain_Call) RunAndReturn(run func(*types.State, *abcitypes.ResponseInitChain)) *MockExecutorI_UpdateStateAfterInitChain_Call { - _c.Call.Return(run) + _c.Run(run) return _c } diff --git a/mocks/github.com/dymensionxyz/dymint/block/mock_FraudHandler.go b/mocks/github.com/dymensionxyz/dymint/block/mock_FraudHandler.go index 932c51a2e..bdfefdbdf 100644 --- a/mocks/github.com/dymensionxyz/dymint/block/mock_FraudHandler.go +++ b/mocks/github.com/dymensionxyz/dymint/block/mock_FraudHandler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package block @@ -51,7 +51,7 @@ func (_c *MockFraudHandler_HandleFault_Call) Return() *MockFraudHandler_HandleFa } func (_c *MockFraudHandler_HandleFault_Call) RunAndReturn(run func(context.Context, error)) *MockFraudHandler_HandleFault_Call { - _c.Call.Return(run) + _c.Run(run) return _c } diff --git a/mocks/github.com/dymensionxyz/dymint/da/avail/mock_SubstrateApiI.go b/mocks/github.com/dymensionxyz/dymint/da/avail/mock_SubstrateApiI.go index 6a52c1df8..63d733829 100644 --- a/mocks/github.com/dymensionxyz/dymint/da/avail/mock_SubstrateApiI.go +++ b/mocks/github.com/dymensionxyz/dymint/da/avail/mock_SubstrateApiI.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package avail @@ -143,7 +143,7 @@ func (_c *MockSubstrateApiI_GetBlockHash_Call) RunAndReturn(run func(uint64) (ty return _c } -// GetBlockHashLatest provides a mock function with given fields: +// GetBlockHashLatest provides a mock function with no fields func (_m *MockSubstrateApiI) GetBlockHashLatest() (types.Hash, error) { ret := _m.Called() @@ -200,7 +200,7 @@ func (_c *MockSubstrateApiI_GetBlockHashLatest_Call) RunAndReturn(run func() (ty return _c } -// GetBlockLatest provides a mock function with given fields: +// GetBlockLatest provides a mock function with no fields func (_m *MockSubstrateApiI) GetBlockLatest() (*types.SignedBlock, error) { ret := _m.Called() @@ -846,7 +846,7 @@ func (_c *MockSubstrateApiI_GetChildStorageSizeLatest_Call) RunAndReturn(run fun return _c } -// GetFinalizedHead provides a mock function with given fields: +// GetFinalizedHead provides a mock function with no fields func (_m *MockSubstrateApiI) GetFinalizedHead() (types.Hash, error) { ret := _m.Called() @@ -961,7 +961,7 @@ func (_c *MockSubstrateApiI_GetHeader_Call) RunAndReturn(run func(types.Hash) (* return _c } -// GetHeaderLatest provides a mock function with given fields: +// GetHeaderLatest provides a mock function with no fields func (_m *MockSubstrateApiI) GetHeaderLatest() (*types.Header, error) { ret := _m.Called() @@ -1193,7 +1193,7 @@ func (_c *MockSubstrateApiI_GetMetadata_Call) RunAndReturn(run func(types.Hash) return _c } -// GetMetadataLatest provides a mock function with given fields: +// GetMetadataLatest provides a mock function with no fields func (_m *MockSubstrateApiI) GetMetadataLatest() (*types.Metadata, error) { ret := _m.Called() @@ -1308,7 +1308,7 @@ func (_c *MockSubstrateApiI_GetRuntimeVersion_Call) RunAndReturn(run func(types. return _c } -// GetRuntimeVersionLatest provides a mock function with given fields: +// GetRuntimeVersionLatest provides a mock function with no fields func (_m *MockSubstrateApiI) GetRuntimeVersionLatest() (*types.RuntimeVersion, error) { ret := _m.Called() @@ -1827,7 +1827,7 @@ func (_c *MockSubstrateApiI_GetStorageSizeLatest_Call) RunAndReturn(run func(typ return _c } -// PendingExtrinsics provides a mock function with given fields: +// PendingExtrinsics provides a mock function with no fields func (_m *MockSubstrateApiI) PendingExtrinsics() ([]types.Extrinsic, error) { ret := _m.Called() @@ -2236,7 +2236,7 @@ func (_c *MockSubstrateApiI_SubmitExtrinsic_Call) RunAndReturn(run func(types.Ex return _c } -// SubscribeFinalizedHeads provides a mock function with given fields: +// SubscribeFinalizedHeads provides a mock function with no fields func (_m *MockSubstrateApiI) SubscribeFinalizedHeads() (*chain.FinalizedHeadsSubscription, error) { ret := _m.Called() @@ -2293,7 +2293,7 @@ func (_c *MockSubstrateApiI_SubscribeFinalizedHeads_Call) RunAndReturn(run func( return _c } -// SubscribeNewHeads provides a mock function with given fields: +// SubscribeNewHeads provides a mock function with no fields func (_m *MockSubstrateApiI) SubscribeNewHeads() (*chain.NewHeadsSubscription, error) { ret := _m.Called() @@ -2350,7 +2350,7 @@ func (_c *MockSubstrateApiI_SubscribeNewHeads_Call) RunAndReturn(run func() (*ch return _c } -// SubscribeRuntimeVersion provides a mock function with given fields: +// SubscribeRuntimeVersion provides a mock function with no fields func (_m *MockSubstrateApiI) SubscribeRuntimeVersion() (*state.RuntimeVersionSubscription, error) { ret := _m.Called() diff --git a/mocks/github.com/dymensionxyz/dymint/da/celestia/types/mock_CelestiaRPCClient.go b/mocks/github.com/dymensionxyz/dymint/da/celestia/types/mock_CelestiaRPCClient.go index f80184e4f..63341e9ae 100644 --- a/mocks/github.com/dymensionxyz/dymint/da/celestia/types/mock_CelestiaRPCClient.go +++ b/mocks/github.com/dymensionxyz/dymint/da/celestia/types/mock_CelestiaRPCClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package types diff --git a/mocks/github.com/dymensionxyz/dymint/da/mock_DataAvailabilityLayerClient.go b/mocks/github.com/dymensionxyz/dymint/da/mock_DataAvailabilityLayerClient.go index 9c20b8b5c..57d740bb2 100644 --- a/mocks/github.com/dymensionxyz/dymint/da/mock_DataAvailabilityLayerClient.go +++ b/mocks/github.com/dymensionxyz/dymint/da/mock_DataAvailabilityLayerClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package da @@ -72,7 +72,7 @@ func (_c *MockDataAvailabilityLayerClient_CheckBatchAvailability_Call) RunAndRet return _c } -// GetClientType provides a mock function with given fields: +// GetClientType provides a mock function with no fields func (_m *MockDataAvailabilityLayerClient) GetClientType() da.Client { ret := _m.Called() @@ -117,7 +117,7 @@ func (_c *MockDataAvailabilityLayerClient_GetClientType_Call) RunAndReturn(run f return _c } -// GetMaxBlobSizeBytes provides a mock function with given fields: +// GetMaxBlobSizeBytes provides a mock function with no fields func (_m *MockDataAvailabilityLayerClient) GetMaxBlobSizeBytes() uint32 { ret := _m.Called() @@ -162,7 +162,7 @@ func (_c *MockDataAvailabilityLayerClient_GetMaxBlobSizeBytes_Call) RunAndReturn return _c } -// GetSignerBalance provides a mock function with given fields: +// GetSignerBalance provides a mock function with no fields func (_m *MockDataAvailabilityLayerClient) GetSignerBalance() (da.Balance, error) { ret := _m.Called() @@ -281,7 +281,7 @@ func (_c *MockDataAvailabilityLayerClient_Init_Call) RunAndReturn(run func([]byt return _c } -// Start provides a mock function with given fields: +// Start provides a mock function with no fields func (_m *MockDataAvailabilityLayerClient) Start() error { ret := _m.Called() @@ -326,7 +326,7 @@ func (_c *MockDataAvailabilityLayerClient_Start_Call) RunAndReturn(run func() er return _c } -// Stop provides a mock function with given fields: +// Stop provides a mock function with no fields func (_m *MockDataAvailabilityLayerClient) Stop() error { ret := _m.Called() @@ -417,7 +417,7 @@ func (_c *MockDataAvailabilityLayerClient_SubmitBatch_Call) RunAndReturn(run fun return _c } -// WaitForSyncing provides a mock function with given fields: +// WaitForSyncing provides a mock function with no fields func (_m *MockDataAvailabilityLayerClient) WaitForSyncing() { _m.Called() } @@ -445,7 +445,7 @@ func (_c *MockDataAvailabilityLayerClient_WaitForSyncing_Call) Return() *MockDat } func (_c *MockDataAvailabilityLayerClient_WaitForSyncing_Call) RunAndReturn(run func()) *MockDataAvailabilityLayerClient_WaitForSyncing_Call { - _c.Call.Return(run) + _c.Run(run) return _c } diff --git a/mocks/github.com/dymensionxyz/dymint/p2p/mock_StateGetter.go b/mocks/github.com/dymensionxyz/dymint/p2p/mock_StateGetter.go index 4377638cb..d336d1828 100644 --- a/mocks/github.com/dymensionxyz/dymint/p2p/mock_StateGetter.go +++ b/mocks/github.com/dymensionxyz/dymint/p2p/mock_StateGetter.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package p2p @@ -20,7 +20,7 @@ func (_m *MockStateGetter) EXPECT() *MockStateGetter_Expecter { return &MockStateGetter_Expecter{mock: &_m.Mock} } -// GetProposerPubKey provides a mock function with given fields: +// GetProposerPubKey provides a mock function with no fields func (_m *MockStateGetter) GetProposerPubKey() crypto.PubKey { ret := _m.Called() @@ -67,7 +67,7 @@ func (_c *MockStateGetter_GetProposerPubKey_Call) RunAndReturn(run func() crypto return _c } -// GetRevision provides a mock function with given fields: +// GetRevision provides a mock function with no fields func (_m *MockStateGetter) GetRevision() uint64 { ret := _m.Called() diff --git a/mocks/github.com/dymensionxyz/dymint/settlement/dymension/mock_CosmosClient.go b/mocks/github.com/dymensionxyz/dymint/settlement/dymension/mock_CosmosClient.go index ade8efe9b..d2130e1c8 100644 --- a/mocks/github.com/dymensionxyz/dymint/settlement/dymension/mock_CosmosClient.go +++ b/mocks/github.com/dymensionxyz/dymint/settlement/dymension/mock_CosmosClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package dymension @@ -106,7 +106,7 @@ func (_c *MockCosmosClient_BroadcastTx_Call) RunAndReturn(run func(string, ...ty return _c } -// Context provides a mock function with given fields: +// Context provides a mock function with no fields func (_m *MockCosmosClient) Context() client.Context { ret := _m.Called() @@ -151,7 +151,7 @@ func (_c *MockCosmosClient_Context_Call) RunAndReturn(run func() client.Context) return _c } -// EventListenerQuit provides a mock function with given fields: +// EventListenerQuit provides a mock function with no fields func (_m *MockCosmosClient) EventListenerQuit() <-chan struct{} { ret := _m.Called() @@ -314,7 +314,7 @@ func (_c *MockCosmosClient_GetBalance_Call) RunAndReturn(run func(context.Contex return _c } -// GetRollappClient provides a mock function with given fields: +// GetRollappClient provides a mock function with no fields func (_m *MockCosmosClient) GetRollappClient() rollapp.QueryClient { ret := _m.Called() @@ -361,7 +361,7 @@ func (_c *MockCosmosClient_GetRollappClient_Call) RunAndReturn(run func() rollap return _c } -// GetSequencerClient provides a mock function with given fields: +// GetSequencerClient provides a mock function with no fields func (_m *MockCosmosClient) GetSequencerClient() sequencer.QueryClient { ret := _m.Called() @@ -408,7 +408,7 @@ func (_c *MockCosmosClient_GetSequencerClient_Call) RunAndReturn(run func() sequ return _c } -// StartEventListener provides a mock function with given fields: +// StartEventListener provides a mock function with no fields func (_m *MockCosmosClient) StartEventListener() error { ret := _m.Called() @@ -453,7 +453,7 @@ func (_c *MockCosmosClient_StartEventListener_Call) RunAndReturn(run func() erro return _c } -// StopEventListener provides a mock function with given fields: +// StopEventListener provides a mock function with no fields func (_m *MockCosmosClient) StopEventListener() error { ret := _m.Called() diff --git a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go index a609b4d42..cbb1e9eb9 100644 --- a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go +++ b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package settlement @@ -28,7 +28,7 @@ func (_m *MockClientI) EXPECT() *MockClientI_Expecter { return &MockClientI_Expecter{mock: &_m.Mock} } -// GetAllSequencers provides a mock function with given fields: +// GetAllSequencers provides a mock function with no fields func (_m *MockClientI) GetAllSequencers() ([]types.Sequencer, error) { ret := _m.Called() @@ -201,7 +201,7 @@ func (_c *MockClientI_GetBatchAtIndex_Call) RunAndReturn(run func(uint64) (*sett return _c } -// GetBondedSequencers provides a mock function with given fields: +// GetBondedSequencers provides a mock function with no fields func (_m *MockClientI) GetBondedSequencers() ([]types.Sequencer, error) { ret := _m.Called() @@ -258,7 +258,7 @@ func (_c *MockClientI_GetBondedSequencers_Call) RunAndReturn(run func() ([]types return _c } -// GetLatestBatch provides a mock function with given fields: +// GetLatestBatch provides a mock function with no fields func (_m *MockClientI) GetLatestBatch() (*settlement.ResultRetrieveBatch, error) { ret := _m.Called() @@ -315,7 +315,7 @@ func (_c *MockClientI_GetLatestBatch_Call) RunAndReturn(run func() (*settlement. return _c } -// GetLatestFinalizedHeight provides a mock function with given fields: +// GetLatestFinalizedHeight provides a mock function with no fields func (_m *MockClientI) GetLatestFinalizedHeight() (uint64, error) { ret := _m.Called() @@ -370,7 +370,7 @@ func (_c *MockClientI_GetLatestFinalizedHeight_Call) RunAndReturn(run func() (ui return _c } -// GetLatestHeight provides a mock function with given fields: +// GetLatestHeight provides a mock function with no fields func (_m *MockClientI) GetLatestHeight() (uint64, error) { ret := _m.Called() @@ -425,7 +425,7 @@ func (_c *MockClientI_GetLatestHeight_Call) RunAndReturn(run func() (uint64, err return _c } -// GetNextProposer provides a mock function with given fields: +// GetNextProposer provides a mock function with no fields func (_m *MockClientI) GetNextProposer() (*types.Sequencer, error) { ret := _m.Called() @@ -482,7 +482,7 @@ func (_c *MockClientI_GetNextProposer_Call) RunAndReturn(run func() (*types.Sequ return _c } -// GetObsoleteDrs provides a mock function with given fields: +// GetObsoleteDrs provides a mock function with no fields func (_m *MockClientI) GetObsoleteDrs() ([]uint32, error) { ret := _m.Called() @@ -597,7 +597,7 @@ func (_c *MockClientI_GetProposerAtHeight_Call) RunAndReturn(run func(int64) (*t return _c } -// GetRollapp provides a mock function with given fields: +// GetRollapp provides a mock function with no fields func (_m *MockClientI) GetRollapp() (*types.Rollapp, error) { ret := _m.Called() @@ -710,7 +710,7 @@ func (_c *MockClientI_GetSequencerByAddress_Call) RunAndReturn(run func(string) return _c } -// GetSignerBalance provides a mock function with given fields: +// GetSignerBalance provides a mock function with no fields func (_m *MockClientI) GetSignerBalance() (types.Balance, error) { ret := _m.Called() @@ -829,7 +829,7 @@ func (_c *MockClientI_Init_Call) RunAndReturn(run func(settlement.Config, string return _c } -// Start provides a mock function with given fields: +// Start provides a mock function with no fields func (_m *MockClientI) Start() error { ret := _m.Called() @@ -874,7 +874,7 @@ func (_c *MockClientI_Start_Call) RunAndReturn(run func() error) *MockClientI_St return _c } -// Stop provides a mock function with given fields: +// Stop provides a mock function with no fields func (_m *MockClientI) Stop() error { ret := _m.Called() diff --git a/mocks/github.com/dymensionxyz/dymint/store/mock_Store.go b/mocks/github.com/dymensionxyz/dymint/store/mock_Store.go index 5035e135f..90e8526cf 100644 --- a/mocks/github.com/dymensionxyz/dymint/store/mock_Store.go +++ b/mocks/github.com/dymensionxyz/dymint/store/mock_Store.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package store @@ -26,7 +26,7 @@ func (_m *MockStore) EXPECT() *MockStore_Expecter { return &MockStore_Expecter{mock: &_m.Mock} } -// Close provides a mock function with given fields: +// Close provides a mock function with no fields func (_m *MockStore) Close() error { ret := _m.Called() @@ -71,7 +71,7 @@ func (_c *MockStore_Close_Call) RunAndReturn(run func() error) *MockStore_Close_ return _c } -// LoadBaseHeight provides a mock function with given fields: +// LoadBaseHeight provides a mock function with no fields func (_m *MockStore) LoadBaseHeight() (uint64, error) { ret := _m.Called() @@ -412,7 +412,7 @@ func (_c *MockStore_LoadBlockSource_Call) RunAndReturn(run func(uint64) (types.B return _c } -// LoadBlockSyncBaseHeight provides a mock function with given fields: +// LoadBlockSyncBaseHeight provides a mock function with no fields func (_m *MockStore) LoadBlockSyncBaseHeight() (uint64, error) { ret := _m.Called() @@ -639,7 +639,7 @@ func (_c *MockStore_LoadDRSVersion_Call) RunAndReturn(run func(uint64) (uint32, return _c } -// LoadIndexerBaseHeight provides a mock function with given fields: +// LoadIndexerBaseHeight provides a mock function with no fields func (_m *MockStore) LoadIndexerBaseHeight() (uint64, error) { ret := _m.Called() @@ -694,7 +694,7 @@ func (_c *MockStore_LoadIndexerBaseHeight_Call) RunAndReturn(run func() (uint64, return _c } -// LoadLastBlockSequencerSet provides a mock function with given fields: +// LoadLastBlockSequencerSet provides a mock function with no fields func (_m *MockStore) LoadLastBlockSequencerSet() (types.Sequencers, error) { ret := _m.Called() @@ -807,7 +807,7 @@ func (_c *MockStore_LoadProposer_Call) RunAndReturn(run func(uint64) (types.Sequ return _c } -// LoadState provides a mock function with given fields: +// LoadState provides a mock function with no fields func (_m *MockStore) LoadState() (*types.State, error) { ret := _m.Called() @@ -864,7 +864,7 @@ func (_c *MockStore_LoadState_Call) RunAndReturn(run func() (*types.State, error return _c } -// LoadValidationHeight provides a mock function with given fields: +// LoadValidationHeight provides a mock function with no fields func (_m *MockStore) LoadValidationHeight() (uint64, error) { ret := _m.Called() @@ -919,7 +919,7 @@ func (_c *MockStore_LoadValidationHeight_Call) RunAndReturn(run func() (uint64, return _c } -// NewBatch provides a mock function with given fields: +// NewBatch provides a mock function with no fields func (_m *MockStore) NewBatch() store.KVBatch { ret := _m.Called() @@ -966,6 +966,64 @@ func (_c *MockStore_NewBatch_Call) RunAndReturn(run func() store.KVBatch) *MockS return _c } +// PruneHeights provides a mock function with given fields: from, to, logger +func (_m *MockStore) PruneHeights(from uint64, to uint64, logger types.Logger) (uint64, error) { + ret := _m.Called(from, to, logger) + + if len(ret) == 0 { + panic("no return value specified for PruneHeights") + } + + var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(uint64, uint64, types.Logger) (uint64, error)); ok { + return rf(from, to, logger) + } + if rf, ok := ret.Get(0).(func(uint64, uint64, types.Logger) uint64); ok { + r0 = rf(from, to, logger) + } else { + r0 = ret.Get(0).(uint64) + } + + if rf, ok := ret.Get(1).(func(uint64, uint64, types.Logger) error); ok { + r1 = rf(from, to, logger) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockStore_PruneHeights_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PruneHeights' +type MockStore_PruneHeights_Call struct { + *mock.Call +} + +// PruneHeights is a helper method to define mock.On call +// - from uint64 +// - to uint64 +// - logger types.Logger +func (_e *MockStore_Expecter) PruneHeights(from interface{}, to interface{}, logger interface{}) *MockStore_PruneHeights_Call { + return &MockStore_PruneHeights_Call{Call: _e.mock.On("PruneHeights", from, to, logger)} +} + +func (_c *MockStore_PruneHeights_Call) Run(run func(from uint64, to uint64, logger types.Logger)) *MockStore_PruneHeights_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64), args[1].(uint64), args[2].(types.Logger)) + }) + return _c +} + +func (_c *MockStore_PruneHeights_Call) Return(_a0 uint64, _a1 error) *MockStore_PruneHeights_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockStore_PruneHeights_Call) RunAndReturn(run func(uint64, uint64, types.Logger) (uint64, error)) *MockStore_PruneHeights_Call { + _c.Call.Return(run) + return _c +} + // PruneStore provides a mock function with given fields: to, logger func (_m *MockStore) PruneStore(to uint64, logger types.Logger) (uint64, error) { ret := _m.Called(to, logger) diff --git a/mocks/github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp/mock_QueryClient.go b/mocks/github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp/mock_QueryClient.go index 80d7ab986..a9d0c6aa7 100644 --- a/mocks/github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp/mock_QueryClient.go +++ b/mocks/github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp/mock_QueryClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package rollapp diff --git a/mocks/github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/sequencer/mock_QueryClient.go b/mocks/github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/sequencer/mock_QueryClient.go index af5bcaf4b..5922ea573 100644 --- a/mocks/github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/sequencer/mock_QueryClient.go +++ b/mocks/github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/sequencer/mock_QueryClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package sequencer diff --git a/mocks/github.com/tendermint/tendermint/abci/types/mock_Application.go b/mocks/github.com/tendermint/tendermint/abci/types/mock_Application.go index 7393ef94e..8edab35fb 100644 --- a/mocks/github.com/tendermint/tendermint/abci/types/mock_Application.go +++ b/mocks/github.com/tendermint/tendermint/abci/types/mock_Application.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package types @@ -158,7 +158,7 @@ func (_c *MockApplication_CheckTx_Call) RunAndReturn(run func(types.RequestCheck return _c } -// Commit provides a mock function with given fields: +// Commit provides a mock function with no fields func (_m *MockApplication) Commit() types.ResponseCommit { ret := _m.Called() diff --git a/mocks/github.com/tendermint/tendermint/proxy/mock_AppConnConsensus.go b/mocks/github.com/tendermint/tendermint/proxy/mock_AppConnConsensus.go index 9ec6b2d18..1e7be7685 100644 --- a/mocks/github.com/tendermint/tendermint/proxy/mock_AppConnConsensus.go +++ b/mocks/github.com/tendermint/tendermint/proxy/mock_AppConnConsensus.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package proxy @@ -80,7 +80,7 @@ func (_c *MockAppConnConsensus_BeginBlockSync_Call) RunAndReturn(run func(types. return _c } -// CommitSync provides a mock function with given fields: +// CommitSync provides a mock function with no fields func (_m *MockAppConnConsensus) CommitSync() (*types.ResponseCommit, error) { ret := _m.Called() @@ -243,7 +243,7 @@ func (_c *MockAppConnConsensus_EndBlockSync_Call) RunAndReturn(run func(types.Re return _c } -// Error provides a mock function with given fields: +// Error provides a mock function with no fields func (_m *MockAppConnConsensus) Error() error { ret := _m.Called() @@ -375,7 +375,7 @@ func (_c *MockAppConnConsensus_SetResponseCallback_Call) Return() *MockAppConnCo } func (_c *MockAppConnConsensus_SetResponseCallback_Call) RunAndReturn(run func(abcicli.Callback)) *MockAppConnConsensus_SetResponseCallback_Call { - _c.Call.Return(run) + _c.Run(run) return _c } diff --git a/mocks/github.com/tendermint/tendermint/proxy/mock_AppConns.go b/mocks/github.com/tendermint/tendermint/proxy/mock_AppConns.go index affc90a4e..e8ca892e0 100644 --- a/mocks/github.com/tendermint/tendermint/proxy/mock_AppConns.go +++ b/mocks/github.com/tendermint/tendermint/proxy/mock_AppConns.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.50.2. DO NOT EDIT. package proxy @@ -22,7 +22,7 @@ func (_m *MockAppConns) EXPECT() *MockAppConns_Expecter { return &MockAppConns_Expecter{mock: &_m.Mock} } -// Consensus provides a mock function with given fields: +// Consensus provides a mock function with no fields func (_m *MockAppConns) Consensus() proxy.AppConnConsensus { ret := _m.Called() @@ -69,7 +69,7 @@ func (_c *MockAppConns_Consensus_Call) RunAndReturn(run func() proxy.AppConnCons return _c } -// IsRunning provides a mock function with given fields: +// IsRunning provides a mock function with no fields func (_m *MockAppConns) IsRunning() bool { ret := _m.Called() @@ -114,7 +114,7 @@ func (_c *MockAppConns_IsRunning_Call) RunAndReturn(run func() bool) *MockAppCon return _c } -// Mempool provides a mock function with given fields: +// Mempool provides a mock function with no fields func (_m *MockAppConns) Mempool() proxy.AppConnMempool { ret := _m.Called() @@ -161,7 +161,7 @@ func (_c *MockAppConns_Mempool_Call) RunAndReturn(run func() proxy.AppConnMempoo return _c } -// OnReset provides a mock function with given fields: +// OnReset provides a mock function with no fields func (_m *MockAppConns) OnReset() error { ret := _m.Called() @@ -206,7 +206,7 @@ func (_c *MockAppConns_OnReset_Call) RunAndReturn(run func() error) *MockAppConn return _c } -// OnStart provides a mock function with given fields: +// OnStart provides a mock function with no fields func (_m *MockAppConns) OnStart() error { ret := _m.Called() @@ -251,7 +251,7 @@ func (_c *MockAppConns_OnStart_Call) RunAndReturn(run func() error) *MockAppConn return _c } -// OnStop provides a mock function with given fields: +// OnStop provides a mock function with no fields func (_m *MockAppConns) OnStop() { _m.Called() } @@ -279,11 +279,11 @@ func (_c *MockAppConns_OnStop_Call) Return() *MockAppConns_OnStop_Call { } func (_c *MockAppConns_OnStop_Call) RunAndReturn(run func()) *MockAppConns_OnStop_Call { - _c.Call.Return(run) + _c.Run(run) return _c } -// Query provides a mock function with given fields: +// Query provides a mock function with no fields func (_m *MockAppConns) Query() proxy.AppConnQuery { ret := _m.Called() @@ -330,7 +330,7 @@ func (_c *MockAppConns_Query_Call) RunAndReturn(run func() proxy.AppConnQuery) * return _c } -// Quit provides a mock function with given fields: +// Quit provides a mock function with no fields func (_m *MockAppConns) Quit() <-chan struct{} { ret := _m.Called() @@ -377,7 +377,7 @@ func (_c *MockAppConns_Quit_Call) RunAndReturn(run func() <-chan struct{}) *Mock return _c } -// Reset provides a mock function with given fields: +// Reset provides a mock function with no fields func (_m *MockAppConns) Reset() error { ret := _m.Called() @@ -451,11 +451,11 @@ func (_c *MockAppConns_SetLogger_Call) Return() *MockAppConns_SetLogger_Call { } func (_c *MockAppConns_SetLogger_Call) RunAndReturn(run func(log.Logger)) *MockAppConns_SetLogger_Call { - _c.Call.Return(run) + _c.Run(run) return _c } -// Snapshot provides a mock function with given fields: +// Snapshot provides a mock function with no fields func (_m *MockAppConns) Snapshot() proxy.AppConnSnapshot { ret := _m.Called() @@ -502,7 +502,7 @@ func (_c *MockAppConns_Snapshot_Call) RunAndReturn(run func() proxy.AppConnSnaps return _c } -// Start provides a mock function with given fields: +// Start provides a mock function with no fields func (_m *MockAppConns) Start() error { ret := _m.Called() @@ -547,7 +547,7 @@ func (_c *MockAppConns_Start_Call) RunAndReturn(run func() error) *MockAppConns_ return _c } -// Stop provides a mock function with given fields: +// Stop provides a mock function with no fields func (_m *MockAppConns) Stop() error { ret := _m.Called() @@ -592,7 +592,7 @@ func (_c *MockAppConns_Stop_Call) RunAndReturn(run func() error) *MockAppConns_S return _c } -// String provides a mock function with given fields: +// String provides a mock function with no fields func (_m *MockAppConns) String() string { ret := _m.Called() diff --git a/store/pruning.go b/store/pruning.go index 5940f8ae9..cac5dca6b 100644 --- a/store/pruning.go +++ b/store/pruning.go @@ -17,7 +17,7 @@ func (s *DefaultStore) PruneStore(to uint64, logger types.Logger) (uint64, error } else if err != nil { return pruned, err } - pruned, err = s.pruneHeights(from, to, logger) + pruned, err = s.PruneHeights(from, to, logger) if err != nil { return pruned, fmt.Errorf("pruning blocks. from: %d to: %d: err:%w", from, to, err) } @@ -30,7 +30,7 @@ func (s *DefaultStore) PruneStore(to uint64, logger types.Logger) (uint64, error } // pruneHeights prunes all store entries that are stored along blocks (blocks,commit,proposer, etc) -func (s *DefaultStore) pruneHeights(from, to uint64, logger types.Logger) (uint64, error) { +func (s *DefaultStore) PruneHeights(from, to uint64, logger types.Logger) (uint64, error) { pruneBlocks := func(batch KVBatch, height uint64) error { hash, err := s.loadHashFromIndex(height) if err != nil { diff --git a/store/storeIface.go b/store/storeIface.go index 8220b25ad..bcb8019bf 100644 --- a/store/storeIface.go +++ b/store/storeIface.go @@ -76,6 +76,8 @@ type Store interface { PruneStore(to uint64, logger types.Logger) (uint64, error) + PruneHeights(from, to uint64, logger types.Logger) (uint64, error) + SaveBlockCid(height uint64, cid cid.Cid, batch KVBatch) (KVBatch, error) LoadBlockCid(height uint64) (cid.Cid, error)