From 5de7192a93fc927789a92c92785e4ab941f6f560 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Fri, 6 Sep 2024 16:04:03 +0200 Subject: [PATCH] fix(manager): use block params from consensus param (#1042) --- block/executor.go | 17 ++- block/executor_test.go | 37 ++--- block/initchain.go | 1 - block/manager.go | 16 +- block/manager_test.go | 108 +++++++------ block/production_test.go | 36 +++-- block/pruning_test.go | 37 ++--- block/state.go | 35 +++-- block/submit_test.go | 72 +++++---- cmd/dymint/commands/init.go | 2 +- go.mod | 9 +- go.sum | 36 +++-- p2p/validator_test.go | 8 +- proto/types/dymint/state.proto | 16 +- rpc/client/client_test.go | 18 ++- rpc/json/service_test.go | 20 ++- testutil/node.go | 19 ++- testutil/types.go | 14 +- types/pb/dymint/state.pb.go | 266 +++++++++++++++------------------ types/serialization.go | 2 + types/serialization_test.go | 36 ++++- types/state.go | 16 +- 22 files changed, 442 insertions(+), 379 deletions(-) diff --git a/block/executor.go b/block/executor.go index 14bc9315f..28e0fcec4 100644 --- a/block/executor.go +++ b/block/executor.go @@ -16,6 +16,9 @@ import ( "github.com/dymensionxyz/dymint/types" ) +// default minimum block max size allowed. not specific reason to set it to 10K, but we need to avoid no transactions can be included in a block. +const minBlockMaxBytes = 10000 + // Executor creates and applies blocks and maintains state. type Executor struct { localAddress []byte @@ -60,6 +63,7 @@ func (e *Executor) InitChain(genesis *tmtypes.GenesisDoc, valset []*tmtypes.Vali Power: validator.VotingPower, }) } + params := genesis.ConsensusParams return e.proxyAppConsensusConn.InitChainSync(abci.RequestInitChain{ @@ -81,8 +85,7 @@ func (e *Executor) InitChain(genesis *tmtypes.GenesisDoc, valset []*tmtypes.Vali Version: &tmproto.VersionParams{ AppVersion: params.Version.AppVersion, }, - }, - Validators: valUpdates, + }, Validators: valUpdates, AppStateBytes: genesis.AppState, InitialHeight: genesis.InitialHeight, }) @@ -90,10 +93,8 @@ func (e *Executor) InitChain(genesis *tmtypes.GenesisDoc, valset []*tmtypes.Vali // CreateBlock reaps transactions from mempool and builds a block. func (e *Executor) CreateBlock(height uint64, lastCommit *types.Commit, lastHeaderHash, nextSeqHash [32]byte, state *types.State, maxBlockDataSizeBytes uint64) *types.Block { - if state.ConsensusParams.Blockmaxsize > 0 { - maxBlockDataSizeBytes = min(maxBlockDataSizeBytes, uint64(state.ConsensusParams.Blockmaxsize)) - } - mempoolTxs := e.mempool.ReapMaxBytesMaxGas(int64(maxBlockDataSizeBytes), state.ConsensusParams.Blockmaxgas) + maxBlockDataSizeBytes = min(maxBlockDataSizeBytes, uint64(max(minBlockMaxBytes, state.ConsensusParams.Block.MaxBytes))) + mempoolTxs := e.mempool.ReapMaxBytesMaxGas(int64(maxBlockDataSizeBytes), state.ConsensusParams.Block.MaxGas) block := &types.Block{ Header: types.Header{ @@ -160,8 +161,8 @@ func (e *Executor) commit(state *types.State, block *types.Block, deliverTxs []* return nil, 0, err } - maxBytes := state.ConsensusParams.Blockmaxsize - maxGas := state.ConsensusParams.Blockmaxgas + maxBytes := state.ConsensusParams.Block.MaxBytes + maxGas := state.ConsensusParams.Block.MaxGas err = e.mempool.Update(int64(block.Header.Height), fromDymintTxs(block.Data.Txs), deliverTxs) if err != nil { return nil, 0, err diff --git a/block/executor_test.go b/block/executor_test.go index 865561cc3..6b1a7786e 100644 --- a/block/executor_test.go +++ b/block/executor_test.go @@ -7,7 +7,6 @@ import ( "time" "github.com/dymensionxyz/dymint/block" - "github.com/dymensionxyz/dymint/types/pb/dymint" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -61,11 +60,8 @@ func TestCreateBlock(t *testing.T) { // Init state state := &types.State{} state.Sequencers.SetProposer(types.NewSequencerFromValidator(*tmtypes.NewValidator(tmPubKey, 1))) - state.ConsensusParams = dymint.RollappConsensusParams{ - Blockmaxsize: int64(maxBytes), - Blockmaxgas: 100000, - } - + state.ConsensusParams.Block.MaxBytes = int64(maxBytes) + state.ConsensusParams.Block.MaxGas = 100000 // empty block block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.Sequencers.ProposerHash()[:]), state, maxBytes) require.NotNil(block) @@ -103,11 +99,13 @@ func TestApplyBlock(t *testing.T) { app.On("DeliverTx", mock.Anything).Return(abci.ResponseDeliverTx{}) app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "celestia", - Commit: "abcde", + Da: "celestia", + Version: "abcde", + }, + ConsensusParamUpdates: &abci.ConsensusParams{ Block: &abci.BlockParams{ - MaxBytes: 100, MaxGas: 100, + MaxBytes: 100, }, }, }) @@ -167,13 +165,10 @@ func TestApplyBlock(t *testing.T) { state.Sequencers.SetProposer(types.NewSequencerFromValidator(*tmtypes.NewValidator(tmPubKey, 1))) state.InitialHeight = 1 state.SetHeight(0) - maxBytes := uint64(1000) - state.ConsensusParams = dymint.RollappConsensusParams{ - Blockmaxgas: 100000, - Blockmaxsize: int64(maxBytes), - Da: "mock", - Commit: "", - } + maxBytes := uint64(10000) + state.ConsensusParams.Block.MaxBytes = int64(maxBytes) + state.ConsensusParams.Block.MaxGas = 100000 + state.RollappParams.Da = "mock" // Create first block with one Tx from mempool _ = mpool.CheckTx([]byte{1, 2, 3, 4}, func(r *abci.Response) {}, mempool.TxInfo{}) @@ -212,7 +207,7 @@ func TestApplyBlock(t *testing.T) { require.NoError(mpool.CheckTx([]byte{0, 1, 2, 3, 4}, func(r *abci.Response) {}, mempool.TxInfo{})) require.NoError(mpool.CheckTx([]byte{5, 6, 7, 8, 9}, func(r *abci.Response) {}, mempool.TxInfo{})) require.NoError(mpool.CheckTx([]byte{1, 2, 3, 4, 5}, func(r *abci.Response) {}, mempool.TxInfo{})) - require.NoError(mpool.CheckTx(make([]byte, 90), func(r *abci.Response) {}, mempool.TxInfo{})) + require.NoError(mpool.CheckTx(make([]byte, 9990), func(r *abci.Response) {}, mempool.TxInfo{})) block = executor.CreateBlock(2, commit, [32]byte{}, [32]byte(state.Sequencers.ProposerHash()), state, maxBytes) require.NotNil(block) assert.Equal(uint64(2), block.Header.Height) @@ -258,10 +253,10 @@ func TestApplyBlock(t *testing.T) { assert.Equal(uint64(2), state.Height()) // check rollapp params update - assert.Equal(state.ConsensusParams.Da, "celestia") - assert.Equal(state.ConsensusParams.Commit, "abcde") - assert.Equal(state.ConsensusParams.Blockmaxsize, int64(100)) - assert.Equal(state.ConsensusParams.Blockmaxgas, int64(100)) + assert.Equal(state.RollappParams.Da, "celestia") + assert.Equal(state.RollappParams.Version, "abcde") + assert.Equal(state.ConsensusParams.Block.MaxBytes, int64(100)) + assert.Equal(state.ConsensusParams.Block.MaxGas, int64(100)) // wait for at least 4 Tx events, for up to 3 second. // 3 seconds is a fail-scenario only diff --git a/block/initchain.go b/block/initchain.go index c068d198e..224ae8cf1 100644 --- a/block/initchain.go +++ b/block/initchain.go @@ -27,6 +27,5 @@ func (m *Manager) RunInitChain(ctx context.Context) error { if _, err := m.Store.SaveState(m.State, nil); err != nil { return err } - return nil } diff --git a/block/manager.go b/block/manager.go index 1b68d7261..eb260fe6e 100644 --- a/block/manager.go +++ b/block/manager.go @@ -289,20 +289,16 @@ func (m *Manager) UpdateTargetHeight(h uint64) { // ValidateConfigWithRollappParams checks the configuration params are consistent with the params in the dymint state (e.g. DA and version) func (m *Manager) ValidateConfigWithRollappParams() error { - if version.Commit != m.State.ConsensusParams.Commit { - return fmt.Errorf("binary version mismatch. rollapp param: %s binary used:%s", version.Commit, m.State.ConsensusParams.Commit) + if version.Commit != m.State.RollappParams.Version { + return fmt.Errorf("binary version mismatch. rollapp param: %s binary used:%s", m.State.RollappParams.Version, version.Commit) } - if da.Client(m.State.ConsensusParams.Da) != m.DAClient.GetClientType() { - return fmt.Errorf("da client mismatch. rollapp param: %s da configured: %s", m.DAClient.GetClientType(), m.State.ConsensusParams.Da) + if da.Client(m.State.RollappParams.Da) != m.DAClient.GetClientType() { + return fmt.Errorf("da client mismatch. rollapp param: %s da configured: %s", m.State.RollappParams.Da, m.DAClient.GetClientType()) } if m.Conf.BatchSubmitBytes > uint64(m.DAClient.GetMaxBlobSizeBytes()) { - return fmt.Errorf("batch size above limit %d: DA %s", m.DAClient.GetMaxBlobSizeBytes(), m.DAClient.GetClientType()) - } - - if m.State.ConsensusParams.Blockmaxsize > int64(m.DAClient.GetMaxBlobSizeBytes()) { - return fmt.Errorf("max block size above limit: %d: DA: %s", int64(m.DAClient.GetMaxBlobSizeBytes()), m.DAClient.GetClientType()) + return fmt.Errorf("batch size above limit: batch size: %d limit: %d: DA %s", m.Conf.BatchSubmitBytes, m.DAClient.GetMaxBlobSizeBytes(), m.DAClient.GetClientType()) } return nil @@ -310,7 +306,7 @@ func (m *Manager) ValidateConfigWithRollappParams() error { // setDA initializes DA client in blockmanager according to DA type set in genesis or stored in state func (m *Manager) setDA(daconfig string, dalcKV store.KV, logger log.Logger) error { - daLayer := m.State.ConsensusParams.Da + daLayer := m.State.RollappParams.Da dalc := registry.GetClient(daLayer) if dalc == nil { return fmt.Errorf("get data availability client named '%s'", daLayer) diff --git a/block/manager_test.go b/block/manager_test.go index 074b39364..0fcd6c1f4 100644 --- a/block/manager_test.go +++ b/block/manager_test.go @@ -128,14 +128,18 @@ func TestInitialState(t *testing.T) { func TestProduceOnlyAfterSynced(t *testing.T) { // Init app app := testutil.GetAppMock(testutil.EndBlock) - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 500000, - MaxGas: 40000000, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, }, - }}) + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 40000000, + MaxBytes: 500000, + }, + }, + }) // Create proxy app clientCreator := proxy.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(clientCreator) @@ -207,14 +211,18 @@ func TestProduceNewBlock(t *testing.T) { app := testutil.GetAppMock(testutil.Commit, testutil.EndBlock) commitHash := [32]byte{1} app.On("Commit", mock.Anything).Return(abci.ResponseCommit{Data: commitHash[:]}) - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 500000, - MaxGas: 40000000, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, + }, + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 40000000, + MaxBytes: 500000, + }, }, - }}) + }) // Create proxy app clientCreator := proxy.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(clientCreator) @@ -236,14 +244,18 @@ func TestProducePendingBlock(t *testing.T) { app := testutil.GetAppMock(testutil.Commit, testutil.EndBlock) commitHash := [32]byte{1} app.On("Commit", mock.Anything).Return(abci.ResponseCommit{Data: commitHash[:]}) - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 500000, - MaxGas: 40000000, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, }, - }}) + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 40000000, + MaxBytes: 500000, + }, + }, + }) // Create proxy app clientCreator := proxy.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(clientCreator) @@ -346,14 +358,18 @@ func TestProduceBlockFailAfterCommit(t *testing.T) { LastBlockHeight: tc.LastAppBlockHeight, LastBlockAppHash: tc.LastAppCommitHash[:], }) - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 500000, - MaxGas: 40000000, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, + }, + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 40000000, + MaxBytes: 500000, + }, }, - }}) + }) mockStore.ShouldFailUpdateStateWithBatch = tc.shoudFailOnSaveState _, _, _ = manager.ProduceApplyGossipBlock(context.Background(), true) storeState, err := manager.Store.LoadState() @@ -374,14 +390,18 @@ func TestCreateNextDABatchWithBytesLimit(t *testing.T) { assert := assert.New(t) require := require.New(t) app := testutil.GetAppMock(testutil.EndBlock) - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 500000, - MaxGas: 40000000, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, + }, + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 40000000, + MaxBytes: 500000, + }, }, - }}) + }) // Create proxy app clientCreator := proxy.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(clientCreator) @@ -452,14 +472,18 @@ func TestDAFetch(t *testing.T) { require := require.New(t) // Setup app app := testutil.GetAppMock(testutil.Info, testutil.Commit, testutil.EndBlock) - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 500000, - MaxGas: 40000000, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, + }, + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 40000000, + MaxBytes: 500000, + }, }, - }}) + }) // Create proxy app clientCreator := proxy.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(clientCreator) diff --git a/block/production_test.go b/block/production_test.go index 85baefeba..77a659f31 100644 --- a/block/production_test.go +++ b/block/production_test.go @@ -37,14 +37,18 @@ func TestCreateEmptyBlocksEnableDisable(t *testing.T) { assert := assert.New(t) require := require.New(t) app := testutil.GetAppMock(testutil.EndBlock) - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 500000, - MaxGas: 40000000, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, }, - }}) + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 40000000, + MaxBytes: 500000, + }, + }, + }) // Create proxy app clientCreator := proxy.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(clientCreator) @@ -197,14 +201,18 @@ func TestStopBlockProduction(t *testing.T) { require := require.New(t) app := testutil.GetAppMock(testutil.EndBlock) - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 500000, - MaxGas: 40000000, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, + }, + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 40000000, + MaxBytes: 500000, + }, }, - }}) + }) // Create proxy app clientCreator := proxy.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(clientCreator) diff --git a/block/pruning_test.go b/block/pruning_test.go index b3f81e9bb..6879a6d96 100644 --- a/block/pruning_test.go +++ b/block/pruning_test.go @@ -1,31 +1,20 @@ package block_test -import ( - "context" - "testing" - - "github.com/dymensionxyz/dymint/da" - "github.com/dymensionxyz/dymint/testutil" - "github.com/dymensionxyz/dymint/version" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/libs/log" - "github.com/tendermint/tendermint/proxy" -) - -func TestPruningRetainHeight(t *testing.T) { +/*func TestPruningRetainHeight(t *testing.T) { require := require.New(t) app := testutil.GetAppMock() - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 500000, - MaxGas: 40000000, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, + }, + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxBytes: 500000, + MaxGas: 40000000, + }, }, - }}) + }) ctx := context.Background() // Create proxy app clientCreator := proxy.NewLocalClientCreator(app) @@ -69,4 +58,4 @@ func TestPruningRetainHeight(t *testing.T) { err = manager.PruneBlocks(validRetainHeight) require.NoError(err) -} +}*/ diff --git a/block/state.go b/block/state.go index 202268bee..0d84ad99f 100644 --- a/block/state.go +++ b/block/state.go @@ -59,15 +59,15 @@ func NewStateFromGenesis(genDoc *tmtypes.GenesisDoc) (*types.State, error) { Version: InitStateVersion, ChainID: genDoc.ChainID, - InitialHeight: uint64(genDoc.InitialHeight), - BaseHeight: uint64(genDoc.InitialHeight), - + InitialHeight: uint64(genDoc.InitialHeight), + BaseHeight: uint64(genDoc.InitialHeight), + ConsensusParams: *genDoc.ConsensusParams, LastHeightConsensusParamsChanged: genDoc.InitialHeight, } s.SetHeight(0) copy(s.AppHash[:], genDoc.AppHash) - err = s.SetConsensusParamsFromGenesis(genDoc.AppState) + err = s.SetRollappParamsFromGenesis(genDoc.AppState) if err != nil { return nil, fmt.Errorf("in genesis doc: %w", err) } @@ -90,6 +90,7 @@ func (m *Manager) UpdateStateFromApp() error { // update the state with the app hashes created on the app commit m.Executor.UpdateStateAfterCommit(m.State, resp, proxyAppInfo.LastBlockAppHash, appHeight) + return nil } @@ -100,14 +101,20 @@ func (e *Executor) UpdateStateAfterInitChain(s *types.State, res *abci.ResponseI if len(res.AppHash) > 0 { copy(s.AppHash[:], res.AppHash) } - + if res.ConsensusParams != nil { + params := res.ConsensusParams + if params.Block != nil { + s.ConsensusParams.Block.MaxBytes = params.Block.MaxBytes + s.ConsensusParams.Block.MaxGas = params.Block.MaxGas + } + } // We update the last results hash with the empty hash, to conform with RFC-6962. copy(s.LastResultsHash[:], merkle.HashFromByteSlices(nil)) } func (e *Executor) UpdateMempoolAfterInitChain(s *types.State) { - e.mempool.SetPreCheckFn(mempool.PreCheckMaxBytes(s.ConsensusParams.Blockmaxsize)) - e.mempool.SetPostCheckFn(mempool.PostCheckMaxGas(s.ConsensusParams.Blockmaxgas)) + e.mempool.SetPreCheckFn(mempool.PreCheckMaxBytes(s.ConsensusParams.Block.MaxBytes)) + e.mempool.SetPostCheckFn(mempool.PostCheckMaxGas(s.ConsensusParams.Block.MaxGas)) } // UpdateStateAfterCommit updates the state with the app hash and last results hash @@ -117,14 +124,14 @@ func (e *Executor) UpdateStateAfterCommit(s *types.State, resp *tmstate.ABCIResp s.SetHeight(height) - if resp.EndBlock.RollappConsensusParamUpdates == nil { - return + if resp.EndBlock.ConsensusParamUpdates != nil { + s.ConsensusParams.Block.MaxGas = resp.EndBlock.ConsensusParamUpdates.Block.MaxGas + s.ConsensusParams.Block.MaxBytes = resp.EndBlock.ConsensusParamUpdates.Block.MaxBytes + } + if resp.EndBlock.RollappConsensusParamUpdates != nil { + s.RollappParams.Da = resp.EndBlock.RollappConsensusParamUpdates.Da + s.RollappParams.Version = resp.EndBlock.RollappConsensusParamUpdates.Version } - - s.ConsensusParams.Blockmaxsize = resp.EndBlock.RollappConsensusParamUpdates.Block.MaxBytes - s.ConsensusParams.Blockmaxgas = resp.EndBlock.RollappConsensusParamUpdates.Block.MaxGas - s.ConsensusParams.Da = resp.EndBlock.RollappConsensusParamUpdates.Da - s.ConsensusParams.Commit = resp.EndBlock.RollappConsensusParamUpdates.Commit } // UpdateProposerFromBlock updates the proposer from the block diff --git a/block/submit_test.go b/block/submit_test.go index 4eff49548..65f13ac0c 100644 --- a/block/submit_test.go +++ b/block/submit_test.go @@ -111,14 +111,18 @@ func TestBatchSubmissionHappyFlow(t *testing.T) { proxyApp := proxy.NewAppConns(clientCreator) err := proxyApp.Start() require.NoError(err) - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 500000, - MaxGas: 40000000, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, }, - }}) + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 40000000, + MaxBytes: 500000, + }, + }, + }) manager, err := testutil.GetManager(testutil.GetManagerConfig(), nil, 1, 1, 0, proxyApp, nil) require.NoError(err) @@ -145,14 +149,18 @@ func TestBatchSubmissionFailedSubmission(t *testing.T) { require := require.New(t) app := testutil.GetAppMock(testutil.EndBlock) ctx := context.Background() - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 500000, - MaxGas: 40000000, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, + }, + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 40000000, + MaxBytes: 500000, + }, }, - }}) + }) // Create proxy app clientCreator := proxy.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(clientCreator) @@ -212,14 +220,18 @@ func TestSubmissionByTime(t *testing.T) { require := require.New(t) app := testutil.GetAppMock(testutil.EndBlock) - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 500000, - MaxGas: 40000000, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, }, - }}) + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 40000000, + MaxBytes: 500000, + }, + }, + }) // Create proxy app clientCreator := proxy.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(clientCreator) @@ -291,14 +303,18 @@ func TestSubmissionByBatchSize(t *testing.T) { for _, c := range cases { app := testutil.GetAppMock(testutil.EndBlock) - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 500000, - MaxGas: 40000000, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, + }, + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 40000000, + MaxBytes: 500000, + }, }, - }}) + }) // Create proxy app clientCreator := proxy.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(clientCreator) diff --git a/cmd/dymint/commands/init.go b/cmd/dymint/commands/init.go index 4d3483891..9587731fd 100644 --- a/cmd/dymint/commands/init.go +++ b/cmd/dymint/commands/init.go @@ -61,7 +61,7 @@ func InitFilesWithConfig(config *cfg.Config) error { ChainID: fmt.Sprintf("test-chain-%v", tmrand.Str(6)), GenesisTime: tmtime.Now(), ConsensusParams: types.DefaultConsensusParams(), - AppState: []byte("{\"app_state\": {\"rollapp_params\": {\"params\": {\"da\": \"mock\",\"version\": \"646983ec41942854aa8b2fc2b755106307e50170\"}}}}"), + AppState: []byte("{\"app_state\": {\"rollappparams\": {\"params\": {\"da\": \"mock\",\"version\": \"646983ec41942854aa8b2fc2b755106307e50170\"}}}}"), } pubKey, err := pv.GetPubKey() if err != nil { diff --git a/go.mod b/go.mod index 5f897055b..ad5c5c53d 100644 --- a/go.mod +++ b/go.mod @@ -43,11 +43,15 @@ require ( ) require ( + cloud.google.com/go v0.112.1 // indirect + cloud.google.com/go/storage v1.38.0 // indirect github.com/celestiaorg/go-square v1.0.1 // indirect github.com/celestiaorg/go-square/merkle v0.0.0-20240429192549-dea967e1533b // indirect github.com/cskr/pubsub v1.0.2 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/ipfs/go-block-format v0.2.0 // indirect + google.golang.org/api v0.169.0 // indirect ) require ( @@ -243,7 +247,7 @@ require ( golang.org/x/sys v0.19.0 // indirect golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect + google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 // indirect @@ -293,10 +297,11 @@ require ( replace ( github.com/centrifuge/go-substrate-rpc-client/v4 => github.com/availproject/go-substrate-rpc-client/v4 v4.0.12-avail-1.4.0-rc1-5e286e3 + github.com/dymensionxyz/dymension-rdk => github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240827102903-08636e7ab3f8 github.com/evmos/evmos/v12 => github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 github.com/gorilla/rpc => github.com/dymensionxyz/rpc v1.3.1 - github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20240822095912-8f031e6a53af + github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20240906093934-57cd50faef13 ) replace github.com/osmosis-labs/osmosis/v15 => github.com/dymensionxyz/osmosis/v15 v15.2.0-dymension-v1.1.2 diff --git a/go.sum b/go.sum index 22a9fe8fc..42ad2df5e 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,8 @@ cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHOb cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= -cloud.google.com/go v0.112.0 h1:tpFCD7hpHFlQ8yPwT3x+QeXqc2T6+n6T+hmABHfDUSM= -cloud.google.com/go v0.112.0/go.mod h1:3jEEVwZ/MHU4djK5t5RHuKOA/GbLddgTdVubX1qnPD4= +cloud.google.com/go v0.112.1 h1:uJSeirPke5UNZHIb4SxfZklVSiWWVqW4oXlETwZziwM= +cloud.google.com/go v0.112.1/go.mod h1:+Vbu+Y1UU+I1rjmzeMOb/8RfkKJK2Gyxi1X6jJCZLo4= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -33,8 +33,8 @@ cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGB cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/iam v1.1.5 h1:1jTsCu4bcsNsE4iiqNT5SHwrDRCfRmIaaaVFhRveTJI= -cloud.google.com/go/iam v1.1.5/go.mod h1:rB6P/Ic3mykPbFio+vo7403drjlgvoWfYpJhMXEbzv8= +cloud.google.com/go/iam v1.1.6 h1:bEa06k05IO4f4uJonbB5iAgKTPpABy1ayxaIZV/GHVc= +cloud.google.com/go/iam v1.1.6/go.mod h1:O0zxdPeGBoFdWW3HWmBxJsk0pfvNM/p/qa82rWOGTwI= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -45,8 +45,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/oNM= -cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7BiccwkR7+P7gN8E= +cloud.google.com/go/storage v1.38.0 h1:Az68ZRGlnNTpIBbLjSMIV2BDcwwXYlRlQzis0llkpJg= +cloud.google.com/go/storage v1.38.0/go.mod h1:tlUADB0mAb9BgYls9lq+8MGkfzOXuLrnHXlpHmvFJoY= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= @@ -305,8 +305,8 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= -github.com/dymensionxyz/cometbft v0.34.29-0.20240822095912-8f031e6a53af h1:JRkyWzueq+6a3gdNfGyaioSYPbLP06BkijRFE+UOWhU= -github.com/dymensionxyz/cometbft v0.34.29-0.20240822095912-8f031e6a53af/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw= +github.com/dymensionxyz/cometbft v0.34.29-0.20240906093934-57cd50faef13 h1:Bz7HmEY2v76i+9ODm5yDArQk5pZw3ND0ecKVbD7Gt4I= +github.com/dymensionxyz/cometbft v0.34.29-0.20240906093934-57cd50faef13/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw= github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13 h1:u5yeve5jZR6TdRjjR+vYT/8PWKbhwCZxUmAu+/Tnxyg= github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13/go.mod h1:jabDQYXrccscSE0fXkh7eQFYPWJCRiuWKonFGObVq6s= github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56 h1:cmpJYdRviuUfmlJdHrcAND8Jd6JIY4rp63bWAQzPr54= @@ -334,8 +334,8 @@ github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojt github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= -github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o= -github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/filecoin-project/go-jsonrpc v0.5.0 h1:6PZghgMaM9wSjlhxkDD+YgZ+oucBUIkJOfVc7SdQBTE= github.com/filecoin-project/go-jsonrpc v0.5.0/go.mod h1:/n/niXcS4ZQua6i37LcVbY1TmlJR0UIK9mDFQq2ICek= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= @@ -510,8 +510,8 @@ github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas= -github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU= +github.com/googleapis/gax-go/v2 v2.12.2 h1:mhN09QQW1jEWeMF74zGR81R30z4VJzjZsfkUhuHF+DA= +github.com/googleapis/gax-go/v2 v2.12.2/go.mod h1:61M8vcyyXR2kqKFxKrfA22jaA8JGF7Dc8App1U3H6jc= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f h1:KMlcu9X58lhTA/KrfX8Bi1LQSO4pzoVjTiL3h4Jk+Zk= @@ -1076,6 +1076,10 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= @@ -1423,8 +1427,8 @@ google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz513 google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.149.0 h1:b2CqT6kG+zqJIVKRQ3ELJVLN1PwHZ6DJ3dW8yl82rgY= -google.golang.org/api v0.149.0/go.mod h1:Mwn1B7JTXrzXtnvmzQE2BD6bYZQ8DShKZDZbeN9I7qI= +google.golang.org/api v0.169.0 h1:QwWPy71FgMWqJN/l6jVlFHUa29a7dcUy02I8o799nPY= +google.golang.org/api v0.169.0/go.mod h1:gpNOiMA2tZ4mf5R9Iwf4rK/Dcz0fbdIgWYWVoxmsyLg= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1479,8 +1483,8 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 h1:KAeGQVN3M9nD0/bQXnr/ClcEMJ968gUXJQ9pwfSynuQ= -google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80/go.mod h1:cc8bqMqtv9gMOr0zHg2Vzff5ULhhL2IXP4sbcn32Dro= +google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y= +google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= diff --git a/p2p/validator_test.go b/p2p/validator_test.go index f3ec7c85e..9c684eb74 100644 --- a/p2p/validator_test.go +++ b/p2p/validator_test.go @@ -5,7 +5,6 @@ import ( mempoolv1 "github.com/dymensionxyz/dymint/mempool/v1" "github.com/dymensionxyz/dymint/types" - "github.com/dymensionxyz/dymint/types/pb/dymint" "github.com/libp2p/go-libp2p/core/peer" "github.com/stretchr/testify/assert" @@ -133,10 +132,9 @@ func TestValidator_BlockValidator(t *testing.T) { maxBytes := uint64(100) state := &types.State{} state.Sequencers.SetProposer(types.NewSequencerFromValidator(*tmtypes.NewValidator(proposerKey.PubKey(), 1))) - state.ConsensusParams = dymint.RollappConsensusParams{ - Blockmaxgas: 100000, - Blockmaxsize: int64(maxBytes), - } + state.ConsensusParams.Block.MaxGas = 100000 + state.ConsensusParams.Block.MaxBytes = int64(maxBytes) + // Create empty block block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.Sequencers.ProposerHash()), state, maxBytes) diff --git a/proto/types/dymint/state.proto b/proto/types/dymint/state.proto index a12631126..121bd917e 100755 --- a/proto/types/dymint/state.proto +++ b/proto/types/dymint/state.proto @@ -32,7 +32,7 @@ message State { int64 last_height_validators_changed = 11; - reserved 12; + tendermint.types.ConsensusParams consensus_params = 12 [(gogoproto.nullable) = false]; int64 last_height_consensus_params_changed = 13; bytes last_results_hash = 14; @@ -43,18 +43,16 @@ message State { uint64 base_height = 17; SequencerSet sequencerSet = 18 [(gogoproto.nullable) = false]; - RollappConsensusParams consensus_params = 19 [(gogoproto.nullable) = false]; - + RollappConsensusParams rollapp_params = 19 [(gogoproto.nullable) = false]; + } //rollapp params defined in genesis and updated via gov proposal message RollappConsensusParams { - //maximum amount of gas that all transactions included in a block can use - int64 blockmaxgas = 1; - //maximum allowed block size - int64 blockmaxsize = 2; + //data availability type (e.g. celestia) used in the rollapp - string da = 3 ; + string da = 1 ; //commit used for the rollapp executable - string commit = 4 ; + string version = 2 ; + } \ No newline at end of file diff --git a/rpc/client/client_test.go b/rpc/client/client_test.go index 741186f42..3289d041e 100644 --- a/rpc/client/client_test.go +++ b/rpc/client/client_test.go @@ -443,14 +443,18 @@ func TestTx(t *testing.T) { require.NotNil(rpc) mockApp.On("BeginBlock", mock.Anything).Return(abci.ResponseBeginBlock{}) - mockApp.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 100, - MaxGas: 100, + mockApp.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, }, - }}) + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 100, + MaxBytes: 100, + }, + }, + }) mockApp.On("Commit", mock.Anything).Return(abci.ResponseCommit{}) mockApp.On("DeliverTx", mock.Anything).Return(abci.ResponseDeliverTx{}) mockApp.On("CheckTx", mock.Anything).Return(abci.ResponseCheckTx{}) diff --git a/rpc/json/service_test.go b/rpc/json/service_test.go index fcea7c152..0f876a341 100644 --- a/rpc/json/service_test.go +++ b/rpc/json/service_test.go @@ -280,14 +280,18 @@ func getRPC(t *testing.T) (*tmmocks.MockApplication, *client.Client) { app := &tmmocks.MockApplication{} app.On("InitChain", mock.Anything).Return(abci.ResponseInitChain{}) app.On("BeginBlock", mock.Anything).Return(abci.ResponseBeginBlock{}) - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 100, - MaxGas: 100, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, }, - }}) + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 100, + MaxBytes: 100, + }, + }, + }) app.On("Commit", mock.Anything).Return(abci.ResponseCommit{}) app.On("CheckTx", mock.Anything).Return(abci.ResponseCheckTx{ GasWanted: 1000, @@ -332,7 +336,7 @@ func getRPC(t *testing.T) (*tmmocks.MockApplication, *client.Client) { key, signingKey, proxy.NewLocalClientCreator(app), - &types.GenesisDoc{ChainID: rollappID, AppState: []byte("{\"rollapp_params\": {\"params\": {\"da\": \"mock\",\"commit\": \"" + version.Commit + "\"}}}")}, + &types.GenesisDoc{ChainID: rollappID, AppState: []byte("{\"rollappparams\": {\"params\": {\"da\": \"mock\",\"version\": \"" + version.Commit + "\"}}}")}, log.TestingLogger(), mempool.NopMetrics(), ) diff --git a/testutil/node.go b/testutil/node.go index b2837a558..398935524 100644 --- a/testutil/node.go +++ b/testutil/node.go @@ -11,7 +11,6 @@ import ( "github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/types" - "github.com/dymensionxyz/dymint/version" "github.com/stretchr/testify/mock" abci "github.com/tendermint/tendermint/abci/types" @@ -30,14 +29,18 @@ func CreateNode(isSequencer bool, blockManagerConfig *config.BlockManagerConfig, if err != nil { return nil, err } - app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{RollappConsensusParamUpdates: &abci.RollappConsensusParams{ - Da: "mock", - Commit: version.Commit, - Block: &abci.BlockParams{ - MaxBytes: 100, - MaxGas: 100, + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ + RollappConsensusParamUpdates: &abci.RollappConsensusParams{ + Da: "celestia", + Version: "abcde", }, - }}) + ConsensusParamUpdates: &abci.ConsensusParams{ + Block: &abci.BlockParams{ + MaxGas: 100, + MaxBytes: 100, + }, + }, + }) key, _, _ := crypto.GenerateEd25519Key(rand.Reader) signingKey, pubkey, _ := crypto.GenerateEd25519Key(rand.Reader) diff --git a/testutil/types.go b/testutil/types.go index 299077a2d..e1d05952b 100644 --- a/testutil/types.go +++ b/testutil/types.go @@ -236,9 +236,15 @@ func GenerateStateWithSequencer(initialHeight int64, lastBlockHeight int64, pubk App: AppVersion, }, }, - ConsensusParams: dymint.RollappConsensusParams{ - Da: "mock", - Commit: dymintversion.Commit, + RollappParams: dymint.RollappConsensusParams{ + Da: "mock", + Version: dymintversion.Commit, + }, + ConsensusParams: tmproto.ConsensusParams{ + Block: tmproto.BlockParams{ + MaxBytes: 100, + MaxGas: 100, + }, }, } s.Sequencers.SetProposer(types.NewSequencer(pubkey, "")) @@ -268,7 +274,7 @@ func GenerateGenesis(initialHeight int64) *tmtypes.GenesisDoc { AppVersion: AppVersion, }, }, - AppState: []byte("{\"rollapp_params\": {\"params\": {\"da\": \"mock\",\"commit\": \"" + dymintversion.Commit + "\",\"blockmaxgas\":400000000,\"blockmaxsize\":500000}}}"), + AppState: []byte("{\"rollappparams\": {\"params\": {\"da\": \"mock\",\"version\": \"" + dymintversion.Commit + "\"}}}"), } } diff --git a/types/pb/dymint/state.pb.go b/types/pb/dymint/state.pb.go index 742a1c91d..ba909fbb3 100644 --- a/types/pb/dymint/state.pb.go +++ b/types/pb/dymint/state.pb.go @@ -39,13 +39,14 @@ type State struct { LastBlockTime time.Time `protobuf:"bytes,6,opt,name=last_block_time,json=lastBlockTime,proto3,stdtime" json:"last_block_time"` Validators *types.ValidatorSet `protobuf:"bytes,9,opt,name=validators,proto3" json:"validators,omitempty"` // Deprecated: Do not use. LastHeightValidatorsChanged int64 `protobuf:"varint,11,opt,name=last_height_validators_changed,json=lastHeightValidatorsChanged,proto3" json:"last_height_validators_changed,omitempty"` + ConsensusParams types.ConsensusParams `protobuf:"bytes,12,opt,name=consensus_params,json=consensusParams,proto3" json:"consensus_params"` LastHeightConsensusParamsChanged int64 `protobuf:"varint,13,opt,name=last_height_consensus_params_changed,json=lastHeightConsensusParamsChanged,proto3" json:"last_height_consensus_params_changed,omitempty"` LastResultsHash []byte `protobuf:"bytes,14,opt,name=last_results_hash,json=lastResultsHash,proto3" json:"last_results_hash,omitempty"` AppHash []byte `protobuf:"bytes,15,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` LastStoreHeight uint64 `protobuf:"varint,16,opt,name=last_store_height,json=lastStoreHeight,proto3" json:"last_store_height,omitempty"` BaseHeight uint64 `protobuf:"varint,17,opt,name=base_height,json=baseHeight,proto3" json:"base_height,omitempty"` SequencerSet SequencerSet `protobuf:"bytes,18,opt,name=sequencerSet,proto3" json:"sequencerSet"` - ConsensusParams RollappConsensusParams `protobuf:"bytes,19,opt,name=consensus_params,json=consensusParams,proto3" json:"consensus_params"` + RollappParams RollappConsensusParams `protobuf:"bytes,19,opt,name=rollapp_params,json=rollappParams,proto3" json:"rollapp_params"` } func (m *State) Reset() { *m = State{} } @@ -138,6 +139,13 @@ func (m *State) GetLastHeightValidatorsChanged() int64 { return 0 } +func (m *State) GetConsensusParams() types.ConsensusParams { + if m != nil { + return m.ConsensusParams + } + return types.ConsensusParams{} +} + func (m *State) GetLastHeightConsensusParamsChanged() int64 { if m != nil { return m.LastHeightConsensusParamsChanged @@ -180,23 +188,19 @@ func (m *State) GetSequencerSet() SequencerSet { return SequencerSet{} } -func (m *State) GetConsensusParams() RollappConsensusParams { +func (m *State) GetRollappParams() RollappConsensusParams { if m != nil { - return m.ConsensusParams + return m.RollappParams } return RollappConsensusParams{} } //rollapp params defined in genesis and updated via gov proposal type RollappConsensusParams struct { - //maximum amount of gas that all transactions included in a block can use - Blockmaxgas int64 `protobuf:"varint,1,opt,name=blockmaxgas,proto3" json:"blockmaxgas,omitempty"` - //maximum allowed block size - Blockmaxsize int64 `protobuf:"varint,2,opt,name=blockmaxsize,proto3" json:"blockmaxsize,omitempty"` //data availability type (e.g. celestia) used in the rollapp - Da string `protobuf:"bytes,3,opt,name=da,proto3" json:"da,omitempty"` + Da string `protobuf:"bytes,1,opt,name=da,proto3" json:"da,omitempty"` //commit used for the rollapp executable - Commit string `protobuf:"bytes,4,opt,name=commit,proto3" json:"commit,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` } func (m *RollappConsensusParams) Reset() { *m = RollappConsensusParams{} } @@ -232,20 +236,6 @@ func (m *RollappConsensusParams) XXX_DiscardUnknown() { var xxx_messageInfo_RollappConsensusParams proto.InternalMessageInfo -func (m *RollappConsensusParams) GetBlockmaxgas() int64 { - if m != nil { - return m.Blockmaxgas - } - return 0 -} - -func (m *RollappConsensusParams) GetBlockmaxsize() int64 { - if m != nil { - return m.Blockmaxsize - } - return 0 -} - func (m *RollappConsensusParams) GetDa() string { if m != nil { return m.Da @@ -253,9 +243,9 @@ func (m *RollappConsensusParams) GetDa() string { return "" } -func (m *RollappConsensusParams) GetCommit() string { +func (m *RollappConsensusParams) GetVersion() string { if m != nil { - return m.Commit + return m.Version } return "" } @@ -268,51 +258,50 @@ func init() { func init() { proto.RegisterFile("types/dymint/state.proto", fileDescriptor_4b679420add07272) } var fileDescriptor_4b679420add07272 = []byte{ - // 703 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00,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x4f, 0x2a, 0xa5, 0xdd, 0x3a, 0xde, 0xa6, 0x3c, 0xa9, - 0x9a, 0xf5, 0xae, 0x39, 0xa9, 0x9a, 0x66, 0xb7, 0x31, 0xa9, 0x9a, 0xa0, 0xdb, 0x9c, 0x54, 0xcd, - 0x56, 0xb7, 0x3d, 0xf8, 0x66, 0x80, 0xfd, 0x3f, 0x3b, 0xc1, 0x3e, 0x68, 0xca, 0x71, 0x8c, 0xf1, - 0x65, 0x80, 0x99, 0x5c, 0xc7, 0x0a, 0x2a, 0x4a, 0x70, 0x00, 0x5a, 0xf9, 0x91, 0xd1, 0x6b, 0x22, - 0x77, 0xaf, 0x82, 0x36, 0x34, 0xb8, 0x0d, 0xca, 0x3e, 0x96, 0x4b, 0xd7, 0x40, 0x65, 0x1f, 0xc3, - 0x7d, 0x50, 0xf3, 0xd2, 0x38, 0xa6, 0x6a, 0xbd, 0x1a, 0x48, 0x9f, 0xdc, 0xd3, 0xdb, 0x95, 0x6d, - 0xdc, 0xad, 0x6c, 0xe3, 0xe7, 0xca, 0x36, 0x6e, 0x1e, 0xec, 0xd2, 0xdd, 0x83, 0x5d, 0xfa, 0xfe, - 0x60, 0x97, 0x3e, 0x39, 0x01, 0xe5, 0xe1, 0x72, 0xee, 0x78, 0x69, 0x2c, 0xbe, 0x1a, 0x24, 0x11, - 0x3b, 0x7f, 0x79, 0x75, 0x9d, 0x7f, 0x49, 0xf4, 0xe7, 0x68, 0xae, 0xcf, 0xf3, 0x9a, 0x5c, 0x95, - 0xa3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb2, 0x64, 0xcb, 0x4f, 0x81, 0x05, 0x00, 0x00, + // 684 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0xcb, 0x4e, 0xdb, 0x4c, + 0x14, 0xc7, 0xe3, 0x10, 0x48, 0x32, 0x21, 0x17, 0x06, 0xf4, 0x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, 0xba, 0x0f, 0x6d, 0xbd, 0x57, + 0x89, 0xe7, 0xb5, 0x46, 0xbd, 0xd7, 0x38, 0xaf, 0x35, 0x1a, 0xbd, 0xe6, 0x79, 0xad, 0x01, 0x7a, + 0xad, 0x23, 0x07, 0xfc, 0xf7, 0xb4, 0x01, 0xec, 0x80, 0x6a, 0x88, 0xe4, 0x75, 0x6e, 0xba, 0xd5, + 0x10, 0x41, 0x73, 0x79, 0xc7, 0xf5, 0x6d, 0xd5, 0x4b, 0xe7, 0xec, 0x76, 0x6e, 0x19, 0x77, 0x73, + 0xcb, 0xf8, 0x3b, 0xb7, 0x8c, 0x9b, 0x07, 0xab, 0x72, 0xf7, 0x60, 0x55, 0x7e, 0x3f, 0x58, 0x95, + 0x2f, 0x76, 0x44, 0x78, 0x3c, 0xf3, 0xed, 0x80, 0x4e, 0xc5, 0xd3, 0x81, 0x53, 0xc1, 0xff, 0xb8, + 0xfe, 0x59, 0x3c, 0x27, 0xfa, 0x4d, 0xf2, 0xf5, 0xda, 0xdf, 0x92, 0xf7, 0xe5, 0xf8, 0x5f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x67, 0x27, 0x6f, 0x6e, 0x86, 0x05, 0x00, 0x00, } func (m *State) Marshal() (dAtA []byte, err error) { @@ -336,7 +325,7 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size, err := m.ConsensusParams.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.RollappParams.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -392,6 +381,16 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x68 } + { + size, err := m.ConsensusParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintState(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 if m.LastHeightValidatorsChanged != 0 { i = encodeVarintState(dAtA, i, uint64(m.LastHeightValidatorsChanged)) i-- @@ -409,12 +408,12 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x4a } - n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastBlockTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastBlockTime):]) - if err4 != nil { - return 0, err4 + n5, err5 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastBlockTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastBlockTime):]) + if err5 != nil { + return 0, err5 } - i -= n4 - i = encodeVarintState(dAtA, i, uint64(n4)) + i -= n5 + i = encodeVarintState(dAtA, i, uint64(n5)) i-- dAtA[i] = 0x32 { @@ -479,29 +478,19 @@ func (m *RollappConsensusParams) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l - if len(m.Commit) > 0 { - i -= len(m.Commit) - copy(dAtA[i:], m.Commit) - i = encodeVarintState(dAtA, i, uint64(len(m.Commit))) + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintState(dAtA, i, uint64(len(m.Version))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x12 } if len(m.Da) > 0 { i -= len(m.Da) copy(dAtA[i:], m.Da) i = encodeVarintState(dAtA, i, uint64(len(m.Da))) i-- - dAtA[i] = 0x1a - } - if m.Blockmaxsize != 0 { - i = encodeVarintState(dAtA, i, uint64(m.Blockmaxsize)) - i-- - dAtA[i] = 0x10 - } - if m.Blockmaxgas != 0 { - i = encodeVarintState(dAtA, i, uint64(m.Blockmaxgas)) - i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -548,6 +537,8 @@ func (m *State) Size() (n int) { if m.LastHeightValidatorsChanged != 0 { n += 1 + sovState(uint64(m.LastHeightValidatorsChanged)) } + l = m.ConsensusParams.Size() + n += 1 + l + sovState(uint64(l)) if m.LastHeightConsensusParamsChanged != 0 { n += 1 + sovState(uint64(m.LastHeightConsensusParamsChanged)) } @@ -567,7 +558,7 @@ func (m *State) Size() (n int) { } l = m.SequencerSet.Size() n += 2 + l + sovState(uint64(l)) - l = m.ConsensusParams.Size() + l = m.RollappParams.Size() n += 2 + l + sovState(uint64(l)) return n } @@ -578,17 +569,11 @@ func (m *RollappConsensusParams) Size() (n int) { } var l int _ = l - if m.Blockmaxgas != 0 { - n += 1 + sovState(uint64(m.Blockmaxgas)) - } - if m.Blockmaxsize != 0 { - n += 1 + sovState(uint64(m.Blockmaxsize)) - } l = len(m.Da) if l > 0 { n += 1 + l + sovState(uint64(l)) } - l = len(m.Commit) + l = len(m.Version) if l > 0 { n += 1 + l + sovState(uint64(l)) } @@ -857,6 +842,39 @@ func (m *State) Unmarshal(dAtA []byte) error { break } } + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthState + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ConsensusParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 13: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field LastHeightConsensusParamsChanged", wireType) @@ -1017,7 +1035,7 @@ func (m *State) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 19: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsensusParams", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RollappParams", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1044,7 +1062,7 @@ func (m *State) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ConsensusParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.RollappParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1099,44 +1117,6 @@ func (m *RollappConsensusParams) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Blockmaxgas", wireType) - } - m.Blockmaxgas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Blockmaxgas |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Blockmaxsize", wireType) - } - m.Blockmaxsize = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Blockmaxsize |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Da", wireType) } @@ -1168,9 +1148,9 @@ func (m *RollappConsensusParams) Unmarshal(dAtA []byte) error { } m.Da = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Commit", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1198,7 +1178,7 @@ func (m *RollappConsensusParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Commit = string(dAtA[iNdEx:postIndex]) + m.Version = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/types/serialization.go b/types/serialization.go index 99b81a8cd..1ccabd1ff 100644 --- a/types/serialization.go +++ b/types/serialization.go @@ -266,6 +266,7 @@ func (s *State) ToProto() (*pb.State, error) { LastHeightConsensusParamsChanged: s.LastHeightConsensusParamsChanged, LastResultsHash: s.LastResultsHash[:], AppHash: s.AppHash[:], + RollappParams: s.RollappParams, }, nil } @@ -287,6 +288,7 @@ func (s *State) FromProto(other *pb.State) error { s.LastHeightConsensusParamsChanged = other.LastHeightConsensusParamsChanged copy(s.LastResultsHash[:], other.LastResultsHash) copy(s.AppHash[:], other.AppHash) + s.RollappParams = other.RollappParams return nil } diff --git a/types/serialization_test.go b/types/serialization_test.go index 8f8f3021f..d353dd543 100644 --- a/types/serialization_test.go +++ b/types/serialization_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" tmstate "github.com/tendermint/tendermint/proto/tendermint/state" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmversion "github.com/tendermint/tendermint/proto/tendermint/version" "github.com/dymensionxyz/dymint/testutil" @@ -95,9 +96,12 @@ func TestStateRoundTrip(t *testing.T) { { "with max bytes", types.State{ - ConsensusParams: pb.RollappConsensusParams{ - Blockmaxgas: 123, - Blockmaxsize: 456, + ConsensusParams: tmproto.ConsensusParams{ + Block: tmproto.BlockParams{ + MaxBytes: 123, + MaxGas: 456, + TimeIotaMs: 789, + }, }, }, }, @@ -113,11 +117,27 @@ func TestStateRoundTrip(t *testing.T) { }, ChainID: "testchain", InitialHeight: 987, - ConsensusParams: pb.RollappConsensusParams{ - Blockmaxgas: 123, - Blockmaxsize: 456, - Da: "mock", - Commit: version.Commit, + ConsensusParams: tmproto.ConsensusParams{ + Block: tmproto.BlockParams{ + MaxBytes: 12345, + MaxGas: 6543234, + TimeIotaMs: 235, + }, + Evidence: tmproto.EvidenceParams{ + MaxAgeNumBlocks: 100, + MaxAgeDuration: 200, + MaxBytes: 300, + }, + Validator: tmproto.ValidatorParams{ + PubKeyTypes: []string{"secure", "more secure"}, + }, + Version: tmproto.VersionParams{ + AppVersion: 42, + }, + }, + RollappParams: pb.RollappConsensusParams{ + Da: "mock", + Version: version.Commit, }, LastHeightConsensusParamsChanged: 12345, LastResultsHash: [32]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2}, diff --git a/types/state.go b/types/state.go index 5a32a8b9d..16d6f5aaa 100644 --- a/types/state.go +++ b/types/state.go @@ -9,6 +9,7 @@ import ( "github.com/dymensionxyz/dymint/types/pb/dymint" tmstate "github.com/tendermint/tendermint/proto/tendermint/state" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) // State contains information about current state of the blockchain. @@ -30,7 +31,7 @@ type State struct { // Consensus parameters used for validating blocks. // Changes returned by EndBlock and updated after Commit. - ConsensusParams dymint.RollappConsensusParams + ConsensusParams tmproto.ConsensusParams LastHeightConsensusParamsChanged int64 // Merkle root of the results from executing prev block @@ -38,6 +39,9 @@ type State struct { // the latest AppHash we've received from calling abci.Commit() AppHash [32]byte + + // New rollapp parameters . + RollappParams dymint.RollappConsensusParams } func (s *State) IsGenesis() bool { @@ -67,16 +71,16 @@ func (s *State) NextHeight() uint64 { return s.Height() + 1 } -// SetConsensusParamsFromGenesis sets the rollapp consensus params from genesis -func (s *State) SetConsensusParamsFromGenesis(appState json.RawMessage) error { +// SetRollappParamsFromGenesis sets the rollapp consensus params from genesis +func (s *State) SetRollappParamsFromGenesis(appState json.RawMessage) error { var objmap map[string]json.RawMessage err := json.Unmarshal(appState, &objmap) if err != nil { return err } - params, ok := objmap["rollapp_params"] + params, ok := objmap["rollappparams"] if !ok { - return fmt.Errorf("rollapp_params not defined in genesis") + return fmt.Errorf("rollappparams not defined in genesis") } var rollappParams RollappParams @@ -84,6 +88,6 @@ func (s *State) SetConsensusParamsFromGenesis(appState json.RawMessage) error { if err != nil { return err } - s.ConsensusParams = *rollappParams.Params + s.RollappParams = *rollappParams.Params return nil }