From 7ac76f8dc65bb2f26ac5222b4c87baaa85e4f7b4 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Fri, 27 Sep 2024 16:31:08 +0200 Subject: [PATCH 1/8] wip --- block/manager.go | 1 + block/sequencers.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/block/manager.go b/block/manager.go index dd1994bd2..ce5cdce93 100644 --- a/block/manager.go +++ b/block/manager.go @@ -194,6 +194,7 @@ func (m *Manager) Start(ctx context.Context) error { /* ----------------------------- sequencer mode ----------------------------- */ // Subscribe to batch events, to update last submitted height in case batch confirmation was lost. This could happen if the sequencer crash/restarted just after submitting a batch to the settlement and by the time we query the last batch, this batch wasn't accepted yet. go uevent.MustSubscribe(ctx, m.Pubsub, "updateSubmittedHeightLoop", settlement.EventQueryNewSettlementBatchAccepted, m.UpdateLastSubmittedHeight, m.logger) + go uevent.MustSubscribe(ctx, m.Pubsub, "newBondedSequencer", settlement.EventQueryNewBondedSequencer, m.UpdateLastSubmittedHeight, m.logger) // Sequencer must wait till DA is synced to start submitting blobs <-m.DAClient.Synced() diff --git a/block/sequencers.go b/block/sequencers.go index 4c98c4f3b..9cc064cfa 100644 --- a/block/sequencers.go +++ b/block/sequencers.go @@ -8,6 +8,7 @@ import ( "github.com/dymensionxyz/dymint/settlement" "github.com/dymensionxyz/dymint/types" + "github.com/tendermint/tendermint/libs/pubsub" ) func (m *Manager) MonitorSequencerRotation(ctx context.Context, rotateC chan string) error { @@ -179,3 +180,17 @@ func (m *Manager) UpdateProposer() error { m.State.Sequencers.SetProposer(m.SLClient.GetProposer()) return nil } + +// UpdateLastSubmittedHeight will update last height submitted height upon events. +// This may be necessary in case we crashed/restarted before getting response for our submission to the settlement layer. +func (m *Manager) UpdateSequencerSet(event pubsub.Message) { + eventData, ok := event.Data().(*settlement.EventDataNewBondedSequencer) + if !ok { + m.logger.Error("onReceivedBatch", "err", "wrong event data received") + return + } + newSeqAddr := eventData.SeqAddr + + sequencers := m.State.Sequencers + m.State.Sequencers.SetSequencers() +} From 405d152b7a861c8dc1fd4cf31b929ca345f19a5e Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Fri, 27 Sep 2024 17:36:56 +0200 Subject: [PATCH 2/8] GetSequencerByAddress added --- block/sequencers.go | 10 +++- .../dymint/da/avail/mock_SubstrateApiI.go | 2 +- .../celestia/types/mock_CelestiaRPCClient.go | 2 +- .../da/mock_DataAvailabilityLayerClient.go | 2 +- .../settlement/dymension/mock_CosmosClient.go | 2 +- .../dymint/settlement/mock_ClientI.go | 58 ++++++++++++++++++- .../dymensionxyz/dymint/store/mock_Store.go | 41 ++++++------- .../sequencer/types/mock_QueryClient.go | 2 +- .../dymension/rollapp/mock_QueryClient.go | 2 +- .../tendermint/abci/types/mock_Application.go | 2 +- .../tendermint/proxy/mock_AppConnConsensus.go | 2 +- .../tendermint/proxy/mock_AppConns.go | 2 +- settlement/dymension/dymension.go | 40 +++++++++++++ settlement/grpc/grpc.go | 5 ++ settlement/local/local.go | 5 ++ settlement/settlement.go | 3 +- 16 files changed, 147 insertions(+), 33 deletions(-) diff --git a/block/sequencers.go b/block/sequencers.go index 9cc064cfa..b7265d2d7 100644 --- a/block/sequencers.go +++ b/block/sequencers.go @@ -189,8 +189,14 @@ func (m *Manager) UpdateSequencerSet(event pubsub.Message) { m.logger.Error("onReceivedBatch", "err", "wrong event data received") return } + newSeqAddr := eventData.SeqAddr - sequencers := m.State.Sequencers - m.State.Sequencers.SetSequencers() + sequencers := m.State.Sequencers.Sequencers + newSequencer, err := m.SLClient.GetSequencerByAddress(newSeqAddr) + if err != nil { + m.logger.Error("unable to add new sequencer from event. err:%w", err) + } + sequencers = append(sequencers, newSequencer) + m.State.Sequencers.SetSequencers(sequencers) } 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 bba31b087..6a52c1df8 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.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. DO NOT EDIT. package avail 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 5994cf817..4935cc66a 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.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. 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 1480d557c..75727dd5e 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.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. DO NOT EDIT. package da 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 bebd10ade..4b14a3eaf 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.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. DO NOT EDIT. package dymension diff --git a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go index e71cc9d27..784febab1 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.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. DO NOT EDIT. package settlement @@ -417,6 +417,62 @@ func (_c *MockClientI_GetProposer_Call) RunAndReturn(run func() *types.Sequencer return _c } +// GetSequencerByAddress provides a mock function with given fields: address +func (_m *MockClientI) GetSequencerByAddress(address string) (types.Sequencer, error) { + ret := _m.Called(address) + + if len(ret) == 0 { + panic("no return value specified for GetSequencerByAddress") + } + + var r0 types.Sequencer + var r1 error + if rf, ok := ret.Get(0).(func(string) (types.Sequencer, error)); ok { + return rf(address) + } + if rf, ok := ret.Get(0).(func(string) types.Sequencer); ok { + r0 = rf(address) + } else { + r0 = ret.Get(0).(types.Sequencer) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(address) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientI_GetSequencerByAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSequencerByAddress' +type MockClientI_GetSequencerByAddress_Call struct { + *mock.Call +} + +// GetSequencerByAddress is a helper method to define mock.On call +// - address string +func (_e *MockClientI_Expecter) GetSequencerByAddress(address interface{}) *MockClientI_GetSequencerByAddress_Call { + return &MockClientI_GetSequencerByAddress_Call{Call: _e.mock.On("GetSequencerByAddress", address)} +} + +func (_c *MockClientI_GetSequencerByAddress_Call) Run(run func(address string)) *MockClientI_GetSequencerByAddress_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockClientI_GetSequencerByAddress_Call) Return(_a0 types.Sequencer, _a1 error) *MockClientI_GetSequencerByAddress_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientI_GetSequencerByAddress_Call) RunAndReturn(run func(string) (types.Sequencer, error)) *MockClientI_GetSequencerByAddress_Call { + _c.Call.Return(run) + return _c +} + // Init provides a mock function with given fields: config, rollappId, _a2, logger, options func (_m *MockClientI) Init(config settlement.Config, rollappId string, _a2 *pubsub.Server, logger types.Logger, options ...settlement.Option) error { _va := make([]interface{}, len(options)) diff --git a/mocks/github.com/dymensionxyz/dymint/store/mock_Store.go b/mocks/github.com/dymensionxyz/dymint/store/mock_Store.go index 3a1678d0a..010d1c41c 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.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. DO NOT EDIT. package store @@ -579,27 +579,27 @@ func (_c *MockStore_NewBatch_Call) RunAndReturn(run func() store.KVBatch) *MockS return _c } -// PruneBlocks provides a mock function with given fields: from, to -func (_m *MockStore) PruneBlocks(from uint64, to uint64) (uint64, error) { - ret := _m.Called(from, to) +// PruneStore provides a mock function with given fields: from, to, logger +func (_m *MockStore) PruneStore(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 PruneBlocks") + panic("no return value specified for PruneStore") } var r0 uint64 var r1 error - if rf, ok := ret.Get(0).(func(uint64, uint64) (uint64, error)); ok { - return rf(from, to) + 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) uint64); ok { - r0 = rf(from, to) + 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) error); ok { - r1 = rf(from, to) + if rf, ok := ret.Get(1).(func(uint64, uint64, types.Logger) error); ok { + r1 = rf(from, to, logger) } else { r1 = ret.Error(1) } @@ -607,31 +607,32 @@ func (_m *MockStore) PruneBlocks(from uint64, to uint64) (uint64, error) { return r0, r1 } -// MockStore_PruneBlocks_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PruneBlocks' -type MockStore_PruneBlocks_Call struct { +// MockStore_PruneStore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PruneStore' +type MockStore_PruneStore_Call struct { *mock.Call } -// PruneBlocks is a helper method to define mock.On call +// PruneStore is a helper method to define mock.On call // - from uint64 // - to uint64 -func (_e *MockStore_Expecter) PruneBlocks(from interface{}, to interface{}) *MockStore_PruneBlocks_Call { - return &MockStore_PruneBlocks_Call{Call: _e.mock.On("PruneBlocks", from, to)} +// - logger types.Logger +func (_e *MockStore_Expecter) PruneStore(from interface{}, to interface{}, logger interface{}) *MockStore_PruneStore_Call { + return &MockStore_PruneStore_Call{Call: _e.mock.On("PruneStore", from, to, logger)} } -func (_c *MockStore_PruneBlocks_Call) Run(run func(from uint64, to uint64)) *MockStore_PruneBlocks_Call { +func (_c *MockStore_PruneStore_Call) Run(run func(from uint64, to uint64, logger types.Logger)) *MockStore_PruneStore_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(uint64), args[1].(uint64)) + run(args[0].(uint64), args[1].(uint64), args[2].(types.Logger)) }) return _c } -func (_c *MockStore_PruneBlocks_Call) Return(_a0 uint64, _a1 error) *MockStore_PruneBlocks_Call { +func (_c *MockStore_PruneStore_Call) Return(_a0 uint64, _a1 error) *MockStore_PruneStore_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockStore_PruneBlocks_Call) RunAndReturn(run func(uint64, uint64) (uint64, error)) *MockStore_PruneBlocks_Call { +func (_c *MockStore_PruneStore_Call) RunAndReturn(run func(uint64, uint64, types.Logger) (uint64, error)) *MockStore_PruneStore_Call { _c.Call.Return(run) return _c } diff --git a/mocks/github.com/dymensionxyz/dymint/third_party/dymension/sequencer/types/mock_QueryClient.go b/mocks/github.com/dymensionxyz/dymint/third_party/dymension/sequencer/types/mock_QueryClient.go index 6b16285aa..fed52c6c5 100644 --- a/mocks/github.com/dymensionxyz/dymint/third_party/dymension/sequencer/types/mock_QueryClient.go +++ b/mocks/github.com/dymensionxyz/dymint/third_party/dymension/sequencer/types/mock_QueryClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. DO NOT EDIT. package types 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 f182218a5..83c174f72 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.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. DO NOT EDIT. package rollapp 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 45011bdc9..7393ef94e 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.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. DO NOT EDIT. package types diff --git a/mocks/github.com/tendermint/tendermint/proxy/mock_AppConnConsensus.go b/mocks/github.com/tendermint/tendermint/proxy/mock_AppConnConsensus.go index 9a28054e1..9ec6b2d18 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.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. DO NOT EDIT. package proxy diff --git a/mocks/github.com/tendermint/tendermint/proxy/mock_AppConns.go b/mocks/github.com/tendermint/tendermint/proxy/mock_AppConns.go index 120c2f698..affc90a4e 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.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. DO NOT EDIT. package proxy diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index f1987c9c0..dfb4a8b38 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -318,6 +318,46 @@ func (c *Client) GetProposer() *types.Sequencer { return &seqs[index] } +// GetSequencerByAddress returns a sequencer by its address. +func (c *Client) GetSequencerByAddress(address string) (types.Sequencer, error) { + var res *sequencertypes.QueryGetSequencerResponse + req := &sequencertypes.QueryGetSequencerRequest{ + SequencerAddress: address, + } + + err := c.RunWithRetry(func() error { + var err error + res, err = c.sequencerQueryClient.Sequencer(c.ctx, req) + if err == nil { + return nil + } + + if status.Code(err) == codes.NotFound { + return retry.Unrecoverable(errors.Join(gerrc.ErrNotFound, err)) + } + return err + }) + + if err != nil { + return types.Sequencer{}, err + } + + var pubKey cryptotypes.PubKey + err = c.protoCodec.UnpackAny(res.Sequencer.DymintPubKey, &pubKey) + if err != nil { + return types.Sequencer{}, err + } + + tmPubKey, err := cryptocodec.ToTmPubKeyInterface(pubKey) + if err != nil { + return types.Sequencer{}, err + } + + sequencer := *types.NewSequencer(tmPubKey, res.Sequencer.Address) + + return sequencer, nil +} + // GetAllSequencers returns all sequencers of the given rollapp. func (c *Client) GetAllSequencers() ([]types.Sequencer, error) { var res *sequencertypes.QueryGetSequencersByRollappResponse diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index 67c62e0d3..7b243064a 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -228,6 +228,11 @@ func (c *Client) GetProposer() *types.Sequencer { return types.NewSequencer(tmPubKey, pubKey.Address().String()) } +// GetSequencerByAddress returns all sequencer information by its address. Not implemented since it will not be used in grpc SL +func (c *Client) GetSequencerByAddress(address string) (types.Sequencer, error) { + return types.Sequencer{}, nil +} + // GetAllSequencers implements settlement.ClientI. func (c *Client) GetAllSequencers() ([]types.Sequencer, error) { return c.GetBondedSequencers() diff --git a/settlement/local/local.go b/settlement/local/local.go index b085a567b..ed36cf79e 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -206,6 +206,11 @@ func (c *Client) GetProposer() *types.Sequencer { return types.NewSequencer(tmPubKey, pubKey.Address().String()) } +// GetSequencerByAddress returns all sequencer information by its address. Not implemented since it will not be used in mock SL +func (c *Client) GetSequencerByAddress(address string) (types.Sequencer, error) { + return types.Sequencer{}, nil +} + // GetAllSequencers implements settlement.ClientI. func (c *Client) GetAllSequencers() ([]types.Sequencer, error) { return c.GetBondedSequencers() diff --git a/settlement/settlement.go b/settlement/settlement.go index 91dea7fdb..66b78e604 100644 --- a/settlement/settlement.go +++ b/settlement/settlement.go @@ -73,7 +73,8 @@ type ClientI interface { GetLatestBatch() (*ResultRetrieveBatch, error) // GetBatchAtIndex returns the batch at the given index. GetBatchAtIndex(index uint64) (*ResultRetrieveBatch, error) - + // GetSequencerByAddress returns all sequencer information by its address. + GetSequencerByAddress(address string) (types.Sequencer, error) // GetAllSequencers returns all sequencers for this rollapp (bonded and not bonded). GetAllSequencers() ([]types.Sequencer, error) // GetBondedSequencers returns the list of the bonded sequencers for this rollapp. From be51c83901428b024907bb27f919e3b57676455b Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Fri, 27 Sep 2024 17:48:01 +0200 Subject: [PATCH 3/8] check if already present --- block/manager.go | 2 +- block/sequencers.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/block/manager.go b/block/manager.go index ce5cdce93..71120aa70 100644 --- a/block/manager.go +++ b/block/manager.go @@ -194,7 +194,7 @@ func (m *Manager) Start(ctx context.Context) error { /* ----------------------------- sequencer mode ----------------------------- */ // Subscribe to batch events, to update last submitted height in case batch confirmation was lost. This could happen if the sequencer crash/restarted just after submitting a batch to the settlement and by the time we query the last batch, this batch wasn't accepted yet. go uevent.MustSubscribe(ctx, m.Pubsub, "updateSubmittedHeightLoop", settlement.EventQueryNewSettlementBatchAccepted, m.UpdateLastSubmittedHeight, m.logger) - go uevent.MustSubscribe(ctx, m.Pubsub, "newBondedSequencer", settlement.EventQueryNewBondedSequencer, m.UpdateLastSubmittedHeight, m.logger) + go uevent.MustSubscribe(ctx, m.Pubsub, "newBondedSequencer", settlement.EventQueryNewBondedSequencer, m.UpdateSequencerSet, m.logger) // Sequencer must wait till DA is synced to start submitting blobs <-m.DAClient.Synced() diff --git a/block/sequencers.go b/block/sequencers.go index b7265d2d7..db37d4d57 100644 --- a/block/sequencers.go +++ b/block/sequencers.go @@ -190,13 +190,17 @@ func (m *Manager) UpdateSequencerSet(event pubsub.Message) { return } - newSeqAddr := eventData.SeqAddr + if m.State.Sequencers.GetByAddress(eventData.SeqAddr) != nil { + m.logger.Debug("Sequencer not added from new bonded sequencer event because already in the list.") + return + } - sequencers := m.State.Sequencers.Sequencers - newSequencer, err := m.SLClient.GetSequencerByAddress(newSeqAddr) + newSequencer, err := m.SLClient.GetSequencerByAddress(eventData.SeqAddr) if err != nil { - m.logger.Error("unable to add new sequencer from event. err:%w", err) + m.logger.Error("Unable to add new sequencer from event. err:%w", err) + return } + sequencers := m.State.Sequencers.Sequencers sequencers = append(sequencers, newSequencer) m.State.Sequencers.SetSequencers(sequencers) } From 7caa95770d49db34d590b83794cdfe43d44e2601 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 30 Sep 2024 14:58:13 +0200 Subject: [PATCH 4/8] lint fix --- settlement/dymension/dymension.go | 1 - 1 file changed, 1 deletion(-) diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index dfb4a8b38..b0ab5c2dd 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -337,7 +337,6 @@ func (c *Client) GetSequencerByAddress(address string) (types.Sequencer, error) } return err }) - if err != nil { return types.Sequencer{}, err } From bc9eac9ede8a11ab10ca785764d080a3be363cc1 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 8 Oct 2024 09:46:01 +0200 Subject: [PATCH 5/8] fixing comments --- settlement/grpc/grpc.go | 2 +- settlement/local/local.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index 7b243064a..a4889d80a 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -230,7 +230,7 @@ func (c *Client) GetProposer() *types.Sequencer { // GetSequencerByAddress returns all sequencer information by its address. Not implemented since it will not be used in grpc SL func (c *Client) GetSequencerByAddress(address string) (types.Sequencer, error) { - return types.Sequencer{}, nil + panic("GetSequencerByAddress not implemented in grpc SL") } // GetAllSequencers implements settlement.ClientI. diff --git a/settlement/local/local.go b/settlement/local/local.go index ed36cf79e..bacae1f10 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -208,7 +208,7 @@ func (c *Client) GetProposer() *types.Sequencer { // GetSequencerByAddress returns all sequencer information by its address. Not implemented since it will not be used in mock SL func (c *Client) GetSequencerByAddress(address string) (types.Sequencer, error) { - return types.Sequencer{}, nil + panic("GetSequencerByAddress not implemented in mock SL") } // GetAllSequencers implements settlement.ClientI. From 3756c476b338844b4af1ea7929c80842ea4eb876 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 8 Oct 2024 09:46:55 +0200 Subject: [PATCH 6/8] fixing comments --- block/manager.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/manager.go b/block/manager.go index 71120aa70..978632ce0 100644 --- a/block/manager.go +++ b/block/manager.go @@ -173,6 +173,9 @@ func (m *Manager) Start(ctx context.Context) error { return m.PruningLoop(ctx) }) + // listen to new bonded sequencers events to add them in the sequencer set + go uevent.MustSubscribe(ctx, m.Pubsub, "newBondedSequencer", settlement.EventQueryNewBondedSequencer, m.UpdateSequencerSet, m.logger) + /* ----------------------------- full node mode ----------------------------- */ if !isProposer { // Full-nodes can sync from DA but it is not necessary to wait for it, since it can sync from P2P as well in parallel. @@ -194,7 +197,6 @@ func (m *Manager) Start(ctx context.Context) error { /* ----------------------------- sequencer mode ----------------------------- */ // Subscribe to batch events, to update last submitted height in case batch confirmation was lost. This could happen if the sequencer crash/restarted just after submitting a batch to the settlement and by the time we query the last batch, this batch wasn't accepted yet. go uevent.MustSubscribe(ctx, m.Pubsub, "updateSubmittedHeightLoop", settlement.EventQueryNewSettlementBatchAccepted, m.UpdateLastSubmittedHeight, m.logger) - go uevent.MustSubscribe(ctx, m.Pubsub, "newBondedSequencer", settlement.EventQueryNewBondedSequencer, m.UpdateSequencerSet, m.logger) // Sequencer must wait till DA is synced to start submitting blobs <-m.DAClient.Synced() From 0a33e1afb2a865e2920d76f7f14067e18fc8899e Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 8 Oct 2024 09:47:52 +0200 Subject: [PATCH 7/8] Update block/sequencers.go Co-authored-by: Michael Tsitrin <114929630+mtsitrin@users.noreply.github.com> --- block/sequencers.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/sequencers.go b/block/sequencers.go index db37d4d57..6c72d4d22 100644 --- a/block/sequencers.go +++ b/block/sequencers.go @@ -200,7 +200,6 @@ func (m *Manager) UpdateSequencerSet(event pubsub.Message) { m.logger.Error("Unable to add new sequencer from event. err:%w", err) return } - sequencers := m.State.Sequencers.Sequencers - sequencers = append(sequencers, newSequencer) + sequencers := append(m.State.Sequencers.Sequencers, newSequencer) m.State.Sequencers.SetSequencers(sequencers) } From 5f2cc0e72ca9eac2d99f17d8b31ca3f1a62fec2e Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 8 Oct 2024 09:49:39 +0200 Subject: [PATCH 8/8] fixing comments --- settlement/local/local.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settlement/local/local.go b/settlement/local/local.go index bacae1f10..579ddfb0f 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -208,7 +208,7 @@ func (c *Client) GetProposer() *types.Sequencer { // GetSequencerByAddress returns all sequencer information by its address. Not implemented since it will not be used in mock SL func (c *Client) GetSequencerByAddress(address string) (types.Sequencer, error) { - panic("GetSequencerByAddress not implemented in mock SL") + panic("GetSequencerByAddress not implemented in local SL") } // GetAllSequencers implements settlement.ClientI.