From de9c1cbc49eedc1633260506c689cccdcae4ae86 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 30 Oct 2024 17:53:06 +0100 Subject: [PATCH 001/119] temp commit to merge main --- block/fork.go | 63 ++++++ block/fork_test.go | 41 ++++ .../dymint/settlement/mock_ClientI.go | 57 +++++ .../dymension/rollapp/rollapp.proto | 6 + settlement/dymension/dymension.go | 33 +++ settlement/grpc/grpc.go | 5 + settlement/local/local.go | 5 + settlement/settlement.go | 3 + types/instruction.go | 47 +++++ .../dymension/rollapp/rollapp.pb.go | 198 ++++++++++++------ types/rollapp.go | 9 + 11 files changed, 407 insertions(+), 60 deletions(-) create mode 100644 block/fork.go create mode 100644 block/fork_test.go create mode 100644 types/instruction.go create mode 100644 types/rollapp.go diff --git a/block/fork.go b/block/fork.go new file mode 100644 index 000000000..12d48541a --- /dev/null +++ b/block/fork.go @@ -0,0 +1,63 @@ +package block + +import ( + "context" + "time" + + "github.com/dymensionxyz/dymint/types" +) + +// MonitorForkUpdate listens to the hub +func (m *Manager) MonitorForkUpdate(ctx context.Context) error { + ticker := time.NewTicker(15 * time.Second) + defer ticker.Stop() + + for { + select { + case <-ctx.Done(): + return nil + case <-ticker.C: + if err := m.checkForkUpdate(); err != nil { + continue + } + } + } +} + +// checkForkUpdate checks if the hub has a fork update +func (m *Manager) checkForkUpdate() error { + rollapp, err := m.SLClient.GetRollapp() + if err != nil { + return err + } + + lastBlock, err := m.Store.LoadBlock(m.State.Height()) + + if m.shouldStopNode(rollapp, lastBlock) { + createInstruction(rollapp) + } + + return nil +} + +func createInstruction(rollapp *types.Rollapp) { + instruction := types.Instruction{ + Revision: rollapp.Revision, + RevisionStartHeight: rollapp.RevisionStartHeight, + Sequencer: + } +} + +// shouldStopNode determines if a rollapp node should be stopped based on revision criteria. +// +// This method checks two conditions to decide if a node should be stopped: +// 1. If the current state height is greater than or equal to the rollapp's revision start height +// 2. If the block's app version (equivalent to revision) is less than the rollapp's revision +func (m *Manager) shouldStopNode(rollapp *types.Rollapp, block *types.Block) bool { + revision := block.Header.Version.App + if m.State.Height() >= rollapp.RevisionStartHeight && revision < rollapp.Revision { + return true + } + + return false +} diff --git a/block/fork_test.go b/block/fork_test.go new file mode 100644 index 000000000..5747765fe --- /dev/null +++ b/block/fork_test.go @@ -0,0 +1,41 @@ +package block + +import ( + "github.com/dymensionxyz/dymint/types" + "github.com/stretchr/testify/require" + "testing" +) + +func TestPersistInstruction(t *testing.T) { + dir := t.TempDir() + + instructionWithNilFaultyDrs := types.Instruction{ + Revision: 1, + RevisionStartHeight: 1, + Sequencer: "sequencer", + FaultyDRS: nil, + } + + err := types.PersistInstructionToDisk(dir, instructionWithNilFaultyDrs) + require.NoError(t, err) + + instruction, err := types.LoadInstructionFromDisk(dir) + require.NoError(t, err) + require.Equal(t, instructionWithNilFaultyDrs, instruction) + + faultyDrs := new(uint64) + *faultyDrs = 1 + instructionWithFaultyDrs := types.Instruction{ + Revision: 1, + RevisionStartHeight: 1, + Sequencer: "sequencer", + FaultyDRS: faultyDrs, + } + + err = types.PersistInstructionToDisk(dir, instructionWithFaultyDrs) + require.NoError(t, err) + + instruction, err = types.LoadInstructionFromDisk(dir) + require.NoError(t, err) + require.Equal(t, instructionWithFaultyDrs, instruction) +} diff --git a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go index ad870557c..c0a234fee 100644 --- a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go +++ b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go @@ -534,6 +534,63 @@ func (_c *MockClientI_GetProposer_Call) RunAndReturn(run func() *types.Sequencer return _c } +// GetRollapp provides a mock function with given fields: +func (_m *MockClientI) GetRollapp() (*types.Rollapp, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetRollapp") + } + + var r0 *types.Rollapp + var r1 error + if rf, ok := ret.Get(0).(func() (*types.Rollapp, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *types.Rollapp); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.Rollapp) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientI_GetRollapp_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRollapp' +type MockClientI_GetRollapp_Call struct { + *mock.Call +} + +// GetRollapp is a helper method to define mock.On call +func (_e *MockClientI_Expecter) GetRollapp() *MockClientI_GetRollapp_Call { + return &MockClientI_GetRollapp_Call{Call: _e.mock.On("GetRollapp")} +} + +func (_c *MockClientI_GetRollapp_Call) Run(run func()) *MockClientI_GetRollapp_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClientI_GetRollapp_Call) Return(_a0 *types.Rollapp, _a1 error) *MockClientI_GetRollapp_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientI_GetRollapp_Call) RunAndReturn(run func() (*types.Rollapp, error)) *MockClientI_GetRollapp_Call { + _c.Call.Return(run) + return _c +} + // GetSequencerByAddress provides a mock function with given fields: address func (_m *MockClientI) GetSequencerByAddress(address string) (types.Sequencer, error) { ret := _m.Called(address) diff --git a/proto/types/dymensionxyz/dymension/rollapp/rollapp.proto b/proto/types/dymensionxyz/dymension/rollapp/rollapp.proto index dfda3ad07..e12e1c042 100644 --- a/proto/types/dymensionxyz/dymension/rollapp/rollapp.proto +++ b/proto/types/dymensionxyz/dymension/rollapp/rollapp.proto @@ -74,6 +74,12 @@ message Rollapp { // The LastStateUpdateHeight HUB height when the last state update was // received int64 last_state_update_height = 18; + + // Revision is the revision number of the rollapp + int64 revision = 19; + + // RevisionStartHeight is the height at which the revision was started + int64 revision_start_height = 20; } message GenesisInfo { diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index 00d07caed..ca7b3a906 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -556,6 +556,39 @@ func (c *Client) GetNextProposer() (*types.Sequencer, error) { return nil, fmt.Errorf("next proposer not found in bonded set: %w", gerrc.ErrInternal) } +func (c *Client) GetRollapp() (*types.Rollapp, error) { + var res *rollapptypes.QueryGetRollappResponse + req := &rollapptypes.QueryGetRollappRequest{ + RollappId: c.rollappId, + } + + err := c.RunWithRetry(func() error { + var err error + res, err = c.cosmosClient.GetRollappClient().Rollapp(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 nil, fmt.Errorf("get rollapp: %w", err) + } + + // not supposed to happen, but just in case + if res == nil { + return nil, fmt.Errorf("empty response: %w", gerrc.ErrUnknown) + } + + return &types.Rollapp{ + RollappID: c.rollappId, + Revision: uint64(res.Rollapp.Revision), + RevisionStartHeight: uint64(res.Rollapp.RevisionStartHeight), + }, nil +} + func (c *Client) broadcastBatch(msgUpdateState *rollapptypes.MsgUpdateState) error { txResp, err := c.cosmosClient.BroadcastTx(c.config.DymAccountName, msgUpdateState) if err != nil { diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index f10437ec2..03f73df86 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -51,6 +51,11 @@ type Client struct { refreshTime int } +func (c *Client) GetRollapp() (*types.Rollapp, error) { + //TODO implement me + panic("implement me") +} + var _ settlement.ClientI = (*Client)(nil) // Init initializes the mock layer client. diff --git a/settlement/local/local.go b/settlement/local/local.go index 989bac2d2..63fb6ffbf 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -54,6 +54,11 @@ type Client struct { settlementKV store.KV } +func (c *Client) GetRollapp() (*types.Rollapp, error) { + //TODO implement me + panic("implement me") +} + var _ settlement.ClientI = (*Client)(nil) // Init initializes the mock layer client. diff --git a/settlement/settlement.go b/settlement/settlement.go index 98d54bc85..1925fb63e 100644 --- a/settlement/settlement.go +++ b/settlement/settlement.go @@ -94,4 +94,7 @@ type ClientI interface { // GetNextProposer returns the next proposer for this chain in case of a rotation. // If no rotation is in progress, it should return nil. GetNextProposer() (*types.Sequencer, error) + CheckRotationInProgress() (*types.Sequencer, error) + // GetRollapp returns the rollapp information. + GetRollapp() (*types.Rollapp, error) } diff --git a/types/instruction.go b/types/instruction.go new file mode 100644 index 000000000..4d01e6594 --- /dev/null +++ b/types/instruction.go @@ -0,0 +1,47 @@ +package types + +import ( + "encoding/json" + "os" + "path/filepath" +) + +type Instruction struct { + Revision uint64 + RevisionStartHeight uint64 + Sequencer string + FaultyDRS *uint64 +} + +const instructionFileName = "instruction.json" + +func PersistInstructionToDisk(dir string, instruction Instruction) error { + if err := os.MkdirAll(dir, 0755); err != nil { + return err + } + + data, err := json.Marshal(instruction) + if err != nil { + return err + } + + filePath := filepath.Join(dir, instructionFileName) + return os.WriteFile(filePath, data, 0644) +} + +func LoadInstructionFromDisk(dir string) (Instruction, error) { + var instruction Instruction + + filePath := filepath.Join(dir, instructionFileName) + data, err := os.ReadFile(filePath) + if err != nil { + return Instruction{}, err + } + + err = json.Unmarshal(data, &instruction) + if err != nil { + return Instruction{}, err + } + + return instruction, nil +} diff --git a/types/pb/dymensionxyz/dymension/rollapp/rollapp.pb.go b/types/pb/dymensionxyz/dymension/rollapp/rollapp.pb.go index 50d7ac057..c4b992df4 100644 --- a/types/pb/dymensionxyz/dymension/rollapp/rollapp.pb.go +++ b/types/pb/dymensionxyz/dymension/rollapp/rollapp.pb.go @@ -150,6 +150,10 @@ type Rollapp struct { // The LastStateUpdateHeight HUB height when the last state update was // received LastStateUpdateHeight int64 `protobuf:"varint,18,opt,name=last_state_update_height,json=lastStateUpdateHeight,proto3" json:"last_state_update_height,omitempty"` + // Revision is the revision number of the rollapp + Revision int64 `protobuf:"varint,19,opt,name=revision,proto3" json:"revision,omitempty"` + // RevisionStartHeight is the height at which the revision was started + RevisionStartHeight int64 `protobuf:"varint,20,opt,name=revision_start_height,json=revisionStartHeight,proto3" json:"revision_start_height,omitempty"` } func (m *Rollapp) Reset() { *m = Rollapp{} } @@ -276,6 +280,20 @@ func (m *Rollapp) GetLastStateUpdateHeight() int64 { return 0 } +func (m *Rollapp) GetRevision() int64 { + if m != nil { + return m.Revision + } + return 0 +} + +func (m *Rollapp) GetRevisionStartHeight() int64 { + if m != nil { + return m.RevisionStartHeight + } + return 0 +} + type GenesisInfo struct { // checksum used to verify integrity of the genesis file GenesisChecksum string `protobuf:"bytes,1,opt,name=genesis_checksum,json=genesisChecksum,proto3" json:"genesis_checksum,omitempty"` @@ -546,66 +564,68 @@ func init() { } var fileDescriptor_3b0028f80c0f8489 = []byte{ - // 941 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcb, 0x6e, 0xdb, 0x46, - 0x14, 0x35, 0x2d, 0x59, 0x92, 0xaf, 0x6c, 0x89, 0x99, 0xc4, 0x05, 0x2b, 0xd4, 0xb2, 0xa0, 0x02, - 0x85, 0x8a, 0x34, 0x24, 0x2a, 0xb7, 0xe8, 0x3a, 0x6e, 0xed, 0x58, 0x6e, 0x0d, 0x04, 0xf4, 0xa3, - 0x40, 0x16, 0x65, 0x46, 0xe4, 0x88, 0x22, 0x42, 0x0e, 0x59, 0xce, 0x48, 0x8d, 0xfc, 0x01, 0x5d, - 0xe7, 0xb3, 0xb2, 0x0c, 0xba, 0x2a, 0xba, 0x48, 0x0b, 0xfb, 0x33, 0xba, 0x29, 0xe6, 0x41, 0x59, - 0x76, 0xd2, 0x5a, 0xcd, 0x6a, 0x78, 0x5f, 0x67, 0xee, 0xe3, 0xdc, 0x21, 0xf4, 0xf9, 0x2c, 0x23, - 0xcc, 0x09, 0x66, 0x09, 0xa1, 0x2c, 0x4a, 0xe9, 0xcb, 0xd9, 0xc5, 0xb5, 0xe0, 0xe4, 0x69, 0x1c, - 0xe3, 0x2c, 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0x8c, 0x13, 0x16, - 0xd4, 0x87, 0xad, 0x38, 0x9a, 0x8a, 0x62, 0x99, 0x47, 0xa6, 0x84, 0x72, 0x6f, 0x4c, 0xa2, 0x70, - 0xcc, 0xad, 0x7b, 0x1d, 0xa3, 0x57, 0x72, 0xef, 0x17, 0xc6, 0x7d, 0x61, 0x3b, 0x94, 0x26, 0xf4, - 0x0d, 0x58, 0x31, 0x66, 0x5c, 0xd1, 0xc8, 0x9b, 0x64, 0x81, 0x38, 0x74, 0x18, 0x92, 0x61, 0x5b, - 0xc2, 0x2e, 0x69, 0x71, 0x26, 0xad, 0x2a, 0xb0, 0xfb, 0x05, 0x54, 0x54, 0x91, 0xa8, 0x09, 0xf5, - 0x33, 0xca, 0x32, 0xe2, 0x47, 0xa3, 0x88, 0x04, 0xe6, 0x0a, 0xaa, 0x42, 0x69, 0xff, 0xfc, 0xd8, - 0x34, 0x50, 0x0d, 0xca, 0x3f, 0x3e, 0x3e, 0x39, 0x36, 0x57, 0x8f, 0xca, 0xb5, 0x92, 0x59, 0x3d, - 0x2a, 0xd7, 0xc0, 0xac, 0x77, 0x7f, 0x2d, 0x41, 0x7d, 0x61, 0x4a, 0xe8, 0x73, 0x30, 0x8b, 0x41, - 0xfb, 0x63, 0xe2, 0xbf, 0x60, 0x93, 0x44, 0xef, 0x41, 0x53, 0xeb, 0xbf, 0xd5, 0x6a, 0xf4, 0x29, - 0x6c, 0x0e, 0x89, 0x3f, 0xde, 0xed, 0x7b, 0x59, 0x4e, 0x46, 0xd1, 0x4b, 0xbd, 0x15, 0x1b, 0x4a, - 0xf9, 0x54, 0xea, 0xd0, 0x39, 0x6c, 0x50, 0xcc, 0xa3, 0x29, 0xf1, 0x02, 0x42, 0xd3, 0xc4, 0x2a, - 0xc9, 0x6e, 0x3e, 0xba, 0x6b, 0x74, 0xdf, 0x09, 0xe7, 0x82, 0x87, 0x05, 0x75, 0x14, 0x90, 0x34, - 0xa1, 0x33, 0x68, 0xcc, 0xa9, 0x33,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d1, 0x05, 0x09, 0x16, 0x2e, - 0x29, 0x7d, 0xd0, 0x25, 0xff, 0x0e, 0x88, 0xba, 0xb0, 0xa1, 0x8c, 0x6a, 0x4d, 0x25, 0x45, 0xcb, - 0xee, 0x0d, 0x1d, 0xfa, 0x0a, 0xb6, 0x6e, 0x01, 0x68, 0xe7, 0x35, 0xe9, 0xfc, 0x7e, 0xe3, 0xde, - 0xf3, 0xd7, 0x97, 0x6d, 0xe3, 0xcd, 0x65, 0xdb, 0xf8, 0xeb, 0xb2, 0x6d, 0xbc, 0xba, 0x6a, 0xaf, - 0xbc, 0xb9, 0x6a, 0xaf, 0xfc, 0x7e, 0xd5, 0x5e, 0x79, 0x76, 0xb0, 0x30, 0xb8, 0xdb, 0xbf, 0xd4, - 0x88, 0x72, 0x35, 0x3a, 0x27, 0x1b, 0xde, 0xf1, 0xbf, 0x1d, 0x56, 0xe4, 0x43, 0xb7, 0xfb, 0x4f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x3e, 0x25, 0x96, 0xa1, 0x7f, 0x08, 0x00, 0x00, + // 969 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x5f, 0x6f, 0xdb, 0x54, + 0x14, 0xaf, 0x9b, 0x34, 0x71, 0x4f, 0xfa, 0xc7, 0xbb, 0x6d, 0x91, 0x89, 0x68, 0x1a, 0x05, 0x09, + 0x05, 0x8d, 0xd9, 0x22, 0x05, 0xf1, 0xbc, 0x42, 0xbb, 0xa6, 0x50, 0x69, 0x72, 0xda, 0x22, 0xed, + 0x01, 0xef, 0xc6, 0xbe, 0x71, 0xac, 0xd9, 0xd7, 0xc6, 0xd7, 0x09, 0x4b, 0x3f, 0x00, 0xcf, 0xfb, + 0x58, 0x93, 0x78, 0x99, 0x78, 0x42, 0x3c, 0x0c, 0xd4, 0x7e, 0x11, 0x74, 0xff, 0xd8, 0x4d, 0xbb, + 0x41,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, 0x67, 0x84, + 0x31, 0x35, 0x06, 0x85, 0xd8, 0xf9, 0x7d, 0x19, 0x36, 0xd4, 0x66, 0x0f, 0x26, 0x71, 0x8c, 0xb3, + 0x19, 0xfa, 0x04, 0x6e, 0x1e, 0xe9, 0x77, 0x5f, 0xed, 0x67, 0x60, 0x44, 0x38, 0x27, 0x6a, 0x6f, + 0xfa, 0xd4, 0x27, 0x72, 0xb4, 0x16, 0x48, 0x5f, 0x79, 0x8c, 0x12, 0xe1, 0xe5, 0xbc, 0xc3, 0x83, + 0x22, 0xf8, 0x58, 0xea, 0x8e, 0x42, 0x8a, 0xa3, 0xf0, 0x92, 0xf8, 0x73, 0x97, 0x54, 0x3e, 0xe8, + 0x92, 0x7f, 0x27, 0x44, 0x1d, 0x58, 0x93, 0xa0, 0x5c, 0x53, 0x31, 0xa2, 0x55, 0xe7, 0x96, 0x0e, + 0x7d, 0x05, 0x3b, 0x77, 0x08, 0x94, 0xf1, 0x8a, 0x30, 0x7e, 0x3f, 0x78, 0xf0, 0xfc, 0xf5, 0x55, + 0x4b, 0x7b, 0x73, 0xd5, 0xd2, 0xfe, 0xbe, 0x6a, 0x69, 0xaf, 0xae, 0x5b, 0x4b, 0x6f, 0xae, 0x5b, + 0x4b, 0x7f, 0x5c, 0xb7, 0x96, 0x9e, 0x1d, 0xcd, 0x35, 0xee, 0xee, 0x2f, 0x3a, 0xa4, 0xb9, 0x6c, + 0x9d, 0x9d, 0x0e, 0xef, 0xf9, 0x7f, 0x0f, 0x6b, 0xe2, 0xe1, 0xdc, 0xff, 0x27, 0x00, 0x00, 0xff, + 0xff, 0xd6, 0xda, 0x27, 0x18, 0xcf, 0x08, 0x00, 0x00, } func (m *RollappGenesisState) Marshal() (dAtA []byte, err error) { @@ -661,6 +681,20 @@ func (m *Rollapp) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.RevisionStartHeight != 0 { + i = encodeVarintRollapp(dAtA, i, uint64(m.RevisionStartHeight)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa0 + } + if m.Revision != 0 { + i = encodeVarintRollapp(dAtA, i, uint64(m.Revision)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x98 + } if m.LastStateUpdateHeight != 0 { i = encodeVarintRollapp(dAtA, i, uint64(m.LastStateUpdateHeight)) i-- @@ -1067,6 +1101,12 @@ func (m *Rollapp) Size() (n int) { if m.LastStateUpdateHeight != 0 { n += 2 + sovRollapp(uint64(m.LastStateUpdateHeight)) } + if m.Revision != 0 { + n += 2 + sovRollapp(uint64(m.Revision)) + } + if m.RevisionStartHeight != 0 { + n += 2 + sovRollapp(uint64(m.RevisionStartHeight)) + } return n } @@ -1623,6 +1663,44 @@ func (m *Rollapp) Unmarshal(dAtA []byte) error { break } } + case 19: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + } + m.Revision = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRollapp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Revision |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 20: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RevisionStartHeight", wireType) + } + m.RevisionStartHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRollapp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RevisionStartHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipRollapp(dAtA[iNdEx:]) diff --git a/types/rollapp.go b/types/rollapp.go new file mode 100644 index 000000000..286c9971d --- /dev/null +++ b/types/rollapp.go @@ -0,0 +1,9 @@ +package types + +type Rollapp struct { + RollappID string + + Revision uint64 + + RevisionStartHeight uint64 +} From 76e3b1af66b942ba2864f652084359d1f29bfda6 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 30 Oct 2024 18:43:44 +0100 Subject: [PATCH 002/119] fork validation and send freeze signal --- block/fork.go | 52 ++++++++++++++++++++++++++++++++++++---- block/manager.go | 2 ++ settlement/settlement.go | 2 ++ types/state_info.go | 5 ++++ 4 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 types/state_info.go diff --git a/block/fork.go b/block/fork.go index 12d48541a..145bce69f 100644 --- a/block/fork.go +++ b/block/fork.go @@ -2,6 +2,9 @@ package block import ( "context" + "fmt" + "github.com/dymensionxyz/dymint/node/events" + uevent "github.com/dymensionxyz/dymint/utils/event" "time" "github.com/dymensionxyz/dymint/types" @@ -17,7 +20,7 @@ func (m *Manager) MonitorForkUpdate(ctx context.Context) error { case <-ctx.Done(): return nil case <-ticker.C: - if err := m.checkForkUpdate(); err != nil { + if err := m.checkForkUpdate(ctx); err != nil { continue } } @@ -25,27 +28,47 @@ func (m *Manager) MonitorForkUpdate(ctx context.Context) error { } // checkForkUpdate checks if the hub has a fork update -func (m *Manager) checkForkUpdate() error { +func (m *Manager) checkForkUpdate(ctx context.Context) error { rollapp, err := m.SLClient.GetRollapp() if err != nil { return err } lastBlock, err := m.Store.LoadBlock(m.State.Height()) + if err != nil { + return err + } if m.shouldStopNode(rollapp, lastBlock) { - createInstruction(rollapp) + err = m.createInstruction(rollapp, lastBlock) + if err != nil { + return err + } + + m.freezeNode(ctx) } return nil } -func createInstruction(rollapp *types.Rollapp) { +func (m *Manager) createInstruction(rollapp *types.Rollapp, block *types.Block) error { + info, err := m.SLClient.GetStateInfo(block.Header.Height) + if err != nil { + return err + } + instruction := types.Instruction{ Revision: rollapp.Revision, RevisionStartHeight: rollapp.RevisionStartHeight, - Sequencer: + Sequencer: info.NextProposer, } + + err = types.PersistInstructionToDisk(m.Conf.RootDir, instruction) + if err != nil { + return err + } + + return nil } // shouldStopNode determines if a rollapp node should be stopped based on revision criteria. @@ -56,8 +79,27 @@ func createInstruction(rollapp *types.Rollapp) { func (m *Manager) shouldStopNode(rollapp *types.Rollapp, block *types.Block) bool { revision := block.Header.Version.App if m.State.Height() >= rollapp.RevisionStartHeight && revision < rollapp.Revision { + m.logger.Info( + "Freezing node due to fork update", + "local_block_height", + m.State.Height(), + "rollapp_revision_start_height", + rollapp.RevisionStartHeight, + "local_revision", + revision, + "rollapp_revision", + rollapp.Revision, + ) return true } return false } + +// freezeNode stops the rollapp node +func (m *Manager) freezeNode(ctx context.Context) { + m.logger.Info("Freezing node due to fork update") + + err := fmt.Errorf("node frozen due to fork update") + uevent.MustPublish(ctx, m.Pubsub, &events.DataHealthStatus{Error: err}, events.HealthStatusList) +} diff --git a/block/manager.go b/block/manager.go index cf26f0a39..6f805ff9f 100644 --- a/block/manager.go +++ b/block/manager.go @@ -53,6 +53,7 @@ type Manager struct { Genesis *tmtypes.GenesisDoc GenesisChecksum string LocalKey crypto.PrivKey + RootDir string // Store and execution Store store.Store @@ -155,6 +156,7 @@ func NewManager( Pubsub: pubsub, P2PClient: p2pClient, LocalKey: localKey, + RootDir: conf.RootDir, Conf: conf.BlockManagerConfig, Genesis: genesis, GenesisChecksum: genesisChecksum, diff --git a/settlement/settlement.go b/settlement/settlement.go index 1925fb63e..758921805 100644 --- a/settlement/settlement.go +++ b/settlement/settlement.go @@ -97,4 +97,6 @@ type ClientI interface { CheckRotationInProgress() (*types.Sequencer, error) // GetRollapp returns the rollapp information. GetRollapp() (*types.Rollapp, error) + // GetStateInfo returns the state info for the given index. + GetStateInfo(index uint64) (*types.StateInfo, error) } diff --git a/types/state_info.go b/types/state_info.go new file mode 100644 index 000000000..35a2ae4d3 --- /dev/null +++ b/types/state_info.go @@ -0,0 +1,5 @@ +package types + +type StateInfo struct { + NextProposer string +} From b2bf43e5b91567a5d70cfdc77b2bcbb5f3581ca2 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 30 Oct 2024 18:47:13 +0100 Subject: [PATCH 003/119] fix tests --- block/fork.go | 2 +- .../dymint/settlement/mock_ClientI.go | 58 +++++++++++++++++++ settlement/dymension/dymension.go | 5 ++ settlement/grpc/grpc.go | 5 ++ settlement/local/local.go | 5 ++ 5 files changed, 74 insertions(+), 1 deletion(-) diff --git a/block/fork.go b/block/fork.go index 145bce69f..4e824cdb2 100644 --- a/block/fork.go +++ b/block/fork.go @@ -63,7 +63,7 @@ func (m *Manager) createInstruction(rollapp *types.Rollapp, block *types.Block) Sequencer: info.NextProposer, } - err = types.PersistInstructionToDisk(m.Conf.RootDir, instruction) + err = types.PersistInstructionToDisk(m.RootDir, instruction) if err != nil { return err } diff --git a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go index c0a234fee..d2e70b5e1 100644 --- a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go +++ b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go @@ -647,6 +647,64 @@ func (_c *MockClientI_GetSequencerByAddress_Call) RunAndReturn(run func(string) return _c } +// GetStateInfo provides a mock function with given fields: index +func (_m *MockClientI) GetStateInfo(index uint64) (*types.StateInfo, error) { + ret := _m.Called(index) + + if len(ret) == 0 { + panic("no return value specified for GetStateInfo") + } + + var r0 *types.StateInfo + var r1 error + if rf, ok := ret.Get(0).(func(uint64) (*types.StateInfo, error)); ok { + return rf(index) + } + if rf, ok := ret.Get(0).(func(uint64) *types.StateInfo); ok { + r0 = rf(index) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.StateInfo) + } + } + + if rf, ok := ret.Get(1).(func(uint64) error); ok { + r1 = rf(index) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientI_GetStateInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetStateInfo' +type MockClientI_GetStateInfo_Call struct { + *mock.Call +} + +// GetStateInfo is a helper method to define mock.On call +// - index uint64 +func (_e *MockClientI_Expecter) GetStateInfo(index interface{}) *MockClientI_GetStateInfo_Call { + return &MockClientI_GetStateInfo_Call{Call: _e.mock.On("GetStateInfo", index)} +} + +func (_c *MockClientI_GetStateInfo_Call) Run(run func(index uint64)) *MockClientI_GetStateInfo_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64)) + }) + return _c +} + +func (_c *MockClientI_GetStateInfo_Call) Return(_a0 *types.StateInfo, _a1 error) *MockClientI_GetStateInfo_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientI_GetStateInfo_Call) RunAndReturn(run func(uint64) (*types.StateInfo, error)) *MockClientI_GetStateInfo_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/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index ca7b3a906..43016bc36 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -56,6 +56,11 @@ type Client struct { batchAcceptanceAttempts uint } +func (c *Client) GetStateInfo(index uint64) (*types.StateInfo, error) { + //TODO implement me + panic("implement me") +} + var _ settlement.ClientI = &Client{} // Init is called once. it initializes the struct members. diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index 03f73df86..73ff5d13f 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -51,6 +51,11 @@ type Client struct { refreshTime int } +func (c *Client) GetStateInfo(index uint64) (*types.StateInfo, error) { + //TODO implement me + panic("implement me") +} + func (c *Client) GetRollapp() (*types.Rollapp, error) { //TODO implement me panic("implement me") diff --git a/settlement/local/local.go b/settlement/local/local.go index 63fb6ffbf..93e6db371 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -54,6 +54,11 @@ type Client struct { settlementKV store.KV } +func (c *Client) GetStateInfo(index uint64) (*types.StateInfo, error) { + //TODO implement me + panic("implement me") +} + func (c *Client) GetRollapp() (*types.Rollapp, error) { //TODO implement me panic("implement me") From 879766cbb3b75eb61c2c87f10904ccde15cfdc76 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 30 Oct 2024 18:49:33 +0100 Subject: [PATCH 004/119] go lint --- block/fork.go | 3 ++- settlement/dymension/dymension.go | 2 +- settlement/grpc/grpc.go | 4 ++-- settlement/local/local.go | 4 ++-- types/instruction.go | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/block/fork.go b/block/fork.go index 4e824cdb2..afce53708 100644 --- a/block/fork.go +++ b/block/fork.go @@ -3,9 +3,10 @@ package block import ( "context" "fmt" + "time" + "github.com/dymensionxyz/dymint/node/events" uevent "github.com/dymensionxyz/dymint/utils/event" - "time" "github.com/dymensionxyz/dymint/types" ) diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index 43016bc36..17c1173d2 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -57,7 +57,7 @@ type Client struct { } func (c *Client) GetStateInfo(index uint64) (*types.StateInfo, error) { - //TODO implement me + // TODO implement me panic("implement me") } diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index 73ff5d13f..af6047615 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -52,12 +52,12 @@ type Client struct { } func (c *Client) GetStateInfo(index uint64) (*types.StateInfo, error) { - //TODO implement me + // TODO implement me panic("implement me") } func (c *Client) GetRollapp() (*types.Rollapp, error) { - //TODO implement me + // TODO implement me panic("implement me") } diff --git a/settlement/local/local.go b/settlement/local/local.go index 93e6db371..93697ac4b 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -55,12 +55,12 @@ type Client struct { } func (c *Client) GetStateInfo(index uint64) (*types.StateInfo, error) { - //TODO implement me + // TODO implement me panic("implement me") } func (c *Client) GetRollapp() (*types.Rollapp, error) { - //TODO implement me + // TODO implement me panic("implement me") } diff --git a/types/instruction.go b/types/instruction.go index 4d01e6594..b3250658a 100644 --- a/types/instruction.go +++ b/types/instruction.go @@ -16,7 +16,7 @@ type Instruction struct { const instructionFileName = "instruction.json" func PersistInstructionToDisk(dir string, instruction Instruction) error { - if err := os.MkdirAll(dir, 0755); err != nil { + if err := os.MkdirAll(dir, 0o755); err != nil { return err } @@ -26,7 +26,7 @@ func PersistInstructionToDisk(dir string, instruction Instruction) error { } filePath := filepath.Join(dir, instructionFileName) - return os.WriteFile(filePath, data, 0644) + return os.WriteFile(filePath, data, 0o644) } func LoadInstructionFromDisk(dir string) (Instruction, error) { From 0a7f39ba2474dd138d66647836850076381989c4 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 31 Oct 2024 10:38:03 +0100 Subject: [PATCH 005/119] move test file --- block/fork_test.go | 40 -------------------------------------- types/instruction_test.go | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 types/instruction_test.go diff --git a/block/fork_test.go b/block/fork_test.go index 5747765fe..bd5a2ecd1 100644 --- a/block/fork_test.go +++ b/block/fork_test.go @@ -1,41 +1 @@ package block - -import ( - "github.com/dymensionxyz/dymint/types" - "github.com/stretchr/testify/require" - "testing" -) - -func TestPersistInstruction(t *testing.T) { - dir := t.TempDir() - - instructionWithNilFaultyDrs := types.Instruction{ - Revision: 1, - RevisionStartHeight: 1, - Sequencer: "sequencer", - FaultyDRS: nil, - } - - err := types.PersistInstructionToDisk(dir, instructionWithNilFaultyDrs) - require.NoError(t, err) - - instruction, err := types.LoadInstructionFromDisk(dir) - require.NoError(t, err) - require.Equal(t, instructionWithNilFaultyDrs, instruction) - - faultyDrs := new(uint64) - *faultyDrs = 1 - instructionWithFaultyDrs := types.Instruction{ - Revision: 1, - RevisionStartHeight: 1, - Sequencer: "sequencer", - FaultyDRS: faultyDrs, - } - - err = types.PersistInstructionToDisk(dir, instructionWithFaultyDrs) - require.NoError(t, err) - - instruction, err = types.LoadInstructionFromDisk(dir) - require.NoError(t, err) - require.Equal(t, instructionWithFaultyDrs, instruction) -} diff --git a/types/instruction_test.go b/types/instruction_test.go new file mode 100644 index 000000000..e682445c9 --- /dev/null +++ b/types/instruction_test.go @@ -0,0 +1,41 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestPersistInstruction(t *testing.T) { + dir := t.TempDir() + + instructionWithNilFaultyDrs := Instruction{ + Revision: 1, + RevisionStartHeight: 1, + Sequencer: "sequencer", + FaultyDRS: nil, + } + + err := PersistInstructionToDisk(dir, instructionWithNilFaultyDrs) + require.NoError(t, err) + + instruction, err := LoadInstructionFromDisk(dir) + require.NoError(t, err) + require.Equal(t, instructionWithNilFaultyDrs, instruction) + + faultyDrs := new(uint64) + *faultyDrs = 1 + instructionWithFaultyDrs := Instruction{ + Revision: 1, + RevisionStartHeight: 1, + Sequencer: "sequencer", + FaultyDRS: faultyDrs, + } + + err = PersistInstructionToDisk(dir, instructionWithFaultyDrs) + require.NoError(t, err) + + instruction, err = LoadInstructionFromDisk(dir) + require.NoError(t, err) + require.Equal(t, instructionWithFaultyDrs, instruction) +} From f326c352c10274fc096c4b28ae508bb1fef9af7c Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 31 Oct 2024 14:03:10 +0100 Subject: [PATCH 006/119] add tests --- block/fork.go | 8 +- block/fork_test.go | 277 ++++++++++++++++++++++++++++++++++++++++++ block/manager_test.go | 9 +- 3 files changed, 290 insertions(+), 4 deletions(-) diff --git a/block/fork.go b/block/fork.go index afce53708..95a40d5a6 100644 --- a/block/fork.go +++ b/block/fork.go @@ -6,13 +6,17 @@ import ( "time" "github.com/dymensionxyz/dymint/node/events" - uevent "github.com/dymensionxyz/dymint/utils/event" - "github.com/dymensionxyz/dymint/types" + uevent "github.com/dymensionxyz/dymint/utils/event" ) // MonitorForkUpdate listens to the hub func (m *Manager) MonitorForkUpdate(ctx context.Context) error { + err := m.checkForkUpdate(ctx) + if err != nil { + return err + } + ticker := time.NewTicker(15 * time.Second) defer ticker.Stop() diff --git a/block/fork_test.go b/block/fork_test.go index bd5a2ecd1..684ab21fd 100644 --- a/block/fork_test.go +++ b/block/fork_test.go @@ -1 +1,278 @@ package block + +import ( + "context" + "github.com/dymensionxyz/dymint/node/events" + uevent "github.com/dymensionxyz/dymint/utils/event" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/tendermint/tendermint/libs/log" + "github.com/tendermint/tendermint/libs/pubsub" + + "github.com/dymensionxyz/dymint/mocks/github.com/dymensionxyz/dymint/settlement" + "github.com/dymensionxyz/dymint/mocks/github.com/dymensionxyz/dymint/store" + "github.com/dymensionxyz/dymint/types" +) + +func TestShouldStopNode(t *testing.T) { + tests := []struct { + name string + rollapp *types.Rollapp + block *types.Block + height uint64 + expected bool + }{ + { + name: "should stop - current height greater than revision start height and lower revision", + rollapp: &types.Rollapp{ + Revision: 2, + RevisionStartHeight: 100, + }, + block: &types.Block{ + Header: types.Header{ + Version: types.Version{ + App: 1, + }, + }, + }, + height: 150, + expected: true, + }, + { + name: "should not stop - current height less than revision start height", + rollapp: &types.Rollapp{ + Revision: 2, + RevisionStartHeight: 100, + }, + block: &types.Block{ + Header: types.Header{ + Version: types.Version{ + App: 1, + }, + }, + }, + height: 50, + expected: false, + }, + { + name: "should not stop - same revision", + rollapp: &types.Rollapp{ + Revision: 2, + RevisionStartHeight: 100, + }, + block: &types.Block{ + Header: types.Header{ + Version: types.Version{ + App: 2, + }, + }, + }, + height: 150, + expected: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + state := &types.State{} + state.LastBlockHeight.Store(tt.height) + + logger := log.NewNopLogger() + + manager := &Manager{ + State: state, + logger: logger, + } + + result := manager.shouldStopNode(tt.rollapp, tt.block) + assert.Equal(t, tt.expected, result) + }) + } +} + +func TestCheckForkUpdate(t *testing.T) { + ctx := context.Background() + + tests := []struct { + name string + setupMocks func(*settlement.MockClientI, *store.MockStore, *types.State) + expectedError bool + }{ + { + name: "successful check - no fork update needed", + setupMocks: func(mockSL *settlement.MockClientI, mockStore *store.MockStore, mockState *types.State) { + mockState.LastBlockHeight.Store(uint64(100)) + + mockSL.On("GetRollapp").Return(&types.Rollapp{ + Revision: 1, + RevisionStartHeight: 200, + }, nil) + + mockStore.On("LoadBlock", uint64(100)).Return(&types.Block{ + Header: types.Header{ + Version: types.Version{ + App: 1, + }, + }, + }, nil) + }, + expectedError: false, + }, + { + name: "error getting rollapp", + setupMocks: func(mockSL *settlement.MockClientI, mockStore *store.MockStore, mockState *types.State) { + mockSL.On("GetRollapp").Return((*types.Rollapp)(nil), assert.AnError) + }, + expectedError: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + mockSL := new(settlement.MockClientI) + mockStore := new(store.MockStore) + mockState := &types.State{} + + tt.setupMocks(mockSL, mockStore, mockState) + + manager := &Manager{ + SLClient: mockSL, + Store: mockStore, + State: mockState, + } + + err := manager.checkForkUpdate(ctx) + if tt.expectedError { + assert.Error(t, err) + } else { + assert.NoError(t, err) + } + }) + } +} + +func TestMonitorForkUpdate(t *testing.T) { + t.Skip() + ctx, cancel := context.WithTimeout(context.Background(), 50000*time.Millisecond) + defer cancel() + + mockSL := new(settlement.MockClientI) + mockStore := new(store.MockStore) + state := &types.State{} + + // Setup basic mocks for a successful check + state.LastBlockHeight.Store(uint64(100)) + mockSL.On("GetRollapp").Return(&types.Rollapp{ + Revision: 2, + RevisionStartHeight: 100, + }, nil) + + mockStore.On("LoadBlock", uint64(100)).Return(&types.Block{ + Header: types.Header{ + Height: 100, + Version: types.Version{ + App: 1, + }, + }, + }, nil) + + mockSL.On("GetStateInfo", uint64(100)).Return(&types.StateInfo{ + NextProposer: "sequencer1", + }, nil) + + logger := log.NewNopLogger() + + pubsubServer := pubsub.NewServer() + go uevent.MustSubscribe(ctx, pubsubServer, "RPCNodeHealthStatusHandler", events.QueryHealthStatus, func(event pubsub.Message) { + println("event") + }, logger) + + manager := &Manager{ + SLClient: mockSL, + Store: mockStore, + State: state, + logger: logger, + RootDir: t.TempDir(), + Pubsub: pubsubServer, + } + + // Run MonitorForkUpdate in a goroutine since it's a blocking operation + errCh := make(chan error) + go func() { + errCh <- manager.MonitorForkUpdate(ctx) + }() + + // Wait for context cancellation or error + select { + case err := <-errCh: + assert.NoError(t, err) + case <-ctx.Done(): + t.Fatal("MonitorForkUpdate did not return within the context deadline") + } +} + +func TestCreateInstruction(t *testing.T) { + tests := []struct { + name string + rollapp *types.Rollapp + block *types.Block + setupMocks func(*settlement.MockClientI) + expectedError bool + }{ + { + name: "successful instruction creation", + rollapp: &types.Rollapp{ + Revision: 2, + RevisionStartHeight: 100, + }, + block: &types.Block{ + Header: types.Header{ + Height: 150, + }, + }, + setupMocks: func(mockSL *settlement.MockClientI) { + mockSL.On("GetStateInfo", uint64(150)).Return(&types.StateInfo{ + NextProposer: "sequencer1", + }, nil) + }, + expectedError: false, + }, + { + name: "error getting state info", + rollapp: &types.Rollapp{ + Revision: 2, + RevisionStartHeight: 100, + }, + block: &types.Block{ + Header: types.Header{ + Height: 150, + }, + }, + setupMocks: func(mockSL *settlement.MockClientI) { + mockSL.On("GetStateInfo", uint64(150)).Return((*types.StateInfo)(nil), assert.AnError) + }, + expectedError: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + mockSL := new(settlement.MockClientI) + tt.setupMocks(mockSL) + + manager := &Manager{ + SLClient: mockSL, + RootDir: t.TempDir(), // Use temporary directory for testing + } + + err := manager.createInstruction(tt.rollapp, tt.block) + if tt.expectedError { + assert.Error(t, err) + } else { + assert.NoError(t, err) + } + }) + } +} diff --git a/block/manager_test.go b/block/manager_test.go index 95d1cccfd..2185ba322 100644 --- a/block/manager_test.go +++ b/block/manager_test.go @@ -8,8 +8,6 @@ import ( "testing" "time" - "github.com/dymensionxyz/gerr-cosmos/gerrc" - "github.com/ipfs/go-datastore" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -31,13 +29,20 @@ import ( "github.com/tendermint/tendermint/proxy" tmtypes "github.com/tendermint/tendermint/types" + "github.com/dymensionxyz/dymint/block" "github.com/dymensionxyz/dymint/config" "github.com/dymensionxyz/dymint/da" blockmocks "github.com/dymensionxyz/dymint/mocks/github.com/dymensionxyz/dymint/block" "github.com/dymensionxyz/dymint/node/events" + "github.com/dymensionxyz/dymint/p2p" + "github.com/dymensionxyz/dymint/settlement" slregistry "github.com/dymensionxyz/dymint/settlement/registry" "github.com/dymensionxyz/dymint/store" + "github.com/dymensionxyz/dymint/testutil" + "github.com/dymensionxyz/dymint/types" + "github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp" "github.com/dymensionxyz/dymint/utils/event" + "github.com/dymensionxyz/gerr-cosmos/gerrc" ) // TODO: test loading sequencer while rotation in progress From 389373845aa2dbb49a2a6ee70de78bfc7dfa5a85 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 31 Oct 2024 14:18:42 +0100 Subject: [PATCH 007/119] put rolllap fields in proto from int64 to uint64 --- block/fork_test.go | 4 +- .../dymension/rollapp/rollapp.proto | 4 +- settlement/dymension/dymension.go | 4 +- .../dymension/rollapp/rollapp.pb.go | 70 +++++++++---------- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/block/fork_test.go b/block/fork_test.go index 684ab21fd..15b401065 100644 --- a/block/fork_test.go +++ b/block/fork_test.go @@ -2,8 +2,6 @@ package block import ( "context" - "github.com/dymensionxyz/dymint/node/events" - uevent "github.com/dymensionxyz/dymint/utils/event" "testing" "time" @@ -13,7 +11,9 @@ import ( "github.com/dymensionxyz/dymint/mocks/github.com/dymensionxyz/dymint/settlement" "github.com/dymensionxyz/dymint/mocks/github.com/dymensionxyz/dymint/store" + "github.com/dymensionxyz/dymint/node/events" "github.com/dymensionxyz/dymint/types" + uevent "github.com/dymensionxyz/dymint/utils/event" ) func TestShouldStopNode(t *testing.T) { diff --git a/proto/types/dymensionxyz/dymension/rollapp/rollapp.proto b/proto/types/dymensionxyz/dymension/rollapp/rollapp.proto index e12e1c042..df3da8a1a 100644 --- a/proto/types/dymensionxyz/dymension/rollapp/rollapp.proto +++ b/proto/types/dymensionxyz/dymension/rollapp/rollapp.proto @@ -76,10 +76,10 @@ message Rollapp { int64 last_state_update_height = 18; // Revision is the revision number of the rollapp - int64 revision = 19; + uint64 revision = 19; // RevisionStartHeight is the height at which the revision was started - int64 revision_start_height = 20; + uint64 revision_start_height = 20; } message GenesisInfo { diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index 17c1173d2..93f90a77f 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -589,8 +589,8 @@ func (c *Client) GetRollapp() (*types.Rollapp, error) { return &types.Rollapp{ RollappID: c.rollappId, - Revision: uint64(res.Rollapp.Revision), - RevisionStartHeight: uint64(res.Rollapp.RevisionStartHeight), + Revision: res.Rollapp.Revision, + RevisionStartHeight: res.Rollapp.RevisionStartHeight, }, nil } diff --git a/types/pb/dymensionxyz/dymension/rollapp/rollapp.pb.go b/types/pb/dymensionxyz/dymension/rollapp/rollapp.pb.go index c4b992df4..60e2be449 100644 --- a/types/pb/dymensionxyz/dymension/rollapp/rollapp.pb.go +++ b/types/pb/dymensionxyz/dymension/rollapp/rollapp.pb.go @@ -151,9 +151,9 @@ type Rollapp struct { // received LastStateUpdateHeight int64 `protobuf:"varint,18,opt,name=last_state_update_height,json=lastStateUpdateHeight,proto3" json:"last_state_update_height,omitempty"` // Revision is the revision number of the rollapp - Revision int64 `protobuf:"varint,19,opt,name=revision,proto3" json:"revision,omitempty"` + Revision uint64 `protobuf:"varint,19,opt,name=revision,proto3" json:"revision,omitempty"` // RevisionStartHeight is the height at which the revision was started - RevisionStartHeight int64 `protobuf:"varint,20,opt,name=revision_start_height,json=revisionStartHeight,proto3" json:"revision_start_height,omitempty"` + RevisionStartHeight uint64 `protobuf:"varint,20,opt,name=revision_start_height,json=revisionStartHeight,proto3" json:"revision_start_height,omitempty"` } func (m *Rollapp) Reset() { *m = Rollapp{} } @@ -280,14 +280,14 @@ func (m *Rollapp) GetLastStateUpdateHeight() int64 { return 0 } -func (m *Rollapp) GetRevision() int64 { +func (m *Rollapp) GetRevision() uint64 { if m != nil { return m.Revision } return 0 } -func (m *Rollapp) GetRevisionStartHeight() int64 { +func (m *Rollapp) GetRevisionStartHeight() uint64 { if m != nil { return m.RevisionStartHeight } @@ -564,7 +564,7 @@ func init() { } var fileDescriptor_3b0028f80c0f8489 = []byte{ - // 969 bytes of a gzipped FileDescriptorProto + // 973 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x5f, 0x6f, 0xdb, 0x54, 0x14, 0xaf, 0x9b, 0x34, 0x71, 0x4f, 0xfa, 0xc7, 0xbb, 0x6d, 0x91, 0x89, 0x68, 0x1a, 0x05, 0x09, 0x05, 0x8d, 0xd9, 0x22, 0x05, 0xf1, 0xbc, 0x42, 0xbb, 0xa6, 0x50, 0x69, 0x72, 0xda, 0x22, 0xed, @@ -598,34 +598,34 @@ var fileDescriptor_3b0028f80c0f8489 = []byte{ 0x3d, 0xd8, 0x89, 0xc2, 0x29, 0x4f, 0x96, 0xb9, 0x64, 0x4a, 0x68, 0xee, 0x8e, 0x49, 0x18, 0x8c, 0x73, 0xf3, 0x41, 0x5b, 0xeb, 0x56, 0x9c, 0xad, 0x02, 0x3c, 0xe4, 0xd8, 0xb1, 0x80, 0xd0, 0x37, 0x60, 0x46, 0x98, 0xe5, 0x72, 0x8c, 0xdc, 0x49, 0xea, 0xf3, 0x43, 0xb9, 0x21, 0xe1, 0xb6, 0xc3, - 0x71, 0x31, 0x16, 0xe7, 0x02, 0x55, 0x8e, 0x4d, 0xd0, 0x33, 0x32, 0x0d, 0x79, 0xf6, 0xe6, 0x96, - 0x30, 0x2c, 0x65, 0x1e, 0x48, 0xf1, 0xcd, 0x89, 0xb3, 0x32, 0x90, 0x6d, 0x19, 0x48, 0x01, 0x0e, - 0x38, 0x26, 0xf9, 0x3a, 0x5f, 0x40, 0x4d, 0x16, 0x0d, 0x6d, 0x42, 0xe3, 0x9c, 0xb2, 0x94, 0x78, - 0xe1, 0x28, 0x24, 0xbe, 0xb1, 0x84, 0xea, 0x50, 0x39, 0xbc, 0x38, 0x35, 0x34, 0xa4, 0x43, 0xf5, - 0xc7, 0xc7, 0x83, 0x53, 0x63, 0xf9, 0xa4, 0xaa, 0x57, 0x8c, 0xfa, 0x49, 0x55, 0x07, 0xa3, 0xd1, - 0xf9, 0xb5, 0x02, 0x8d, 0xb9, 0xae, 0xa3, 0xcf, 0xc1, 0x28, 0x06, 0xc7, 0x1b, 0x13, 0xef, 0x05, - 0x9b, 0xc4, 0x6a, 0xaf, 0x36, 0x95, 0xfe, 0x5b, 0xa5, 0x46, 0x9f, 0xc2, 0xfa, 0x90, 0x78, 0xe3, - 0xfd, 0x9e, 0x9b, 0x66, 0x64, 0x14, 0xbe, 0x54, 0x5b, 0xb6, 0x26, 0x95, 0x4f, 0x85, 0x0e, 0x5d, - 0xc0, 0x1a, 0xc5, 0x79, 0x38, 0x25, 0xae, 0x4f, 0x68, 0x12, 0x9b, 0x15, 0xd1, 0x9d, 0x47, 0xf7, - 0x8d, 0xc2, 0x77, 0xdc, 0xb8, 0x98, 0xeb, 0x62, 0x14, 0x25, 0x91, 0x80, 0xd0, 0x39, 0x6c, 0x94, - 0xa3, 0x38, 0x49, 0xd3, 0x68, 0x66, 0x56, 0xf9, 0xed, 0x07, 0x16, 0x37, 0xfd, 0xf3, 0xed, 0xde, - 0x67, 0x41, 0x98, 0x8f, 0x27, 0x43, 0xcb, 0x4b, 0xe2, 0xe2, 0xfd, 0x93, 0xc7, 0x23, 0xe6, 0xbf, - 0xb0, 0xc5, 0x0b, 0x66, 0xf5, 0x69, 0xee, 0xac, 0x17, 0x73, 0x2b, 0x48, 0xf8, 0x72, 0x32, 0x82, - 0xf9, 0x23, 0xb4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b5, 0x9f, 0x81, 0x11, 0xe1, + 0x9c, 0xa8, 0xbd, 0xe9, 0x53, 0x9f, 0xc8, 0xd1, 0x5a, 0x20, 0x7d, 0xe5, 0x31, 0x4a, 0x84, 0x97, + 0xf3, 0x0e, 0x0f, 0x8a, 0xe0, 0x63, 0xa9, 0x3b, 0x0a, 0x29, 0x8e, 0xc2, 0x4b, 0xe2, 0xcf, 0x5d, + 0x52, 0xf9, 0xa0, 0x4b, 0xfe, 0x9d, 0x10, 0x75, 0x60, 0x4d, 0x82, 0x72, 0x4d, 0xc5, 0x88, 0x56, + 0x9d, 0x5b, 0x3a, 0xf4, 0x15, 0xec, 0xdc, 0x21, 0x50, 0xc6, 0x2b, 0xc2, 0xf8, 0xfd, 0xe0, 0xc1, + 0xf3, 0xd7, 0x57, 0x2d, 0xed, 0xcd, 0x55, 0x4b, 0xfb, 0xfb, 0xaa, 0xa5, 0xbd, 0xba, 0x6e, 0x2d, + 0xbd, 0xb9, 0x6e, 0x2d, 0xfd, 0x71, 0xdd, 0x5a, 0x7a, 0x76, 0x34, 0xd7, 0xb8, 0xbb, 0xbf, 0xe8, + 0x90, 0xe6, 0xb2, 0x75, 0x76, 0x3a, 0xbc, 0xe7, 0xff, 0x3d, 0xac, 0x89, 0x87, 0x73, 0xff, 0x9f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xda, 0x8e, 0x54, 0x3e, 0xcf, 0x08, 0x00, 0x00, } func (m *RollappGenesisState) Marshal() (dAtA []byte, err error) { @@ -1677,7 +1677,7 @@ func (m *Rollapp) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Revision |= int64(b&0x7F) << shift + m.Revision |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1696,7 +1696,7 @@ func (m *Rollapp) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.RevisionStartHeight |= int64(b&0x7F) << shift + m.RevisionStartHeight |= uint64(b&0x7F) << shift if b < 0x80 { break } From cdb0cf323fcdd3b97779396d65f4c25928f7d196 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 31 Oct 2024 14:32:28 +0100 Subject: [PATCH 008/119] add skip to test --- block/fork_test.go | 1 + types/instruction.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block/fork_test.go b/block/fork_test.go index 15b401065..f7ddf53cf 100644 --- a/block/fork_test.go +++ b/block/fork_test.go @@ -201,6 +201,7 @@ func TestMonitorForkUpdate(t *testing.T) { // Run MonitorForkUpdate in a goroutine since it's a blocking operation errCh := make(chan error) go func() { + time.Sleep(1 * time.Second) // Wait for the pubsub server to start errCh <- manager.MonitorForkUpdate(ctx) }() diff --git a/types/instruction.go b/types/instruction.go index b3250658a..ccabb1897 100644 --- a/types/instruction.go +++ b/types/instruction.go @@ -16,7 +16,7 @@ type Instruction struct { const instructionFileName = "instruction.json" func PersistInstructionToDisk(dir string, instruction Instruction) error { - if err := os.MkdirAll(dir, 0o755); err != nil { + if err := os.MkdirAll(dir, 0o750); err != nil { return err } From 0283729f9602e91496d8d675736606eec36d22e3 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 31 Oct 2024 14:35:12 +0100 Subject: [PATCH 009/119] add nolint --- types/instruction.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/instruction.go b/types/instruction.go index ccabb1897..e5cd88963 100644 --- a/types/instruction.go +++ b/types/instruction.go @@ -26,13 +26,13 @@ func PersistInstructionToDisk(dir string, instruction Instruction) error { } filePath := filepath.Join(dir, instructionFileName) - return os.WriteFile(filePath, data, 0o644) + return os.WriteFile(filePath, data, 0o600) } func LoadInstructionFromDisk(dir string) (Instruction, error) { var instruction Instruction - filePath := filepath.Join(dir, instructionFileName) + filePath := filepath.Join(dir, instructionFileName) // nolint:gosec data, err := os.ReadFile(filePath) if err != nil { return Instruction{}, err From 300bd489660a2cf2da564f633d78f07d9a61a9d2 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 31 Oct 2024 14:48:09 +0100 Subject: [PATCH 010/119] move nolint --- types/instruction.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/instruction.go b/types/instruction.go index e5cd88963..26df5e82e 100644 --- a/types/instruction.go +++ b/types/instruction.go @@ -32,8 +32,8 @@ func PersistInstructionToDisk(dir string, instruction Instruction) error { func LoadInstructionFromDisk(dir string) (Instruction, error) { var instruction Instruction - filePath := filepath.Join(dir, instructionFileName) // nolint:gosec - data, err := os.ReadFile(filePath) + filePath := filepath.Join(dir, instructionFileName) + data, err := os.ReadFile(filePath) // nolint:gosec if err != nil { return Instruction{}, err } From fccc8529f0c791d0c3766a3d68b2f250770ee8a2 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Mon, 4 Nov 2024 15:10:44 +0100 Subject: [PATCH 011/119] include NewDRS message --- block/executor.go | 10 +- block/fork.go | 108 ++- block/fork_test.go | 2 +- block/manager.go | 16 + block/produce.go | 6 +- go.mod | 21 +- go.sum | 40 +- proto/types/rollapp/sequencers/types/tx.proto | 20 + types/pb/rollapp/sequencers/types/tx.pb.go | 679 +++++++++++++++++- 9 files changed, 836 insertions(+), 66 deletions(-) diff --git a/block/executor.go b/block/executor.go index 6f6cfc71f..c507c4e02 100644 --- a/block/executor.go +++ b/block/executor.go @@ -143,9 +143,15 @@ func (e *Executor) CreateBlock( lastHeaderHash, nextSeqHash [32]byte, state *types.State, maxBlockDataSizeBytes uint64, + enforceEmpty bool, ) *types.Block { maxBlockDataSizeBytes = min(maxBlockDataSizeBytes, uint64(max(minBlockMaxBytes, state.ConsensusParams.Block.MaxBytes))) - mempoolTxs := e.mempool.ReapMaxBytesMaxGas(int64(maxBlockDataSizeBytes), state.ConsensusParams.Block.MaxGas) + + var txs types.Txs + if !enforceEmpty { + mempoolTxs := e.mempool.ReapMaxBytesMaxGas(int64(maxBlockDataSizeBytes), state.ConsensusParams.Block.MaxGas) + txs = toDymintTxs(mempoolTxs) + } block := &types.Block{ Header: types.Header{ @@ -164,7 +170,7 @@ func (e *Executor) CreateBlock( ProposerAddress: e.localAddress, }, Data: types.Data{ - Txs: toDymintTxs(mempoolTxs), + Txs: txs, IntermediateStateRoots: types.IntermediateStateRoots{RawRootsList: nil}, Evidence: types.EvidenceData{Evidence: nil}, ConsensusMessages: fromProtoMsgSliceToAnySlice(e.consensusMsgQueue.Get()...), diff --git a/block/fork.go b/block/fork.go index 95a40d5a6..8259a7dd2 100644 --- a/block/fork.go +++ b/block/fork.go @@ -5,19 +5,27 @@ import ( "fmt" "time" + "github.com/gogo/protobuf/proto" + "github.com/dymensionxyz/dymint/node/events" "github.com/dymensionxyz/dymint/types" + sequencers "github.com/dymensionxyz/dymint/types/pb/rollapp/sequencers/types" uevent "github.com/dymensionxyz/dymint/utils/event" ) -// MonitorForkUpdate listens to the hub -func (m *Manager) MonitorForkUpdate(ctx context.Context) error { +const ( + LoopInterval = 15 * time.Second + FetchInterval = 5 * time.Second +) + +// MonitorForkUpdateLoop monitors the hub for fork updates in a loop +func (m *Manager) MonitorForkUpdateLoop(ctx context.Context) error { err := m.checkForkUpdate(ctx) if err != nil { return err } - ticker := time.NewTicker(15 * time.Second) + ticker := time.NewTicker(LoopInterval) // TODO make this configurable defer ticker.Stop() for { @@ -108,3 +116,97 @@ func (m *Manager) freezeNode(ctx context.Context) { err := fmt.Errorf("node frozen due to fork update") uevent.MustPublish(ctx, m.Pubsub, &events.DataHealthStatus{Error: err}, events.HealthStatusList) } + +// forkNeeded returns true if the fork file exists +func (m *Manager) forkNeeded() bool { + if _, err := types.LoadInstructionFromDisk(m.RootDir); err == nil { + return true + } + + return false +} + +// handleSequencerForkTransition handles the sequencer fork transition +func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { + lastBlock, err := m.Store.LoadBlock(m.State.Height()) + if err != nil { + panic(fmt.Sprintf("load block: height: %d: %v", m.State.Height(), err)) + } + + var consensusMsgs []proto.Message + if instruction.FaultyDRS != nil { + if lastBlock.Header.Version.App == instruction.Revision { + panic(fmt.Sprintf("running faulty DRS version %d", *instruction.FaultyDRS)) + } + + msgUpgradeDRS := &sequencers.MsgUpgradeDRS{ + DrsVersion: *instruction.FaultyDRS, + } + + consensusMsgs = append(consensusMsgs, msgUpgradeDRS) + } + + // Always bump the account sequences + msgBumpSequences := &sequencers.MsgBumpAccountSequences{Authority: "gov"} + + consensusMsgs = append(consensusMsgs, msgBumpSequences) + + // Create a new block with the consensus messages + m.Executor.AddConsensusMsgs(consensusMsgs...) + + block, commit, err := m.produceBlock(true, nil, true) + if err != nil { + panic(fmt.Sprintf("produce block: %v", err)) + } + + err = m.applyBlock(block, commit, types.BlockMetaData{Source: types.Produced}) + + // Create another block emtpy + block, commit, err = m.produceBlock(true, nil, true) + if err != nil { + panic(fmt.Sprintf("produce empty block: %v", err)) + } + + err = m.applyBlock(block, commit, types.BlockMetaData{Source: types.Produced}) + + // Create Batch and send + _, err = m.CreateAndSubmitBatch(m.Conf.BatchSubmitBytes, false) + if err != nil { + panic(fmt.Sprintf("create and submit batch: %v", err)) + } +} + +/*// handleFullNodeForkTransition handles the full node fork transition +func (m *Manager) handleFullNodeForkTransition(instruction types.Instruction) { + for { + select { + case <-time.After(FetchInterval): + lastBlock, err := m.Store.LoadBlock(m.State.Height()) + if err != nil { + panic(fmt.Sprintf("load block: height: %d: %v", m.State.Height(), err)) + } + + hubState := m.fetchBatch() + + // First validate software version + drsVersion, err := strconv.ParseUint(version.DrsVersion, 10, 32) + if err != nil { + panic(fmt.Sprintf("parse software version: %v", err)) + } + + if drsVersion != lastBlock.Header.Version.App { + panic(fmt.Sprintf("software version mismatch: local: %d, hub: %d", drsVersion, lastBlock.Header.Version.App)) + } + + // Check if first block of new fork has arrived + if hasNewForkBlock(hubState, instruction.Revision) { + log.Info("Received first block of new fork, resuming normal operation") + return nil + } + + case <-ctx.Done(): + return ctx.Err() + } + } +} +*/ diff --git a/block/fork_test.go b/block/fork_test.go index f7ddf53cf..eced3cb12 100644 --- a/block/fork_test.go +++ b/block/fork_test.go @@ -202,7 +202,7 @@ func TestMonitorForkUpdate(t *testing.T) { errCh := make(chan error) go func() { time.Sleep(1 * time.Second) // Wait for the pubsub server to start - errCh <- manager.MonitorForkUpdate(ctx) + errCh <- manager.MonitorForkUpdateLoop(ctx) }() // Wait for context cancellation or error diff --git a/block/manager.go b/block/manager.go index 6f805ff9f..85895952b 100644 --- a/block/manager.go +++ b/block/manager.go @@ -231,6 +231,22 @@ func (m *Manager) Start(ctx context.Context) error { } amIProposer := amIProposerOnSL || m.AmIProposerOnRollapp() + if m.forkNeeded() { + instruction, err := types.LoadInstructionFromDisk(m.RootDir) + if err != nil { + return fmt.Errorf("load instruction from disk: %w", err) + } + + if amIProposer { + m.handleSequencerForkTransition(instruction) + } else { // full node + // m.handleFullNodeForkTransition(instruction) + // Nothing? + } + } + + m.logger.Info("starting block manager", "mode", map[bool]string{true: "proposer", false: "full node"}[amIProposer]) + // update local state from latest state in settlement err = m.updateFromLastSettlementState() if err != nil { diff --git a/block/produce.go b/block/produce.go index 90062ba8b..00492520e 100644 --- a/block/produce.go +++ b/block/produce.go @@ -112,7 +112,7 @@ func (m *Manager) ProduceApplyGossipBlock(ctx context.Context, allowEmpty bool) func (m *Manager) produceApplyGossip(ctx context.Context, allowEmpty bool, nextProposerHash *[32]byte) (block *types.Block, commit *types.Commit, err error) { // If I'm not the current rollapp proposer, I should not produce a blocks. - block, commit, err = m.produceBlock(allowEmpty, nextProposerHash) + block, commit, err = m.produceBlock(allowEmpty, nextProposerHash, false) if err != nil { return nil, nil, fmt.Errorf("produce block: %w", err) } @@ -128,7 +128,7 @@ func (m *Manager) produceApplyGossip(ctx context.Context, allowEmpty bool, nextP return block, commit, nil } -func (m *Manager) produceBlock(allowEmpty bool, nextProposerHash *[32]byte) (*types.Block, *types.Commit, error) { +func (m *Manager) produceBlock(allowEmpty bool, nextProposerHash *[32]byte, enforceEmpty bool) (*types.Block, *types.Commit, error) { newHeight := m.State.NextHeight() lastHeaderHash, lastCommit, err := m.GetPreviousBlockHashes(newHeight) if err != nil { @@ -137,6 +137,7 @@ func (m *Manager) produceBlock(allowEmpty bool, nextProposerHash *[32]byte) (*ty var block *types.Block var commit *types.Commit + // Check if there's an already stored block and commit at a newer height // If there is use that instead of creating a new block pendingBlock, err := m.Store.LoadBlock(newHeight) @@ -160,6 +161,7 @@ func (m *Manager) produceBlock(allowEmpty bool, nextProposerHash *[32]byte) (*ty maxBlockDataSize = 0 proposerHashForBlock = *nextProposerHash } + block = m.Executor.CreateBlock(newHeight, lastCommit, lastHeaderHash, proposerHashForBlock, m.State, maxBlockDataSize) if !allowEmpty && len(block.Data.Txs) == 0 { return nil, nil, fmt.Errorf("%w: %w", types.ErrEmptyBlock, ErrRecoverable) diff --git a/go.mod b/go.mod index 6bc498fb0..22d77275e 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/stretchr/testify v1.9.0 github.com/tendermint/tendermint v0.34.29 go.uber.org/multierr v1.11.0 - golang.org/x/net v0.28.0 + golang.org/x/net v0.30.0 gonum.org/v1/gonum v0.14.0 google.golang.org/grpc v1.64.0 google.golang.org/protobuf v1.33.0 @@ -118,7 +118,7 @@ require ( go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/dig v1.17.1 // indirect go.uber.org/fx v1.20.1 // indirect - golang.org/x/exp v0.0.0-20240213143201-ec583247a57a + golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect @@ -242,12 +242,12 @@ require ( go.etcd.io/bbolt v1.3.8 // indirect go.opencensus.io v0.24.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.26.0 // indirect - golang.org/x/mod v0.17.0 // indirect + golang.org/x/crypto v0.28.0 // indirect + golang.org/x/mod v0.21.0 // indirect golang.org/x/sync v0.8.0 - golang.org/x/sys v0.24.0 // indirect - golang.org/x/term v0.23.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/term v0.25.0 // indirect + golang.org/x/text v0.19.0 // 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 @@ -257,7 +257,7 @@ require ( require ( cosmossdk.io/math v1.3.0 // indirect - github.com/DataDog/zstd v1.5.2 // indirect + github.com/DataDog/zstd v1.5.5 // indirect github.com/Jorropo/jsync v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect github.com/btcsuite/btcd/btcutil v1.1.3 // indirect @@ -270,7 +270,7 @@ require ( github.com/cosmos/ibc-go/v6 v6.2.1 // indirect github.com/danwt/gerr v1.0.0 // indirect github.com/evmos/evmos/v12 v12.1.6 // indirect - github.com/getsentry/sentry-go v0.18.0 // indirect + github.com/getsentry/sentry-go v0.23.0 // indirect github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f // indirect github.com/holiman/uint256 v1.2.2 // indirect github.com/ipfs/bbloom v0.0.4 // indirect @@ -291,12 +291,13 @@ require ( github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect go.uber.org/mock v0.4.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + golang.org/x/tools v0.26.0 // indirect pgregory.net/rapid v1.1.0 ) 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 => ../dymension-rdk 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 diff --git a/go.sum b/go.sum index 839bf72b0..aa881d688 100644 --- a/go.sum +++ b/go.sum @@ -212,8 +212,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= -github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= +github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Jorropo/jsync v1.0.1 h1:6HgRolFZnsdfzRUj+ImB9og1JYOxQoReSywkHOGSaUU= github.com/Jorropo/jsync v1.0.1/go.mod h1:jCOZj3vrBCri3bSU3ErUYvevKlnbssrXeCivybS5ABQ= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= @@ -509,8 +509,8 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= -github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= -github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= +github.com/getsentry/sentry-go v0.23.0 h1:dn+QRCeJv4pPt9OjVXiMcGIBIefaTJPw/h0bZWO05nE= +github.com/getsentry/sentry-go v0.23.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= @@ -1316,8 +1316,8 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1328,8 +1328,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY= +golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1357,8 +1357,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1418,8 +1418,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1558,13 +1558,13 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1575,8 +1575,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1645,8 +1645,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= +golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/proto/types/rollapp/sequencers/types/tx.proto b/proto/types/rollapp/sequencers/types/tx.proto index 1519ff6c8..0811a03ce 100644 --- a/proto/types/rollapp/sequencers/types/tx.proto +++ b/proto/types/rollapp/sequencers/types/tx.proto @@ -54,3 +54,23 @@ message ConsensusMsgUpsertSequencer { } message ConsensusMsgUpsertSequencerResponse {} + +message MsgBumpAccountSequences { + option (cosmos.msg.v1.signer) = "authority"; + // authority defines the address of the authority that is allowed to bump the account sequences. + // this is gov but it can be triggered by a consensus message. + string authority = 1; +} + +message MsgBumpAccountSequencesResponse {} + +message MsgUpgradeDRS { + option (cosmos.msg.v1.signer) = "authority"; + // authority defines the address of the authority that is allowed to bump the account sequences. + // this is gov but it can be triggered by a consensus message. + string authority = 1; + + uint64 drs_version = 2; +} + +message MsgUpgradeDRSResponse {} diff --git a/types/pb/rollapp/sequencers/types/tx.pb.go b/types/pb/rollapp/sequencers/types/tx.pb.go index 2a6d8c3dc..fe0fda64d 100644 --- a/types/pb/rollapp/sequencers/types/tx.pb.go +++ b/types/pb/rollapp/sequencers/types/tx.pb.go @@ -327,6 +327,178 @@ func (m *ConsensusMsgUpsertSequencerResponse) XXX_DiscardUnknown() { var xxx_messageInfo_ConsensusMsgUpsertSequencerResponse proto.InternalMessageInfo +type MsgBumpAccountSequences struct { + // authority defines the address of the authority that is allowed to bump the account sequences. + // this is gov but it can be triggered by a consensus message. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` +} + +func (m *MsgBumpAccountSequences) Reset() { *m = MsgBumpAccountSequences{} } +func (m *MsgBumpAccountSequences) String() string { return proto.CompactTextString(m) } +func (*MsgBumpAccountSequences) ProtoMessage() {} +func (*MsgBumpAccountSequences) Descriptor() ([]byte, []int) { + return fileDescriptor_bb27942d1c1a6ff0, []int{6} +} +func (m *MsgBumpAccountSequences) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBumpAccountSequences) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBumpAccountSequences.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgBumpAccountSequences) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBumpAccountSequences.Merge(m, src) +} +func (m *MsgBumpAccountSequences) XXX_Size() int { + return m.Size() +} +func (m *MsgBumpAccountSequences) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBumpAccountSequences.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBumpAccountSequences proto.InternalMessageInfo + +func (m *MsgBumpAccountSequences) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +type MsgBumpAccountSequencesResponse struct { +} + +func (m *MsgBumpAccountSequencesResponse) Reset() { *m = MsgBumpAccountSequencesResponse{} } +func (m *MsgBumpAccountSequencesResponse) String() string { return proto.CompactTextString(m) } +func (*MsgBumpAccountSequencesResponse) ProtoMessage() {} +func (*MsgBumpAccountSequencesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bb27942d1c1a6ff0, []int{7} +} +func (m *MsgBumpAccountSequencesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBumpAccountSequencesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBumpAccountSequencesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgBumpAccountSequencesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBumpAccountSequencesResponse.Merge(m, src) +} +func (m *MsgBumpAccountSequencesResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgBumpAccountSequencesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBumpAccountSequencesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBumpAccountSequencesResponse proto.InternalMessageInfo + +type MsgUpgradeDRS struct { + // authority defines the address of the authority that is allowed to bump the account sequences. + // this is gov but it can be triggered by a consensus message. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + DrsVersion uint64 `protobuf:"varint,2,opt,name=drs_version,json=drsVersion,proto3" json:"drs_version,omitempty"` +} + +func (m *MsgUpgradeDRS) Reset() { *m = MsgUpgradeDRS{} } +func (m *MsgUpgradeDRS) String() string { return proto.CompactTextString(m) } +func (*MsgUpgradeDRS) ProtoMessage() {} +func (*MsgUpgradeDRS) Descriptor() ([]byte, []int) { + return fileDescriptor_bb27942d1c1a6ff0, []int{8} +} +func (m *MsgUpgradeDRS) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpgradeDRS) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpgradeDRS.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpgradeDRS) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpgradeDRS.Merge(m, src) +} +func (m *MsgUpgradeDRS) XXX_Size() int { + return m.Size() +} +func (m *MsgUpgradeDRS) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpgradeDRS.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpgradeDRS proto.InternalMessageInfo + +func (m *MsgUpgradeDRS) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpgradeDRS) GetDrsVersion() uint64 { + if m != nil { + return m.DrsVersion + } + return 0 +} + +type MsgUpgradeDRSResponse struct { +} + +func (m *MsgUpgradeDRSResponse) Reset() { *m = MsgUpgradeDRSResponse{} } +func (m *MsgUpgradeDRSResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpgradeDRSResponse) ProtoMessage() {} +func (*MsgUpgradeDRSResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bb27942d1c1a6ff0, []int{9} +} +func (m *MsgUpgradeDRSResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpgradeDRSResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpgradeDRSResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpgradeDRSResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpgradeDRSResponse.Merge(m, src) +} +func (m *MsgUpgradeDRSResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpgradeDRSResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpgradeDRSResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpgradeDRSResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgUpdateRewardAddress)(nil), "dymension_rdk.sequencers.types.MsgUpdateRewardAddress") proto.RegisterType((*MsgUpdateRewardAddressResponse)(nil), "dymension_rdk.sequencers.types.MsgUpdateRewardAddressResponse") @@ -334,6 +506,10 @@ func init() { proto.RegisterType((*MsgUpdateWhitelistedRelayersResponse)(nil), "dymension_rdk.sequencers.types.MsgUpdateWhitelistedRelayersResponse") proto.RegisterType((*ConsensusMsgUpsertSequencer)(nil), "dymension_rdk.sequencers.types.ConsensusMsgUpsertSequencer") proto.RegisterType((*ConsensusMsgUpsertSequencerResponse)(nil), "dymension_rdk.sequencers.types.ConsensusMsgUpsertSequencerResponse") + proto.RegisterType((*MsgBumpAccountSequences)(nil), "dymension_rdk.sequencers.types.MsgBumpAccountSequences") + proto.RegisterType((*MsgBumpAccountSequencesResponse)(nil), "dymension_rdk.sequencers.types.MsgBumpAccountSequencesResponse") + proto.RegisterType((*MsgUpgradeDRS)(nil), "dymension_rdk.sequencers.types.MsgUpgradeDRS") + proto.RegisterType((*MsgUpgradeDRSResponse)(nil), "dymension_rdk.sequencers.types.MsgUpgradeDRSResponse") } func init() { @@ -341,34 +517,40 @@ func init() { } var fileDescriptor_bb27942d1c1a6ff0 = []byte{ - // 426 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0x4d, 0x8b, 0xd4, 0x40, - 0x10, 0x9d, 0xcc, 0xea, 0xb2, 0xf6, 0xe8, 0x65, 0x58, 0x96, 0x71, 0xd4, 0x36, 0xc4, 0xaf, 0xc5, - 0x43, 0x1a, 0x15, 0x3c, 0xec, 0x6d, 0xf5, 0x28, 0x82, 0x44, 0x45, 0xf0, 0x12, 0x92, 0x74, 0xd9, - 0x1b, 0x36, 0xe9, 0x6e, 0xb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0x00, 0x00, - 0xff, 0xff, 0x88, 0x76, 0xc9, 0xf3, 0x0b, 0x03, 0x00, 0x00, + // 513 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x53, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0x8d, 0xd3, 0x52, 0xb5, 0x13, 0xca, 0x21, 0x2a, 0x6d, 0x08, 0xc5, 0x0d, 0xe1, 0xab, 0xe2, + 0x60, 0x0b, 0x90, 0x38, 0xe4, 0x96, 0x82, 0xc4, 0x01, 0x55, 0x42, 0x2e, 0x1f, 0x12, 0x07, 0x22, + 0xdb, 0x3b, 0x6c, 0xac, 0x26, 0xbb, 0xcb, 0xce, 0xba, 0xd4, 0x1c, 0xf9, 0x05, 0xfc, 0x14, 0x7e, + 0x06, 0xc7, 0x4a, 0x5c, 0x38, 0xa2, 0xe4, 0xc0, 0xdf, 0x40, 0x6b, 0x3b, 0x8e, 0x12, 0x4a, 0x4e, + 0xf6, 0xdb, 0x79, 0xbb, 0xef, 0xbd, 0x19, 0x0d, 0x3c, 0x30, 0x99, 0x42, 0xf2, 0xb5, 0x1c, 0x8d, + 0x42, 0xa5, 0x7c, 0xc2, 0x4f, 0x29, 0x8a, 0x18, 0x35, 0xf9, 0x45, 0xc1, 0x9c, 0x7b, 0x4a, 0x4b, + 0x23, 0x9b, 0x2e, 0xcb, 0xc6, 0x28, 0x28, 0x91, 0x62, 0xa0, 0xd9, 0xa9, 0x37, 0x27, 0x7a, 0x39, + 0xb1, 0xbd, 0xc3, 0x25, 0x97, 0x39, 0xd5, 0xb7, 0x7f, 0xc5, 0xad, 0xf6, 0xad, 0xe2, 0x95, 0x58, + 0xd2, 0x58, 0x92, 0x3f, 0x26, 0xee, 0x9f, 0x3d, 0xb2, 0x9f, 0xb2, 0x7c, 0x83, 0x4b, 0xc9, 0x47, + 0xe8, 0xe7, 0x28, 0x4a, 0x3f, 0xfa, 0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x72, 0xb3, 0x17, 0xf2, 0x5f, 0x59, + 0xca, 0xdf, 0xb0, 0xf9, 0x4b, 0x77, 0xdd, 0x7b, 0x70, 0x67, 0x45, 0xa8, 0x2a, 0xfc, 0x0b, 0xd8, + 0x3b, 0x26, 0x7e, 0x94, 0x8e, 0x55, 0x3f, 0x8e, 0x65, 0x2a, 0x2a, 0x0a, 0x35, 0xf7, 0x61, 0x2b, + 0x4c, 0xcd, 0x50, 0xea, 0xc4, 0x64, 0x65, 0xf4, 0xf9, 0x41, 0xef, 0x9a, 0x15, 0x9b, 0xe3, 0xee, + 0x6d, 0x38, 0xf8, 0xcf, 0x43, 0x95, 0xd6, 0x07, 0xd8, 0xce, 0x9d, 0x70, 0x1d, 0x32, 0x7c, 0x1e, + 0x9c, 0xac, 0x56, 0xb0, 0xbd, 0x60, 0x9a, 0x06, 0x67, 0xa8, 0xed, 0x8a, 0xe4, 0x2d, 0x5e, 0x0f, + 0x80, 0x69, 0x7a, 0x5b, 0x9c, 0xfc, 0x63, 0x61, 0x0f, 0xae, 0x2f, 0xbc, 0x3f, 0x13, 0x3e, 0x7a, + 0xfd, 0x63, 0xe2, 0x3a, 0x17, 0x13, 0xd7, 0xf9, 0x3d, 0x71, 0x9d, 0x6f, 0x53, 0xb7, 0x76, 0x31, + 0x75, 0x6b, 0xbf, 0xa6, 0x6e, 0xed, 0x7d, 0x8f, 0x27, 0x66, 0x98, 0x46, 0x5e, 0x2c, 0xc7, 0x7e, + 0xb5, 0x8d, 0xe7, 0xd9, 0x17, 0x0b, 0x12, 0x61, 0xca, 0x8d, 0x55, 0xd1, 0x25, 0xdb, 0x1c, 0x6d, + 0xe4, 0x53, 0x7c, 0xf2, 0x37, 0x00, 0x00, 0xff, 0xff, 0x6b, 0x8c, 0x8f, 0x24, 0xf0, 0x03, 0x00, + 0x00, } func (m *MsgUpdateRewardAddress) Marshal() (dAtA []byte, err error) { @@ -581,6 +763,117 @@ func (m *ConsensusMsgUpsertSequencerResponse) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } +func (m *MsgBumpAccountSequences) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgBumpAccountSequences) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBumpAccountSequences) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgBumpAccountSequencesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgBumpAccountSequencesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBumpAccountSequencesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpgradeDRS) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpgradeDRS) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpgradeDRS) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.DrsVersion != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.DrsVersion)) + i-- + dAtA[i] = 0x10 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpgradeDRSResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpgradeDRSResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpgradeDRSResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -686,6 +979,53 @@ func (m *ConsensusMsgUpsertSequencerResponse) Size() (n int) { return n } +func (m *MsgBumpAccountSequences) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgBumpAccountSequencesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpgradeDRS) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.DrsVersion != 0 { + n += 1 + sovTx(uint64(m.DrsVersion)) + } + return n +} + +func (m *MsgUpgradeDRSResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1284,6 +1624,289 @@ func (m *ConsensusMsgUpsertSequencerResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgBumpAccountSequences) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgBumpAccountSequences: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBumpAccountSequences: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgBumpAccountSequencesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgBumpAccountSequencesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBumpAccountSequencesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpgradeDRS) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpgradeDRS: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpgradeDRS: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DrsVersion", wireType) + } + m.DrsVersion = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DrsVersion |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpgradeDRSResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpgradeDRSResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpgradeDRSResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From eb8668a1f7e43640127f9733c707bc3fadbae30e Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Mon, 4 Nov 2024 19:25:53 +0100 Subject: [PATCH 012/119] remove commented code --- block/fork.go | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/block/fork.go b/block/fork.go index 8259a7dd2..6f1b4bb96 100644 --- a/block/fork.go +++ b/block/fork.go @@ -14,8 +14,7 @@ import ( ) const ( - LoopInterval = 15 * time.Second - FetchInterval = 5 * time.Second + LoopInterval = 15 * time.Second ) // MonitorForkUpdateLoop monitors the hub for fork updates in a loop @@ -175,38 +174,3 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { panic(fmt.Sprintf("create and submit batch: %v", err)) } } - -/*// handleFullNodeForkTransition handles the full node fork transition -func (m *Manager) handleFullNodeForkTransition(instruction types.Instruction) { - for { - select { - case <-time.After(FetchInterval): - lastBlock, err := m.Store.LoadBlock(m.State.Height()) - if err != nil { - panic(fmt.Sprintf("load block: height: %d: %v", m.State.Height(), err)) - } - - hubState := m.fetchBatch() - - // First validate software version - drsVersion, err := strconv.ParseUint(version.DrsVersion, 10, 32) - if err != nil { - panic(fmt.Sprintf("parse software version: %v", err)) - } - - if drsVersion != lastBlock.Header.Version.App { - panic(fmt.Sprintf("software version mismatch: local: %d, hub: %d", drsVersion, lastBlock.Header.Version.App)) - } - - // Check if first block of new fork has arrived - if hasNewForkBlock(hubState, instruction.Revision) { - log.Info("Received first block of new fork, resuming normal operation") - return nil - } - - case <-ctx.Done(): - return ctx.Err() - } - } -} -*/ From 5e037d40ddc339a88e79a1bf57cf5b99fa8b0f34 Mon Sep 17 00:00:00 2001 From: unknown unknown Date: Tue, 5 Nov 2024 22:34:47 +0100 Subject: [PATCH 013/119] adjust mock --- .../dymint/settlement/mock_ClientI.go | 85 ++++++++++++++++--- 1 file changed, 73 insertions(+), 12 deletions(-) diff --git a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go index d2e70b5e1..db5360a01 100644 --- a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go +++ b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go @@ -480,7 +480,7 @@ func (_c *MockClientI_GetNextProposer_Call) RunAndReturn(run func() (*types.Sequ return _c } -// GetProposer provides a mock function with given fields: +// GetProposerAtHeight provides a mock function with given fields: height func (_m *MockClientI) GetProposerAtHeight(height int64) (*types.Sequencer, error) { ret := _m.Called(height) @@ -489,15 +489,76 @@ func (_m *MockClientI) GetProposerAtHeight(height int64) (*types.Sequencer, erro } var r0 *types.Sequencer - if rf, ok := ret.Get(0).(func() *types.Sequencer); ok { - r0 = rf() + var r1 error + if rf, ok := ret.Get(0).(func(int64) (*types.Sequencer, error)); ok { + return rf(height) + } + if rf, ok := ret.Get(0).(func(int64) *types.Sequencer); ok { + r0 = rf(height) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*types.Sequencer) } } + if rf, ok := ret.Get(1).(func(int64) error); ok { + r1 = rf(height) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientI_GetProposerAtHeight_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProposerAtHeight' +type MockClientI_GetProposerAtHeight_Call struct { + *mock.Call +} + +// GetProposerAtHeight is a helper method to define mock.On call +// - height int64 +func (_e *MockClientI_Expecter) GetProposerAtHeight(height interface{}) *MockClientI_GetProposerAtHeight_Call { + return &MockClientI_GetProposerAtHeight_Call{Call: _e.mock.On("GetProposerAtHeight", height)} +} + +func (_c *MockClientI_GetProposerAtHeight_Call) Run(run func(height int64)) *MockClientI_GetProposerAtHeight_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64)) + }) + return _c +} + +func (_c *MockClientI_GetProposerAtHeight_Call) Return(_a0 *types.Sequencer, _a1 error) *MockClientI_GetProposerAtHeight_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientI_GetProposerAtHeight_Call) RunAndReturn(run func(int64) (*types.Sequencer, error)) *MockClientI_GetProposerAtHeight_Call { + _c.Call.Return(run) + return _c +} + +// GetRollapp provides a mock function with given fields: +func (_m *MockClientI) GetRollapp() (*types.Rollapp, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetRollapp") + } + + var r0 *types.Rollapp var r1 error + if rf, ok := ret.Get(0).(func() (*types.Rollapp, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *types.Rollapp); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.Rollapp) + } + } + if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -507,29 +568,29 @@ func (_m *MockClientI) GetProposerAtHeight(height int64) (*types.Sequencer, erro return r0, r1 } -// MockClientI_GetProposer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProposer' -type MockClientI_GetProposer_Call struct { +// MockClientI_GetRollapp_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRollapp' +type MockClientI_GetRollapp_Call struct { *mock.Call } -// GetProposer is a helper method to define mock.On call -func (_e *MockClientI_Expecter) GetProposer() *MockClientI_GetProposer_Call { - return &MockClientI_GetProposer_Call{Call: _e.mock.On("GetProposer")} +// GetRollapp is a helper method to define mock.On call +func (_e *MockClientI_Expecter) GetRollapp() *MockClientI_GetRollapp_Call { + return &MockClientI_GetRollapp_Call{Call: _e.mock.On("GetRollapp")} } -func (_c *MockClientI_GetProposer_Call) Run(run func()) *MockClientI_GetProposer_Call { +func (_c *MockClientI_GetRollapp_Call) Run(run func()) *MockClientI_GetRollapp_Call { _c.Call.Run(func(args mock.Arguments) { run() }) return _c } -func (_c *MockClientI_GetProposer_Call) Return(_a0 *types.Sequencer) *MockClientI_GetProposer_Call { - _c.Call.Return(_a0) +func (_c *MockClientI_GetRollapp_Call) Return(_a0 *types.Rollapp, _a1 error) *MockClientI_GetRollapp_Call { + _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientI_GetProposer_Call) RunAndReturn(run func() *types.Sequencer) *MockClientI_GetProposer_Call { +func (_c *MockClientI_GetRollapp_Call) RunAndReturn(run func() (*types.Rollapp, error)) *MockClientI_GetRollapp_Call { _c.Call.Return(run) return _c } From c833986557f5a20f109c9c5e55b298b1786148e2 Mon Sep 17 00:00:00 2001 From: unknown unknown Date: Tue, 5 Nov 2024 22:44:35 +0100 Subject: [PATCH 014/119] merge main --- block/executor_test.go | 12 +++++------ block/produce.go | 2 +- .../dymint/block/mock_ExecutorI.go | 21 ++++++++++--------- p2p/validator_test.go | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/block/executor_test.go b/block/executor_test.go index c40e4af2b..2dbae1842 100644 --- a/block/executor_test.go +++ b/block/executor_test.go @@ -67,7 +67,7 @@ func TestCreateBlock(t *testing.T) { state.ConsensusParams.Block.MaxBytes = int64(maxBytes) state.ConsensusParams.Block.MaxGas = 100000 // empty block - block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes) + block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes, false) require.NotNil(block) assert.Empty(block.Data.Txs) assert.Equal(uint64(1), block.Header.Height) @@ -75,7 +75,7 @@ func TestCreateBlock(t *testing.T) { // one small Tx err = mpool.CheckTx([]byte{1, 2, 3, 4}, func(r *abci.Response) {}, mempool.TxInfo{}) require.NoError(err) - block = executor.CreateBlock(2, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes) + block = executor.CreateBlock(2, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes, false) require.NotNil(block) assert.Equal(uint64(2), block.Header.Height) assert.Len(block.Data.Txs, 1) @@ -85,7 +85,7 @@ func TestCreateBlock(t *testing.T) { require.NoError(err) err = mpool.CheckTx(make([]byte, 100), func(r *abci.Response) {}, mempool.TxInfo{}) require.NoError(err) - block = executor.CreateBlock(3, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes) + block = executor.CreateBlock(3, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes, false) require.NotNil(block) assert.Len(block.Data.Txs, 2) } @@ -132,7 +132,7 @@ func TestCreateBlockWithConsensusMessages(t *testing.T) { state.ConsensusParams.Block.MaxBytes = int64(maxBytes) state.ConsensusParams.Block.MaxGas = 100000 - block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()[:]), state, maxBytes) + block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()[:]), state, maxBytes, false) require.NotNil(block) assert.Empty(block.Data.Txs) @@ -251,7 +251,7 @@ func TestApplyBlock(t *testing.T) { // Create first block with one Tx from mempool _ = mpool.CheckTx([]byte{1, 2, 3, 4}, func(r *abci.Response) {}, mempool.TxInfo{}) require.NoError(err) - block := executor.CreateBlock(1, &types.Commit{Height: 0}, [32]byte{0x01}, [32]byte(state.GetProposerHash()), state, maxBytes) + block := executor.CreateBlock(1, &types.Commit{Height: 0}, [32]byte{0x01}, [32]byte(state.GetProposerHash()), state, maxBytes, false) require.NotNil(block) assert.Equal(uint64(1), block.Header.Height) assert.Len(block.Data.Txs, 1) @@ -286,7 +286,7 @@ func TestApplyBlock(t *testing.T) { 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, 9990), func(r *abci.Response) {}, mempool.TxInfo{})) - block = executor.CreateBlock(2, commit, block.Header.Hash(), [32]byte(state.GetProposerHash()), state, maxBytes) + block = executor.CreateBlock(2, commit, block.Header.Hash(), [32]byte(state.GetProposerHash()), state, maxBytes, false) require.NotNil(block) assert.Equal(uint64(2), block.Header.Height) assert.Len(block.Data.Txs, 3) diff --git a/block/produce.go b/block/produce.go index 00492520e..0afd267b2 100644 --- a/block/produce.go +++ b/block/produce.go @@ -162,7 +162,7 @@ func (m *Manager) produceBlock(allowEmpty bool, nextProposerHash *[32]byte, enfo proposerHashForBlock = *nextProposerHash } - block = m.Executor.CreateBlock(newHeight, lastCommit, lastHeaderHash, proposerHashForBlock, m.State, maxBlockDataSize) + block = m.Executor.CreateBlock(newHeight, lastCommit, lastHeaderHash, proposerHashForBlock, m.State, maxBlockDataSize, false) if !allowEmpty && len(block.Data.Txs) == 0 { return nil, nil, fmt.Errorf("%w: %w", types.ErrEmptyBlock, ErrRecoverable) } diff --git a/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go b/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go index 4dcbd3213..560f38340 100644 --- a/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go +++ b/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go @@ -142,17 +142,17 @@ func (_c *MockExecutorI_Commit_Call) RunAndReturn(run func(*types.State, *types. return _c } -// CreateBlock provides a mock function with given fields: height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes -func (_m *MockExecutorI) CreateBlock(height uint64, lastCommit *types.Commit, lastHeaderHash [32]byte, nextSeqHash [32]byte, _a4 *types.State, maxBlockDataSizeBytes uint64) *types.Block { - ret := _m.Called(height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes) +// CreateBlock provides a mock function with given fields: height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes, enforceEmpty +func (_m *MockExecutorI) CreateBlock(height uint64, lastCommit *types.Commit, lastHeaderHash [32]byte, nextSeqHash [32]byte, _a4 *types.State, maxBlockDataSizeBytes uint64, enforceEmpty bool) *types.Block { + ret := _m.Called(height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes, enforceEmpty) if len(ret) == 0 { panic("no return value specified for CreateBlock") } var r0 *types.Block - if rf, ok := ret.Get(0).(func(uint64, *types.Commit, [32]byte, [32]byte, *types.State, uint64) *types.Block); ok { - r0 = rf(height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes) + if rf, ok := ret.Get(0).(func(uint64, *types.Commit, [32]byte, [32]byte, *types.State, uint64, bool) *types.Block); ok { + r0 = rf(height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes, enforceEmpty) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*types.Block) @@ -174,13 +174,14 @@ type MockExecutorI_CreateBlock_Call struct { // - nextSeqHash [32]byte // - _a4 *types.State // - maxBlockDataSizeBytes uint64 -func (_e *MockExecutorI_Expecter) CreateBlock(height interface{}, lastCommit interface{}, lastHeaderHash interface{}, nextSeqHash interface{}, _a4 interface{}, maxBlockDataSizeBytes interface{}) *MockExecutorI_CreateBlock_Call { - return &MockExecutorI_CreateBlock_Call{Call: _e.mock.On("CreateBlock", height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes)} +// - enforceEmpty bool +func (_e *MockExecutorI_Expecter) CreateBlock(height interface{}, lastCommit interface{}, lastHeaderHash interface{}, nextSeqHash interface{}, _a4 interface{}, maxBlockDataSizeBytes interface{}, enforceEmpty interface{}) *MockExecutorI_CreateBlock_Call { + return &MockExecutorI_CreateBlock_Call{Call: _e.mock.On("CreateBlock", height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes, enforceEmpty)} } -func (_c *MockExecutorI_CreateBlock_Call) Run(run func(height uint64, lastCommit *types.Commit, lastHeaderHash [32]byte, nextSeqHash [32]byte, _a4 *types.State, maxBlockDataSizeBytes uint64)) *MockExecutorI_CreateBlock_Call { +func (_c *MockExecutorI_CreateBlock_Call) Run(run func(height uint64, lastCommit *types.Commit, lastHeaderHash [32]byte, nextSeqHash [32]byte, _a4 *types.State, maxBlockDataSizeBytes uint64, enforceEmpty bool)) *MockExecutorI_CreateBlock_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(uint64), args[1].(*types.Commit), args[2].([32]byte), args[3].([32]byte), args[4].(*types.State), args[5].(uint64)) + run(args[0].(uint64), args[1].(*types.Commit), args[2].([32]byte), args[3].([32]byte), args[4].(*types.State), args[5].(uint64), args[6].(bool)) }) return _c } @@ -190,7 +191,7 @@ func (_c *MockExecutorI_CreateBlock_Call) Return(_a0 *types.Block) *MockExecutor return _c } -func (_c *MockExecutorI_CreateBlock_Call) RunAndReturn(run func(uint64, *types.Commit, [32]byte, [32]byte, *types.State, uint64) *types.Block) *MockExecutorI_CreateBlock_Call { +func (_c *MockExecutorI_CreateBlock_Call) RunAndReturn(run func(uint64, *types.Commit, [32]byte, [32]byte, *types.State, uint64, bool) *types.Block) *MockExecutorI_CreateBlock_Call { _c.Call.Return(run) return _c } diff --git a/p2p/validator_test.go b/p2p/validator_test.go index f40d707be..b693ae749 100644 --- a/p2p/validator_test.go +++ b/p2p/validator_test.go @@ -136,7 +136,7 @@ func TestValidator_BlockValidator(t *testing.T) { state.ConsensusParams.Block.MaxBytes = int64(maxBytes) // Create empty block - block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes) + block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes, false) getProposer := &p2pmock.MockGetProposerI{} getProposer.On("GetProposerPubKey").Return(proposerKey.PubKey()) From ff877ef5892412789b9ec8fc4ec39e235ca7ead6 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 6 Nov 2024 11:29:15 +0100 Subject: [PATCH 015/119] update the way we get version --- block/fork.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/block/fork.go b/block/fork.go index 6f1b4bb96..763c33ec4 100644 --- a/block/fork.go +++ b/block/fork.go @@ -3,6 +3,8 @@ package block import ( "context" "fmt" + "github.com/dymensionxyz/dymint/version" + "strconv" "time" "github.com/gogo/protobuf/proto" @@ -138,8 +140,13 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { panic(fmt.Sprintf("running faulty DRS version %d", *instruction.FaultyDRS)) } + drsAsInt, err := strconv.Atoi(version.DrsVersion) + if err != nil { + panic(fmt.Sprintf("error converting DRS version to int: %v", err)) + } + msgUpgradeDRS := &sequencers.MsgUpgradeDRS{ - DrsVersion: *instruction.FaultyDRS, + DrsVersion: uint64(drsAsInt), } consensusMsgs = append(consensusMsgs, msgUpgradeDRS) From 47903ba747cc92e54f693c83b0f06d7df09c6d2b Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 6 Nov 2024 14:02:57 +0100 Subject: [PATCH 016/119] fix faulty drs misconception --- block/fork.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/block/fork.go b/block/fork.go index 763c33ec4..bad62f71c 100644 --- a/block/fork.go +++ b/block/fork.go @@ -129,22 +129,17 @@ func (m *Manager) forkNeeded() bool { // handleSequencerForkTransition handles the sequencer fork transition func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { - lastBlock, err := m.Store.LoadBlock(m.State.Height()) - if err != nil { - panic(fmt.Sprintf("load block: height: %d: %v", m.State.Height(), err)) - } - var consensusMsgs []proto.Message if instruction.FaultyDRS != nil { - if lastBlock.Header.Version.App == instruction.Revision { - panic(fmt.Sprintf("running faulty DRS version %d", *instruction.FaultyDRS)) - } - drsAsInt, err := strconv.Atoi(version.DrsVersion) if err != nil { panic(fmt.Sprintf("error converting DRS version to int: %v", err)) } + if *instruction.FaultyDRS == uint64(drsAsInt) { + panic(fmt.Sprintf("running faulty DRS version %d", *instruction.FaultyDRS)) + } + msgUpgradeDRS := &sequencers.MsgUpgradeDRS{ DrsVersion: uint64(drsAsInt), } From 6903b021eee6194ee3db4ae789a3add6b9705950 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 6 Nov 2024 17:47:00 +0100 Subject: [PATCH 017/119] add improvement related to fork --- block/fork.go | 10 +++++----- block/manager.go | 24 ++++++++++-------------- block/modes.go | 5 +++++ 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/block/fork.go b/block/fork.go index bad62f71c..091b5286b 100644 --- a/block/fork.go +++ b/block/fork.go @@ -3,7 +3,6 @@ package block import ( "context" "fmt" - "github.com/dymensionxyz/dymint/version" "strconv" "time" @@ -13,6 +12,7 @@ import ( "github.com/dymensionxyz/dymint/types" sequencers "github.com/dymensionxyz/dymint/types/pb/rollapp/sequencers/types" uevent "github.com/dymensionxyz/dymint/utils/event" + "github.com/dymensionxyz/dymint/version" ) const ( @@ -119,12 +119,12 @@ func (m *Manager) freezeNode(ctx context.Context) { } // forkNeeded returns true if the fork file exists -func (m *Manager) forkNeeded() bool { - if _, err := types.LoadInstructionFromDisk(m.RootDir); err == nil { - return true +func (m *Manager) forkNeeded() (types.Instruction, bool) { + if instruction, err := types.LoadInstructionFromDisk(m.RootDir); err == nil { + return instruction, true } - return false + return types.Instruction{}, false } // handleSequencerForkTransition handles the sequencer fork transition diff --git a/block/manager.go b/block/manager.go index 85895952b..ea12f614a 100644 --- a/block/manager.go +++ b/block/manager.go @@ -209,6 +209,16 @@ func (m *Manager) Start(ctx context.Context) error { } } + if instruction, forkNeeded := m.forkNeeded(); forkNeeded { + // Set proposer to nil + m.State.SetProposer(nil) + + // Upgrade revision on state + state := m.State + state.Version.Consensus.App = instruction.Revision + m.State = state + } + // 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. @@ -231,20 +241,6 @@ func (m *Manager) Start(ctx context.Context) error { } amIProposer := amIProposerOnSL || m.AmIProposerOnRollapp() - if m.forkNeeded() { - instruction, err := types.LoadInstructionFromDisk(m.RootDir) - if err != nil { - return fmt.Errorf("load instruction from disk: %w", err) - } - - if amIProposer { - m.handleSequencerForkTransition(instruction) - } else { // full node - // m.handleFullNodeForkTransition(instruction) - // Nothing? - } - } - m.logger.Info("starting block manager", "mode", map[bool]string{true: "proposer", false: "full node"}[amIProposer]) // update local state from latest state in settlement diff --git a/block/modes.go b/block/modes.go index 6f8cff9f5..b1a2033bd 100644 --- a/block/modes.go +++ b/block/modes.go @@ -51,6 +51,11 @@ func (m *Manager) runAsProposer(ctx context.Context, eg *errgroup.Group) error { // Sequencer must wait till node is synced till last submittedHeight, in case it is not m.waitForSettlementSyncing() + // if instruction file exists + if instruction, forkNeeded := m.forkNeeded(); forkNeeded { + m.handleSequencerForkTransition(instruction) + } + // check if we should rotate shouldRotate, err := m.ShouldRotate() if err != nil { From a98a616750b93021c4e187a47d7be579a3243466 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 6 Nov 2024 00:33:16 +0100 Subject: [PATCH 018/119] bring back monitor fork update --- block/manager.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/manager.go b/block/manager.go index ea12f614a..300acc496 100644 --- a/block/manager.go +++ b/block/manager.go @@ -275,6 +275,10 @@ func (m *Manager) Start(ctx context.Context) error { return m.MonitorSequencerSetUpdates(ctx) }) + uerrors.ErrGroupGoLog(eg, m.logger, func() error { + return m.MonitorForkUpdate(ctx) + }) + // run based on the node role if !amIProposer { return m.runAsFullNode(ctx, eg) From 6ae531bff3d6a4adc0a0692d4f5a43eb75a1e5b8 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 6 Nov 2024 18:13:24 +0100 Subject: [PATCH 019/119] update code --- block/manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/manager.go b/block/manager.go index 300acc496..b9e3fc741 100644 --- a/block/manager.go +++ b/block/manager.go @@ -276,7 +276,7 @@ func (m *Manager) Start(ctx context.Context) error { }) uerrors.ErrGroupGoLog(eg, m.logger, func() error { - return m.MonitorForkUpdate(ctx) + return m.MonitorForkUpdateLoop(ctx) }) // run based on the node role From 51c788da47fafd15f0bfa3a8ec97bb631e6877a7 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 7 Nov 2024 11:17:44 +0100 Subject: [PATCH 020/119] some comments solved --- block/fork.go | 7 +++++-- block/produce.go | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/block/fork.go b/block/fork.go index 091b5286b..6c2d3dd82 100644 --- a/block/fork.go +++ b/block/fork.go @@ -155,15 +155,18 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { // Create a new block with the consensus messages m.Executor.AddConsensusMsgs(consensusMsgs...) - block, commit, err := m.produceBlock(true, nil, true) + block, commit, err := m.produceBlock(true, nil) if err != nil { panic(fmt.Sprintf("produce block: %v", err)) } err = m.applyBlock(block, commit, types.BlockMetaData{Source: types.Produced}) + if err != nil { + panic(fmt.Sprintf("apply block: %v", err)) + } // Create another block emtpy - block, commit, err = m.produceBlock(true, nil, true) + block, commit, err = m.produceBlock(true, nil) if err != nil { panic(fmt.Sprintf("produce empty block: %v", err)) } diff --git a/block/produce.go b/block/produce.go index 0afd267b2..65e388f1a 100644 --- a/block/produce.go +++ b/block/produce.go @@ -112,7 +112,7 @@ func (m *Manager) ProduceApplyGossipBlock(ctx context.Context, allowEmpty bool) func (m *Manager) produceApplyGossip(ctx context.Context, allowEmpty bool, nextProposerHash *[32]byte) (block *types.Block, commit *types.Commit, err error) { // If I'm not the current rollapp proposer, I should not produce a blocks. - block, commit, err = m.produceBlock(allowEmpty, nextProposerHash, false) + block, commit, err = m.produceBlock(allowEmpty, nextProposerHash) if err != nil { return nil, nil, fmt.Errorf("produce block: %w", err) } @@ -128,7 +128,7 @@ func (m *Manager) produceApplyGossip(ctx context.Context, allowEmpty bool, nextP return block, commit, nil } -func (m *Manager) produceBlock(allowEmpty bool, nextProposerHash *[32]byte, enforceEmpty bool) (*types.Block, *types.Commit, error) { +func (m *Manager) produceBlock(allowEmpty bool, nextProposerHash *[32]byte) (*types.Block, *types.Commit, error) { newHeight := m.State.NextHeight() lastHeaderHash, lastCommit, err := m.GetPreviousBlockHashes(newHeight) if err != nil { From 8f6618f1fe3ce2b3c804a7de6f13b91a512bc9b7 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 7 Nov 2024 11:20:39 +0100 Subject: [PATCH 021/119] update code --- block/fork.go | 4 +- .../dymint/settlement/mock_ClientI.go | 58 ------------------- settlement/dymension/dymension.go | 5 -- settlement/settlement.go | 2 - 4 files changed, 2 insertions(+), 67 deletions(-) diff --git a/block/fork.go b/block/fork.go index 6c2d3dd82..04c285c37 100644 --- a/block/fork.go +++ b/block/fork.go @@ -66,7 +66,7 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { } func (m *Manager) createInstruction(rollapp *types.Rollapp, block *types.Block) error { - info, err := m.SLClient.GetStateInfo(block.Header.Height) + nextProposer, err := m.SLClient.GetNextProposer() if err != nil { return err } @@ -74,7 +74,7 @@ func (m *Manager) createInstruction(rollapp *types.Rollapp, block *types.Block) instruction := types.Instruction{ Revision: rollapp.Revision, RevisionStartHeight: rollapp.RevisionStartHeight, - Sequencer: info.NextProposer, + Sequencer: nextProposer.SettlementAddress, } err = types.PersistInstructionToDisk(m.RootDir, instruction) diff --git a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go index db5360a01..ccfc7a69b 100644 --- a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go +++ b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go @@ -708,64 +708,6 @@ func (_c *MockClientI_GetSequencerByAddress_Call) RunAndReturn(run func(string) return _c } -// GetStateInfo provides a mock function with given fields: index -func (_m *MockClientI) GetStateInfo(index uint64) (*types.StateInfo, error) { - ret := _m.Called(index) - - if len(ret) == 0 { - panic("no return value specified for GetStateInfo") - } - - var r0 *types.StateInfo - var r1 error - if rf, ok := ret.Get(0).(func(uint64) (*types.StateInfo, error)); ok { - return rf(index) - } - if rf, ok := ret.Get(0).(func(uint64) *types.StateInfo); ok { - r0 = rf(index) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*types.StateInfo) - } - } - - if rf, ok := ret.Get(1).(func(uint64) error); ok { - r1 = rf(index) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockClientI_GetStateInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetStateInfo' -type MockClientI_GetStateInfo_Call struct { - *mock.Call -} - -// GetStateInfo is a helper method to define mock.On call -// - index uint64 -func (_e *MockClientI_Expecter) GetStateInfo(index interface{}) *MockClientI_GetStateInfo_Call { - return &MockClientI_GetStateInfo_Call{Call: _e.mock.On("GetStateInfo", index)} -} - -func (_c *MockClientI_GetStateInfo_Call) Run(run func(index uint64)) *MockClientI_GetStateInfo_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(uint64)) - }) - return _c -} - -func (_c *MockClientI_GetStateInfo_Call) Return(_a0 *types.StateInfo, _a1 error) *MockClientI_GetStateInfo_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockClientI_GetStateInfo_Call) RunAndReturn(run func(uint64) (*types.StateInfo, error)) *MockClientI_GetStateInfo_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/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index 93f90a77f..058224a95 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -56,11 +56,6 @@ type Client struct { batchAcceptanceAttempts uint } -func (c *Client) GetStateInfo(index uint64) (*types.StateInfo, error) { - // TODO implement me - panic("implement me") -} - var _ settlement.ClientI = &Client{} // Init is called once. it initializes the struct members. diff --git a/settlement/settlement.go b/settlement/settlement.go index 758921805..1925fb63e 100644 --- a/settlement/settlement.go +++ b/settlement/settlement.go @@ -97,6 +97,4 @@ type ClientI interface { CheckRotationInProgress() (*types.Sequencer, error) // GetRollapp returns the rollapp information. GetRollapp() (*types.Rollapp, error) - // GetStateInfo returns the state info for the given index. - GetStateInfo(index uint64) (*types.StateInfo, error) } From d6cdd1a835dcf326279bb976018178335ca899cf Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 7 Nov 2024 11:21:29 +0100 Subject: [PATCH 022/119] comments on fork --- block/fork.go | 4 ++-- block/fork_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/block/fork.go b/block/fork.go index 04c285c37..fdcc0ce8e 100644 --- a/block/fork.go +++ b/block/fork.go @@ -54,7 +54,7 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { } if m.shouldStopNode(rollapp, lastBlock) { - err = m.createInstruction(rollapp, lastBlock) + err = m.createInstruction(rollapp) if err != nil { return err } @@ -65,7 +65,7 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { return nil } -func (m *Manager) createInstruction(rollapp *types.Rollapp, block *types.Block) error { +func (m *Manager) createInstruction(rollapp *types.Rollapp) error { nextProposer, err := m.SLClient.GetNextProposer() if err != nil { return err diff --git a/block/fork_test.go b/block/fork_test.go index eced3cb12..94137992d 100644 --- a/block/fork_test.go +++ b/block/fork_test.go @@ -268,7 +268,7 @@ func TestCreateInstruction(t *testing.T) { RootDir: t.TempDir(), // Use temporary directory for testing } - err := manager.createInstruction(tt.rollapp, tt.block) + err := manager.createInstruction(tt.rollapp) if tt.expectedError { assert.Error(t, err) } else { From 5a49f60dc01eb202daa13c49318b4dad3b8082c3 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 7 Nov 2024 11:27:25 +0100 Subject: [PATCH 023/119] add review changes --- block/fork_test.go | 6 +- .../dymensionxyz/dymension/rollapp/tx.proto | 2 + settlement/grpc/grpc.go | 5 - settlement/local/local.go | 5 - .../dymensionxyz/dymension/rollapp/tx.pb.go | 151 +++++++++++------- 5 files changed, 99 insertions(+), 70 deletions(-) diff --git a/block/fork_test.go b/block/fork_test.go index 94137992d..2d7ee8c98 100644 --- a/block/fork_test.go +++ b/block/fork_test.go @@ -234,8 +234,8 @@ func TestCreateInstruction(t *testing.T) { }, }, setupMocks: func(mockSL *settlement.MockClientI) { - mockSL.On("GetStateInfo", uint64(150)).Return(&types.StateInfo{ - NextProposer: "sequencer1", + mockSL.On("GetNextProposer").Return(&types.Sequencer{ + SettlementAddress: "sequencer1", }, nil) }, expectedError: false, @@ -252,7 +252,7 @@ func TestCreateInstruction(t *testing.T) { }, }, setupMocks: func(mockSL *settlement.MockClientI) { - mockSL.On("GetStateInfo", uint64(150)).Return((*types.StateInfo)(nil), assert.AnError) + mockSL.On("GetNextProposer").Return((*types.Sequencer)(nil), assert.AnError) }, expectedError: true, }, diff --git a/proto/types/dymensionxyz/dymension/rollapp/tx.proto b/proto/types/dymensionxyz/dymension/rollapp/tx.proto index e3a1475c2..74be2ff78 100644 --- a/proto/types/dymensionxyz/dymension/rollapp/tx.proto +++ b/proto/types/dymensionxyz/dymension/rollapp/tx.proto @@ -80,6 +80,8 @@ message MsgUpdateState { BlockDescriptors BDs = 7 [(gogoproto.nullable) = false]; // last is true if this is the last batch of the sequencer bool last = 8; + // rollapp_revision is the revision of the rollapp chain + uint64 rollapp_revision = 9; } message MsgUpdateStateResponse { diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index af6047615..f6fc86edb 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -51,11 +51,6 @@ type Client struct { refreshTime int } -func (c *Client) GetStateInfo(index uint64) (*types.StateInfo, error) { - // TODO implement me - panic("implement me") -} - func (c *Client) GetRollapp() (*types.Rollapp, error) { // TODO implement me panic("implement me") diff --git a/settlement/local/local.go b/settlement/local/local.go index 93697ac4b..c0508009b 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -54,11 +54,6 @@ type Client struct { settlementKV store.KV } -func (c *Client) GetStateInfo(index uint64) (*types.StateInfo, error) { - // TODO implement me - panic("implement me") -} - func (c *Client) GetRollapp() (*types.Rollapp, error) { // TODO implement me panic("implement me") diff --git a/types/pb/dymensionxyz/dymension/rollapp/tx.pb.go b/types/pb/dymensionxyz/dymension/rollapp/tx.pb.go index b3ad872a4..5386dde4a 100644 --- a/types/pb/dymensionxyz/dymension/rollapp/tx.pb.go +++ b/types/pb/dymensionxyz/dymension/rollapp/tx.pb.go @@ -301,6 +301,8 @@ type MsgUpdateState struct { BDs BlockDescriptors `protobuf:"bytes,7,opt,name=BDs,proto3" json:"BDs"` // last is true if this is the last batch of the sequencer Last bool `protobuf:"varint,8,opt,name=last,proto3" json:"last,omitempty"` + // rollapp_revision is the revision of the rollapp chain + RollappRevision uint64 `protobuf:"varint,9,opt,name=rollapp_revision,json=rollappRevision,proto3" json:"rollapp_revision,omitempty"` } func (m *MsgUpdateState) Reset() { *m = MsgUpdateState{} } @@ -385,6 +387,13 @@ func (m *MsgUpdateState) GetLast() bool { return false } +func (m *MsgUpdateState) GetRollappRevision() uint64 { + if m != nil { + return m.RollappRevision + } + return 0 +} + type MsgUpdateStateResponse struct { } @@ -1018,63 +1027,64 @@ func init() { } var fileDescriptor_fa9b86052c2a43cd = []byte{ - // 891 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x6f, 0x23, 0x35, - 0x14, 0xef, 0x24, 0x69, 0xfe, 0xbc, 0xa4, 0x21, 0x6b, 0xaa, 0x6a, 0xe8, 0xee, 0x86, 0x6c, 0x2a, - 0xa4, 0x88, 0x15, 0x09, 0x74, 0x6f, 0xe5, 0xd4, 0x52, 0xb1, 0xbb, 0xa0, 0x68, 0x61, 0xb6, 0xf4, - 0xc0, 0x25, 0x38, 0x19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0xa0, 0x6a, 0x62, 0xbb, - 0x99, 0x39, 0xd0, 0x03, 0xa8, 0xf8, 0x42, 0xf6, 0xc6, 0x44, 0xe8, 0xeb, 0x2a, 0xdd, 0x4c, 0x23, - 0xdb, 0xda, 0xf2, 0xca, 0xbe, 0x90, 0xa7, 0xd6, 0x75, 0x50, 0xd5, 0x3d, 0xcc, 0x52, 0x9a, 0x7b, - 0xf0, 0xe0, 0xc6, 0xdd, 0xa6, 0x2d, 0x1d, 0x7d, 0xf7, 0xea, 0xa2, 0xee, 0xbc, 0xbe, 0xa8, 0x3b, - 0xff, 0x5c, 0xd4, 0x9d, 0x5f, 0x2e, 0xeb, 0x1b, 0xaf, 0x2f, 0xeb, 0x1b, 0x7f, 0x5e, 0xd6, 0x37, - 0xbe, 0xfd, 0x3c, 0xa0, 0x6a, 0x38, 0xea, 0xb7, 0x07, 0x3c, 0xba, 0xf6, 0x6b, 0xa0, 0x4c, 0x75, - 0x92, 0xff, 0x44, 0xdc, 0x5f, 0xf1, 0xa5, 0xe8, 0xe7, 0xcd, 0xa7, 0xe1, 0xd1, 0x7f, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x0d, 0xbb, 0x21, 0x76, 0x60, 0x09, 0x00, 0x00, + // 910 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x41, 0x73, 0x1b, 0x35, + 0x14, 0xce, 0xda, 0x8e, 0x63, 0x3f, 0x3b, 0xae, 0x2b, 0x32, 0x99, 0x25, 0x6d, 0x8d, 0xeb, 0x0c, + 0x33, 0x86, 0x0e, 0x36, 0xa4, 0xb7, 0x70, 0x4a, 0xc8, 0xd0, 0x16, 0xc6, 0x53, 0xd8, 0x86, 0x1c, + 0xb8, 0x18, 0xd9, 0xab, 0xac, 0x35, 0xdd, 0x95, 0x16, 0x49, 0x76, 0x6a, 0x8e, 0x5c, 0x99, 0x61, + 0xf8, 0x29, 0x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x01, 0x1e, 0xab, 0x11, 0x17, + 0x54, 0x4d, 0x6d, 0x35, 0x33, 0x07, 0xba, 0x0f, 0x55, 0x5f, 0xc8, 0xfe, 0x84, 0x08, 0x7d, 0xec, + 0xa4, 0x9b, 0x6b, 0xe6, 0xdb, 0x9b, 0x5e, 0xc5, 0x17, 0xf2, 0xc4, 0xba, 0xf6, 0x6b, 0xba, 0x86, + 0x59, 0x48, 0x6b, 0x17, 0xee, 0x5f, 0xbb, 0x5b, 0x5a, 0xd2, 0xe1, 0x77, 0x2f, 0xcf, 0x1b, 0xce, + 0xab, 0xf3, 0x86, 0xf3, 0xcf, 0x79, 0xc3, 0xf9, 0xe5, 0xa2, 0xb1, 0xf6, 0xea, 0xa2, 0xb1, 0xf6, + 0xe7, 0x45, 0x63, 0xed, 0xdb, 0xcf, 0x03, 0xaa, 0x46, 0xe3, 0x41, 0x67, 0xc8, 0xa3, 0x2b, 0x0f, + 0x0c, 0xca, 0x54, 0x37, 0x79, 0x7a, 0xc4, 0x83, 0x15, 0xaf, 0x8f, 0x41, 0xd1, 0xbc, 0x2f, 0x1e, + 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0x69, 0x20, 0xba, 0x5d, 0x8b, 0x09, 0x00, 0x00, } func (m *MsgCreateRollapp) Marshal() (dAtA []byte, err error) { @@ -1287,6 +1297,11 @@ func (m *MsgUpdateState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.RollappRevision != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.RollappRevision)) + i-- + dAtA[i] = 0x48 + } if m.Last { i-- if m.Last { @@ -1877,6 +1892,9 @@ func (m *MsgUpdateState) Size() (n int) { if m.Last { n += 2 } + if m.RollappRevision != 0 { + n += 1 + sovTx(uint64(m.RollappRevision)) + } return n } @@ -2873,6 +2891,25 @@ func (m *MsgUpdateState) Unmarshal(dAtA []byte) error { } } m.Last = bool(v != 0) + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RollappRevision", wireType) + } + m.RollappRevision = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RollappRevision |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From 206578ae7c2341a365ca40a5c734a1a783937033 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 7 Nov 2024 11:40:28 +0100 Subject: [PATCH 024/119] send revision --- block/manager_test.go | 8 +++---- block/submit.go | 4 +++- .../dymint/settlement/mock_ClientI.go | 21 ++++++++++--------- settlement/dymension/dymension.go | 21 ++++++++++--------- settlement/dymension/dymension_test.go | 2 +- settlement/grpc/grpc.go | 2 +- settlement/local/local.go | 2 +- settlement/local/local_test.go | 6 +++--- settlement/settlement.go | 2 +- 9 files changed, 36 insertions(+), 32 deletions(-) diff --git a/block/manager_test.go b/block/manager_test.go index 2185ba322..710bc0b80 100644 --- a/block/manager_test.go +++ b/block/manager_test.go @@ -179,7 +179,7 @@ func TestProduceOnlyAfterSynced(t *testing.T) { assert.NoError(t, err) daResultSubmitBatch := manager.DAClient.SubmitBatch(batch) assert.Equal(t, daResultSubmitBatch.Code, da.StatusSuccess) - err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch) + err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch, 0) require.NoError(t, err) nextBatchStartHeight = batch.EndHeight() + 1 lastBlockHeaderHash = batch.Blocks[len(batch.Blocks)-1].Header.Hash() @@ -347,7 +347,7 @@ func TestApplyLocalBlock_WithFraudCheck(t *testing.T) { daResultSubmitBatch := manager.DAClient.SubmitBatch(batch) assert.Equal(t, daResultSubmitBatch.Code, da.StatusSuccess) - err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch) + err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch, 0) require.NoError(t, err) nextBatchStartHeight = batch.EndHeight() + 1 @@ -720,7 +720,7 @@ func TestDAFetch(t *testing.T) { require.NoError(err) daResultSubmitBatch := manager.DAClient.SubmitBatch(batch) require.Equal(daResultSubmitBatch.Code, da.StatusSuccess) - err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch) + err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch, 0) require.NoError(err) cases := []struct { @@ -813,7 +813,7 @@ func TestManager_ApplyBatchFromSL_FraudHandling(t *testing.T) { require.NoError(err) daResultSubmitBatch := manager.DAClient.SubmitBatch(batch) require.Equal(daResultSubmitBatch.Code, da.StatusSuccess) - err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch) + err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch, 0) require.NoError(err) // Mock Executor to return ErrFraud diff --git a/block/submit.go b/block/submit.go index d2d6d6e03..b5e8b640a 100644 --- a/block/submit.go +++ b/block/submit.go @@ -234,7 +234,9 @@ func (m *Manager) SubmitBatch(batch *types.Batch) error { } m.logger.Info("Submitted batch to DA.", "start height", batch.StartHeight(), "end height", batch.EndHeight()) - err := m.SLClient.SubmitBatch(batch, m.DAClient.GetClientType(), &resultSubmitToDA) + revision := m.State.Version.Consensus.App + + err := m.SLClient.SubmitBatch(batch, m.DAClient.GetClientType(), &resultSubmitToDA, revision) if err != nil { return fmt.Errorf("sl client submit batch: start height: %d: end height: %d: %w", batch.StartHeight(), batch.EndHeight(), err) } diff --git a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go index ccfc7a69b..e90167f00 100644 --- a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go +++ b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go @@ -862,17 +862,17 @@ func (_c *MockClientI_Stop_Call) RunAndReturn(run func() error) *MockClientI_Sto return _c } -// SubmitBatch provides a mock function with given fields: batch, daClient, daResult -func (_m *MockClientI) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) error { - ret := _m.Called(batch, daClient, daResult) +// SubmitBatch provides a mock function with given fields: batch, daClient, daResult, revision +func (_m *MockClientI) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch, revision uint64) error { + ret := _m.Called(batch, daClient, daResult, revision) if len(ret) == 0 { panic("no return value specified for SubmitBatch") } var r0 error - if rf, ok := ret.Get(0).(func(*types.Batch, da.Client, *da.ResultSubmitBatch) error); ok { - r0 = rf(batch, daClient, daResult) + if rf, ok := ret.Get(0).(func(*types.Batch, da.Client, *da.ResultSubmitBatch, uint64) error); ok { + r0 = rf(batch, daClient, daResult, revision) } else { r0 = ret.Error(0) } @@ -889,13 +889,14 @@ type MockClientI_SubmitBatch_Call struct { // - batch *types.Batch // - daClient da.Client // - daResult *da.ResultSubmitBatch -func (_e *MockClientI_Expecter) SubmitBatch(batch interface{}, daClient interface{}, daResult interface{}) *MockClientI_SubmitBatch_Call { - return &MockClientI_SubmitBatch_Call{Call: _e.mock.On("SubmitBatch", batch, daClient, daResult)} +// - revision uint64 +func (_e *MockClientI_Expecter) SubmitBatch(batch interface{}, daClient interface{}, daResult interface{}, revision interface{}) *MockClientI_SubmitBatch_Call { + return &MockClientI_SubmitBatch_Call{Call: _e.mock.On("SubmitBatch", batch, daClient, daResult, revision)} } -func (_c *MockClientI_SubmitBatch_Call) Run(run func(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch)) *MockClientI_SubmitBatch_Call { +func (_c *MockClientI_SubmitBatch_Call) Run(run func(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch, revision uint64)) *MockClientI_SubmitBatch_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*types.Batch), args[1].(da.Client), args[2].(*da.ResultSubmitBatch)) + run(args[0].(*types.Batch), args[1].(da.Client), args[2].(*da.ResultSubmitBatch), args[3].(uint64)) }) return _c } @@ -905,7 +906,7 @@ func (_c *MockClientI_SubmitBatch_Call) Return(_a0 error) *MockClientI_SubmitBat return _c } -func (_c *MockClientI_SubmitBatch_Call) RunAndReturn(run func(*types.Batch, da.Client, *da.ResultSubmitBatch) error) *MockClientI_SubmitBatch_Call { +func (_c *MockClientI_SubmitBatch_Call) RunAndReturn(run func(*types.Batch, da.Client, *da.ResultSubmitBatch, uint64) error) *MockClientI_SubmitBatch_Call { _c.Call.Return(run) return _c } diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index 058224a95..5dc5c38bf 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -113,8 +113,8 @@ func (c *Client) Stop() error { // SubmitBatch posts a batch to the Dymension Hub. it tries to post the batch until it is accepted by the settlement layer. // it emits success and failure events to the event bus accordingly. -func (c *Client) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) error { - msgUpdateState, err := c.convertBatchToMsgUpdateState(batch, daResult) +func (c *Client) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch, revision uint64) error { + msgUpdateState, err := c.convertBatchToMsgUpdateState(batch, daResult, revision) if err != nil { return fmt.Errorf("convert batch to msg update state: %w", err) } @@ -606,7 +606,7 @@ func (c *Client) broadcastBatch(msgUpdateState *rollapptypes.MsgUpdateState) err return nil } -func (c *Client) convertBatchToMsgUpdateState(batch *types.Batch, daResult *da.ResultSubmitBatch) (*rollapptypes.MsgUpdateState, error) { +func (c *Client) convertBatchToMsgUpdateState(batch *types.Batch, daResult *da.ResultSubmitBatch, rollappRevision uint64) (*rollapptypes.MsgUpdateState, error) { account, err := c.cosmosClient.GetAccount(c.config.DymAccountName) if err != nil { return nil, fmt.Errorf("get account: %w", err) @@ -629,13 +629,14 @@ func (c *Client) convertBatchToMsgUpdateState(batch *types.Batch, daResult *da.R } settlementBatch := &rollapptypes.MsgUpdateState{ - Creator: addr, - RollappId: c.rollappId, - StartHeight: batch.StartHeight(), - NumBlocks: batch.NumBlocks(), - DAPath: daResult.SubmitMetaData.ToPath(), - BDs: rollapptypes.BlockDescriptors{BD: blockDescriptors}, - Last: batch.LastBatch, + Creator: addr, + RollappId: c.rollappId, + StartHeight: batch.StartHeight(), + NumBlocks: batch.NumBlocks(), + DAPath: daResult.SubmitMetaData.ToPath(), + BDs: rollapptypes.BlockDescriptors{BD: blockDescriptors}, + Last: batch.LastBatch, + RollappRevision: rollappRevision, } return settlementBatch, nil } diff --git a/settlement/dymension/dymension_test.go b/settlement/dymension/dymension_test.go index 1ee60eb0e..07ebbf6f0 100644 --- a/settlement/dymension/dymension_test.go +++ b/settlement/dymension/dymension_test.go @@ -179,7 +179,7 @@ func TestPostBatch(t *testing.T) { errChan := make(chan error, 1) // Create a channel to receive an error from the goroutine // Post the batch in a goroutine and capture any error. go func() { - err := hubClient.SubmitBatch(batch, da.Mock, resultSubmitBatch) + err := hubClient.SubmitBatch(batch, da.Mock, resultSubmitBatch, 0) errChan <- err // Send any error to the errChan }() diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index f6fc86edb..d2514a77f 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -185,7 +185,7 @@ func (c *Client) Stop() error { } // SubmitBatch saves the batch to the kv store -func (c *Client) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) error { +func (c *Client) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch, revision uint64) error { settlementBatch := c.convertBatchtoSettlementBatch(batch, daResult) err := c.saveBatch(settlementBatch) if err != nil { diff --git a/settlement/local/local.go b/settlement/local/local.go index c0508009b..deb6d0ed3 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -143,7 +143,7 @@ func (c *Client) Stop() error { } // PostBatch saves the batch to the kv store -func (c *Client) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) error { +func (c *Client) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch, revision uint64) error { settlementBatch := c.convertBatchToSettlementBatch(batch, daResult) err := c.saveBatch(settlementBatch) if err != nil { diff --git a/settlement/local/local_test.go b/settlement/local/local_test.go index 6a1c5deb8..6d62e2986 100644 --- a/settlement/local/local_test.go +++ b/settlement/local/local_test.go @@ -68,7 +68,7 @@ func TestSubmitBatch(t *testing.T) { resultSubmitBatch.SubmitMetaData = &da.DASubmitMetaData{} // Submit the first batch and check if it was successful - err = sllayer.SubmitBatch(batch1, da.Mock, resultSubmitBatch) + err = sllayer.SubmitBatch(batch1, da.Mock, resultSubmitBatch, 0) assert.NoError(err) assert.True(resultSubmitBatch.Code == 0) // success code @@ -86,7 +86,7 @@ func TestSubmitBatch(t *testing.T) { assert.Equal(batch1.EndHeight(), queriedBatch.Batch.EndHeight) // Submit the 2nd batch and check if it was successful - err = sllayer.SubmitBatch(batch2, da.Mock, resultSubmitBatch) + err = sllayer.SubmitBatch(batch2, da.Mock, resultSubmitBatch, 0) assert.NoError(err) assert.True(resultSubmitBatch.Code == 0) // success code @@ -140,7 +140,7 @@ func TestPersistency(t *testing.T) { resultSubmitBatch.SubmitMetaData = &da.DASubmitMetaData{} // Submit the first batch and check if it was successful - err = sllayer.SubmitBatch(batch1, da.Mock, resultSubmitBatch) + err = sllayer.SubmitBatch(batch1, da.Mock, resultSubmitBatch, 0) assert.NoError(err) assert.True(resultSubmitBatch.Code == 0) // success code diff --git a/settlement/settlement.go b/settlement/settlement.go index 1925fb63e..ae94bc925 100644 --- a/settlement/settlement.go +++ b/settlement/settlement.go @@ -72,7 +72,7 @@ type ClientI interface { Stop() error // SubmitBatch tries submitting the batch in an async way to the settlement layer. This should create a transaction which (potentially) // triggers a state transition in the settlement layer. Events are emitted on success or failure. - SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) error + SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch, revision uint64) error // GetLatestBatch returns the latest batch from the settlement layer. GetLatestBatch() (*ResultRetrieveBatch, error) // GetBatchAtIndex returns the batch at the given index. From f86dcad8dca1e94b9c55186c2065b2e2d541120a Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 8 Nov 2024 11:05:21 +0100 Subject: [PATCH 025/119] delete instruction --- block/modes.go | 13 +++++++++++++ types/instruction.go | 10 ++++++++++ types/instruction_test.go | 6 ++++++ 3 files changed, 29 insertions(+) diff --git a/block/modes.go b/block/modes.go index b1a2033bd..5c9ee8162 100644 --- a/block/modes.go +++ b/block/modes.go @@ -3,6 +3,7 @@ package block import ( "context" "fmt" + "github.com/dymensionxyz/dymint/types" "github.com/dymensionxyz/dymint/p2p" "github.com/dymensionxyz/dymint/settlement" @@ -35,6 +36,13 @@ func (m *Manager) runAsFullNode(ctx context.Context, eg *errgroup.Group) error { m.subscribeFullNodeEvents(ctx) + if _, forkNeeded := m.forkNeeded(); forkNeeded { + err := types.DeleteInstructionFromDisk(m.RootDir) + if err != nil { + return fmt.Errorf("deleting instruction file: %w", err) + } + } + return nil } @@ -54,6 +62,11 @@ func (m *Manager) runAsProposer(ctx context.Context, eg *errgroup.Group) error { // if instruction file exists if instruction, forkNeeded := m.forkNeeded(); forkNeeded { m.handleSequencerForkTransition(instruction) + + err := types.DeleteInstructionFromDisk(m.RootDir) + if err != nil { + return fmt.Errorf("deleting instruction file: %w", err) + } } // check if we should rotate diff --git a/types/instruction.go b/types/instruction.go index 26df5e82e..3664d6c54 100644 --- a/types/instruction.go +++ b/types/instruction.go @@ -45,3 +45,13 @@ func LoadInstructionFromDisk(dir string) (Instruction, error) { return instruction, nil } + +func DeleteInstructionFromDisk(dir string) error { + filePath := filepath.Join(dir, instructionFileName) + err := os.Remove(filePath) + if err != nil { + return err + } + + return nil +} diff --git a/types/instruction_test.go b/types/instruction_test.go index e682445c9..75e8f4311 100644 --- a/types/instruction_test.go +++ b/types/instruction_test.go @@ -38,4 +38,10 @@ func TestPersistInstruction(t *testing.T) { instruction, err = LoadInstructionFromDisk(dir) require.NoError(t, err) require.Equal(t, instructionWithFaultyDrs, instruction) + + err = DeleteInstructionFromDisk(dir) + require.NoError(t, err) + + _, err = LoadInstructionFromDisk(dir) + require.Error(t, err) } From 32dddd9bc9ac3f83ac21fc076bb3bb0f07b283af Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Fri, 8 Nov 2024 12:49:19 +0100 Subject: [PATCH 026/119] fix(hardfork): fix tests and update for height 0 (#1207) --- block/fork.go | 23 ++++++----------------- block/manager_test.go | 2 +- block/modes.go | 1 + block/submit.go | 1 + block/submit_test.go | 4 ++-- settlement/local/local.go | 7 +++++-- 6 files changed, 16 insertions(+), 22 deletions(-) diff --git a/block/fork.go b/block/fork.go index fdcc0ce8e..9274e1ec6 100644 --- a/block/fork.go +++ b/block/fork.go @@ -48,6 +48,9 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { return err } + if m.State.Height() == 0 { + return nil + } lastBlock, err := m.Store.LoadBlock(m.State.Height()) if err != nil { return err @@ -154,27 +157,13 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { // Create a new block with the consensus messages m.Executor.AddConsensusMsgs(consensusMsgs...) - - block, commit, err := m.produceBlock(true, nil) - if err != nil { - panic(fmt.Sprintf("produce block: %v", err)) - } - - err = m.applyBlock(block, commit, types.BlockMetaData{Source: types.Produced}) - if err != nil { - panic(fmt.Sprintf("apply block: %v", err)) - } + m.ProduceApplyGossipBlock(context.Background(), true) // Create another block emtpy - block, commit, err = m.produceBlock(true, nil) - if err != nil { - panic(fmt.Sprintf("produce empty block: %v", err)) - } - - err = m.applyBlock(block, commit, types.BlockMetaData{Source: types.Produced}) + m.ProduceApplyGossipBlock(context.Background(), true) // Create Batch and send - _, err = m.CreateAndSubmitBatch(m.Conf.BatchSubmitBytes, false) + _, err := m.CreateAndSubmitBatch(m.Conf.BatchSubmitBytes, false) if err != nil { panic(fmt.Sprintf("create and submit batch: %v", err)) } diff --git a/block/manager_test.go b/block/manager_test.go index 710bc0b80..0b511c25e 100644 --- a/block/manager_test.go +++ b/block/manager_test.go @@ -192,7 +192,7 @@ func TestProduceOnlyAfterSynced(t *testing.T) { assert.True(t, manager.State.Height() == 0) // enough time to sync and produce blocks - ctx, cancel := context.WithTimeout(context.Background(), time.Second*4) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() // Capture the error returned by manager.Start. diff --git a/block/modes.go b/block/modes.go index 5c9ee8162..000d03fa1 100644 --- a/block/modes.go +++ b/block/modes.go @@ -84,6 +84,7 @@ func (m *Manager) runAsProposer(ctx context.Context, eg *errgroup.Group) error { uerrors.ErrGroupGoLog(eg, m.logger, func() error { return m.SubmitLoop(ctx, bytesProducedC) }) + uerrors.ErrGroupGoLog(eg, m.logger, func() error { bytesProducedC <- m.GetUnsubmittedBytes() // load unsubmitted bytes from previous run return m.ProduceBlockLoop(ctx, bytesProducedC) diff --git a/block/submit.go b/block/submit.go index b5e8b640a..8dabe60cb 100644 --- a/block/submit.go +++ b/block/submit.go @@ -275,6 +275,7 @@ func (m *Manager) GetUnsubmittedBytes() int { } total += block.SizeBytes() + commit.SizeBytes() } + return total } diff --git a/block/submit_test.go b/block/submit_test.go index bcdd37772..7a5f54be5 100644 --- a/block/submit_test.go +++ b/block/submit_test.go @@ -206,12 +206,12 @@ func TestBatchSubmissionFailedSubmission(t *testing.T) { assert.Zero(t, manager.LastSettlementHeight.Load()) // try to submit, we expect failure - slmock.On("SubmitBatch", mock.Anything, mock.Anything, mock.Anything).Return(fmt.Errorf("submit batch")).Once() + slmock.On("SubmitBatch", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(fmt.Errorf("submit batch")).Once() _, err = manager.CreateAndSubmitBatch(manager.Conf.BatchSubmitBytes, false) assert.Error(t, err) // try to submit again, we expect success - slmock.On("SubmitBatch", mock.Anything, mock.Anything, mock.Anything).Return(nil).Once() + slmock.On("SubmitBatch", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil).Once() manager.CreateAndSubmitBatch(manager.Conf.BatchSubmitBytes, false) assert.EqualValues(t, manager.State.Height(), manager.LastSettlementHeight.Load()) } diff --git a/settlement/local/local.go b/settlement/local/local.go index deb6d0ed3..1a488205f 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -55,8 +55,11 @@ type Client struct { } func (c *Client) GetRollapp() (*types.Rollapp, error) { - // TODO implement me - panic("implement me") + return &types.Rollapp{ + RollappID: c.rollappID, + Revision: 0, + RevisionStartHeight: 1, + }, nil } var _ settlement.ClientI = (*Client)(nil) From 8673f577667bea221c712dcb681bc8432f7b252c Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 8 Nov 2024 20:27:41 +0100 Subject: [PATCH 027/119] remove sequencer on instruction --- block/fork.go | 8 +------- block/fork_test.go | 28 +--------------------------- types/instruction.go | 1 - types/instruction_test.go | 2 -- 4 files changed, 2 insertions(+), 37 deletions(-) diff --git a/block/fork.go b/block/fork.go index 9274e1ec6..8806b8a38 100644 --- a/block/fork.go +++ b/block/fork.go @@ -69,18 +69,12 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { } func (m *Manager) createInstruction(rollapp *types.Rollapp) error { - nextProposer, err := m.SLClient.GetNextProposer() - if err != nil { - return err - } - instruction := types.Instruction{ Revision: rollapp.Revision, RevisionStartHeight: rollapp.RevisionStartHeight, - Sequencer: nextProposer.SettlementAddress, } - err = types.PersistInstructionToDisk(m.RootDir, instruction) + err := types.PersistInstructionToDisk(m.RootDir, instruction) if err != nil { return err } diff --git a/block/fork_test.go b/block/fork_test.go index 2d7ee8c98..c0045806e 100644 --- a/block/fork_test.go +++ b/block/fork_test.go @@ -219,7 +219,6 @@ func TestCreateInstruction(t *testing.T) { name string rollapp *types.Rollapp block *types.Block - setupMocks func(*settlement.MockClientI) expectedError bool }{ { @@ -233,39 +232,14 @@ func TestCreateInstruction(t *testing.T) { Height: 150, }, }, - setupMocks: func(mockSL *settlement.MockClientI) { - mockSL.On("GetNextProposer").Return(&types.Sequencer{ - SettlementAddress: "sequencer1", - }, nil) - }, expectedError: false, }, - { - name: "error getting state info", - rollapp: &types.Rollapp{ - Revision: 2, - RevisionStartHeight: 100, - }, - block: &types.Block{ - Header: types.Header{ - Height: 150, - }, - }, - setupMocks: func(mockSL *settlement.MockClientI) { - mockSL.On("GetNextProposer").Return((*types.Sequencer)(nil), assert.AnError) - }, - expectedError: true, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - mockSL := new(settlement.MockClientI) - tt.setupMocks(mockSL) - manager := &Manager{ - SLClient: mockSL, - RootDir: t.TempDir(), // Use temporary directory for testing + RootDir: t.TempDir(), // Use temporary directory for testing } err := manager.createInstruction(tt.rollapp) diff --git a/types/instruction.go b/types/instruction.go index 3664d6c54..2ae259f10 100644 --- a/types/instruction.go +++ b/types/instruction.go @@ -9,7 +9,6 @@ import ( type Instruction struct { Revision uint64 RevisionStartHeight uint64 - Sequencer string FaultyDRS *uint64 } diff --git a/types/instruction_test.go b/types/instruction_test.go index 75e8f4311..7bcfbab5d 100644 --- a/types/instruction_test.go +++ b/types/instruction_test.go @@ -12,7 +12,6 @@ func TestPersistInstruction(t *testing.T) { instructionWithNilFaultyDrs := Instruction{ Revision: 1, RevisionStartHeight: 1, - Sequencer: "sequencer", FaultyDRS: nil, } @@ -28,7 +27,6 @@ func TestPersistInstruction(t *testing.T) { instructionWithFaultyDrs := Instruction{ Revision: 1, RevisionStartHeight: 1, - Sequencer: "sequencer", FaultyDRS: faultyDrs, } From 665d5c5994b051eac8ae365677e124a94a0f5627 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 8 Nov 2024 22:13:40 +0100 Subject: [PATCH 028/119] validate blocks --- block/fork.go | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/block/fork.go b/block/fork.go index 8806b8a38..13fecbdbc 100644 --- a/block/fork.go +++ b/block/fork.go @@ -146,18 +146,50 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { // Always bump the account sequences msgBumpSequences := &sequencers.MsgBumpAccountSequences{Authority: "gov"} - consensusMsgs = append(consensusMsgs, msgBumpSequences) + // validate we haven't create the blocks yet + if m.State.NextHeight() == instruction.RevisionStartHeight+2 { + block, err := m.Store.LoadBlock(instruction.RevisionStartHeight) + if err != nil { + panic(fmt.Sprintf("load block: %v", err)) + } + + if len(block.Data.ConsensusMessages) <= 0 { + panic("expected consensus messages in block") + } + + nextBlock, err := m.Store.LoadBlock(instruction.RevisionStartHeight + 1) + if err != nil { + panic(fmt.Sprintf("load next block: %v", err)) + } + + if len(nextBlock.Data.ConsensusMessages) > 0 { + panic("unexpected consensus messages in next block") + } + + if len(nextBlock.Data.Txs) > 0 { + panic("unexpected transactions in next block") + } + + return + } + // Create a new block with the consensus messages m.Executor.AddConsensusMsgs(consensusMsgs...) - m.ProduceApplyGossipBlock(context.Background(), true) + _, _, err := m.ProduceApplyGossipBlock(context.Background(), true) + if err != nil { + panic(fmt.Sprintf("produce apply gossip block: %v", err)) + } // Create another block emtpy - m.ProduceApplyGossipBlock(context.Background(), true) + _, _, err = m.ProduceApplyGossipBlock(context.Background(), true) + if err != nil { + panic(fmt.Sprintf("produce apply gossip block: %v", err)) + } // Create Batch and send - _, err := m.CreateAndSubmitBatch(m.Conf.BatchSubmitBytes, false) + _, err = m.CreateAndSubmitBatch(m.Conf.BatchSubmitBytes, false) if err != nil { panic(fmt.Sprintf("create and submit batch: %v", err)) } From fd753cc97f7a78594739b2f824de161eed60824d Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 8 Nov 2024 22:18:42 +0100 Subject: [PATCH 029/119] batch checking before sending the 2 fork blocks --- block/fork.go | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/block/fork.go b/block/fork.go index 13fecbdbc..5785abf08 100644 --- a/block/fork.go +++ b/block/fork.go @@ -171,26 +171,31 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { if len(nextBlock.Data.Txs) > 0 { panic("unexpected transactions in next block") } + } else { + // Create a new block with the consensus messages + m.Executor.AddConsensusMsgs(consensusMsgs...) + _, _, err := m.ProduceApplyGossipBlock(context.Background(), true) + if err != nil { + panic(fmt.Sprintf("produce apply gossip block: %v", err)) + } - return - } - - // Create a new block with the consensus messages - m.Executor.AddConsensusMsgs(consensusMsgs...) - _, _, err := m.ProduceApplyGossipBlock(context.Background(), true) - if err != nil { - panic(fmt.Sprintf("produce apply gossip block: %v", err)) + // Create another block emtpy + _, _, err = m.ProduceApplyGossipBlock(context.Background(), true) + if err != nil { + panic(fmt.Sprintf("produce apply gossip block: %v", err)) + } } - // Create another block emtpy - _, _, err = m.ProduceApplyGossipBlock(context.Background(), true) + resp, err := m.SLClient.GetBatchAtHeight(instruction.RevisionStartHeight) if err != nil { - panic(fmt.Sprintf("produce apply gossip block: %v", err)) + panic(fmt.Sprintf("get batch at height: %v", err)) } - // Create Batch and send - _, err = m.CreateAndSubmitBatch(m.Conf.BatchSubmitBytes, false) - if err != nil { - panic(fmt.Sprintf("create and submit batch: %v", err)) + if resp.Batch == nil { + // Create Batch and send + _, err := m.CreateAndSubmitBatch(m.Conf.BatchSubmitBytes, false) + if err != nil { + panic(fmt.Sprintf("create and submit batch: %v", err)) + } } } From 16a4003c325d1cbc59f11e2769ec7175c8fa8e01 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 8 Nov 2024 22:36:42 +0100 Subject: [PATCH 030/119] add some comments --- block/fork.go | 167 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 115 insertions(+), 52 deletions(-) diff --git a/block/fork.go b/block/fork.go index 5785abf08..b11963f89 100644 --- a/block/fork.go +++ b/block/fork.go @@ -126,76 +126,139 @@ func (m *Manager) forkNeeded() (types.Instruction, bool) { // handleSequencerForkTransition handles the sequencer fork transition func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { - var consensusMsgs []proto.Message - if instruction.FaultyDRS != nil { - drsAsInt, err := strconv.Atoi(version.DrsVersion) - if err != nil { - panic(fmt.Sprintf("error converting DRS version to int: %v", err)) - } + consensusMsgs, err := m.prepareDRSUpgradeMessages(instruction.FaultyDRS) + if err != nil { + panic(fmt.Sprintf("prepare DRS upgrade messages: %v", err)) + } - if *instruction.FaultyDRS == uint64(drsAsInt) { - panic(fmt.Sprintf("running faulty DRS version %d", *instruction.FaultyDRS)) - } + // Always bump the account sequences + consensusMsgs = append(consensusMsgs, &sequencers.MsgBumpAccountSequences{Authority: "gov"}) - msgUpgradeDRS := &sequencers.MsgUpgradeDRS{ - DrsVersion: uint64(drsAsInt), - } + err = m.handleForkBlockCreation(instruction, consensusMsgs) + if err != nil { + panic(fmt.Sprintf("validate existing blocks: %v", err)) + } - consensusMsgs = append(consensusMsgs, msgUpgradeDRS) + if err := m.ensureBatchExists(instruction.RevisionStartHeight); err != nil { + panic(fmt.Sprintf("ensure batch exists: %v", err)) } +} - // Always bump the account sequences - msgBumpSequences := &sequencers.MsgBumpAccountSequences{Authority: "gov"} - consensusMsgs = append(consensusMsgs, msgBumpSequences) +// prepareDRSUpgradeMessages prepares consensus messages for DRS upgrades. +// It performs version validation and generates the necessary upgrade messages for the sequencer. +// +// The function implements the following logic: +// - If no faulty DRS version is provided (faultyDRS is nil), returns no messages +// - Validates the current DRS version against the potentially faulty version +// - Generates an upgrade message with the current valid DRS version +func (m *Manager) prepareDRSUpgradeMessages(faultyDRS *uint64) ([]proto.Message, error) { + if faultyDRS == nil { + return nil, nil + } - // validate we haven't create the blocks yet + actualDRS, err := strconv.Atoi(version.DrsVersion) + if err != nil { + return nil, fmt.Errorf("converting DRS version to int: %v", err) + } + + if *faultyDRS == uint64(actualDRS) { + return nil, fmt.Errorf("running faulty DRS version %d", *faultyDRS) + } + + return []proto.Message{ + &sequencers.MsgUpgradeDRS{ + DrsVersion: uint64(actualDRS), + }, + }, nil +} + +// handleForkBlockCreation manages the block creation process during a fork transition. +// +// The function implements the following logic: +// 1. Checks if blocks for the fork transition have already been created by comparing heights +// 2. If blocks exist (NextHeight == RevisionStartHeight + 2), validates their state +// 3. If blocks don't exist, triggers the creation of new blocks with the provided consensus messages +// +// Block Creation Rules: +// - Two blocks are considered in this process: +// * First block: Contains consensus messages for the fork +// * Second block: Should be empty (no messages or transactions) +// - Total height increase should be 2 blocks from RevisionStartHeight +func (m *Manager) handleForkBlockCreation(instruction types.Instruction, consensusMsgs []proto.Message) error { if m.State.NextHeight() == instruction.RevisionStartHeight+2 { - block, err := m.Store.LoadBlock(instruction.RevisionStartHeight) - if err != nil { - panic(fmt.Sprintf("load block: %v", err)) - } + return m.validateExistingBlocks(instruction) + } - if len(block.Data.ConsensusMessages) <= 0 { - panic("expected consensus messages in block") - } + return m.createNewBlocks(consensusMsgs) +} - nextBlock, err := m.Store.LoadBlock(instruction.RevisionStartHeight + 1) - if err != nil { - panic(fmt.Sprintf("load next block: %v", err)) - } +// validateExistingBlocks performs validation checks on a pair of consecutive blocks +// during the sequencer fork transition process. +// +// The function performs the following validations: +// 1. Verifies that the initial block at RevisionStartHeight exists and contains consensus messages +// 2. Confirms that the subsequent block exists and is empty (no consensus messages or transactions) +func (m *Manager) validateExistingBlocks(instruction types.Instruction) error { + block, err := m.Store.LoadBlock(instruction.RevisionStartHeight) + if err != nil { + return fmt.Errorf("loading block: %v", err) + } - if len(nextBlock.Data.ConsensusMessages) > 0 { - panic("unexpected consensus messages in next block") - } + if len(block.Data.ConsensusMessages) <= 0 { + return fmt.Errorf("expected consensus messages in block") + } - if len(nextBlock.Data.Txs) > 0 { - panic("unexpected transactions in next block") - } - } else { - // Create a new block with the consensus messages - m.Executor.AddConsensusMsgs(consensusMsgs...) - _, _, err := m.ProduceApplyGossipBlock(context.Background(), true) - if err != nil { - panic(fmt.Sprintf("produce apply gossip block: %v", err)) - } + nextBlock, err := m.Store.LoadBlock(instruction.RevisionStartHeight + 1) + if err != nil { + return fmt.Errorf("loading next block: %v", err) + } - // Create another block emtpy - _, _, err = m.ProduceApplyGossipBlock(context.Background(), true) - if err != nil { - panic(fmt.Sprintf("produce apply gossip block: %v", err)) - } + if len(nextBlock.Data.ConsensusMessages) > 0 { + return fmt.Errorf("unexpected consensus messages in next block") } - resp, err := m.SLClient.GetBatchAtHeight(instruction.RevisionStartHeight) + if len(nextBlock.Data.Txs) > 0 { + return fmt.Errorf("unexpected transactions in next block") + } + + return nil +} + +// createNewBlocks creates new blocks with the provided consensus messages +func (m *Manager) createNewBlocks(consensusMsgs []proto.Message) error { + m.Executor.AddConsensusMsgs(consensusMsgs...) + + // Create first block with consensus messages + if _, _, err := m.ProduceApplyGossipBlock(context.Background(), true); err != nil { + return fmt.Errorf("producing first block: %v", err) + } + + // Create second empty block + if _, _, err := m.ProduceApplyGossipBlock(context.Background(), true); err != nil { + return fmt.Errorf("producing second block: %v", err) + } + + return nil +} + +// ensureBatchExists verifies and, if necessary, creates a batch at the specified height. +// This function is critical for maintaining batch consistency in the blockchain while +// preventing duplicate batch submissions. +// +// The function performs the following operations: +// 1. Checks for an existing batch at the specified height via SLClient +// 2. If no batch exists, creates and submits a new one +func (m *Manager) ensureBatchExists(height uint64) error { + resp, err := m.SLClient.GetBatchAtHeight(height) if err != nil { - panic(fmt.Sprintf("get batch at height: %v", err)) + return fmt.Errorf("getting batch at height: %v", err) } if resp.Batch == nil { - // Create Batch and send - _, err := m.CreateAndSubmitBatch(m.Conf.BatchSubmitBytes, false) - if err != nil { - panic(fmt.Sprintf("create and submit batch: %v", err)) + if _, err := m.CreateAndSubmitBatch(m.Conf.BatchSubmitBytes, false); err != nil { + return fmt.Errorf("creating and submitting batch: %v", err) } } + + return nil } From e629e3e1dd9fe74cca25e64ac717e0882dea93dc Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Thu, 7 Nov 2024 10:23:01 +0100 Subject: [PATCH 031/119] fix(manager/indexer): pruning fixes (#1147) --- indexers/blockindexer/kv/kv.go | 2 ++ indexers/txindex/kv/kv.go | 1 + store/pruning.go | 1 + 3 files changed, 4 insertions(+) diff --git a/indexers/blockindexer/kv/kv.go b/indexers/blockindexer/kv/kv.go index d03e32940..648838cc8 100644 --- a/indexers/blockindexer/kv/kv.go +++ b/indexers/blockindexer/kv/kv.go @@ -621,6 +621,8 @@ func (idx *BlockerIndexer) pruneEvents(height int64, logger log.Logger, batch st logger.Error("pruning block indexer iterate events", "height", height, "err", err) continue } + pruned++ + } return pruned, nil } diff --git a/indexers/txindex/kv/kv.go b/indexers/txindex/kv/kv.go index aeca26fc6..a9f1f7608 100644 --- a/indexers/txindex/kv/kv.go +++ b/indexers/txindex/kv/kv.go @@ -665,6 +665,7 @@ func (txi *TxIndex) pruneEvents(height uint64, batch store.KVBatch) (uint64, err if err != nil { return pruned, err } + pruned++ } return pruned, nil } diff --git a/store/pruning.go b/store/pruning.go index 5940f8ae9..555177d3a 100644 --- a/store/pruning.go +++ b/store/pruning.go @@ -32,6 +32,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) { pruneBlocks := func(batch KVBatch, height uint64) error { + hash, err := s.loadHashFromIndex(height) if err != nil { return err From e8f0ee30971262feff3a53eef5a96f3146deee4b Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sat, 9 Nov 2024 16:06:05 +0100 Subject: [PATCH 032/119] freeze proposer --- block/fork.go | 31 +- block/manager.go | 8 + block/produce.go | 5 + .../dymint/block/mock_ExecutorI.go | 2 +- .../dymint/block/mock_FraudHandler.go | 2 +- .../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 | 2 +- .../dymensionxyz/dymint/store/mock_Store.go | 380 +++++++++++++++++- .../dymension/rollapp/mock_QueryClient.go | 2 +- .../dymension/sequencer/mock_QueryClient.go | 2 +- .../tendermint/abci/types/mock_Application.go | 2 +- .../tendermint/proxy/mock_AppConnConsensus.go | 2 +- .../tendermint/proxy/mock_AppConns.go | 2 +- 16 files changed, 400 insertions(+), 48 deletions(-) diff --git a/block/fork.go b/block/fork.go index b11963f89..055c2e3ef 100644 --- a/block/fork.go +++ b/block/fork.go @@ -8,10 +8,8 @@ import ( "github.com/gogo/protobuf/proto" - "github.com/dymensionxyz/dymint/node/events" "github.com/dymensionxyz/dymint/types" sequencers "github.com/dymensionxyz/dymint/types/pb/rollapp/sequencers/types" - uevent "github.com/dymensionxyz/dymint/utils/event" "github.com/dymensionxyz/dymint/version" ) @@ -61,8 +59,9 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { if err != nil { return err } - - m.freezeNode(ctx) + err := fmt.Errorf("fork update") + m.freezeNode(ctx, err) + return err } return nil @@ -107,14 +106,6 @@ func (m *Manager) shouldStopNode(rollapp *types.Rollapp, block *types.Block) boo return false } -// freezeNode stops the rollapp node -func (m *Manager) freezeNode(ctx context.Context) { - m.logger.Info("Freezing node due to fork update") - - err := fmt.Errorf("node frozen due to fork update") - uevent.MustPublish(ctx, m.Pubsub, &events.DataHealthStatus{Error: err}, events.HealthStatusList) -} - // forkNeeded returns true if the fork file exists func (m *Manager) forkNeeded() (types.Instruction, bool) { if instruction, err := types.LoadInstructionFromDisk(m.RootDir); err == nil { @@ -139,7 +130,7 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { panic(fmt.Sprintf("validate existing blocks: %v", err)) } - if err := m.ensureBatchExists(instruction.RevisionStartHeight); err != nil { + if err := m.handleForkBatchSubmission(instruction.RevisionStartHeight); err != nil { panic(fmt.Sprintf("ensure batch exists: %v", err)) } } @@ -175,14 +166,14 @@ func (m *Manager) prepareDRSUpgradeMessages(faultyDRS *uint64) ([]proto.Message, // handleForkBlockCreation manages the block creation process during a fork transition. // // The function implements the following logic: -// 1. Checks if blocks for the fork transition have already been created by comparing heights -// 2. If blocks exist (NextHeight == RevisionStartHeight + 2), validates their state -// 3. If blocks don't exist, triggers the creation of new blocks with the provided consensus messages +// 1. Checks if blocks for the fork transition have already been created by comparing heights +// 2. If blocks exist (NextHeight == RevisionStartHeight + 2), validates their state +// 3. If blocks don't exist, triggers the creation of new blocks with the provided consensus messages // // Block Creation Rules: // - Two blocks are considered in this process: -// * First block: Contains consensus messages for the fork -// * Second block: Should be empty (no messages or transactions) +// - First block: Contains consensus messages for the fork +// - Second block: Should be empty (no messages or transactions) // - Total height increase should be 2 blocks from RevisionStartHeight func (m *Manager) handleForkBlockCreation(instruction types.Instruction, consensusMsgs []proto.Message) error { if m.State.NextHeight() == instruction.RevisionStartHeight+2 { @@ -241,14 +232,14 @@ func (m *Manager) createNewBlocks(consensusMsgs []proto.Message) error { return nil } -// ensureBatchExists verifies and, if necessary, creates a batch at the specified height. +// handleForkBatchSubmission verifies and, if necessary, creates a batch at the specified height. // This function is critical for maintaining batch consistency in the blockchain while // preventing duplicate batch submissions. // // The function performs the following operations: // 1. Checks for an existing batch at the specified height via SLClient // 2. If no batch exists, creates and submits a new one -func (m *Manager) ensureBatchExists(height uint64) error { +func (m *Manager) handleForkBatchSubmission(height uint64) error { resp, err := m.SLClient.GetBatchAtHeight(height) if err != nil { return fmt.Errorf("getting batch at height: %v", err) diff --git a/block/manager.go b/block/manager.go index b9e3fc741..cd958a620 100644 --- a/block/manager.go +++ b/block/manager.go @@ -116,6 +116,9 @@ type Manager struct { // validates all non-finalized state updates from settlement, checking there is consistency between DA and P2P blocks, and the information in the state update. SettlementValidator *SettlementValidator + + // frozen indicates if the node is frozen due to unhealthy event. used to stop block production. + frozen bool } // NewManager creates new block Manager. @@ -173,6 +176,7 @@ func NewManager( settlementSyncingC: make(chan struct{}, 1), // use of buffered channel to avoid blocking. In case channel is full, its skipped because there is an ongoing syncing process, but syncing height is updated, which means the ongoing syncing will sync to the new height. settlementValidationC: make(chan struct{}, 1), // use of buffered channel to avoid blocking. In case channel is full, its skipped because there is an ongoing validation process, but validation height is updated, which means the ongoing validation will validate to the new height. syncedFromSettlement: uchannel.NewNudger(), // used by the sequencer to wait till the node completes the syncing from settlement. + frozen: false, } m.setFraudHandler(NewFreezeHandler(m)) @@ -396,9 +400,13 @@ func (m *Manager) setFraudHandler(handler *FreezeHandler) { m.FraudHandler = handler } +// freezeNode sets the node as unhealthy and prevents the node continues producing and processing blocks func (m *Manager) freezeNode(ctx context.Context, err error) { + m.logger.Info("Freezing node", "err", err) + m.frozen = true uevent.MustPublish(ctx, m.Pubsub, &events.DataHealthStatus{Error: err}, events.HealthStatusList) if m.RunMode == RunModeFullNode { m.unsubscribeFullNodeEvents(ctx) } + } diff --git a/block/produce.go b/block/produce.go index 65e388f1a..ff4f02e93 100644 --- a/block/produce.go +++ b/block/produce.go @@ -45,6 +45,11 @@ func (m *Manager) ProduceBlockLoop(ctx context.Context, bytesProducedC chan int) continue } + // finish the block production loop in case the node is frozen + if m.frozen { + return nil + } + // if empty blocks are configured to be enabled, and one is scheduled... produceEmptyBlock := firstBlock || m.Conf.MaxIdleTime == 0 || nextEmptyBlock.Before(time.Now()) firstBlock = false diff --git a/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go b/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go index 560f38340..ce0bc08de 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.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. DO NOT EDIT. package block diff --git a/mocks/github.com/dymensionxyz/dymint/block/mock_FraudHandler.go b/mocks/github.com/dymensionxyz/dymint/block/mock_FraudHandler.go index b9ddec5ac..932c51a2e 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.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. DO NOT EDIT. package block 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 3478b4c1a..0e79e172c 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 03ca2d67a..52210eec7 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 e90167f00..87a64b313 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 diff --git a/mocks/github.com/dymensionxyz/dymint/store/mock_Store.go b/mocks/github.com/dymensionxyz/dymint/store/mock_Store.go index 764f4e340..5cb0aee0f 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 @@ -71,6 +71,61 @@ func (_c *MockStore_Close_Call) RunAndReturn(run func() error) *MockStore_Close_ return _c } +// LoadBaseHeight provides a mock function with given fields: +func (_m *MockStore) LoadBaseHeight() (uint64, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for LoadBaseHeight") + } + + var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func() (uint64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() uint64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint64) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockStore_LoadBaseHeight_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoadBaseHeight' +type MockStore_LoadBaseHeight_Call struct { + *mock.Call +} + +// LoadBaseHeight is a helper method to define mock.On call +func (_e *MockStore_Expecter) LoadBaseHeight() *MockStore_LoadBaseHeight_Call { + return &MockStore_LoadBaseHeight_Call{Call: _e.mock.On("LoadBaseHeight")} +} + +func (_c *MockStore_LoadBaseHeight_Call) Run(run func()) *MockStore_LoadBaseHeight_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockStore_LoadBaseHeight_Call) Return(_a0 uint64, _a1 error) *MockStore_LoadBaseHeight_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockStore_LoadBaseHeight_Call) RunAndReturn(run func() (uint64, error)) *MockStore_LoadBaseHeight_Call { + _c.Call.Return(run) + return _c +} + // LoadBlock provides a mock function with given fields: height func (_m *MockStore) LoadBlock(height uint64) (*types.Block, error) { ret := _m.Called(height) @@ -357,6 +412,61 @@ func (_c *MockStore_LoadBlockSource_Call) RunAndReturn(run func(uint64) (types.B return _c } +// LoadBlockSyncBaseHeight provides a mock function with given fields: +func (_m *MockStore) LoadBlockSyncBaseHeight() (uint64, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for LoadBlockSyncBaseHeight") + } + + var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func() (uint64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() uint64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint64) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockStore_LoadBlockSyncBaseHeight_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoadBlockSyncBaseHeight' +type MockStore_LoadBlockSyncBaseHeight_Call struct { + *mock.Call +} + +// LoadBlockSyncBaseHeight is a helper method to define mock.On call +func (_e *MockStore_Expecter) LoadBlockSyncBaseHeight() *MockStore_LoadBlockSyncBaseHeight_Call { + return &MockStore_LoadBlockSyncBaseHeight_Call{Call: _e.mock.On("LoadBlockSyncBaseHeight")} +} + +func (_c *MockStore_LoadBlockSyncBaseHeight_Call) Run(run func()) *MockStore_LoadBlockSyncBaseHeight_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockStore_LoadBlockSyncBaseHeight_Call) Return(_a0 uint64, _a1 error) *MockStore_LoadBlockSyncBaseHeight_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockStore_LoadBlockSyncBaseHeight_Call) RunAndReturn(run func() (uint64, error)) *MockStore_LoadBlockSyncBaseHeight_Call { + _c.Call.Return(run) + return _c +} + // LoadCommit provides a mock function with given fields: height func (_m *MockStore) LoadCommit(height uint64) (*types.Commit, error) { ret := _m.Called(height) @@ -529,6 +639,61 @@ func (_c *MockStore_LoadDRSVersion_Call) RunAndReturn(run func(uint64) (uint32, return _c } +// LoadIndexerBaseHeight provides a mock function with given fields: +func (_m *MockStore) LoadIndexerBaseHeight() (uint64, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for LoadIndexerBaseHeight") + } + + var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func() (uint64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() uint64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint64) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockStore_LoadIndexerBaseHeight_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoadIndexerBaseHeight' +type MockStore_LoadIndexerBaseHeight_Call struct { + *mock.Call +} + +// LoadIndexerBaseHeight is a helper method to define mock.On call +func (_e *MockStore_Expecter) LoadIndexerBaseHeight() *MockStore_LoadIndexerBaseHeight_Call { + return &MockStore_LoadIndexerBaseHeight_Call{Call: _e.mock.On("LoadIndexerBaseHeight")} +} + +func (_c *MockStore_LoadIndexerBaseHeight_Call) Run(run func()) *MockStore_LoadIndexerBaseHeight_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockStore_LoadIndexerBaseHeight_Call) Return(_a0 uint64, _a1 error) *MockStore_LoadIndexerBaseHeight_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockStore_LoadIndexerBaseHeight_Call) RunAndReturn(run func() (uint64, error)) *MockStore_LoadIndexerBaseHeight_Call { + _c.Call.Return(run) + return _c +} + // LoadProposer provides a mock function with given fields: height func (_m *MockStore) LoadProposer(height uint64) (types.Sequencer, error) { ret := _m.Called(height) @@ -744,9 +909,9 @@ func (_c *MockStore_NewBatch_Call) RunAndReturn(run func() store.KVBatch) *MockS return _c } -// 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) +// 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) if len(ret) == 0 { panic("no return value specified for PruneStore") @@ -754,17 +919,17 @@ func (_m *MockStore) PruneStore(from uint64, to uint64, logger types.Logger) (ui 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, types.Logger) (uint64, error)); ok { + return rf(to, logger) } - if rf, ok := ret.Get(0).(func(uint64, uint64, types.Logger) uint64); ok { - r0 = rf(from, to, logger) + if rf, ok := ret.Get(0).(func(uint64, types.Logger) uint64); ok { + r0 = rf(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) + if rf, ok := ret.Get(1).(func(uint64, types.Logger) error); ok { + r1 = rf(to, logger) } else { r1 = ret.Error(1) } @@ -778,16 +943,15 @@ type MockStore_PruneStore_Call struct { } // PruneStore is a helper method to define mock.On call -// - from uint64 // - to uint64 // - 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 (_e *MockStore_Expecter) PruneStore(to interface{}, logger interface{}) *MockStore_PruneStore_Call { + return &MockStore_PruneStore_Call{Call: _e.mock.On("PruneStore", to, logger)} } -func (_c *MockStore_PruneStore_Call) Run(run func(from uint64, to uint64, logger types.Logger)) *MockStore_PruneStore_Call { +func (_c *MockStore_PruneStore_Call) Run(run func(to uint64, logger types.Logger)) *MockStore_PruneStore_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(uint64), args[1].(uint64), args[2].(types.Logger)) + run(args[0].(uint64), args[1].(types.Logger)) }) return _c } @@ -797,7 +961,99 @@ func (_c *MockStore_PruneStore_Call) Return(_a0 uint64, _a1 error) *MockStore_Pr return _c } -func (_c *MockStore_PruneStore_Call) RunAndReturn(run func(uint64, uint64, types.Logger) (uint64, error)) *MockStore_PruneStore_Call { +func (_c *MockStore_PruneStore_Call) RunAndReturn(run func(uint64, types.Logger) (uint64, error)) *MockStore_PruneStore_Call { + _c.Call.Return(run) + return _c +} + +// RemoveBlockCid provides a mock function with given fields: height +func (_m *MockStore) RemoveBlockCid(height uint64) error { + ret := _m.Called(height) + + if len(ret) == 0 { + panic("no return value specified for RemoveBlockCid") + } + + var r0 error + if rf, ok := ret.Get(0).(func(uint64) error); ok { + r0 = rf(height) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockStore_RemoveBlockCid_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveBlockCid' +type MockStore_RemoveBlockCid_Call struct { + *mock.Call +} + +// RemoveBlockCid is a helper method to define mock.On call +// - height uint64 +func (_e *MockStore_Expecter) RemoveBlockCid(height interface{}) *MockStore_RemoveBlockCid_Call { + return &MockStore_RemoveBlockCid_Call{Call: _e.mock.On("RemoveBlockCid", height)} +} + +func (_c *MockStore_RemoveBlockCid_Call) Run(run func(height uint64)) *MockStore_RemoveBlockCid_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64)) + }) + return _c +} + +func (_c *MockStore_RemoveBlockCid_Call) Return(_a0 error) *MockStore_RemoveBlockCid_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockStore_RemoveBlockCid_Call) RunAndReturn(run func(uint64) error) *MockStore_RemoveBlockCid_Call { + _c.Call.Return(run) + return _c +} + +// SaveBaseHeight provides a mock function with given fields: height +func (_m *MockStore) SaveBaseHeight(height uint64) error { + ret := _m.Called(height) + + if len(ret) == 0 { + panic("no return value specified for SaveBaseHeight") + } + + var r0 error + if rf, ok := ret.Get(0).(func(uint64) error); ok { + r0 = rf(height) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockStore_SaveBaseHeight_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SaveBaseHeight' +type MockStore_SaveBaseHeight_Call struct { + *mock.Call +} + +// SaveBaseHeight is a helper method to define mock.On call +// - height uint64 +func (_e *MockStore_Expecter) SaveBaseHeight(height interface{}) *MockStore_SaveBaseHeight_Call { + return &MockStore_SaveBaseHeight_Call{Call: _e.mock.On("SaveBaseHeight", height)} +} + +func (_c *MockStore_SaveBaseHeight_Call) Run(run func(height uint64)) *MockStore_SaveBaseHeight_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64)) + }) + return _c +} + +func (_c *MockStore_SaveBaseHeight_Call) Return(_a0 error) *MockStore_SaveBaseHeight_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockStore_SaveBaseHeight_Call) RunAndReturn(run func(uint64) error) *MockStore_SaveBaseHeight_Call { _c.Call.Return(run) return _c } @@ -1042,6 +1298,52 @@ func (_c *MockStore_SaveBlockSource_Call) RunAndReturn(run func(uint64, types.Bl return _c } +// SaveBlockSyncBaseHeight provides a mock function with given fields: height +func (_m *MockStore) SaveBlockSyncBaseHeight(height uint64) error { + ret := _m.Called(height) + + if len(ret) == 0 { + panic("no return value specified for SaveBlockSyncBaseHeight") + } + + var r0 error + if rf, ok := ret.Get(0).(func(uint64) error); ok { + r0 = rf(height) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockStore_SaveBlockSyncBaseHeight_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SaveBlockSyncBaseHeight' +type MockStore_SaveBlockSyncBaseHeight_Call struct { + *mock.Call +} + +// SaveBlockSyncBaseHeight is a helper method to define mock.On call +// - height uint64 +func (_e *MockStore_Expecter) SaveBlockSyncBaseHeight(height interface{}) *MockStore_SaveBlockSyncBaseHeight_Call { + return &MockStore_SaveBlockSyncBaseHeight_Call{Call: _e.mock.On("SaveBlockSyncBaseHeight", height)} +} + +func (_c *MockStore_SaveBlockSyncBaseHeight_Call) Run(run func(height uint64)) *MockStore_SaveBlockSyncBaseHeight_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64)) + }) + return _c +} + +func (_c *MockStore_SaveBlockSyncBaseHeight_Call) Return(_a0 error) *MockStore_SaveBlockSyncBaseHeight_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockStore_SaveBlockSyncBaseHeight_Call) RunAndReturn(run func(uint64) error) *MockStore_SaveBlockSyncBaseHeight_Call { + _c.Call.Return(run) + return _c +} + // SaveDRSVersion provides a mock function with given fields: height, version, batch func (_m *MockStore) SaveDRSVersion(height uint64, version uint32, batch store.KVBatch) (store.KVBatch, error) { ret := _m.Called(height, version, batch) @@ -1102,6 +1404,52 @@ func (_c *MockStore_SaveDRSVersion_Call) RunAndReturn(run func(uint64, uint32, s return _c } +// SaveIndexerBaseHeight provides a mock function with given fields: height +func (_m *MockStore) SaveIndexerBaseHeight(height uint64) error { + ret := _m.Called(height) + + if len(ret) == 0 { + panic("no return value specified for SaveIndexerBaseHeight") + } + + var r0 error + if rf, ok := ret.Get(0).(func(uint64) error); ok { + r0 = rf(height) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockStore_SaveIndexerBaseHeight_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SaveIndexerBaseHeight' +type MockStore_SaveIndexerBaseHeight_Call struct { + *mock.Call +} + +// SaveIndexerBaseHeight is a helper method to define mock.On call +// - height uint64 +func (_e *MockStore_Expecter) SaveIndexerBaseHeight(height interface{}) *MockStore_SaveIndexerBaseHeight_Call { + return &MockStore_SaveIndexerBaseHeight_Call{Call: _e.mock.On("SaveIndexerBaseHeight", height)} +} + +func (_c *MockStore_SaveIndexerBaseHeight_Call) Run(run func(height uint64)) *MockStore_SaveIndexerBaseHeight_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64)) + }) + return _c +} + +func (_c *MockStore_SaveIndexerBaseHeight_Call) Return(_a0 error) *MockStore_SaveIndexerBaseHeight_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockStore_SaveIndexerBaseHeight_Call) RunAndReturn(run func(uint64) error) *MockStore_SaveIndexerBaseHeight_Call { + _c.Call.Return(run) + return _c +} + // SaveProposer provides a mock function with given fields: height, proposer, batch func (_m *MockStore) SaveProposer(height uint64, proposer types.Sequencer, batch store.KVBatch) (store.KVBatch, error) { ret := _m.Called(height, proposer, batch) 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/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 ba704d658..af5bcaf4b 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.46.0. DO NOT EDIT. +// Code generated by mockery v2.42.3. 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 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 From a7d7e574ab2536233792bd6b109ba977cbd7310f Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sat, 9 Nov 2024 16:28:09 +0100 Subject: [PATCH 033/119] lint fix --- .golangci.yml | 5 ++++- block/manager.go | 1 - block/modes.go | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 53f3833d1..3131b8918 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -48,6 +48,9 @@ linters: - unconvert - unused +excludes: + gosec: + - G115 issues: exclude-use-default: false exclude: @@ -71,4 +74,4 @@ linters-settings: severity: warning disabled: true errcheck: - check-type-assertions: true \ No newline at end of file + check-type-assertions: true diff --git a/block/manager.go b/block/manager.go index cd958a620..20ff36b58 100644 --- a/block/manager.go +++ b/block/manager.go @@ -408,5 +408,4 @@ func (m *Manager) freezeNode(ctx context.Context, err error) { if m.RunMode == RunModeFullNode { m.unsubscribeFullNodeEvents(ctx) } - } diff --git a/block/modes.go b/block/modes.go index 000d03fa1..bd99ec44b 100644 --- a/block/modes.go +++ b/block/modes.go @@ -3,6 +3,7 @@ package block import ( "context" "fmt" + "github.com/dymensionxyz/dymint/types" "github.com/dymensionxyz/dymint/p2p" From 9fa63cfeeb75247ce1e38eee035393643c2527d2 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sat, 9 Nov 2024 16:33:49 +0100 Subject: [PATCH 034/119] lint test --- .golangci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 3131b8918..447ce4906 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -48,9 +48,6 @@ linters: - unconvert - unused -excludes: - gosec: - - G115 issues: exclude-use-default: false exclude: @@ -75,3 +72,6 @@ linters-settings: disabled: true errcheck: check-type-assertions: true + gosec: + settings: + exclude: "G115" From b150dadb6a4d287cb0f51b99986e3678d750a63d Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sat, 9 Nov 2024 18:27:46 +0100 Subject: [PATCH 035/119] freeze submit loop --- block/fork.go | 8 ++++++-- block/manager.go | 5 +++++ block/submit.go | 8 ++++++++ block/submit_loop_test.go | 6 ++++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/block/fork.go b/block/fork.go index 055c2e3ef..452568b8a 100644 --- a/block/fork.go +++ b/block/fork.go @@ -2,6 +2,7 @@ package block import ( "context" + "errors" "fmt" "strconv" "time" @@ -11,6 +12,7 @@ import ( "github.com/dymensionxyz/dymint/types" sequencers "github.com/dymensionxyz/dymint/types/pb/rollapp/sequencers/types" "github.com/dymensionxyz/dymint/version" + "github.com/dymensionxyz/gerr-cosmos/gerrc" ) const ( @@ -35,6 +37,9 @@ func (m *Manager) MonitorForkUpdateLoop(ctx context.Context) error { if err := m.checkForkUpdate(ctx); err != nil { continue } + if m.frozen { + return nil + } } } } @@ -61,7 +66,6 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { } err := fmt.Errorf("fork update") m.freezeNode(ctx, err) - return err } return nil @@ -241,7 +245,7 @@ func (m *Manager) createNewBlocks(consensusMsgs []proto.Message) error { // 2. If no batch exists, creates and submits a new one func (m *Manager) handleForkBatchSubmission(height uint64) error { resp, err := m.SLClient.GetBatchAtHeight(height) - if err != nil { + if err != nil && !errors.Is(err, gerrc.ErrNotFound) { return fmt.Errorf("getting batch at height: %v", err) } diff --git a/block/manager.go b/block/manager.go index 20ff36b58..35e1d7b61 100644 --- a/block/manager.go +++ b/block/manager.go @@ -409,3 +409,8 @@ func (m *Manager) freezeNode(ctx context.Context, err error) { m.unsubscribeFullNodeEvents(ctx) } } + +// isFrozen returns whether the node is in frozen state +func (m *Manager) isFrozen() bool { + return m.frozen +} diff --git a/block/submit.go b/block/submit.go index 8dabe60cb..b0dccf62f 100644 --- a/block/submit.go +++ b/block/submit.go @@ -35,6 +35,7 @@ func (m *Manager) SubmitLoop(ctx context.Context, m.Conf.BatchSubmitTime, m.Conf.BatchSubmitBytes, m.CreateAndSubmitBatchGetSizeBlocksCommits, + m.isFrozen, ) } @@ -48,6 +49,7 @@ func SubmitLoopInner( maxBatchTime time.Duration, // max time to allow between batches maxBatchBytes uint64, // max size of serialised batch in bytes createAndSubmitBatch func(maxSizeBytes uint64) (sizeBlocksCommits uint64, err error), + frozen func() bool, ) error { eg, ctx := errgroup.WithContext(ctx) @@ -60,6 +62,9 @@ func SubmitLoopInner( // 'trigger': this thread is responsible for waking up the submitter when a new block arrives, and back-pressures the block production loop // if it gets too far ahead. for { + if frozen() { + return nil + } if maxBatchSkew*maxBatchBytes < pendingBytes.Load() { // too much stuff is pending submission // we block here until we get a progress nudge from the submitter thread @@ -95,6 +100,9 @@ func SubmitLoopInner( case <-ticker.C: case <-submitter.C: } + if frozen() { + return nil + } pending := pendingBytes.Load() types.RollappPendingSubmissionsSkewBytes.Set(float64(pendingBytes.Load())) types.RollappPendingSubmissionsSkewBlocks.Set(float64(unsubmittedBlocks())) diff --git a/block/submit_loop_test.go b/block/submit_loop_test.go index 403adda52..347e0b268 100644 --- a/block/submit_loop_test.go +++ b/block/submit_loop_test.go @@ -113,8 +113,10 @@ func testSubmitLoopInner( accumulatedBlocks := func() uint64 { return pendingBlocks.Load() } - - block.SubmitLoopInner(ctx, log.NewNopLogger(), producedBytesC, args.batchSkew, accumulatedBlocks, args.maxTime, args.batchBytes, submitBatch) + frozen := func() bool { + return false + } + block.SubmitLoopInner(ctx, log.NewNopLogger(), producedBytesC, args.batchSkew, accumulatedBlocks, args.maxTime, args.batchBytes, submitBatch, frozen) } // Make sure the producer does not get too far ahead From 88df4b12330334dd26e742acce7d555a8115f191 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sun, 10 Nov 2024 12:18:46 +0100 Subject: [PATCH 036/119] race cond fix --- .golangci.yml | 3 --- block/fork.go | 2 +- block/manager.go | 8 +++----- block/produce.go | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 447ce4906..3fec4d490 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -72,6 +72,3 @@ linters-settings: disabled: true errcheck: check-type-assertions: true - gosec: - settings: - exclude: "G115" diff --git a/block/fork.go b/block/fork.go index 452568b8a..b334dc66e 100644 --- a/block/fork.go +++ b/block/fork.go @@ -37,7 +37,7 @@ func (m *Manager) MonitorForkUpdateLoop(ctx context.Context) error { if err := m.checkForkUpdate(ctx); err != nil { continue } - if m.frozen { + if m.isFrozen() { return nil } } diff --git a/block/manager.go b/block/manager.go index 35e1d7b61..7abbe77be 100644 --- a/block/manager.go +++ b/block/manager.go @@ -118,7 +118,7 @@ type Manager struct { SettlementValidator *SettlementValidator // frozen indicates if the node is frozen due to unhealthy event. used to stop block production. - frozen bool + frozen atomic.Bool } // NewManager creates new block Manager. @@ -176,10 +176,8 @@ func NewManager( settlementSyncingC: make(chan struct{}, 1), // use of buffered channel to avoid blocking. In case channel is full, its skipped because there is an ongoing syncing process, but syncing height is updated, which means the ongoing syncing will sync to the new height. settlementValidationC: make(chan struct{}, 1), // use of buffered channel to avoid blocking. In case channel is full, its skipped because there is an ongoing validation process, but validation height is updated, which means the ongoing validation will validate to the new height. syncedFromSettlement: uchannel.NewNudger(), // used by the sequencer to wait till the node completes the syncing from settlement. - frozen: false, } m.setFraudHandler(NewFreezeHandler(m)) - err = m.LoadStateOnInit(store, genesis, logger) if err != nil { return nil, fmt.Errorf("get initial state: %w", err) @@ -403,7 +401,7 @@ func (m *Manager) setFraudHandler(handler *FreezeHandler) { // freezeNode sets the node as unhealthy and prevents the node continues producing and processing blocks func (m *Manager) freezeNode(ctx context.Context, err error) { m.logger.Info("Freezing node", "err", err) - m.frozen = true + m.frozen.Store(true) uevent.MustPublish(ctx, m.Pubsub, &events.DataHealthStatus{Error: err}, events.HealthStatusList) if m.RunMode == RunModeFullNode { m.unsubscribeFullNodeEvents(ctx) @@ -412,5 +410,5 @@ func (m *Manager) freezeNode(ctx context.Context, err error) { // isFrozen returns whether the node is in frozen state func (m *Manager) isFrozen() bool { - return m.frozen + return m.frozen.Load() } diff --git a/block/produce.go b/block/produce.go index ff4f02e93..932c8f1c4 100644 --- a/block/produce.go +++ b/block/produce.go @@ -46,7 +46,7 @@ func (m *Manager) ProduceBlockLoop(ctx context.Context, bytesProducedC chan int) } // finish the block production loop in case the node is frozen - if m.frozen { + if m.isFrozen() { return nil } From 2f307c4c5d6c8e0ed2723c28b7d93d7e03487d12 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sun, 10 Nov 2024 12:26:39 +0100 Subject: [PATCH 037/119] fix --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 3fec4d490..53f3833d1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -71,4 +71,4 @@ linters-settings: severity: warning disabled: true errcheck: - check-type-assertions: true + check-type-assertions: true \ No newline at end of file From cf213d9603f741a51c31879b65db26f2b8673ecc Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sun, 10 Nov 2024 12:57:12 +0100 Subject: [PATCH 038/119] revision start height changes --- block/fork.go | 13 +++- block/manager.go | 1 + block/state.go | 5 +- proto/types/dymint/state.proto | 2 + types/pb/dymint/state.pb.go | 129 +++++++++++++++++++++------------ types/serialization.go | 23 +++--- types/state.go | 4 +- types/validation.go | 7 +- 8 files changed, 120 insertions(+), 64 deletions(-) diff --git a/block/fork.go b/block/fork.go index b334dc66e..23d282cef 100644 --- a/block/fork.go +++ b/block/fork.go @@ -88,11 +88,20 @@ func (m *Manager) createInstruction(rollapp *types.Rollapp) error { // shouldStopNode determines if a rollapp node should be stopped based on revision criteria. // // This method checks two conditions to decide if a node should be stopped: -// 1. If the current state height is greater than or equal to the rollapp's revision start height +// 1. If the current state height is greater than or equal to the rollapp's revision start height, for fullnode, +// or whether the next state height is greater than or equal to the rollapp's revision start height for proposer. +// This differentiation is because in case no rollback is required, proposer still needs to stop just before the revision start height +// to enter the fork loop and upgrade. // 2. If the block's app version (equivalent to revision) is less than the rollapp's revision func (m *Manager) shouldStopNode(rollapp *types.Rollapp, block *types.Block) bool { + var stopHeight uint64 + if m.RunMode == RunModeProposer { + stopHeight = m.State.NextHeight() + } else { + stopHeight = m.State.Height() + } revision := block.Header.Version.App - if m.State.Height() >= rollapp.RevisionStartHeight && revision < rollapp.Revision { + if stopHeight >= rollapp.RevisionStartHeight && revision < rollapp.Revision { m.logger.Info( "Freezing node due to fork update", "local_block_height", diff --git a/block/manager.go b/block/manager.go index 7abbe77be..f4b6d96dd 100644 --- a/block/manager.go +++ b/block/manager.go @@ -218,6 +218,7 @@ func (m *Manager) Start(ctx context.Context) error { // Upgrade revision on state state := m.State state.Version.Consensus.App = instruction.Revision + state.VersionStartHeight = instruction.RevisionStartHeight m.State = state } diff --git a/block/state.go b/block/state.go index e1e850825..97d865635 100644 --- a/block/state.go +++ b/block/state.go @@ -57,9 +57,8 @@ func NewStateFromGenesis(genDoc *tmtypes.GenesisDoc) (*types.State, error) { } s := types.State{ - Version: InitStateVersion, - ChainID: genDoc.ChainID, - + Version: InitStateVersion, + ChainID: genDoc.ChainID, InitialHeight: uint64(genDoc.InitialHeight), ConsensusParams: *genDoc.ConsensusParams, } diff --git a/proto/types/dymint/state.proto b/proto/types/dymint/state.proto index 48f243594..adfd645ab 100755 --- a/proto/types/dymint/state.proto +++ b/proto/types/dymint/state.proto @@ -48,6 +48,8 @@ message State { // Proposer is a sequencer that acts as a proposer. Can be nil if no proposer is set. Sequencer proposer = 20; + + int64 version_start_height = 21; } //rollapp params defined in genesis and updated via gov proposal diff --git a/types/pb/dymint/state.pb.go b/types/pb/dymint/state.pb.go index 16f5b2548..7ebb84dad 100644 --- a/types/pb/dymint/state.pb.go +++ b/types/pb/dymint/state.pb.go @@ -46,7 +46,8 @@ type State struct { RollappParams RollappParams `protobuf:"bytes,18,opt,name=rollapp_params,json=rollappParams,proto3" json:"rollapp_params"` LastHeaderHash []byte `protobuf:"bytes,19,opt,name=last_header_hash,json=lastHeaderHash,proto3" json:"last_header_hash,omitempty"` // Proposer is a sequencer that acts as a proposer. Can be nil if no proposer is set. - Proposer *Sequencer `protobuf:"bytes,20,opt,name=proposer,proto3" json:"proposer,omitempty"` + Proposer *Sequencer `protobuf:"bytes,20,opt,name=proposer,proto3" json:"proposer,omitempty"` + VersionStartHeight int64 `protobuf:"varint,21,opt,name=version_start_height,json=versionStartHeight,proto3" json:"version_start_height,omitempty"` } func (m *State) Reset() { *m = State{} } @@ -188,6 +189,13 @@ func (m *State) GetProposer() *Sequencer { return nil } +func (m *State) GetVersionStartHeight() int64 { + if m != nil { + return m.VersionStartHeight + } + return 0 +} + //rollapp params defined in genesis and updated via gov proposal type RollappParams struct { //data availability type (e.g. celestia) used in the rollapp @@ -251,50 +259,52 @@ func init() { func init() { proto.RegisterFile("types/dymint/state.proto", fileDescriptor_4b679420add07272) } var fileDescriptor_4b679420add07272 = []byte{ - // 686 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0xd1, 0x4e, 0xdb, 0x3c, - 0x14, 0xc7, 0x9b, 0x12, 0xda, 0xd4, 0xa5, 0x6d, 0x30, 0x7c, 0x52, 0xe0, 0x93, 0xd2, 0xc2, 0xb4, - 0xa9, 0x9a, 0xb4, 0x54, 0x1a, 0x0f, 0xb0, 0x29, 0x70, 0x41, 0x2b, 0x2e, 0x26, 0x77, 0xe2, 0x62, - 0x37, 0x91, 0x9b, 0x78, 0x49, 0xb4, 0x34, 0xce, 0x6c, 0x17, 0x8d, 0x3d, 0x05, 0x8f, 0xc5, 0x25, - 0x97, 0xbb, 0x62, 0x53, 0xb9, 0xdd, 0x43, 0x4c, 0xb6, 0x93, 0xd2, 0xaa, 0xe2, 0x0a, 0xf2, 0x3f, - 0x3f, 0xff, 0x7d, 0xce, 0xf1, 0x39, 0x05, 0x8e, 0xb8, 0x2d, 0x08, 0x1f, 0x45, 0xb7, 0xf3, 0x34, - 0x17, 0x23, 0x2e, 0xb0, 0x20, 0x5e, 0xc1, 0xa8, 0xa0, 0xb0, 0xa1, 0x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, 0x3a, 0x97, 0x3b, 0x4e, 0x72, 0xc9, - 0xff, 0xb8, 0xfd, 0x59, 0xed, 0x7d, 0xf9, 0xe3, 0x31, 0x2b, 0xbf, 0x67, 0x0d, 0x35, 0xd8, 0x67, - 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x93, 0x2f, 0x96, 0x2f, 0x05, 0x00, 0x00, + // 708 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0xcd, 0x4e, 0xdb, 0x4c, + 0x14, 0x86, 0xe3, 0x60, 0x88, 0x33, 0x21, 0x89, 0x19, 0x40, 0x32, 0x7c, 0x92, 0x13, 0xf8, 0xd4, + 0x2a, 0xaa, 0x54, 0xa7, 0x2a, 0x17, 0xd0, 0xca, 0xb0, 0x20, 0x11, 0x8b, 0xca, 0xa9, 0x58, 0x74, + 0x63, 0x4d, 0xec, 0xa9, 0x6d, 0xd5, 0xf1, 0xb8, 0x33, 0x13, 0x54, 0x7a, 0x15, 0x5c, 0x41, 0xaf, + 0x87, 0x25, 0xcb, 0xae, 0x68, 0x15, 0x6e, 0xa4, 0x9a, 0x1f, 0x87, 0x44, 0x11, 0xab, 0xc4, 0xef, + 0x79, 0xfc, 0xce, 0xf9, 0x99, 0x63, 0xe0, 0xf0, 0xdb, 0x12, 0xb3, 0x61, 0x7c, 0x3b, 0xcb, 0x0a, + 0x3e, 0x64, 0x1c, 0x71, 0xec, 0x95, 0x94, 0x70, 0x02, 0x77, 0x94, 0x76, 0x7c, 0x90, 0x90, 0x84, + 0x48, 0x69, 0x28, 0xfe, 0xa9, 0xe8, 0x71, 0x2f, 0x21, 0x24, 0xc9, 0xf1, 0x50, 0x3e, 0x4d, 0xe7, + 0x5f, 0x87, 0x3c, 0x9b, 0x61, 0xc6, 0xd1, 0xac, 0xd4, 0xc0, 0x89, 0x32, 0xe6, 0xb8, 0x88, 0x31, + 0x95, 0xe6, 0x68, 0x1a, 0x65, 0x43, 0xa9, 0x6a, 0xe4, 0x74, 0x03, 0xd1, 0xc2, 0x0a, 0xf3, 0xfa, + 0x05, 0xe6, 0x06, 0xe5, 0x59, 0x8c, 0x38, 0xa1, 0x9a, 0xfb, 0xff, 0x05, 0xae, 0x44, 0x14, 0xcd, + 0x5e, 0x3e, 0x50, 0x16, 0xbc, 0x76, 0xe0, 0xd1, 0x5a, 0x43, 0xd4, 0x8f, 0x0a, 0x9d, 0xfe, 0x6a, + 0x80, 0xed, 0x89, 0x78, 0x01, 0x9e, 0x81, 0xc6, 0x0d, 0xa6, 0x2c, 0x23, 0x85, 0x63, 0xf4, 0x8d, + 0x41, 0xeb, 0xfd, 0x91, 0xf7, 0x6c, 0xea, 0xa9, 0x2e, 0x5e, 0x2b, 0x20, 0xa8, 0x48, 0x78, 0x04, + 0xac, 0x28, 0x45, 0x59, 0x11, 0x66, 0xb1, 0x53, 0xef, 0x1b, 0x83, 0x66, 0xd0, 0x90, 0xcf, 0xa3, + 0x18, 0xbe, 0x02, 0x9d, 0xac, 0xc8, 0x78, 0x86, 0xf2, 0x30, 0xc5, 0x59, 0x92, 0x72, 0x67, 0xab, + 0x6f, 0x0c, 0xb6, 0x82, 0xb6, 0x56, 0x2f, 0xa5, 0x08, 0xdf, 0x80, 0xbd, 0x1c, 0x31, 0x1e, 0x4e, + 0x73, 0x12, 0x7d, 0xab, 0x48, 0x53, 0x92, 0x5d, 0x11, 0xf0, 0x85, 0xae, 0xd9, 0x00, 0xb4, 0x57, + 0xd8, 0x2c, 0x76, 0xb6, 0x37, 0x13, 0x55, 0x75, 0xcb, 0xb7, 0x46, 0x17, 0xfe, 0xfe, 0xfd, 0x63, + 0xaf, 0xb6, 0x78, 0xec, 0xb5, 0xae, 0x2a, 0xab, 0xd1, 0x45, 0xd0, 0x5a, 0xfa, 0x8e, 0x62, 0x78, + 0x05, 0xba, 0x2b, 0x9e, 0x62, 0xe2, 0xce, 0x8e, 0x74, 0x3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0x00, 0x00, 0x00, 0xff, 0xff, 0x2b, 0xf4, 0x1c, 0xe7, + 0x61, 0x05, 0x00, 0x00, } func (m *State) Marshal() (dAtA []byte, err error) { @@ -317,6 +327,13 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.VersionStartHeight != 0 { + i = encodeVarintState(dAtA, i, uint64(m.VersionStartHeight)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa8 + } if m.Proposer != nil { { size, err := m.Proposer.MarshalToSizedBuffer(dAtA[:i]) @@ -550,6 +567,9 @@ func (m *State) Size() (n int) { l = m.Proposer.Size() n += 2 + l + sovState(uint64(l)) } + if m.VersionStartHeight != 0 { + n += 2 + sovState(uint64(m.VersionStartHeight)) + } return n } @@ -1054,6 +1074,25 @@ func (m *State) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 21: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VersionStartHeight", wireType) + } + m.VersionStartHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VersionStartHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipState(dAtA[iNdEx:]) diff --git a/types/serialization.go b/types/serialization.go index 43bca0d87..1ae6baa9b 100644 --- a/types/serialization.go +++ b/types/serialization.go @@ -261,16 +261,17 @@ func (s *State) ToProto() (*pb.State, error) { } return &pb.State{ - Version: &s.Version, - ChainId: s.ChainID, - InitialHeight: int64(s.InitialHeight), - LastBlockHeight: int64(s.Height()), - ConsensusParams: s.ConsensusParams, - LastResultsHash: s.LastResultsHash[:], - LastHeaderHash: s.LastHeaderHash[:], - AppHash: s.AppHash[:], - RollappParams: s.RollappParams, - Proposer: proposerProto, + Version: &s.Version, + ChainId: s.ChainID, + InitialHeight: int64(s.InitialHeight), + LastBlockHeight: int64(s.Height()), + ConsensusParams: s.ConsensusParams, + LastResultsHash: s.LastResultsHash[:], + LastHeaderHash: s.LastHeaderHash[:], + AppHash: s.AppHash[:], + RollappParams: s.RollappParams, + Proposer: proposerProto, + VersionStartHeight: int64(s.VersionStartHeight), }, nil } @@ -280,7 +281,7 @@ func (s *State) FromProto(other *pb.State) error { s.ChainID = other.ChainId s.InitialHeight = uint64(other.InitialHeight) s.SetHeight(uint64(other.LastBlockHeight)) - + s.VersionStartHeight = uint64(other.VersionStartHeight) if other.Proposer != nil { proposer, err := SequencerFromProto(other.Proposer) if err != nil { diff --git a/types/state.go b/types/state.go index 529cccaa0..8db1efdb0 100644 --- a/types/state.go +++ b/types/state.go @@ -16,8 +16,8 @@ import ( // State contains information about current state of the blockchain. type State struct { - Version tmstate.Version - + Version tmstate.Version + VersionStartHeight uint64 // immutable ChainID string InitialHeight uint64 // should be 1, not 0, when starting from height 1 diff --git a/types/validation.go b/types/validation.go index 0d0c7a1ed..c766af4a5 100644 --- a/types/validation.go +++ b/types/validation.go @@ -67,7 +67,12 @@ func (b *Block) ValidateWithState(state *State) error { return NewErrTimeFraud(b, currentTime) } - if b.Header.Version.App != state.Version.Consensus.App || + appVersion := state.Version.Consensus.App + if b.Header.Height < state.VersionStartHeight { + appVersion-- + } + + if b.Header.Version.App != appVersion || b.Header.Version.Block != state.Version.Consensus.Block { return ErrVersionMismatch } From e63d30b1a54f4605062c53353d97edf23f96c273 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sun, 10 Nov 2024 14:32:32 +0100 Subject: [PATCH 039/119] obsolete drs query --- go.mod | 4 +- settlement/dymension/dymension.go | 29 + settlement/grpc/grpc.go | 5 + settlement/local/local.go | 5 + settlement/settlement.go | 2 + .../dymension/rollapp/query.pb.go | 933 ++++++++++++++++-- .../dymension/rollapp/query.pb.gw.go | 186 +++- 7 files changed, 1087 insertions(+), 77 deletions(-) diff --git a/go.mod b/go.mod index 22d77275e..09eb6eb23 100644 --- a/go.mod +++ b/go.mod @@ -77,7 +77,7 @@ require ( github.com/cometbft/cometbft v0.37.2 github.com/cometbft/cometbft-db v0.11.0 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/gogoproto v1.5.0 // indirect + github.com/cosmos/gogoproto v1.5.0 github.com/creachadair/taskgroup v0.3.2 // indirect github.com/deckarep/golang-set v1.8.0 // indirect github.com/decred/base58 v1.0.4 // indirect @@ -120,7 +120,7 @@ require ( go.uber.org/fx v1.20.1 // indirect golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect sigs.k8s.io/yaml v1.4.0 // indirect diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index 5dc5c38bf..be28bb43b 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -589,6 +589,35 @@ func (c *Client) GetRollapp() (*types.Rollapp, error) { }, nil } +// GetObsoleteDrs returns the list of deprecated DRS. +func (c *Client) GetObsoleteDrs() ([]uint32, error) { + + var res *rollapptypes.QueryObsoleteDRSVersionsResponse + req := &rollapptypes.QueryObsoleteDRSVersionsRequest{} + + err := c.RunWithRetry(func() error { + var err error + res, err = c.cosmosClient.GetRollappClient().ObsoleteDRSVersions(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 nil, fmt.Errorf("get rollapp: %w", err) + } + + // not supposed to happen, but just in case + if res == nil { + return nil, fmt.Errorf("empty response: %w", gerrc.ErrUnknown) + } + + return res.DrsVersions, nil +} + func (c *Client) broadcastBatch(msgUpdateState *rollapptypes.MsgUpdateState) error { txResp, err := c.cosmosClient.BroadcastTx(c.config.DymAccountName, msgUpdateState) if err != nil { diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index d2514a77f..e74d8bde9 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -56,6 +56,11 @@ func (c *Client) GetRollapp() (*types.Rollapp, error) { panic("implement me") } +// GetObsoleteDrs returns the list of deprecated DRS. +func (c *Client) GetObsoleteDrs() ([]uint32, error) { + panic("GetObsoleteDrs not implemented in local SL") +} + var _ settlement.ClientI = (*Client)(nil) // Init initializes the mock layer client. diff --git a/settlement/local/local.go b/settlement/local/local.go index 1a488205f..f393da644 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -244,6 +244,11 @@ func (c *Client) GetAllSequencers() ([]types.Sequencer, error) { return c.GetBondedSequencers() } +// GetObsoleteDrs returns the list of deprecated DRS. +func (c *Client) GetObsoleteDrs() ([]uint32, error) { + panic("GetObsoleteDrs not implemented in local SL") +} + // GetBondedSequencers implements settlement.ClientI. func (c *Client) GetBondedSequencers() ([]types.Sequencer, error) { proposer, err := c.GetProposerAtHeight(-1) diff --git a/settlement/settlement.go b/settlement/settlement.go index ae94bc925..bcbb8a620 100644 --- a/settlement/settlement.go +++ b/settlement/settlement.go @@ -97,4 +97,6 @@ type ClientI interface { CheckRotationInProgress() (*types.Sequencer, error) // GetRollapp returns the rollapp information. GetRollapp() (*types.Rollapp, error) + // GetObsoleteDrs returns the list of deprecated DRS. + GetObsoleteDrs() ([]uint32, error) } diff --git a/types/pb/dymensionxyz/dymension/rollapp/query.pb.go b/types/pb/dymensionxyz/dymension/rollapp/query.pb.go index ef6c13d40..29f21ace4 100644 --- a/types/pb/dymensionxyz/dymension/rollapp/query.pb.go +++ b/types/pb/dymensionxyz/dymension/rollapp/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: types/dymensionxyz/dymension/rollapp/query.proto +// source: dymensionxyz/dymension/rollapp/query.proto package rollapp @@ -7,9 +7,10 @@ import ( context "context" fmt "fmt" query "github.com/cosmos/cosmos-sdk/types/query" - _ "github.com/gogo/protobuf/gogoproto" - grpc1 "github.com/gogo/protobuf/grpc" - proto "github.com/gogo/protobuf/proto" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -37,7 +38,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_20818724c4f98326, []int{0} + return fileDescriptor_00a0238fb38306fa, []int{0} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -76,7 +77,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20818724c4f98326, []int{1} + return fileDescriptor_00a0238fb38306fa, []int{1} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -122,7 +123,7 @@ func (m *QueryGetRollappRequest) Reset() { *m = QueryGetRollappRequest{} func (m *QueryGetRollappRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetRollappRequest) ProtoMessage() {} func (*QueryGetRollappRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_20818724c4f98326, []int{2} + return fileDescriptor_00a0238fb38306fa, []int{2} } func (m *QueryGetRollappRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -175,7 +176,7 @@ func (m *QueryGetRollappByEIP155Request) Reset() { *m = QueryGetRollappB func (m *QueryGetRollappByEIP155Request) String() string { return proto.CompactTextString(m) } func (*QueryGetRollappByEIP155Request) ProtoMessage() {} func (*QueryGetRollappByEIP155Request) Descriptor() ([]byte, []int) { - return fileDescriptor_20818724c4f98326, []int{3} + return fileDescriptor_00a0238fb38306fa, []int{3} } func (m *QueryGetRollappByEIP155Request) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -227,7 +228,7 @@ func (m *QueryGetLatestHeightRequest) Reset() { *m = QueryGetLatestHeigh func (m *QueryGetLatestHeightRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetLatestHeightRequest) ProtoMessage() {} func (*QueryGetLatestHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_20818724c4f98326, []int{4} + return fileDescriptor_00a0238fb38306fa, []int{4} } func (m *QueryGetLatestHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -278,7 +279,7 @@ func (m *QueryGetLatestHeightResponse) Reset() { *m = QueryGetLatestHeig func (m *QueryGetLatestHeightResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetLatestHeightResponse) ProtoMessage() {} func (*QueryGetLatestHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20818724c4f98326, []int{5} + return fileDescriptor_00a0238fb38306fa, []int{5} } func (m *QueryGetLatestHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -323,7 +324,7 @@ func (m *QueryGetLatestStateIndexRequest) Reset() { *m = QueryGetLatestS func (m *QueryGetLatestStateIndexRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetLatestStateIndexRequest) ProtoMessage() {} func (*QueryGetLatestStateIndexRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_20818724c4f98326, []int{6} + return fileDescriptor_00a0238fb38306fa, []int{6} } func (m *QueryGetLatestStateIndexRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -374,7 +375,7 @@ func (m *QueryGetLatestStateIndexResponse) Reset() { *m = QueryGetLatest func (m *QueryGetLatestStateIndexResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetLatestStateIndexResponse) ProtoMessage() {} func (*QueryGetLatestStateIndexResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20818724c4f98326, []int{7} + return fileDescriptor_00a0238fb38306fa, []int{7} } func (m *QueryGetLatestStateIndexResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -421,7 +422,7 @@ func (m *QueryGetRollappResponse) Reset() { *m = QueryGetRollappResponse func (m *QueryGetRollappResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetRollappResponse) ProtoMessage() {} func (*QueryGetRollappResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20818724c4f98326, []int{8} + return fileDescriptor_00a0238fb38306fa, []int{8} } func (m *QueryGetRollappResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -481,7 +482,7 @@ func (m *QueryAllRollappRequest) Reset() { *m = QueryAllRollappRequest{} func (m *QueryAllRollappRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllRollappRequest) ProtoMessage() {} func (*QueryAllRollappRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_20818724c4f98326, []int{9} + return fileDescriptor_00a0238fb38306fa, []int{9} } func (m *QueryAllRollappRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -533,7 +534,7 @@ func (m *QueryAllRollappResponse) Reset() { *m = QueryAllRollappResponse func (m *QueryAllRollappResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllRollappResponse) ProtoMessage() {} func (*QueryAllRollappResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20818724c4f98326, []int{10} + return fileDescriptor_00a0238fb38306fa, []int{10} } func (m *QueryAllRollappResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -587,7 +588,7 @@ func (m *QueryGetStateInfoRequest) Reset() { *m = QueryGetStateInfoReque func (m *QueryGetStateInfoRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetStateInfoRequest) ProtoMessage() {} func (*QueryGetStateInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_20818724c4f98326, []int{11} + return fileDescriptor_00a0238fb38306fa, []int{11} } func (m *QueryGetStateInfoRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -652,7 +653,7 @@ func (m *QueryGetStateInfoResponse) Reset() { *m = QueryGetStateInfoResp func (m *QueryGetStateInfoResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetStateInfoResponse) ProtoMessage() {} func (*QueryGetStateInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20818724c4f98326, []int{12} + return fileDescriptor_00a0238fb38306fa, []int{12} } func (m *QueryGetStateInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -688,6 +689,174 @@ func (m *QueryGetStateInfoResponse) GetStateInfo() StateInfo { return StateInfo{} } +type QueryRegisteredDenomsRequest struct { + RollappId string `protobuf:"bytes,1,opt,name=rollappId,proto3" json:"rollappId,omitempty"` +} + +func (m *QueryRegisteredDenomsRequest) Reset() { *m = QueryRegisteredDenomsRequest{} } +func (m *QueryRegisteredDenomsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRegisteredDenomsRequest) ProtoMessage() {} +func (*QueryRegisteredDenomsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_00a0238fb38306fa, []int{13} +} +func (m *QueryRegisteredDenomsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRegisteredDenomsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRegisteredDenomsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryRegisteredDenomsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRegisteredDenomsRequest.Merge(m, src) +} +func (m *QueryRegisteredDenomsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRegisteredDenomsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRegisteredDenomsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRegisteredDenomsRequest proto.InternalMessageInfo + +func (m *QueryRegisteredDenomsRequest) GetRollappId() string { + if m != nil { + return m.RollappId + } + return "" +} + +type QueryRegisteredDenomsResponse struct { + Denoms []string `protobuf:"bytes,1,rep,name=denoms,proto3" json:"denoms,omitempty"` +} + +func (m *QueryRegisteredDenomsResponse) Reset() { *m = QueryRegisteredDenomsResponse{} } +func (m *QueryRegisteredDenomsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRegisteredDenomsResponse) ProtoMessage() {} +func (*QueryRegisteredDenomsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_00a0238fb38306fa, []int{14} +} +func (m *QueryRegisteredDenomsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRegisteredDenomsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRegisteredDenomsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryRegisteredDenomsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRegisteredDenomsResponse.Merge(m, src) +} +func (m *QueryRegisteredDenomsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRegisteredDenomsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRegisteredDenomsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRegisteredDenomsResponse proto.InternalMessageInfo + +func (m *QueryRegisteredDenomsResponse) GetDenoms() []string { + if m != nil { + return m.Denoms + } + return nil +} + +type QueryObsoleteDRSVersionsRequest struct { +} + +func (m *QueryObsoleteDRSVersionsRequest) Reset() { *m = QueryObsoleteDRSVersionsRequest{} } +func (m *QueryObsoleteDRSVersionsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryObsoleteDRSVersionsRequest) ProtoMessage() {} +func (*QueryObsoleteDRSVersionsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_00a0238fb38306fa, []int{15} +} +func (m *QueryObsoleteDRSVersionsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryObsoleteDRSVersionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryObsoleteDRSVersionsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryObsoleteDRSVersionsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryObsoleteDRSVersionsRequest.Merge(m, src) +} +func (m *QueryObsoleteDRSVersionsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryObsoleteDRSVersionsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryObsoleteDRSVersionsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryObsoleteDRSVersionsRequest proto.InternalMessageInfo + +type QueryObsoleteDRSVersionsResponse struct { + DrsVersions []uint32 `protobuf:"varint,1,rep,packed,name=drs_versions,json=drsVersions,proto3" json:"drs_versions,omitempty"` +} + +func (m *QueryObsoleteDRSVersionsResponse) Reset() { *m = QueryObsoleteDRSVersionsResponse{} } +func (m *QueryObsoleteDRSVersionsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryObsoleteDRSVersionsResponse) ProtoMessage() {} +func (*QueryObsoleteDRSVersionsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_00a0238fb38306fa, []int{16} +} +func (m *QueryObsoleteDRSVersionsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryObsoleteDRSVersionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryObsoleteDRSVersionsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryObsoleteDRSVersionsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryObsoleteDRSVersionsResponse.Merge(m, src) +} +func (m *QueryObsoleteDRSVersionsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryObsoleteDRSVersionsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryObsoleteDRSVersionsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryObsoleteDRSVersionsResponse proto.InternalMessageInfo + +func (m *QueryObsoleteDRSVersionsResponse) GetDrsVersions() []uint32 { + if m != nil { + return m.DrsVersions + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "dymensionxyz.dymension.rollapp.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "dymensionxyz.dymension.rollapp.QueryParamsResponse") @@ -702,65 +871,86 @@ func init() { proto.RegisterType((*QueryAllRollappResponse)(nil), "dymensionxyz.dymension.rollapp.QueryAllRollappResponse") proto.RegisterType((*QueryGetStateInfoRequest)(nil), "dymensionxyz.dymension.rollapp.QueryGetStateInfoRequest") proto.RegisterType((*QueryGetStateInfoResponse)(nil), "dymensionxyz.dymension.rollapp.QueryGetStateInfoResponse") + proto.RegisterType((*QueryRegisteredDenomsRequest)(nil), "dymensionxyz.dymension.rollapp.QueryRegisteredDenomsRequest") + proto.RegisterType((*QueryRegisteredDenomsResponse)(nil), "dymensionxyz.dymension.rollapp.QueryRegisteredDenomsResponse") + proto.RegisterType((*QueryObsoleteDRSVersionsRequest)(nil), "dymensionxyz.dymension.rollapp.QueryObsoleteDRSVersionsRequest") + proto.RegisterType((*QueryObsoleteDRSVersionsResponse)(nil), "dymensionxyz.dymension.rollapp.QueryObsoleteDRSVersionsResponse") } func init() { - proto.RegisterFile("types/dymensionxyz/dymension/rollapp/query.proto", fileDescriptor_20818724c4f98326) -} - -var fileDescriptor_20818724c4f98326 = []byte{ - // 809 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4b, 0x4f, 0x13, 0x51, - 0x14, 0xee, 0x94, 0xd2, 0xc7, 0xc1, 0x44, 0x72, 0x25, 0x58, 0x0b, 0x19, 0x9a, 0x31, 0x51, 0xdc, - 0xcc, 0xd8, 0x92, 0xa2, 0xc6, 0x67, 0x89, 0x82, 0x10, 0x35, 0x38, 0x68, 0x8c, 0x1a, 0x83, 0x53, - 0x7a, 0x29, 0x63, 0x3a, 0x0f, 0x7a, 0xa7, 0x86, 0x12, 0x8d, 0x89, 0x71, 0xa7, 0x0b, 0x77, 0xfe, - 0x14, 0xd7, 0xee, 0x58, 0xb2, 0x74, 0x65, 0x0c, 0xfc, 0x08, 0xb7, 0xa6, 0x73, 0xcf, 0x4c, 0xa7, - 0x53, 0xa0, 0xd3, 0xea, 0xaa, 0xbd, 0x27, 0xf3, 0x7d, 0xe7, 0x3b, 0xcf, 0x7b, 0xe1, 0xb2, 0xd3, - 0xb2, 0x29, 0x53, 0xaa, 0x2d, 0x83, 0x9a, 0x4c, 0xb7, 0xcc, 0x9d, 0xd6, 0x6e, 0xe7, 0xa0, 0x34, - 0xac, 0x7a, 0x5d, 0xb3, 0x6d, 0x65, 0xbb, 0x49, 0x1b, 0x2d, 0xd9, 0x6e, 0x58, 0x8e, 0x45, 0xc4, - 0xe0, 0xb7, 0xb2, 0x7f, 0x90, 0xf1, 0xdb, 0xdc, 0x44, 0xcd, 0xaa, 0x59, 0xee, 0xa7, 0x4a, 0xfb, - 0x1f, 0x47, 0xe5, 0xd0, 0xcf, 0x86, 0xc5, 0x0c, 0x8b, 0x29, 0x15, 0x8d, 0x51, 0x4e, 0xaa, 0xbc, -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0x04, 0x18, 0x0f, 0xdf, 0x1e, 0xe4, 0xf6, 0x60, 0xa4, 0x3d, 0xd7, 0x5a, 0xee, - 0xce, 0xf0, 0x04, 0xbe, 0xb2, 0x8f, 0x02, 0x64, 0xfc, 0x99, 0x22, 0x57, 0xa3, 0x32, 0x86, 0x57, - 0x4a, 0xee, 0xda, 0x10, 0x48, 0x4f, 0xc4, 0xc2, 0xeb, 0xbd, 0x03, 0x51, 0xd8, 0x3f, 0x10, 0x85, - 0xdf, 0x07, 0xa2, 0xf0, 0xf5, 0x50, 0x8c, 0xed, 0x1f, 0x8a, 0xb1, 0x9f, 0x87, 0x62, 0xec, 0xc5, - 0x62, 0x4d, 0x77, 0xb6, 0x9a, 0x15, 0x79, 0xc3, 0x32, 0x7a, 0xde, 0x70, 0xba, 0xe9, 0x28, 0xfc, - 0x75, 0x67, 0x57, 0xfa, 0x3c, 0xf0, 0x2a, 0x49, 0xf7, 0x75, 0x37, 0xf7, 0x37, 0x00, 0x00, 0xff, - 0xff, 0x3d, 0x13, 0xc0, 0xe4, 0x47, 0x0b, 0x00, 0x00, + proto.RegisterFile("dymensionxyz/dymension/rollapp/query.proto", fileDescriptor_00a0238fb38306fa) +} + +var fileDescriptor_00a0238fb38306fa = []byte{ + // 1078 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0x38, 0xae, 0x13, 0xbf, 0xb4, 0x22, 0x9a, 0x46, 0x21, 0xb8, 0xc1, 0x75, 0x17, 0xa9, + 0x75, 0x0b, 0xda, 0x95, 0x63, 0xdc, 0x10, 0xa5, 0x29, 0x75, 0x94, 0x36, 0xa4, 0x82, 0x12, 0x36, + 0xfc, 0x11, 0x20, 0x64, 0xad, 0xeb, 0x89, 0xb3, 0x68, 0xbd, 0xbb, 0xf5, 0x6c, 0x22, 0xbb, 0x51, + 0x2e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0xca, 0x8a, 0xb4, 0x10, 0x59, 0x3c, 0x01, + 0x42, 0x45, 0xce, 0x23, 0xfa, 0x1b, 0x81, 0xab, 0x03, 0x06, 0x4d, 0xcc, 0xd4, 0x1b, 0x3e, 0xc5, + 0x62, 0xa6, 0xde, 0x88, 0x19, 0xa7, 0x6c, 0x08, 0x55, 0xab, 0xb4, 0x14, 0xa5, 0xca, 0x41, 0x90, + 0x4a, 0x78, 0x24, 0x6e, 0x3e, 0x39, 0x3d, 0xcb, 0x92, 0x17, 0x67, 0x59, 0xf2, 0xd7, 0x59, 0x96, + 0x7c, 0x73, 0x9e, 0x9d, 0x7a, 0x71, 0x9e, 0x9d, 0xfa, 0xfd, 0x3c, 0x3b, 0xf5, 0xd9, 0x9b, 0x75, + 0xd3, 0x3b, 0x38, 0xac, 0xaa, 0x4f, 0x9d, 0xc6, 0x30, 0xe8, 0xa3, 0xa2, 0xd6, 0x0a, 0xf0, 0xbd, + 0xb6, 0xcb, 0x78, 0x35, 0x25, 0x3e, 0xf9, 0x8a, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xce, + 0xc4, 0xdb, 0x56, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -789,6 +979,10 @@ type QueryClient interface { LatestStateIndex(ctx context.Context, in *QueryGetLatestStateIndexRequest, opts ...grpc.CallOption) (*QueryGetLatestStateIndexResponse, error) // Queries a StateInfo by index. StateInfo(ctx context.Context, in *QueryGetStateInfoRequest, opts ...grpc.CallOption) (*QueryGetStateInfoResponse, error) + // Queries a list of registered denoms for the rollapp. + RegisteredDenoms(ctx context.Context, in *QueryRegisteredDenomsRequest, opts ...grpc.CallOption) (*QueryRegisteredDenomsResponse, error) + // Queries a list of obsolete DRS versions. + ObsoleteDRSVersions(ctx context.Context, in *QueryObsoleteDRSVersionsRequest, opts ...grpc.CallOption) (*QueryObsoleteDRSVersionsResponse, error) } type queryClient struct { @@ -862,6 +1056,24 @@ func (c *queryClient) StateInfo(ctx context.Context, in *QueryGetStateInfoReques return out, nil } +func (c *queryClient) RegisteredDenoms(ctx context.Context, in *QueryRegisteredDenomsRequest, opts ...grpc.CallOption) (*QueryRegisteredDenomsResponse, error) { + out := new(QueryRegisteredDenomsResponse) + err := c.cc.Invoke(ctx, "/dymensionxyz.dymension.rollapp.Query/RegisteredDenoms", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ObsoleteDRSVersions(ctx context.Context, in *QueryObsoleteDRSVersionsRequest, opts ...grpc.CallOption) (*QueryObsoleteDRSVersionsResponse, error) { + out := new(QueryObsoleteDRSVersionsResponse) + err := c.cc.Invoke(ctx, "/dymensionxyz.dymension.rollapp.Query/ObsoleteDRSVersions", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -878,6 +1090,10 @@ type QueryServer interface { LatestStateIndex(context.Context, *QueryGetLatestStateIndexRequest) (*QueryGetLatestStateIndexResponse, error) // Queries a StateInfo by index. StateInfo(context.Context, *QueryGetStateInfoRequest) (*QueryGetStateInfoResponse, error) + // Queries a list of registered denoms for the rollapp. + RegisteredDenoms(context.Context, *QueryRegisteredDenomsRequest) (*QueryRegisteredDenomsResponse, error) + // Queries a list of obsolete DRS versions. + ObsoleteDRSVersions(context.Context, *QueryObsoleteDRSVersionsRequest) (*QueryObsoleteDRSVersionsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -905,6 +1121,12 @@ func (*UnimplementedQueryServer) LatestStateIndex(ctx context.Context, req *Quer func (*UnimplementedQueryServer) StateInfo(ctx context.Context, req *QueryGetStateInfoRequest) (*QueryGetStateInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method StateInfo not implemented") } +func (*UnimplementedQueryServer) RegisteredDenoms(ctx context.Context, req *QueryRegisteredDenomsRequest) (*QueryRegisteredDenomsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisteredDenoms not implemented") +} +func (*UnimplementedQueryServer) ObsoleteDRSVersions(ctx context.Context, req *QueryObsoleteDRSVersionsRequest) (*QueryObsoleteDRSVersionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ObsoleteDRSVersions not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1036,6 +1258,42 @@ func _Query_StateInfo_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _Query_RegisteredDenoms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRegisteredDenomsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RegisteredDenoms(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dymensionxyz.dymension.rollapp.Query/RegisteredDenoms", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RegisteredDenoms(ctx, req.(*QueryRegisteredDenomsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ObsoleteDRSVersions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryObsoleteDRSVersionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ObsoleteDRSVersions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dymensionxyz.dymension.rollapp.Query/ObsoleteDRSVersions", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ObsoleteDRSVersions(ctx, req.(*QueryObsoleteDRSVersionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "dymensionxyz.dymension.rollapp.Query", HandlerType: (*QueryServer)(nil), @@ -1068,9 +1326,17 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "StateInfo", Handler: _Query_StateInfo_Handler, }, + { + MethodName: "RegisteredDenoms", + Handler: _Query_RegisteredDenoms_Handler, + }, + { + MethodName: "ObsoleteDRSVersions", + Handler: _Query_ObsoleteDRSVersions_Handler, + }, }, Streams: []grpc.StreamDesc{}, - Metadata: "types/dymensionxyz/dymension/rollapp/query.proto", + Metadata: "dymensionxyz/dymension/rollapp/query.proto", } func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { @@ -1582,6 +1848,132 @@ func (m *QueryGetStateInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } +func (m *QueryRegisteredDenomsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryRegisteredDenomsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRegisteredDenomsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RollappId) > 0 { + i -= len(m.RollappId) + copy(dAtA[i:], m.RollappId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.RollappId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryRegisteredDenomsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryRegisteredDenomsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRegisteredDenomsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denoms) > 0 { + for iNdEx := len(m.Denoms) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Denoms[iNdEx]) + copy(dAtA[i:], m.Denoms[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denoms[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryObsoleteDRSVersionsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryObsoleteDRSVersionsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryObsoleteDRSVersionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryObsoleteDRSVersionsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryObsoleteDRSVersionsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryObsoleteDRSVersionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DrsVersions) > 0 { + dAtA9 := make([]byte, len(m.DrsVersions)*10) + var j8 int + for _, num := range m.DrsVersions { + for num >= 1<<7 { + dAtA9[j8] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j8++ + } + dAtA9[j8] = uint8(num) + j8++ + } + i -= j8 + copy(dAtA[i:], dAtA9[:j8]) + i = encodeVarintQuery(dAtA, i, uint64(j8)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1786,6 +2178,59 @@ func (m *QueryGetStateInfoResponse) Size() (n int) { return n } +func (m *QueryRegisteredDenomsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RollappId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryRegisteredDenomsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Denoms) > 0 { + for _, s := range m.Denoms { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryObsoleteDRSVersionsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryObsoleteDRSVersionsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.DrsVersions) > 0 { + l = 0 + for _, e := range m.DrsVersions { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3071,6 +3516,346 @@ func (m *QueryGetStateInfoResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryRegisteredDenomsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryRegisteredDenomsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRegisteredDenomsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RollappId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RollappId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRegisteredDenomsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryRegisteredDenomsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRegisteredDenomsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denoms", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denoms = append(m.Denoms, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryObsoleteDRSVersionsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryObsoleteDRSVersionsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryObsoleteDRSVersionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryObsoleteDRSVersionsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryObsoleteDRSVersionsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryObsoleteDRSVersionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.DrsVersions = append(m.DrsVersions, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.DrsVersions) == 0 { + m.DrsVersions = make([]uint32, 0, elementCount) + } + for iNdEx < postIndex { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.DrsVersions = append(m.DrsVersions, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field DrsVersions", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/types/pb/dymensionxyz/dymension/rollapp/query.pb.gw.go b/types/pb/dymensionxyz/dymension/rollapp/query.pb.gw.go index 6157c9131..c6e4edd82 100644 --- a/types/pb/dymensionxyz/dymension/rollapp/query.pb.gw.go +++ b/types/pb/dymensionxyz/dymension/rollapp/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: dymension/rollapp/query.proto +// source: dymensionxyz/dymension/rollapp/query.proto /* Package types is a reverse proxy. @@ -51,6 +51,10 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +var ( + filter_Query_Rollapp_0 = &utilities.DoubleArray{Encoding: map[string]int{"rollappId": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + func request_Query_Rollapp_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryGetRollappRequest var metadata runtime.ServerMetadata @@ -73,6 +77,13 @@ func request_Query_Rollapp_0(ctx context.Context, marshaler runtime.Marshaler, c return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rollappId", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Rollapp_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.Rollapp(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -100,11 +111,22 @@ func local_request_Query_Rollapp_0(ctx context.Context, marshaler runtime.Marsha return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rollappId", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Rollapp_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.Rollapp(ctx, &protoReq) return msg, metadata, err } +var ( + filter_Query_RollappByEIP155_0 = &utilities.DoubleArray{Encoding: map[string]int{"eip155": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + func request_Query_RollappByEIP155_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryGetRollappByEIP155Request var metadata runtime.ServerMetadata @@ -127,6 +149,13 @@ func request_Query_RollappByEIP155_0(ctx context.Context, marshaler runtime.Mars return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "eip155", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RollappByEIP155_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.RollappByEIP155(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -154,6 +183,13 @@ func local_request_Query_RollappByEIP155_0(ctx context.Context, marshaler runtim return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "eip155", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RollappByEIP155_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.RollappByEIP155(ctx, &protoReq) return msg, metadata, err @@ -433,6 +469,60 @@ func local_request_Query_StateInfo_0(ctx context.Context, marshaler runtime.Mars } +var ( + filter_Query_RegisteredDenoms_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_RegisteredDenoms_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRegisteredDenomsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RegisteredDenoms_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.RegisteredDenoms(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RegisteredDenoms_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRegisteredDenomsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RegisteredDenoms_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.RegisteredDenoms(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_ObsoleteDRSVersions_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryObsoleteDRSVersionsRequest + var metadata runtime.ServerMetadata + + msg, err := client.ObsoleteDRSVersions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ObsoleteDRSVersions_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryObsoleteDRSVersionsRequest + var metadata runtime.ServerMetadata + + msg, err := server.ObsoleteDRSVersions(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -600,6 +690,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_RegisteredDenoms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RegisteredDenoms_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RegisteredDenoms_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ObsoleteDRSVersions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ObsoleteDRSVersions_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ObsoleteDRSVersions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -781,6 +917,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_RegisteredDenoms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_RegisteredDenoms_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RegisteredDenoms_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ObsoleteDRSVersions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ObsoleteDRSVersions_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ObsoleteDRSVersions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -798,6 +974,10 @@ var ( pattern_Query_LatestStateIndex_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"dymensionxyz", "dymension", "rollapp", "latest_state_index", "rollappId"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_StateInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"dymensionxyz", "dymension", "rollapp", "state_info", "rollappId", "index"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RegisteredDenoms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"dymensionxyz", "dymension", "rollapp", "registered_denoms"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_ObsoleteDRSVersions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"dymensionxyz", "dymension", "rollapp", "obsolete_drs_versions"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -814,4 +994,8 @@ var ( forward_Query_LatestStateIndex_0 = runtime.ForwardResponseMessage forward_Query_StateInfo_0 = runtime.ForwardResponseMessage + + forward_Query_RegisteredDenoms_0 = runtime.ForwardResponseMessage + + forward_Query_ObsoleteDRSVersions_0 = runtime.ForwardResponseMessage ) From e9a1f57dd34b41a7aab64a3f10b8268da88463e6 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sun, 10 Nov 2024 14:40:18 +0100 Subject: [PATCH 040/119] obsolete drs --- block/fork.go | 15 +- .../dymint/settlement/mock_ClientI.go | 57 +++++++ .../dymension/rollapp/mock_QueryClient.go | 148 ++++++++++++++++++ types/instruction.go | 2 +- 4 files changed, 217 insertions(+), 5 deletions(-) diff --git a/block/fork.go b/block/fork.go index 23d282cef..3512fb146 100644 --- a/block/fork.go +++ b/block/fork.go @@ -72,12 +72,17 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { } func (m *Manager) createInstruction(rollapp *types.Rollapp) error { + obsoleteDrs, err := m.SLClient.GetObsoleteDrs() + if err != nil { + return err + } instruction := types.Instruction{ Revision: rollapp.Revision, RevisionStartHeight: rollapp.RevisionStartHeight, + FaultyDRS: obsoleteDrs, } - err := types.PersistInstructionToDisk(m.RootDir, instruction) + err = types.PersistInstructionToDisk(m.RootDir, instruction) if err != nil { return err } @@ -155,7 +160,7 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { // - If no faulty DRS version is provided (faultyDRS is nil), returns no messages // - Validates the current DRS version against the potentially faulty version // - Generates an upgrade message with the current valid DRS version -func (m *Manager) prepareDRSUpgradeMessages(faultyDRS *uint64) ([]proto.Message, error) { +func (m *Manager) prepareDRSUpgradeMessages(faultyDRS []uint32) ([]proto.Message, error) { if faultyDRS == nil { return nil, nil } @@ -165,8 +170,10 @@ func (m *Manager) prepareDRSUpgradeMessages(faultyDRS *uint64) ([]proto.Message, return nil, fmt.Errorf("converting DRS version to int: %v", err) } - if *faultyDRS == uint64(actualDRS) { - return nil, fmt.Errorf("running faulty DRS version %d", *faultyDRS) + for _, drs := range faultyDRS { + if drs == uint32(actualDRS) { + return nil, fmt.Errorf("running faulty DRS version %d", drs) + } } return []proto.Message{ diff --git a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go index 87a64b313..4e2377ec3 100644 --- a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go +++ b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go @@ -480,6 +480,63 @@ func (_c *MockClientI_GetNextProposer_Call) RunAndReturn(run func() (*types.Sequ return _c } +// GetObsoleteDrs provides a mock function with given fields: +func (_m *MockClientI) GetObsoleteDrs() ([]uint32, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetObsoleteDrs") + } + + var r0 []uint32 + var r1 error + if rf, ok := ret.Get(0).(func() ([]uint32, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []uint32); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint32) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientI_GetObsoleteDrs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetObsoleteDrs' +type MockClientI_GetObsoleteDrs_Call struct { + *mock.Call +} + +// GetObsoleteDrs is a helper method to define mock.On call +func (_e *MockClientI_Expecter) GetObsoleteDrs() *MockClientI_GetObsoleteDrs_Call { + return &MockClientI_GetObsoleteDrs_Call{Call: _e.mock.On("GetObsoleteDrs")} +} + +func (_c *MockClientI_GetObsoleteDrs_Call) Run(run func()) *MockClientI_GetObsoleteDrs_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClientI_GetObsoleteDrs_Call) Return(_a0 []uint32, _a1 error) *MockClientI_GetObsoleteDrs_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientI_GetObsoleteDrs_Call) RunAndReturn(run func() ([]uint32, error)) *MockClientI_GetObsoleteDrs_Call { + _c.Call.Return(run) + return _c +} + // GetProposerAtHeight provides a mock function with given fields: height func (_m *MockClientI) GetProposerAtHeight(height int64) (*types.Sequencer, error) { ret := _m.Called(height) 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 83c174f72..a88bb2401 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 @@ -173,6 +173,80 @@ func (_c *MockQueryClient_LatestStateIndex_Call) RunAndReturn(run func(context.C return _c } +// ObsoleteDRSVersions provides a mock function with given fields: ctx, in, opts +func (_m *MockQueryClient) ObsoleteDRSVersions(ctx context.Context, in *rollapp.QueryObsoleteDRSVersionsRequest, opts ...grpc.CallOption) (*rollapp.QueryObsoleteDRSVersionsResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ObsoleteDRSVersions") + } + + var r0 *rollapp.QueryObsoleteDRSVersionsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *rollapp.QueryObsoleteDRSVersionsRequest, ...grpc.CallOption) (*rollapp.QueryObsoleteDRSVersionsResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *rollapp.QueryObsoleteDRSVersionsRequest, ...grpc.CallOption) *rollapp.QueryObsoleteDRSVersionsResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*rollapp.QueryObsoleteDRSVersionsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *rollapp.QueryObsoleteDRSVersionsRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockQueryClient_ObsoleteDRSVersions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ObsoleteDRSVersions' +type MockQueryClient_ObsoleteDRSVersions_Call struct { + *mock.Call +} + +// ObsoleteDRSVersions is a helper method to define mock.On call +// - ctx context.Context +// - in *rollapp.QueryObsoleteDRSVersionsRequest +// - opts ...grpc.CallOption +func (_e *MockQueryClient_Expecter) ObsoleteDRSVersions(ctx interface{}, in interface{}, opts ...interface{}) *MockQueryClient_ObsoleteDRSVersions_Call { + return &MockQueryClient_ObsoleteDRSVersions_Call{Call: _e.mock.On("ObsoleteDRSVersions", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *MockQueryClient_ObsoleteDRSVersions_Call) Run(run func(ctx context.Context, in *rollapp.QueryObsoleteDRSVersionsRequest, opts ...grpc.CallOption)) *MockQueryClient_ObsoleteDRSVersions_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*rollapp.QueryObsoleteDRSVersionsRequest), variadicArgs...) + }) + return _c +} + +func (_c *MockQueryClient_ObsoleteDRSVersions_Call) Return(_a0 *rollapp.QueryObsoleteDRSVersionsResponse, _a1 error) *MockQueryClient_ObsoleteDRSVersions_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockQueryClient_ObsoleteDRSVersions_Call) RunAndReturn(run func(context.Context, *rollapp.QueryObsoleteDRSVersionsRequest, ...grpc.CallOption) (*rollapp.QueryObsoleteDRSVersionsResponse, error)) *MockQueryClient_ObsoleteDRSVersions_Call { + _c.Call.Return(run) + return _c +} + // Params provides a mock function with given fields: ctx, in, opts func (_m *MockQueryClient) Params(ctx context.Context, in *rollapp.QueryParamsRequest, opts ...grpc.CallOption) (*rollapp.QueryParamsResponse, error) { _va := make([]interface{}, len(opts)) @@ -247,6 +321,80 @@ func (_c *MockQueryClient_Params_Call) RunAndReturn(run func(context.Context, *r return _c } +// RegisteredDenoms provides a mock function with given fields: ctx, in, opts +func (_m *MockQueryClient) RegisteredDenoms(ctx context.Context, in *rollapp.QueryRegisteredDenomsRequest, opts ...grpc.CallOption) (*rollapp.QueryRegisteredDenomsResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for RegisteredDenoms") + } + + var r0 *rollapp.QueryRegisteredDenomsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *rollapp.QueryRegisteredDenomsRequest, ...grpc.CallOption) (*rollapp.QueryRegisteredDenomsResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *rollapp.QueryRegisteredDenomsRequest, ...grpc.CallOption) *rollapp.QueryRegisteredDenomsResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*rollapp.QueryRegisteredDenomsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *rollapp.QueryRegisteredDenomsRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockQueryClient_RegisteredDenoms_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RegisteredDenoms' +type MockQueryClient_RegisteredDenoms_Call struct { + *mock.Call +} + +// RegisteredDenoms is a helper method to define mock.On call +// - ctx context.Context +// - in *rollapp.QueryRegisteredDenomsRequest +// - opts ...grpc.CallOption +func (_e *MockQueryClient_Expecter) RegisteredDenoms(ctx interface{}, in interface{}, opts ...interface{}) *MockQueryClient_RegisteredDenoms_Call { + return &MockQueryClient_RegisteredDenoms_Call{Call: _e.mock.On("RegisteredDenoms", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *MockQueryClient_RegisteredDenoms_Call) Run(run func(ctx context.Context, in *rollapp.QueryRegisteredDenomsRequest, opts ...grpc.CallOption)) *MockQueryClient_RegisteredDenoms_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*rollapp.QueryRegisteredDenomsRequest), variadicArgs...) + }) + return _c +} + +func (_c *MockQueryClient_RegisteredDenoms_Call) Return(_a0 *rollapp.QueryRegisteredDenomsResponse, _a1 error) *MockQueryClient_RegisteredDenoms_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockQueryClient_RegisteredDenoms_Call) RunAndReturn(run func(context.Context, *rollapp.QueryRegisteredDenomsRequest, ...grpc.CallOption) (*rollapp.QueryRegisteredDenomsResponse, error)) *MockQueryClient_RegisteredDenoms_Call { + _c.Call.Return(run) + return _c +} + // Rollapp provides a mock function with given fields: ctx, in, opts func (_m *MockQueryClient) Rollapp(ctx context.Context, in *rollapp.QueryGetRollappRequest, opts ...grpc.CallOption) (*rollapp.QueryGetRollappResponse, error) { _va := make([]interface{}, len(opts)) diff --git a/types/instruction.go b/types/instruction.go index 2ae259f10..e7588136e 100644 --- a/types/instruction.go +++ b/types/instruction.go @@ -9,7 +9,7 @@ import ( type Instruction struct { Revision uint64 RevisionStartHeight uint64 - FaultyDRS *uint64 + FaultyDRS []uint32 } const instructionFileName = "instruction.json" From 82aa03dbd7d1445dfe38a29abe134b3a25d89ff9 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sun, 10 Nov 2024 15:09:02 +0100 Subject: [PATCH 041/119] test fix --- block/fork_test.go | 7 +++++++ settlement/grpc/grpc.go | 2 +- settlement/local/local.go | 2 +- types/instruction_test.go | 3 +-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/block/fork_test.go b/block/fork_test.go index c0045806e..218585f1b 100644 --- a/block/fork_test.go +++ b/block/fork_test.go @@ -241,7 +241,14 @@ func TestCreateInstruction(t *testing.T) { manager := &Manager{ RootDir: t.TempDir(), // Use temporary directory for testing } + mockSL := new(settlement.MockClientI) + mockSL.On("GetObsoleteDrs").Return([]uint32{}, nil) + mockSL.On("GetRollapp").Return(&types.Rollapp{ + Revision: 2, + RevisionStartHeight: 100, + }, nil) + manager.SLClient = mockSL err := manager.createInstruction(tt.rollapp) if tt.expectedError { assert.Error(t, err) diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index e74d8bde9..96b1ed38d 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -58,7 +58,7 @@ func (c *Client) GetRollapp() (*types.Rollapp, error) { // GetObsoleteDrs returns the list of deprecated DRS. func (c *Client) GetObsoleteDrs() ([]uint32, error) { - panic("GetObsoleteDrs not implemented in local SL") + return []uint32{}, nil } var _ settlement.ClientI = (*Client)(nil) diff --git a/settlement/local/local.go b/settlement/local/local.go index f393da644..9a308820b 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -246,7 +246,7 @@ func (c *Client) GetAllSequencers() ([]types.Sequencer, error) { // GetObsoleteDrs returns the list of deprecated DRS. func (c *Client) GetObsoleteDrs() ([]uint32, error) { - panic("GetObsoleteDrs not implemented in local SL") + return []uint32{}, nil } // GetBondedSequencers implements settlement.ClientI. diff --git a/types/instruction_test.go b/types/instruction_test.go index 7bcfbab5d..0dea0111d 100644 --- a/types/instruction_test.go +++ b/types/instruction_test.go @@ -22,8 +22,7 @@ func TestPersistInstruction(t *testing.T) { require.NoError(t, err) require.Equal(t, instructionWithNilFaultyDrs, instruction) - faultyDrs := new(uint64) - *faultyDrs = 1 + faultyDrs := []uint32{1} instructionWithFaultyDrs := Instruction{ Revision: 1, RevisionStartHeight: 1, From 65a32fdbe534977fd212f0c3a7f7570565266586 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sun, 10 Nov 2024 15:09:20 +0100 Subject: [PATCH 042/119] 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 be28bb43b..27d11e4d5 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -591,7 +591,6 @@ func (c *Client) GetRollapp() (*types.Rollapp, error) { // GetObsoleteDrs returns the list of deprecated DRS. func (c *Client) GetObsoleteDrs() ([]uint32, error) { - var res *rollapptypes.QueryObsoleteDRSVersionsResponse req := &rollapptypes.QueryObsoleteDRSVersionsRequest{} From e14ceb6842329f7ff73c8eca15b9e73ad9d97083 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sun, 10 Nov 2024 15:37:52 +0100 Subject: [PATCH 043/119] fix --- block/fork.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/fork.go b/block/fork.go index 3512fb146..0f909dff8 100644 --- a/block/fork.go +++ b/block/fork.go @@ -165,7 +165,7 @@ func (m *Manager) prepareDRSUpgradeMessages(faultyDRS []uint32) ([]proto.Message return nil, nil } - actualDRS, err := strconv.Atoi(version.DrsVersion) + actualDRS, err := strconv.ParseUint(version.DrsVersion, 10, 32) if err != nil { return nil, fmt.Errorf("converting DRS version to int: %v", err) } From f27822efcfccca6124f19c27932bd515c6182c08 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 10:46:05 +0100 Subject: [PATCH 044/119] clear drsversion fork --- block/manager.go | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/block/manager.go b/block/manager.go index f4b6d96dd..76c679925 100644 --- a/block/manager.go +++ b/block/manager.go @@ -188,6 +188,24 @@ func NewManager( return nil, err } + if instruction, forkNeeded := m.forkNeeded(); forkNeeded { + // Set proposer to nil + m.State.SetProposer(nil) + + // Upgrade revision on state + state := m.State + state.Version.Consensus.App = instruction.Revision + state.VersionStartHeight = instruction.RevisionStartHeight + if instruction.RevisionStartHeight == m.State.Height() { + drsVersion, err := strconv.ParseUint(version.DrsVersion, 10, 32) + if err != nil { + return nil, fmt.Errorf("unable to parse drs version") + } + state.RollappParams.DrsVersion = uint32(drsVersion) + } + m.State = state + } + // validate configuration params and rollapp consensus params are in line err = m.ValidateConfigWithRollappParams() if err != nil { @@ -211,17 +229,6 @@ func (m *Manager) Start(ctx context.Context) error { } } - if instruction, forkNeeded := m.forkNeeded(); forkNeeded { - // Set proposer to nil - m.State.SetProposer(nil) - - // Upgrade revision on state - state := m.State - state.Version.Consensus.App = instruction.Revision - state.VersionStartHeight = instruction.RevisionStartHeight - m.State = state - } - // 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. From f24ca4db4649a5b0b9bd21dd615f07920e6479d8 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 11:49:38 +0100 Subject: [PATCH 045/119] merge fix --- block/executor.go | 8 +-- block/executor_test.go | 12 ++-- block/manager_test.go | 8 +-- block/produce.go | 2 +- indexers/blockindexer/kv/kv.go | 1 - indexers/txindex/kv/kv.go | 1 - .../dymint/block/mock_ExecutorI.go | 21 ++++--- .../dymint/settlement/mock_ClientI.go | 57 ------------------- p2p/validator_test.go | 2 +- settlement/settlement.go | 1 - 10 files changed, 22 insertions(+), 91 deletions(-) diff --git a/block/executor.go b/block/executor.go index c507c4e02..6b038a486 100644 --- a/block/executor.go +++ b/block/executor.go @@ -143,15 +143,11 @@ func (e *Executor) CreateBlock( lastHeaderHash, nextSeqHash [32]byte, state *types.State, maxBlockDataSizeBytes uint64, - enforceEmpty bool, ) *types.Block { maxBlockDataSizeBytes = min(maxBlockDataSizeBytes, uint64(max(minBlockMaxBytes, state.ConsensusParams.Block.MaxBytes))) - var txs types.Txs - if !enforceEmpty { - mempoolTxs := e.mempool.ReapMaxBytesMaxGas(int64(maxBlockDataSizeBytes), state.ConsensusParams.Block.MaxGas) - txs = toDymintTxs(mempoolTxs) - } + mempoolTxs := e.mempool.ReapMaxBytesMaxGas(int64(maxBlockDataSizeBytes), state.ConsensusParams.Block.MaxGas) + txs := toDymintTxs(mempoolTxs) block := &types.Block{ Header: types.Header{ diff --git a/block/executor_test.go b/block/executor_test.go index 2dbae1842..c40e4af2b 100644 --- a/block/executor_test.go +++ b/block/executor_test.go @@ -67,7 +67,7 @@ func TestCreateBlock(t *testing.T) { state.ConsensusParams.Block.MaxBytes = int64(maxBytes) state.ConsensusParams.Block.MaxGas = 100000 // empty block - block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes, false) + block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes) require.NotNil(block) assert.Empty(block.Data.Txs) assert.Equal(uint64(1), block.Header.Height) @@ -75,7 +75,7 @@ func TestCreateBlock(t *testing.T) { // one small Tx err = mpool.CheckTx([]byte{1, 2, 3, 4}, func(r *abci.Response) {}, mempool.TxInfo{}) require.NoError(err) - block = executor.CreateBlock(2, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes, false) + block = executor.CreateBlock(2, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes) require.NotNil(block) assert.Equal(uint64(2), block.Header.Height) assert.Len(block.Data.Txs, 1) @@ -85,7 +85,7 @@ func TestCreateBlock(t *testing.T) { require.NoError(err) err = mpool.CheckTx(make([]byte, 100), func(r *abci.Response) {}, mempool.TxInfo{}) require.NoError(err) - block = executor.CreateBlock(3, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes, false) + block = executor.CreateBlock(3, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes) require.NotNil(block) assert.Len(block.Data.Txs, 2) } @@ -132,7 +132,7 @@ func TestCreateBlockWithConsensusMessages(t *testing.T) { state.ConsensusParams.Block.MaxBytes = int64(maxBytes) state.ConsensusParams.Block.MaxGas = 100000 - block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()[:]), state, maxBytes, false) + block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()[:]), state, maxBytes) require.NotNil(block) assert.Empty(block.Data.Txs) @@ -251,7 +251,7 @@ func TestApplyBlock(t *testing.T) { // Create first block with one Tx from mempool _ = mpool.CheckTx([]byte{1, 2, 3, 4}, func(r *abci.Response) {}, mempool.TxInfo{}) require.NoError(err) - block := executor.CreateBlock(1, &types.Commit{Height: 0}, [32]byte{0x01}, [32]byte(state.GetProposerHash()), state, maxBytes, false) + block := executor.CreateBlock(1, &types.Commit{Height: 0}, [32]byte{0x01}, [32]byte(state.GetProposerHash()), state, maxBytes) require.NotNil(block) assert.Equal(uint64(1), block.Header.Height) assert.Len(block.Data.Txs, 1) @@ -286,7 +286,7 @@ func TestApplyBlock(t *testing.T) { 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, 9990), func(r *abci.Response) {}, mempool.TxInfo{})) - block = executor.CreateBlock(2, commit, block.Header.Hash(), [32]byte(state.GetProposerHash()), state, maxBytes, false) + block = executor.CreateBlock(2, commit, block.Header.Hash(), [32]byte(state.GetProposerHash()), state, maxBytes) require.NotNil(block) assert.Equal(uint64(2), block.Header.Height) assert.Len(block.Data.Txs, 3) diff --git a/block/manager_test.go b/block/manager_test.go index 0b511c25e..cbc970244 100644 --- a/block/manager_test.go +++ b/block/manager_test.go @@ -29,18 +29,14 @@ import ( "github.com/tendermint/tendermint/proxy" tmtypes "github.com/tendermint/tendermint/types" - "github.com/dymensionxyz/dymint/block" "github.com/dymensionxyz/dymint/config" "github.com/dymensionxyz/dymint/da" blockmocks "github.com/dymensionxyz/dymint/mocks/github.com/dymensionxyz/dymint/block" "github.com/dymensionxyz/dymint/node/events" - "github.com/dymensionxyz/dymint/p2p" - "github.com/dymensionxyz/dymint/settlement" + slregistry "github.com/dymensionxyz/dymint/settlement/registry" "github.com/dymensionxyz/dymint/store" - "github.com/dymensionxyz/dymint/testutil" - "github.com/dymensionxyz/dymint/types" - "github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp" + "github.com/dymensionxyz/dymint/utils/event" "github.com/dymensionxyz/gerr-cosmos/gerrc" ) diff --git a/block/produce.go b/block/produce.go index 932c8f1c4..ed388456d 100644 --- a/block/produce.go +++ b/block/produce.go @@ -167,7 +167,7 @@ func (m *Manager) produceBlock(allowEmpty bool, nextProposerHash *[32]byte) (*ty proposerHashForBlock = *nextProposerHash } - block = m.Executor.CreateBlock(newHeight, lastCommit, lastHeaderHash, proposerHashForBlock, m.State, maxBlockDataSize, false) + block = m.Executor.CreateBlock(newHeight, lastCommit, lastHeaderHash, proposerHashForBlock, m.State, maxBlockDataSize) if !allowEmpty && len(block.Data.Txs) == 0 { return nil, nil, fmt.Errorf("%w: %w", types.ErrEmptyBlock, ErrRecoverable) } diff --git a/indexers/blockindexer/kv/kv.go b/indexers/blockindexer/kv/kv.go index 648838cc8..673323561 100644 --- a/indexers/blockindexer/kv/kv.go +++ b/indexers/blockindexer/kv/kv.go @@ -621,7 +621,6 @@ func (idx *BlockerIndexer) pruneEvents(height int64, logger log.Logger, batch st logger.Error("pruning block indexer iterate events", "height", height, "err", err) continue } - pruned++ } return pruned, nil diff --git a/indexers/txindex/kv/kv.go b/indexers/txindex/kv/kv.go index a9f1f7608..aeca26fc6 100644 --- a/indexers/txindex/kv/kv.go +++ b/indexers/txindex/kv/kv.go @@ -665,7 +665,6 @@ func (txi *TxIndex) pruneEvents(height uint64, batch store.KVBatch) (uint64, err if err != nil { return pruned, err } - pruned++ } return pruned, nil } diff --git a/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go b/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go index ce0bc08de..2ba9eee27 100644 --- a/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go +++ b/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go @@ -142,17 +142,17 @@ func (_c *MockExecutorI_Commit_Call) RunAndReturn(run func(*types.State, *types. return _c } -// CreateBlock provides a mock function with given fields: height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes, enforceEmpty -func (_m *MockExecutorI) CreateBlock(height uint64, lastCommit *types.Commit, lastHeaderHash [32]byte, nextSeqHash [32]byte, _a4 *types.State, maxBlockDataSizeBytes uint64, enforceEmpty bool) *types.Block { - ret := _m.Called(height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes, enforceEmpty) +// CreateBlock provides a mock function with given fields: height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes +func (_m *MockExecutorI) CreateBlock(height uint64, lastCommit *types.Commit, lastHeaderHash [32]byte, nextSeqHash [32]byte, _a4 *types.State, maxBlockDataSizeBytes uint64) *types.Block { + ret := _m.Called(height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes) if len(ret) == 0 { panic("no return value specified for CreateBlock") } var r0 *types.Block - if rf, ok := ret.Get(0).(func(uint64, *types.Commit, [32]byte, [32]byte, *types.State, uint64, bool) *types.Block); ok { - r0 = rf(height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes, enforceEmpty) + if rf, ok := ret.Get(0).(func(uint64, *types.Commit, [32]byte, [32]byte, *types.State, uint64) *types.Block); ok { + r0 = rf(height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*types.Block) @@ -174,14 +174,13 @@ type MockExecutorI_CreateBlock_Call struct { // - nextSeqHash [32]byte // - _a4 *types.State // - maxBlockDataSizeBytes uint64 -// - enforceEmpty bool -func (_e *MockExecutorI_Expecter) CreateBlock(height interface{}, lastCommit interface{}, lastHeaderHash interface{}, nextSeqHash interface{}, _a4 interface{}, maxBlockDataSizeBytes interface{}, enforceEmpty interface{}) *MockExecutorI_CreateBlock_Call { - return &MockExecutorI_CreateBlock_Call{Call: _e.mock.On("CreateBlock", height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes, enforceEmpty)} +func (_e *MockExecutorI_Expecter) CreateBlock(height interface{}, lastCommit interface{}, lastHeaderHash interface{}, nextSeqHash interface{}, _a4 interface{}, maxBlockDataSizeBytes interface{}) *MockExecutorI_CreateBlock_Call { + return &MockExecutorI_CreateBlock_Call{Call: _e.mock.On("CreateBlock", height, lastCommit, lastHeaderHash, nextSeqHash, _a4, maxBlockDataSizeBytes)} } -func (_c *MockExecutorI_CreateBlock_Call) Run(run func(height uint64, lastCommit *types.Commit, lastHeaderHash [32]byte, nextSeqHash [32]byte, _a4 *types.State, maxBlockDataSizeBytes uint64, enforceEmpty bool)) *MockExecutorI_CreateBlock_Call { +func (_c *MockExecutorI_CreateBlock_Call) Run(run func(height uint64, lastCommit *types.Commit, lastHeaderHash [32]byte, nextSeqHash [32]byte, _a4 *types.State, maxBlockDataSizeBytes uint64)) *MockExecutorI_CreateBlock_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(uint64), args[1].(*types.Commit), args[2].([32]byte), args[3].([32]byte), args[4].(*types.State), args[5].(uint64), args[6].(bool)) + run(args[0].(uint64), args[1].(*types.Commit), args[2].([32]byte), args[3].([32]byte), args[4].(*types.State), args[5].(uint64)) }) return _c } @@ -191,7 +190,7 @@ func (_c *MockExecutorI_CreateBlock_Call) Return(_a0 *types.Block) *MockExecutor return _c } -func (_c *MockExecutorI_CreateBlock_Call) RunAndReturn(run func(uint64, *types.Commit, [32]byte, [32]byte, *types.State, uint64, bool) *types.Block) *MockExecutorI_CreateBlock_Call { +func (_c *MockExecutorI_CreateBlock_Call) RunAndReturn(run func(uint64, *types.Commit, [32]byte, [32]byte, *types.State, uint64) *types.Block) *MockExecutorI_CreateBlock_Call { _c.Call.Return(run) return _c } diff --git a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go index 4e2377ec3..8afdb97d6 100644 --- a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go +++ b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go @@ -652,63 +652,6 @@ func (_c *MockClientI_GetRollapp_Call) RunAndReturn(run func() (*types.Rollapp, return _c } -// GetRollapp provides a mock function with given fields: -func (_m *MockClientI) GetRollapp() (*types.Rollapp, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetRollapp") - } - - var r0 *types.Rollapp - var r1 error - if rf, ok := ret.Get(0).(func() (*types.Rollapp, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() *types.Rollapp); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*types.Rollapp) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockClientI_GetRollapp_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRollapp' -type MockClientI_GetRollapp_Call struct { - *mock.Call -} - -// GetRollapp is a helper method to define mock.On call -func (_e *MockClientI_Expecter) GetRollapp() *MockClientI_GetRollapp_Call { - return &MockClientI_GetRollapp_Call{Call: _e.mock.On("GetRollapp")} -} - -func (_c *MockClientI_GetRollapp_Call) Run(run func()) *MockClientI_GetRollapp_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockClientI_GetRollapp_Call) Return(_a0 *types.Rollapp, _a1 error) *MockClientI_GetRollapp_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockClientI_GetRollapp_Call) RunAndReturn(run func() (*types.Rollapp, error)) *MockClientI_GetRollapp_Call { - _c.Call.Return(run) - return _c -} - // GetSequencerByAddress provides a mock function with given fields: address func (_m *MockClientI) GetSequencerByAddress(address string) (types.Sequencer, error) { ret := _m.Called(address) diff --git a/p2p/validator_test.go b/p2p/validator_test.go index b693ae749..f40d707be 100644 --- a/p2p/validator_test.go +++ b/p2p/validator_test.go @@ -136,7 +136,7 @@ func TestValidator_BlockValidator(t *testing.T) { state.ConsensusParams.Block.MaxBytes = int64(maxBytes) // Create empty block - block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes, false) + block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.GetProposerHash()), state, maxBytes) getProposer := &p2pmock.MockGetProposerI{} getProposer.On("GetProposerPubKey").Return(proposerKey.PubKey()) diff --git a/settlement/settlement.go b/settlement/settlement.go index bcbb8a620..e19898375 100644 --- a/settlement/settlement.go +++ b/settlement/settlement.go @@ -94,7 +94,6 @@ type ClientI interface { // GetNextProposer returns the next proposer for this chain in case of a rotation. // If no rotation is in progress, it should return nil. GetNextProposer() (*types.Sequencer, error) - CheckRotationInProgress() (*types.Sequencer, error) // GetRollapp returns the rollapp information. GetRollapp() (*types.Rollapp, error) // GetObsoleteDrs returns the list of deprecated DRS. From 23e688f93fc9ca4500217506cd642a8744a5e359 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 11:53:49 +0100 Subject: [PATCH 046/119] merge fix --- block/executor.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/block/executor.go b/block/executor.go index 6b038a486..6f6cfc71f 100644 --- a/block/executor.go +++ b/block/executor.go @@ -145,9 +145,7 @@ func (e *Executor) CreateBlock( maxBlockDataSizeBytes uint64, ) *types.Block { maxBlockDataSizeBytes = min(maxBlockDataSizeBytes, uint64(max(minBlockMaxBytes, state.ConsensusParams.Block.MaxBytes))) - mempoolTxs := e.mempool.ReapMaxBytesMaxGas(int64(maxBlockDataSizeBytes), state.ConsensusParams.Block.MaxGas) - txs := toDymintTxs(mempoolTxs) block := &types.Block{ Header: types.Header{ @@ -166,7 +164,7 @@ func (e *Executor) CreateBlock( ProposerAddress: e.localAddress, }, Data: types.Data{ - Txs: txs, + Txs: toDymintTxs(mempoolTxs), IntermediateStateRoots: types.IntermediateStateRoots{RawRootsList: nil}, Evidence: types.EvidenceData{Evidence: nil}, ConsensusMessages: fromProtoMsgSliceToAnySlice(e.consensusMsgQueue.Get()...), From 658dea092e28eb116c745acf765f172708f57c59 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 12:09:59 +0100 Subject: [PATCH 047/119] addressing comments --- block/fork.go | 2 +- block/manager.go | 2 +- proto/types/dymint/state.proto | 2 +- types/pb/dymint/state.pb.go | 114 ++++++++++++++++----------------- types/serialization.go | 24 +++---- types/state.go | 4 +- types/validation.go | 2 +- 7 files changed, 75 insertions(+), 75 deletions(-) diff --git a/block/fork.go b/block/fork.go index 0f909dff8..7fe32eb1b 100644 --- a/block/fork.go +++ b/block/fork.go @@ -265,7 +265,7 @@ func (m *Manager) handleForkBatchSubmission(height uint64) error { return fmt.Errorf("getting batch at height: %v", err) } - if resp.Batch == nil { + if resp == nil { if _, err := m.CreateAndSubmitBatch(m.Conf.BatchSubmitBytes, false); err != nil { return fmt.Errorf("creating and submitting batch: %v", err) } diff --git a/block/manager.go b/block/manager.go index 76c679925..a07cf1cae 100644 --- a/block/manager.go +++ b/block/manager.go @@ -195,7 +195,7 @@ func NewManager( // Upgrade revision on state state := m.State state.Version.Consensus.App = instruction.Revision - state.VersionStartHeight = instruction.RevisionStartHeight + state.RevisionStartHeight = instruction.RevisionStartHeight if instruction.RevisionStartHeight == m.State.Height() { drsVersion, err := strconv.ParseUint(version.DrsVersion, 10, 32) if err != nil { diff --git a/proto/types/dymint/state.proto b/proto/types/dymint/state.proto index adfd645ab..21d6a39cb 100755 --- a/proto/types/dymint/state.proto +++ b/proto/types/dymint/state.proto @@ -49,7 +49,7 @@ message State { // Proposer is a sequencer that acts as a proposer. Can be nil if no proposer is set. Sequencer proposer = 20; - int64 version_start_height = 21; + int64 revision_start_height = 21; } //rollapp params defined in genesis and updated via gov proposal diff --git a/types/pb/dymint/state.pb.go b/types/pb/dymint/state.pb.go index 7ebb84dad..c73e18c79 100644 --- a/types/pb/dymint/state.pb.go +++ b/types/pb/dymint/state.pb.go @@ -46,8 +46,8 @@ type State struct { RollappParams RollappParams `protobuf:"bytes,18,opt,name=rollapp_params,json=rollappParams,proto3" json:"rollapp_params"` LastHeaderHash []byte `protobuf:"bytes,19,opt,name=last_header_hash,json=lastHeaderHash,proto3" json:"last_header_hash,omitempty"` // Proposer is a sequencer that acts as a proposer. Can be nil if no proposer is set. - Proposer *Sequencer `protobuf:"bytes,20,opt,name=proposer,proto3" json:"proposer,omitempty"` - VersionStartHeight int64 `protobuf:"varint,21,opt,name=version_start_height,json=versionStartHeight,proto3" json:"version_start_height,omitempty"` + Proposer *Sequencer `protobuf:"bytes,20,opt,name=proposer,proto3" json:"proposer,omitempty"` + RevisionStartHeight int64 `protobuf:"varint,21,opt,name=revision_start_height,json=revisionStartHeight,proto3" json:"revision_start_height,omitempty"` } func (m *State) Reset() { *m = State{} } @@ -189,9 +189,9 @@ func (m *State) GetProposer() *Sequencer { return nil } -func (m *State) GetVersionStartHeight() int64 { +func (m *State) GetRevisionStartHeight() int64 { if m != nil { - return m.VersionStartHeight + return m.RevisionStartHeight } return 0 } @@ -259,52 +259,52 @@ func init() { func init() { proto.RegisterFile("types/dymint/state.proto", fileDescriptor_4b679420add07272) } var fileDescriptor_4b679420add07272 = []byte{ - // 708 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0xcd, 0x4e, 0xdb, 0x4c, - 0x14, 0x86, 0xe3, 0x60, 0x88, 0x33, 0x21, 0x89, 0x19, 0x40, 0x32, 0x7c, 0x92, 0x13, 0xf8, 0xd4, - 0x2a, 0xaa, 0x54, 0xa7, 0x2a, 0x17, 0xd0, 0xca, 0xb0, 0x20, 0x11, 0x8b, 0xca, 0xa9, 0x58, 0x74, - 0x63, 0x4d, 0xec, 0xa9, 0x6d, 0xd5, 0xf1, 0xb8, 0x33, 0x13, 0x54, 0x7a, 0x15, 0x5c, 0x41, 0xaf, - 0x87, 0x25, 0xcb, 0xae, 0x68, 0x15, 0x6e, 0xa4, 0x9a, 0x1f, 0x87, 0x44, 0x11, 0xab, 0xc4, 0xef, - 0x79, 0xfc, 0xce, 0xf9, 0x99, 0x63, 0xe0, 0xf0, 0xdb, 0x12, 0xb3, 0x61, 0x7c, 0x3b, 0xcb, 0x0a, - 0x3e, 0x64, 0x1c, 0x71, 0xec, 0x95, 0x94, 0x70, 0x02, 0x77, 0x94, 0x76, 0x7c, 0x90, 0x90, 0x84, - 0x48, 0x69, 0x28, 0xfe, 0xa9, 0xe8, 0x71, 0x2f, 0x21, 0x24, 0xc9, 0xf1, 0x50, 0x3e, 0x4d, 0xe7, - 0x5f, 0x87, 0x3c, 0x9b, 0x61, 0xc6, 0xd1, 0xac, 0xd4, 0xc0, 0x89, 0x32, 0xe6, 0xb8, 0x88, 0x31, - 0x95, 0xe6, 0x68, 0x1a, 0x65, 0x43, 0xa9, 0x6a, 0xe4, 0x74, 0x03, 0xd1, 0xc2, 0x0a, 0xf3, 0xfa, - 0x05, 0xe6, 0x06, 0xe5, 0x59, 0x8c, 0x38, 0xa1, 0x9a, 0xfb, 0xff, 0x05, 0xae, 0x44, 0x14, 0xcd, - 0x5e, 0x3e, 0x50, 0x16, 0xbc, 0x76, 0xe0, 0xd1, 0x5a, 0x43, 0xd4, 0x8f, 0x0a, 0x9d, 0xfe, 0x6a, - 0x80, 0xed, 0x89, 0x78, 0x01, 0x9e, 0x81, 0xc6, 0x0d, 0xa6, 0x2c, 0x23, 0x85, 0x63, 0xf4, 0x8d, - 0x41, 0xeb, 0xfd, 0x91, 0xf7, 0x6c, 0xea, 0xa9, 0x2e, 0x5e, 0x2b, 0x20, 0xa8, 0x48, 0x78, 0x04, - 0xac, 0x28, 0x45, 0x59, 0x11, 0x66, 0xb1, 0x53, 0xef, 0x1b, 0x83, 0x66, 0xd0, 0x90, 0xcf, 0xa3, - 0x18, 0xbe, 0x02, 0x9d, 0xac, 0xc8, 0x78, 0x86, 0xf2, 0x30, 0xc5, 0x59, 0x92, 0x72, 0x67, 0xab, - 0x6f, 0x0c, 0xb6, 0x82, 0xb6, 0x56, 0x2f, 0xa5, 0x08, 0xdf, 0x80, 0xbd, 0x1c, 0x31, 0x1e, 0x4e, - 0x73, 0x12, 0x7d, 0xab, 0x48, 0x53, 0x92, 0x5d, 0x11, 0xf0, 0x85, 0xae, 0xd9, 0x00, 0xb4, 0x57, - 0xd8, 0x2c, 0x76, 0xb6, 0x37, 0x13, 0x55, 0x75, 0xcb, 0xb7, 0x46, 0x17, 0xfe, 0xfe, 0xfd, 0x63, - 0xaf, 0xb6, 0x78, 0xec, 0xb5, 0xae, 0x2a, 0xab, 0xd1, 0x45, 0xd0, 0x5a, 0xfa, 0x8e, 0x62, 0x78, - 0x05, 0xba, 0x2b, 0x9e, 0x62, 0xe2, 0xce, 0x8e, 0x74, 0x3d, 0xf6, 0xd4, 0x75, 0xf0, 0xaa, 0xeb, - 0xe0, 0x7d, 0xae, 0xae, 0x83, 0x6f, 0x09, 0xdb, 0xbb, 0x3f, 0x3d, 0x23, 0x68, 0x2f, 0xbd, 0x44, - 0x14, 0xfa, 0x00, 0x2c, 0xa7, 0xc8, 0x9c, 0xa6, 0x34, 0x72, 0x37, 0xd3, 0xbb, 0xae, 0x98, 0x09, - 0xe6, 0x7e, 0xdd, 0x31, 0x82, 0x95, 0xb7, 0xe0, 0x39, 0x70, 0x65, 0x46, 0xaa, 0x17, 0xe1, 0x73, - 0x24, 0x8c, 0x52, 0x54, 0x24, 0x38, 0x76, 0x5a, 0xb2, 0x3d, 0xff, 0x09, 0x4a, 0x75, 0x66, 0xe9, - 0xc7, 0xce, 0x15, 0x02, 0x03, 0x60, 0x47, 0xa4, 0x60, 0xb8, 0x60, 0x73, 0x16, 0xaa, 0x0b, 0xe3, - 0xec, 0xca, 0x74, 0x4e, 0x36, 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, 0x36, 0xad, 0x3d, 0x1b, 0x9e, - 0x7e, 0x04, 0xed, 0xb5, 0x72, 0x60, 0x07, 0xd4, 0x63, 0x24, 0x57, 0xb4, 0x19, 0xd4, 0x63, 0x04, - 0x7b, 0xa0, 0x15, 0x53, 0x16, 0x56, 0xbb, 0x2b, 0xb6, 0xb0, 0x1d, 0x80, 0x98, 0x32, 0xbd, 0xac, - 0xfe, 0xe5, 0xfd, 0xc2, 0x35, 0x1e, 0x16, 0xae, 0xf1, 0x77, 0xe1, 0x1a, 0x77, 0x4f, 0x6e, 0xed, - 0xe1, 0xc9, 0xad, 0xfd, 0x7e, 0x72, 0x6b, 0x5f, 0xbc, 0x24, 0xe3, 0xe9, 0x7c, 0xea, 0x45, 0x64, - 0x26, 0xbe, 0x0a, 0xb8, 0x10, 0xfc, 0x8f, 0xdb, 0x9f, 0xd5, 0x97, 0x42, 0x7f, 0x6e, 0xa6, 0xfa, - 0x79, 0xba, 0x23, 0x57, 0xe1, 0xec, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2b, 0xf4, 0x1c, 0xe7, - 0x61, 0x05, 0x00, 0x00, + // 712 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0xcf, 0x4e, 0xdb, 0x4a, + 0x14, 0xc6, 0xe3, 0x60, 0x88, 0x33, 0x21, 0x89, 0x99, 0x80, 0x64, 0xb8, 0x92, 0x13, 0xb8, 0xba, + 0x57, 0xd1, 0x95, 0xae, 0x23, 0xc1, 0x03, 0xb4, 0x32, 0x2c, 0x48, 0xc4, 0xa2, 0x72, 0x2a, 0x16, + 0xdd, 0x58, 0x13, 0x7b, 0x6a, 0x8f, 0xea, 0x78, 0xdc, 0x99, 0x09, 0x2a, 0x7d, 0x0a, 0x1e, 0xa1, + 0x8f, 0xc3, 0x92, 0x65, 0x57, 0xb4, 0x0a, 0x2f, 0x52, 0xcd, 0x8c, 0x1d, 0x12, 0x45, 0xac, 0x12, + 0x7f, 0xe7, 0xe7, 0x6f, 0xce, 0x9f, 0x39, 0x06, 0x8e, 0xb8, 0x2f, 0x30, 0x1f, 0xc5, 0xf7, 0x73, + 0x92, 0x8b, 0x11, 0x17, 0x48, 0x60, 0xaf, 0x60, 0x54, 0x50, 0xb8, 0xa7, 0xb5, 0x93, 0xc3, 0x84, + 0x26, 0x54, 0x49, 0x23, 0xf9, 0x4f, 0x47, 0x4f, 0xfa, 0x09, 0xa5, 0x49, 0x86, 0x47, 0xea, 0x69, + 0xb6, 0xf8, 0x3c, 0x12, 0x64, 0x8e, 0xb9, 0x40, 0xf3, 0xa2, 0x04, 0x4e, 0xb5, 0xb1, 0xc0, 0x79, + 0x8c, 0x99, 0x32, 0x47, 0xb3, 0x88, 0x8c, 0x94, 0x5a, 0x22, 0x67, 0x5b, 0x48, 0x29, 0xac, 0x31, + 0xff, 0xbe, 0xc1, 0xdc, 0xa1, 0x8c, 0xc4, 0x48, 0x50, 0x56, 0x72, 0x7f, 0xbf, 0xc1, 0x15, 0x88, + 0xa1, 0xf9, 0xdb, 0x07, 0xaa, 0x82, 0x37, 0x0e, 0x3c, 0xde, 0x68, 0x88, 0xfe, 0xd1, 0xa1, 0xb3, + 0x1f, 0x0d, 0xb0, 0x3b, 0x95, 0x2f, 0xc0, 0x0b, 0xd0, 0xb8, 0xc3, 0x8c, 0x13, 0x9a, 0x3b, 0xc6, + 0xc0, 0x18, 0xb6, 0xce, 0x8f, 0xbd, 0x57, 0x53, 0x4f, 0x77, 0xf1, 0x56, 0x03, 0x41, 0x45, 0xc2, + 0x63, 0x60, 0x45, 0x29, 0x22, 0x79, 0x48, 0x62, 0xa7, 0x3e, 0x30, 0x86, 0xcd, 0xa0, 0xa1, 0x9e, + 0xc7, 0x31, 0xfc, 0x07, 0x74, 0x48, 0x4e, 0x04, 0x41, 0x59, 0x98, 0x62, 0x92, 0xa4, 0xc2, 0xd9, + 0x19, 0x18, 0xc3,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+ 0xcd, 0xa0, 0x1e, 0x23, 0xd8, 0x07, 0xad, 0x98, 0xf1, 0xb0, 0xda, 0x5e, 0xb9, 0x87, 0xed, 0x00, + 0xc4, 0x8c, 0x97, 0xeb, 0xea, 0x5f, 0x3f, 0x2e, 0x5d, 0xe3, 0x69, 0xe9, 0x1a, 0xbf, 0x97, 0xae, + 0xf1, 0xf0, 0xe2, 0xd6, 0x9e, 0x5e, 0xdc, 0xda, 0xcf, 0x17, 0xb7, 0xf6, 0xc9, 0x4b, 0x88, 0x48, + 0x17, 0x33, 0x2f, 0xa2, 0x73, 0xf9, 0x5d, 0xc0, 0xb9, 0xe4, 0xbf, 0xdd, 0x7f, 0xaf, 0xbe, 0x15, + 0xe5, 0x07, 0x67, 0x56, 0x3e, 0xcf, 0xf6, 0xd4, 0x32, 0x5c, 0xfc, 0x09, 0x00, 0x00, 0xff, 0xff, + 0x62, 0x29, 0x77, 0x07, 0x63, 0x05, 0x00, 0x00, } func (m *State) Marshal() (dAtA []byte, err error) { @@ -327,8 +327,8 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.VersionStartHeight != 0 { - i = encodeVarintState(dAtA, i, uint64(m.VersionStartHeight)) + if m.RevisionStartHeight != 0 { + i = encodeVarintState(dAtA, i, uint64(m.RevisionStartHeight)) i-- dAtA[i] = 0x1 i-- @@ -567,8 +567,8 @@ func (m *State) Size() (n int) { l = m.Proposer.Size() n += 2 + l + sovState(uint64(l)) } - if m.VersionStartHeight != 0 { - n += 2 + sovState(uint64(m.VersionStartHeight)) + if m.RevisionStartHeight != 0 { + n += 2 + sovState(uint64(m.RevisionStartHeight)) } return n } @@ -1076,9 +1076,9 @@ func (m *State) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 21: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field VersionStartHeight", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RevisionStartHeight", wireType) } - m.VersionStartHeight = 0 + m.RevisionStartHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowState @@ -1088,7 +1088,7 @@ func (m *State) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.VersionStartHeight |= int64(b&0x7F) << shift + m.RevisionStartHeight |= int64(b&0x7F) << shift if b < 0x80 { break } diff --git a/types/serialization.go b/types/serialization.go index 1ae6baa9b..1c2bcc7ef 100644 --- a/types/serialization.go +++ b/types/serialization.go @@ -261,17 +261,17 @@ func (s *State) ToProto() (*pb.State, error) { } return &pb.State{ - Version: &s.Version, - ChainId: s.ChainID, - InitialHeight: int64(s.InitialHeight), - LastBlockHeight: int64(s.Height()), - ConsensusParams: s.ConsensusParams, - LastResultsHash: s.LastResultsHash[:], - LastHeaderHash: s.LastHeaderHash[:], - AppHash: s.AppHash[:], - RollappParams: s.RollappParams, - Proposer: proposerProto, - VersionStartHeight: int64(s.VersionStartHeight), + Version: &s.Version, + ChainId: s.ChainID, + InitialHeight: int64(s.InitialHeight), + LastBlockHeight: int64(s.Height()), + ConsensusParams: s.ConsensusParams, + LastResultsHash: s.LastResultsHash[:], + LastHeaderHash: s.LastHeaderHash[:], + AppHash: s.AppHash[:], + RollappParams: s.RollappParams, + Proposer: proposerProto, + RevisionStartHeight: int64(s.RevisionStartHeight), }, nil } @@ -281,7 +281,7 @@ func (s *State) FromProto(other *pb.State) error { s.ChainID = other.ChainId s.InitialHeight = uint64(other.InitialHeight) s.SetHeight(uint64(other.LastBlockHeight)) - s.VersionStartHeight = uint64(other.VersionStartHeight) + s.RevisionStartHeight = uint64(other.RevisionStartHeight) if other.Proposer != nil { proposer, err := SequencerFromProto(other.Proposer) if err != nil { diff --git a/types/state.go b/types/state.go index 8db1efdb0..d76a55735 100644 --- a/types/state.go +++ b/types/state.go @@ -16,8 +16,8 @@ import ( // State contains information about current state of the blockchain. type State struct { - Version tmstate.Version - VersionStartHeight uint64 + Version tmstate.Version + RevisionStartHeight uint64 // immutable ChainID string InitialHeight uint64 // should be 1, not 0, when starting from height 1 diff --git a/types/validation.go b/types/validation.go index c766af4a5..dcf6eb324 100644 --- a/types/validation.go +++ b/types/validation.go @@ -68,7 +68,7 @@ func (b *Block) ValidateWithState(state *State) error { } appVersion := state.Version.Consensus.App - if b.Header.Height < state.VersionStartHeight { + if b.Header.Height < state.RevisionStartHeight { appVersion-- } From 892ba126b1a6288817dea02ac5752eb8ec8ce55f Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 12:23:24 +0100 Subject: [PATCH 048/119] updated hub query proto --- .../dymension/rollapp/query.proto | 73 +++++++++++++++---- 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/proto/types/dymensionxyz/dymension/rollapp/query.proto b/proto/types/dymensionxyz/dymension/rollapp/query.proto index 0473c49e3..24dedab2d 100644 --- a/proto/types/dymensionxyz/dymension/rollapp/query.proto +++ b/proto/types/dymensionxyz/dymension/rollapp/query.proto @@ -1,42 +1,69 @@ -// This file is a modified copy of the rollapp module proto contract. Source: -// https://github.com/dymensionxyz/dymension/blob/f140cd1dd561cefb3e6562cbf4379b88cd16400d/proto/dymensionxyz/dymension/rollapp/. - syntax = "proto3"; package dymensionxyz.dymension.rollapp; -option go_package = "github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp"; +option go_package = "github.com/dymensionxyz/dymension/v3/x/rollapp/types"; import "gogoproto/gogo.proto"; -import "types/cosmos/base/query/v1beta1/pagination.proto"; -import "types/dymensionxyz/dymension/rollapp/params.proto"; -import "types/dymensionxyz/dymension/rollapp/rollapp.proto"; -import "types/dymensionxyz/dymension/rollapp/state_info.proto"; -import "types/dymensionxyz/dymension/rollapp/app.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "dymensionxyz/dymension/rollapp/params.proto"; +import "dymensionxyz/dymension/rollapp/rollapp.proto"; +import "dymensionxyz/dymension/rollapp/state_info.proto"; +import "dymensionxyz/dymension/rollapp/app.proto"; // Query defines the gRPC querier service. service Query { // Parameters queries the parameters of the module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {} + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/dymensionxyz/dymension/rollapp/params"; + } // Queries a Rollapp by index. - rpc Rollapp(QueryGetRollappRequest) returns (QueryGetRollappResponse) {} + rpc Rollapp(QueryGetRollappRequest) returns (QueryGetRollappResponse) { + option (google.api.http).get = + "/dymensionxyz/dymension/rollapp/rollapp/{rollappId}"; + } // Queries a Rollapp by index. rpc RollappByEIP155(QueryGetRollappByEIP155Request) - returns (QueryGetRollappResponse) {} + returns (QueryGetRollappResponse) { + option (google.api.http).get = + "/dymensionxyz/dymension/rollapp/eip155/{eip155}"; + } // Queries a list of Rollapp items. - rpc RollappAll(QueryAllRollappRequest) returns (QueryAllRollappResponse) {} + rpc RollappAll(QueryAllRollappRequest) returns (QueryAllRollappResponse) { + option (google.api.http).get = "/dymensionxyz/dymension/rollapp/rollapp"; + } // Queries a LatestHeight by rollapp-id. rpc LatestHeight(QueryGetLatestHeightRequest) - returns (QueryGetLatestHeightResponse) {} + returns (QueryGetLatestHeightResponse) { + option (google.api.http).get = + "/dymensionxyz/dymension/rollapp/latest_height/{rollappId}"; + } // Queries a LatestStateIndex by rollapp-id. rpc LatestStateIndex(QueryGetLatestStateIndexRequest) - returns (QueryGetLatestStateIndexResponse) {} + returns (QueryGetLatestStateIndexResponse) { + option (google.api.http).get = + "/dymensionxyz/dymension/rollapp/latest_state_index/{rollappId}"; + } // Queries a StateInfo by index. - rpc StateInfo(QueryGetStateInfoRequest) returns (QueryGetStateInfoResponse) {} + rpc StateInfo(QueryGetStateInfoRequest) returns (QueryGetStateInfoResponse) { + option (google.api.http).get = + "/dymensionxyz/dymension/rollapp/state_info/{rollappId}/{index}"; + } + + // Queries a list of registered denoms for the rollapp. + rpc RegisteredDenoms(QueryRegisteredDenomsRequest) returns (QueryRegisteredDenomsResponse) { + option (google.api.http).get = "/dymensionxyz/dymension/rollapp/registered_denoms"; + } + + // Queries a list of obsolete DRS versions. + rpc ObsoleteDRSVersions(QueryObsoleteDRSVersionsRequest) returns (QueryObsoleteDRSVersionsResponse) { + option (google.api.http).get = "/dymensionxyz/dymension/rollapp/obsolete_drs_versions"; + } } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -106,3 +133,17 @@ message QueryGetStateInfoRequest { message QueryGetStateInfoResponse { StateInfo stateInfo = 1 [ (gogoproto.nullable) = false ]; } + +message QueryRegisteredDenomsRequest { + string rollappId = 1; +} + +message QueryRegisteredDenomsResponse { + repeated string denoms = 1; +} + +message QueryObsoleteDRSVersionsRequest {} + +message QueryObsoleteDRSVersionsResponse { + repeated uint32 drs_versions = 1; +} From d76875f39225ec31978f94bcae9c1f5c21025af5 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 12:27:16 +0100 Subject: [PATCH 049/119] stop for next height is revision height also for fullnode --- block/fork.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/block/fork.go b/block/fork.go index 7fe32eb1b..bd5852a38 100644 --- a/block/fork.go +++ b/block/fork.go @@ -93,20 +93,12 @@ func (m *Manager) createInstruction(rollapp *types.Rollapp) error { // shouldStopNode determines if a rollapp node should be stopped based on revision criteria. // // This method checks two conditions to decide if a node should be stopped: -// 1. If the current state height is greater than or equal to the rollapp's revision start height, for fullnode, -// or whether the next state height is greater than or equal to the rollapp's revision start height for proposer. -// This differentiation is because in case no rollback is required, proposer still needs to stop just before the revision start height -// to enter the fork loop and upgrade. +// 1. If the next state height is greater than or equal to the rollapp's revision start height. // 2. If the block's app version (equivalent to revision) is less than the rollapp's revision func (m *Manager) shouldStopNode(rollapp *types.Rollapp, block *types.Block) bool { - var stopHeight uint64 - if m.RunMode == RunModeProposer { - stopHeight = m.State.NextHeight() - } else { - stopHeight = m.State.Height() - } + revision := block.Header.Version.App - if stopHeight >= rollapp.RevisionStartHeight && revision < rollapp.Revision { + if m.State.NextHeight() >= rollapp.RevisionStartHeight && revision < rollapp.Revision { m.logger.Info( "Freezing node due to fork update", "local_block_height", From b03343dba56dc079c5454889424d6a6f23d47eb4 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 12:55:50 +0100 Subject: [PATCH 050/119] rollapp query proto --- .../dymension/rollapp/query.proto | 53 +-- .../proto/google/api/annotations.proto | 0 third_party/proto/google/api/http.proto | 371 ++++++++++++++++++ .../dymension/rollapp/query.pb.go | 184 +++++---- 4 files changed, 474 insertions(+), 134 deletions(-) create mode 100644 third_party/proto/google/api/annotations.proto create mode 100644 third_party/proto/google/api/http.proto diff --git a/proto/types/dymensionxyz/dymension/rollapp/query.proto b/proto/types/dymensionxyz/dymension/rollapp/query.proto index 24dedab2d..feb4b4d73 100644 --- a/proto/types/dymensionxyz/dymension/rollapp/query.proto +++ b/proto/types/dymensionxyz/dymension/rollapp/query.proto @@ -1,69 +1,46 @@ syntax = "proto3"; package dymensionxyz.dymension.rollapp; -option go_package = "github.com/dymensionxyz/dymension/v3/x/rollapp/types"; +option go_package = "github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; -import "dymensionxyz/dymension/rollapp/params.proto"; -import "dymensionxyz/dymension/rollapp/rollapp.proto"; -import "dymensionxyz/dymension/rollapp/state_info.proto"; -import "dymensionxyz/dymension/rollapp/app.proto"; +import "types/cosmos/base/query/v1beta1/pagination.proto"; +import "types/dymensionxyz/dymension/rollapp/params.proto"; +import "types/dymensionxyz/dymension/rollapp/rollapp.proto"; +import "types/dymensionxyz/dymension/rollapp/state_info.proto"; +import "types/dymensionxyz/dymension/rollapp/app.proto"; // Query defines the gRPC querier service. service Query { // Parameters queries the parameters of the module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/dymensionxyz/dymension/rollapp/params"; - } + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {} // Queries a Rollapp by index. - rpc Rollapp(QueryGetRollappRequest) returns (QueryGetRollappResponse) { - option (google.api.http).get = - "/dymensionxyz/dymension/rollapp/rollapp/{rollappId}"; - } + rpc Rollapp(QueryGetRollappRequest) returns (QueryGetRollappResponse) { } // Queries a Rollapp by index. rpc RollappByEIP155(QueryGetRollappByEIP155Request) - returns (QueryGetRollappResponse) { - option (google.api.http).get = - "/dymensionxyz/dymension/rollapp/eip155/{eip155}"; - } + returns (QueryGetRollappResponse) {} // Queries a list of Rollapp items. - rpc RollappAll(QueryAllRollappRequest) returns (QueryAllRollappResponse) { - option (google.api.http).get = "/dymensionxyz/dymension/rollapp/rollapp"; - } + rpc RollappAll(QueryAllRollappRequest) returns (QueryAllRollappResponse) {} // Queries a LatestHeight by rollapp-id. rpc LatestHeight(QueryGetLatestHeightRequest) - returns (QueryGetLatestHeightResponse) { - option (google.api.http).get = - "/dymensionxyz/dymension/rollapp/latest_height/{rollappId}"; - } + returns (QueryGetLatestHeightResponse) {} // Queries a LatestStateIndex by rollapp-id. rpc LatestStateIndex(QueryGetLatestStateIndexRequest) - returns (QueryGetLatestStateIndexResponse) { - option (google.api.http).get = - "/dymensionxyz/dymension/rollapp/latest_state_index/{rollappId}"; - } + returns (QueryGetLatestStateIndexResponse) {} // Queries a StateInfo by index. - rpc StateInfo(QueryGetStateInfoRequest) returns (QueryGetStateInfoResponse) { - option (google.api.http).get = - "/dymensionxyz/dymension/rollapp/state_info/{rollappId}/{index}"; - } + rpc StateInfo(QueryGetStateInfoRequest) returns (QueryGetStateInfoResponse) {} // Queries a list of registered denoms for the rollapp. - rpc RegisteredDenoms(QueryRegisteredDenomsRequest) returns (QueryRegisteredDenomsResponse) { - option (google.api.http).get = "/dymensionxyz/dymension/rollapp/registered_denoms"; - } + rpc RegisteredDenoms(QueryRegisteredDenomsRequest) returns (QueryRegisteredDenomsResponse) {} // Queries a list of obsolete DRS versions. - rpc ObsoleteDRSVersions(QueryObsoleteDRSVersionsRequest) returns (QueryObsoleteDRSVersionsResponse) { - option (google.api.http).get = "/dymensionxyz/dymension/rollapp/obsolete_drs_versions"; - } + rpc ObsoleteDRSVersions(QueryObsoleteDRSVersionsRequest) returns (QueryObsoleteDRSVersionsResponse) {} } // QueryParamsRequest is request type for the Query/Params RPC method. diff --git a/third_party/proto/google/api/annotations.proto b/third_party/proto/google/api/annotations.proto new file mode 100644 index 000000000..e69de29bb diff --git a/third_party/proto/google/api/http.proto b/third_party/proto/google/api/http.proto new file mode 100644 index 000000000..c9b7fdc3f --- /dev/null +++ b/third_party/proto/google/api/http.proto @@ -0,0 +1,371 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "HttpProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +// Defines the HTTP configuration for an API service. It contains a list of +// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method +// to one or more HTTP REST API methods. +message Http { + // A list of HTTP configuration rules that apply to individual API methods. + // + // **NOTE:** All service configuration rules follow "last one wins" order. + repeated HttpRule rules = 1; + + // When set to true, URL path parameters will be fully URI-decoded except in + // cases of single segment matches in reserved expansion, where "%2F" will be + // left encoded. + // + // The default behavior is to not decode RFC 6570 reserved characters in multi + // segment matches. + bool fully_decode_reserved_expansion = 2; +} + +// gRPC Transcoding +// +// gRPC Transcoding is a feature for mapping between a gRPC method and one or +// more HTTP REST endpoints. It allows developers to build a single API service +// that supports both gRPC APIs and REST APIs. Many systems, including [Google +// APIs](https://github.com/googleapis/googleapis), +// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC +// Gateway](https://github.com/grpc-ecosystem/grpc-gateway), +// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature +// and use it for large scale production services. +// +// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies +// how different portions of the gRPC request message are mapped to the URL +// path, URL query parameters, and HTTP request body. It also controls how the +// gRPC response message is mapped to the HTTP response body. `HttpRule` is +// typically specified as an `google.api.http` annotation on the gRPC method. +// +// Each mapping specifies a URL path template and an HTTP method. The path +// template may refer to one or more fields in the gRPC request message, as long +// as each field is a non-repeated field with a primitive (non-message) type. +// The path template controls how fields of the request message are mapped to +// the URL path. +// +// Example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get: "/v1/{name=messages/*}" +// }; +// } +// } +// message GetMessageRequest { +// string name = 1; // Mapped to URL path. +// } +// message Message { +// string text = 1; // The resource content. +// } +// +// This enables an HTTP REST to gRPC mapping as below: +// +// - HTTP: `GET /v1/messages/123456` +// - gRPC: `GetMessage(name: "messages/123456")` +// +// Any fields in the request message which are not bound by the path template +// automatically become HTTP query parameters if there is no HTTP request body. +// For example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get:"/v1/messages/{message_id}" +// }; +// } +// } +// message GetMessageRequest { +// message SubMessage { +// string subfield = 1; +// } +// string message_id = 1; // Mapped to URL path. +// int64 revision = 2; // Mapped to URL query parameter `revision`. +// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. +// } +// +// This enables a HTTP JSON to RPC mapping as below: +// +// - HTTP: `GET /v1/messages/123456?revision=2&sub.subfield=foo` +// - gRPC: `GetMessage(message_id: "123456" revision: 2 sub: +// SubMessage(subfield: "foo"))` +// +// Note that fields which are mapped to URL query parameters must have a +// primitive type or a repeated primitive type or a non-repeated message type. +// In the case of a repeated type, the parameter can be repeated in the URL +// as `...?param=A¶m=B`. In the case of a message type, each field of the +// message is mapped to a separate parameter, such as +// `...?foo.a=A&foo.b=B&foo.c=C`. +// +// For HTTP methods that allow a request body, the `body` field +// specifies the mapping. Consider a REST update method on the +// message resource collection: +// +// service Messaging { +// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { +// option (google.api.http) = { +// patch: "/v1/messages/{message_id}" +// body: "message" +// }; +// } +// } +// message UpdateMessageRequest { +// string message_id = 1; // mapped to the URL +// Message message = 2; // mapped to the body +// } +// +// The following HTTP JSON to RPC mapping is enabled, where the +// representation of the JSON in the request body is determined by +// protos JSON encoding: +// +// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` +// - gRPC: `UpdateMessage(message_id: "123456" message { text: "Hi!" })` +// +// The special name `*` can be used in the body mapping to define that +// every field not bound by the path template should be mapped to the +// request body. This enables the following alternative definition of +// the update method: +// +// service Messaging { +// rpc UpdateMessage(Message) returns (Message) { +// option (google.api.http) = { +// patch: "/v1/messages/{message_id}" +// body: "*" +// }; +// } +// } +// message Message { +// string message_id = 1; +// string text = 2; +// } +// +// +// The following HTTP JSON to RPC mapping is enabled: +// +// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` +// - gRPC: `UpdateMessage(message_id: "123456" text: "Hi!")` +// +// Note that when using `*` in the body mapping, it is not possible to +// have HTTP parameters, as all fields not bound by the path end in +// the body. This makes this option more rarely used in practice when +// defining REST APIs. The common usage of `*` is in custom methods +// which don't use the URL at all for transferring data. +// +// It is possible to define multiple HTTP methods for one RPC by using +// the `additional_bindings` option. Example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get: "/v1/messages/{message_id}" +// additional_bindings { +// get: "/v1/users/{user_id}/messages/{message_id}" +// } +// }; +// } +// } +// message GetMessageRequest { +// string message_id = 1; +// string user_id = 2; +// } +// +// This enables the following two alternative HTTP JSON to RPC mappings: +// +// - HTTP: `GET /v1/messages/123456` +// - gRPC: `GetMessage(message_id: "123456")` +// +// - HTTP: `GET /v1/users/me/messages/123456` +// - gRPC: `GetMessage(user_id: "me" message_id: "123456")` +// +// Rules for HTTP mapping +// +// 1. Leaf request fields (recursive expansion nested messages in the request +// message) are classified into three categories: +// - Fields referred by the path template. They are passed via the URL path. +// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They +// are passed via the HTTP +// request body. +// - All other fields are passed via the URL query parameters, and the +// parameter name is the field path in the request message. A repeated +// field can be represented as multiple query parameters under the same +// name. +// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL +// query parameter, all fields +// are passed via URL path and HTTP request body. +// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP +// request body, all +// fields are passed via URL path and URL query parameters. +// +// Path template syntax +// +// Template = "/" Segments [ Verb ] ; +// Segments = Segment { "/" Segment } ; +// Segment = "*" | "**" | LITERAL | Variable ; +// Variable = "{" FieldPath [ "=" Segments ] "}" ; +// FieldPath = IDENT { "." IDENT } ; +// Verb = ":" LITERAL ; +// +// The syntax `*` matches a single URL path segment. The syntax `**` matches +// zero or more URL path segments, which must be the last part of the URL path +// except the `Verb`. +// +// The syntax `Variable` matches part of the URL path as specified by its +// template. A variable template must not contain other variables. If a variable +// matches a single path segment, its template may be omitted, e.g. `{var}` +// is equivalent to `{var=*}`. +// +// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` +// contains any reserved character, such characters should be percent-encoded +// before the matching. +// +// If a variable contains exactly one path segment, such as `"{var}"` or +// `"{var=*}"`, when such a variable is expanded into a URL path on the client +// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The +// server side does the reverse decoding. Such variables show up in the +// [Discovery +// Document](https://developers.google.com/discovery/v1/reference/apis) as +// `{var}`. +// +// If a variable contains multiple path segments, such as `"{var=foo/*}"` +// or `"{var=**}"`, when such a variable is expanded into a URL path on the +// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. +// The server side does the reverse decoding, except "%2F" and "%2f" are left +// unchanged. Such variables show up in the +// [Discovery +// Document](https://developers.google.com/discovery/v1/reference/apis) as +// `{+var}`. +// +// Using gRPC API Service Configuration +// +// gRPC API Service Configuration (service config) is a configuration language +// for configuring a gRPC service to become a user-facing product. The +// service config is simply the YAML representation of the `google.api.Service` +// proto message. +// +// As an alternative to annotating your proto file, you can configure gRPC +// transcoding in your service config YAML files. You do this by specifying a +// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same +// effect as the proto annotation. This can be particularly useful if you +// have a proto that is reused in multiple services. Note that any transcoding +// specified in the service config will override any matching transcoding +// configuration in the proto. +// +// The following example selects a gRPC method and applies an `HttpRule` to it: +// +// http: +// rules: +// - selector: example.v1.Messaging.GetMessage +// get: /v1/messages/{message_id}/{sub.subfield} +// +// Special notes +// +// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the +// proto to JSON conversion must follow the [proto3 +// specification](https://developers.google.com/protocol-buffers/docs/proto3#json). +// +// While the single segment variable follows the semantics of +// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String +// Expansion, the multi segment variable **does not** follow RFC 6570 Section +// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion +// does not expand special characters like `?` and `#`, which would lead +// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding +// for multi segment variables. +// +// The path variables **must not** refer to any repeated or mapped field, +// because client libraries are not capable of handling such variable expansion. +// +// The path variables **must not** capture the leading "/" character. The reason +// is that the most common use case "{var}" does not capture the leading "/" +// character. For consistency, all path variables must share the same behavior. +// +// Repeated message fields must not be mapped to URL query parameters, because +// no client library can support such complicated mapping. +// +// If an API needs to use a JSON array for request or response body, it can map +// the request or response body to a repeated field. However, some gRPC +// Transcoding implementations may not support this feature. +message HttpRule { + // Selects a method to which this rule applies. + // + // Refer to [selector][google.api.DocumentationRule.selector] for syntax + // details. + string selector = 1; + + // Determines the URL pattern is matched by this rules. This pattern can be + // used with any of the {get|put|post|delete|patch} methods. A custom method + // can be defined using the 'custom' field. + oneof pattern { + // Maps to HTTP GET. Used for listing and getting information about + // resources. + string get = 2; + + // Maps to HTTP PUT. Used for replacing a resource. + string put = 3; + + // Maps to HTTP POST. Used for creating a resource or performing an action. + string post = 4; + + // Maps to HTTP DELETE. Used for deleting a resource. + string delete = 5; + + // Maps to HTTP PATCH. Used for updating a resource. + string patch = 6; + + // The custom pattern is used for specifying an HTTP method that is not + // included in the `pattern` field, such as HEAD, or "*" to leave the + // HTTP method unspecified for this rule. The wild-card rule is useful + // for services that provide content to Web (HTML) clients. + CustomHttpPattern custom = 8; + } + + // The name of the request field whose value is mapped to the HTTP request + // body, or `*` for mapping all request fields not captured by the path + // pattern to the HTTP body, or omitted for not having any HTTP request body. + // + // NOTE: the referred field must be present at the top-level of the request + // message type. + string body = 7; + + // Optional. The name of the response field whose value is mapped to the HTTP + // response body. When omitted, the entire response message will be used + // as the HTTP response body. + // + // NOTE: The referred field must be present at the top-level of the response + // message type. + string response_body = 12; + + // Additional HTTP bindings for the selector. Nested bindings must + // not contain an `additional_bindings` field themselves (that is, + // the nesting may only be one level deep). + repeated HttpRule additional_bindings = 11; +} + +// A custom pattern is used for defining custom HTTP verb. +message CustomHttpPattern { + // The name of this custom HTTP verb. + string kind = 1; + + // The path matched by this custom verb. + string path = 2; +} \ No newline at end of file diff --git a/types/pb/dymensionxyz/dymension/rollapp/query.pb.go b/types/pb/dymensionxyz/dymension/rollapp/query.pb.go index 29f21ace4..9e104b457 100644 --- a/types/pb/dymensionxyz/dymension/rollapp/query.pb.go +++ b/types/pb/dymensionxyz/dymension/rollapp/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: dymensionxyz/dymension/rollapp/query.proto +// source: types/dymensionxyz/dymension/rollapp/query.proto package rollapp @@ -7,13 +7,13 @@ import ( context "context" fmt "fmt" query "github.com/cosmos/cosmos-sdk/types/query" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + _ "google/api" io "io" math "math" math_bits "math/bits" @@ -38,7 +38,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{0} + return fileDescriptor_20818724c4f98326, []int{0} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -77,7 +77,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{1} + return fileDescriptor_20818724c4f98326, []int{1} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -123,7 +123,7 @@ func (m *QueryGetRollappRequest) Reset() { *m = QueryGetRollappRequest{} func (m *QueryGetRollappRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetRollappRequest) ProtoMessage() {} func (*QueryGetRollappRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{2} + return fileDescriptor_20818724c4f98326, []int{2} } func (m *QueryGetRollappRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -176,7 +176,7 @@ func (m *QueryGetRollappByEIP155Request) Reset() { *m = QueryGetRollappB func (m *QueryGetRollappByEIP155Request) String() string { return proto.CompactTextString(m) } func (*QueryGetRollappByEIP155Request) ProtoMessage() {} func (*QueryGetRollappByEIP155Request) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{3} + return fileDescriptor_20818724c4f98326, []int{3} } func (m *QueryGetRollappByEIP155Request) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -228,7 +228,7 @@ func (m *QueryGetLatestHeightRequest) Reset() { *m = QueryGetLatestHeigh func (m *QueryGetLatestHeightRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetLatestHeightRequest) ProtoMessage() {} func (*QueryGetLatestHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{4} + return fileDescriptor_20818724c4f98326, []int{4} } func (m *QueryGetLatestHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -279,7 +279,7 @@ func (m *QueryGetLatestHeightResponse) Reset() { *m = QueryGetLatestHeig func (m *QueryGetLatestHeightResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetLatestHeightResponse) ProtoMessage() {} func (*QueryGetLatestHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{5} + return fileDescriptor_20818724c4f98326, []int{5} } func (m *QueryGetLatestHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -324,7 +324,7 @@ func (m *QueryGetLatestStateIndexRequest) Reset() { *m = QueryGetLatestS func (m *QueryGetLatestStateIndexRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetLatestStateIndexRequest) ProtoMessage() {} func (*QueryGetLatestStateIndexRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{6} + return fileDescriptor_20818724c4f98326, []int{6} } func (m *QueryGetLatestStateIndexRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -375,7 +375,7 @@ func (m *QueryGetLatestStateIndexResponse) Reset() { *m = QueryGetLatest func (m *QueryGetLatestStateIndexResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetLatestStateIndexResponse) ProtoMessage() {} func (*QueryGetLatestStateIndexResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{7} + return fileDescriptor_20818724c4f98326, []int{7} } func (m *QueryGetLatestStateIndexResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -422,7 +422,7 @@ func (m *QueryGetRollappResponse) Reset() { *m = QueryGetRollappResponse func (m *QueryGetRollappResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetRollappResponse) ProtoMessage() {} func (*QueryGetRollappResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{8} + return fileDescriptor_20818724c4f98326, []int{8} } func (m *QueryGetRollappResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -482,7 +482,7 @@ func (m *QueryAllRollappRequest) Reset() { *m = QueryAllRollappRequest{} func (m *QueryAllRollappRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllRollappRequest) ProtoMessage() {} func (*QueryAllRollappRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{9} + return fileDescriptor_20818724c4f98326, []int{9} } func (m *QueryAllRollappRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -534,7 +534,7 @@ func (m *QueryAllRollappResponse) Reset() { *m = QueryAllRollappResponse func (m *QueryAllRollappResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllRollappResponse) ProtoMessage() {} func (*QueryAllRollappResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{10} + return fileDescriptor_20818724c4f98326, []int{10} } func (m *QueryAllRollappResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -588,7 +588,7 @@ func (m *QueryGetStateInfoRequest) Reset() { *m = QueryGetStateInfoReque func (m *QueryGetStateInfoRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetStateInfoRequest) ProtoMessage() {} func (*QueryGetStateInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{11} + return fileDescriptor_20818724c4f98326, []int{11} } func (m *QueryGetStateInfoRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -653,7 +653,7 @@ func (m *QueryGetStateInfoResponse) Reset() { *m = QueryGetStateInfoResp func (m *QueryGetStateInfoResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetStateInfoResponse) ProtoMessage() {} func (*QueryGetStateInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{12} + return fileDescriptor_20818724c4f98326, []int{12} } func (m *QueryGetStateInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -697,7 +697,7 @@ func (m *QueryRegisteredDenomsRequest) Reset() { *m = QueryRegisteredDen func (m *QueryRegisteredDenomsRequest) String() string { return proto.CompactTextString(m) } func (*QueryRegisteredDenomsRequest) ProtoMessage() {} func (*QueryRegisteredDenomsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{13} + return fileDescriptor_20818724c4f98326, []int{13} } func (m *QueryRegisteredDenomsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -741,7 +741,7 @@ func (m *QueryRegisteredDenomsResponse) Reset() { *m = QueryRegisteredDe func (m *QueryRegisteredDenomsResponse) String() string { return proto.CompactTextString(m) } func (*QueryRegisteredDenomsResponse) ProtoMessage() {} func (*QueryRegisteredDenomsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{14} + return fileDescriptor_20818724c4f98326, []int{14} } func (m *QueryRegisteredDenomsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -784,7 +784,7 @@ func (m *QueryObsoleteDRSVersionsRequest) Reset() { *m = QueryObsoleteDR func (m *QueryObsoleteDRSVersionsRequest) String() string { return proto.CompactTextString(m) } func (*QueryObsoleteDRSVersionsRequest) ProtoMessage() {} func (*QueryObsoleteDRSVersionsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{15} + return fileDescriptor_20818724c4f98326, []int{15} } func (m *QueryObsoleteDRSVersionsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -821,7 +821,7 @@ func (m *QueryObsoleteDRSVersionsResponse) Reset() { *m = QueryObsoleteD func (m *QueryObsoleteDRSVersionsResponse) String() string { return proto.CompactTextString(m) } func (*QueryObsoleteDRSVersionsResponse) ProtoMessage() {} func (*QueryObsoleteDRSVersionsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_00a0238fb38306fa, []int{16} + return fileDescriptor_20818724c4f98326, []int{16} } func (m *QueryObsoleteDRSVersionsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -878,79 +878,71 @@ func init() { } func init() { - proto.RegisterFile("dymensionxyz/dymension/rollapp/query.proto", fileDescriptor_00a0238fb38306fa) -} - -var fileDescriptor_00a0238fb38306fa = []byte{ - // 1078 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0x38, 0xae, 0x13, 0xbf, 0xb4, 0x22, 0x9a, 0x46, 0x21, 0xb8, 0xc1, 0x75, 0x17, 0xa9, - 0x75, 0x0b, 0xda, 0x95, 0x63, 0xdc, 0x10, 0xa5, 0x29, 0x75, 0x94, 0x36, 0xa4, 0x82, 0x12, 0x36, - 0xfc, 0x11, 0x20, 0x64, 0xad, 0xeb, 0x89, 0xb3, 0x68, 0xbd, 0xbb, 0xf5, 0x6c, 0x22, 0xbb, 0x51, - 0x2e, 0x88, 0x0f, 0x80, 0xc4, 0x27, 0xe0, 0x0b, 0x70, 0xe5, 0x8c, 0xb8, 0x44, 0x88, 0x43, 0x25, - 0x0e, 0x70, 0x01, 0xa1, 0x84, 0xef, 0xc0, 0x09, 0x09, 0x79, 0xe6, 0xed, 0x7a, 0xed, 0xd8, 0xde, - 0xb5, 0xc5, 0xc9, 0x99, 0xc9,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ca, 0x41, 0x90, - 0x4a, 0x78, 0x24, 0x6e, 0x3e, 0x39, 0x3d, 0xcb, 0x92, 0x17, 0x67, 0x59, 0xf2, 0xd7, 0x59, 0x96, - 0x7c, 0x73, 0x9e, 0x9d, 0x7a, 0x71, 0x9e, 0x9d, 0xfa, 0xfd, 0x3c, 0x3b, 0xf5, 0xd9, 0x9b, 0x75, - 0xd3, 0x3b, 0x38, 0xac, 0xaa, 0x4f, 0x9d, 0xc6, 0x30, 0xe8, 0xa3, 0xa2, 0xd6, 0x0a, 0xf0, 0xbd, - 0xb6, 0xcb, 0x78, 0x35, 0x25, 0x3e, 0xf9, 0x8a, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xce, - 0xc4, 0xdb, 0x56, 0x0f, 0x00, 0x00, + proto.RegisterFile("types/dymensionxyz/dymension/rollapp/query.proto", fileDescriptor_20818724c4f98326) +} + +var fileDescriptor_20818724c4f98326 = []byte{ + // 956 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xf6, 0x38, 0xae, 0x13, 0xbf, 0x14, 0x11, 0x4d, 0xa3, 0x60, 0xdc, 0xe0, 0xba, 0x8b, 0x04, + 0xe1, 0xb2, 0x8b, 0x5d, 0xb9, 0x05, 0xd1, 0x02, 0x89, 0xd2, 0x86, 0x54, 0xfc, 0x08, 0x1b, 0x7e, + 0x08, 0x10, 0x0a, 0xeb, 0x7a, 0xb2, 0x59, 0xb4, 0xde, 0xd9, 0xee, 0x4c, 0xaa, 0xb8, 0x02, 0x21, + 0x21, 0x6e, 0x70, 0x80, 0x13, 0x12, 0xff, 0x0d, 0xb7, 0x1e, 0x7b, 0xe4, 0x84, 0x50, 0x72, 0xe1, + 0x3f, 0xe0, 0x8a, 0x3c, 0xfb, 0x76, 0x6d, 0xaf, 0x7f, 0x8d, 0x0d, 0x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 0xec, 0xf3, 0x48, 0xdf, 0x9a, 0x8f, 0x74, 0xe4, 0xdd, 0xae, 0xbc, 0xbd, 0x38, 0x41, + 0xaa, 0xec, 0x7b, 0x02, 0xa5, 0xd4, 0x34, 0xe8, 0x6b, 0xba, 0x8c, 0x59, 0xcf, 0xac, 0xbc, 0xbe, + 0x00, 0x32, 0x15, 0xf1, 0x0b, 0x81, 0xb5, 0xac, 0xb1, 0x50, 0xbd, 0x33, 0x9f, 0xe0, 0x66, 0x95, + 0x3b, 0x0b, 0xa2, 0x53, 0x4d, 0xbf, 0x11, 0xb8, 0x32, 0xc6, 0x90, 0x34, 0x6f, 0x6d, 0xb2, 0xdb, + 0x69, 0xde, 0xda, 0x14, 0x2f, 0x34, 0x72, 0x3b, 0x5f, 0x3d, 0x39, 0xaf, 0x92, 0xa7, 0xe7, 0x55, + 0xf2, 0xd7, 0x79, 0x95, 0xfc, 0x7c, 0x51, 0xcd, 0x3d, 0xbd, 0xa8, 0xe6, 0xfe, 0xb8, 0xa8, 0xe6, + 0x3e, 0xbf, 0xe7, 0x7a, 0xf2, 0xe4, 0xb4, 0x65, 0x3e, 0xe0, 0x9d, 0x91, 0xaf, 0x7a, 0x2f, 0x90, + 0x56, 0xfc, 0xbd, 0x1f, 0xb6, 0x66, 0x7c, 0xf2, 0xb7, 0x8a, 0xea, 0x7b, 0xff, 0xc6, 0xbf, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x73, 0x92, 0x99, 0x0b, 0x77, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1336,7 +1328,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "dymensionxyz/dymension/rollapp/query.proto", + Metadata: "types/dymensionxyz/dymension/rollapp/query.proto", } func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { From ed21ee976c68a5e8cc2f4536e10546e656177c70 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 13:03:14 +0100 Subject: [PATCH 051/119] proto fix --- .../dymension/rollapp/query.proto | 1 - .../proto/google/api/annotations.proto | 0 third_party/proto/google/api/http.proto | 371 ------------------ .../dymension/rollapp/query.pb.go | 122 +++--- 4 files changed, 60 insertions(+), 434 deletions(-) delete mode 100644 third_party/proto/google/api/annotations.proto delete mode 100644 third_party/proto/google/api/http.proto diff --git a/proto/types/dymensionxyz/dymension/rollapp/query.proto b/proto/types/dymensionxyz/dymension/rollapp/query.proto index feb4b4d73..49d214e15 100644 --- a/proto/types/dymensionxyz/dymension/rollapp/query.proto +++ b/proto/types/dymensionxyz/dymension/rollapp/query.proto @@ -4,7 +4,6 @@ package dymensionxyz.dymension.rollapp; option go_package = "github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp"; import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; import "types/cosmos/base/query/v1beta1/pagination.proto"; import "types/dymensionxyz/dymension/rollapp/params.proto"; import "types/dymensionxyz/dymension/rollapp/rollapp.proto"; diff --git a/third_party/proto/google/api/annotations.proto b/third_party/proto/google/api/annotations.proto deleted file mode 100644 index e69de29bb..000000000 diff --git a/third_party/proto/google/api/http.proto b/third_party/proto/google/api/http.proto deleted file mode 100644 index c9b7fdc3f..000000000 --- a/third_party/proto/google/api/http.proto +++ /dev/null @@ -1,371 +0,0 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "HttpProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -// Defines the HTTP configuration for an API service. It contains a list of -// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method -// to one or more HTTP REST API methods. -message Http { - // A list of HTTP configuration rules that apply to individual API methods. - // - // **NOTE:** All service configuration rules follow "last one wins" order. - repeated HttpRule rules = 1; - - // When set to true, URL path parameters will be fully URI-decoded except in - // cases of single segment matches in reserved expansion, where "%2F" will be - // left encoded. - // - // The default behavior is to not decode RFC 6570 reserved characters in multi - // segment matches. - bool fully_decode_reserved_expansion = 2; -} - -// gRPC Transcoding -// -// gRPC Transcoding is a feature for mapping between a gRPC method and one or -// more HTTP REST endpoints. It allows developers to build a single API service -// that supports both gRPC APIs and REST APIs. Many systems, including [Google -// APIs](https://github.com/googleapis/googleapis), -// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC -// Gateway](https://github.com/grpc-ecosystem/grpc-gateway), -// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature -// and use it for large scale production services. -// -// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies -// how different portions of the gRPC request message are mapped to the URL -// path, URL query parameters, and HTTP request body. It also controls how the -// gRPC response message is mapped to the HTTP response body. `HttpRule` is -// typically specified as an `google.api.http` annotation on the gRPC method. -// -// Each mapping specifies a URL path template and an HTTP method. The path -// template may refer to one or more fields in the gRPC request message, as long -// as each field is a non-repeated field with a primitive (non-message) type. -// The path template controls how fields of the request message are mapped to -// the URL path. -// -// Example: -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http) = { -// get: "/v1/{name=messages/*}" -// }; -// } -// } -// message GetMessageRequest { -// string name = 1; // Mapped to URL path. -// } -// message Message { -// string text = 1; // The resource content. -// } -// -// This enables an HTTP REST to gRPC mapping as below: -// -// - HTTP: `GET /v1/messages/123456` -// - gRPC: `GetMessage(name: "messages/123456")` -// -// Any fields in the request message which are not bound by the path template -// automatically become HTTP query parameters if there is no HTTP request body. -// For example: -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http) = { -// get:"/v1/messages/{message_id}" -// }; -// } -// } -// message GetMessageRequest { -// message SubMessage { -// string subfield = 1; -// } -// string message_id = 1; // Mapped to URL path. -// int64 revision = 2; // Mapped to URL query parameter `revision`. -// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. -// } -// -// This enables a HTTP JSON to RPC mapping as below: -// -// - HTTP: `GET /v1/messages/123456?revision=2&sub.subfield=foo` -// - gRPC: `GetMessage(message_id: "123456" revision: 2 sub: -// SubMessage(subfield: "foo"))` -// -// Note that fields which are mapped to URL query parameters must have a -// primitive type or a repeated primitive type or a non-repeated message type. -// In the case of a repeated type, the parameter can be repeated in the URL -// as `...?param=A¶m=B`. In the case of a message type, each field of the -// message is mapped to a separate parameter, such as -// `...?foo.a=A&foo.b=B&foo.c=C`. -// -// For HTTP methods that allow a request body, the `body` field -// specifies the mapping. Consider a REST update method on the -// message resource collection: -// -// service Messaging { -// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { -// option (google.api.http) = { -// patch: "/v1/messages/{message_id}" -// body: "message" -// }; -// } -// } -// message UpdateMessageRequest { -// string message_id = 1; // mapped to the URL -// Message message = 2; // mapped to the body -// } -// -// The following HTTP JSON to RPC mapping is enabled, where the -// representation of the JSON in the request body is determined by -// protos JSON encoding: -// -// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` -// - gRPC: `UpdateMessage(message_id: "123456" message { text: "Hi!" })` -// -// The special name `*` can be used in the body mapping to define that -// every field not bound by the path template should be mapped to the -// request body. This enables the following alternative definition of -// the update method: -// -// service Messaging { -// rpc UpdateMessage(Message) returns (Message) { -// option (google.api.http) = { -// patch: "/v1/messages/{message_id}" -// body: "*" -// }; -// } -// } -// message Message { -// string message_id = 1; -// string text = 2; -// } -// -// -// The following HTTP JSON to RPC mapping is enabled: -// -// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` -// - gRPC: `UpdateMessage(message_id: "123456" text: "Hi!")` -// -// Note that when using `*` in the body mapping, it is not possible to -// have HTTP parameters, as all fields not bound by the path end in -// the body. This makes this option more rarely used in practice when -// defining REST APIs. The common usage of `*` is in custom methods -// which don't use the URL at all for transferring data. -// -// It is possible to define multiple HTTP methods for one RPC by using -// the `additional_bindings` option. Example: -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http) = { -// get: "/v1/messages/{message_id}" -// additional_bindings { -// get: "/v1/users/{user_id}/messages/{message_id}" -// } -// }; -// } -// } -// message GetMessageRequest { -// string message_id = 1; -// string user_id = 2; -// } -// -// This enables the following two alternative HTTP JSON to RPC mappings: -// -// - HTTP: `GET /v1/messages/123456` -// - gRPC: `GetMessage(message_id: "123456")` -// -// - HTTP: `GET /v1/users/me/messages/123456` -// - gRPC: `GetMessage(user_id: "me" message_id: "123456")` -// -// Rules for HTTP mapping -// -// 1. Leaf request fields (recursive expansion nested messages in the request -// message) are classified into three categories: -// - Fields referred by the path template. They are passed via the URL path. -// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They -// are passed via the HTTP -// request body. -// - All other fields are passed via the URL query parameters, and the -// parameter name is the field path in the request message. A repeated -// field can be represented as multiple query parameters under the same -// name. -// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL -// query parameter, all fields -// are passed via URL path and HTTP request body. -// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP -// request body, all -// fields are passed via URL path and URL query parameters. -// -// Path template syntax -// -// Template = "/" Segments [ Verb ] ; -// Segments = Segment { "/" Segment } ; -// Segment = "*" | "**" | LITERAL | Variable ; -// Variable = "{" FieldPath [ "=" Segments ] "}" ; -// FieldPath = IDENT { "." IDENT } ; -// Verb = ":" LITERAL ; -// -// The syntax `*` matches a single URL path segment. The syntax `**` matches -// zero or more URL path segments, which must be the last part of the URL path -// except the `Verb`. -// -// The syntax `Variable` matches part of the URL path as specified by its -// template. A variable template must not contain other variables. If a variable -// matches a single path segment, its template may be omitted, e.g. `{var}` -// is equivalent to `{var=*}`. -// -// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` -// contains any reserved character, such characters should be percent-encoded -// before the matching. -// -// If a variable contains exactly one path segment, such as `"{var}"` or -// `"{var=*}"`, when such a variable is expanded into a URL path on the client -// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The -// server side does the reverse decoding. Such variables show up in the -// [Discovery -// Document](https://developers.google.com/discovery/v1/reference/apis) as -// `{var}`. -// -// If a variable contains multiple path segments, such as `"{var=foo/*}"` -// or `"{var=**}"`, when such a variable is expanded into a URL path on the -// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. -// The server side does the reverse decoding, except "%2F" and "%2f" are left -// unchanged. Such variables show up in the -// [Discovery -// Document](https://developers.google.com/discovery/v1/reference/apis) as -// `{+var}`. -// -// Using gRPC API Service Configuration -// -// gRPC API Service Configuration (service config) is a configuration language -// for configuring a gRPC service to become a user-facing product. The -// service config is simply the YAML representation of the `google.api.Service` -// proto message. -// -// As an alternative to annotating your proto file, you can configure gRPC -// transcoding in your service config YAML files. You do this by specifying a -// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same -// effect as the proto annotation. This can be particularly useful if you -// have a proto that is reused in multiple services. Note that any transcoding -// specified in the service config will override any matching transcoding -// configuration in the proto. -// -// The following example selects a gRPC method and applies an `HttpRule` to it: -// -// http: -// rules: -// - selector: example.v1.Messaging.GetMessage -// get: /v1/messages/{message_id}/{sub.subfield} -// -// Special notes -// -// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the -// proto to JSON conversion must follow the [proto3 -// specification](https://developers.google.com/protocol-buffers/docs/proto3#json). -// -// While the single segment variable follows the semantics of -// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String -// Expansion, the multi segment variable **does not** follow RFC 6570 Section -// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion -// does not expand special characters like `?` and `#`, which would lead -// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding -// for multi segment variables. -// -// The path variables **must not** refer to any repeated or mapped field, -// because client libraries are not capable of handling such variable expansion. -// -// The path variables **must not** capture the leading "/" character. The reason -// is that the most common use case "{var}" does not capture the leading "/" -// character. For consistency, all path variables must share the same behavior. -// -// Repeated message fields must not be mapped to URL query parameters, because -// no client library can support such complicated mapping. -// -// If an API needs to use a JSON array for request or response body, it can map -// the request or response body to a repeated field. However, some gRPC -// Transcoding implementations may not support this feature. -message HttpRule { - // Selects a method to which this rule applies. - // - // Refer to [selector][google.api.DocumentationRule.selector] for syntax - // details. - string selector = 1; - - // Determines the URL pattern is matched by this rules. This pattern can be - // used with any of the {get|put|post|delete|patch} methods. A custom method - // can be defined using the 'custom' field. - oneof pattern { - // Maps to HTTP GET. Used for listing and getting information about - // resources. - string get = 2; - - // Maps to HTTP PUT. Used for replacing a resource. - string put = 3; - - // Maps to HTTP POST. Used for creating a resource or performing an action. - string post = 4; - - // Maps to HTTP DELETE. Used for deleting a resource. - string delete = 5; - - // Maps to HTTP PATCH. Used for updating a resource. - string patch = 6; - - // The custom pattern is used for specifying an HTTP method that is not - // included in the `pattern` field, such as HEAD, or "*" to leave the - // HTTP method unspecified for this rule. The wild-card rule is useful - // for services that provide content to Web (HTML) clients. - CustomHttpPattern custom = 8; - } - - // The name of the request field whose value is mapped to the HTTP request - // body, or `*` for mapping all request fields not captured by the path - // pattern to the HTTP body, or omitted for not having any HTTP request body. - // - // NOTE: the referred field must be present at the top-level of the request - // message type. - string body = 7; - - // Optional. The name of the response field whose value is mapped to the HTTP - // response body. When omitted, the entire response message will be used - // as the HTTP response body. - // - // NOTE: The referred field must be present at the top-level of the response - // message type. - string response_body = 12; - - // Additional HTTP bindings for the selector. Nested bindings must - // not contain an `additional_bindings` field themselves (that is, - // the nesting may only be one level deep). - repeated HttpRule additional_bindings = 11; -} - -// A custom pattern is used for defining custom HTTP verb. -message CustomHttpPattern { - // The name of this custom HTTP verb. - string kind = 1; - - // The path matched by this custom verb. - string path = 2; -} \ No newline at end of file diff --git a/types/pb/dymensionxyz/dymension/rollapp/query.pb.go b/types/pb/dymensionxyz/dymension/rollapp/query.pb.go index 9e104b457..72feab839 100644 --- a/types/pb/dymensionxyz/dymension/rollapp/query.pb.go +++ b/types/pb/dymensionxyz/dymension/rollapp/query.pb.go @@ -13,7 +13,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - _ "google/api" io "io" math "math" math_bits "math/bits" @@ -882,67 +881,66 @@ func init() { } var fileDescriptor_20818724c4f98326 = []byte{ - // 956 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xf6, 0x38, 0xae, 0x13, 0xbf, 0x14, 0x11, 0x4d, 0xa3, 0x60, 0xdc, 0xe0, 0xba, 0x8b, 0x04, - 0xe1, 0xb2, 0x8b, 0x5d, 0xb9, 0x05, 0xd1, 0x02, 0x89, 0xd2, 0x86, 0x54, 0xfc, 0x08, 0x1b, 0x7e, - 0x08, 0x10, 0x0a, 0xeb, 0x7a, 0xb2, 0x59, 0xb4, 0xde, 0xd9, 0xee, 0x4c, 0xaa, 0xb8, 0x02, 0x21, - 0x21, 0x6e, 0x70, 0x80, 0x13, 0x12, 0xff, 0x0d, 0xb7, 0x1e, 0x7b, 0xe4, 0x84, 0x50, 0x72, 0xe1, - 0x3f, 0xe0, 0x8a, 0x3c, 0xfb, 0x76, 0x6d, 0xaf, 0x7f, 0x8d, 0x0d, 0xa7, 0x64, 0x9e, 0xe7, 0xfb, - 0xde, 0xf7, 0x66, 0xde, 0xfb, 0x66, 0xe1, 0x55, 0xd9, 0x0d, 0x99, 0xb0, 0xda, 0xdd, 0x0e, 0x0b, - 0x84, 0xc7, 0x83, 0xb3, 0xee, 0xe3, 0xfe, 0xc2, 0x8a, 0xb8, 0xef, 0x3b, 0x61, 0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0x0b, 0x81, 0xb5, 0xac, 0xb1, 0x50, 0xbd, 0x33, 0x9f, 0xe0, 0x66, 0x95, - 0x3b, 0x0b, 0xa2, 0x53, 0x4d, 0xbf, 0x11, 0xb8, 0x32, 0xc6, 0x90, 0x34, 0x6f, 0x6d, 0xb2, 0xdb, - 0x69, 0xde, 0xda, 0x14, 0x2f, 0x34, 0x72, 0x3b, 0x5f, 0x3d, 0x39, 0xaf, 0x92, 0xa7, 0xe7, 0x55, - 0xf2, 0xd7, 0x79, 0x95, 0xfc, 0x7c, 0x51, 0xcd, 0x3d, 0xbd, 0xa8, 0xe6, 0xfe, 0xb8, 0xa8, 0xe6, - 0x3e, 0xbf, 0xe7, 0x7a, 0xf2, 0xe4, 0xb4, 0x65, 0x3e, 0xe0, 0x9d, 0x91, 0xaf, 0x7a, 0x2f, 0x90, - 0x56, 0xfc, 0xbd, 0x1f, 0xb6, 0x66, 0x7c, 0xf2, 0xb7, 0x8a, 0xea, 0x7b, 0xff, 0xc6, 0xbf, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x73, 0x92, 0x99, 0x0b, 0x77, 0x0d, 0x00, 0x00, + // 938 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcd, 0x6f, 0x1b, 0x45, + 0x14, 0xf7, 0x38, 0xae, 0x13, 0xbf, 0x14, 0x11, 0x4d, 0xa3, 0x60, 0xdc, 0xe0, 0xba, 0x83, 0x04, + 0xe1, 0xb2, 0xc6, 0xae, 0xdc, 0x82, 0x68, 0x81, 0x44, 0x69, 0x43, 0x2a, 0x3e, 0xc2, 0x86, 0x0f, + 0x01, 0x42, 0x61, 0x5d, 0x4f, 0x9c, 0x45, 0xf6, 0xee, 0x76, 0x67, 0x52, 0xc5, 0x15, 0x08, 0x09, + 0x71, 0x83, 0x03, 0x9c, 0x90, 0xf8, 0x6f, 0xb8, 0xf5, 0xd8, 0x23, 0x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e, 0xec, 0xed, 0xd2, 0xdb, 0x8b, 0x13, 0xc4, 0x91, 0x7d, + 0x4f, 0xa0, 0x10, 0x8b, 0x06, 0x7d, 0xcd, 0x94, 0x31, 0xad, 0x99, 0xa5, 0xd7, 0x17, 0x40, 0xc6, + 0x41, 0xfc, 0x42, 0x60, 0x2d, 0x2d, 0x2c, 0xd4, 0xac, 0xe6, 0x13, 0xd4, 0xac, 0x74, 0x67, 0x41, + 0x74, 0x1c, 0xd3, 0x6f, 0x04, 0xae, 0x8c, 0x11, 0x24, 0xc3, 0x57, 0x9b, 0xac, 0x76, 0x86, 0xaf, + 0x36, 0x45, 0x0b, 0x59, 0x66, 0xe7, 0xab, 0x27, 0xe7, 0x65, 0xf2, 0xf4, 0xbc, 0x4c, 0xfe, 0x3a, + 0x2f, 0x93, 0x9f, 0x2f, 0xca, 0x99, 0xa7, 0x17, 0xe5, 0xcc, 0x1f, 0x17, 0xe5, 0xcc, 0xe7, 0xf7, + 0xda, 0xae, 0x3c, 0x39, 0x6d, 0x5a, 0x0f, 0xfc, 0xee, 0xc8, 0x57, 0xbd, 0xeb, 0xc9, 0xaa, 0xfe, + 0xde, 0x0f, 0x9a, 0x33, 0x3e, 0xf9, 0x9b, 0x79, 0xf5, 0xbd, 0x7f, 0xe3, 0xdf, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xf2, 0xe2, 0x5c, 0x94, 0x59, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. From dd744b9550d7eb8c6b8263495763fbfe8f2cb784 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 14:39:57 +0100 Subject: [PATCH 052/119] addressing comments --- block/fork_test.go | 4 ---- settlement/grpc/grpc.go | 7 +++++-- types/state_info.go | 5 ----- 3 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 types/state_info.go diff --git a/block/fork_test.go b/block/fork_test.go index 218585f1b..967688ae9 100644 --- a/block/fork_test.go +++ b/block/fork_test.go @@ -178,10 +178,6 @@ func TestMonitorForkUpdate(t *testing.T) { }, }, nil) - mockSL.On("GetStateInfo", uint64(100)).Return(&types.StateInfo{ - NextProposer: "sequencer1", - }, nil) - logger := log.NewNopLogger() pubsubServer := pubsub.NewServer() diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index 96b1ed38d..c00c7aba2 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -52,8 +52,11 @@ type Client struct { } func (c *Client) GetRollapp() (*types.Rollapp, error) { - // TODO implement me - panic("implement me") + return &types.Rollapp{ + RollappID: c.rollappID, + Revision: 0, + RevisionStartHeight: 1, + }, nil } // GetObsoleteDrs returns the list of deprecated DRS. diff --git a/types/state_info.go b/types/state_info.go deleted file mode 100644 index 35a2ae4d3..000000000 --- a/types/state_info.go +++ /dev/null @@ -1,5 +0,0 @@ -package types - -type StateInfo struct { - NextProposer string -} From 476e0a623f99d18b85e2ed23fed93467c3fe783d Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 14:41:00 +0100 Subject: [PATCH 053/119] addressing comments --- go.mod | 1 - 1 file changed, 1 deletion(-) diff --git a/go.mod b/go.mod index 09eb6eb23..b3dafd634 100644 --- a/go.mod +++ b/go.mod @@ -297,7 +297,6 @@ 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 => ../dymension-rdk 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 From b5827fb80a34dc4f6b212816a054c2735e8ad153 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 14:49:22 +0100 Subject: [PATCH 054/119] fixme --- block/fork.go | 1 + types/validation.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/block/fork.go b/block/fork.go index bd5852a38..29c5c8f55 100644 --- a/block/fork.go +++ b/block/fork.go @@ -127,6 +127,7 @@ func (m *Manager) forkNeeded() (types.Instruction, bool) { // handleSequencerForkTransition handles the sequencer fork transition func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { + consensusMsgs, err := m.prepareDRSUpgradeMessages(instruction.FaultyDRS) if err != nil { panic(fmt.Sprintf("prepare DRS upgrade messages: %v", err)) diff --git a/types/validation.go b/types/validation.go index dcf6eb324..a23a3e780 100644 --- a/types/validation.go +++ b/types/validation.go @@ -67,6 +67,8 @@ func (b *Block) ValidateWithState(state *State) error { return NewErrTimeFraud(b, currentTime) } + // FIXME(srene): temporary solution for hardfork syncing, but this does not support multiple hardforks per rollapp + // https://github.com/dymensionxyz/dymint/issues/1210 appVersion := state.Version.Consensus.App if b.Header.Height < state.RevisionStartHeight { appVersion-- From 944172983bad6c75d4f6152dffd2cbf6812082a6 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 15:37:56 +0100 Subject: [PATCH 055/119] fix --- block/executor.go | 2 +- block/fork.go | 2 -- block/manager.go | 2 +- store/pruning.go | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/block/executor.go b/block/executor.go index 6f6cfc71f..a83e0e8d4 100644 --- a/block/executor.go +++ b/block/executor.go @@ -261,7 +261,7 @@ func (e *Executor) ExecuteBlock(block *types.Block) (*tmstate.ABCIResponses, err Votes: nil, }, ByzantineValidators: nil, - // ConsensusMessages: block.Data.ConsensusMessages, + ConsensusMessages: block.Data.ConsensusMessages, }) if err != nil { return nil, err diff --git a/block/fork.go b/block/fork.go index 29c5c8f55..920baafc6 100644 --- a/block/fork.go +++ b/block/fork.go @@ -96,7 +96,6 @@ func (m *Manager) createInstruction(rollapp *types.Rollapp) error { // 1. If the next state height is greater than or equal to the rollapp's revision start height. // 2. If the block's app version (equivalent to revision) is less than the rollapp's revision func (m *Manager) shouldStopNode(rollapp *types.Rollapp, block *types.Block) bool { - revision := block.Header.Version.App if m.State.NextHeight() >= rollapp.RevisionStartHeight && revision < rollapp.Revision { m.logger.Info( @@ -127,7 +126,6 @@ func (m *Manager) forkNeeded() (types.Instruction, bool) { // handleSequencerForkTransition handles the sequencer fork transition func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { - consensusMsgs, err := m.prepareDRSUpgradeMessages(instruction.FaultyDRS) if err != nil { panic(fmt.Sprintf("prepare DRS upgrade messages: %v", err)) diff --git a/block/manager.go b/block/manager.go index a07cf1cae..c5d090fc5 100644 --- a/block/manager.go +++ b/block/manager.go @@ -196,7 +196,7 @@ func NewManager( state := m.State state.Version.Consensus.App = instruction.Revision state.RevisionStartHeight = instruction.RevisionStartHeight - if instruction.RevisionStartHeight == m.State.Height() { + if instruction.RevisionStartHeight == m.State.NextHeight() { drsVersion, err := strconv.ParseUint(version.DrsVersion, 10, 32) if err != nil { return nil, fmt.Errorf("unable to parse drs version") diff --git a/store/pruning.go b/store/pruning.go index 555177d3a..5940f8ae9 100644 --- a/store/pruning.go +++ b/store/pruning.go @@ -32,7 +32,6 @@ 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) { pruneBlocks := func(batch KVBatch, height uint64) error { - hash, err := s.loadHashFromIndex(height) if err != nil { return err From 2cb5922d4fef301eae7a992bdc6843754e0e28b7 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 17:28:51 +0100 Subject: [PATCH 056/119] fixes consensus msgs --- block/executor.go | 5 ++++- block/fork.go | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/block/executor.go b/block/executor.go index a83e0e8d4..f46ca2959 100644 --- a/block/executor.go +++ b/block/executor.go @@ -2,6 +2,7 @@ package block import ( "errors" + "strings" "time" proto2 "github.com/gogo/protobuf/proto" @@ -344,8 +345,10 @@ func fromProtoMsgToAny(msg proto2.Message) *proto.Any { return nil } + typeUrl := strings.Replace(proto2.MessageName(msg), "dymension_rdk", "rollapp", 1) + return &proto.Any{ - TypeUrl: proto2.MessageName(msg), + TypeUrl: typeUrl, Value: theType, } } diff --git a/block/fork.go b/block/fork.go index 920baafc6..134de5055 100644 --- a/block/fork.go +++ b/block/fork.go @@ -7,6 +7,7 @@ import ( "strconv" "time" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/gogo/protobuf/proto" "github.com/dymensionxyz/dymint/types" @@ -64,8 +65,7 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { if err != nil { return err } - err := fmt.Errorf("fork update") - m.freezeNode(ctx, err) + m.freezeNode(ctx, fmt.Errorf("fork update detected")) } return nil @@ -130,9 +130,8 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { if err != nil { panic(fmt.Sprintf("prepare DRS upgrade messages: %v", err)) } - // Always bump the account sequences - consensusMsgs = append(consensusMsgs, &sequencers.MsgBumpAccountSequences{Authority: "gov"}) + consensusMsgs = append(consensusMsgs, &sequencers.MsgBumpAccountSequences{Authority: authtypes.NewModuleAddress("sequencers").String()}) err = m.handleForkBlockCreation(instruction, consensusMsgs) if err != nil { @@ -169,6 +168,7 @@ func (m *Manager) prepareDRSUpgradeMessages(faultyDRS []uint32) ([]proto.Message return []proto.Message{ &sequencers.MsgUpgradeDRS{ + Authority: authtypes.NewModuleAddress("sequencers").String(), DrsVersion: uint64(actualDRS), }, }, nil From e8ce428b3c31daddb6b7ac0d62844c5d711d2056 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 11 Nov 2024 20:29:12 +0100 Subject: [PATCH 057/119] test fix --- block/production_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/production_test.go b/block/production_test.go index 8ff470b26..23c83e622 100644 --- a/block/production_test.go +++ b/block/production_test.go @@ -369,7 +369,7 @@ func TestUpdateInitialSequencerSet(t *testing.T) { expectedConsMsgBytes1, err := proto.Marshal(expectedConsMsg1) require.NoError(err) anyMsg1 := &prototypes.Any{ - TypeUrl: proto.MessageName(expectedConsMsg1), + TypeUrl: "rollapp.sequencers.types.ConsensusMsgUpsertSequencer", Value: expectedConsMsgBytes1, } @@ -386,7 +386,7 @@ func TestUpdateInitialSequencerSet(t *testing.T) { expectedConsMsgBytes2, err := proto.Marshal(expectedConsMsg2) require.NoError(err) anyMsg2 := &prototypes.Any{ - TypeUrl: proto.MessageName(expectedConsMsg2), + TypeUrl: "rollapp.sequencers.types.ConsensusMsgUpsertSequencer", Value: expectedConsMsgBytes2, } @@ -493,7 +493,7 @@ func TestUpdateExistingSequencerSet(t *testing.T) { expectedConsMsgBytes, err := proto.Marshal(expectedConsMsg) require.NoError(err) anyMsg1 := &prototypes.Any{ - TypeUrl: proto.MessageName(expectedConsMsg), + TypeUrl: "rollapp.sequencers.types.ConsensusMsgUpsertSequencer", Value: expectedConsMsgBytes, } From 12ae4ddb18ac8d4a6bf029afae9c877763934ece Mon Sep 17 00:00:00 2001 From: keruch Date: Tue, 12 Nov 2024 11:29:47 +0100 Subject: [PATCH 058/119] fix: consensus msgs serialization --- block/executor.go | 24 ++---------------------- types/serialization.go | 2 ++ types/serialization_test.go | 10 ++++++++-- utils/proto/converters.go | 21 +++++++++++++++++++++ 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/block/executor.go b/block/executor.go index 6f6cfc71f..8ac0a7e0d 100644 --- a/block/executor.go +++ b/block/executor.go @@ -5,7 +5,6 @@ import ( "time" proto2 "github.com/gogo/protobuf/proto" - proto "github.com/gogo/protobuf/types" "go.uber.org/multierr" abci "github.com/tendermint/tendermint/abci/types" @@ -17,6 +16,7 @@ import ( "github.com/dymensionxyz/dymint/mempool" "github.com/dymensionxyz/dymint/types" + protoutils "github.com/dymensionxyz/dymint/utils/proto" ) // 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. @@ -167,7 +167,7 @@ func (e *Executor) CreateBlock( Txs: toDymintTxs(mempoolTxs), IntermediateStateRoots: types.IntermediateStateRoots{RawRootsList: nil}, Evidence: types.EvidenceData{Evidence: nil}, - ConsensusMessages: fromProtoMsgSliceToAnySlice(e.consensusMsgQueue.Get()...), + ConsensusMessages: protoutils.FromProtoMsgSliceToAnySlice(e.consensusMsgQueue.Get()...), }, LastCommit: *lastCommit, } @@ -337,23 +337,3 @@ func fromDymintTxs(optiTxs types.Txs) tmtypes.Txs { } return txs } - -func fromProtoMsgToAny(msg proto2.Message) *proto.Any { - theType, err := proto2.Marshal(msg) - if err != nil { - return nil - } - - return &proto.Any{ - TypeUrl: proto2.MessageName(msg), - Value: theType, - } -} - -func fromProtoMsgSliceToAnySlice(msgs ...proto2.Message) []*proto.Any { - result := make([]*proto.Any, len(msgs)) - for i, msg := range msgs { - result[i] = fromProtoMsgToAny(msg) - } - return result -} diff --git a/types/serialization.go b/types/serialization.go index 43bca0d87..8c04fe512 100644 --- a/types/serialization.go +++ b/types/serialization.go @@ -175,6 +175,7 @@ func (d *Data) ToProto() *pb.Data { Txs: txsToByteSlices(d.Txs), IntermediateStateRoots: d.IntermediateStateRoots.RawRootsList, Evidence: evidenceToProto(d.Evidence), + ConsensusMessages: d.ConsensusMessages, } } @@ -187,6 +188,7 @@ func (b *Block) FromProto(other *pb.Block) error { b.Data.Txs = byteSlicesToTxs(other.Data.Txs) b.Data.IntermediateStateRoots.RawRootsList = other.Data.IntermediateStateRoots b.Data.Evidence = evidenceFromProto(other.Data.Evidence) + b.Data.ConsensusMessages = other.Data.ConsensusMessages if other.LastCommit != nil { err := b.LastCommit.FromProto(other.LastCommit) if err != nil { diff --git a/types/serialization_test.go b/types/serialization_test.go index 780235585..2ed884500 100644 --- a/types/serialization_test.go +++ b/types/serialization_test.go @@ -6,14 +6,15 @@ import ( "github.com/stretchr/testify/assert" "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/block" "github.com/dymensionxyz/dymint/testutil" "github.com/dymensionxyz/dymint/types" pb "github.com/dymensionxyz/dymint/types/pb/dymint" + protoutils "github.com/dymensionxyz/dymint/utils/proto" ) func TestBlockSerializationRoundTrip(t *testing.T) { @@ -31,6 +32,10 @@ func TestBlockSerializationRoundTrip(t *testing.T) { h = append(h, h1) } + sequencers := []types.Sequencer{testutil.GenerateSequencer()} + consensusMsgs, err := block.ConsensusMsgsOnSequencerSetUpdate(sequencers) + require.NoError(err) + cases := []struct { name string input *types.Block @@ -57,7 +62,8 @@ func TestBlockSerializationRoundTrip(t *testing.T) { Txs: nil, IntermediateStateRoots: types.IntermediateStateRoots{RawRootsList: [][]byte{{0x1}}}, // TODO(tzdybal): update when we have actual evidence types - Evidence: types.EvidenceData{Evidence: nil}, + Evidence: types.EvidenceData{Evidence: nil}, + ConsensusMessages: protoutils.FromProtoMsgSliceToAnySlice(consensusMsgs...), }, LastCommit: types.Commit{ Height: 8, diff --git a/utils/proto/converters.go b/utils/proto/converters.go index 32c9902a5..1a2073dd0 100644 --- a/utils/proto/converters.go +++ b/utils/proto/converters.go @@ -2,6 +2,7 @@ package proto import ( cosmos "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/gogo/protobuf/proto" gogo "github.com/gogo/protobuf/types" ) @@ -24,3 +25,23 @@ func CosmosToGogo(v *cosmos.Any) *gogo.Any { Value: v.Value, } } + +func FromProtoMsgToAny(msg proto.Message) *gogo.Any { + theType, err := proto.Marshal(msg) + if err != nil { + return nil + } + + return &gogo.Any{ + TypeUrl: proto.MessageName(msg), + Value: theType, + } +} + +func FromProtoMsgSliceToAnySlice(msgs ...proto.Message) []*gogo.Any { + result := make([]*gogo.Any, len(msgs)) + for i, msg := range msgs { + result[i] = FromProtoMsgToAny(msg) + } + return result +} From fae5391d138dc6c18abbabae8c1ba198839bb444 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 12 Nov 2024 13:57:03 +0100 Subject: [PATCH 059/119] remove stop syncing drs upgrade --- block/sync.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/block/sync.go b/block/sync.go index af441cecd..14da62063 100644 --- a/block/sync.go +++ b/block/sync.go @@ -4,13 +4,11 @@ import ( "context" "errors" "fmt" - "strconv" "github.com/dymensionxyz/gerr-cosmos/gerrc" "github.com/tendermint/tendermint/libs/pubsub" "github.com/dymensionxyz/dymint/settlement" - "github.com/dymensionxyz/dymint/version" ) // onNewStateUpdate will update the last submitted height and will update sequencers list from SL. After, it triggers syncing or validation, depending whether it needs to sync first or only validate. @@ -75,22 +73,6 @@ func (m *Manager) SettlementSyncLoop(ctx context.Context) error { } m.logger.Info("Retrieved state update from SL.", "state_index", settlementBatch.StateIndex) - actualDRS, err := strconv.ParseUint(version.DrsVersion, 10, 32) - if err != nil { - return fmt.Errorf("converting DRS version to int: %v", err) - } - if settlementBatch.BlockDescriptors[0].DrsVersion != uint32(actualDRS) { - - rollapp, err := m.SLClient.GetRollapp() - if err != nil { - return err - } - err = m.createInstruction(rollapp) - if err != nil { - return err - } - return fmt.Errorf("wrong DRS version") - } err = m.ApplyBatchFromSL(settlementBatch.Batch) if err != nil { return fmt.Errorf("process next DA batch. err:%w", err) From fb2e64e53d2c7787d9a338707e0ea685ad8e405b Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 12 Nov 2024 17:23:49 +0100 Subject: [PATCH 060/119] exiting loops when freezing --- block/manager.go | 10 ++++++++++ block/produce.go | 5 ++++- block/submit.go | 8 ++++++++ block/submit_loop_test.go | 5 ++++- block/sync.go | 3 +++ block/validate.go | 3 +++ 6 files changed, 32 insertions(+), 2 deletions(-) diff --git a/block/manager.go b/block/manager.go index cf26f0a39..dc5566986 100644 --- a/block/manager.go +++ b/block/manager.go @@ -115,6 +115,9 @@ type Manager struct { // validates all non-finalized state updates from settlement, checking there is consistency between DA and P2P blocks, and the information in the state update. SettlementValidator *SettlementValidator + + // frozen indicates if the node is frozen due to unhealthy event. used to stop block production. + frozen atomic.Bool } // NewManager creates new block Manager. @@ -379,8 +382,15 @@ func (m *Manager) setFraudHandler(handler *FreezeHandler) { } func (m *Manager) freezeNode(ctx context.Context, err error) { + m.logger.Info("Freezing node", "err", err) + m.frozen.Store(true) uevent.MustPublish(ctx, m.Pubsub, &events.DataHealthStatus{Error: err}, events.HealthStatusList) if m.RunMode == RunModeFullNode { m.unsubscribeFullNodeEvents(ctx) } } + +// isFrozen returns whether the node is in frozen state +func (m *Manager) isFrozen() bool { + return m.frozen.Load() +} diff --git a/block/produce.go b/block/produce.go index 90062ba8b..71929725c 100644 --- a/block/produce.go +++ b/block/produce.go @@ -44,7 +44,10 @@ func (m *Manager) ProduceBlockLoop(ctx context.Context, bytesProducedC chan int) if !m.AmIProposerOnRollapp() { continue } - + // finish the block production loop in case the node is frozen + if m.isFrozen() { + return nil + } // if empty blocks are configured to be enabled, and one is scheduled... produceEmptyBlock := firstBlock || m.Conf.MaxIdleTime == 0 || nextEmptyBlock.Before(time.Now()) firstBlock = false diff --git a/block/submit.go b/block/submit.go index 4881854c9..07a69a77a 100644 --- a/block/submit.go +++ b/block/submit.go @@ -35,6 +35,7 @@ func (m *Manager) SubmitLoop(ctx context.Context, m.Conf.BatchSubmitTime, m.Conf.BatchSubmitBytes, m.CreateAndSubmitBatchGetSizeBlocksCommits, + m.isFrozen, ) } @@ -48,6 +49,7 @@ func SubmitLoopInner( maxBatchTime time.Duration, // max time to allow between batches maxBatchBytes uint64, // max size of serialised batch in bytes createAndSubmitBatch func(maxSizeBytes uint64) (sizeBlocksCommits uint64, err error), + frozen func() bool, ) error { eg, ctx := errgroup.WithContext(ctx) @@ -60,6 +62,9 @@ func SubmitLoopInner( // 'trigger': this thread is responsible for waking up the submitter when a new block arrives, and back-pressures the block production loop // if it gets too far ahead. for { + if frozen() { + return nil + } if maxBatchSkew*maxBatchBytes < pendingBytes.Load() { // too much stuff is pending submission // we block here until we get a progress nudge from the submitter thread @@ -95,6 +100,9 @@ func SubmitLoopInner( case <-ticker.C: case <-submitter.C: } + if frozen() { + return nil + } pending := pendingBytes.Load() types.RollappPendingSubmissionsSkewBytes.Set(float64(pendingBytes.Load())) types.RollappPendingSubmissionsSkewBlocks.Set(float64(unsubmittedBlocks())) diff --git a/block/submit_loop_test.go b/block/submit_loop_test.go index 403adda52..708a220e8 100644 --- a/block/submit_loop_test.go +++ b/block/submit_loop_test.go @@ -113,8 +113,11 @@ func testSubmitLoopInner( accumulatedBlocks := func() uint64 { return pendingBlocks.Load() } + frozen := func() bool { + return false + } - block.SubmitLoopInner(ctx, log.NewNopLogger(), producedBytesC, args.batchSkew, accumulatedBlocks, args.maxTime, args.batchBytes, submitBatch) + block.SubmitLoopInner(ctx, log.NewNopLogger(), producedBytesC, args.batchSkew, accumulatedBlocks, args.maxTime, args.batchBytes, submitBatch, frozen) } // Make sure the producer does not get too far ahead diff --git a/block/sync.go b/block/sync.go index 14da62063..e6c955ac7 100644 --- a/block/sync.go +++ b/block/sync.go @@ -53,6 +53,9 @@ func (m *Manager) SettlementSyncLoop(ctx context.Context) error { case <-m.settlementSyncingC: + if m.isFrozen() { + return nil + } m.logger.Info("syncing to target height", "targetHeight", m.LastSettlementHeight.Load()) for currH := m.State.NextHeight(); currH <= m.LastSettlementHeight.Load(); currH = m.State.NextHeight() { diff --git a/block/validate.go b/block/validate.go index 2af532b1f..3ae8d98f5 100644 --- a/block/validate.go +++ b/block/validate.go @@ -30,6 +30,9 @@ func (m *Manager) SettlementValidateLoop(ctx context.Context) error { return ctx.Err() case <-m.settlementValidationC: + if m.isFrozen() { + return nil + } targetValidationHeight := min(m.LastSettlementHeight.Load(), m.State.Height()) m.logger.Info("validating state updates to target height", "targetHeight", targetValidationHeight) From 59a92d1beb7127a57a0dc5a8c3c1a4c97a7e6e10 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Tue, 12 Nov 2024 17:38:25 +0100 Subject: [PATCH 061/119] createForkBlocks func --- block/fork.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/fork.go b/block/fork.go index 3b77c8ec1..a06eff032 100644 --- a/block/fork.go +++ b/block/fork.go @@ -129,7 +129,7 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { // Always bump the account sequences consensusMsgs = append(consensusMsgs, &sequencers.MsgBumpAccountSequences{Authority: authtypes.NewModuleAddress("sequencers").String()}) - err = m.handleForkBlockCreation(instruction, consensusMsgs) + err = m.createForkBlocks(instruction, consensusMsgs) if err != nil { panic(fmt.Sprintf("validate existing blocks: %v", err)) } @@ -170,7 +170,7 @@ func (m *Manager) prepareDRSUpgradeMessages(faultyDRS []uint32) ([]proto.Message }, nil } -// handleForkBlockCreation manages the block creation process during a fork transition. +// createForkBlocks manages the block creation process during a fork transition. // // The function implements the following logic: // 1. Checks if blocks for the fork transition have already been created by comparing heights @@ -182,7 +182,7 @@ func (m *Manager) prepareDRSUpgradeMessages(faultyDRS []uint32) ([]proto.Message // - First block: Contains consensus messages for the fork // - Second block: Should be empty (no messages or transactions) // - Total height increase should be 2 blocks from RevisionStartHeight -func (m *Manager) handleForkBlockCreation(instruction types.Instruction, consensusMsgs []proto.Message) error { +func (m *Manager) createForkBlocks(instruction types.Instruction, consensusMsgs []proto.Message) error { if m.State.NextHeight() == instruction.RevisionStartHeight+2 { return m.validateExistingBlocks(instruction) } From f5ba4e0fdd4e56d040ba6ed58b8a47f2b87691bf Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 12 Nov 2024 17:38:38 +0100 Subject: [PATCH 062/119] replace bool by channel --- block/manager.go | 12 ++++-------- block/produce.go | 7 +++---- block/submit.go | 17 +++++++++-------- block/submit_loop_test.go | 6 ++---- block/sync.go | 7 ++----- block/validate.go | 5 ++--- 6 files changed, 22 insertions(+), 32 deletions(-) diff --git a/block/manager.go b/block/manager.go index dc5566986..59657fdce 100644 --- a/block/manager.go +++ b/block/manager.go @@ -116,8 +116,8 @@ type Manager struct { // validates all non-finalized state updates from settlement, checking there is consistency between DA and P2P blocks, and the information in the state update. SettlementValidator *SettlementValidator - // frozen indicates if the node is frozen due to unhealthy event. used to stop block production. - frozen atomic.Bool + // channel used to signal freeze + frozenC chan struct{} } // NewManager creates new block Manager. @@ -174,6 +174,7 @@ func NewManager( settlementSyncingC: make(chan struct{}, 1), // use of buffered channel to avoid blocking. In case channel is full, its skipped because there is an ongoing syncing process, but syncing height is updated, which means the ongoing syncing will sync to the new height. settlementValidationC: make(chan struct{}, 1), // use of buffered channel to avoid blocking. In case channel is full, its skipped because there is an ongoing validation process, but validation height is updated, which means the ongoing validation will validate to the new height. syncedFromSettlement: uchannel.NewNudger(), // used by the sequencer to wait till the node completes the syncing from settlement. + frozenC: make(chan struct{}), } m.setFraudHandler(NewFreezeHandler(m)) @@ -383,14 +384,9 @@ func (m *Manager) setFraudHandler(handler *FreezeHandler) { func (m *Manager) freezeNode(ctx context.Context, err error) { m.logger.Info("Freezing node", "err", err) - m.frozen.Store(true) + m.frozenC <- struct{}{} uevent.MustPublish(ctx, m.Pubsub, &events.DataHealthStatus{Error: err}, events.HealthStatusList) if m.RunMode == RunModeFullNode { m.unsubscribeFullNodeEvents(ctx) } } - -// isFrozen returns whether the node is in frozen state -func (m *Manager) isFrozen() bool { - return m.frozen.Load() -} diff --git a/block/produce.go b/block/produce.go index 71929725c..317d80d23 100644 --- a/block/produce.go +++ b/block/produce.go @@ -38,16 +38,15 @@ func (m *Manager) ProduceBlockLoop(ctx context.Context, bytesProducedC chan int) for { select { case <-ctx.Done(): + return ctx.Err() + case <-m.frozenC: return nil case <-ticker.C: // Only produce if I'm the current rollapp proposer. if !m.AmIProposerOnRollapp() { continue } - // finish the block production loop in case the node is frozen - if m.isFrozen() { - return nil - } + // if empty blocks are configured to be enabled, and one is scheduled... produceEmptyBlock := firstBlock || m.Conf.MaxIdleTime == 0 || nextEmptyBlock.Before(time.Now()) firstBlock = false diff --git a/block/submit.go b/block/submit.go index 07a69a77a..64701cee1 100644 --- a/block/submit.go +++ b/block/submit.go @@ -35,7 +35,7 @@ func (m *Manager) SubmitLoop(ctx context.Context, m.Conf.BatchSubmitTime, m.Conf.BatchSubmitBytes, m.CreateAndSubmitBatchGetSizeBlocksCommits, - m.isFrozen, + m.frozenC, ) } @@ -49,7 +49,7 @@ func SubmitLoopInner( maxBatchTime time.Duration, // max time to allow between batches maxBatchBytes uint64, // max size of serialised batch in bytes createAndSubmitBatch func(maxSizeBytes uint64) (sizeBlocksCommits uint64, err error), - frozen func() bool, + frozenC chan struct{}, ) error { eg, ctx := errgroup.WithContext(ctx) @@ -62,21 +62,23 @@ func SubmitLoopInner( // 'trigger': this thread is responsible for waking up the submitter when a new block arrives, and back-pressures the block production loop // if it gets too far ahead. for { - if frozen() { - return nil - } + if maxBatchSkew*maxBatchBytes < pendingBytes.Load() { // too much stuff is pending submission // we block here until we get a progress nudge from the submitter thread select { case <-ctx.Done(): return ctx.Err() + case <-frozenC: + return nil case <-trigger.C: } } else { select { case <-ctx.Done(): return ctx.Err() + case <-frozenC: + return nil case n := <-bytesProduced: pendingBytes.Add(uint64(n)) logger.Debug("Added bytes produced to bytes pending submission counter.", "bytes added", n, "pending", pendingBytes.Load()) @@ -97,12 +99,11 @@ func SubmitLoopInner( select { case <-ctx.Done(): return ctx.Err() + case <-frozenC: + return nil case <-ticker.C: case <-submitter.C: } - if frozen() { - return nil - } pending := pendingBytes.Load() types.RollappPendingSubmissionsSkewBytes.Set(float64(pendingBytes.Load())) types.RollappPendingSubmissionsSkewBlocks.Set(float64(unsubmittedBlocks())) diff --git a/block/submit_loop_test.go b/block/submit_loop_test.go index 708a220e8..cac911de9 100644 --- a/block/submit_loop_test.go +++ b/block/submit_loop_test.go @@ -113,11 +113,9 @@ func testSubmitLoopInner( accumulatedBlocks := func() uint64 { return pendingBlocks.Load() } - frozen := func() bool { - return false - } + frozenC := make(chan struct{}) - block.SubmitLoopInner(ctx, log.NewNopLogger(), producedBytesC, args.batchSkew, accumulatedBlocks, args.maxTime, args.batchBytes, submitBatch, frozen) + block.SubmitLoopInner(ctx, log.NewNopLogger(), producedBytesC, args.batchSkew, accumulatedBlocks, args.maxTime, args.batchBytes, submitBatch, frozenC) } // Make sure the producer does not get too far ahead diff --git a/block/sync.go b/block/sync.go index e6c955ac7..f739507a2 100644 --- a/block/sync.go +++ b/block/sync.go @@ -50,12 +50,9 @@ func (m *Manager) SettlementSyncLoop(ctx context.Context) error { select { case <-ctx.Done(): return ctx.Err() - + case <-m.frozenC: + return nil case <-m.settlementSyncingC: - - if m.isFrozen() { - return nil - } m.logger.Info("syncing to target height", "targetHeight", m.LastSettlementHeight.Load()) for currH := m.State.NextHeight(); currH <= m.LastSettlementHeight.Load(); currH = m.State.NextHeight() { diff --git a/block/validate.go b/block/validate.go index 3ae8d98f5..9f79fc25d 100644 --- a/block/validate.go +++ b/block/validate.go @@ -28,11 +28,10 @@ func (m *Manager) SettlementValidateLoop(ctx context.Context) error { select { case <-ctx.Done(): return ctx.Err() + case <-m.frozenC: + return nil case <-m.settlementValidationC: - if m.isFrozen() { - return nil - } targetValidationHeight := min(m.LastSettlementHeight.Load(), m.State.Height()) m.logger.Info("validating state updates to target height", "targetHeight", targetValidationHeight) From 0df4a203a2eafe3f363d30e4637f852ff06a0b75 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Tue, 12 Nov 2024 17:44:05 +0100 Subject: [PATCH 063/119] update name of function --- block/fork.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/fork.go b/block/fork.go index a06eff032..f138bb1ee 100644 --- a/block/fork.go +++ b/block/fork.go @@ -129,7 +129,7 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { // Always bump the account sequences consensusMsgs = append(consensusMsgs, &sequencers.MsgBumpAccountSequences{Authority: authtypes.NewModuleAddress("sequencers").String()}) - err = m.createForkBlocks(instruction, consensusMsgs) + err = m.handleCreationOfForkBlocks(instruction, consensusMsgs) if err != nil { panic(fmt.Sprintf("validate existing blocks: %v", err)) } @@ -170,7 +170,7 @@ func (m *Manager) prepareDRSUpgradeMessages(faultyDRS []uint32) ([]proto.Message }, nil } -// createForkBlocks manages the block creation process during a fork transition. +// handleCreationOfForkBlocks manages the block creation process during a fork transition. // // The function implements the following logic: // 1. Checks if blocks for the fork transition have already been created by comparing heights @@ -182,7 +182,7 @@ func (m *Manager) prepareDRSUpgradeMessages(faultyDRS []uint32) ([]proto.Message // - First block: Contains consensus messages for the fork // - Second block: Should be empty (no messages or transactions) // - Total height increase should be 2 blocks from RevisionStartHeight -func (m *Manager) createForkBlocks(instruction types.Instruction, consensusMsgs []proto.Message) error { +func (m *Manager) handleCreationOfForkBlocks(instruction types.Instruction, consensusMsgs []proto.Message) error { if m.State.NextHeight() == instruction.RevisionStartHeight+2 { return m.validateExistingBlocks(instruction) } From 2d2eaa4199e32c3b0368e9adc55096c8f7db6cc7 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Tue, 12 Nov 2024 18:29:37 +0100 Subject: [PATCH 064/119] move method --- block/fork.go | 13 +------------ block/fraud.go | 2 +- block/manager.go | 19 ++++++++++++++++--- block/p2p.go | 2 +- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/block/fork.go b/block/fork.go index f138bb1ee..b56a403e6 100644 --- a/block/fork.go +++ b/block/fork.go @@ -61,7 +61,7 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { if err != nil { return err } - m.freezeNode(ctx, fmt.Errorf("fork update detected")) + m.freezeNode(ctx, rollapp, lastBlock, fmt.Errorf("fork update detected")) } return nil @@ -94,17 +94,6 @@ func (m *Manager) createInstruction(rollapp *types.Rollapp) error { func (m *Manager) shouldStopNode(rollapp *types.Rollapp, block *types.Block) bool { revision := block.Header.Version.App if m.State.NextHeight() >= rollapp.RevisionStartHeight && revision < rollapp.Revision { - m.logger.Info( - "Freezing node due to fork update", - "local_block_height", - m.State.Height(), - "rollapp_revision_start_height", - rollapp.RevisionStartHeight, - "local_revision", - revision, - "rollapp_revision", - rollapp.Revision, - ) return true } diff --git a/block/fraud.go b/block/fraud.go index 9933c808f..3a3b7024d 100644 --- a/block/fraud.go +++ b/block/fraud.go @@ -19,7 +19,7 @@ type FreezeHandler struct { } func (f FreezeHandler) HandleFault(ctx context.Context, fault error) { - f.m.freezeNode(ctx, fault) + f.m.freezeNode(ctx, nil, nil, fault) } func NewFreezeHandler(manager *Manager) *FreezeHandler { diff --git a/block/manager.go b/block/manager.go index c5d090fc5..6b8094a05 100644 --- a/block/manager.go +++ b/block/manager.go @@ -275,7 +275,7 @@ func (m *Manager) Start(ctx context.Context) error { uerrors.ErrGroupGoLog(eg, m.logger, func() error { err := m.SettlementSyncLoop(ctx) if err != nil { - m.freezeNode(context.Background(), err) + m.freezeNode(context.Background(), nil, nil, err) } return nil }) @@ -407,8 +407,21 @@ func (m *Manager) setFraudHandler(handler *FreezeHandler) { } // freezeNode sets the node as unhealthy and prevents the node continues producing and processing blocks -func (m *Manager) freezeNode(ctx context.Context, err error) { - m.logger.Info("Freezing node", "err", err) +func (m *Manager) freezeNode(ctx context.Context, rollapp *types.Rollapp, block *types.Block, err error) { + revision := block.Header.Version.App + + m.logger.Info( + "Freezing node due to fork update", + "local_block_height", + m.State.Height(), + "rollapp_revision_start_height", + rollapp.RevisionStartHeight, + "local_revision", + revision, + "rollapp_revision", + rollapp.Revision, + ) + m.frozen.Store(true) uevent.MustPublish(ctx, m.Pubsub, &events.DataHealthStatus{Error: err}, events.HealthStatusList) if m.RunMode == RunModeFullNode { diff --git a/block/p2p.go b/block/p2p.go index 2a795456c..cf51f8d2c 100644 --- a/block/p2p.go +++ b/block/p2p.go @@ -58,7 +58,7 @@ func (m *Manager) OnReceivedBlock(event pubsub.Message) { err := m.attemptApplyCachedBlocks() if err != nil { - m.freezeNode(context.Background(), err) + m.freezeNode(context.Background(), nil, nil, err) m.logger.Error("Attempt apply cached blocks.", "err", err) } } From 638650255c8459b864b0d2df5a8a40b6b99a2195 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Tue, 12 Nov 2024 20:56:59 +0100 Subject: [PATCH 065/119] revision updated --- block/fork.go | 4 ++-- block/manager.go | 25 +++++++++++++++---------- types/block.go | 4 ++++ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/block/fork.go b/block/fork.go index b56a403e6..6d4baa89a 100644 --- a/block/fork.go +++ b/block/fork.go @@ -92,7 +92,7 @@ func (m *Manager) createInstruction(rollapp *types.Rollapp) error { // 1. If the next state height is greater than or equal to the rollapp's revision start height. // 2. If the block's app version (equivalent to revision) is less than the rollapp's revision func (m *Manager) shouldStopNode(rollapp *types.Rollapp, block *types.Block) bool { - revision := block.Header.Version.App + revision := block.GetRevision() if m.State.NextHeight() >= rollapp.RevisionStartHeight && revision < rollapp.Revision { return true } @@ -136,7 +136,7 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { // - Validates the current DRS version against the potentially faulty version // - Generates an upgrade message with the current valid DRS version func (m *Manager) prepareDRSUpgradeMessages(faultyDRS []uint32) ([]proto.Message, error) { - if faultyDRS == nil { + if len(faultyDRS) == 0 { return nil, nil } diff --git a/block/manager.go b/block/manager.go index 6b8094a05..82d7288a6 100644 --- a/block/manager.go +++ b/block/manager.go @@ -196,13 +196,20 @@ func NewManager( state := m.State state.Version.Consensus.App = instruction.Revision state.RevisionStartHeight = instruction.RevisionStartHeight - if instruction.RevisionStartHeight == m.State.NextHeight() { - drsVersion, err := strconv.ParseUint(version.DrsVersion, 10, 32) - if err != nil { - return nil, fmt.Errorf("unable to parse drs version") - } - state.RollappParams.DrsVersion = uint32(drsVersion) - } + + /* if instruction.RevisionStartHeight == m.State.NextHeight() { + drsVersion, err := strconv.ParseUint(version.DrsVersion, 10, 32) + if err != nil { + return nil, fmt.Errorf("unable to parse drs version") + } + state.RollappParams.DrsVersion = uint32(drsVersion) + } + + TO BE TESTED and removed + + In theory this is happening on func (e *Executor) UpdateStateAfterCommit + */ + m.State = state } @@ -408,8 +415,6 @@ func (m *Manager) setFraudHandler(handler *FreezeHandler) { // freezeNode sets the node as unhealthy and prevents the node continues producing and processing blocks func (m *Manager) freezeNode(ctx context.Context, rollapp *types.Rollapp, block *types.Block, err error) { - revision := block.Header.Version.App - m.logger.Info( "Freezing node due to fork update", "local_block_height", @@ -417,7 +422,7 @@ func (m *Manager) freezeNode(ctx context.Context, rollapp *types.Rollapp, block "rollapp_revision_start_height", rollapp.RevisionStartHeight, "local_revision", - revision, + block.GetRevision(), "rollapp_revision", rollapp.Revision, ) diff --git a/types/block.go b/types/block.go index 8bd7b652b..01cbb7c32 100644 --- a/types/block.go +++ b/types/block.go @@ -74,6 +74,10 @@ func (b Block) SizeBytes() int { return b.ToProto().Size() } +func (b *Block) GetRevision() uint64 { + return b.Header.Version.App +} + var ( _ encoding.BinaryMarshaler = &Block{} _ encoding.BinaryUnmarshaler = &Block{} From 272c54c76b1cd8f126fb198d7126badc749fa095 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 12 Nov 2024 21:46:25 +0100 Subject: [PATCH 066/119] using context to freeze node --- block/manager.go | 11 ++++------- block/manager_test.go | 4 +--- block/modes.go | 14 -------------- block/produce.go | 2 -- block/submit.go | 8 -------- block/submit_loop_test.go | 3 +-- block/sync.go | 6 ++++-- block/validate.go | 5 ++--- node/node.go | 2 +- 9 files changed, 13 insertions(+), 42 deletions(-) diff --git a/block/manager.go b/block/manager.go index 59657fdce..93a7814bb 100644 --- a/block/manager.go +++ b/block/manager.go @@ -116,8 +116,7 @@ type Manager struct { // validates all non-finalized state updates from settlement, checking there is consistency between DA and P2P blocks, and the information in the state update. SettlementValidator *SettlementValidator - // channel used to signal freeze - frozenC chan struct{} + Cancel context.CancelFunc } // NewManager creates new block Manager. @@ -174,7 +173,6 @@ func NewManager( settlementSyncingC: make(chan struct{}, 1), // use of buffered channel to avoid blocking. In case channel is full, its skipped because there is an ongoing syncing process, but syncing height is updated, which means the ongoing syncing will sync to the new height. settlementValidationC: make(chan struct{}, 1), // use of buffered channel to avoid blocking. In case channel is full, its skipped because there is an ongoing validation process, but validation height is updated, which means the ongoing validation will validate to the new height. syncedFromSettlement: uchannel.NewNudger(), // used by the sequencer to wait till the node completes the syncing from settlement. - frozenC: make(chan struct{}), } m.setFraudHandler(NewFreezeHandler(m)) @@ -201,6 +199,7 @@ func NewManager( // Start starts the block manager. func (m *Manager) Start(ctx context.Context) error { + ctx, m.Cancel = context.WithCancel(ctx) // Check if InitChain flow is needed if m.State.IsGenesis() { m.logger.Info("Running InitChain") @@ -384,9 +383,7 @@ func (m *Manager) setFraudHandler(handler *FreezeHandler) { func (m *Manager) freezeNode(ctx context.Context, err error) { m.logger.Info("Freezing node", "err", err) - m.frozenC <- struct{}{} uevent.MustPublish(ctx, m.Pubsub, &events.DataHealthStatus{Error: err}, events.HealthStatusList) - if m.RunMode == RunModeFullNode { - m.unsubscribeFullNodeEvents(ctx) - } + m.Cancel() + } diff --git a/block/manager_test.go b/block/manager_test.go index 3681ab2cf..9ffa04bfa 100644 --- a/block/manager_test.go +++ b/block/manager_test.go @@ -233,7 +233,6 @@ func TestApplyCachedBlocks_WithFraudCheck(t *testing.T) { t.Log("Taking the manager out of sync by submitting a batch") manager.DAClient = testutil.GetMockDALC(log.TestingLogger()) manager.Retriever = manager.DAClient.(da.BatchRetriever) - mockExecutor := &blockmocks.MockExecutorI{} manager.Executor = mockExecutor mockExecutor.On("GetAppInfo").Return(&abci.ResponseInfo{ @@ -243,12 +242,11 @@ func TestApplyCachedBlocks_WithFraudCheck(t *testing.T) { // Check that handle fault is called manager.FraudHandler = block.NewFreezeHandler(manager) - fraudEventReceived := make(chan *events.DataHealthStatus, 1) ctx, cancel := context.WithCancel(context.Background()) defer cancel() - + _, manager.Cancel = context.WithCancel(context.Background()) go event.MustSubscribe( ctx, manager.Pubsub, diff --git a/block/modes.go b/block/modes.go index 6f8cff9f5..7a7d11270 100644 --- a/block/modes.go +++ b/block/modes.go @@ -86,17 +86,3 @@ func (m *Manager) subscribeFullNodeEvents(ctx context.Context) { go uevent.MustSubscribe(ctx, m.Pubsub, p2pGossipLoop, p2p.EventQueryNewGossipedBlock, m.OnReceivedBlock, m.logger) go uevent.MustSubscribe(ctx, m.Pubsub, p2pBlocksyncLoop, p2p.EventQueryNewBlockSyncBlock, m.OnReceivedBlock, m.logger) } - -func (m *Manager) unsubscribeFullNodeEvents(ctx context.Context) { - // unsubscribe for specific event (clientId) - unsubscribe := func(clientId string) { - err := m.Pubsub.UnsubscribeAll(ctx, clientId) - if err != nil { - m.logger.Error("Unsubscribe", "clientId", clientId, "error", err) - } - } - unsubscribe(syncLoop) - unsubscribe(validateLoop) - unsubscribe(p2pGossipLoop) - unsubscribe(p2pBlocksyncLoop) -} diff --git a/block/produce.go b/block/produce.go index 317d80d23..2c5965e5f 100644 --- a/block/produce.go +++ b/block/produce.go @@ -39,8 +39,6 @@ func (m *Manager) ProduceBlockLoop(ctx context.Context, bytesProducedC chan int) select { case <-ctx.Done(): return ctx.Err() - case <-m.frozenC: - return nil case <-ticker.C: // Only produce if I'm the current rollapp proposer. if !m.AmIProposerOnRollapp() { diff --git a/block/submit.go b/block/submit.go index 64701cee1..7828b2593 100644 --- a/block/submit.go +++ b/block/submit.go @@ -35,7 +35,6 @@ func (m *Manager) SubmitLoop(ctx context.Context, m.Conf.BatchSubmitTime, m.Conf.BatchSubmitBytes, m.CreateAndSubmitBatchGetSizeBlocksCommits, - m.frozenC, ) } @@ -49,7 +48,6 @@ func SubmitLoopInner( maxBatchTime time.Duration, // max time to allow between batches maxBatchBytes uint64, // max size of serialised batch in bytes createAndSubmitBatch func(maxSizeBytes uint64) (sizeBlocksCommits uint64, err error), - frozenC chan struct{}, ) error { eg, ctx := errgroup.WithContext(ctx) @@ -69,16 +67,12 @@ func SubmitLoopInner( select { case <-ctx.Done(): return ctx.Err() - case <-frozenC: - return nil case <-trigger.C: } } else { select { case <-ctx.Done(): return ctx.Err() - case <-frozenC: - return nil case n := <-bytesProduced: pendingBytes.Add(uint64(n)) logger.Debug("Added bytes produced to bytes pending submission counter.", "bytes added", n, "pending", pendingBytes.Load()) @@ -99,8 +93,6 @@ func SubmitLoopInner( select { case <-ctx.Done(): return ctx.Err() - case <-frozenC: - return nil case <-ticker.C: case <-submitter.C: } diff --git a/block/submit_loop_test.go b/block/submit_loop_test.go index cac911de9..403adda52 100644 --- a/block/submit_loop_test.go +++ b/block/submit_loop_test.go @@ -113,9 +113,8 @@ func testSubmitLoopInner( accumulatedBlocks := func() uint64 { return pendingBlocks.Load() } - frozenC := make(chan struct{}) - block.SubmitLoopInner(ctx, log.NewNopLogger(), producedBytesC, args.batchSkew, accumulatedBlocks, args.maxTime, args.batchBytes, submitBatch, frozenC) + block.SubmitLoopInner(ctx, log.NewNopLogger(), producedBytesC, args.batchSkew, accumulatedBlocks, args.maxTime, args.batchBytes, submitBatch) } // Make sure the producer does not get too far ahead diff --git a/block/sync.go b/block/sync.go index f739507a2..1f7b6a53e 100644 --- a/block/sync.go +++ b/block/sync.go @@ -50,12 +50,14 @@ func (m *Manager) SettlementSyncLoop(ctx context.Context) error { select { case <-ctx.Done(): return ctx.Err() - case <-m.frozenC: - return nil case <-m.settlementSyncingC: m.logger.Info("syncing to target height", "targetHeight", m.LastSettlementHeight.Load()) for currH := m.State.NextHeight(); currH <= m.LastSettlementHeight.Load(); currH = m.State.NextHeight() { + // if context has been cancelled, stop syncing + if ctx.Err() != nil { + return ctx.Err() + } // if we have the block locally, we don't need to fetch it from the DA. // it will only happen in case of rollback. err := m.applyLocalBlock(currH) diff --git a/block/validate.go b/block/validate.go index 9f79fc25d..84b57ee7c 100644 --- a/block/validate.go +++ b/block/validate.go @@ -3,6 +3,7 @@ package block import ( "context" "errors" + "fmt" "github.com/dymensionxyz/dymint/node/events" "github.com/dymensionxyz/dymint/settlement" @@ -28,10 +29,8 @@ func (m *Manager) SettlementValidateLoop(ctx context.Context) error { select { case <-ctx.Done(): return ctx.Err() - case <-m.frozenC: - return nil case <-m.settlementValidationC: - + m.freezeNode(ctx, fmt.Errorf("error")) targetValidationHeight := min(m.LastSettlementHeight.Load(), m.State.Height()) m.logger.Info("validating state updates to target height", "targetHeight", targetValidationHeight) diff --git a/node/node.go b/node/node.go index f0f1a88e5..9c1275b89 100644 --- a/node/node.go +++ b/node/node.go @@ -270,7 +270,7 @@ func (n *Node) OnStop() { n.Logger.Error("close store", "error", err) } - n.cancel() + //n.cancel() } // OnReset is a part of Service interface. From 0fa99a1d06c72afeaef87b46d55f44bfb9adb7a4 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 12 Nov 2024 21:58:32 +0100 Subject: [PATCH 067/119] fix --- block/manager.go | 1 - block/validate.go | 2 -- node/node.go | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/block/manager.go b/block/manager.go index 93a7814bb..0bc4f6df8 100644 --- a/block/manager.go +++ b/block/manager.go @@ -385,5 +385,4 @@ func (m *Manager) freezeNode(ctx context.Context, err error) { m.logger.Info("Freezing node", "err", err) uevent.MustPublish(ctx, m.Pubsub, &events.DataHealthStatus{Error: err}, events.HealthStatusList) m.Cancel() - } diff --git a/block/validate.go b/block/validate.go index 84b57ee7c..281f49f44 100644 --- a/block/validate.go +++ b/block/validate.go @@ -3,7 +3,6 @@ package block import ( "context" "errors" - "fmt" "github.com/dymensionxyz/dymint/node/events" "github.com/dymensionxyz/dymint/settlement" @@ -30,7 +29,6 @@ func (m *Manager) SettlementValidateLoop(ctx context.Context) error { case <-ctx.Done(): return ctx.Err() case <-m.settlementValidationC: - m.freezeNode(ctx, fmt.Errorf("error")) targetValidationHeight := min(m.LastSettlementHeight.Load(), m.State.Height()) m.logger.Info("validating state updates to target height", "targetHeight", targetValidationHeight) diff --git a/node/node.go b/node/node.go index 9c1275b89..f0f1a88e5 100644 --- a/node/node.go +++ b/node/node.go @@ -270,7 +270,7 @@ func (n *Node) OnStop() { n.Logger.Error("close store", "error", err) } - //n.cancel() + n.cancel() } // OnReset is a part of Service interface. From 35db9a9dc2d5999a6a8336a09d312f7fbc20b209 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 12 Nov 2024 22:30:25 +0100 Subject: [PATCH 068/119] freeze update --- block/fork.go | 12 ++++++++++++ block/fraud.go | 2 +- block/manager.go | 13 +------------ block/p2p.go | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/block/fork.go b/block/fork.go index 818583562..74e2b6bc1 100644 --- a/block/fork.go +++ b/block/fork.go @@ -60,6 +60,18 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { if err != nil { return err } + m.logger.Info( + "Freezing node due to fork update", + "local_block_height", + m.State.Height(), + "rollapp_revision_start_height", + rollapp.RevisionStartHeight, + "local_revision", + lastBlock.GetRevision(), + "rollapp_revision", + rollapp.Revision, + ) + m.freezeNode(ctx, rollapp, lastBlock, fmt.Errorf("fork update detected")) } diff --git a/block/fraud.go b/block/fraud.go index 3a3b7024d..9933c808f 100644 --- a/block/fraud.go +++ b/block/fraud.go @@ -19,7 +19,7 @@ type FreezeHandler struct { } func (f FreezeHandler) HandleFault(ctx context.Context, fault error) { - f.m.freezeNode(ctx, nil, nil, fault) + f.m.freezeNode(ctx, fault) } func NewFreezeHandler(manager *Manager) *FreezeHandler { diff --git a/block/manager.go b/block/manager.go index e43b465d8..8fef86189 100644 --- a/block/manager.go +++ b/block/manager.go @@ -413,18 +413,7 @@ func (m *Manager) setFraudHandler(handler *FreezeHandler) { } // freezeNode sets the node as unhealthy and prevents the node continues producing and processing blocks -func (m *Manager) freezeNode(ctx context.Context, rollapp *types.Rollapp, block *types.Block, err error) { - m.logger.Info( - "Freezing node due to fork update", - "local_block_height", - m.State.Height(), - "rollapp_revision_start_height", - rollapp.RevisionStartHeight, - "local_revision", - block.GetRevision(), - "rollapp_revision", - rollapp.Revision, - ) +func (m *Manager) freezeNode(ctx context.Context, err error) { m.frozen.Store(true) uevent.MustPublish(ctx, m.Pubsub, &events.DataHealthStatus{Error: err}, events.HealthStatusList) diff --git a/block/p2p.go b/block/p2p.go index cf51f8d2c..2a795456c 100644 --- a/block/p2p.go +++ b/block/p2p.go @@ -58,7 +58,7 @@ func (m *Manager) OnReceivedBlock(event pubsub.Message) { err := m.attemptApplyCachedBlocks() if err != nil { - m.freezeNode(context.Background(), nil, nil, err) + m.freezeNode(context.Background(), err) m.logger.Error("Attempt apply cached blocks.", "err", err) } } From 9cfdbd561acdc3516e651562134aaac629885c9c Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 12 Nov 2024 22:38:10 +0100 Subject: [PATCH 069/119] freeze refactor --- block/fork.go | 3 --- block/manager.go | 2 +- block/produce.go | 5 ----- block/submit.go | 6 +----- block/submit_loop_test.go | 6 ++---- 5 files changed, 4 insertions(+), 18 deletions(-) diff --git a/block/fork.go b/block/fork.go index 10b9fd9eb..b183af120 100644 --- a/block/fork.go +++ b/block/fork.go @@ -33,9 +33,6 @@ func (m *Manager) MonitorForkUpdateLoop(ctx context.Context) error { if err := m.checkForkUpdate(ctx); err != nil { continue } - if m.isFrozen() { - return nil - } } } } diff --git a/block/manager.go b/block/manager.go index 6124a7bf9..184bd414f 100644 --- a/block/manager.go +++ b/block/manager.go @@ -372,7 +372,7 @@ func (m *Manager) ValidateConfigWithRollappParams() error { return err } if uint32(currentDRS) != m.State.RollappParams.DrsVersion { - return fmt.Errorf("DRS version mismatch. rollapp param: %d binary used:%d", m.State.RollappParams.DrsVersion, drsVersion) + return fmt.Errorf("DRS version mismatch. rollapp param: %d binary used:%d", m.State.RollappParams.DrsVersion, currentDRS) } if da.Client(m.State.RollappParams.Da) != m.DAClient.GetClientType() { diff --git a/block/produce.go b/block/produce.go index 7938fffb5..bd6fc0dd6 100644 --- a/block/produce.go +++ b/block/produce.go @@ -45,11 +45,6 @@ func (m *Manager) ProduceBlockLoop(ctx context.Context, bytesProducedC chan int) continue } - // finish the block production loop in case the node is frozen - if m.isFrozen() { - return nil - } - // if empty blocks are configured to be enabled, and one is scheduled... produceEmptyBlock := firstBlock || m.Conf.MaxIdleTime == 0 || nextEmptyBlock.Before(time.Now()) firstBlock = false diff --git a/block/submit.go b/block/submit.go index 67d44ec76..c4f1c484e 100644 --- a/block/submit.go +++ b/block/submit.go @@ -35,7 +35,6 @@ func (m *Manager) SubmitLoop(ctx context.Context, m.Conf.BatchSubmitTime, m.Conf.BatchSubmitBytes, m.CreateAndSubmitBatchGetSizeBlocksCommits, - m.isFrozen, ) } @@ -49,7 +48,6 @@ func SubmitLoopInner( maxBatchTime time.Duration, // max time to allow between batches maxBatchBytes uint64, // max size of serialised batch in bytes createAndSubmitBatch func(maxSizeBytes uint64) (sizeBlocksCommits uint64, err error), - frozen func() bool, ) error { eg, ctx := errgroup.WithContext(ctx) @@ -97,9 +95,7 @@ func SubmitLoopInner( case <-ticker.C: case <-submitter.C: } - if frozen() { - return nil - } + pending := pendingBytes.Load() types.RollappPendingSubmissionsSkewBytes.Set(float64(pendingBytes.Load())) types.RollappPendingSubmissionsSkewBlocks.Set(float64(unsubmittedBlocks())) diff --git a/block/submit_loop_test.go b/block/submit_loop_test.go index 347e0b268..403adda52 100644 --- a/block/submit_loop_test.go +++ b/block/submit_loop_test.go @@ -113,10 +113,8 @@ func testSubmitLoopInner( accumulatedBlocks := func() uint64 { return pendingBlocks.Load() } - frozen := func() bool { - return false - } - block.SubmitLoopInner(ctx, log.NewNopLogger(), producedBytesC, args.batchSkew, accumulatedBlocks, args.maxTime, args.batchBytes, submitBatch, frozen) + + block.SubmitLoopInner(ctx, log.NewNopLogger(), producedBytesC, args.batchSkew, accumulatedBlocks, args.maxTime, args.batchBytes, submitBatch) } // Make sure the producer does not get too far ahead From 05d58ddf72193d25e7a4527142e185d55b127a3e Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 12 Nov 2024 23:05:32 +0100 Subject: [PATCH 070/119] addressing comments --- block/manager.go | 23 ++++++++----------- block/manager_test.go | 8 +++---- block/submit.go | 5 ++-- .../dymint/settlement/mock_ClientI.go | 21 ++++++++--------- settlement/dymension/dymension.go | 8 +++---- settlement/dymension/dymension_test.go | 2 +- settlement/grpc/grpc.go | 2 +- settlement/local/local.go | 2 +- settlement/local/local_test.go | 6 ++--- settlement/settlement.go | 2 +- types/batch.go | 1 + types/state.go | 8 +++++++ types/validation.go | 8 +++---- 13 files changed, 50 insertions(+), 46 deletions(-) diff --git a/block/manager.go b/block/manager.go index 184bd414f..c48e1cfe5 100644 --- a/block/manager.go +++ b/block/manager.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "strconv" "sync" "sync/atomic" @@ -192,21 +193,17 @@ func NewManager( // Upgrade revision on state state := m.State - state.Version.Consensus.App = instruction.Revision + state.SetRevision(instruction.Revision) state.RevisionStartHeight = instruction.RevisionStartHeight - /* if instruction.RevisionStartHeight == m.State.NextHeight() { - drsVersion, err := strconv.ParseUint(version.DrsVersion, 10, 32) - if err != nil { - return nil, fmt.Errorf("unable to parse drs version") - } - state.RollappParams.DrsVersion = uint32(drsVersion) - } - - TO BE TESTED and removed - - In theory this is happening on func (e *Executor) UpdateStateAfterCommit - */ + // this is necessary to pass ValidateConfigWithRollappParams when DRS upgrade is required + if instruction.RevisionStartHeight == m.State.NextHeight() { + drsVersion, err := strconv.ParseUint(version.DrsVersion, 10, 32) + if err != nil { + return nil, fmt.Errorf("unable to parse drs version") + } + state.RollappParams.DrsVersion = uint32(drsVersion) + } m.State = state } diff --git a/block/manager_test.go b/block/manager_test.go index 3a3aab845..a54351587 100644 --- a/block/manager_test.go +++ b/block/manager_test.go @@ -175,7 +175,7 @@ func TestProduceOnlyAfterSynced(t *testing.T) { assert.NoError(t, err) daResultSubmitBatch := manager.DAClient.SubmitBatch(batch) assert.Equal(t, daResultSubmitBatch.Code, da.StatusSuccess) - err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch, 0) + err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch) require.NoError(t, err) nextBatchStartHeight = batch.EndHeight() + 1 lastBlockHeaderHash = batch.Blocks[len(batch.Blocks)-1].Header.Hash() @@ -341,7 +341,7 @@ func TestApplyLocalBlock_WithFraudCheck(t *testing.T) { daResultSubmitBatch := manager.DAClient.SubmitBatch(batch) assert.Equal(t, daResultSubmitBatch.Code, da.StatusSuccess) - err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch, 0) + err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch) require.NoError(t, err) nextBatchStartHeight = batch.EndHeight() + 1 @@ -714,7 +714,7 @@ func TestDAFetch(t *testing.T) { require.NoError(err) daResultSubmitBatch := manager.DAClient.SubmitBatch(batch) require.Equal(daResultSubmitBatch.Code, da.StatusSuccess) - err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch, 0) + err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch) require.NoError(err) cases := []struct { @@ -808,7 +808,7 @@ func TestManager_ApplyBatchFromSL_FraudHandling(t *testing.T) { require.NoError(err) daResultSubmitBatch := manager.DAClient.SubmitBatch(batch) require.Equal(daResultSubmitBatch.Code, da.StatusSuccess) - err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch, 0) + err = manager.SLClient.SubmitBatch(batch, manager.DAClient.GetClientType(), &daResultSubmitBatch) require.NoError(err) // Mock Executor to return ErrFraud diff --git a/block/submit.go b/block/submit.go index c4f1c484e..9facdeef4 100644 --- a/block/submit.go +++ b/block/submit.go @@ -224,6 +224,7 @@ func (m *Manager) CreateBatch(maxBatchSize uint64, startHeight uint64, endHeight break } } + batch.Revision = batch.Blocks[len(batch.Blocks)-1].GetRevision() return batch, nil } @@ -235,9 +236,7 @@ func (m *Manager) SubmitBatch(batch *types.Batch) error { } m.logger.Info("Submitted batch to DA.", "start height", batch.StartHeight(), "end height", batch.EndHeight()) - revision := m.State.Version.Consensus.App - - err := m.SLClient.SubmitBatch(batch, m.DAClient.GetClientType(), &resultSubmitToDA, revision) + err := m.SLClient.SubmitBatch(batch, m.DAClient.GetClientType(), &resultSubmitToDA) if err != nil { return fmt.Errorf("sl client submit batch: start height: %d: end height: %d: %w", batch.StartHeight(), batch.EndHeight(), err) } diff --git a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go index 8afdb97d6..b531f2d00 100644 --- a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go +++ b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go @@ -862,17 +862,17 @@ func (_c *MockClientI_Stop_Call) RunAndReturn(run func() error) *MockClientI_Sto return _c } -// SubmitBatch provides a mock function with given fields: batch, daClient, daResult, revision -func (_m *MockClientI) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch, revision uint64) error { - ret := _m.Called(batch, daClient, daResult, revision) +// SubmitBatch provides a mock function with given fields: batch, daClient, daResult +func (_m *MockClientI) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) error { + ret := _m.Called(batch, daClient, daResult) if len(ret) == 0 { panic("no return value specified for SubmitBatch") } var r0 error - if rf, ok := ret.Get(0).(func(*types.Batch, da.Client, *da.ResultSubmitBatch, uint64) error); ok { - r0 = rf(batch, daClient, daResult, revision) + if rf, ok := ret.Get(0).(func(*types.Batch, da.Client, *da.ResultSubmitBatch) error); ok { + r0 = rf(batch, daClient, daResult) } else { r0 = ret.Error(0) } @@ -889,14 +889,13 @@ type MockClientI_SubmitBatch_Call struct { // - batch *types.Batch // - daClient da.Client // - daResult *da.ResultSubmitBatch -// - revision uint64 -func (_e *MockClientI_Expecter) SubmitBatch(batch interface{}, daClient interface{}, daResult interface{}, revision interface{}) *MockClientI_SubmitBatch_Call { - return &MockClientI_SubmitBatch_Call{Call: _e.mock.On("SubmitBatch", batch, daClient, daResult, revision)} +func (_e *MockClientI_Expecter) SubmitBatch(batch interface{}, daClient interface{}, daResult interface{}) *MockClientI_SubmitBatch_Call { + return &MockClientI_SubmitBatch_Call{Call: _e.mock.On("SubmitBatch", batch, daClient, daResult)} } -func (_c *MockClientI_SubmitBatch_Call) Run(run func(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch, revision uint64)) *MockClientI_SubmitBatch_Call { +func (_c *MockClientI_SubmitBatch_Call) Run(run func(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch)) *MockClientI_SubmitBatch_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*types.Batch), args[1].(da.Client), args[2].(*da.ResultSubmitBatch), args[3].(uint64)) + run(args[0].(*types.Batch), args[1].(da.Client), args[2].(*da.ResultSubmitBatch)) }) return _c } @@ -906,7 +905,7 @@ func (_c *MockClientI_SubmitBatch_Call) Return(_a0 error) *MockClientI_SubmitBat return _c } -func (_c *MockClientI_SubmitBatch_Call) RunAndReturn(run func(*types.Batch, da.Client, *da.ResultSubmitBatch, uint64) error) *MockClientI_SubmitBatch_Call { +func (_c *MockClientI_SubmitBatch_Call) RunAndReturn(run func(*types.Batch, da.Client, *da.ResultSubmitBatch) error) *MockClientI_SubmitBatch_Call { _c.Call.Return(run) return _c } diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index 27d11e4d5..3a008866e 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -113,8 +113,8 @@ func (c *Client) Stop() error { // SubmitBatch posts a batch to the Dymension Hub. it tries to post the batch until it is accepted by the settlement layer. // it emits success and failure events to the event bus accordingly. -func (c *Client) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch, revision uint64) error { - msgUpdateState, err := c.convertBatchToMsgUpdateState(batch, daResult, revision) +func (c *Client) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) error { + msgUpdateState, err := c.convertBatchToMsgUpdateState(batch, daResult) if err != nil { return fmt.Errorf("convert batch to msg update state: %w", err) } @@ -634,7 +634,7 @@ func (c *Client) broadcastBatch(msgUpdateState *rollapptypes.MsgUpdateState) err return nil } -func (c *Client) convertBatchToMsgUpdateState(batch *types.Batch, daResult *da.ResultSubmitBatch, rollappRevision uint64) (*rollapptypes.MsgUpdateState, error) { +func (c *Client) convertBatchToMsgUpdateState(batch *types.Batch, daResult *da.ResultSubmitBatch) (*rollapptypes.MsgUpdateState, error) { account, err := c.cosmosClient.GetAccount(c.config.DymAccountName) if err != nil { return nil, fmt.Errorf("get account: %w", err) @@ -664,7 +664,7 @@ func (c *Client) convertBatchToMsgUpdateState(batch *types.Batch, daResult *da.R DAPath: daResult.SubmitMetaData.ToPath(), BDs: rollapptypes.BlockDescriptors{BD: blockDescriptors}, Last: batch.LastBatch, - RollappRevision: rollappRevision, + RollappRevision: batch.Revision, } return settlementBatch, nil } diff --git a/settlement/dymension/dymension_test.go b/settlement/dymension/dymension_test.go index 07ebbf6f0..1ee60eb0e 100644 --- a/settlement/dymension/dymension_test.go +++ b/settlement/dymension/dymension_test.go @@ -179,7 +179,7 @@ func TestPostBatch(t *testing.T) { errChan := make(chan error, 1) // Create a channel to receive an error from the goroutine // Post the batch in a goroutine and capture any error. go func() { - err := hubClient.SubmitBatch(batch, da.Mock, resultSubmitBatch, 0) + err := hubClient.SubmitBatch(batch, da.Mock, resultSubmitBatch) errChan <- err // Send any error to the errChan }() diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index c00c7aba2..969adaf8b 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -193,7 +193,7 @@ func (c *Client) Stop() error { } // SubmitBatch saves the batch to the kv store -func (c *Client) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch, revision uint64) error { +func (c *Client) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) error { settlementBatch := c.convertBatchtoSettlementBatch(batch, daResult) err := c.saveBatch(settlementBatch) if err != nil { diff --git a/settlement/local/local.go b/settlement/local/local.go index 9a308820b..30f1372bc 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -146,7 +146,7 @@ func (c *Client) Stop() error { } // PostBatch saves the batch to the kv store -func (c *Client) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch, revision uint64) error { +func (c *Client) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) error { settlementBatch := c.convertBatchToSettlementBatch(batch, daResult) err := c.saveBatch(settlementBatch) if err != nil { diff --git a/settlement/local/local_test.go b/settlement/local/local_test.go index 6d62e2986..6a1c5deb8 100644 --- a/settlement/local/local_test.go +++ b/settlement/local/local_test.go @@ -68,7 +68,7 @@ func TestSubmitBatch(t *testing.T) { resultSubmitBatch.SubmitMetaData = &da.DASubmitMetaData{} // Submit the first batch and check if it was successful - err = sllayer.SubmitBatch(batch1, da.Mock, resultSubmitBatch, 0) + err = sllayer.SubmitBatch(batch1, da.Mock, resultSubmitBatch) assert.NoError(err) assert.True(resultSubmitBatch.Code == 0) // success code @@ -86,7 +86,7 @@ func TestSubmitBatch(t *testing.T) { assert.Equal(batch1.EndHeight(), queriedBatch.Batch.EndHeight) // Submit the 2nd batch and check if it was successful - err = sllayer.SubmitBatch(batch2, da.Mock, resultSubmitBatch, 0) + err = sllayer.SubmitBatch(batch2, da.Mock, resultSubmitBatch) assert.NoError(err) assert.True(resultSubmitBatch.Code == 0) // success code @@ -140,7 +140,7 @@ func TestPersistency(t *testing.T) { resultSubmitBatch.SubmitMetaData = &da.DASubmitMetaData{} // Submit the first batch and check if it was successful - err = sllayer.SubmitBatch(batch1, da.Mock, resultSubmitBatch, 0) + err = sllayer.SubmitBatch(batch1, da.Mock, resultSubmitBatch) assert.NoError(err) assert.True(resultSubmitBatch.Code == 0) // success code diff --git a/settlement/settlement.go b/settlement/settlement.go index f8e96ab2b..9859dafcb 100644 --- a/settlement/settlement.go +++ b/settlement/settlement.go @@ -72,7 +72,7 @@ type ClientI interface { Stop() error // SubmitBatch tries submitting the batch in an async way to the settlement layer. This should create a transaction which (potentially) // triggers a state transition in the settlement layer. Events are emitted on success or failure. - SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch, revision uint64) error + SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) error // GetLatestBatch returns the latest batch from the settlement layer. GetLatestBatch() (*ResultRetrieveBatch, error) // GetBatchAtIndex returns the batch at the given index. diff --git a/types/batch.go b/types/batch.go index ea2377144..14d486539 100644 --- a/types/batch.go +++ b/types/batch.go @@ -12,6 +12,7 @@ type Batch struct { // LastBatch is true if this is the last batch of the sequencer (i.e completes it's rotation flow). LastBatch bool DRSVersion []uint32 + Revision uint64 } // StartHeight is the height of the first block in the batch. diff --git a/types/state.go b/types/state.go index d76a55735..a02a8355e 100644 --- a/types/state.go +++ b/types/state.go @@ -118,3 +118,11 @@ func (s *State) SetRollappParamsFromGenesis(appState json.RawMessage) error { s.RollappParams = *rollappParams.Params return nil } + +func (s *State) GetRevision() uint64 { + return s.Version.Consensus.App +} + +func (s *State) SetRevision(revision uint64) { + s.Version.Consensus.App = revision +} diff --git a/types/validation.go b/types/validation.go index a23a3e780..8506e898c 100644 --- a/types/validation.go +++ b/types/validation.go @@ -69,12 +69,12 @@ func (b *Block) ValidateWithState(state *State) error { // FIXME(srene): temporary solution for hardfork syncing, but this does not support multiple hardforks per rollapp // https://github.com/dymensionxyz/dymint/issues/1210 - appVersion := state.Version.Consensus.App - if b.Header.Height < state.RevisionStartHeight { - appVersion-- + revision := uint64(0) + if b.Header.Height >= state.RevisionStartHeight { + revision = state.GetRevision() } - if b.Header.Version.App != appVersion || + if b.Header.Version.App != revision || b.Header.Version.Block != state.Version.Consensus.Block { return ErrVersionMismatch } From d4a2bab8e6db8f3912ebf4fd64748d816564e0eb Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 12 Nov 2024 23:15:56 +0100 Subject: [PATCH 071/119] addressing comments --- block/manager.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/block/manager.go b/block/manager.go index c48e1cfe5..a893a32c3 100644 --- a/block/manager.go +++ b/block/manager.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "strconv" "sync" "sync/atomic" @@ -198,11 +197,11 @@ func NewManager( // this is necessary to pass ValidateConfigWithRollappParams when DRS upgrade is required if instruction.RevisionStartHeight == m.State.NextHeight() { - drsVersion, err := strconv.ParseUint(version.DrsVersion, 10, 32) + drsVersion, err := version.CurrentDRSVersion() if err != nil { - return nil, fmt.Errorf("unable to parse drs version") + return nil, err } - state.RollappParams.DrsVersion = uint32(drsVersion) + state.RollappParams.DrsVersion = drsVersion } m.State = state From 3eae06570be0676143a47ad38af3d35585b7aaf1 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 12 Nov 2024 23:17:36 +0100 Subject: [PATCH 072/119] lint fix --- block/fork.go | 1 - block/manager.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/block/fork.go b/block/fork.go index b183af120..5cac1f7d2 100644 --- a/block/fork.go +++ b/block/fork.go @@ -21,7 +21,6 @@ const ( // MonitorForkUpdateLoop monitors the hub for fork updates in a loop func (m *Manager) MonitorForkUpdateLoop(ctx context.Context) error { - ticker := time.NewTicker(LoopInterval) // TODO make this configurable defer ticker.Stop() diff --git a/block/manager.go b/block/manager.go index a893a32c3..b9895bd16 100644 --- a/block/manager.go +++ b/block/manager.go @@ -367,7 +367,7 @@ func (m *Manager) ValidateConfigWithRollappParams() error { if err != nil { return err } - if uint32(currentDRS) != m.State.RollappParams.DrsVersion { + if currentDRS != m.State.RollappParams.DrsVersion { return fmt.Errorf("DRS version mismatch. rollapp param: %d binary used:%d", m.State.RollappParams.DrsVersion, currentDRS) } From 45fe640080e67d3e4ec13a4b179c2c4e88dfaa69 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Wed, 13 Nov 2024 10:01:26 +0100 Subject: [PATCH 073/119] check againgst prefork drs --- block/fork.go | 33 ++++++++++++++++++++++++++------- types/instruction.go | 1 + 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/block/fork.go b/block/fork.go index 5cac1f7d2..b2767d04f 100644 --- a/block/fork.go +++ b/block/fork.go @@ -68,10 +68,15 @@ func (m *Manager) createInstruction(rollapp *types.Rollapp) error { if err != nil { return err } + currentDRS, err := version.CurrentDRSVersion() + if err != nil { + return err + } instruction := types.Instruction{ Revision: rollapp.Revision, RevisionStartHeight: rollapp.RevisionStartHeight, FaultyDRS: obsoleteDrs, + DRSPreFork: currentDRS, } err = types.PersistInstructionToDisk(m.RootDir, instruction) @@ -107,14 +112,19 @@ func (m *Manager) forkNeeded() (types.Instruction, bool) { // handleSequencerForkTransition handles the sequencer fork transition func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { - consensusMsgs, err := m.prepareDRSUpgradeMessages(instruction.FaultyDRS) - if err != nil { - panic(fmt.Sprintf("prepare DRS upgrade messages: %v", err)) + + var consensusMsgs []proto.Message + if isDRSFaulty(instruction.DRSPreFork, instruction.FaultyDRS) { + msgs, err := m.prepareDRSUpgradeMessages(instruction.FaultyDRS) + if err != nil { + panic(fmt.Sprintf("prepare DRS upgrade messages: %v", err)) + } + consensusMsgs = append(consensusMsgs, msgs...) } // Always bump the account sequences consensusMsgs = append(consensusMsgs, &sequencers.MsgBumpAccountSequences{Authority: authtypes.NewModuleAddress("sequencers").String()}) - err = m.handleCreationOfForkBlocks(instruction, consensusMsgs) + err := m.handleCreationOfForkBlocks(instruction, consensusMsgs) if err != nil { panic(fmt.Sprintf("validate existing blocks: %v", err)) } @@ -132,14 +142,12 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { // - Validates the current DRS version against the potentially faulty version // - Generates an upgrade message with the current valid DRS version func (m *Manager) prepareDRSUpgradeMessages(faultyDRS []uint32) ([]proto.Message, error) { - if len(faultyDRS) == 0 { - return nil, nil - } currentDRS, err := version.CurrentDRSVersion() if err != nil { return nil, err } + for _, drs := range faultyDRS { if drs == currentDRS { return nil, fmt.Errorf("running faulty DRS version %d", drs) @@ -244,3 +252,14 @@ func (m *Manager) handleForkBatchSubmission(height uint64) error { return nil } + +func isDRSFaulty(drs uint32, faultyDRS []uint32) bool { + + found := false + for _, faulty := range faultyDRS { + if drs == faulty { + return true + } + } + return found +} diff --git a/types/instruction.go b/types/instruction.go index e7588136e..885e25237 100644 --- a/types/instruction.go +++ b/types/instruction.go @@ -10,6 +10,7 @@ type Instruction struct { Revision uint64 RevisionStartHeight uint64 FaultyDRS []uint32 + DRSPreFork uint32 } const instructionFileName = "instruction.json" From 90365f686640e2f2ce2108b111b6681b182f8a4e Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 13 Nov 2024 10:08:00 +0100 Subject: [PATCH 074/119] be more defensive in fork --- block/fork.go | 98 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 37 deletions(-) diff --git a/block/fork.go b/block/fork.go index 5cac1f7d2..5ca22230a 100644 --- a/block/fork.go +++ b/block/fork.go @@ -154,68 +154,92 @@ func (m *Manager) prepareDRSUpgradeMessages(faultyDRS []uint32) ([]proto.Message }, nil } -// handleCreationOfForkBlocks manages the block creation process during a fork transition. -// -// The function implements the following logic: -// 1. Checks if blocks for the fork transition have already been created by comparing heights -// 2. If blocks exist (NextHeight == RevisionStartHeight + 2), validates their state -// 3. If blocks don't exist, triggers the creation of new blocks with the provided consensus messages -// // Block Creation Rules: // - Two blocks are considered in this process: // - First block: Contains consensus messages for the fork // - Second block: Should be empty (no messages or transactions) // - Total height increase should be 2 blocks from RevisionStartHeight func (m *Manager) handleCreationOfForkBlocks(instruction types.Instruction, consensusMsgs []proto.Message) error { - if m.State.NextHeight() == instruction.RevisionStartHeight+2 { - return m.validateExistingBlocks(instruction) + nextHeight := m.State.NextHeight() + heightDiff := nextHeight - instruction.RevisionStartHeight + + // Case 1: Both blocks already exist (heightDiff == 2) + if heightDiff == 2 { + return m.validateExistingBlocks(instruction, 2) + } + + // Case 2: First block exists (heightDiff == 1) + if heightDiff == 1 { + if err := m.validateExistingBlocks(instruction, 1); err != nil { + return err + } + return m.createNewBlocks(consensusMsgs, 1) // Create only the second block + } + + // Case 3: No blocks exist yet (heightDiff == 0) + if heightDiff == 0 { + return m.createNewBlocks(consensusMsgs, 2) // Create both blocks } - return m.createNewBlocks(consensusMsgs) + return fmt.Errorf("unexpected height difference: %d", heightDiff) } -// validateExistingBlocks performs validation checks on a pair of consecutive blocks -// during the sequencer fork transition process. +// validateExistingBlocks validates one or two consecutive blocks based on +// the specified number of blocks to validate. // -// The function performs the following validations: -// 1. Verifies that the initial block at RevisionStartHeight exists and contains consensus messages -// 2. Confirms that the subsequent block exists and is empty (no consensus messages or transactions) -func (m *Manager) validateExistingBlocks(instruction types.Instruction) error { - block, err := m.Store.LoadBlock(instruction.RevisionStartHeight) - if err != nil { - return fmt.Errorf("loading block: %v", err) - } +// Validation process: +// 1. For the first block (if numBlocksToValidate > 0): +// - Verifies it contains consensus messages +// 2. For the second block (if numBlocksToValidate > 1): +// - Verifies it does NOT contain consensus messages +// - Verifies it does NOT contain transactions +// - Basically, that is empty. +func (m *Manager) validateExistingBlocks(instruction types.Instruction, numBlocksToValidate uint64) error { + if numBlocksToValidate > 0 { + block, err := m.Store.LoadBlock(instruction.RevisionStartHeight) + if err != nil { + return fmt.Errorf("loading block: %v", err) + } - if len(block.Data.ConsensusMessages) <= 0 { - return fmt.Errorf("expected consensus messages in block") + if len(block.Data.ConsensusMessages) <= 0 { + return fmt.Errorf("expected consensus messages in block") + } } - nextBlock, err := m.Store.LoadBlock(instruction.RevisionStartHeight + 1) - if err != nil { - return fmt.Errorf("loading next block: %v", err) - } + if numBlocksToValidate > 1 { + nextBlock, err := m.Store.LoadBlock(instruction.RevisionStartHeight + 1) + if err != nil { + return fmt.Errorf("loading next block: %v", err) + } - if len(nextBlock.Data.ConsensusMessages) > 0 { - return fmt.Errorf("unexpected consensus messages in next block") - } + if len(nextBlock.Data.ConsensusMessages) > 0 { + return fmt.Errorf("unexpected consensus messages in next block") + } - if len(nextBlock.Data.Txs) > 0 { - return fmt.Errorf("unexpected transactions in next block") + if len(nextBlock.Data.Txs) > 0 { + return fmt.Errorf("unexpected transactions in next block") + } } return nil } -// createNewBlocks creates new blocks with the provided consensus messages -func (m *Manager) createNewBlocks(consensusMsgs []proto.Message) error { +// createNewBlocks creates new blocks with the provided consensus messages. +// If blocksToCreate is 1, it creates only the second (empty) block. +// If blocksToCreate is 2, it creates both the first block (with consensus messages) +// and the second empty block. +func (m *Manager) createNewBlocks(consensusMsgs []proto.Message, blocksToCreate uint64) error { + // Add consensus messages regardless of blocks to create m.Executor.AddConsensusMsgs(consensusMsgs...) - // Create first block with consensus messages - if _, _, err := m.ProduceApplyGossipBlock(context.Background(), true); err != nil { - return fmt.Errorf("producing first block: %v", err) + // Create first block with consensus messages if blocksToCreate == 2 + if blocksToCreate == 2 { + if _, _, err := m.ProduceApplyGossipBlock(context.Background(), true); err != nil { + return fmt.Errorf("producing first block: %v", err) + } } - // Create second empty block + // Create second empty block for both cases (blocksToCreate == 1 or 2) if _, _, err := m.ProduceApplyGossipBlock(context.Background(), true); err != nil { return fmt.Errorf("producing second block: %v", err) } From 67ff0ca2d03c64c964ba74d024d9879a2dbb45b2 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 13 Nov 2024 10:11:43 +0100 Subject: [PATCH 075/119] remove unused func --- block/fork.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/block/fork.go b/block/fork.go index 55e2b207b..47baa6c34 100644 --- a/block/fork.go +++ b/block/fork.go @@ -278,12 +278,10 @@ func (m *Manager) handleForkBatchSubmission(height uint64) error { } func isDRSFaulty(drs uint32, faultyDRS []uint32) bool { - - found := false for _, faulty := range faultyDRS { if drs == faulty { return true } } - return found + return false } From dbdccfb09fe8466a5e158b793e1f95d01de6eb7d Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Wed, 13 Nov 2024 10:51:49 +0100 Subject: [PATCH 076/119] send drs upgrade cns mssg in all cases --- block/fork.go | 29 +++++------------------------ types/instruction.go | 1 - 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/block/fork.go b/block/fork.go index 55e2b207b..aa90a0333 100644 --- a/block/fork.go +++ b/block/fork.go @@ -68,15 +68,11 @@ func (m *Manager) createInstruction(rollapp *types.Rollapp) error { if err != nil { return err } - currentDRS, err := version.CurrentDRSVersion() - if err != nil { - return err - } + instruction := types.Instruction{ Revision: rollapp.Revision, RevisionStartHeight: rollapp.RevisionStartHeight, FaultyDRS: obsoleteDrs, - DRSPreFork: currentDRS, } err = types.PersistInstructionToDisk(m.RootDir, instruction) @@ -113,18 +109,14 @@ func (m *Manager) forkNeeded() (types.Instruction, bool) { // handleSequencerForkTransition handles the sequencer fork transition func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { - var consensusMsgs []proto.Message - if isDRSFaulty(instruction.DRSPreFork, instruction.FaultyDRS) { - msgs, err := m.prepareDRSUpgradeMessages(instruction.FaultyDRS) - if err != nil { - panic(fmt.Sprintf("prepare DRS upgrade messages: %v", err)) - } - consensusMsgs = append(consensusMsgs, msgs...) + consensusMsgs, err := m.prepareDRSUpgradeMessages(instruction.FaultyDRS) + if err != nil { + panic(fmt.Sprintf("prepare DRS upgrade messages: %v", err)) } // Always bump the account sequences consensusMsgs = append(consensusMsgs, &sequencers.MsgBumpAccountSequences{Authority: authtypes.NewModuleAddress("sequencers").String()}) - err := m.handleCreationOfForkBlocks(instruction, consensusMsgs) + err = m.handleCreationOfForkBlocks(instruction, consensusMsgs) if err != nil { panic(fmt.Sprintf("validate existing blocks: %v", err)) } @@ -276,14 +268,3 @@ func (m *Manager) handleForkBatchSubmission(height uint64) error { return nil } - -func isDRSFaulty(drs uint32, faultyDRS []uint32) bool { - - found := false - for _, faulty := range faultyDRS { - if drs == faulty { - return true - } - } - return found -} diff --git a/types/instruction.go b/types/instruction.go index 885e25237..e7588136e 100644 --- a/types/instruction.go +++ b/types/instruction.go @@ -10,7 +10,6 @@ type Instruction struct { Revision uint64 RevisionStartHeight uint64 FaultyDRS []uint32 - DRSPreFork uint32 } const instructionFileName = "instruction.json" From cbb4b09d91d29f2a81e91e90b1cbe9cda41e77da Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Wed, 13 Nov 2024 10:53:49 +0100 Subject: [PATCH 077/119] lint fix --- block/fork.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/block/fork.go b/block/fork.go index aa90a0333..da05fb940 100644 --- a/block/fork.go +++ b/block/fork.go @@ -108,7 +108,6 @@ func (m *Manager) forkNeeded() (types.Instruction, bool) { // handleSequencerForkTransition handles the sequencer fork transition func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { - consensusMsgs, err := m.prepareDRSUpgradeMessages(instruction.FaultyDRS) if err != nil { panic(fmt.Sprintf("prepare DRS upgrade messages: %v", err)) @@ -134,7 +133,6 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { // - Validates the current DRS version against the potentially faulty version // - Generates an upgrade message with the current valid DRS version func (m *Manager) prepareDRSUpgradeMessages(faultyDRS []uint32) ([]proto.Message, error) { - currentDRS, err := version.CurrentDRSVersion() if err != nil { return nil, err From 48da75305fb15bca99b2e2a81927ccccc9976c7a Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 13 Nov 2024 16:30:20 +0100 Subject: [PATCH 078/119] instruction exist --- block/fork.go | 7 +++++++ types/instruction.go | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/block/fork.go b/block/fork.go index 47baa6c34..ff30284b9 100644 --- a/block/fork.go +++ b/block/fork.go @@ -21,6 +21,13 @@ const ( // MonitorForkUpdateLoop monitors the hub for fork updates in a loop func (m *Manager) MonitorForkUpdateLoop(ctx context.Context) error { + if !types.InstructionExists(m.RootDir) { + err := m.checkForkUpdate(ctx) + if err != nil { + return err + } + } + ticker := time.NewTicker(LoopInterval) // TODO make this configurable defer ticker.Stop() diff --git a/types/instruction.go b/types/instruction.go index 885e25237..d1d8dc5eb 100644 --- a/types/instruction.go +++ b/types/instruction.go @@ -46,6 +46,12 @@ func LoadInstructionFromDisk(dir string) (Instruction, error) { return instruction, nil } +func InstructionExists(dir string) bool { + filePath := filepath.Join(dir, instructionFileName) + _, err := os.Stat(filePath) + return !os.IsNotExist(err) +} + func DeleteInstructionFromDisk(dir string) error { filePath := filepath.Join(dir, instructionFileName) err := os.Remove(filePath) From f20fadc5ae6508a66c3deb1c57db57b0516d6d13 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Wed, 13 Nov 2024 18:04:12 +0100 Subject: [PATCH 079/119] remove unused function --- block/fork.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/block/fork.go b/block/fork.go index fbc2e91cd..b4658249f 100644 --- a/block/fork.go +++ b/block/fork.go @@ -273,12 +273,3 @@ func (m *Manager) handleForkBatchSubmission(height uint64) error { return nil } - -func isDRSFaulty(drs uint32, faultyDRS []uint32) bool { - for _, faulty := range faultyDRS { - if drs == faulty { - return true - } - } - return false -} From af24f127b271a624eafec58c679abd25db44f9b3 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Thu, 14 Nov 2024 12:19:00 +0100 Subject: [PATCH 080/119] bytes in block hash err --- block/slvalidator.go | 2 +- go.mod | 4 ++-- types/errors.go | 41 +++++++++++++++++++++++++++-------------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/block/slvalidator.go b/block/slvalidator.go index 874fb9eb2..7c30ba017 100644 --- a/block/slvalidator.go +++ b/block/slvalidator.go @@ -131,7 +131,7 @@ func (v *SettlementValidator) ValidateP2PBlocks(daBlocks []*types.Block, p2pBloc return err } if !bytes.Equal(p2pBlockHash, daBlockHash) { - return types.NewErrStateUpdateDoubleSigningFraud(daBlock, p2pBlock) + return types.NewErrStateUpdateDoubleSigningFraud(daBlock, p2pBlock, daBlockHash, p2pBlockHash) } } diff --git a/go.mod b/go.mod index b3dafd634..b438193c9 100644 --- a/go.mod +++ b/go.mod @@ -77,7 +77,7 @@ require ( github.com/cometbft/cometbft v0.37.2 github.com/cometbft/cometbft-db v0.11.0 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/gogoproto v1.5.0 + github.com/cosmos/gogoproto v1.5.0 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect github.com/deckarep/golang-set v1.8.0 // indirect github.com/decred/base58 v1.0.4 // indirect @@ -120,7 +120,7 @@ require ( go.uber.org/fx v1.20.1 // indirect golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 + google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect sigs.k8s.io/yaml v1.4.0 // indirect diff --git a/types/errors.go b/types/errors.go index 8323e077e..32b591f0c 100644 --- a/types/errors.go +++ b/types/errors.go @@ -420,27 +420,40 @@ func (e ErrStateUpdateTimestampNotMatchingFraud) Unwrap() error { } type ErrStateUpdateDoubleSigningFraud struct { - DABlock []byte - P2PBlock []byte + DABlock *Block + P2PBlock *Block + DABlockHash []byte + P2PBlockHash []byte } -func NewErrStateUpdateDoubleSigningFraud(daBlock *Block, p2pBlock *Block) error { - jsonDABlock, err := getJsonFromBlock(daBlock) - if err != nil { - return err - } - jsonP2PBlock, err := getJsonFromBlock(p2pBlock) - if err != nil { - return err - } +func NewErrStateUpdateDoubleSigningFraud(daBlock *Block, p2pBlock *Block, daBlockHash []byte, p2pBlockHash []byte) error { + return &ErrStateUpdateDoubleSigningFraud{ - DABlock: jsonDABlock, - P2PBlock: jsonP2PBlock, + DABlock: daBlock, + P2PBlock: p2pBlock, + DABlockHash: daBlockHash, + P2PBlockHash: p2pBlockHash, } } func (e ErrStateUpdateDoubleSigningFraud) Error() string { - return fmt.Sprintf("block received from P2P not matching block found in DA. P2P Block: %s DA Block:%s", e.P2PBlock, e.DABlock) + jsonDABlock, err := getJsonFromBlock(e.DABlock) + if err != nil { + return fmt.Sprintf("err json da block:%s", err) + } + jsonP2PBlock, err := getJsonFromBlock(e.P2PBlock) + if err != nil { + return fmt.Sprintf("err json p2p block:%s", err) + } + p2pBlockBytes, err := e.P2PBlock.MarshalBinary() + if err != nil { + return fmt.Sprintf("err marshal p2p block:%s", err) + } + daBlockBytes, err := e.DABlock.MarshalBinary() + if err != nil { + return fmt.Sprintf("err marshal da block:%s", err) + } + return fmt.Sprintf("block received from P2P not matching block found in DA. \n P2P Json Block: %s \n DA Json Block:%s \n P2P Block hash:%s \n DA block hash:%s \n P2P block bytes:%s \n DA Block bytes:%s \n", jsonP2PBlock, jsonDABlock, hex.EncodeToString(e.P2PBlockHash), hex.EncodeToString(e.DABlockHash), hex.EncodeToString(p2pBlockBytes), hex.EncodeToString(daBlockBytes)) } func (e ErrStateUpdateDoubleSigningFraud) Unwrap() error { From f353a9dfe6d1d411011b65f5813d202ed1d0b3f2 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Thu, 14 Nov 2024 12:44:43 +0100 Subject: [PATCH 081/119] lint fix --- types/errors.go | 1 - 1 file changed, 1 deletion(-) diff --git a/types/errors.go b/types/errors.go index 32b591f0c..ae722c029 100644 --- a/types/errors.go +++ b/types/errors.go @@ -427,7 +427,6 @@ type ErrStateUpdateDoubleSigningFraud struct { } func NewErrStateUpdateDoubleSigningFraud(daBlock *Block, p2pBlock *Block, daBlockHash []byte, p2pBlockHash []byte) error { - return &ErrStateUpdateDoubleSigningFraud{ DABlock: daBlock, P2PBlock: p2pBlock, From db18434669c2808fdb1be58797a57112dc037e99 Mon Sep 17 00:00:00 2001 From: Daniel T <30197399+danwt@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:04:50 +0000 Subject: [PATCH 082/119] tweaks fixes (#1233) --- block/fork.go | 151 ++++++++++++--------------------------- block/manager.go | 15 ++-- block/manager_test.go | 24 +++---- block/modes.go | 2 +- block/produce.go | 36 ++++++---- block/production_test.go | 4 +- block/pruning_test.go | 5 +- block/sequencers.go | 2 +- block/submit_test.go | 4 +- rpc/client/client.go | 2 +- testutil/types.go | 8 +-- version/version.go | 17 +---- 12 files changed, 101 insertions(+), 169 deletions(-) diff --git a/block/fork.go b/block/fork.go index b4658249f..375be324f 100644 --- a/block/fork.go +++ b/block/fork.go @@ -21,24 +21,21 @@ const ( // MonitorForkUpdateLoop monitors the hub for fork updates in a loop func (m *Manager) MonitorForkUpdateLoop(ctx context.Context) error { - if !types.InstructionExists(m.RootDir) { - err := m.checkForkUpdate(ctx) - if err != nil { - return err - } + if types.InstructionExists(m.RootDir) { // TODO: why do we have this check + return nil } ticker := time.NewTicker(LoopInterval) // TODO make this configurable defer ticker.Stop() for { + if err := m.checkForkUpdate(ctx); err != nil { + m.logger.Error("Check for update.", err) + } select { case <-ctx.Done(): - return nil + return ctx.Err() case <-ticker.C: - if err := m.checkForkUpdate(ctx); err != nil { - continue - } } } } @@ -113,8 +110,7 @@ func (m *Manager) forkNeeded() (types.Instruction, bool) { return types.Instruction{}, false } -// handleSequencerForkTransition handles the sequencer fork transition -func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { +func (m *Manager) doFork(instruction types.Instruction) { consensusMsgs, err := m.prepareDRSUpgradeMessages(instruction.FaultyDRS) if err != nil { panic(fmt.Sprintf("prepare DRS upgrade messages: %v", err)) @@ -122,12 +118,12 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { // Always bump the account sequences consensusMsgs = append(consensusMsgs, &sequencers.MsgBumpAccountSequences{Authority: authtypes.NewModuleAddress("sequencers").String()}) - err = m.handleCreationOfForkBlocks(instruction, consensusMsgs) + err = m.createForkBlocks(instruction, consensusMsgs) if err != nil { panic(fmt.Sprintf("validate existing blocks: %v", err)) } - if err := m.handleForkBatchSubmission(instruction.RevisionStartHeight); err != nil { + if err := m.submitForkBatch(instruction.RevisionStartHeight); err != nil { panic(fmt.Sprintf("ensure batch exists: %v", err)) } } @@ -139,136 +135,81 @@ func (m *Manager) handleSequencerForkTransition(instruction types.Instruction) { // - If no faulty DRS version is provided (faultyDRS is nil), returns no messages // - Validates the current DRS version against the potentially faulty version // - Generates an upgrade message with the current valid DRS version -func (m *Manager) prepareDRSUpgradeMessages(faultyDRS []uint32) ([]proto.Message, error) { - currentDRS, err := version.CurrentDRSVersion() - if err != nil { - return nil, err - } +func (m *Manager) prepareDRSUpgradeMessages(obsoleteDRS []uint32) ([]proto.Message, error) { - for _, drs := range faultyDRS { - if drs == currentDRS { - return nil, fmt.Errorf("running faulty DRS version %d", drs) + for _, drs := range obsoleteDRS { + if drs == version.DRS { + return nil, gerrc.ErrCancelled.Wrapf("obsolete DRS version: %d", drs) } } return []proto.Message{ &sequencers.MsgUpgradeDRS{ Authority: authtypes.NewModuleAddress("sequencers").String(), - DrsVersion: uint64(currentDRS), + DrsVersion: uint64(version.DRS), }, }, nil } -// Block Creation Rules: -// - Two blocks are considered in this process: -// - First block: Contains consensus messages for the fork -// - Second block: Should be empty (no messages or transactions) -// - Total height increase should be 2 blocks from RevisionStartHeight -func (m *Manager) handleCreationOfForkBlocks(instruction types.Instruction, consensusMsgs []proto.Message) error { +// create the first two blocks of the new revision +// the first one should have a cons message(s) +// both should not have tx's +func (m *Manager) createForkBlocks(instruction types.Instruction, consensusMsgs []proto.Message) error { nextHeight := m.State.NextHeight() - heightDiff := nextHeight - instruction.RevisionStartHeight - - // Case 1: Both blocks already exist (heightDiff == 2) - if heightDiff == 2 { - return m.validateExistingBlocks(instruction, 2) - } - - // Case 2: First block exists (heightDiff == 1) - if heightDiff == 1 { - if err := m.validateExistingBlocks(instruction, 1); err != nil { - return err - } - return m.createNewBlocks(consensusMsgs, 1) // Create only the second block - } - - // Case 3: No blocks exist yet (heightDiff == 0) - if heightDiff == 0 { - return m.createNewBlocks(consensusMsgs, 2) // Create both blocks - } - - return fmt.Errorf("unexpected height difference: %d", heightDiff) -} -// validateExistingBlocks validates one or two consecutive blocks based on -// the specified number of blocks to validate. -// -// Validation process: -// 1. For the first block (if numBlocksToValidate > 0): -// - Verifies it contains consensus messages -// 2. For the second block (if numBlocksToValidate > 1): -// - Verifies it does NOT contain consensus messages -// - Verifies it does NOT contain transactions -// - Basically, that is empty. -func (m *Manager) validateExistingBlocks(instruction types.Instruction, numBlocksToValidate uint64) error { - if numBlocksToValidate > 0 { - block, err := m.Store.LoadBlock(instruction.RevisionStartHeight) + // Something already been created? + // TODO: how is possible to have more than one already created? Crash failure should result in at most one. + for h := instruction.RevisionStartHeight; h < nextHeight; h++ { + b, err := m.Store.LoadBlock(h) if err != nil { - return fmt.Errorf("loading block: %v", err) + return gerrc.ErrInternal.Wrapf("load stored blocks: %d", h) } - if len(block.Data.ConsensusMessages) <= 0 { - return fmt.Errorf("expected consensus messages in block") - } - } - - if numBlocksToValidate > 1 { - nextBlock, err := m.Store.LoadBlock(instruction.RevisionStartHeight + 1) - if err != nil { - return fmt.Errorf("loading next block: %v", err) + if 0 < len(b.Data.Txs) { + return gerrc.ErrInternal.Wrapf("fork block has tx: %d", h) } - if len(nextBlock.Data.ConsensusMessages) > 0 { - return fmt.Errorf("unexpected consensus messages in next block") - } - - if len(nextBlock.Data.Txs) > 0 { - return fmt.Errorf("unexpected transactions in next block") + if (h == instruction.RevisionStartHeight) != (0 < len(b.Data.ConsensusMessages)) { + return gerrc.ErrInternal.Wrapf("fork block has wrong num cons messages: %d", h) } } - return nil -} - -// createNewBlocks creates new blocks with the provided consensus messages. -// If blocksToCreate is 1, it creates only the second (empty) block. -// If blocksToCreate is 2, it creates both the first block (with consensus messages) -// and the second empty block. -func (m *Manager) createNewBlocks(consensusMsgs []proto.Message, blocksToCreate uint64) error { - // Add consensus messages regardless of blocks to create - m.Executor.AddConsensusMsgs(consensusMsgs...) - - // Create first block with consensus messages if blocksToCreate == 2 - if blocksToCreate == 2 { - if _, _, err := m.ProduceApplyGossipBlock(context.Background(), true); err != nil { - return fmt.Errorf("producing first block: %v", err) + for h := nextHeight; h < instruction.RevisionStartHeight+2; h++ { + if h == instruction.RevisionStartHeight { + m.Executor.AddConsensusMsgs(consensusMsgs...) + } + zero := uint64(0) + if _, _, err := m.ProduceApplyGossipBlock(context.Background(), ProduceBlockOptions{ + AllowEmpty: true, + MaxData: &zero, + NextProposerHash: nil, + }); err != nil { + return fmt.Errorf("produce apply gossip: h: %d : %w", h, err) } - } - - // Create second empty block for both cases (blocksToCreate == 1 or 2) - if _, _, err := m.ProduceApplyGossipBlock(context.Background(), true); err != nil { - return fmt.Errorf("producing second block: %v", err) } return nil } -// handleForkBatchSubmission verifies and, if necessary, creates a batch at the specified height. +// submitForkBatch verifies and, if necessary, creates a batch at the specified height. // This function is critical for maintaining batch consistency in the blockchain while // preventing duplicate batch submissions. // // The function performs the following operations: // 1. Checks for an existing batch at the specified height via SLClient // 2. If no batch exists, creates and submits a new one -func (m *Manager) handleForkBatchSubmission(height uint64) error { +func (m *Manager) submitForkBatch(height uint64) error { resp, err := m.SLClient.GetBatchAtHeight(height) if err != nil && !errors.Is(err, gerrc.ErrNotFound) { return fmt.Errorf("getting batch at height: %v", err) } - if resp == nil { - if _, err := m.CreateAndSubmitBatch(m.Conf.BatchSubmitBytes, false); err != nil { - return fmt.Errorf("creating and submitting batch: %v", err) - } + if resp != nil { + return nil + } + + if _, err = m.CreateAndSubmitBatch(m.Conf.BatchSubmitBytes, false); err != nil { + return fmt.Errorf("creating and submitting batch: %v", err) } return nil diff --git a/block/manager.go b/block/manager.go index b9895bd16..a0906bce6 100644 --- a/block/manager.go +++ b/block/manager.go @@ -197,11 +197,7 @@ func NewManager( // this is necessary to pass ValidateConfigWithRollappParams when DRS upgrade is required if instruction.RevisionStartHeight == m.State.NextHeight() { - drsVersion, err := version.CurrentDRSVersion() - if err != nil { - return nil, err - } - state.RollappParams.DrsVersion = drsVersion + state.RollappParams.DrsVersion = version.DRS } m.State = state @@ -363,12 +359,9 @@ 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 { - currentDRS, err := version.CurrentDRSVersion() - if err != nil { - return err - } - if currentDRS != m.State.RollappParams.DrsVersion { - return fmt.Errorf("DRS version mismatch. rollapp param: %d binary used:%d", m.State.RollappParams.DrsVersion, currentDRS) + + if version.DRS != m.State.RollappParams.DrsVersion { + return fmt.Errorf("DRS version mismatch. rollapp param: %d binary used:%d", m.State.RollappParams.DrsVersion, version.DRS) } if da.Client(m.State.RollappParams.Da) != m.DAClient.GetClientType() { diff --git a/block/manager_test.go b/block/manager_test.go index a54351587..721122cdf 100644 --- a/block/manager_test.go +++ b/block/manager_test.go @@ -436,7 +436,7 @@ func TestProduceNewBlock(t *testing.T) { manager, err := testutil.GetManager(testutil.GetManagerConfig(), nil, 1, 1, 0, proxyApp, nil) require.NoError(t, err) // Produce block - _, _, err = manager.ProduceApplyGossipBlock(context.Background(), true) + _, _, err = manager.ProduceApplyGossipBlock(context.Background(), block.ProduceBlockOptions{AllowEmpty: true}) require.NoError(t, err) // Validate state is updated with the commit hash assert.Equal(t, uint64(1), manager.State.Height()) @@ -468,19 +468,19 @@ func TestProducePendingBlock(t *testing.T) { // Init manager manager, err := testutil.GetManager(testutil.GetManagerConfig(), nil, 1, 1, 0, proxyApp, nil) require.NoError(t, err) - // Generate block and commit and save it to the store - block := testutil.GetRandomBlock(1, 3) - copy(block.Header.SequencerHash[:], manager.State.GetProposerHash()) - copy(block.Header.NextSequencersHash[:], manager.State.GetProposerHash()) + // Generate b and commit and save it to the store + b := testutil.GetRandomBlock(1, 3) + copy(b.Header.SequencerHash[:], manager.State.GetProposerHash()) + copy(b.Header.NextSequencersHash[:], manager.State.GetProposerHash()) - _, err = manager.Store.SaveBlock(block, &block.LastCommit, nil) + _, err = manager.Store.SaveBlock(b, &b.LastCommit, nil) require.NoError(t, err) - // Produce block - _, _, err = manager.ProduceApplyGossipBlock(context.Background(), true) + // Produce b + _, _, err = manager.ProduceApplyGossipBlock(context.Background(), block.ProduceBlockOptions{AllowEmpty: true}) require.NoError(t, err) - // Validate state is updated with the block that was saved in the store - // hacky way to validate the block was indeed contain txs + // Validate state is updated with the b that was saved in the store + // hacky way to validate the b was indeed contain txs assert.NotEqual(t, manager.State.LastResultsHash, testutil.GetEmptyLastResultsHash()) } @@ -574,7 +574,7 @@ func TestProduceBlockFailAfterCommit(t *testing.T) { }, }) mockStore.ShouldFailUpdateStateWithBatch = tc.shoudFailOnSaveState - _, _, _ = manager.ProduceApplyGossipBlock(context.Background(), true) + _, _, _ = manager.ProduceApplyGossipBlock(context.Background(), block.ProduceBlockOptions{AllowEmpty: true}) storeState, err := manager.Store.LoadState() assert.NoError(err) manager.State = storeState @@ -640,7 +640,7 @@ func TestCreateNextDABatchWithBytesLimit(t *testing.T) { t.Run(tc.name, func(t *testing.T) { // Produce blocks for i := 0; i < tc.blocksToProduce; i++ { - _, _, err := manager.ProduceApplyGossipBlock(ctx, true) + _, _, err := manager.ProduceApplyGossipBlock(ctx, block.ProduceBlockOptions{AllowEmpty: true}) assert.NoError(err) } diff --git a/block/modes.go b/block/modes.go index 19179dc38..e752c57fc 100644 --- a/block/modes.go +++ b/block/modes.go @@ -62,7 +62,7 @@ func (m *Manager) runAsProposer(ctx context.Context, eg *errgroup.Group) error { // if instruction file exists if instruction, forkNeeded := m.forkNeeded(); forkNeeded { - m.handleSequencerForkTransition(instruction) + m.doFork(instruction) err := types.DeleteInstructionFromDisk(m.RootDir) if err != nil { diff --git a/block/produce.go b/block/produce.go index bd6fc0dd6..ef723286e 100644 --- a/block/produce.go +++ b/block/produce.go @@ -49,7 +49,7 @@ func (m *Manager) ProduceBlockLoop(ctx context.Context, bytesProducedC chan int) produceEmptyBlock := firstBlock || m.Conf.MaxIdleTime == 0 || nextEmptyBlock.Before(time.Now()) firstBlock = false - block, commit, err := m.ProduceApplyGossipBlock(ctx, produceEmptyBlock) + block, commit, err := m.ProduceApplyGossipBlock(ctx, ProduceBlockOptions{AllowEmpty: produceEmptyBlock}) if errors.Is(err, context.Canceled) { m.logger.Error("Produce and gossip: context canceled.", "error", err) return nil @@ -100,19 +100,28 @@ func (m *Manager) ProduceBlockLoop(ctx context.Context, bytesProducedC chan int) } } -// ProduceApplyGossipLastBlock produces and applies a block with the given nextProposerHash. +type ProduceBlockOptions struct { + AllowEmpty bool + MaxData *uint64 + NextProposerHash *[32]byte // optional, used for last block +} + +// ProduceApplyGossipLastBlock produces and applies a block with the given NextProposerHash. func (m *Manager) ProduceApplyGossipLastBlock(ctx context.Context, nextProposerHash [32]byte) (err error) { - _, _, err = m.produceApplyGossip(ctx, true, &nextProposerHash) + _, _, err = m.produceApplyGossip(ctx, ProduceBlockOptions{ + AllowEmpty: true, + NextProposerHash: &nextProposerHash, + }) return err } -func (m *Manager) ProduceApplyGossipBlock(ctx context.Context, allowEmpty bool) (block *types.Block, commit *types.Commit, err error) { - return m.produceApplyGossip(ctx, allowEmpty, nil) +func (m *Manager) ProduceApplyGossipBlock(ctx context.Context, opts ProduceBlockOptions) (block *types.Block, commit *types.Commit, err error) { + return m.produceApplyGossip(ctx, opts) } -func (m *Manager) produceApplyGossip(ctx context.Context, allowEmpty bool, nextProposerHash *[32]byte) (block *types.Block, commit *types.Commit, err error) { +func (m *Manager) produceApplyGossip(ctx context.Context, opts ProduceBlockOptions) (block *types.Block, commit *types.Commit, err error) { // If I'm not the current rollapp proposer, I should not produce a blocks. - block, commit, err = m.produceBlock(allowEmpty, nextProposerHash) + block, commit, err = m.produceBlock(opts) if err != nil { return nil, nil, fmt.Errorf("produce block: %w", err) } @@ -128,7 +137,7 @@ func (m *Manager) produceApplyGossip(ctx context.Context, allowEmpty bool, nextP return block, commit, nil } -func (m *Manager) produceBlock(allowEmpty bool, nextProposerHash *[32]byte) (*types.Block, *types.Commit, error) { +func (m *Manager) produceBlock(opts ProduceBlockOptions) (*types.Block, *types.Commit, error) { newHeight := m.State.NextHeight() lastHeaderHash, lastCommit, err := m.GetPreviousBlockHashes(newHeight) if err != nil { @@ -155,15 +164,18 @@ func (m *Manager) produceBlock(allowEmpty bool, nextProposerHash *[32]byte) (*ty } maxBlockDataSize := uint64(float64(m.Conf.BatchSubmitBytes) * types.MaxBlockSizeAdjustment) + if opts.MaxData != nil { + maxBlockDataSize = *opts.MaxData + } proposerHashForBlock := [32]byte(m.State.GetProposerHash()) - // if nextProposerHash is set, we create a last block - if nextProposerHash != nil { + // if NextProposerHash is set, we create a last block + if opts.NextProposerHash != nil { maxBlockDataSize = 0 - proposerHashForBlock = *nextProposerHash + proposerHashForBlock = *opts.NextProposerHash } block = m.Executor.CreateBlock(newHeight, lastCommit, lastHeaderHash, proposerHashForBlock, m.State, maxBlockDataSize) - if !allowEmpty && len(block.Data.Txs) == 0 { + if !opts.AllowEmpty && len(block.Data.Txs) == 0 { return nil, nil, fmt.Errorf("%w: %w", types.ErrEmptyBlock, ErrRecoverable) } diff --git a/block/production_test.go b/block/production_test.go index 23c83e622..408410def 100644 --- a/block/production_test.go +++ b/block/production_test.go @@ -344,7 +344,7 @@ func TestUpdateInitialSequencerSet(t *testing.T) { require.NoError(err) // Produce block and validate that we produced blocks - block, _, err := manager.ProduceApplyGossipBlock(ctx, true) + block, _, err := manager.ProduceApplyGossipBlock(ctx, block2.ProduceBlockOptions{AllowEmpty: true}) require.NoError(err) assert.Greater(t, manager.State.Height(), uint64(0)) assert.Zero(t, manager.LastSettlementHeight.Load()) @@ -470,7 +470,7 @@ func TestUpdateExistingSequencerSet(t *testing.T) { require.Equal(updatedSequencer, sequencers[1]) // Produce block and validate that we produced blocks - block, _, err := manager.ProduceApplyGossipBlock(ctx, true) + block, _, err := manager.ProduceApplyGossipBlock(ctx, block2.ProduceBlockOptions{AllowEmpty: true}) require.NoError(err) assert.Greater(t, manager.State.Height(), uint64(0)) assert.Zero(t, manager.LastSettlementHeight.Load()) diff --git a/block/pruning_test.go b/block/pruning_test.go index 3f2c742ff..fa41f7bf6 100644 --- a/block/pruning_test.go +++ b/block/pruning_test.go @@ -4,6 +4,7 @@ import ( "context" "testing" + "github.com/dymensionxyz/dymint/block" "github.com/dymensionxyz/dymint/da" "github.com/dymensionxyz/dymint/testutil" "github.com/dymensionxyz/gerr-cosmos/gerrc" @@ -50,7 +51,7 @@ func TestPruningRetainHeight(t *testing.T) { // Produce blocks for i := 0; i < batchSize; i++ { - _, _, err = manager.ProduceApplyGossipBlock(ctx, true) + _, _, err = manager.ProduceApplyGossipBlock(ctx, block.ProduceBlockOptions{AllowEmpty: true}) require.NoError(err) } // submit and validate sync target @@ -61,7 +62,7 @@ func TestPruningRetainHeight(t *testing.T) { // Produce new blocks for i := 0; i < batchSize; i++ { - _, _, err = manager.ProduceApplyGossipBlock(ctx, true) + _, _, err = manager.ProduceApplyGossipBlock(ctx, block.ProduceBlockOptions{AllowEmpty: true}) require.NoError(err) } validRetainHeight := manager.NextHeightToSubmit() // the max possible valid retain height diff --git a/block/sequencers.go b/block/sequencers.go index e560e5c14..8ab60334c 100644 --- a/block/sequencers.go +++ b/block/sequencers.go @@ -119,7 +119,7 @@ func (m *Manager) CreateAndPostLastBatch(ctx context.Context, nextSeqHash [32]by return fmt.Errorf("load block: height: %d: %w", h, err) } - // check if the last block already produced with nextProposerHash set. + // check if the last block already produced with NextProposerHash set. // After creating the last block, the sequencer will be restarted so it will not be able to produce blocks anymore. if bytes.Equal(block.Header.NextSequencersHash[:], nextSeqHash[:]) { m.logger.Debug("Last block already produced and applied.") diff --git a/block/submit_test.go b/block/submit_test.go index 7a5f54be5..2118fe78f 100644 --- a/block/submit_test.go +++ b/block/submit_test.go @@ -135,7 +135,7 @@ func TestBatchSubmissionHappyFlow(t *testing.T) { require.Zero(manager.LastSettlementHeight.Load()) // Produce block and validate that we produced blocks - _, _, err = manager.ProduceApplyGossipBlock(ctx, true) + _, _, err = manager.ProduceApplyGossipBlock(ctx, block.ProduceBlockOptions{AllowEmpty: true}) require.NoError(err) assert.Greater(t, manager.State.Height(), initialHeight) assert.Zero(t, manager.LastSettlementHeight.Load()) @@ -200,7 +200,7 @@ func TestBatchSubmissionFailedSubmission(t *testing.T) { require.Zero(manager.LastSettlementHeight.Load()) // Produce block and validate that we produced blocks - _, _, err = manager.ProduceApplyGossipBlock(ctx, true) + _, _, err = manager.ProduceApplyGossipBlock(ctx, block.ProduceBlockOptions{AllowEmpty: true}) require.NoError(err) assert.Greater(t, manager.State.Height(), initialHeight) assert.Zero(t, manager.LastSettlementHeight.Load()) diff --git a/rpc/client/client.go b/rpc/client/client.go index 339e6b95a..5181e46d2 100644 --- a/rpc/client/client.go +++ b/rpc/client/client.go @@ -743,7 +743,7 @@ func (c *Client) Status(ctx context.Context) (*ctypes.ResultStatus, error) { DefaultNodeID: id, ListenAddr: addr, Network: network, - Version: version.BuildVersion, + Version: version.Build, Channels: []byte{0x1}, Moniker: config.DefaultBaseConfig().Moniker, Other: p2p.DefaultNodeInfoOther{ diff --git a/testutil/types.go b/testutil/types.go index d536bf179..27b3265b7 100644 --- a/testutil/types.go +++ b/testutil/types.go @@ -3,7 +3,6 @@ package testutil import ( "crypto/rand" "math/big" - "strconv" "time" "github.com/cosmos/cosmos-sdk/types/bech32" @@ -18,6 +17,7 @@ import ( "github.com/dymensionxyz/dymint/types" "github.com/dymensionxyz/dymint/types/pb/dymint" + dversion "github.com/dymensionxyz/dymint/version" dymintversion "github.com/dymensionxyz/dymint/version" ) @@ -184,10 +184,9 @@ func GenerateCommits(blocks []*types.Block, proposerKey crypto.PrivKey) ([]*type } func GenerateDRS(blocks int) []uint32 { - drsVersion, _ := strconv.ParseUint(dymintversion.DrsVersion, 10, 32) drs := make([]uint32, blocks) for i := 0; i < blocks; i++ { - drs[i] = uint32(drsVersion) + drs[i] = dymintversion.DRS } return drs } @@ -322,7 +321,6 @@ func GenerateSequencer() types.Sequencer { // GenerateStateWithSequencer generates an initial state for testing. func GenerateStateWithSequencer(initialHeight int64, lastBlockHeight int64, pubkey tmcrypto.PubKey) *types.State { - dymintVersion, _ := strconv.ParseUint(dymintversion.DrsVersion, 10, 32) s := &types.State{ ChainID: "test-chain", InitialHeight: uint64(initialHeight), @@ -336,7 +334,7 @@ func GenerateStateWithSequencer(initialHeight int64, lastBlockHeight int64, pubk }, RollappParams: dymint.RollappParams{ Da: "mock", - DrsVersion: uint32(dymintVersion), + DrsVersion: dversion.DRS, }, ConsensusParams: tmproto.ConsensusParams{ Block: tmproto.BlockParams{ diff --git a/version/version.go b/version/version.go index 1affa3f24..ee85cbbee 100644 --- a/version/version.go +++ b/version/version.go @@ -1,19 +1,6 @@ package version -import ( - "fmt" - "strconv" -) - var ( - BuildVersion = "" - DrsVersion = "0" + Build = "" + DRS = uint32(0) ) - -func CurrentDRSVersion() (uint32, error) { - currentDRS, err := strconv.ParseUint(DrsVersion, 10, 32) - if err != nil { - return uint32(0), fmt.Errorf("converting DRS version to int: %v", err) - } - return uint32(currentDRS), nil -} From 3ae0608f45c9edaceea4b8272de8f99d336a261f Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Fri, 15 Nov 2024 21:53:08 +0100 Subject: [PATCH 083/119] drs for ldflag --- block/fork.go | 8 ++++++-- block/manager.go | 15 +++++++++++---- testutil/types.go | 8 ++++---- version/version.go | 15 ++++++++++++++- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/block/fork.go b/block/fork.go index 375be324f..0807349fe 100644 --- a/block/fork.go +++ b/block/fork.go @@ -136,9 +136,13 @@ func (m *Manager) doFork(instruction types.Instruction) { // - Validates the current DRS version against the potentially faulty version // - Generates an upgrade message with the current valid DRS version func (m *Manager) prepareDRSUpgradeMessages(obsoleteDRS []uint32) ([]proto.Message, error) { + drsVersion, err := version.GetDRSVersion() + if err != nil { + return nil, err + } for _, drs := range obsoleteDRS { - if drs == version.DRS { + if drs == drsVersion { return nil, gerrc.ErrCancelled.Wrapf("obsolete DRS version: %d", drs) } } @@ -146,7 +150,7 @@ func (m *Manager) prepareDRSUpgradeMessages(obsoleteDRS []uint32) ([]proto.Messa return []proto.Message{ &sequencers.MsgUpgradeDRS{ Authority: authtypes.NewModuleAddress("sequencers").String(), - DrsVersion: uint64(version.DRS), + DrsVersion: uint64(drsVersion), }, }, nil } diff --git a/block/manager.go b/block/manager.go index a0906bce6..9dc630f04 100644 --- a/block/manager.go +++ b/block/manager.go @@ -197,7 +197,11 @@ func NewManager( // this is necessary to pass ValidateConfigWithRollappParams when DRS upgrade is required if instruction.RevisionStartHeight == m.State.NextHeight() { - state.RollappParams.DrsVersion = version.DRS + drsVersion, err := version.GetDRSVersion() + if err != nil { + return nil, err + } + state.RollappParams.DrsVersion = drsVersion } m.State = state @@ -359,9 +363,12 @@ 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.DRS != m.State.RollappParams.DrsVersion { - return fmt.Errorf("DRS version mismatch. rollapp param: %d binary used:%d", m.State.RollappParams.DrsVersion, version.DRS) + drsVersion, err := version.GetDRSVersion() + if err != nil { + return err + } + if drsVersion != m.State.RollappParams.DrsVersion { + return fmt.Errorf("DRS version mismatch. rollapp param: %d binary used:%d", m.State.RollappParams.DrsVersion, drsVersion) } if da.Client(m.State.RollappParams.Da) != m.DAClient.GetClientType() { diff --git a/testutil/types.go b/testutil/types.go index 27b3265b7..a99a8b2ae 100644 --- a/testutil/types.go +++ b/testutil/types.go @@ -6,6 +6,7 @@ import ( "time" "github.com/cosmos/cosmos-sdk/types/bech32" + dymintversion "github.com/dymensionxyz/dymint/version" "github.com/libp2p/go-libp2p/core/crypto" abci "github.com/tendermint/tendermint/abci/types" tmcrypto "github.com/tendermint/tendermint/crypto" @@ -17,8 +18,6 @@ import ( "github.com/dymensionxyz/dymint/types" "github.com/dymensionxyz/dymint/types/pb/dymint" - dversion "github.com/dymensionxyz/dymint/version" - dymintversion "github.com/dymensionxyz/dymint/version" ) const ( @@ -184,9 +183,10 @@ func GenerateCommits(blocks []*types.Block, proposerKey crypto.PrivKey) ([]*type } func GenerateDRS(blocks int) []uint32 { + drsVersion, _ := dymintversion.GetDRSVersion() drs := make([]uint32, blocks) for i := 0; i < blocks; i++ { - drs[i] = dymintversion.DRS + drs[i] = drsVersion } return drs } @@ -334,7 +334,7 @@ func GenerateStateWithSequencer(initialHeight int64, lastBlockHeight int64, pubk }, RollappParams: dymint.RollappParams{ Da: "mock", - DrsVersion: dversion.DRS, + DrsVersion: 0, }, ConsensusParams: tmproto.ConsensusParams{ Block: tmproto.BlockParams{ diff --git a/version/version.go b/version/version.go index ee85cbbee..b74a99f83 100644 --- a/version/version.go +++ b/version/version.go @@ -1,6 +1,19 @@ package version +import ( + "fmt" + "strconv" +) + var ( Build = "" - DRS = uint32(0) + DRS = "" ) + +func GetDRSVersion() (uint32, error) { + currentDRS, err := strconv.ParseUint(DRS, 10, 32) + if err != nil { + return uint32(0), fmt.Errorf("converting DRS version to int: %v", err) + } + return uint32(currentDRS), nil +} From 75a63c90311d425acb81d44a635b6565ba1448c0 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Fri, 15 Nov 2024 22:45:49 +0100 Subject: [PATCH 084/119] simplify checkforupdatE --- block/fork.go | 19 +++++-------------- block/fork_test.go | 2 +- block/manager_test.go | 2 ++ block/production_test.go | 6 +++++- node/node_test.go | 2 ++ p2p/block_sync_test.go | 2 ++ rpc/client/client_test.go | 2 ++ rpc/json/service_test.go | 3 ++- rpc/rpc_test.go | 2 ++ 9 files changed, 23 insertions(+), 17 deletions(-) diff --git a/block/fork.go b/block/fork.go index 0807349fe..6663cd994 100644 --- a/block/fork.go +++ b/block/fork.go @@ -21,7 +21,8 @@ const ( // MonitorForkUpdateLoop monitors the hub for fork updates in a loop func (m *Manager) MonitorForkUpdateLoop(ctx context.Context) error { - if types.InstructionExists(m.RootDir) { // TODO: why do we have this check + // if instruction already exists no need to check for fork update + if types.InstructionExists(m.RootDir) { return nil } @@ -47,21 +48,13 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { return err } - if m.State.Height() == 0 { - return nil - } - lastBlock, err := m.Store.LoadBlock(m.State.Height()) - if err != nil { - return err - } - - if m.shouldStopNode(rollapp, lastBlock) { + if m.shouldStopNode(rollapp, m.State.GetRevision()) { err = m.createInstruction(rollapp) if err != nil { return err } - m.freezeNode(ctx, fmt.Errorf("fork update detected. local_block_height: %d rollapp_revision_start_height: %d local_revision: %d rollapp_revision: %d", m.State.Height(), rollapp.RevisionStartHeight, lastBlock.GetRevision(), rollapp.Revision)) + m.freezeNode(ctx, fmt.Errorf("fork update detected. local_block_height: %d rollapp_revision_start_height: %d local_revision: %d rollapp_revision: %d", m.State.Height(), rollapp.RevisionStartHeight, m.State.GetRevision(), rollapp.Revision)) } return nil @@ -92,12 +85,10 @@ func (m *Manager) createInstruction(rollapp *types.Rollapp) error { // This method checks two conditions to decide if a node should be stopped: // 1. If the next state height is greater than or equal to the rollapp's revision start height. // 2. If the block's app version (equivalent to revision) is less than the rollapp's revision -func (m *Manager) shouldStopNode(rollapp *types.Rollapp, block *types.Block) bool { - revision := block.GetRevision() +func (m *Manager) shouldStopNode(rollapp *types.Rollapp, revision uint64) bool { if m.State.NextHeight() >= rollapp.RevisionStartHeight && revision < rollapp.Revision { return true } - return false } diff --git a/block/fork_test.go b/block/fork_test.go index 967688ae9..1eb00faf2 100644 --- a/block/fork_test.go +++ b/block/fork_test.go @@ -86,7 +86,7 @@ func TestShouldStopNode(t *testing.T) { logger: logger, } - result := manager.shouldStopNode(tt.rollapp, tt.block) + result := manager.shouldStopNode(tt.rollapp, tt.block.Header.Version.App) assert.Equal(t, tt.expected, result) }) } diff --git a/block/manager_test.go b/block/manager_test.go index 721122cdf..215540937 100644 --- a/block/manager_test.go +++ b/block/manager_test.go @@ -21,6 +21,7 @@ import ( "github.com/dymensionxyz/dymint/testutil" "github.com/dymensionxyz/dymint/types" "github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp" + "github.com/dymensionxyz/dymint/version" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto/ed25519" @@ -45,6 +46,7 @@ import ( // TODO: test sequencer after L2 handover but before last state update submitted // TODO: test halt scenario func TestInitialState(t *testing.T) { + version.DRS = "0" var err error assert := assert.New(t) genesis := testutil.GenerateGenesis(123) diff --git a/block/production_test.go b/block/production_test.go index 408410def..d87158774 100644 --- a/block/production_test.go +++ b/block/production_test.go @@ -33,11 +33,13 @@ import ( uchannel "github.com/dymensionxyz/dymint/utils/channel" uevent "github.com/dymensionxyz/dymint/utils/event" protoutils "github.com/dymensionxyz/dymint/utils/proto" + "github.com/dymensionxyz/dymint/version" ) // TODO: test producing lastBlock // TODO: test using already produced lastBlock func TestCreateEmptyBlocksEnableDisable(t *testing.T) { + version.DRS = "0" const blockTime = 200 * time.Millisecond const MaxIdleTime = blockTime * 10 const runTime = 10 * time.Second @@ -207,7 +209,7 @@ func TestCreateEmptyBlocksNew(t *testing.T) { func TestStopBlockProduction(t *testing.T) { assert := assert.New(t) require := require.New(t) - + version.DRS = "0" app := testutil.GetAppMock(testutil.EndBlock) app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ RollappParamUpdates: &abci.RollappParams{ @@ -293,6 +295,7 @@ func TestUpdateInitialSequencerSet(t *testing.T) { require := require.New(t) app := testutil.GetAppMock(testutil.EndBlock) ctx := context.Background() + version.DRS = "0" app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ RollappParamUpdates: &abci.RollappParams{ Da: "mock", @@ -399,6 +402,7 @@ func TestUpdateExistingSequencerSet(t *testing.T) { require := require.New(t) app := testutil.GetAppMock(testutil.EndBlock) ctx := context.Background() + version.DRS = "0" app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ RollappParamUpdates: &abci.RollappParams{ Da: "mock", diff --git a/node/node_test.go b/node/node_test.go index 57aecf762..01870da2b 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -14,6 +14,7 @@ import ( "github.com/dymensionxyz/dymint/node" "github.com/dymensionxyz/dymint/settlement" "github.com/dymensionxyz/dymint/testutil" + "github.com/dymensionxyz/dymint/version" "github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/peer" @@ -31,6 +32,7 @@ import ( // simply check that node is starting and stopping without panicking func TestStartup(t *testing.T) { + version.DRS = "0" assert := assert.New(t) require := require.New(t) diff --git a/p2p/block_sync_test.go b/p2p/block_sync_test.go index c9e05fb00..dcbe124e5 100644 --- a/p2p/block_sync_test.go +++ b/p2p/block_sync_test.go @@ -6,12 +6,14 @@ import ( "github.com/dymensionxyz/dymint/p2p" "github.com/dymensionxyz/dymint/testutil" + "github.com/dymensionxyz/dymint/version" "github.com/ipfs/go-datastore" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" ) func TestBlockSync(t *testing.T) { + version.DRS = "0" logger := log.TestingLogger() ctx := context.Background() diff --git a/rpc/client/client_test.go b/rpc/client/client_test.go index afb1a915c..ea5f1e4e4 100644 --- a/rpc/client/client_test.go +++ b/rpc/client/client_test.go @@ -37,6 +37,7 @@ import ( "github.com/dymensionxyz/dymint/settlement" "github.com/dymensionxyz/dymint/testutil" "github.com/dymensionxyz/dymint/types" + "github.com/dymensionxyz/dymint/version" ) var expectedInfo = abci.ResponseInfo{ @@ -986,6 +987,7 @@ func getRPCAndNodeSequencer(t *testing.T) (*tmmocks.MockApplication, *client.Cli // getRPC returns a mock application and a new RPC client (non-sequencer mode) func getRPCInternal(t *testing.T, sequencer bool) (*tmmocks.MockApplication, *client.Client, *node.Node) { t.Helper() + version.DRS = "0" require := require.New(t) app := &tmmocks.MockApplication{} app.On("Info", mock.Anything).Return(expectedInfo) diff --git a/rpc/json/service_test.go b/rpc/json/service_test.go index 41500d1ad..c8d8b457c 100644 --- a/rpc/json/service_test.go +++ b/rpc/json/service_test.go @@ -29,6 +29,7 @@ import ( "github.com/dymensionxyz/dymint/config" "github.com/dymensionxyz/dymint/mempool" tmmocks "github.com/dymensionxyz/dymint/mocks/github.com/tendermint/tendermint/abci/types" + "github.com/dymensionxyz/dymint/version" "github.com/dymensionxyz/dymint/node" "github.com/dymensionxyz/dymint/rpc/client" @@ -277,7 +278,7 @@ func TestSubscription(t *testing.T) { func getRPC(t *testing.T) (*tmmocks.MockApplication, *client.Client) { t.Helper() require := require.New(t) - + version.DRS = "0" app := &tmmocks.MockApplication{} app.On("InitChain", mock.Anything).Return(abci.ResponseInitChain{}) app.On("BeginBlock", mock.Anything).Return(abci.ResponseBeginBlock{}) diff --git a/rpc/rpc_test.go b/rpc/rpc_test.go index 6b12b5786..05ccac0e1 100644 --- a/rpc/rpc_test.go +++ b/rpc/rpc_test.go @@ -14,10 +14,12 @@ import ( "github.com/dymensionxyz/dymint/node/events" "github.com/dymensionxyz/dymint/testutil" + "github.com/dymensionxyz/dymint/version" ) func TestNodeHealthRPCPropagation(t *testing.T) { var err error + version.DRS = "0" server, listener := testutil.CreateLocalServer(t) defer func() { err = server.Stop() From 4adfc92684ae0185fdd2ac8b305541218289d02d Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sat, 16 Nov 2024 10:49:37 +0100 Subject: [PATCH 085/119] add validation hard fork support and stopping fullnodes syncing when fork detected --- block/block.go | 5 ++++- block/fork.go | 14 +++++++++++++- block/manager.go | 2 +- block/modes.go | 8 +++++++- block/retriever.go | 17 +++++++++++++++++ block/slvalidator.go | 9 ++++++++- types/validation.go | 9 +-------- 7 files changed, 51 insertions(+), 13 deletions(-) diff --git a/block/block.go b/block/block.go index 6f3bc4836..fd6d60e14 100644 --- a/block/block.go +++ b/block/block.go @@ -14,6 +14,7 @@ import ( // applyBlockWithFraudHandling calls applyBlock and validateBlockBeforeApply with fraud handling. func (m *Manager) applyBlockWithFraudHandling(block *types.Block, commit *types.Commit, blockMetaData types.BlockMetaData) error { + validateWithFraud := func() error { if err := m.validateBlockBeforeApply(block, commit); err != nil { m.blockCache.Delete(block.Header.Height) @@ -212,7 +213,9 @@ func (m *Manager) attemptApplyCachedBlocks() error { if !blockExists { break } - + if cachedBlock.Block.GetRevision() != m.State.GetRevision() { + break + } err := m.applyBlockWithFraudHandling(cachedBlock.Block, cachedBlock.Commit, types.BlockMetaData{Source: cachedBlock.Source}) if err != nil { return fmt.Errorf("apply cached block: expected height: %d: %w", expectedHeight, err) diff --git a/block/fork.go b/block/fork.go index 6663cd994..58b62c914 100644 --- a/block/fork.go +++ b/block/fork.go @@ -101,7 +101,13 @@ func (m *Manager) forkNeeded() (types.Instruction, bool) { return types.Instruction{}, false } -func (m *Manager) doFork(instruction types.Instruction) { +func (m *Manager) doFork(instruction types.Instruction) error { + m.State.SetRevision(instruction.Revision) + SLProposer, err := m.SLClient.GetProposerAtHeight(int64(m.State.NextHeight())) + if err != nil { + return fmt.Errorf("get proposer at height: %w", err) + } + m.State.SetProposer(SLProposer) consensusMsgs, err := m.prepareDRSUpgradeMessages(instruction.FaultyDRS) if err != nil { panic(fmt.Sprintf("prepare DRS upgrade messages: %v", err)) @@ -117,6 +123,12 @@ func (m *Manager) doFork(instruction types.Instruction) { if err := m.submitForkBatch(instruction.RevisionStartHeight); err != nil { panic(fmt.Sprintf("ensure batch exists: %v", err)) } + + err = types.DeleteInstructionFromDisk(m.RootDir) + if err != nil { + return fmt.Errorf("deleting instruction file: %w", err) + } + return nil } // prepareDRSUpgradeMessages prepares consensus messages for DRS upgrades. diff --git a/block/manager.go b/block/manager.go index 9dc630f04..3c494b081 100644 --- a/block/manager.go +++ b/block/manager.go @@ -192,11 +192,11 @@ func NewManager( // Upgrade revision on state state := m.State - state.SetRevision(instruction.Revision) state.RevisionStartHeight = instruction.RevisionStartHeight // this is necessary to pass ValidateConfigWithRollappParams when DRS upgrade is required if instruction.RevisionStartHeight == m.State.NextHeight() { + state.SetRevision(instruction.Revision) drsVersion, err := version.GetDRSVersion() if err != nil { return nil, err diff --git a/block/modes.go b/block/modes.go index e752c57fc..756d92294 100644 --- a/block/modes.go +++ b/block/modes.go @@ -62,12 +62,18 @@ func (m *Manager) runAsProposer(ctx context.Context, eg *errgroup.Group) error { // if instruction file exists if instruction, forkNeeded := m.forkNeeded(); forkNeeded { - m.doFork(instruction) + if m.LastSettlementHeight.Load() < instruction.RevisionStartHeight { + err := m.doFork(instruction) + if err != nil { + return err + } + } err := types.DeleteInstructionFromDisk(m.RootDir) if err != nil { return fmt.Errorf("deleting instruction file: %w", err) } + } // check if we should rotate diff --git a/block/retriever.go b/block/retriever.go index f7ba0125b..885b5d521 100644 --- a/block/retriever.go +++ b/block/retriever.go @@ -1,6 +1,7 @@ package block import ( + "context" "fmt" "github.com/dymensionxyz/gerr-cosmos/gerrc" @@ -36,6 +37,22 @@ func (m *Manager) ApplyBatchFromSL(slBatch *settlement.Batch) error { continue } + if block.GetRevision() != m.State.GetRevision() { + + rollapp, err := m.SLClient.GetRollapp() + if err != nil { + return err + } + if m.shouldStopNode(rollapp, m.State.GetRevision()) { + err = m.createInstruction(rollapp) + if err != nil { + return err + } + m.freezeNode(context.Background(), fmt.Errorf("syncing to fork height. please restart the node. local_block_height: %d rollapp_revision_start_height: %d local_revision: %d rollapp_revision: %d", m.State.Height(), rollapp.RevisionStartHeight, m.State.GetRevision(), rollapp.Revision)) + return nil + } + } + // We dont validate because validateBlockBeforeApply already checks if the block is already applied, and we don't need to fail there. err := m.applyBlockWithFraudHandling(block, batch.Commits[i], types.BlockMetaData{Source: types.DA, DAHeight: slBatch.MetaData.DA.Height}) if err != nil { diff --git a/block/slvalidator.go b/block/slvalidator.go index 7c30ba017..93535976d 100644 --- a/block/slvalidator.go +++ b/block/slvalidator.go @@ -177,6 +177,13 @@ func (v *SettlementValidator) ValidateDaBlocks(slBatch *settlement.ResultRetriev // because it did not change. If the next sequencer is set, we check if the next sequencer hash is equal on the // last block of the batch lastDABlock := daBlocks[numSlBDs-1] + + // if lastDaBlock is previous block to fork, dont validate nextsequencerhash of last block because it will not match + if v.blockManager.State.RevisionStartHeight-1 == lastDABlock.Header.Height { + v.logger.Debug("DA blocks, previous to fork, validated successfully", "start height", daBlocks[0].Header.Height, "end height", daBlocks[len(daBlocks)-1].Header.Height) + return nil + } + expectedNextSeqHash := lastDABlock.Header.SequencerHash if slBatch.NextSequencer != slBatch.Sequencer { nextSequencer, found := v.blockManager.Sequencers.GetByAddress(slBatch.NextSequencer) @@ -185,7 +192,7 @@ func (v *SettlementValidator) ValidateDaBlocks(slBatch *settlement.ResultRetriev } copy(expectedNextSeqHash[:], nextSequencer.MustHash()) } - // FIXME: support hard fork + if !bytes.Equal(expectedNextSeqHash[:], lastDABlock.Header.NextSequencersHash[:]) { return types.NewErrInvalidNextSequencersHashFraud( expectedNextSeqHash, diff --git a/types/validation.go b/types/validation.go index 8506e898c..77f144212 100644 --- a/types/validation.go +++ b/types/validation.go @@ -67,14 +67,7 @@ func (b *Block) ValidateWithState(state *State) error { return NewErrTimeFraud(b, currentTime) } - // FIXME(srene): temporary solution for hardfork syncing, but this does not support multiple hardforks per rollapp - // https://github.com/dymensionxyz/dymint/issues/1210 - revision := uint64(0) - if b.Header.Height >= state.RevisionStartHeight { - revision = state.GetRevision() - } - - if b.Header.Version.App != revision || + if b.Header.Version.App != state.GetRevision() || b.Header.Version.Block != state.Version.Consensus.Block { return ErrVersionMismatch } From e100840ace7ae090dc067ba8efe4dcc1abce71de Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Sat, 16 Nov 2024 10:50:28 +0100 Subject: [PATCH 086/119] last fixes --- block/sequencers.go | 10 ++++++++-- settlement/dymension/dymension.go | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/block/sequencers.go b/block/sequencers.go index 8ab60334c..1a1c141f2 100644 --- a/block/sequencers.go +++ b/block/sequencers.go @@ -100,7 +100,12 @@ func (m *Manager) rotate(ctx context.Context) { panic(fmt.Sprintf("rotate: fetch next proposer set from Hub: %v", err)) } - err = m.CreateAndPostLastBatch(ctx, [32]byte(nextProposer.MustHash())) + var nextProposerHash [32]byte + if !nextProposer.IsEmpty() { + nextProposerHash = [32]byte(nextProposer.MustHash()) + } + + err = m.CreateAndPostLastBatch(ctx, nextProposerHash) if err != nil { panic(fmt.Sprintf("rotate: create and post last batch: %v", err)) } @@ -164,8 +169,9 @@ func (m *Manager) UpdateSequencerSetFromSL() error { // creates consensus messages for all new sequencers. The method updates the current state // and is not thread-safe. Returns errors on serialization issues. func (m *Manager) HandleSequencerSetUpdate(newSet []types.Sequencer) error { + actualSequencers := m.Sequencers.GetAll() // find new (updated) sequencers - newSequencers := types.SequencerListRightOuterJoin(m.Sequencers.GetAll(), newSet) + newSequencers := types.SequencerListRightOuterJoin(actualSequencers, newSet) // create consensus msgs for new sequencers msgs, err := ConsensusMsgsOnSequencerSetUpdate(newSequencers) if err != nil { diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index 3a008866e..19261ce75 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -31,7 +31,7 @@ import ( const ( addressPrefix = "dym" - SENTINEL_PROPOSER = "" + SENTINEL_PROPOSER = "sentinel" ) const ( From 5f0f8d1cb9e0b5aa997c42ea2916a132442da897 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sat, 16 Nov 2024 10:53:18 +0100 Subject: [PATCH 087/119] test fix --- block/sequencers_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/sequencers_test.go b/block/sequencers_test.go index b421a59bb..6b46a7152 100644 --- a/block/sequencers_test.go +++ b/block/sequencers_test.go @@ -8,6 +8,7 @@ import ( "github.com/dymensionxyz/dymint/block" "github.com/dymensionxyz/dymint/testutil" "github.com/dymensionxyz/dymint/types" + "github.com/dymensionxyz/dymint/version" ) func TestHandleSequencerSetUpdate(t *testing.T) { @@ -15,7 +16,7 @@ func TestHandleSequencerSetUpdate(t *testing.T) { seq2 := testutil.GenerateSequencer() seq3 := testutil.GenerateSequencer() seq4 := testutil.GenerateSequencer() - + version.DRS = "0" testCases := []struct { name string initial []types.Sequencer From 2cb5b7aacfd5ca9ae13b01c6943374d49ea1db75 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sat, 16 Nov 2024 11:24:51 +0100 Subject: [PATCH 088/119] remove extra delete instruction --- block/modes.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/block/modes.go b/block/modes.go index 756d92294..eb54c3a40 100644 --- a/block/modes.go +++ b/block/modes.go @@ -69,10 +69,6 @@ func (m *Manager) runAsProposer(ctx context.Context, eg *errgroup.Group) error { return err } } - err := types.DeleteInstructionFromDisk(m.RootDir) - if err != nil { - return fmt.Errorf("deleting instruction file: %w", err) - } } From 4ce2d42fc27a0230f331eb1a47f44efdd8fca990 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Sat, 16 Nov 2024 10:50:28 +0100 Subject: [PATCH 089/119] last fixes --- block/sequencers.go | 10 ++++++++-- settlement/dymension/dymension.go | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/block/sequencers.go b/block/sequencers.go index 8ab60334c..1a1c141f2 100644 --- a/block/sequencers.go +++ b/block/sequencers.go @@ -100,7 +100,12 @@ func (m *Manager) rotate(ctx context.Context) { panic(fmt.Sprintf("rotate: fetch next proposer set from Hub: %v", err)) } - err = m.CreateAndPostLastBatch(ctx, [32]byte(nextProposer.MustHash())) + var nextProposerHash [32]byte + if !nextProposer.IsEmpty() { + nextProposerHash = [32]byte(nextProposer.MustHash()) + } + + err = m.CreateAndPostLastBatch(ctx, nextProposerHash) if err != nil { panic(fmt.Sprintf("rotate: create and post last batch: %v", err)) } @@ -164,8 +169,9 @@ func (m *Manager) UpdateSequencerSetFromSL() error { // creates consensus messages for all new sequencers. The method updates the current state // and is not thread-safe. Returns errors on serialization issues. func (m *Manager) HandleSequencerSetUpdate(newSet []types.Sequencer) error { + actualSequencers := m.Sequencers.GetAll() // find new (updated) sequencers - newSequencers := types.SequencerListRightOuterJoin(m.Sequencers.GetAll(), newSet) + newSequencers := types.SequencerListRightOuterJoin(actualSequencers, newSet) // create consensus msgs for new sequencers msgs, err := ConsensusMsgsOnSequencerSetUpdate(newSequencers) if err != nil { diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index 3a008866e..19261ce75 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -31,7 +31,7 @@ import ( const ( addressPrefix = "dym" - SENTINEL_PROPOSER = "" + SENTINEL_PROPOSER = "sentinel" ) const ( From fae0f512f34da4cbd287316e9ea54fc142d87bb4 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sun, 17 Nov 2024 18:04:56 +0100 Subject: [PATCH 090/119] fix nil pointer proposer --- block/sequencers.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/sequencers.go b/block/sequencers.go index 1a1c141f2..3e94c0aa9 100644 --- a/block/sequencers.go +++ b/block/sequencers.go @@ -63,6 +63,9 @@ func (m *Manager) AmIProposerOnSL() (bool, error) { // AmIProposerOnRollapp checks if the current node is the proposer on the rollapp. // Proposer on the rollapp is not necessarily the proposer on the hub during rotation phase. func (m *Manager) AmIProposerOnRollapp() bool { + if m.State.GetProposer() == nil { + return false + } localProposerKeyBytes, _ := m.LocalKey.GetPublic().Raw() rollappProposer := m.State.GetProposerPubKey().Bytes() From 8dbc1d867f75873a76f776c9be77f34068f1a96c Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Sun, 17 Nov 2024 22:59:04 +0100 Subject: [PATCH 091/119] code refactoring --- block/fork.go | 92 +++++++++++++++++++++++++++++++++------------ block/manager.go | 23 ++---------- block/modes.go | 25 ++++-------- block/sequencers.go | 6 ++- 4 files changed, 86 insertions(+), 60 deletions(-) diff --git a/block/fork.go b/block/fork.go index 58b62c914..c6acbb0f1 100644 --- a/block/fork.go +++ b/block/fork.go @@ -16,7 +16,7 @@ import ( ) const ( - LoopInterval = 15 * time.Second + ForkMonitorInterval = 15 * time.Second ) // MonitorForkUpdateLoop monitors the hub for fork updates in a loop @@ -26,7 +26,7 @@ func (m *Manager) MonitorForkUpdateLoop(ctx context.Context) error { return nil } - ticker := time.NewTicker(LoopInterval) // TODO make this configurable + ticker := time.NewTicker(ForkMonitorInterval) // TODO make this configurable defer ticker.Stop() for { @@ -60,6 +60,7 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { return nil } +// createInstruction writes file to disk with fork information func (m *Manager) createInstruction(rollapp *types.Rollapp) error { obsoleteDrs, err := m.SLClient.GetObsoleteDrs() if err != nil { @@ -101,33 +102,31 @@ func (m *Manager) forkNeeded() (types.Instruction, bool) { return types.Instruction{}, false } +// doFork creates fork blocks and submits a new batch with them func (m *Manager) doFork(instruction types.Instruction) error { - m.State.SetRevision(instruction.Revision) - SLProposer, err := m.SLClient.GetProposerAtHeight(int64(m.State.NextHeight())) - if err != nil { - return fmt.Errorf("get proposer at height: %w", err) - } - m.State.SetProposer(SLProposer) - consensusMsgs, err := m.prepareDRSUpgradeMessages(instruction.FaultyDRS) - if err != nil { - panic(fmt.Sprintf("prepare DRS upgrade messages: %v", err)) - } - // Always bump the account sequences - consensusMsgs = append(consensusMsgs, &sequencers.MsgBumpAccountSequences{Authority: authtypes.NewModuleAddress("sequencers").String()}) - err = m.createForkBlocks(instruction, consensusMsgs) - if err != nil { - panic(fmt.Sprintf("validate existing blocks: %v", err)) + // if fork (two) blocks are not produced and applied yet, produce them + if m.State.Height() < instruction.RevisionStartHeight+1 { + // add consensus msgs for upgrade DRS only if current DRS is obsolete + consensusMsgs, err := m.prepareDRSUpgradeMessages(instruction.FaultyDRS) + if err != nil { + panic(fmt.Sprintf("prepare DRS upgrade messages: %v", err)) + } + // add consensus msg to bump the account sequences in all fork cases + consensusMsgs = append(consensusMsgs, &sequencers.MsgBumpAccountSequences{Authority: authtypes.NewModuleAddress("sequencers").String()}) + + // create fork blocks + err = m.createForkBlocks(instruction, consensusMsgs) + if err != nil { + panic(fmt.Sprintf("validate existing blocks: %v", err)) + } } + // submit fork batch including two fork blocks if err := m.submitForkBatch(instruction.RevisionStartHeight); err != nil { panic(fmt.Sprintf("ensure batch exists: %v", err)) } - err = types.DeleteInstructionFromDisk(m.RootDir) - if err != nil { - return fmt.Errorf("deleting instruction file: %w", err) - } return nil } @@ -164,8 +163,7 @@ func (m *Manager) prepareDRSUpgradeMessages(obsoleteDRS []uint32) ([]proto.Messa func (m *Manager) createForkBlocks(instruction types.Instruction, consensusMsgs []proto.Message) error { nextHeight := m.State.NextHeight() - // Something already been created? - // TODO: how is possible to have more than one already created? Crash failure should result in at most one. + // Revise already created fork blocks for h := instruction.RevisionStartHeight; h < nextHeight; h++ { b, err := m.Store.LoadBlock(h) if err != nil { @@ -181,6 +179,7 @@ func (m *Manager) createForkBlocks(instruction types.Instruction, consensusMsgs } } + // create two empty blocks including consensus msgs in the first one for h := nextHeight; h < instruction.RevisionStartHeight+2; h++ { if h == instruction.RevisionStartHeight { m.Executor.AddConsensusMsgs(consensusMsgs...) @@ -221,3 +220,50 @@ func (m *Manager) submitForkBatch(height uint64) error { return nil } + +// updateStateWhenFork updates dymint state in case fork is detected +func (m *Manager) updateStateWhenFork() error { + + // in case fork is detected dymint state needs to be updated + if instruction, forkNeeded := m.forkNeeded(); forkNeeded { + // Set proposer to nil to force updating it from SL + m.State.SetProposer(nil) + // Upgrade revision on state + state := m.State + state.RevisionStartHeight = instruction.RevisionStartHeight + // this is necessary to pass ValidateConfigWithRollappParams when DRS upgrade is required + if instruction.RevisionStartHeight == m.State.NextHeight() { + state.SetRevision(instruction.Revision) + drsVersion, err := version.GetDRSVersion() + if err != nil { + return err + } + state.RollappParams.DrsVersion = drsVersion + } + m.State = state + } + return nil +} + +// forkFromInstruction checks if fork is needed, reading instruction file, and performs fork actions +func (m *Manager) forkFromInstruction() error { + // if instruction file exists proposer needs to do fork actions (if settlement height is higher than revision height it is considered fork already happened and no need to do anything) + instruction, forkNeeded := m.forkNeeded() + if !forkNeeded { + return nil + } + if m.RunMode == RunModeProposer { + m.State.SetRevision(instruction.Revision) + if m.LastSettlementHeight.Load() < instruction.RevisionStartHeight { + err := m.doFork(instruction) + if err != nil { + return err + } + } + } + err := types.DeleteInstructionFromDisk(m.RootDir) + if err != nil { + return fmt.Errorf("deleting instruction file: %w", err) + } + return nil +} diff --git a/block/manager.go b/block/manager.go index 3c494b081..41dc12d94 100644 --- a/block/manager.go +++ b/block/manager.go @@ -186,25 +186,10 @@ func NewManager( return nil, err } - if instruction, forkNeeded := m.forkNeeded(); forkNeeded { - // Set proposer to nil - m.State.SetProposer(nil) - - // Upgrade revision on state - state := m.State - state.RevisionStartHeight = instruction.RevisionStartHeight - - // this is necessary to pass ValidateConfigWithRollappParams when DRS upgrade is required - if instruction.RevisionStartHeight == m.State.NextHeight() { - state.SetRevision(instruction.Revision) - drsVersion, err := version.GetDRSVersion() - if err != nil { - return nil, err - } - state.RollappParams.DrsVersion = drsVersion - } - - m.State = state + // update dymint state with fork info + err = m.updateStateWhenFork() + if err != nil { + return nil, err } // validate configuration params and rollapp consensus params are in line diff --git a/block/modes.go b/block/modes.go index eb54c3a40..b1ded0381 100644 --- a/block/modes.go +++ b/block/modes.go @@ -4,8 +4,6 @@ import ( "context" "fmt" - "github.com/dymensionxyz/dymint/types" - "github.com/dymensionxyz/dymint/p2p" "github.com/dymensionxyz/dymint/settlement" uerrors "github.com/dymensionxyz/dymint/utils/errors" @@ -37,11 +35,10 @@ func (m *Manager) runAsFullNode(ctx context.Context, eg *errgroup.Group) error { m.subscribeFullNodeEvents(ctx) - if _, forkNeeded := m.forkNeeded(); forkNeeded { - err := types.DeleteInstructionFromDisk(m.RootDir) - if err != nil { - return fmt.Errorf("deleting instruction file: %w", err) - } + // forkFromInstruction deletes fork instruction file for full nodes + err = m.forkFromInstruction() + if err != nil { + return err } return nil @@ -60,16 +57,10 @@ func (m *Manager) runAsProposer(ctx context.Context, eg *errgroup.Group) error { // Sequencer must wait till node is synced till last submittedHeight, in case it is not m.waitForSettlementSyncing() - // if instruction file exists - if instruction, forkNeeded := m.forkNeeded(); forkNeeded { - - if m.LastSettlementHeight.Load() < instruction.RevisionStartHeight { - err := m.doFork(instruction) - if err != nil { - return err - } - } - + // forkFromInstruction executes fork if necessary + err := m.forkFromInstruction() + if err != nil { + return err } // check if we should rotate diff --git a/block/sequencers.go b/block/sequencers.go index 3e94c0aa9..705f5b902 100644 --- a/block/sequencers.go +++ b/block/sequencers.go @@ -9,8 +9,12 @@ import ( "github.com/dymensionxyz/dymint/types" ) +const ( + ProposerMonitorInterval = 3 * time.Minute +) + func (m *Manager) MonitorProposerRotation(ctx context.Context) { - ticker := time.NewTicker(3 * time.Minute) // TODO: make this configurable + ticker := time.NewTicker(ProposerMonitorInterval) // TODO: make this configurable defer ticker.Stop() for { From fcbc31d7bea5c7feef631c89ae8c1a50ce712b2f Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 18 Nov 2024 12:19:41 +0100 Subject: [PATCH 092/119] rdk dep fix --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2d0ef864d..9f60622d3 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/cosmos/cosmos-sdk v0.46.16 github.com/dgraph-io/badger/v4 v4.3.0 github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13 - github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241103133127-423dc71fef28 + github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241115090119-5216362174e3 github.com/dymensionxyz/gerr-cosmos v1.0.0 github.com/go-kit/kit v0.12.0 github.com/gofrs/uuid v4.3.0+incompatible diff --git a/go.sum b/go.sum index 47ea3b6a9..4550e03a6 100644 --- a/go.sum +++ b/go.sum @@ -328,8 +328,8 @@ github.com/dymensionxyz/cometbft v0.34.29-0.20241104165035-feade34f8f89 h1:rGkCc github.com/dymensionxyz/cometbft v0.34.29-0.20241104165035-feade34f8f89/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-rdk v1.6.1-0.20241103133127-423dc71fef28 h1:dWhUVvYfIPnhVq+lZ1h7U6U9Mvi1DTFx4egoTe6Z5OU= -github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241103133127-423dc71fef28/go.mod h1:HH7sGM/4MSI8OLces8axABf7K0ppXNok+G2nxC/l5YI= +github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241115090119-5216362174e3 h1:sXTU7h2Qu8XZL4J11V2Z2ADUemQ38KWd1oujQFSCatk= +github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241115090119-5216362174e3/go.mod h1:y89w1OG4C4aF7yyW8bv9PwV3o1KkCx1hyt34ap04Rnk= github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3 h1:vmAdUGUc4rTIiO3Phezr7vGq+0uPDVKSA4WAe8+yl6w= github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3/go.mod h1:LfPv2O1HXMgETpka81Pg3nXy+U/7urq8dn85ZnSXK5Y= github.com/dymensionxyz/gerr-cosmos v1.0.0 h1:oi91rgOkpJWr41oX9JOyjvvBnhGY54tj513x8VlDAEc= From e8e20c4383e936916be2fb78850b489a084a79a0 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 18 Nov 2024 12:36:31 +0100 Subject: [PATCH 093/119] update rollback msg --- block/fork.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/fork.go b/block/fork.go index 3d894fdbb..4e3bec634 100644 --- a/block/fork.go +++ b/block/fork.go @@ -55,7 +55,7 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { return err } - m.freezeNode(ctx, fmt.Errorf("fork update detected. local_block_height: %d rollapp_revision_start_height: %d local_revision: %d rollapp_revision: %d", m.State.Height(), rollapp.RevisionStartHeight, m.State.GetRevision(), rollapp.Revision)) + m.freezeNode(ctx, fmt.Errorf("fork update detected. please rollback to height: %d. local_block_height: %d rollapp_revision_start_height: %d local_revision: %d rollapp_revision: %d", rollapp.RevisionStartHeight-1, m.State.Height(), rollapp.RevisionStartHeight, m.State.GetRevision(), rollapp.Revision)) } return nil From ab3246126505acf44c4942ccb6d10a26989cbd6f Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 18 Nov 2024 12:50:04 +0100 Subject: [PATCH 094/119] comments --- block/fork.go | 7 ++++--- block/fork_test.go | 2 +- block/manager.go | 9 +++++---- block/retriever.go | 16 ++-------------- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/block/fork.go b/block/fork.go index 4e3bec634..b079539d7 100644 --- a/block/fork.go +++ b/block/fork.go @@ -18,6 +18,7 @@ import ( const ( ForkMonitorInterval = 15 * time.Second + ForkMessage = "rollapp fork detected. please rollback to height previous to rollapp_revision_start_height." ) // MonitorForkUpdateLoop monitors the hub for fork updates in a loop @@ -31,7 +32,7 @@ func (m *Manager) MonitorForkUpdateLoop(ctx context.Context) error { defer ticker.Stop() for { - if err := m.checkForkUpdate(ctx); err != nil { + if err := m.checkForkUpdate(ctx, ForkMessage); err != nil { m.logger.Error("Check for update.", err) } select { @@ -43,7 +44,7 @@ func (m *Manager) MonitorForkUpdateLoop(ctx context.Context) error { } // checkForkUpdate checks if the hub has a fork update -func (m *Manager) checkForkUpdate(ctx context.Context) error { +func (m *Manager) checkForkUpdate(ctx context.Context, msg string) error { rollapp, err := m.SLClient.GetRollapp() if err != nil { return err @@ -55,7 +56,7 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error { return err } - m.freezeNode(ctx, fmt.Errorf("fork update detected. please rollback to height: %d. local_block_height: %d rollapp_revision_start_height: %d local_revision: %d rollapp_revision: %d", rollapp.RevisionStartHeight-1, m.State.Height(), rollapp.RevisionStartHeight, m.State.GetRevision(), rollapp.Revision)) + m.freezeNode(ctx, fmt.Errorf("%s local_block_height: %d rollapp_revision_start_height: %d local_revision: %d rollapp_revision: %d", msg, m.State.Height(), rollapp.RevisionStartHeight, m.State.GetRevision(), rollapp.Revision)) } return nil diff --git a/block/fork_test.go b/block/fork_test.go index 1eb00faf2..dee64f42f 100644 --- a/block/fork_test.go +++ b/block/fork_test.go @@ -143,7 +143,7 @@ func TestCheckForkUpdate(t *testing.T) { State: mockState, } - err := manager.checkForkUpdate(ctx) + err := manager.checkForkUpdate(ctx, "") if tt.expectedError { assert.Error(t, err) } else { diff --git a/block/manager.go b/block/manager.go index 41dc12d94..e83b33791 100644 --- a/block/manager.go +++ b/block/manager.go @@ -69,6 +69,9 @@ type Manager struct { // RunMode represents the mode of the node. Set during initialization and shouldn't change after that. RunMode uint + // context used when freezing node + Cancel context.CancelFunc + ctx context.Context /* Sequencer and full-node */ @@ -115,8 +118,6 @@ type Manager struct { // validates all non-finalized state updates from settlement, checking there is consistency between DA and P2P blocks, and the information in the state update. SettlementValidator *SettlementValidator - - Cancel context.CancelFunc } // NewManager creates new block Manager. @@ -205,7 +206,7 @@ func NewManager( // Start starts the block manager. func (m *Manager) Start(ctx context.Context) error { - ctx, m.Cancel = context.WithCancel(ctx) + m.ctx, m.Cancel = context.WithCancel(ctx) // Check if InitChain flow is needed if m.State.IsGenesis() { m.logger.Info("Running InitChain") @@ -262,7 +263,7 @@ func (m *Manager) Start(ctx context.Context) error { uerrors.ErrGroupGoLog(eg, m.logger, func() error { err := m.SettlementSyncLoop(ctx) if err != nil { - m.freezeNode(context.Background(), err) + m.freezeNode(m.ctx, err) } return nil }) diff --git a/block/retriever.go b/block/retriever.go index 885b5d521..f3944d94c 100644 --- a/block/retriever.go +++ b/block/retriever.go @@ -1,7 +1,6 @@ package block import ( - "context" "fmt" "github.com/dymensionxyz/gerr-cosmos/gerrc" @@ -38,19 +37,8 @@ func (m *Manager) ApplyBatchFromSL(slBatch *settlement.Batch) error { } if block.GetRevision() != m.State.GetRevision() { - - rollapp, err := m.SLClient.GetRollapp() - if err != nil { - return err - } - if m.shouldStopNode(rollapp, m.State.GetRevision()) { - err = m.createInstruction(rollapp) - if err != nil { - return err - } - m.freezeNode(context.Background(), fmt.Errorf("syncing to fork height. please restart the node. local_block_height: %d rollapp_revision_start_height: %d local_revision: %d rollapp_revision: %d", m.State.Height(), rollapp.RevisionStartHeight, m.State.GetRevision(), rollapp.Revision)) - return nil - } + err := m.checkForkUpdate(m.ctx, "syncing to fork height. please restart the node.") + return err } // We dont validate because validateBlockBeforeApply already checks if the block is already applied, and we don't need to fail there. From 6419ab77c59d3875d4a13b6070f8dd97edc1e6de Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 18 Nov 2024 13:01:44 +0100 Subject: [PATCH 095/119] fixing tests --- block/slvalidator_test.go | 2 ++ block/submit_test.go | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/block/slvalidator_test.go b/block/slvalidator_test.go index 2fc289d7c..827ce680d 100644 --- a/block/slvalidator_test.go +++ b/block/slvalidator_test.go @@ -18,6 +18,7 @@ import ( "github.com/dymensionxyz/dymint/testutil" "github.com/dymensionxyz/dymint/types" "github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp" + "github.com/dymensionxyz/dymint/version" "github.com/libp2p/go-libp2p/core/crypto" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -29,6 +30,7 @@ import ( ) func TestStateUpdateValidator_ValidateStateUpdate(t *testing.T) { + version.DRS = "0" // Init app app := testutil.GetAppMock(testutil.EndBlock) app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ diff --git a/block/submit_test.go b/block/submit_test.go index 2118fe78f..c5aa10318 100644 --- a/block/submit_test.go +++ b/block/submit_test.go @@ -26,6 +26,7 @@ import ( slmocks "github.com/dymensionxyz/dymint/mocks/github.com/dymensionxyz/dymint/settlement" "github.com/dymensionxyz/dymint/testutil" "github.com/dymensionxyz/dymint/types" + "github.com/dymensionxyz/dymint/version" ) // TestBatchOverhead tests the scenario where we have a single block that is very large, and occupies the entire batch size. @@ -34,10 +35,10 @@ import ( // 1. single block with single large tx // 2. single block with multiple small tx func TestBatchOverhead(t *testing.T) { + version.DRS = "0" manager, err := testutil.GetManager(testutil.GetManagerConfig(), nil, 1, 1, 0, nil, nil) require.NoError(t, err) require.NotNil(t, manager) - maxBatchSize := uint64(10_000) // 10KB maxTxData := uint64(float64(maxBatchSize) * types.MaxBlockSizeAdjustment) // 90% of maxBatchSize @@ -106,6 +107,8 @@ func TestBatchSubmissionHappyFlow(t *testing.T) { app := testutil.GetAppMock(testutil.EndBlock) ctx := context.Background() + version.DRS = "0" + // Create proxy app clientCreator := proxy.NewLocalClientCreator(app) proxyApp := proxy.NewAppConns(clientCreator) @@ -150,6 +153,8 @@ func TestBatchSubmissionFailedSubmission(t *testing.T) { app := testutil.GetAppMock(testutil.EndBlock) ctx := context.Background() + version.DRS = "0" + app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ RollappParamUpdates: &abci.RollappParams{ Da: "mock", @@ -223,6 +228,7 @@ func TestSubmissionByTime(t *testing.T) { submitTimeout = 1 * time.Second blockTime = 200 * time.Millisecond ) + version.DRS = "0" require := require.New(t) app := testutil.GetAppMock(testutil.EndBlock) From fb6745a8e0c62429d029fb6d3d4e11813bd3dc16 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 18 Nov 2024 13:02:30 +0100 Subject: [PATCH 096/119] lint --- block/block.go | 1 - block/fork.go | 2 -- 2 files changed, 3 deletions(-) diff --git a/block/block.go b/block/block.go index fd6d60e14..b02a5b11f 100644 --- a/block/block.go +++ b/block/block.go @@ -14,7 +14,6 @@ import ( // applyBlockWithFraudHandling calls applyBlock and validateBlockBeforeApply with fraud handling. func (m *Manager) applyBlockWithFraudHandling(block *types.Block, commit *types.Commit, blockMetaData types.BlockMetaData) error { - validateWithFraud := func() error { if err := m.validateBlockBeforeApply(block, commit); err != nil { m.blockCache.Delete(block.Header.Height) diff --git a/block/fork.go b/block/fork.go index b079539d7..9f4e414ca 100644 --- a/block/fork.go +++ b/block/fork.go @@ -106,7 +106,6 @@ func (m *Manager) forkNeeded() (types.Instruction, bool) { // doFork creates fork blocks and submits a new batch with them func (m *Manager) doFork(instruction types.Instruction) error { - // if fork (two) blocks are not produced and applied yet, produce them if m.State.Height() < instruction.RevisionStartHeight+1 { // add consensus msgs for upgrade DRS only if current DRS is obsolete @@ -225,7 +224,6 @@ func (m *Manager) submitForkBatch(height uint64) error { // updateStateWhenFork updates dymint state in case fork is detected func (m *Manager) updateStateWhenFork() error { - // in case fork is detected dymint state needs to be updated if instruction, forkNeeded := m.forkNeeded(); forkNeeded { // Set proposer to nil to force updating it from SL From 526619b0891aa7657fdc8ff7dac58482d25d6908 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Mon, 18 Nov 2024 13:33:07 +0100 Subject: [PATCH 097/119] fix ctx --- block/manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/manager.go b/block/manager.go index e83b33791..a26ba9aa3 100644 --- a/block/manager.go +++ b/block/manager.go @@ -252,7 +252,7 @@ func (m *Manager) Start(ctx context.Context) error { // send signal to validation loop with last settlement state update m.triggerSettlementValidation() - eg, ctx := errgroup.WithContext(ctx) + eg, ctx := errgroup.WithContext(m.ctx) // Start the pruning loop in the background uerrors.ErrGroupGoLog(eg, m.logger, func() error { From 9d3dff0bf1ab4b8fd0f23d59df617417e94e4a85 Mon Sep 17 00:00:00 2001 From: keruch <53012408+keruch@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:52:53 +0300 Subject: [PATCH 098/119] feat: syncing with changing revisions (#1234) Co-authored-by: Sergi Rene --- block/fork.go | 11 +- block/fork_test.go | 42 +- .../dymension/rollapp/rollapp.proto | 13 +- settlement/dymension/dymension.go | 7 +- settlement/grpc/grpc.go | 5 +- settlement/local/local.go | 5 +- .../dymension/rollapp/rollapp.pb.go | 381 +++++++++++++----- types/rollapp.go | 39 +- 8 files changed, 370 insertions(+), 133 deletions(-) diff --git a/block/fork.go b/block/fork.go index 9f4e414ca..b1a130328 100644 --- a/block/fork.go +++ b/block/fork.go @@ -7,13 +7,13 @@ import ( "time" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/dymensionxyz/gerr-cosmos/gerrc" "github.com/gogo/protobuf/proto" sequencers "github.com/dymensionxyz/dymension-rdk/x/sequencers/types" "github.com/dymensionxyz/dymint/types" "github.com/dymensionxyz/dymint/version" - "github.com/dymensionxyz/gerr-cosmos/gerrc" ) const ( @@ -56,7 +56,7 @@ func (m *Manager) checkForkUpdate(ctx context.Context, msg string) error { return err } - m.freezeNode(ctx, fmt.Errorf("%s local_block_height: %d rollapp_revision_start_height: %d local_revision: %d rollapp_revision: %d", msg, m.State.Height(), rollapp.RevisionStartHeight, m.State.GetRevision(), rollapp.Revision)) + m.freezeNode(ctx, fmt.Errorf("%s local_block_height: %d rollapp_revision_start_height: %d local_revision: %d rollapp_revision: %d", msg, m.State.Height(), rollapp.LatestRevision().StartHeight, m.State.GetRevision(), rollapp.LatestRevision().Number)) } return nil @@ -69,9 +69,10 @@ func (m *Manager) createInstruction(rollapp *types.Rollapp) error { return err } + revision := rollapp.LatestRevision() instruction := types.Instruction{ - Revision: rollapp.Revision, - RevisionStartHeight: rollapp.RevisionStartHeight, + Revision: revision.Number, + RevisionStartHeight: revision.StartHeight, FaultyDRS: obsoleteDrs, } @@ -89,7 +90,7 @@ func (m *Manager) createInstruction(rollapp *types.Rollapp) error { // 1. If the next state height is greater than or equal to the rollapp's revision start height. // 2. If the block's app version (equivalent to revision) is less than the rollapp's revision func (m *Manager) shouldStopNode(rollapp *types.Rollapp, revision uint64) bool { - if m.State.NextHeight() >= rollapp.RevisionStartHeight && revision < rollapp.Revision { + if m.State.NextHeight() >= rollapp.LatestRevision().StartHeight && revision < rollapp.LatestRevision().Number { return true } return false diff --git a/block/fork_test.go b/block/fork_test.go index dee64f42f..44125be3b 100644 --- a/block/fork_test.go +++ b/block/fork_test.go @@ -27,8 +27,10 @@ func TestShouldStopNode(t *testing.T) { { name: "should stop - current height greater than revision start height and lower revision", rollapp: &types.Rollapp{ - Revision: 2, - RevisionStartHeight: 100, + Revisions: []types.Revision{{ + Number: 2, + StartHeight: 100, + }}, }, block: &types.Block{ Header: types.Header{ @@ -43,8 +45,10 @@ func TestShouldStopNode(t *testing.T) { { name: "should not stop - current height less than revision start height", rollapp: &types.Rollapp{ - Revision: 2, - RevisionStartHeight: 100, + Revisions: []types.Revision{{ + Number: 2, + StartHeight: 100, + }}, }, block: &types.Block{ Header: types.Header{ @@ -59,8 +63,10 @@ func TestShouldStopNode(t *testing.T) { { name: "should not stop - same revision", rollapp: &types.Rollapp{ - Revision: 2, - RevisionStartHeight: 100, + Revisions: []types.Revision{{ + Number: 2, + StartHeight: 100, + }}, }, block: &types.Block{ Header: types.Header{ @@ -106,8 +112,10 @@ func TestCheckForkUpdate(t *testing.T) { mockState.LastBlockHeight.Store(uint64(100)) mockSL.On("GetRollapp").Return(&types.Rollapp{ - Revision: 1, - RevisionStartHeight: 200, + Revisions: []types.Revision{{ + Number: 1, + StartHeight: 200, + }}, }, nil) mockStore.On("LoadBlock", uint64(100)).Return(&types.Block{ @@ -165,8 +173,10 @@ func TestMonitorForkUpdate(t *testing.T) { // Setup basic mocks for a successful check state.LastBlockHeight.Store(uint64(100)) mockSL.On("GetRollapp").Return(&types.Rollapp{ - Revision: 2, - RevisionStartHeight: 100, + Revisions: []types.Revision{{ + Number: 2, + StartHeight: 100, + }}, }, nil) mockStore.On("LoadBlock", uint64(100)).Return(&types.Block{ @@ -220,8 +230,10 @@ func TestCreateInstruction(t *testing.T) { { name: "successful instruction creation", rollapp: &types.Rollapp{ - Revision: 2, - RevisionStartHeight: 100, + Revisions: []types.Revision{{ + Number: 2, + StartHeight: 100, + }}, }, block: &types.Block{ Header: types.Header{ @@ -240,8 +252,10 @@ func TestCreateInstruction(t *testing.T) { mockSL := new(settlement.MockClientI) mockSL.On("GetObsoleteDrs").Return([]uint32{}, nil) mockSL.On("GetRollapp").Return(&types.Rollapp{ - Revision: 2, - RevisionStartHeight: 100, + Revisions: []types.Revision{{ + Number: 2, + StartHeight: 100, + }}, }, nil) manager.SLClient = mockSL diff --git a/proto/types/dymensionxyz/dymension/rollapp/rollapp.proto b/proto/types/dymensionxyz/dymension/rollapp/rollapp.proto index df3da8a1a..61c7de7e9 100644 --- a/proto/types/dymensionxyz/dymension/rollapp/rollapp.proto +++ b/proto/types/dymensionxyz/dymension/rollapp/rollapp.proto @@ -75,11 +75,16 @@ message Rollapp { // received int64 last_state_update_height = 18; - // Revision is the revision number of the rollapp - uint64 revision = 19; + // Revisions is a list of all the rollapp revisions. + repeated Revision revisions = 19 [ (gogoproto.nullable) = false ]; +} - // RevisionStartHeight is the height at which the revision was started - uint64 revision_start_height = 20; +// Revision is a representation of the rollapp revision. +message Revision { + // Number is the revision number of the rollapp. Always start with 0 revision. + uint64 number = 19; + // StartHeight is the first height of the rollapp when the revision started. + uint64 start_height = 20; } message GenesisInfo { diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index 19261ce75..90348112c 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -582,11 +582,8 @@ func (c *Client) GetRollapp() (*types.Rollapp, error) { return nil, fmt.Errorf("empty response: %w", gerrc.ErrUnknown) } - return &types.Rollapp{ - RollappID: c.rollappId, - Revision: res.Rollapp.Revision, - RevisionStartHeight: res.Rollapp.RevisionStartHeight, - }, nil + rollapp := types.RollappFromProto(res.Rollapp) + return &rollapp, nil } // GetObsoleteDrs returns the list of deprecated DRS. diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index 969adaf8b..57f7c64df 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -53,9 +53,8 @@ type Client struct { func (c *Client) GetRollapp() (*types.Rollapp, error) { return &types.Rollapp{ - RollappID: c.rollappID, - Revision: 0, - RevisionStartHeight: 1, + RollappID: c.rollappID, + Revisions: []types.Revision{{Number: 0, StartHeight: 0}}, }, nil } diff --git a/settlement/local/local.go b/settlement/local/local.go index 30f1372bc..49c18b9c3 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -56,9 +56,8 @@ type Client struct { func (c *Client) GetRollapp() (*types.Rollapp, error) { return &types.Rollapp{ - RollappID: c.rollappID, - Revision: 0, - RevisionStartHeight: 1, + RollappID: c.rollappID, + Revisions: []types.Revision{{Number: 0, StartHeight: 0}}, }, nil } diff --git a/types/pb/dymensionxyz/dymension/rollapp/rollapp.pb.go b/types/pb/dymensionxyz/dymension/rollapp/rollapp.pb.go index 60e2be449..b03450572 100644 --- a/types/pb/dymensionxyz/dymension/rollapp/rollapp.pb.go +++ b/types/pb/dymensionxyz/dymension/rollapp/rollapp.pb.go @@ -150,10 +150,8 @@ type Rollapp struct { // The LastStateUpdateHeight HUB height when the last state update was // received LastStateUpdateHeight int64 `protobuf:"varint,18,opt,name=last_state_update_height,json=lastStateUpdateHeight,proto3" json:"last_state_update_height,omitempty"` - // Revision is the revision number of the rollapp - Revision uint64 `protobuf:"varint,19,opt,name=revision,proto3" json:"revision,omitempty"` - // RevisionStartHeight is the height at which the revision was started - RevisionStartHeight uint64 `protobuf:"varint,20,opt,name=revision_start_height,json=revisionStartHeight,proto3" json:"revision_start_height,omitempty"` + // Revisions is a list of all the rollapp revisions. + Revisions []Revision `protobuf:"bytes,19,rep,name=revisions,proto3" json:"revisions"` } func (m *Rollapp) Reset() { *m = Rollapp{} } @@ -280,16 +278,64 @@ func (m *Rollapp) GetLastStateUpdateHeight() int64 { return 0 } -func (m *Rollapp) GetRevision() uint64 { +func (m *Rollapp) GetRevisions() []Revision { if m != nil { - return m.Revision + return m.Revisions + } + return nil +} + +// Revision is a representation of the rollapp revision. +type Revision struct { + // Number is the revision number of the rollapp. Always start with 0 revision. + Number uint64 `protobuf:"varint,19,opt,name=number,proto3" json:"number,omitempty"` + // StartHeight is the first height of the rollapp when the revision started. + StartHeight uint64 `protobuf:"varint,20,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` +} + +func (m *Revision) Reset() { *m = Revision{} } +func (m *Revision) String() string { return proto.CompactTextString(m) } +func (*Revision) ProtoMessage() {} +func (*Revision) Descriptor() ([]byte, []int) { + return fileDescriptor_3b0028f80c0f8489, []int{2} +} +func (m *Revision) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Revision) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Revision.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Revision) XXX_Merge(src proto.Message) { + xxx_messageInfo_Revision.Merge(m, src) +} +func (m *Revision) XXX_Size() int { + return m.Size() +} +func (m *Revision) XXX_DiscardUnknown() { + xxx_messageInfo_Revision.DiscardUnknown(m) +} + +var xxx_messageInfo_Revision proto.InternalMessageInfo + +func (m *Revision) GetNumber() uint64 { + if m != nil { + return m.Number } return 0 } -func (m *Rollapp) GetRevisionStartHeight() uint64 { +func (m *Revision) GetStartHeight() uint64 { if m != nil { - return m.RevisionStartHeight + return m.StartHeight } return 0 } @@ -312,7 +358,7 @@ func (m *GenesisInfo) Reset() { *m = GenesisInfo{} } func (m *GenesisInfo) String() string { return proto.CompactTextString(m) } func (*GenesisInfo) ProtoMessage() {} func (*GenesisInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_3b0028f80c0f8489, []int{2} + return fileDescriptor_3b0028f80c0f8489, []int{3} } func (m *GenesisInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -384,7 +430,7 @@ func (m *GenesisAccounts) Reset() { *m = GenesisAccounts{} } func (m *GenesisAccounts) String() string { return proto.CompactTextString(m) } func (*GenesisAccounts) ProtoMessage() {} func (*GenesisAccounts) Descriptor() ([]byte, []int) { - return fileDescriptor_3b0028f80c0f8489, []int{3} + return fileDescriptor_3b0028f80c0f8489, []int{4} } func (m *GenesisAccounts) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -432,7 +478,7 @@ func (m *GenesisAccount) Reset() { *m = GenesisAccount{} } func (m *GenesisAccount) String() string { return proto.CompactTextString(m) } func (*GenesisAccount) ProtoMessage() {} func (*GenesisAccount) Descriptor() ([]byte, []int) { - return fileDescriptor_3b0028f80c0f8489, []int{4} + return fileDescriptor_3b0028f80c0f8489, []int{5} } func (m *GenesisAccount) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -485,7 +531,7 @@ func (m *RollappSummary) Reset() { *m = RollappSummary{} } func (m *RollappSummary) String() string { return proto.CompactTextString(m) } func (*RollappSummary) ProtoMessage() {} func (*RollappSummary) Descriptor() ([]byte, []int) { - return fileDescriptor_3b0028f80c0f8489, []int{5} + return fileDescriptor_3b0028f80c0f8489, []int{6} } func (m *RollappSummary) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -553,6 +599,7 @@ func init() { proto.RegisterEnum("dymensionxyz.dymension.rollapp.Rollapp_VMType", Rollapp_VMType_name, Rollapp_VMType_value) proto.RegisterType((*RollappGenesisState)(nil), "dymensionxyz.dymension.rollapp.RollappGenesisState") proto.RegisterType((*Rollapp)(nil), "dymensionxyz.dymension.rollapp.Rollapp") + proto.RegisterType((*Revision)(nil), "dymensionxyz.dymension.rollapp.Revision") proto.RegisterType((*GenesisInfo)(nil), "dymensionxyz.dymension.rollapp.GenesisInfo") proto.RegisterType((*GenesisAccounts)(nil), "dymensionxyz.dymension.rollapp.GenesisAccounts") proto.RegisterType((*GenesisAccount)(nil), "dymensionxyz.dymension.rollapp.GenesisAccount") @@ -564,68 +611,70 @@ func init() { } var fileDescriptor_3b0028f80c0f8489 = []byte{ - // 973 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x5f, 0x6f, 0xdb, 0x54, - 0x14, 0xaf, 0x9b, 0x34, 0x71, 0x4f, 0xfa, 0xc7, 0xbb, 0x6d, 0x91, 0x89, 0x68, 0x1a, 0x05, 0x09, - 0x05, 0x8d, 0xd9, 0x22, 0x05, 0xf1, 0xbc, 0x42, 0xbb, 0xa6, 0x50, 0x69, 0x72, 0xda, 0x22, 0xed, - 0x01, 0xef, 0xc6, 0xbe, 0x71, 0xac, 0xd9, 0xd7, 0xc6, 0xd7, 0x09, 0x4b, 0x3f, 0x00, 0xcf, 0xfb, - 0x58, 0x93, 0x78, 0x99, 0x78, 0x42, 0x3c, 0x0c, 0xd4, 0x7e, 0x11, 0x74, 0xff, 0xd8, 0x4d, 0xbb, - 0x41, 0xc3, 0x9e, 0xae, 0xcf, 0xf9, 0x9d, 0xf3, 0xbb, 0xe7, 0xef, 0x35, 0xf4, 0xf2, 0x59, 0x4a, - 0x98, 0xed, 0xcf, 0x62, 0x42, 0x59, 0x98, 0xd0, 0x97, 0xb3, 0xcb, 0x1b, 0xc1, 0xce, 0x92, 0x28, - 0xc2, 0x69, 0x5a, 0x9c, 0x56, 0x9a, 0x25, 0x79, 0x82, 0x5a, 0xf3, 0xd6, 0x56, 0x29, 0x58, 0xca, - 0xaa, 0xb9, 0x1d, 0x24, 0x41, 0x22, 0x4c, 0x6d, 0xfe, 0x25, 0xbd, 0x9a, 0x7b, 0x41, 0x92, 0x04, - 0x11, 0xb1, 0x85, 0x34, 0x9c, 0x8c, 0xec, 0x3c, 0x8c, 0x09, 0xcb, 0x71, 0xac, 0x68, 0x9b, 0xbb, - 0x32, 0x14, 0x2f, 0x61, 0x71, 0xc2, 0xec, 0x98, 0x05, 0xf6, 0xf4,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, 0x5b, 0x3a, 0xf4, 0x15, 0xec, 0xdc, 0x21, 0x50, 0xc6, 0x2b, 0xc2, 0xf8, 0xfd, 0xe0, 0xc1, - 0xf3, 0xd7, 0x57, 0x2d, 0xed, 0xcd, 0x55, 0x4b, 0xfb, 0xfb, 0xaa, 0xa5, 0xbd, 0xba, 0x6e, 0x2d, - 0xbd, 0xb9, 0x6e, 0x2d, 0xfd, 0x71, 0xdd, 0x5a, 0x7a, 0x76, 0x34, 0xd7, 0xb8, 0xbb, 0xbf, 0xe8, - 0x90, 0xe6, 0xb2, 0x75, 0x76, 0x3a, 0xbc, 0xe7, 0xff, 0x3d, 0xac, 0x89, 0x87, 0x73, 0xff, 0x9f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xda, 0x8e, 0x54, 0x3e, 0xcf, 0x08, 0x00, 0x00, + // 995 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x5d, 0x6f, 0xdb, 0x54, + 0x18, 0xae, 0x9b, 0x34, 0x49, 0xdf, 0xa4, 0xad, 0x77, 0xda, 0x22, 0x53, 0xd1, 0x34, 0x04, 0x09, + 0x05, 0x8d, 0xd9, 0x22, 0x05, 0x71, 0xbd, 0x42, 0xbb, 0xb6, 0xac, 0xd2, 0xe4, 0x7e, 0x20, 0xed, + 0x02, 0xef, 0xc4, 0x3e, 0x71, 0xac, 0xd9, 0xc7, 0xc6, 0xe7, 0x38, 0x2c, 0xfd, 0x01, 0x5c, 0xef, + 0x67, 0x8d, 0xbb, 0x89, 0x2b, 0xc4, 0xc5, 0x40, 0xed, 0x1f, 0x41, 0xe7, 0xc3, 0x69, 0xd6, 0x0d, + 0x9a, 0x71, 0x75, 0xfc, 0x7e, 0x3d, 0xe7, 0xfd, 0x78, 0xde, 0x93, 0x40, 0x9f, 0x4f, 0x32, 0xc2, + 0x9c, 0x60, 0x92, 0x10, 0xca, 0xa2, 0x94,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0x34, 0xb2, 0xa0, 0x8e, 0x83, 0x20, 0x27, 0x8c, 0x69, 0x1a, 0x94, 0x62, 0xf7, 0xf7, + 0x45, 0x58, 0xd5, 0xcf, 0xc3, 0x69, 0x91, 0x24, 0x38, 0x9f, 0xa0, 0x4f, 0xe0, 0xe6, 0xa5, 0x7f, + 0xf7, 0xe9, 0x7f, 0x0a, 0x66, 0x8c, 0x39, 0xd1, 0xcb, 0x77, 0x44, 0x03, 0xa2, 0xa8, 0x35, 0x47, + 0xf9, 0x3a, 0x62, 0x98, 0xca, 0x28, 0xf7, 0x1d, 0x1c, 0x14, 0xc3, 0xc7, 0x4a, 0x77, 0x10, 0x51, + 0x1c, 0x47, 0x97, 0x24, 0x98, 0xb9, 0xa4, 0xf2, 0xbf, 0x2e, 0xf9, 0x77, 0x40, 0xd4, 0x85, 0x96, + 0x32, 0xaa, 0x65, 0x93, 0x14, 0xad, 0xba, 0x6f, 0xe9, 0xd0, 0xd7, 0xb0, 0x79, 0x0b, 0x40, 0x3b, + 0x2f, 0x49, 0xe7, 0xf7, 0x1b, 0xf7, 0x9e, 0xbd, 0xba, 0x6a, 0x1b, 0xaf, 0xaf, 0xda, 0xc6, 0xdf, + 0x57, 0x6d, 0xe3, 0xe5, 0x75, 0x7b, 0xe1, 0xf5, 0x75, 0x7b, 0xe1, 0x8f, 0xeb, 0xf6, 0xc2, 0xd3, + 0x83, 0x99, 0xc1, 0xdd, 0xfe, 0x9d, 0x8f, 0x28, 0x57, 0xa3, 0x73, 0xb2, 0xc1, 0x1d, 0x7f, 0x02, + 0x06, 0x35, 0xf9, 0xfa, 0xee, 0xfe, 0x13, 0x00, 0x00, 0xff, 0xff, 0x39, 0xa3, 0x7e, 0xf5, 0x14, + 0x09, 0x00, 0x00, } func (m *RollappGenesisState) Marshal() (dAtA []byte, err error) { @@ -681,19 +730,21 @@ func (m *Rollapp) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.RevisionStartHeight != 0 { - i = encodeVarintRollapp(dAtA, i, uint64(m.RevisionStartHeight)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xa0 - } - if m.Revision != 0 { - i = encodeVarintRollapp(dAtA, i, uint64(m.Revision)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x98 + if len(m.Revisions) > 0 { + for iNdEx := len(m.Revisions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Revisions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRollapp(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x9a + } } if m.LastStateUpdateHeight != 0 { i = encodeVarintRollapp(dAtA, i, uint64(m.LastStateUpdateHeight)) @@ -809,6 +860,43 @@ func (m *Rollapp) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Revision) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Revision) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Revision) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.StartHeight != 0 { + i = encodeVarintRollapp(dAtA, i, uint64(m.StartHeight)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa0 + } + if m.Number != 0 { + i = encodeVarintRollapp(dAtA, i, uint64(m.Number)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x98 + } + return len(dAtA) - i, nil +} + func (m *GenesisInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1101,11 +1189,26 @@ func (m *Rollapp) Size() (n int) { if m.LastStateUpdateHeight != 0 { n += 2 + sovRollapp(uint64(m.LastStateUpdateHeight)) } - if m.Revision != 0 { - n += 2 + sovRollapp(uint64(m.Revision)) + if len(m.Revisions) > 0 { + for _, e := range m.Revisions { + l = e.Size() + n += 2 + l + sovRollapp(uint64(l)) + } + } + return n +} + +func (m *Revision) Size() (n int) { + if m == nil { + return 0 } - if m.RevisionStartHeight != 0 { - n += 2 + sovRollapp(uint64(m.RevisionStartHeight)) + var l int + _ = l + if m.Number != 0 { + n += 2 + sovRollapp(uint64(m.Number)) + } + if m.StartHeight != 0 { + n += 2 + sovRollapp(uint64(m.StartHeight)) } return n } @@ -1663,11 +1766,95 @@ func (m *Rollapp) Unmarshal(dAtA []byte) error { break } } + case 19: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Revisions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRollapp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRollapp + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRollapp + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Revisions = append(m.Revisions, Revision{}) + if err := m.Revisions[len(m.Revisions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRollapp(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRollapp + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Revision) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRollapp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Revision: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Revision: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { case 19: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Number", wireType) } - m.Revision = 0 + m.Number = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowRollapp @@ -1677,16 +1864,16 @@ func (m *Rollapp) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Revision |= uint64(b&0x7F) << shift + m.Number |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 20: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RevisionStartHeight", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StartHeight", wireType) } - m.RevisionStartHeight = 0 + m.StartHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowRollapp @@ -1696,7 +1883,7 @@ func (m *Rollapp) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.RevisionStartHeight |= uint64(b&0x7F) << shift + m.StartHeight |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/types/rollapp.go b/types/rollapp.go index 286c9971d..f6fcd1d14 100644 --- a/types/rollapp.go +++ b/types/rollapp.go @@ -1,9 +1,44 @@ package types +import rollapptypes "github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp" + type Rollapp struct { RollappID string + Revisions []Revision +} + +type Revision struct { + Number uint64 + StartHeight uint64 +} - Revision uint64 +func (r Rollapp) LatestRevision() Revision { + if len(r.Revisions) == 0 { + // Revision 0 if no revisions exist. + return Revision{} + } + return r.Revisions[len(r.Revisions)-1] +} + +func (r Rollapp) GetRevisionForHeight(height uint64) Revision { + for i := len(r.Revisions) - 1; i >= 0; i-- { + if height >= r.Revisions[i].StartHeight { + return r.Revisions[i] + } + } + return Revision{} +} - RevisionStartHeight uint64 +func RollappFromProto(pb rollapptypes.Rollapp) Rollapp { + revisions := make([]Revision, 0, len(pb.Revisions)) + for _, pbRevision := range pb.Revisions { + revisions = append(revisions, Revision{ + Number: pbRevision.Number, + StartHeight: pbRevision.StartHeight, + }) + } + return Rollapp{ + RollappID: pb.RollappId, + Revisions: revisions, + } } From e5437bcf98bac9973cfc259e097964ab0df7e955 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Mon, 18 Nov 2024 13:55:50 +0100 Subject: [PATCH 099/119] refactor some errors --- types/errors.go | 67 +++++++++++++++++++++++++++------------- types/validation.go | 8 ++--- types/validation_test.go | 6 ++-- 3 files changed, 52 insertions(+), 29 deletions(-) diff --git a/types/errors.go b/types/errors.go index ae722c029..0ba79ad3d 100644 --- a/types/errors.go +++ b/types/errors.go @@ -38,9 +38,9 @@ type ErrFraudHeightMismatch struct { } // NewErrFraudHeightMismatch creates a new ErrFraudHeightMismatch error. -func NewErrFraudHeightMismatch(expected uint64, actual uint64, block *Block) error { +func NewErrFraudHeightMismatch(expected uint64, block *Block) error { return &ErrFraudHeightMismatch{ - Expected: expected, Actual: actual, + Expected: expected, Actual: block.Header.Height, HeaderHash: block.Header.Hash(), Proposer: block.Header.ProposerAddress, } } @@ -54,25 +54,30 @@ func (e ErrFraudHeightMismatch) Unwrap() error { return gerrc.ErrFault } +// ErrFraudAppHashMismatch is the fraud that occurs when the AppHash of the block is different from the expected AppHash. type ErrFraudAppHashMismatch struct { Expected [32]byte HeaderHeight uint64 HeaderHash [32]byte + AppHash [32]byte Proposer []byte } // NewErrFraudAppHashMismatch creates a new ErrFraudAppHashMismatch error. -func NewErrFraudAppHashMismatch(expected [32]byte, actual [32]byte, block *Block) error { +func NewErrFraudAppHashMismatch(expected [32]byte, block *Block) error { return &ErrFraudAppHashMismatch{ Expected: expected, - HeaderHeight: block.Header.Height, HeaderHash: block.Header.Hash(), Proposer: block.Header.ProposerAddress, + HeaderHeight: block.Header.Height, + HeaderHash: block.Header.Hash(), + AppHash: block.Header.AppHash, + Proposer: block.Header.ProposerAddress, } } func (e ErrFraudAppHashMismatch) Error() string { return fmt.Sprintf("possible fraud detected on height %d, with header hash %X, emitted by sequencer %X:"+ - " AppHash mismatch: state expected %X, got %X", e.HeaderHeight, e.HeaderHash, e.Proposer, e.Expected, e.HeaderHash) + " AppHash mismatch: state expected %X, got %X", e.HeaderHeight, e.HeaderHash, e.Proposer, e.Expected, e.AppHash) } func (e ErrFraudAppHashMismatch) Unwrap() error { @@ -106,6 +111,7 @@ func (e ErrLastResultsHashMismatch) Unwrap() error { return gerrc.ErrFault } +// ErrTimeFraud represents an error indicating a possible fraud due to time drift. type ErrTimeFraud struct { Drift time.Duration ProposerAddress []byte @@ -119,21 +125,21 @@ func NewErrTimeFraud(block *Block, currentTime time.Time) error { drift := time.Unix(int64(block.Header.Time), 0).Sub(currentTime) return ErrTimeFraud{ + CurrentTime: currentTime, Drift: drift, ProposerAddress: block.Header.ProposerAddress, HeaderHash: block.Header.Hash(), HeaderHeight: block.Header.Height, HeaderTime: time.Unix(int64(block.Header.Time), 0), - CurrentTime: currentTime, } } func (e ErrTimeFraud) Error() string { return fmt.Sprintf( - "sequencer posted a block with invalid time. "+ - "Max allowed drift exceeded. "+ - "proposerAddress=%s headerHash=%s headerHeight=%d drift=%s MaxDrift=%s headerTime=%s currentTime=%s", - e.ProposerAddress, e.HeaderHash, e.HeaderHeight, e.Drift, TimeFraudMaxDrift, e.HeaderTime, e.CurrentTime, + "possible fraud detected on height %d, with header hash %X, emitted by sequencer %X: "+ + "Time drift exceeded: drift=%s, max allowed drift=%s, header time=%s, current time=%s", + e.HeaderHeight, e.HeaderHash, e.ProposerAddress, + e.Drift, TimeFraudMaxDrift, e.HeaderTime, e.CurrentTime, ) } @@ -141,6 +147,7 @@ func (e ErrTimeFraud) Unwrap() error { return gerrc.ErrFault } +// ErrLastHeaderHashMismatch is the error that occurs when the last header hash does not match the expected value. type ErrLastHeaderHashMismatch struct { Expected [32]byte LastHeaderHash [32]byte @@ -154,13 +161,14 @@ func NewErrLastHeaderHashMismatch(expected [32]byte, block *Block) error { } func (e ErrLastHeaderHashMismatch) Error() string { - return fmt.Sprintf("last header hash mismatch. expected=%X, got=%X", e.Expected, e.LastHeaderHash) + return fmt.Sprintf("possible fraud detected: last header hash mismatch. expected=%X, got=%X", e.Expected, e.LastHeaderHash) } func (e ErrLastHeaderHashMismatch) Unwrap() error { return gerrc.ErrFault } +// ErrInvalidChainID is the fraud that occurs when the chain ID of the block is different from the expected chain ID. type ErrInvalidChainID struct { Expected string Block *Block @@ -174,7 +182,12 @@ func NewErrInvalidChainID(expected string, block *Block) error { } func (e ErrInvalidChainID) Error() string { - return fmt.Sprintf("invalid chain ID. expected=%s, got=%s", e.Expected, e.Block.Header.ChainID) + return fmt.Sprintf( + "possible fraud detected on height %d, with header hash %X, emitted by sequencer %X: "+ + "Invalid Chain ID: expected %s, got %s", + e.Block.Header.Height, e.Block.Header.Hash(), e.Block.Header.ProposerAddress, + e.Expected, e.Block.Header.ChainID, + ) } func (e ErrInvalidChainID) Unwrap() error { @@ -184,19 +197,24 @@ func (e ErrInvalidChainID) Unwrap() error { // ErrInvalidBlockHeightFraud is the fraud that happens when the height that is on the commit header is // different from the height of the block. type ErrInvalidBlockHeightFraud struct { - Expected uint64 - ActualHeight uint64 + Expected uint64 + Header *Header } -func NewErrInvalidBlockHeightFraud(expected uint64, actualHeight uint64) error { +func NewErrInvalidCommitBlockHeightFraud(expected uint64, header *Header) error { return &ErrInvalidBlockHeightFraud{ - Expected: expected, - ActualHeight: actualHeight, + Expected: expected, + Header: header, } } func (e ErrInvalidBlockHeightFraud) Error() string { - return fmt.Sprintf("invalid block height. expected=%d, got=%d", e.Expected, e.ActualHeight) + return fmt.Sprintf( + "possible fraud detected on height %d, with header hash %X, emitted by sequencer %X: "+ + "Invalid Block Height: expected %d, got %d", + e.Header.Height, e.Header.Hash(), e.Header.ProposerAddress, + e.Expected, e.Header.Height, + ) } func (e ErrInvalidBlockHeightFraud) Unwrap() error { @@ -205,18 +223,23 @@ func (e ErrInvalidBlockHeightFraud) Unwrap() error { type ErrInvalidHeaderHashFraud struct { ExpectedHash [32]byte - ActualHash [32]byte + Header *Header } -func NewErrInvalidHeaderHashFraud(expectedHash [32]byte, actualHash [32]byte) error { +func NewErrInvalidHeaderHashFraud(expectedHash [32]byte, header *Header) error { return &ErrInvalidHeaderHashFraud{ ExpectedHash: expectedHash, - ActualHash: actualHash, + Header: header, } } func (e ErrInvalidHeaderHashFraud) Error() string { - return fmt.Sprintf("invalid header hash. expected=%X, got=%X", e.ExpectedHash, e.ActualHash) + return fmt.Sprintf( + "possible fraud detected on height %d, with header hash %X, emitted by sequencer %X: "+ + "Invalid Header Hash: expected %X, got %X", + e.Header.Height, e.Header.Hash(), e.Header.ProposerAddress, + e.ExpectedHash, e.Header.Hash(), + ) } func (e ErrInvalidHeaderHashFraud) Unwrap() error { diff --git a/types/validation.go b/types/validation.go index 77f144212..88a502360 100644 --- a/types/validation.go +++ b/types/validation.go @@ -74,7 +74,7 @@ func (b *Block) ValidateWithState(state *State) error { nextHeight := state.NextHeight() if b.Header.Height != nextHeight { - return NewErrFraudHeightMismatch(state.NextHeight(), b.Header.Height, b) + return NewErrFraudHeightMismatch(state.NextHeight(), b) } proposerHash := state.GetProposerHash() @@ -83,7 +83,7 @@ func (b *Block) ValidateWithState(state *State) error { } if !bytes.Equal(b.Header.AppHash[:], state.AppHash[:]) { - return NewErrFraudAppHashMismatch(state.AppHash, b.Header.AppHash, b) + return NewErrFraudAppHashMismatch(state.AppHash, b) } if !bytes.Equal(b.Header.LastResultsHash[:], state.LastResultsHash[:]) { @@ -138,7 +138,7 @@ func (c *Commit) ValidateWithHeader(proposerPubKey tmcrypto.PubKey, header *Head } if c.Height != header.Height { - return NewErrInvalidBlockHeightFraud(c.Height, header.Height) + return NewErrInvalidCommitBlockHeightFraud(c.Height, header) } if !bytes.Equal(header.ProposerAddress, proposerPubKey.Address()) { @@ -156,7 +156,7 @@ func (c *Commit) ValidateWithHeader(proposerPubKey tmcrypto.PubKey, header *Head } if c.HeaderHash != header.Hash() { - return NewErrInvalidHeaderHashFraud(c.HeaderHash, header.Hash()) + return NewErrInvalidHeaderHashFraud(c.HeaderHash, header) } return nil diff --git a/types/validation_test.go b/types/validation_test.go index 14af79dd9..1e1ab39d8 100644 --- a/types/validation_test.go +++ b/types/validation_test.go @@ -50,7 +50,7 @@ func TestBlock_ValidateWithState(t *testing.T) { DataHash: [32]byte{}, LastHeaderHash: [32]byte{7, 8, 9}, ChainID: "chainID", - SequencerHash: [32]byte(proposerHash), + SequencerHash: [32]byte(proposerHash), }, Data: Data{}, LastCommit: Commit{}, @@ -370,7 +370,7 @@ func TestCommit_ValidateWithHeader(t *testing.T) { err = commit.ValidateWithHeader(proposerKey.PubKey(), &block.Header) require.Error(t, err, "Validation should fail due to an invalid height") - require.Equal(t, &ErrInvalidBlockHeightFraud{0, 1}, err) + require.Equal(t, &ErrInvalidBlockHeightFraud{0, &block.Header}, err) require.True(t, errors.Is(err, gerrc.ErrFault), "The error should be a fraud error") }) @@ -493,7 +493,7 @@ func TestCommit_ValidateWithHeader(t *testing.T) { assert.NotEqual(t, block.Hash(), commit.HeaderHash, "The commit header hash should not match the block header hash") err = commit.ValidateWithHeader(proposerKey.PubKey(), &block.Header) - require.Equal(t, &ErrInvalidHeaderHashFraud{[32]byte{1, 2, 3}, block.Hash()}, err) + require.Equal(t, &ErrInvalidHeaderHashFraud{[32]byte{1, 2, 3}, &block.Header}, err) require.True(t, errors.Is(err, gerrc.ErrFault), "The error should be a fraud error") }) } From 279838cf426beaab7e3e8f08bc8a4c50cb2cb381 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Mon, 18 Nov 2024 15:55:48 +0100 Subject: [PATCH 100/119] some more info --- types/errors.go | 16 ++++++++++++---- types/validation.go | 5 +++-- types/validation_test.go | 6 +++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/types/errors.go b/types/errors.go index 0ba79ad3d..e2f299aa7 100644 --- a/types/errors.go +++ b/types/errors.go @@ -247,17 +247,25 @@ func (e ErrInvalidHeaderHashFraud) Unwrap() error { } type ErrInvalidSignatureFraud struct { - Err error + Err error + Header *Header + Commit *Commit } -func NewErrInvalidSignatureFraud(err error) error { +func NewErrInvalidSignatureFraud(err error, header *Header, c *Commit) error { return &ErrInvalidSignatureFraud{ - Err: err, + Header: header, + Err: err, + Commit: c, } } func (e ErrInvalidSignatureFraud) Error() string { - return fmt.Sprintf("invalid signature: %s", e.Err) + return fmt.Sprintf( + "possible fraud detected on height %d, with header hash %X, emitted by sequencer %X: Invalid Signature: %s, signatures=%v", + e.Header.Height, e.Header.Hash(), e.Header.ProposerAddress, + e.Err, e.Commit.Signatures, + ) } func (e ErrInvalidSignatureFraud) Unwrap() error { diff --git a/types/validation.go b/types/validation.go index 88a502360..98a920255 100644 --- a/types/validation.go +++ b/types/validation.go @@ -118,12 +118,13 @@ func (c *Commit) ValidateBasic() error { return errors.New("signature is too big") } } + return nil } func (c *Commit) ValidateWithHeader(proposerPubKey tmcrypto.PubKey, header *Header) error { if err := c.ValidateBasic(); err != nil { - return NewErrInvalidSignatureFraud(err) + return NewErrInvalidSignatureFraud(err, header, c) } abciHeaderPb := ToABCIHeaderPB(header) @@ -134,7 +135,7 @@ func (c *Commit) ValidateWithHeader(proposerPubKey tmcrypto.PubKey, header *Head // commit is validated to have single signature if !proposerPubKey.VerifySignature(abciHeaderBytes, c.Signatures[0]) { - return NewErrInvalidSignatureFraud(ErrInvalidSignature) + return NewErrInvalidSignatureFraud(ErrInvalidSignature, header, c) } if c.Height != header.Height { diff --git a/types/validation_test.go b/types/validation_test.go index 1e1ab39d8..6f5b2243e 100644 --- a/types/validation_test.go +++ b/types/validation_test.go @@ -386,7 +386,7 @@ func TestCommit_ValidateWithHeader(t *testing.T) { err = commit.ValidateWithHeader(proposerKey.PubKey(), &block.Header) require.Error(t, err, "Validation should fail due to an invalid signature") - assert.Equal(t, NewErrInvalidSignatureFraud(ErrInvalidSignature), err) + assert.Equal(t, NewErrInvalidSignatureFraud(ErrInvalidSignature, &block.Header, commit), err) assert.True(t, errors.Is(err, gerrc.ErrFault), "The error should be a fraud error") }) @@ -407,7 +407,7 @@ func TestCommit_ValidateWithHeader(t *testing.T) { // Validate and expect an error due to multiple signatures err = commit.ValidateWithHeader(proposerKey.PubKey(), &block.Header) require.Error(t, err, "Validation should fail when there is more than one signature") - assert.Equal(t, NewErrInvalidSignatureFraud(errors.New("there should be 1 signature")), err) + assert.Equal(t, NewErrInvalidSignatureFraud(errors.New("there should be 1 signature"), &block.Header, commit), err) assert.True(t, errors.Is(err, gerrc.ErrFault), "The error should be a fraud error") }) @@ -427,7 +427,7 @@ func TestCommit_ValidateWithHeader(t *testing.T) { // Validate and expect an error due to oversized signature err = commit.ValidateWithHeader(proposerKey.PubKey(), &block.Header) require.Error(t, err, "Validation should fail when the signature size exceeds the maximum allowed size") - assert.Equal(t, NewErrInvalidSignatureFraud(errors.New("signature is too big")), err) + assert.Equal(t, NewErrInvalidSignatureFraud(errors.New("signature is too big"), &block.Header, commit), err) assert.True(t, errors.Is(err, gerrc.ErrFault), "The error should be a fraud error") }) From 52a300a3772b00b6c7a6674930b44c42d442758c Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Mon, 18 Nov 2024 16:43:24 +0100 Subject: [PATCH 101/119] unify errors and include necesary info --- block/slvalidator.go | 5 +-- types/errors.go | 84 +++++++++++++++++++++++++++++++--------- types/validation.go | 8 ++-- types/validation_test.go | 4 +- 4 files changed, 73 insertions(+), 28 deletions(-) diff --git a/block/slvalidator.go b/block/slvalidator.go index 93535976d..512c402d4 100644 --- a/block/slvalidator.go +++ b/block/slvalidator.go @@ -194,10 +194,7 @@ func (v *SettlementValidator) ValidateDaBlocks(slBatch *settlement.ResultRetriev } if !bytes.Equal(expectedNextSeqHash[:], lastDABlock.Header.NextSequencersHash[:]) { - return types.NewErrInvalidNextSequencersHashFraud( - expectedNextSeqHash, - lastDABlock.Header.NextSequencersHash, - ) + return types.NewErrInvalidNextSequencersHashFraud(expectedNextSeqHash, lastDABlock.Header) } v.logger.Debug("DA blocks validated successfully", "start height", daBlocks[0].Header.Height, "end height", daBlocks[len(daBlocks)-1].Header.Height) diff --git a/types/errors.go b/types/errors.go index e2f299aa7..4909d49ad 100644 --- a/types/errors.go +++ b/types/errors.go @@ -275,17 +275,24 @@ func (e ErrInvalidSignatureFraud) Unwrap() error { type ErrInvalidProposerAddressFraud struct { ExpectedAddress []byte ActualAddress tmcrypto.Address + + Header *Header } -func NewErrInvalidProposerAddressFraud(address []byte, address2 tmcrypto.Address) error { +func NewErrInvalidProposerAddressFraud(address []byte, address2 tmcrypto.Address, header *Header) error { return &ErrInvalidProposerAddressFraud{ ExpectedAddress: address, ActualAddress: address2, + Header: header, } } func (e ErrInvalidProposerAddressFraud) Error() string { - return fmt.Sprintf("invalid proposer address. expected=%X, got=%X", e.ExpectedAddress, e.ActualAddress) + return fmt.Sprintf( + "possible fraud detected on height %d, with header hash %X, emitted by sequencer %X: Invalid Proposer Address: expected %X, got %X", + e.Header.Height, e.Header.Hash(), e.Header.ProposerAddress, + e.ExpectedAddress, e.ActualAddress, + ) } func (e ErrInvalidProposerAddressFraud) Unwrap() error { @@ -295,17 +302,24 @@ func (e ErrInvalidProposerAddressFraud) Unwrap() error { type ErrInvalidSequencerHashFraud struct { ExpectedHash [32]byte ActualHash []byte + + Header *Header } -func NewErrInvalidSequencerHashFraud(expectedHash [32]byte, actualHash []byte) error { +func NewErrInvalidSequencerHashFraud(expectedHash [32]byte, actualHash []byte, header *Header) error { return &ErrInvalidSequencerHashFraud{ ExpectedHash: expectedHash, ActualHash: actualHash, + Header: header, } } func (e ErrInvalidSequencerHashFraud) Error() string { - return fmt.Sprintf("invalid sequencer hash. expected=%X, got=%X", e.ExpectedHash, e.ActualHash) + return fmt.Sprintf( + "possible fraud detected on height %d, with header hash %X, emitted by sequencer %X: Invalid Sequencer Hash: expected %X, got %X", + e.Header.Height, e.Header.Hash(), e.Header.ProposerAddress, + e.ExpectedHash, e.ActualHash, + ) } func (e ErrInvalidSequencerHashFraud) Unwrap() error { @@ -314,18 +328,22 @@ func (e ErrInvalidSequencerHashFraud) Unwrap() error { type ErrInvalidNextSequencersHashFraud struct { ExpectedHash [32]byte - ActualHash [32]byte + Header Header } -func NewErrInvalidNextSequencersHashFraud(expectedHash [32]byte, actualHash [32]byte) error { +func NewErrInvalidNextSequencersHashFraud(expectedHash [32]byte, header Header) error { return &ErrInvalidNextSequencersHashFraud{ ExpectedHash: expectedHash, - ActualHash: actualHash, + Header: header, } } func (e ErrInvalidNextSequencersHashFraud) Error() string { - return fmt.Sprintf("invalid next sequencers hash. expected=%X, got=%X", e.ExpectedHash, e.ActualHash) + return fmt.Sprintf( + "possible fraud detected on height %d, with header hash %X, emitted by sequencer %X: Invalid Next Sequencers Hash: expected %X, got %X", + e.Header.Height, e.Header.Hash(), e.Header.ProposerAddress, + e.ExpectedHash, e.Header.NextSequencersHash, + ) } func (e ErrInvalidNextSequencersHashFraud) Unwrap() error { @@ -335,17 +353,25 @@ func (e ErrInvalidNextSequencersHashFraud) Unwrap() error { type ErrInvalidHeaderDataHashFraud struct { Expected [32]byte Actual [32]byte + + Header Header } -func NewErrInvalidHeaderDataHashFraud(expected [32]byte, actual [32]byte) error { +func NewErrInvalidHeaderDataHashFraud(expected [32]byte, actual [32]byte, header Header) error { return &ErrInvalidHeaderDataHashFraud{ Expected: expected, Actual: actual, + + Header: header, } } func (e ErrInvalidHeaderDataHashFraud) Error() string { - return fmt.Sprintf("invalid header data hash. expected=%X, got=%X", e.Expected, e.Actual) + return fmt.Sprintf( + "possible fraud detected on height %d, with header hash %X, emitted by sequencer %X: Invalid Header Data Hash: expected %X, got %X", + e.Header.Height, e.Header.Hash(), e.Header.ProposerAddress, + e.Expected, e.Actual, + ) } func (e ErrInvalidHeaderDataHashFraud) Unwrap() error { @@ -369,7 +395,10 @@ func NewErrStateUpdateNumBlocksNotMatchingFraud(stateIndex, slNumBlocks, numbds, } func (e ErrStateUpdateNumBlocksNotMatchingFraud) Error() string { - return fmt.Sprintf("blocks not matching. StateIndex: %d Batch numblocks: %d Num of block descriptors: %d Num of DA blocks: %d", e.StateIndex, e.SLNumBlocks, e.NumBds, e.NumDABlocks) + return fmt.Sprintf( + "possible fraud detected: Blocks Not Matching - StateIndex: %d, BatchNumBlocks: %d, NumBlockDescriptors: %d, NumDABlocks: %d", + e.StateIndex, e.SLNumBlocks, e.NumBds, e.NumDABlocks, + ) } func (e ErrStateUpdateNumBlocksNotMatchingFraud) Unwrap() error { @@ -395,7 +424,10 @@ func NewErrStateUpdateHeightNotMatchingFraud(stateIndex uint64, slBeginHeight ui } func (e ErrStateUpdateHeightNotMatchingFraud) Error() string { - return fmt.Sprintf("block height in DA batch not matching SL batch height. StateIndex: %d SL Begin height: %d DA Begin height: %d SL End height:%d DA End height: %d", e.StateIndex, e.SLBeginHeight, e.DABeginHeight, e.SLEndHeight, e.DAEndHeight) + return fmt.Sprintf( + "possible fraud detected: Height Mismatch - StateIndex: %d, SL Begin Height: %d, DA Begin Height: %d, SL End Height: %d, DA End Height: %d", + e.StateIndex, e.SLBeginHeight, e.DABeginHeight, e.SLEndHeight, e.DAEndHeight, + ) } func (e ErrStateUpdateHeightNotMatchingFraud) Unwrap() error { @@ -419,7 +451,11 @@ func NewErrStateUpdateStateRootNotMatchingFraud(stateIndex uint64, height uint64 } func (e ErrStateUpdateStateRootNotMatchingFraud) Error() string { - return fmt.Sprintf("state root in DA batch block not matching state root in SL. StateIndex: %d Height: %d SL state root: %s DA state root: %s", e.StateIndex, e.Height, hex.EncodeToString(e.SLStateRoot), hex.EncodeToString(e.DAStateRoot)) + return fmt.Sprintf( + "possible fraud detected on height %d: State Root Mismatch - StateIndex: %d, SL State Root: %X, DA State Root: %X", + e.Height, + e.StateIndex, e.SLStateRoot, e.DAStateRoot, + ) } func (e ErrStateUpdateStateRootNotMatchingFraud) Unwrap() error { @@ -443,7 +479,10 @@ func NewErrStateUpdateTimestampNotMatchingFraud(stateIndex uint64, height uint64 } func (e ErrStateUpdateTimestampNotMatchingFraud) Error() string { - return fmt.Sprintf("timestamp in DA batch block not matching timestamp in SL. StateIndex: %d Height: %d SL timestsamp: %s DA timestamp: %s", e.StateIndex, e.Height, e.SLTimestamp, e.DATimestamp) + return fmt.Sprintf( + "possible fraud detected: Timestamp Mismatch - StateIndex: %d, SL Timestamp: %s, DA Timestamp: %s", + e.StateIndex, e.SLTimestamp.Format(time.RFC3339), e.DATimestamp.Format(time.RFC3339), + ) } func (e ErrStateUpdateTimestampNotMatchingFraud) Unwrap() error { @@ -483,7 +522,7 @@ func (e ErrStateUpdateDoubleSigningFraud) Error() string { if err != nil { return fmt.Sprintf("err marshal da block:%s", err) } - return fmt.Sprintf("block received from P2P not matching block found in DA. \n P2P Json Block: %s \n DA Json Block:%s \n P2P Block hash:%s \n DA block hash:%s \n P2P block bytes:%s \n DA Block bytes:%s \n", jsonP2PBlock, jsonDABlock, hex.EncodeToString(e.P2PBlockHash), hex.EncodeToString(e.DABlockHash), hex.EncodeToString(p2pBlockBytes), hex.EncodeToString(daBlockBytes)) + return fmt.Sprintf("possible fraud detected: block received from P2P not matching block found in DA. \n P2P Json Block: %s \n DA Json Block:%s \n P2P Block hash:%s \n DA block hash:%s \n P2P block bytes:%s \n DA Block bytes:%s \n", jsonP2PBlock, jsonDABlock, hex.EncodeToString(e.P2PBlockHash), hex.EncodeToString(e.DABlockHash), hex.EncodeToString(p2pBlockBytes), hex.EncodeToString(daBlockBytes)) } func (e ErrStateUpdateDoubleSigningFraud) Unwrap() error { @@ -531,7 +570,10 @@ func NewErrStateUpdateBlobNotAvailableFraud(stateIndex uint64, da string, daHeig } func (e ErrStateUpdateBlobNotAvailableFraud) Error() string { - return fmt.Sprintf("blob not available in DA. StateIndex: %d DA: %s DA Height: %d Commitment: %s", e.StateIndex, e.DA, e.DAHeight, e.Commitment) + return fmt.Sprintf( + "possible fraud detected: Blob Not Available in DA - StateIndex: %d, DA: %s, DA Height: %d, Commitment: %s", + e.StateIndex, e.DA, e.DAHeight, e.Commitment, + ) } func (e ErrStateUpdateBlobNotAvailableFraud) Unwrap() error { @@ -555,7 +597,10 @@ func NewErrStateUpdateBlobCorruptedFraud(stateIndex uint64, da string, daHeight } func (e ErrStateUpdateBlobCorruptedFraud) Error() string { - return fmt.Sprintf("blob not parsable in DA. StateIndex: %d DA: %s DA Height: %d Commitment: %s", e.StateIndex, e.DA, e.DAHeight, e.Commitment) + return fmt.Sprintf( + "possible fraud detected: Blob Corrupted in DA - StateIndex: %d, DA: %s, DA Height: %d, Commitment: %s", + e.StateIndex, e.DA, e.DAHeight, e.Commitment, + ) } func (e ErrStateUpdateBlobCorruptedFraud) Unwrap() error { @@ -579,7 +624,10 @@ func NewErrStateUpdateDRSVersionFraud(stateIndex uint64, height uint64, blockVer } func (e ErrStateUpdateDRSVersionFraud) Error() string { - return fmt.Sprintf("drs version not matching. StateIndex: %d Height: %d Block DRS: %d SL DRS: %d", e.StateIndex, e.Height, e.BlockVersion, e.SLVersion) + return fmt.Sprintf( + "possible fraud detected: DRS Version Mismatch - StateIndex: %d, Block DRS: %d, SL DRS: %d", + e.StateIndex, e.BlockVersion, e.SLVersion, + ) } func (e ErrStateUpdateDRSVersionFraud) Unwrap() error { diff --git a/types/validation.go b/types/validation.go index 98a920255..8e5cadf19 100644 --- a/types/validation.go +++ b/types/validation.go @@ -48,7 +48,7 @@ func (b *Block) ValidateWithState(state *State) error { err := b.ValidateBasic() if err != nil { if errors.Is(err, ErrInvalidHeaderDataHash) { - return NewErrInvalidHeaderDataHashFraud(b.Header.DataHash, [32]byte(GetDataHash(b))) + return NewErrInvalidHeaderDataHashFraud(b.Header.DataHash, [32]byte(GetDataHash(b)), b.Header) } return err @@ -79,7 +79,7 @@ func (b *Block) ValidateWithState(state *State) error { proposerHash := state.GetProposerHash() if !bytes.Equal(b.Header.SequencerHash[:], proposerHash) { - return NewErrInvalidSequencerHashFraud([32]byte(proposerHash), b.Header.SequencerHash[:]) + return NewErrInvalidSequencerHashFraud([32]byte(proposerHash), b.Header.SequencerHash[:], &b.Header) } if !bytes.Equal(b.Header.AppHash[:], state.AppHash[:]) { @@ -143,7 +143,7 @@ func (c *Commit) ValidateWithHeader(proposerPubKey tmcrypto.PubKey, header *Head } if !bytes.Equal(header.ProposerAddress, proposerPubKey.Address()) { - return NewErrInvalidProposerAddressFraud(header.ProposerAddress, proposerPubKey.Address()) + return NewErrInvalidProposerAddressFraud(header.ProposerAddress, proposerPubKey.Address(), header) } seq := NewSequencerFromValidator(*tmtypes.NewValidator(proposerPubKey, 1)) @@ -153,7 +153,7 @@ func (c *Commit) ValidateWithHeader(proposerPubKey tmcrypto.PubKey, header *Head } if !bytes.Equal(header.SequencerHash[:], proposerHash) { - return NewErrInvalidSequencerHashFraud(header.SequencerHash, proposerHash[:]) + return NewErrInvalidSequencerHashFraud(header.SequencerHash, proposerHash[:], header) } if c.HeaderHash != header.Hash() { diff --git a/types/validation_test.go b/types/validation_test.go index 6f5b2243e..5e0b5c21d 100644 --- a/types/validation_test.go +++ b/types/validation_test.go @@ -452,7 +452,7 @@ func TestCommit_ValidateWithHeader(t *testing.T) { // Validate and expect an error due to mismatching proposer addresses err = commit.ValidateWithHeader(proposerKey.PubKey(), &block.Header) require.Error(t, err, "Validation should fail when the proposer's address does not match the header's proposer address") - assert.Equal(t, NewErrInvalidProposerAddressFraud(block.Header.ProposerAddress, proposerKey.PubKey().Address()), err) + assert.Equal(t, NewErrInvalidProposerAddressFraud(block.Header.ProposerAddress, proposerKey.PubKey().Address(), &block.Header), err) assert.True(t, errors.Is(err, gerrc.ErrFault), "The error should be a fraud error") }) @@ -480,7 +480,7 @@ func TestCommit_ValidateWithHeader(t *testing.T) { err = commit.ValidateWithHeader(proposerKey.PubKey(), &block.Header) bytes := NewSequencerFromValidator(*tmtypes.NewValidator(proposerKey.PubKey(), 1)).MustHash() - require.Equal(t, &ErrInvalidSequencerHashFraud{[32]byte{1, 2, 3}, bytes}, err) + require.Equal(t, &ErrInvalidSequencerHashFraud{[32]byte{1, 2, 3}, bytes, &block.Header}, err) require.True(t, errors.Is(err, gerrc.ErrFault), "The error should be a fraud error") }) From e55a0f69a655624d8c60f0f2a2c258c37b8eacd0 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Mon, 18 Nov 2024 16:47:18 +0100 Subject: [PATCH 102/119] add comments --- types/errors.go | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/types/errors.go b/types/errors.go index 4909d49ad..a771cbff8 100644 --- a/types/errors.go +++ b/types/errors.go @@ -40,8 +40,10 @@ type ErrFraudHeightMismatch struct { // NewErrFraudHeightMismatch creates a new ErrFraudHeightMismatch error. func NewErrFraudHeightMismatch(expected uint64, block *Block) error { return &ErrFraudHeightMismatch{ - Expected: expected, Actual: block.Header.Height, - HeaderHash: block.Header.Hash(), Proposer: block.Header.ProposerAddress, + Expected: expected, + Actual: block.Header.Height, + HeaderHash: block.Header.Hash(), + Proposer: block.Header.ProposerAddress, } } @@ -84,6 +86,7 @@ func (e ErrFraudAppHashMismatch) Unwrap() error { return gerrc.ErrFault } +// ErrLastResultsHashMismatch indicates a potential fraud when the LastResultsHash of a block does not match the expected value. type ErrLastResultsHashMismatch struct { Expected [32]byte @@ -96,8 +99,10 @@ type ErrLastResultsHashMismatch struct { // NewErrLastResultsHashMismatch creates a new ErrLastResultsHashMismatch error. func NewErrLastResultsHashMismatch(expected [32]byte, block *Block) error { return &ErrLastResultsHashMismatch{ - Expected: expected, - HeaderHeight: block.Header.Height, HeaderHash: block.Header.Hash(), Proposer: block.Header.ProposerAddress, + Expected: expected, + HeaderHeight: block.Header.Height, + HeaderHash: block.Header.Hash(), + Proposer: block.Header.ProposerAddress, LastResultHash: block.Header.LastResultsHash, } } @@ -221,6 +226,7 @@ func (e ErrInvalidBlockHeightFraud) Unwrap() error { return gerrc.ErrFault } +// ErrInvalidHeaderHashFraud indicates a potential fraud when the Header Hash does not match the expected value. type ErrInvalidHeaderHashFraud struct { ExpectedHash [32]byte Header *Header @@ -246,6 +252,7 @@ func (e ErrInvalidHeaderHashFraud) Unwrap() error { return gerrc.ErrFault } +// ErrInvalidSignatureFraud indicates a potential fraud due to an invalid signature in the block. type ErrInvalidSignatureFraud struct { Err error Header *Header @@ -272,6 +279,7 @@ func (e ErrInvalidSignatureFraud) Unwrap() error { return gerrc.ErrFault } +// ErrInvalidProposerAddressFraud indicates a potential fraud when the proposer's address is invalid. type ErrInvalidProposerAddressFraud struct { ExpectedAddress []byte ActualAddress tmcrypto.Address @@ -299,6 +307,7 @@ func (e ErrInvalidProposerAddressFraud) Unwrap() error { return gerrc.ErrFault } +// ErrInvalidSequencerHashFraud indicates a potential fraud when the sequencer's hash is invalid. type ErrInvalidSequencerHashFraud struct { ExpectedHash [32]byte ActualHash []byte @@ -326,6 +335,7 @@ func (e ErrInvalidSequencerHashFraud) Unwrap() error { return gerrc.ErrFault } +// ErrInvalidNextSequencersHashFraud indicates a potential fraud when the NextSequencersHash does not match the expected value. type ErrInvalidNextSequencersHashFraud struct { ExpectedHash [32]byte Header Header @@ -350,6 +360,7 @@ func (e ErrInvalidNextSequencersHashFraud) Unwrap() error { return gerrc.ErrFault } +// ErrInvalidHeaderDataHashFraud indicates a potential fraud when the Header Data Hash does not match the expected value. type ErrInvalidHeaderDataHashFraud struct { Expected [32]byte Actual [32]byte @@ -378,6 +389,7 @@ func (e ErrInvalidHeaderDataHashFraud) Unwrap() error { return gerrc.ErrFault } +// ErrStateUpdateNumBlocksNotMatchingFraud represents an error where the number of blocks in the state update does not match the expected number. type ErrStateUpdateNumBlocksNotMatchingFraud struct { StateIndex uint64 SLNumBlocks uint64 @@ -405,6 +417,8 @@ func (e ErrStateUpdateNumBlocksNotMatchingFraud) Unwrap() error { return gerrc.ErrFault } +// ErrStateUpdateHeightNotMatchingFraud is the fraud that happens when the height that is on the commit header is +// different from the height of the block. type ErrStateUpdateHeightNotMatchingFraud struct { StateIndex uint64 SLBeginHeight uint64 @@ -434,6 +448,7 @@ func (e ErrStateUpdateHeightNotMatchingFraud) Unwrap() error { return gerrc.ErrFault } +// ErrStateUpdateStateRootNotMatchingFraud represents an error where the state roots do not match in the state update. type ErrStateUpdateStateRootNotMatchingFraud struct { StateIndex uint64 Height uint64 @@ -462,6 +477,7 @@ func (e ErrStateUpdateStateRootNotMatchingFraud) Unwrap() error { return gerrc.ErrFault } +// ErrStateUpdateTimestampNotMatchingFraud represents an error where the timestamps do not match in the state update. type ErrStateUpdateTimestampNotMatchingFraud struct { StateIndex uint64 Height uint64 @@ -489,6 +505,7 @@ func (e ErrStateUpdateTimestampNotMatchingFraud) Unwrap() error { return gerrc.ErrFault } +// ErrStateUpdateDoubleSigningFraud indicates a potential fraud due to double signing detected between DA and P2P blocks. type ErrStateUpdateDoubleSigningFraud struct { DABlock *Block P2PBlock *Block @@ -553,6 +570,7 @@ func getJsonFromBlock(block *Block) ([]byte, error) { return jsonBlock, nil } +// ErrStateUpdateBlobNotAvailableFraud represents an error where a blob is not available in DA. type ErrStateUpdateBlobNotAvailableFraud struct { StateIndex uint64 DA string @@ -580,6 +598,7 @@ func (e ErrStateUpdateBlobNotAvailableFraud) Unwrap() error { return gerrc.ErrFault } +// ErrStateUpdateBlobCorruptedFraud represents an error where a blob is corrupted in DA. type ErrStateUpdateBlobCorruptedFraud struct { StateIndex uint64 DA string @@ -607,6 +626,7 @@ func (e ErrStateUpdateBlobCorruptedFraud) Unwrap() error { return gerrc.ErrFault } +// ErrStateUpdateDRSVersionFraud represents an error where the DRS versions do not match in the state update. type ErrStateUpdateDRSVersionFraud struct { StateIndex uint64 Height uint64 From e93f448cd2bdc2f05e033e6a7f5d966aad4d4913 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Tue, 19 Nov 2024 15:38:33 +0100 Subject: [PATCH 103/119] temp commit --- block/manager.go | 22 +++++++++++++ block/produce.go | 35 ++++++++++++++++++++ da/avail/avail.go | 7 +++- da/celestia/celestia.go | 20 +++++++++++- da/celestia/rpc.go | 13 +++++--- da/celestia/types/rpc.go | 4 +++ da/da.go | 9 +++++ da/grpc/grpc.go | 5 +++ da/local/local.go | 5 +++ settlement/dymension/cosmosclient.go | 3 ++ settlement/dymension/dymension.go | 49 +++++++++++++++++++++++++++- settlement/grpc/grpc.go | 5 +++ settlement/local/local.go | 5 +++ settlement/settlement.go | 2 ++ types/balance.go | 8 +++++ types/metrics.go | 10 ++++++ 16 files changed, 195 insertions(+), 7 deletions(-) create mode 100644 types/balance.go diff --git a/block/manager.go b/block/manager.go index a26ba9aa3..171b4a954 100644 --- a/block/manager.go +++ b/block/manager.go @@ -400,3 +400,25 @@ func (m *Manager) freezeNode(ctx context.Context, err error) { uevent.MustPublish(ctx, m.Pubsub, &events.DataHealthStatus{Error: err}, events.HealthStatusList) m.Cancel() } + +type Balances struct { + DA *da.Balance + SL *types.Balance +} + +func (m *Manager) checkBalances() (*Balances, error) { + daBalance, err := m.DAClient.GetSignerBalance() + if err != nil { + return nil, fmt.Errorf("get signer balance: %w", err) + } + + slBalance, err := m.SLClient.GetSignerBalance() + if err != nil { + return nil, fmt.Errorf("get signer balance: %w", err) + } + + return &Balances{ + DA: daBalance, + SL: slBalance, + }, nil +} diff --git a/block/produce.go b/block/produce.go index ef723286e..e04214a7e 100644 --- a/block/produce.go +++ b/block/produce.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "strconv" "time" "github.com/dymensionxyz/gerr-cosmos/gerrc" @@ -283,3 +284,37 @@ func getHeaderHashAndCommit(store store.Store, height uint64) ([32]byte, *types. } return lastBlock.Header.Hash(), lastCommit, nil } + +func (m *Manager) MonitorBalances(ctx context.Context) { + ticker := time.NewTicker(m.Conf.BlockTime) + defer ticker.Stop() + + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + m.logger.Info("Checking balances.") + balances, err := m.checkBalances() + if err != nil { + m.logger.Error("Checking balances.", "error", err) + } + + amountStr := balances.DA.Amount.String() + amountFloat, err := strconv.ParseFloat(amountStr, 64) + if err != nil { + m.logger.Error("Checking balances.", "error", err) + return + } + types.DaLayerBalanceGauge.Set(amountFloat) + + amountStr = balances.SL.Amount.String() + amountFloat, err = strconv.ParseFloat(amountStr, 64) + if err != nil { + m.logger.Error("Checking balances.", "error", err) + return + } + types.HubLayerBalanceGauge.Set(amountFloat) + } + } +} diff --git a/da/avail/avail.go b/da/avail/avail.go index ea932c756..c37729c56 100644 --- a/da/avail/avail.go +++ b/da/avail/avail.go @@ -102,7 +102,7 @@ func WithBatchRetryAttempts(attempts uint) da.Option { } // Init initializes DataAvailabilityLayerClient instance. -func (c *DataAvailabilityLayerClient) Init(config []byte, pubsubServer *pubsub.Server, kvStore store.KV, logger types.Logger, options ...da.Option) error { +func (c *DataAvailabilityLayerClient) Init(config []byte, pubsubServer *pubsub.Server, _ store.KV, logger types.Logger, options ...da.Option) error { c.logger = logger c.synced = make(chan struct{}, 1) @@ -442,3 +442,8 @@ func (c *DataAvailabilityLayerClient) getHeightFromHash(hash availtypes.Hash) (u func (d *DataAvailabilityLayerClient) GetMaxBlobSizeBytes() uint32 { return maxBlobSize } + +// GetBalance returns the balance for a specific address +func (c *DataAvailabilityLayerClient) GetSignerBalance() (*da.Balance, error) { + return &da.Balance{}, nil +} diff --git a/da/celestia/celestia.go b/da/celestia/celestia.go index 0f29ad4cf..139116de2 100644 --- a/da/celestia/celestia.go +++ b/da/celestia/celestia.go @@ -72,7 +72,7 @@ func WithSubmitBackoff(c uretry.BackoffConfig) da.Option { } // Init initializes DataAvailabilityLayerClient instance. -func (c *DataAvailabilityLayerClient) Init(config []byte, pubsubServer *pubsub.Server, kvStore store.KV, logger types.Logger, options ...da.Option) error { +func (c *DataAvailabilityLayerClient) Init(config []byte, pubsubServer *pubsub.Server, _ store.KV, logger types.Logger, options ...da.Option) error { c.logger = logger c.synced = make(chan struct{}, 1) var err error @@ -605,3 +605,21 @@ func (c *DataAvailabilityLayerClient) sync(rpc *openrpc.Client) { func (d *DataAvailabilityLayerClient) GetMaxBlobSizeBytes() uint32 { return maxBlobSizeBytes } + +// GetSignerBalance returns the balance for a specific address +func (d *DataAvailabilityLayerClient) GetSignerBalance() (*da.Balance, error) { + ctx, cancel := context.WithTimeout(d.ctx, d.config.Timeout) + defer cancel() + + balance, err := d.rpc.GetSignerBalance(ctx) + if err != nil { + return nil, fmt.Errorf("get balance: %w", err) + } + + daBalance := &da.Balance{ + Amount: balance.Amount, + Denom: balance.Denom, + } + + return daBalance, nil +} diff --git a/da/celestia/rpc.go b/da/celestia/rpc.go index 74673e6a6..fd6113fef 100644 --- a/da/celestia/rpc.go +++ b/da/celestia/rpc.go @@ -2,11 +2,11 @@ package celestia import ( "context" - openrpc "github.com/celestiaorg/celestia-openrpc" "github.com/celestiaorg/celestia-openrpc/types/blob" "github.com/celestiaorg/celestia-openrpc/types/header" "github.com/celestiaorg/celestia-openrpc/types/share" + "github.com/celestiaorg/celestia-openrpc/types/state" "github.com/dymensionxyz/dymint/da/celestia/types" ) @@ -35,7 +35,7 @@ func (c *OpenRPC) Submit(ctx context.Context, blobs []*blob.Blob, options *blob. return c.rpc.Blob.Submit(ctx, blobs, options) } -// Getting proof for submitted blob +// GetProof gets the proof for a specific share commitment. func (c *OpenRPC) GetProof(ctx context.Context, height uint64, namespace share.Namespace, commitment blob.Commitment) (*blob.Proof, error) { return c.rpc.Blob.GetProof(ctx, height, namespace, commitment) } @@ -45,12 +45,17 @@ func (c *OpenRPC) Get(ctx context.Context, height uint64, namespace share.Namesp return c.rpc.Blob.Get(ctx, height, namespace, commitment) } -// Get extended Celestia headers for a specific height +// GetByHeight gets the header by height func (c *OpenRPC) GetByHeight(ctx context.Context, height uint64) (*header.ExtendedHeader, error) { return c.rpc.Header.GetByHeight(ctx, height) } -// Get extended Celestia headers for a specific height +// Included checks if a blob is included in the chain func (c *OpenRPC) Included(ctx context.Context, height uint64, namespace share.Namespace, proof *blob.Proof, commitment blob.Commitment) (bool, error) { return c.rpc.Blob.Included(ctx, height, namespace, proof, commitment) } + +// GetSignerBalance balance for a specific address +func (c *OpenRPC) GetSignerBalance(ctx context.Context) (*state.Balance, error) { + return c.rpc.State.Balance(ctx) +} diff --git a/da/celestia/types/rpc.go b/da/celestia/types/rpc.go index efde9c9a4..e22451c2b 100644 --- a/da/celestia/types/rpc.go +++ b/da/celestia/types/rpc.go @@ -2,6 +2,7 @@ package types import ( "context" + "github.com/celestiaorg/celestia-openrpc/types/state" "github.com/celestiaorg/celestia-openrpc/types/blob" "github.com/celestiaorg/celestia-openrpc/types/header" @@ -18,4 +19,7 @@ type CelestiaRPCClient interface { /* --------------------------------- header --------------------------------- */ GetByHeight(ctx context.Context, height uint64) (*header.ExtendedHeader, error) + + /* ---------------------------------- state --------------------------------- */ + GetSignerBalance(ctx context.Context) (*state.Balance, error) } diff --git a/da/da.go b/da/da.go index 14dec8d9f..2c75cfedd 100644 --- a/da/da.go +++ b/da/da.go @@ -1,6 +1,7 @@ package da import ( + "cosmossdk.io/math" "encoding/hex" "fmt" "strconv" @@ -74,6 +75,11 @@ type DASubmitMetaData struct { Root []byte } +type Balance struct { + Amount math.Int + Denom string +} + const PathSeparator = "|" // ToPath converts a DAMetaData to a path. @@ -221,6 +227,9 @@ type DataAvailabilityLayerClient interface { // Returns the maximum allowed blob size in the DA, used to check the max batch size configured GetMaxBlobSizeBytes() uint32 + + // GetSignerBalance returns the balance for a specific address + GetSignerBalance() (*Balance, error) } // BatchRetriever is additional interface that can be implemented by Data Availability Layer Client that is able to retrieve diff --git a/da/grpc/grpc.go b/da/grpc/grpc.go index 4724d37f2..1e2e64353 100644 --- a/da/grpc/grpc.go +++ b/da/grpc/grpc.go @@ -153,3 +153,8 @@ func (d *DataAvailabilityLayerClient) RetrieveBatches(daMetaData *da.DASubmitMet Batches: batches, } } + +func (d *DataAvailabilityLayerClient) GetSignerBalance() (*da.Balance, error) { + //TODO implement me + panic("implement me") +} diff --git a/da/local/local.go b/da/local/local.go index 87aab4ada..9908d8462 100644 --- a/da/local/local.go +++ b/da/local/local.go @@ -181,3 +181,8 @@ func (m *DataAvailabilityLayerClient) updateDAHeight() { func (d *DataAvailabilityLayerClient) GetMaxBlobSizeBytes() uint32 { return maxBlobSize } + +func (m *DataAvailabilityLayerClient) GetSignerBalance() (*da.Balance, error) { + //TODO implement me + panic("implement me") +} diff --git a/settlement/dymension/cosmosclient.go b/settlement/dymension/cosmosclient.go index db69e477a..4c3f15c50 100644 --- a/settlement/dymension/cosmosclient.go +++ b/settlement/dymension/cosmosclient.go @@ -86,3 +86,6 @@ func (c *cosmosClient) GetAccount(accountName string) (cosmosaccount.Account, er } return acc, err } + +func (c *cosmosClient) GetBalance(accountName string) (sdktypes.Coin, error) { +} diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index 90348112c..e2479093d 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -113,7 +113,7 @@ func (c *Client) Stop() error { // SubmitBatch posts a batch to the Dymension Hub. it tries to post the batch until it is accepted by the settlement layer. // it emits success and failure events to the event bus accordingly. -func (c *Client) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) error { +func (c *Client) SubmitBatch(batch *types.Batch, _ da.Client, daResult *da.ResultSubmitBatch) error { msgUpdateState, err := c.convertBatchToMsgUpdateState(batch, daResult) if err != nil { return fmt.Errorf("convert batch to msg update state: %w", err) @@ -725,3 +725,50 @@ func (c *Client) getLatestProposer() (string, error) { } return proposerAddr, nil } + +func (c *Client) GetSignerBalance() (*types.Balance, error) { + account, err := c.cosmosClient.GetAccount(c.config.DymAccountName) + if err != nil { + return nil, fmt.Errorf("obtain account: %w", err) + } + + addr, err := account.Address(addressPrefix) + if err != nil { + return nil, fmt.Errorf("derive address: %w", err) + } + + denom := "udym" + + // Realizar la consulta de saldo con reintentos + var res *banktypes.QueryBalanceResponse + err = c.RunWithRetry(func() error { + res, err = c.cosmosClient.GetBankClient().Balance(c.ctx, &banktypes.QueryBalanceRequest{ + Address: addr, + Denom: denom, + }) + if err != nil { + // Manejar errores específicos + if status.Code(err) == codes.NotFound { + return retry.Unrecoverable(errors.Join(gerrc.ErrNotFound, err)) + } + return err + } + return nil + }) + if err != nil { + return nil, fmt.Errorf("consultar saldo: %w", err) + } + + // Verificar que la respuesta no sea nil + if res == nil { + return nil, fmt.Errorf("respuesta vacía: %w", gerrc.ErrUnknown) + } + + // Convertir la respuesta al tipo types.Balance + balance := &types.Balance{ + Amount: res.Balance.Amount, + Denom: res.Balance.Denom, + } + + return balance, nil +} diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index 57f7c64df..deb6eaa0b 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -395,3 +395,8 @@ func (c *Client) retrieveBatchAtStateIndex(slStateIndex uint64) (*settlement.Res } return &batchResult, nil } + +func (c *Client) GetSignerBalance() (*types.Balance, error) { + //TODO implement me + panic("implement me") +} diff --git a/settlement/local/local.go b/settlement/local/local.go index 49c18b9c3..3d3ea8dc9 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -344,3 +344,8 @@ func keyFromIndex(ix uint64) []byte { binary.BigEndian.PutUint64(b, ix) return b } + +func (c *Client) GetSignerBalance() (*types.Balance, error) { + //TODO implement me + panic("implement me") +} diff --git a/settlement/settlement.go b/settlement/settlement.go index 9859dafcb..7c49c4218 100644 --- a/settlement/settlement.go +++ b/settlement/settlement.go @@ -98,4 +98,6 @@ type ClientI interface { GetRollapp() (*types.Rollapp, error) // GetObsoleteDrs returns the list of deprecated DRS. GetObsoleteDrs() ([]uint32, error) + // GetSignerBalance returns the balance of the signer. + GetSignerBalance() (*types.Balance, error) } diff --git a/types/balance.go b/types/balance.go new file mode 100644 index 000000000..b31c09ac1 --- /dev/null +++ b/types/balance.go @@ -0,0 +1,8 @@ +package types + +import "cosmossdk.io/math" + +type Balance struct { + Amount math.Int + Denom string +} diff --git a/types/metrics.go b/types/metrics.go index 5ad097313..559e28286 100644 --- a/types/metrics.go +++ b/types/metrics.go @@ -83,3 +83,13 @@ var RollappConsecutiveFailedDASubmission = promauto.NewGauge(prometheus.GaugeOpt Name: "rollapp_consecutive_failed_da_submissions", Help: "The number of consecutive times the da fails to submit.", }) + +var DaLayerBalanceGauge = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "da_layer_balance", + Help: "The balance of the DA layer.", +}) + +var HubLayerBalanceGauge = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "hub_layer_balance", + Help: "The balance of the hub layer.", +}) From d7053d24114426556a480cedf0db9895baa9e411 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Tue, 19 Nov 2024 16:03:33 +0100 Subject: [PATCH 104/119] refactor due to review --- types/errors.go | 36 ++++++++++++++++++------------------ types/validation.go | 8 ++++---- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/types/errors.go b/types/errors.go index 73cebd67e..033c5bd80 100644 --- a/types/errors.go +++ b/types/errors.go @@ -38,12 +38,12 @@ type ErrFraudHeightMismatch struct { } // NewErrFraudHeightMismatch creates a new ErrFraudHeightMismatch error. -func NewErrFraudHeightMismatch(expected uint64, block *Block) error { +func NewErrFraudHeightMismatch(expected uint64, header *Header) error { return &ErrFraudHeightMismatch{ Expected: expected, - Actual: block.Header.Height, - HeaderHash: block.Header.Hash(), - Proposer: block.Header.ProposerAddress, + Actual: header.Height, + HeaderHash: header.Hash(), + Proposer: header.ProposerAddress, } } @@ -67,13 +67,13 @@ type ErrFraudAppHashMismatch struct { } // NewErrFraudAppHashMismatch creates a new ErrFraudAppHashMismatch error. -func NewErrFraudAppHashMismatch(expected [32]byte, block *Block) error { +func NewErrFraudAppHashMismatch(expected [32]byte, header *Header) error { return &ErrFraudAppHashMismatch{ Expected: expected, - HeaderHeight: block.Header.Height, - HeaderHash: block.Header.Hash(), - AppHash: block.Header.AppHash, - Proposer: block.Header.ProposerAddress, + HeaderHeight: header.Height, + HeaderHash: header.Hash(), + AppHash: header.AppHash, + Proposer: header.ProposerAddress, } } @@ -97,13 +97,13 @@ type ErrLastResultsHashMismatch struct { } // NewErrLastResultsHashMismatch creates a new ErrLastResultsHashMismatch error. -func NewErrLastResultsHashMismatch(expected [32]byte, block *Block) error { +func NewErrLastResultsHashMismatch(expected [32]byte, header *Header) error { return &ErrLastResultsHashMismatch{ Expected: expected, - HeaderHeight: block.Header.Height, - HeaderHash: block.Header.Hash(), - Proposer: block.Header.ProposerAddress, - LastResultHash: block.Header.LastResultsHash, + HeaderHeight: header.Height, + HeaderHash: header.Hash(), + Proposer: header.ProposerAddress, + LastResultHash: header.LastResultsHash, } } @@ -369,12 +369,12 @@ type ErrInvalidHeaderDataHashFraud struct { Header Header } -func NewErrInvalidHeaderDataHashFraud(expected [32]byte, actual [32]byte, header Header) error { +func NewErrInvalidHeaderDataHashFraud(block *Block) error { return &ErrInvalidHeaderDataHashFraud{ - Expected: expected, - Actual: actual, + Expected: block.Header.DataHash, + Actual: [32]byte(GetDataHash(block)), - Header: header, + Header: block.Header, } } diff --git a/types/validation.go b/types/validation.go index 5062e9e1a..aa5bedae4 100644 --- a/types/validation.go +++ b/types/validation.go @@ -48,7 +48,7 @@ func (b *Block) ValidateWithState(state *State) error { err := b.ValidateBasic() if err != nil { if errors.Is(err, ErrInvalidHeaderDataHash) { - return NewErrInvalidHeaderDataHashFraud(b.Header.DataHash, [32]byte(GetDataHash(b)), b.Header) + return NewErrInvalidHeaderDataHashFraud(b) } return err @@ -74,7 +74,7 @@ func (b *Block) ValidateWithState(state *State) error { nextHeight := state.NextHeight() if b.Header.Height != nextHeight { - return NewErrFraudHeightMismatch(state.NextHeight(), b) + return NewErrFraudHeightMismatch(state.NextHeight(), &b.Header) } proposerHash := state.GetProposerHash() @@ -83,11 +83,11 @@ func (b *Block) ValidateWithState(state *State) error { } if !bytes.Equal(b.Header.AppHash[:], state.AppHash[:]) { - return NewErrFraudAppHashMismatch(state.AppHash, b) + return NewErrFraudAppHashMismatch(state.AppHash, &b.Header) } if !bytes.Equal(b.Header.LastResultsHash[:], state.LastResultsHash[:]) { - return NewErrLastResultsHashMismatch(state.LastResultsHash, b) + return NewErrLastResultsHashMismatch(state.LastResultsHash, &b.Header) } return nil From f0618827a8f632ab98e1d102730f3fac97ed4969 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Tue, 19 Nov 2024 23:37:25 +0100 Subject: [PATCH 105/119] another update --- go.mod | 1 + .../dymint/block/mock_ExecutorI.go | 2 +- .../dymint/block/mock_FraudHandler.go | 2 +- .../dymint/da/avail/mock_SubstrateApiI.go | 2 +- .../celestia/types/mock_CelestiaRPCClient.go | 62 ++++++++++++++++++- .../da/mock_DataAvailabilityLayerClient.go | 59 +++++++++++++++++- .../settlement/dymension/mock_CosmosClient.go | 2 +- .../dymint/settlement/mock_ClientI.go | 59 +++++++++++++++++- .../dymensionxyz/dymint/store/mock_Store.go | 2 +- .../dymension/rollapp/mock_QueryClient.go | 2 +- .../dymension/sequencer/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/cosmosclient.go | 19 +++++- settlement/dymension/dymension.go | 29 ++------- 16 files changed, 210 insertions(+), 39 deletions(-) diff --git a/go.mod b/go.mod index f359a0a2d..33f2a6f5b 100644 --- a/go.mod +++ b/go.mod @@ -302,6 +302,7 @@ replace ( 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.20241104165035-feade34f8f89 + github.com/dymensionxyz/cosmosclient => ../cosmosclient ) replace github.com/osmosis-labs/osmosis/v15 => github.com/dymensionxyz/osmosis/v15 v15.2.0-dymension-v1.1.2 diff --git a/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go b/mocks/github.com/dymensionxyz/dymint/block/mock_ExecutorI.go index 2ba9eee27..4dcbd3213 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.46.0. DO NOT EDIT. package block diff --git a/mocks/github.com/dymensionxyz/dymint/block/mock_FraudHandler.go b/mocks/github.com/dymensionxyz/dymint/block/mock_FraudHandler.go index 932c51a2e..b9ddec5ac 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.46.0. DO NOT EDIT. package block 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..bba31b087 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.46.0. 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 4935cc66a..e461893d6 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.46.0. DO NOT EDIT. package types @@ -11,6 +11,8 @@ import ( mock "github.com/stretchr/testify/mock" + sdk "github.com/celestiaorg/celestia-openrpc/types/sdk" + share "github.com/celestiaorg/celestia-openrpc/types/share" ) @@ -268,6 +270,64 @@ func (_c *MockCelestiaRPCClient_GetProof_Call) RunAndReturn(run func(context.Con return _c } +// GetSignerBalance provides a mock function with given fields: ctx +func (_m *MockCelestiaRPCClient) GetSignerBalance(ctx context.Context) (*sdk.Coin, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetSignerBalance") + } + + var r0 *sdk.Coin + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (*sdk.Coin, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) *sdk.Coin); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sdk.Coin) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCelestiaRPCClient_GetSignerBalance_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSignerBalance' +type MockCelestiaRPCClient_GetSignerBalance_Call struct { + *mock.Call +} + +// GetSignerBalance is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockCelestiaRPCClient_Expecter) GetSignerBalance(ctx interface{}) *MockCelestiaRPCClient_GetSignerBalance_Call { + return &MockCelestiaRPCClient_GetSignerBalance_Call{Call: _e.mock.On("GetSignerBalance", ctx)} +} + +func (_c *MockCelestiaRPCClient_GetSignerBalance_Call) Run(run func(ctx context.Context)) *MockCelestiaRPCClient_GetSignerBalance_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockCelestiaRPCClient_GetSignerBalance_Call) Return(_a0 *sdk.Coin, _a1 error) *MockCelestiaRPCClient_GetSignerBalance_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockCelestiaRPCClient_GetSignerBalance_Call) RunAndReturn(run func(context.Context) (*sdk.Coin, error)) *MockCelestiaRPCClient_GetSignerBalance_Call { + _c.Call.Return(run) + return _c +} + // Included provides a mock function with given fields: ctx, height, namespace, proof, commitment func (_m *MockCelestiaRPCClient) Included(ctx context.Context, height uint64, namespace share.Namespace, proof *blob.Proof, commitment blob.Commitment) (bool, error) { ret := _m.Called(ctx, height, namespace, proof, commitment) diff --git a/mocks/github.com/dymensionxyz/dymint/da/mock_DataAvailabilityLayerClient.go b/mocks/github.com/dymensionxyz/dymint/da/mock_DataAvailabilityLayerClient.go index 0e79e172c..db4069a22 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.46.0. DO NOT EDIT. package da @@ -162,6 +162,63 @@ func (_c *MockDataAvailabilityLayerClient_GetMaxBlobSizeBytes_Call) RunAndReturn return _c } +// GetSignerBalance provides a mock function with given fields: +func (_m *MockDataAvailabilityLayerClient) GetSignerBalance() (*da.Balance, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetSignerBalance") + } + + var r0 *da.Balance + var r1 error + if rf, ok := ret.Get(0).(func() (*da.Balance, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *da.Balance); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*da.Balance) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataAvailabilityLayerClient_GetSignerBalance_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSignerBalance' +type MockDataAvailabilityLayerClient_GetSignerBalance_Call struct { + *mock.Call +} + +// GetSignerBalance is a helper method to define mock.On call +func (_e *MockDataAvailabilityLayerClient_Expecter) GetSignerBalance() *MockDataAvailabilityLayerClient_GetSignerBalance_Call { + return &MockDataAvailabilityLayerClient_GetSignerBalance_Call{Call: _e.mock.On("GetSignerBalance")} +} + +func (_c *MockDataAvailabilityLayerClient_GetSignerBalance_Call) Run(run func()) *MockDataAvailabilityLayerClient_GetSignerBalance_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockDataAvailabilityLayerClient_GetSignerBalance_Call) Return(_a0 *da.Balance, _a1 error) *MockDataAvailabilityLayerClient_GetSignerBalance_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataAvailabilityLayerClient_GetSignerBalance_Call) RunAndReturn(run func() (*da.Balance, error)) *MockDataAvailabilityLayerClient_GetSignerBalance_Call { + _c.Call.Return(run) + return _c +} + // Init provides a mock function with given fields: config, pubsubServer, kvStore, logger, options func (_m *MockDataAvailabilityLayerClient) Init(config []byte, pubsubServer *pubsub.Server, kvStore store.KV, logger types.Logger, options ...da.Option) error { _va := make([]interface{}, len(options)) 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 52210eec7..03ca2d67a 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.46.0. 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 b531f2d00..48f995187 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.46.0. DO NOT EDIT. package settlement @@ -708,6 +708,63 @@ func (_c *MockClientI_GetSequencerByAddress_Call) RunAndReturn(run func(string) return _c } +// GetSignerBalance provides a mock function with given fields: +func (_m *MockClientI) GetSignerBalance() (*types.Balance, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetSignerBalance") + } + + var r0 *types.Balance + var r1 error + if rf, ok := ret.Get(0).(func() (*types.Balance, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *types.Balance); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.Balance) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientI_GetSignerBalance_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSignerBalance' +type MockClientI_GetSignerBalance_Call struct { + *mock.Call +} + +// GetSignerBalance is a helper method to define mock.On call +func (_e *MockClientI_Expecter) GetSignerBalance() *MockClientI_GetSignerBalance_Call { + return &MockClientI_GetSignerBalance_Call{Call: _e.mock.On("GetSignerBalance")} +} + +func (_c *MockClientI_GetSignerBalance_Call) Run(run func()) *MockClientI_GetSignerBalance_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClientI_GetSignerBalance_Call) Return(_a0 *types.Balance, _a1 error) *MockClientI_GetSignerBalance_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientI_GetSignerBalance_Call) RunAndReturn(run func() (*types.Balance, error)) *MockClientI_GetSignerBalance_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 5cb0aee0f..ef46cc41f 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.46.0. DO NOT EDIT. package store 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 a88bb2401..d65941454 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.46.0. 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..ba704d658 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.46.0. 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..45011bdc9 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.46.0. 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 9ec6b2d18..9a28054e1 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.46.0. 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 affc90a4e..120c2f698 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.46.0. DO NOT EDIT. package proxy diff --git a/settlement/dymension/cosmosclient.go b/settlement/dymension/cosmosclient.go index 4c3f15c50..5eebf55e5 100644 --- a/settlement/dymension/cosmosclient.go +++ b/settlement/dymension/cosmosclient.go @@ -32,6 +32,7 @@ type CosmosClient interface { GetRollappClient() rollapptypes.QueryClient GetSequencerClient() sequencertypes.QueryClient GetAccount(accountName string) (cosmosaccount.Account, error) + GetBalance(ctx context.Context, accountName string, denom string) (*sdktypes.Coin, error) } type cosmosClient struct { @@ -87,5 +88,21 @@ func (c *cosmosClient) GetAccount(accountName string) (cosmosaccount.Account, er return acc, err } -func (c *cosmosClient) GetBalance(accountName string) (sdktypes.Coin, error) { +func (c *cosmosClient) GetBalance(ctx context.Context, accountName string, denom string) (*sdktypes.Coin, error) { + acc, err := c.GetAccount(accountName) + if err != nil { + return &sdktypes.Coin{}, err + } + + addr, err := acc.Address(addressPrefix) + if err != nil { + return &sdktypes.Coin{}, err + } + + balance, err := c.Client.Balance(ctx, addr, denom) + if err != nil { + return &sdktypes.Coin{}, err + } + + return balance.Balance, nil } diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index e2479093d..95be287fb 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -739,35 +739,14 @@ func (c *Client) GetSignerBalance() (*types.Balance, error) { denom := "udym" - // Realizar la consulta de saldo con reintentos - var res *banktypes.QueryBalanceResponse - err = c.RunWithRetry(func() error { - res, err = c.cosmosClient.GetBankClient().Balance(c.ctx, &banktypes.QueryBalanceRequest{ - Address: addr, - Denom: denom, - }) - if err != nil { - // Manejar errores específicos - if status.Code(err) == codes.NotFound { - return retry.Unrecoverable(errors.Join(gerrc.ErrNotFound, err)) - } - return err - } - return nil - }) + res, err := c.cosmosClient.GetBalance(c.ctx, addr, denom) if err != nil { - return nil, fmt.Errorf("consultar saldo: %w", err) - } - - // Verificar que la respuesta no sea nil - if res == nil { - return nil, fmt.Errorf("respuesta vacía: %w", gerrc.ErrUnknown) + return nil, fmt.Errorf("get balance: %w", err) } - // Convertir la respuesta al tipo types.Balance balance := &types.Balance{ - Amount: res.Balance.Amount, - Denom: res.Balance.Denom, + Amount: res.Amount, + Denom: res.Denom, } return balance, nil From 0cf5b50ffddcbf099425e8a74e5e6753d89cbc01 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 20 Nov 2024 09:49:23 +0100 Subject: [PATCH 106/119] include balances monitor --- block/balance.go | 46 ++++++++++++++++++++++++++++ block/manager.go | 45 +++++++++++++++++++++------ block/modes.go | 4 +++ block/produce.go | 35 --------------------- settlement/dymension/cosmosclient.go | 14 ++------- settlement/dymension/dymension.go | 2 +- 6 files changed, 88 insertions(+), 58 deletions(-) create mode 100644 block/balance.go diff --git a/block/balance.go b/block/balance.go new file mode 100644 index 000000000..2f8a7b90d --- /dev/null +++ b/block/balance.go @@ -0,0 +1,46 @@ +package block + +import ( + "context" + "github.com/dymensionxyz/dymint/types" + "strconv" + "time" +) + +// MonitorBalances checks the balances of the node and updates the gauges for prometheus +func (m *Manager) MonitorBalances(ctx context.Context) error { + ticker := time.NewTicker(m.Conf.BlockTime) + defer ticker.Stop() + + for { + select { + case <-ctx.Done(): + return nil + case <-ticker.C: + m.logger.Info("Checking balances.") + balances, err := m.checkBalances() + + if balances.DA != nil { + if amountFloat, err := strconv.ParseFloat(balances.DA.Amount.String(), 64); err == nil { + m.logger.Info("Setting DA balance gauge.", "amount", amountFloat) + types.DaLayerBalanceGauge.Set(amountFloat) + } else { + m.logger.Error("Parsing DA balance amount", "error", err) + } + } + + if balances.SL != nil { + if amountFloat, err := strconv.ParseFloat(balances.SL.Amount.String(), 64); err == nil { + m.logger.Info("Setting SL balance gauge.", "amount", amountFloat) + types.HubLayerBalanceGauge.Set(amountFloat) + } else { + m.logger.Error("Parsing SL balance amount", "error", err) + } + } + + if err != nil { + m.logger.Error("Checking balances", "error", err) + } + } + } +} diff --git a/block/manager.go b/block/manager.go index 466d0ffca..01844f72a 100644 --- a/block/manager.go +++ b/block/manager.go @@ -409,18 +409,43 @@ type Balances struct { } func (m *Manager) checkBalances() (*Balances, error) { - daBalance, err := m.DAClient.GetSignerBalance() - if err != nil { - return nil, fmt.Errorf("get signer balance: %w", err) + balances := &Balances{} + var wg sync.WaitGroup + wg.Add(2) + + errChan := make(chan error, 2) + + go func() { + defer wg.Done() + balance, err := m.DAClient.GetSignerBalance() + if err != nil { + errChan <- fmt.Errorf("get DA signer balance: %w", err) + return + } + balances.DA = balance + }() + + go func() { + defer wg.Done() + balance, err := m.SLClient.GetSignerBalance() + if err != nil { + errChan <- fmt.Errorf("get SL signer balance: %w", err) + return + } + balances.SL = balance + }() + + wg.Wait() + close(errChan) + + var errs []error + for err := range errChan { + errs = append(errs, err) } - slBalance, err := m.SLClient.GetSignerBalance() - if err != nil { - return nil, fmt.Errorf("get signer balance: %w", err) + if len(errs) > 0 { + return balances, fmt.Errorf("errors checking balances: %v", errs) } - return &Balances{ - DA: daBalance, - SL: slBalance, - }, nil + return balances, nil } diff --git a/block/modes.go b/block/modes.go index b1ded0381..779e139da 100644 --- a/block/modes.go +++ b/block/modes.go @@ -87,6 +87,10 @@ func (m *Manager) runAsProposer(ctx context.Context, eg *errgroup.Group) error { // Monitor and handling of the rotation go m.MonitorProposerRotation(ctx) + uerrors.ErrGroupGoLog(eg, m.logger, func() error { + return m.MonitorBalances(ctx) + }) + return nil } diff --git a/block/produce.go b/block/produce.go index e04214a7e..ef723286e 100644 --- a/block/produce.go +++ b/block/produce.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "strconv" "time" "github.com/dymensionxyz/gerr-cosmos/gerrc" @@ -284,37 +283,3 @@ func getHeaderHashAndCommit(store store.Store, height uint64) ([32]byte, *types. } return lastBlock.Header.Hash(), lastCommit, nil } - -func (m *Manager) MonitorBalances(ctx context.Context) { - ticker := time.NewTicker(m.Conf.BlockTime) - defer ticker.Stop() - - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - m.logger.Info("Checking balances.") - balances, err := m.checkBalances() - if err != nil { - m.logger.Error("Checking balances.", "error", err) - } - - amountStr := balances.DA.Amount.String() - amountFloat, err := strconv.ParseFloat(amountStr, 64) - if err != nil { - m.logger.Error("Checking balances.", "error", err) - return - } - types.DaLayerBalanceGauge.Set(amountFloat) - - amountStr = balances.SL.Amount.String() - amountFloat, err = strconv.ParseFloat(amountStr, 64) - if err != nil { - m.logger.Error("Checking balances.", "error", err) - return - } - types.HubLayerBalanceGauge.Set(amountFloat) - } - } -} diff --git a/settlement/dymension/cosmosclient.go b/settlement/dymension/cosmosclient.go index 5eebf55e5..3e90eb499 100644 --- a/settlement/dymension/cosmosclient.go +++ b/settlement/dymension/cosmosclient.go @@ -88,18 +88,8 @@ func (c *cosmosClient) GetAccount(accountName string) (cosmosaccount.Account, er return acc, err } -func (c *cosmosClient) GetBalance(ctx context.Context, accountName string, denom string) (*sdktypes.Coin, error) { - acc, err := c.GetAccount(accountName) - if err != nil { - return &sdktypes.Coin{}, err - } - - addr, err := acc.Address(addressPrefix) - if err != nil { - return &sdktypes.Coin{}, err - } - - balance, err := c.Client.Balance(ctx, addr, denom) +func (c *cosmosClient) GetBalance(ctx context.Context, address string, denom string) (*sdktypes.Coin, error) { + balance, err := c.Client.Balance(ctx, address, denom) if err != nil { return &sdktypes.Coin{}, err } diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index 95be287fb..ab311a702 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -737,7 +737,7 @@ func (c *Client) GetSignerBalance() (*types.Balance, error) { return nil, fmt.Errorf("derive address: %w", err) } - denom := "udym" + denom := "adym" res, err := c.cosmosClient.GetBalance(c.ctx, addr, denom) if err != nil { From e23e7c9f3ecfe8a97b172ae7a6559aed6dd28bb3 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 20 Nov 2024 10:38:25 +0100 Subject: [PATCH 107/119] monitor balances gauge configuration --- block/balance.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/balance.go b/block/balance.go index 2f8a7b90d..e62bea12a 100644 --- a/block/balance.go +++ b/block/balance.go @@ -7,9 +7,11 @@ import ( "time" ) +const CheckBalancesInterval = 3 * time.Minute + // MonitorBalances checks the balances of the node and updates the gauges for prometheus func (m *Manager) MonitorBalances(ctx context.Context) error { - ticker := time.NewTicker(m.Conf.BlockTime) + ticker := time.NewTicker(CheckBalancesInterval) defer ticker.Stop() for { @@ -22,7 +24,6 @@ func (m *Manager) MonitorBalances(ctx context.Context) error { if balances.DA != nil { if amountFloat, err := strconv.ParseFloat(balances.DA.Amount.String(), 64); err == nil { - m.logger.Info("Setting DA balance gauge.", "amount", amountFloat) types.DaLayerBalanceGauge.Set(amountFloat) } else { m.logger.Error("Parsing DA balance amount", "error", err) @@ -31,7 +32,6 @@ func (m *Manager) MonitorBalances(ctx context.Context) error { if balances.SL != nil { if amountFloat, err := strconv.ParseFloat(balances.SL.Amount.String(), 64); err == nil { - m.logger.Info("Setting SL balance gauge.", "amount", amountFloat) types.HubLayerBalanceGauge.Set(amountFloat) } else { m.logger.Error("Parsing SL balance amount", "error", err) From 975db536ed507e2279ef8b6985c33e566756e9ba Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Wed, 20 Nov 2024 10:40:48 +0100 Subject: [PATCH 108/119] remove replace import --- go.mod | 1 - 1 file changed, 1 deletion(-) diff --git a/go.mod b/go.mod index 33f2a6f5b..f359a0a2d 100644 --- a/go.mod +++ b/go.mod @@ -302,7 +302,6 @@ replace ( 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.20241104165035-feade34f8f89 - github.com/dymensionxyz/cosmosclient => ../cosmosclient ) replace github.com/osmosis-labs/osmosis/v15 => github.com/dymensionxyz/osmosis/v15 v15.2.0-dymension-v1.1.2 From d2a3917a30c51a4dfaa6bf18d0c94efa88c778a7 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 21 Nov 2024 15:28:54 +0100 Subject: [PATCH 109/119] update go mod --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index f359a0a2d..20b4409f7 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.12 github.com/cosmos/cosmos-sdk v0.46.16 github.com/dgraph-io/badger/v4 v4.3.0 - github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13 + github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20241121093220-e0d7ad456fbd github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241119103059-def6322e4345 github.com/dymensionxyz/gerr-cosmos v1.0.0 github.com/go-kit/kit v0.12.0 @@ -257,7 +257,7 @@ require ( ) require ( - cosmossdk.io/math v1.3.0 // indirect + cosmossdk.io/math v1.3.0 github.com/DataDog/zstd v1.5.5 // indirect github.com/Jorropo/jsync v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect diff --git a/go.sum b/go.sum index 435e18a78..91ff913de 100644 --- a/go.sum +++ b/go.sum @@ -326,8 +326,8 @@ github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQx github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= github.com/dymensionxyz/cometbft v0.34.29-0.20241104165035-feade34f8f89 h1:rGkCcx4dWX9mxAUrq7zrdOc44XddMY/nM6kqYTWjerY= github.com/dymensionxyz/cometbft v0.34.29-0.20241104165035-feade34f8f89/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/cosmosclient v0.4.2-beta.0.20241121093220-e0d7ad456fbd h1:V89QyOFM84o9w0iFdctMU6So8SS/Xt32JWAXGqJduT0= +github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20241121093220-e0d7ad456fbd/go.mod h1:3weqpVj/TqTFpC0LjEB3H+HZSpm7BrQ1QkEg1Ahy6KY= github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241119103059-def6322e4345 h1:FcHidPgGEHh9ELwodNJkGcHqsG+mdPiGdughzG4W+X8= github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241119103059-def6322e4345/go.mod h1:y89w1OG4C4aF7yyW8bv9PwV3o1KkCx1hyt34ap04Rnk= github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3 h1:vmAdUGUc4rTIiO3Phezr7vGq+0uPDVKSA4WAe8+yl6w= From 9ceb70a260c22daf5b388bb64252d9274318fb70 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 21 Nov 2024 15:35:45 +0100 Subject: [PATCH 110/119] recreate mocks --- .../settlement/dymension/mock_CosmosClient.go | 60 +++++++++ .../dymensionxyz/dymint/store/mock_Store.go | 114 ------------------ 2 files changed, 60 insertions(+), 114 deletions(-) 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 03ca2d67a..d5c2bfda4 100644 --- a/mocks/github.com/dymensionxyz/dymint/settlement/dymension/mock_CosmosClient.go +++ b/mocks/github.com/dymensionxyz/dymint/settlement/dymension/mock_CosmosClient.go @@ -254,6 +254,66 @@ func (_c *MockCosmosClient_GetAccount_Call) RunAndReturn(run func(string) (cosmo return _c } +// GetBalance provides a mock function with given fields: ctx, accountName, denom +func (_m *MockCosmosClient) GetBalance(ctx context.Context, accountName string, denom string) (*types.Coin, error) { + ret := _m.Called(ctx, accountName, denom) + + if len(ret) == 0 { + panic("no return value specified for GetBalance") + } + + var r0 *types.Coin + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*types.Coin, error)); ok { + return rf(ctx, accountName, denom) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string) *types.Coin); ok { + r0 = rf(ctx, accountName, denom) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.Coin) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, accountName, denom) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCosmosClient_GetBalance_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetBalance' +type MockCosmosClient_GetBalance_Call struct { + *mock.Call +} + +// GetBalance is a helper method to define mock.On call +// - ctx context.Context +// - accountName string +// - denom string +func (_e *MockCosmosClient_Expecter) GetBalance(ctx interface{}, accountName interface{}, denom interface{}) *MockCosmosClient_GetBalance_Call { + return &MockCosmosClient_GetBalance_Call{Call: _e.mock.On("GetBalance", ctx, accountName, denom)} +} + +func (_c *MockCosmosClient_GetBalance_Call) Run(run func(ctx context.Context, accountName string, denom string)) *MockCosmosClient_GetBalance_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string)) + }) + return _c +} + +func (_c *MockCosmosClient_GetBalance_Call) Return(_a0 *types.Coin, _a1 error) *MockCosmosClient_GetBalance_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockCosmosClient_GetBalance_Call) RunAndReturn(run func(context.Context, string, string) (*types.Coin, error)) *MockCosmosClient_GetBalance_Call { + _c.Call.Return(run) + return _c +} + // GetRollappClient provides a mock function with given fields: func (_m *MockCosmosClient) GetRollappClient() rollapp.QueryClient { 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 fdc2a9c7e..ef46cc41f 100644 --- a/mocks/github.com/dymensionxyz/dymint/store/mock_Store.go +++ b/mocks/github.com/dymensionxyz/dymint/store/mock_Store.go @@ -694,61 +694,6 @@ func (_c *MockStore_LoadIndexerBaseHeight_Call) RunAndReturn(run func() (uint64, return _c } -// LoadLastSettlementBlockTime provides a mock function with given fields: -func (_m *MockStore) LoadLastSettlementBlockTime() (uint64, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for LoadLastSettlementBlockTime") - } - - var r0 uint64 - var r1 error - if rf, ok := ret.Get(0).(func() (uint64, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() uint64); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(uint64) - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockStore_LoadLastSettlementBlockTime_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoadLastSettlementBlockTime' -type MockStore_LoadLastSettlementBlockTime_Call struct { - *mock.Call -} - -// LoadLastSettlementBlockTime is a helper method to define mock.On call -func (_e *MockStore_Expecter) LoadLastSettlementBlockTime() *MockStore_LoadLastSettlementBlockTime_Call { - return &MockStore_LoadLastSettlementBlockTime_Call{Call: _e.mock.On("LoadLastSettlementBlockTime")} -} - -func (_c *MockStore_LoadLastSettlementBlockTime_Call) Run(run func()) *MockStore_LoadLastSettlementBlockTime_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockStore_LoadLastSettlementBlockTime_Call) Return(_a0 uint64, _a1 error) *MockStore_LoadLastSettlementBlockTime_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockStore_LoadLastSettlementBlockTime_Call) RunAndReturn(run func() (uint64, error)) *MockStore_LoadLastSettlementBlockTime_Call { - _c.Call.Return(run) - return _c -} - // LoadProposer provides a mock function with given fields: height func (_m *MockStore) LoadProposer(height uint64) (types.Sequencer, error) { ret := _m.Called(height) @@ -1505,65 +1450,6 @@ func (_c *MockStore_SaveIndexerBaseHeight_Call) RunAndReturn(run func(uint64) er return _c } -// SaveLastSettlementBlockTime provides a mock function with given fields: height, batch -func (_m *MockStore) SaveLastSettlementBlockTime(height uint64, batch store.KVBatch) (store.KVBatch, error) { - ret := _m.Called(height, batch) - - if len(ret) == 0 { - panic("no return value specified for SaveLastSettlementBlockTime") - } - - var r0 store.KVBatch - var r1 error - if rf, ok := ret.Get(0).(func(uint64, store.KVBatch) (store.KVBatch, error)); ok { - return rf(height, batch) - } - if rf, ok := ret.Get(0).(func(uint64, store.KVBatch) store.KVBatch); ok { - r0 = rf(height, batch) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(store.KVBatch) - } - } - - if rf, ok := ret.Get(1).(func(uint64, store.KVBatch) error); ok { - r1 = rf(height, batch) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockStore_SaveLastSettlementBlockTime_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SaveLastSettlementBlockTime' -type MockStore_SaveLastSettlementBlockTime_Call struct { - *mock.Call -} - -// SaveLastSettlementBlockTime is a helper method to define mock.On call -// - height uint64 -// - batch store.KVBatch -func (_e *MockStore_Expecter) SaveLastSettlementBlockTime(height interface{}, batch interface{}) *MockStore_SaveLastSettlementBlockTime_Call { - return &MockStore_SaveLastSettlementBlockTime_Call{Call: _e.mock.On("SaveLastSettlementBlockTime", height, batch)} -} - -func (_c *MockStore_SaveLastSettlementBlockTime_Call) Run(run func(height uint64, batch store.KVBatch)) *MockStore_SaveLastSettlementBlockTime_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(uint64), args[1].(store.KVBatch)) - }) - return _c -} - -func (_c *MockStore_SaveLastSettlementBlockTime_Call) Return(_a0 store.KVBatch, _a1 error) *MockStore_SaveLastSettlementBlockTime_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockStore_SaveLastSettlementBlockTime_Call) RunAndReturn(run func(uint64, store.KVBatch) (store.KVBatch, error)) *MockStore_SaveLastSettlementBlockTime_Call { - _c.Call.Return(run) - return _c -} - // SaveProposer provides a mock function with given fields: height, proposer, batch func (_m *MockStore) SaveProposer(height uint64, proposer types.Sequencer, batch store.KVBatch) (store.KVBatch, error) { ret := _m.Called(height, proposer, batch) From 036243a36f60b83dccb54727b105a0aa082e7fe8 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 22 Nov 2024 08:54:39 +0100 Subject: [PATCH 111/119] modify based on review --- block/balance.go | 56 +++++++++++++++++++++++++++++++++++++++++++++++- block/manager.go | 47 ---------------------------------------- 2 files changed, 55 insertions(+), 48 deletions(-) diff --git a/block/balance.go b/block/balance.go index e62bea12a..da591a114 100644 --- a/block/balance.go +++ b/block/balance.go @@ -2,9 +2,14 @@ package block import ( "context" - "github.com/dymensionxyz/dymint/types" + "fmt" + "github.com/cockroachdb/errors" "strconv" + "sync" "time" + + "github.com/dymensionxyz/dymint/da" + "github.com/dymensionxyz/dymint/types" ) const CheckBalancesInterval = 3 * time.Minute @@ -44,3 +49,52 @@ func (m *Manager) MonitorBalances(ctx context.Context) error { } } } + +type Balances struct { + DA *da.Balance + SL *types.Balance +} + +func (m *Manager) checkBalances() (*Balances, error) { + balances := &Balances{} + var wg sync.WaitGroup + wg.Add(2) + + var errDA, errSL error + + go func() { + defer wg.Done() + balance, err := m.DAClient.GetSignerBalance() + if err != nil { + errDA = fmt.Errorf("get DA signer balance: %w", err) + return + } + balances.DA = balance + }() + + go func() { + defer wg.Done() + balance, err := m.SLClient.GetSignerBalance() + if err != nil { + errSL = fmt.Errorf("get SL signer balance: %w", err) + return + } + balances.SL = balance + }() + + wg.Wait() + + var errs error + if errDA != nil { + errs = errors.Join(errs, errDA) + } + if errSL != nil { + errs = errors.Join(errs, errSL) + } + + if errs != nil { + return balances, fmt.Errorf("errors checking balances: %w", errs) + } + + return balances, nil +} diff --git a/block/manager.go b/block/manager.go index 18dfba38b..71794ce62 100644 --- a/block/manager.go +++ b/block/manager.go @@ -417,53 +417,6 @@ func (m *Manager) freezeNode(err error) { m.Cancel() } -type Balances struct { - DA *da.Balance - SL *types.Balance -} - -func (m *Manager) checkBalances() (*Balances, error) { - balances := &Balances{} - var wg sync.WaitGroup - wg.Add(2) - - errChan := make(chan error, 2) - - go func() { - defer wg.Done() - balance, err := m.DAClient.GetSignerBalance() - if err != nil { - errChan <- fmt.Errorf("get DA signer balance: %w", err) - return - } - balances.DA = balance - }() - - go func() { - defer wg.Done() - balance, err := m.SLClient.GetSignerBalance() - if err != nil { - errChan <- fmt.Errorf("get SL signer balance: %w", err) - return - } - balances.SL = balance - }() - - wg.Wait() - close(errChan) - - var errs []error - for err := range errChan { - errs = append(errs, err) - } - - if len(errs) > 0 { - return balances, fmt.Errorf("errors checking balances: %v", errs) - } - - return balances, nil -} - // SetLastBlockTimeInSettlementFromHeight is used to initialize LastBlockTimeInSettlement from rollapp height in settlement func (m *Manager) SetLastBlockTimeInSettlementFromHeight(lastSettlementHeight uint64) { block, err := m.Store.LoadBlock(lastSettlementHeight) From efd2eb04047d8edac0b5c70b13d405051a20a50c Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 22 Nov 2024 08:58:10 +0100 Subject: [PATCH 112/119] modify based on review --- da/celestia/types/rpc.go | 2 +- da/da.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/da/celestia/types/rpc.go b/da/celestia/types/rpc.go index e22451c2b..2949f65ec 100644 --- a/da/celestia/types/rpc.go +++ b/da/celestia/types/rpc.go @@ -2,11 +2,11 @@ package types import ( "context" - "github.com/celestiaorg/celestia-openrpc/types/state" "github.com/celestiaorg/celestia-openrpc/types/blob" "github.com/celestiaorg/celestia-openrpc/types/header" "github.com/celestiaorg/celestia-openrpc/types/share" + "github.com/celestiaorg/celestia-openrpc/types/state" ) type CelestiaRPCClient interface { diff --git a/da/da.go b/da/da.go index 2c75cfedd..c30717100 100644 --- a/da/da.go +++ b/da/da.go @@ -1,12 +1,12 @@ package da import ( - "cosmossdk.io/math" "encoding/hex" "fmt" "strconv" "strings" + "cosmossdk.io/math" "github.com/celestiaorg/celestia-openrpc/types/blob" "github.com/cometbft/cometbft/crypto/merkle" "github.com/dymensionxyz/dymint/store" From 5b59757477bb5fe3f433ddc6ec9d206d729aef64 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 22 Nov 2024 11:56:12 +0100 Subject: [PATCH 113/119] move monitor balances to general path --- block/manager.go | 4 ++++ block/modes.go | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block/manager.go b/block/manager.go index 71794ce62..8a1973d4d 100644 --- a/block/manager.go +++ b/block/manager.go @@ -282,6 +282,10 @@ func (m *Manager) Start(ctx context.Context) error { return m.MonitorForkUpdateLoop(ctx) }) + uerrors.ErrGroupGoLog(eg, m.logger, func() error { + return m.MonitorBalances(ctx) + }) + // run based on the node role if !amIProposer { return m.runAsFullNode(ctx, eg) diff --git a/block/modes.go b/block/modes.go index 779e139da..b1ded0381 100644 --- a/block/modes.go +++ b/block/modes.go @@ -87,10 +87,6 @@ func (m *Manager) runAsProposer(ctx context.Context, eg *errgroup.Group) error { // Monitor and handling of the rotation go m.MonitorProposerRotation(ctx) - uerrors.ErrGroupGoLog(eg, m.logger, func() error { - return m.MonitorBalances(ctx) - }) - return nil } From 5d46ffd111880c61367d265b015dcbc1691f34f0 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 22 Nov 2024 12:16:49 +0100 Subject: [PATCH 114/119] error scope clarity --- block/balance.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/balance.go b/block/balance.go index da591a114..76fb17213 100644 --- a/block/balance.go +++ b/block/balance.go @@ -28,18 +28,18 @@ func (m *Manager) MonitorBalances(ctx context.Context) error { balances, err := m.checkBalances() if balances.DA != nil { - if amountFloat, err := strconv.ParseFloat(balances.DA.Amount.String(), 64); err == nil { + if amountFloat, errDA := strconv.ParseFloat(balances.DA.Amount.String(), 64); errDA == nil { types.DaLayerBalanceGauge.Set(amountFloat) } else { - m.logger.Error("Parsing DA balance amount", "error", err) + m.logger.Error("Parsing DA balance amount", "error", errDA) } } if balances.SL != nil { - if amountFloat, err := strconv.ParseFloat(balances.SL.Amount.String(), 64); err == nil { + if amountFloat, errSL := strconv.ParseFloat(balances.SL.Amount.String(), 64); errSL == nil { types.HubLayerBalanceGauge.Set(amountFloat) } else { - m.logger.Error("Parsing SL balance amount", "error", err) + m.logger.Error("Parsing SL balance amount", "error", errSL) } } From 340d0e3ccb7ea9d47d47fe62df8227cb17975284 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 22 Nov 2024 12:23:54 +0100 Subject: [PATCH 115/119] implement panic methods --- da/grpc/grpc.go | 7 +++++-- da/local/local.go | 7 +++++-- settlement/grpc/grpc.go | 7 +++++-- settlement/local/local.go | 7 +++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/da/grpc/grpc.go b/da/grpc/grpc.go index 1e2e64353..4caf42fd0 100644 --- a/da/grpc/grpc.go +++ b/da/grpc/grpc.go @@ -5,6 +5,7 @@ import ( "encoding/json" "strconv" + "cosmossdk.io/math" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" @@ -155,6 +156,8 @@ func (d *DataAvailabilityLayerClient) RetrieveBatches(daMetaData *da.DASubmitMet } func (d *DataAvailabilityLayerClient) GetSignerBalance() (*da.Balance, error) { - //TODO implement me - panic("implement me") + return &da.Balance{ + Amount: math.ZeroInt(), + Denom: "adym", + }, nil } diff --git a/da/local/local.go b/da/local/local.go index 9908d8462..489e72f9c 100644 --- a/da/local/local.go +++ b/da/local/local.go @@ -7,6 +7,7 @@ import ( "sync/atomic" "time" + "cosmossdk.io/math" "github.com/dymensionxyz/dymint/da" "github.com/dymensionxyz/dymint/store" "github.com/dymensionxyz/dymint/types" @@ -183,6 +184,8 @@ func (d *DataAvailabilityLayerClient) GetMaxBlobSizeBytes() uint32 { } func (m *DataAvailabilityLayerClient) GetSignerBalance() (*da.Balance, error) { - //TODO implement me - panic("implement me") + return &da.Balance{ + Amount: math.ZeroInt(), + Denom: "adym", + }, nil } diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index deb6eaa0b..5dfc8142b 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -12,6 +12,7 @@ import ( "sync/atomic" "time" + "cosmossdk.io/math" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -397,6 +398,8 @@ func (c *Client) retrieveBatchAtStateIndex(slStateIndex uint64) (*settlement.Res } func (c *Client) GetSignerBalance() (*types.Balance, error) { - //TODO implement me - panic("implement me") + return &types.Balance{ + Amount: math.ZeroInt(), + Denom: "adym", + }, nil } diff --git a/settlement/local/local.go b/settlement/local/local.go index 3d3ea8dc9..053aa6719 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -12,6 +12,7 @@ import ( "sync" "time" + "cosmossdk.io/math" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -346,6 +347,8 @@ func keyFromIndex(ix uint64) []byte { } func (c *Client) GetSignerBalance() (*types.Balance, error) { - //TODO implement me - panic("implement me") + return &types.Balance{ + Amount: math.ZeroInt(), + Denom: "adym", + }, nil } From 16ffe54154bef2cbc5747de52b128de575978b38 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 22 Nov 2024 12:39:44 +0100 Subject: [PATCH 116/119] update code --- block/balance.go | 2 +- .../dymint/settlement/mock_ClientI.go | 16 +++++++--------- settlement/dymension/dymension.go | 10 +++++----- settlement/grpc/grpc.go | 4 ++-- settlement/local/local.go | 4 ++-- settlement/settlement.go | 2 +- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/block/balance.go b/block/balance.go index 76fb17213..1aae60399 100644 --- a/block/balance.go +++ b/block/balance.go @@ -79,7 +79,7 @@ func (m *Manager) checkBalances() (*Balances, error) { errSL = fmt.Errorf("get SL signer balance: %w", err) return } - balances.SL = balance + balances.SL = &balance }() wg.Wait() diff --git a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go index 48f995187..a0a488cbf 100644 --- a/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go +++ b/mocks/github.com/dymensionxyz/dymint/settlement/mock_ClientI.go @@ -709,24 +709,22 @@ func (_c *MockClientI_GetSequencerByAddress_Call) RunAndReturn(run func(string) } // GetSignerBalance provides a mock function with given fields: -func (_m *MockClientI) GetSignerBalance() (*types.Balance, error) { +func (_m *MockClientI) GetSignerBalance() (types.Balance, error) { ret := _m.Called() if len(ret) == 0 { panic("no return value specified for GetSignerBalance") } - var r0 *types.Balance + var r0 types.Balance var r1 error - if rf, ok := ret.Get(0).(func() (*types.Balance, error)); ok { + if rf, ok := ret.Get(0).(func() (types.Balance, error)); ok { return rf() } - if rf, ok := ret.Get(0).(func() *types.Balance); ok { + if rf, ok := ret.Get(0).(func() types.Balance); ok { r0 = rf() } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*types.Balance) - } + r0 = ret.Get(0).(types.Balance) } if rf, ok := ret.Get(1).(func() error); ok { @@ -755,12 +753,12 @@ func (_c *MockClientI_GetSignerBalance_Call) Run(run func()) *MockClientI_GetSig return _c } -func (_c *MockClientI_GetSignerBalance_Call) Return(_a0 *types.Balance, _a1 error) *MockClientI_GetSignerBalance_Call { +func (_c *MockClientI_GetSignerBalance_Call) Return(_a0 types.Balance, _a1 error) *MockClientI_GetSignerBalance_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientI_GetSignerBalance_Call) RunAndReturn(run func() (*types.Balance, error)) *MockClientI_GetSignerBalance_Call { +func (_c *MockClientI_GetSignerBalance_Call) RunAndReturn(run func() (types.Balance, error)) *MockClientI_GetSignerBalance_Call { _c.Call.Return(run) return _c } diff --git a/settlement/dymension/dymension.go b/settlement/dymension/dymension.go index ab311a702..2041dc0de 100644 --- a/settlement/dymension/dymension.go +++ b/settlement/dymension/dymension.go @@ -726,25 +726,25 @@ func (c *Client) getLatestProposer() (string, error) { return proposerAddr, nil } -func (c *Client) GetSignerBalance() (*types.Balance, error) { +func (c *Client) GetSignerBalance() (types.Balance, error) { account, err := c.cosmosClient.GetAccount(c.config.DymAccountName) if err != nil { - return nil, fmt.Errorf("obtain account: %w", err) + return types.Balance{}, fmt.Errorf("obtain account: %w", err) } addr, err := account.Address(addressPrefix) if err != nil { - return nil, fmt.Errorf("derive address: %w", err) + return types.Balance{}, fmt.Errorf("derive address: %w", err) } denom := "adym" res, err := c.cosmosClient.GetBalance(c.ctx, addr, denom) if err != nil { - return nil, fmt.Errorf("get balance: %w", err) + return types.Balance{}, fmt.Errorf("get balance: %w", err) } - balance := &types.Balance{ + balance := types.Balance{ Amount: res.Amount, Denom: res.Denom, } diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index 5dfc8142b..64fc61de9 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -397,8 +397,8 @@ func (c *Client) retrieveBatchAtStateIndex(slStateIndex uint64) (*settlement.Res return &batchResult, nil } -func (c *Client) GetSignerBalance() (*types.Balance, error) { - return &types.Balance{ +func (c *Client) GetSignerBalance() (types.Balance, error) { + return types.Balance{ Amount: math.ZeroInt(), Denom: "adym", }, nil diff --git a/settlement/local/local.go b/settlement/local/local.go index 053aa6719..33c152cf1 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -346,8 +346,8 @@ func keyFromIndex(ix uint64) []byte { return b } -func (c *Client) GetSignerBalance() (*types.Balance, error) { - return &types.Balance{ +func (c *Client) GetSignerBalance() (types.Balance, error) { + return types.Balance{ Amount: math.ZeroInt(), Denom: "adym", }, nil diff --git a/settlement/settlement.go b/settlement/settlement.go index 7c49c4218..c98957318 100644 --- a/settlement/settlement.go +++ b/settlement/settlement.go @@ -99,5 +99,5 @@ type ClientI interface { // GetObsoleteDrs returns the list of deprecated DRS. GetObsoleteDrs() ([]uint32, error) // GetSignerBalance returns the balance of the signer. - GetSignerBalance() (*types.Balance, error) + GetSignerBalance() (types.Balance, error) } From f40296b8e13a463bd0e0e843ad5163238e22e337 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 22 Nov 2024 12:41:04 +0100 Subject: [PATCH 117/119] errs update --- block/balance.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/block/balance.go b/block/balance.go index 1aae60399..7bada140e 100644 --- a/block/balance.go +++ b/block/balance.go @@ -84,14 +84,7 @@ func (m *Manager) checkBalances() (*Balances, error) { wg.Wait() - var errs error - if errDA != nil { - errs = errors.Join(errs, errDA) - } - if errSL != nil { - errs = errors.Join(errs, errSL) - } - + errs := errors.Join(errDA, errSL) if errs != nil { return balances, fmt.Errorf("errors checking balances: %w", errs) } From 37de170b96aa97b6bbda5ea001239cdb5eb10e31 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 22 Nov 2024 12:46:22 +0100 Subject: [PATCH 118/119] review changes --- block/balance.go | 2 +- da/avail/avail.go | 4 ++-- da/celestia/celestia.go | 6 +++--- da/da.go | 2 +- da/grpc/grpc.go | 4 ++-- da/local/local.go | 4 ++-- .../da/mock_DataAvailabilityLayerClient.go | 16 +++++++--------- 7 files changed, 18 insertions(+), 20 deletions(-) diff --git a/block/balance.go b/block/balance.go index 7bada140e..8d109b7ce 100644 --- a/block/balance.go +++ b/block/balance.go @@ -69,7 +69,7 @@ func (m *Manager) checkBalances() (*Balances, error) { errDA = fmt.Errorf("get DA signer balance: %w", err) return } - balances.DA = balance + balances.DA = &balance }() go func() { diff --git a/da/avail/avail.go b/da/avail/avail.go index c37729c56..d1a84e64d 100644 --- a/da/avail/avail.go +++ b/da/avail/avail.go @@ -444,6 +444,6 @@ func (d *DataAvailabilityLayerClient) GetMaxBlobSizeBytes() uint32 { } // GetBalance returns the balance for a specific address -func (c *DataAvailabilityLayerClient) GetSignerBalance() (*da.Balance, error) { - return &da.Balance{}, nil +func (c *DataAvailabilityLayerClient) GetSignerBalance() (da.Balance, error) { + return da.Balance{}, nil } diff --git a/da/celestia/celestia.go b/da/celestia/celestia.go index 139116de2..05d9a827f 100644 --- a/da/celestia/celestia.go +++ b/da/celestia/celestia.go @@ -607,16 +607,16 @@ func (d *DataAvailabilityLayerClient) GetMaxBlobSizeBytes() uint32 { } // GetSignerBalance returns the balance for a specific address -func (d *DataAvailabilityLayerClient) GetSignerBalance() (*da.Balance, error) { +func (d *DataAvailabilityLayerClient) GetSignerBalance() (da.Balance, error) { ctx, cancel := context.WithTimeout(d.ctx, d.config.Timeout) defer cancel() balance, err := d.rpc.GetSignerBalance(ctx) if err != nil { - return nil, fmt.Errorf("get balance: %w", err) + return da.Balance{}, fmt.Errorf("get balance: %w", err) } - daBalance := &da.Balance{ + daBalance := da.Balance{ Amount: balance.Amount, Denom: balance.Denom, } diff --git a/da/da.go b/da/da.go index c30717100..98bdff5c1 100644 --- a/da/da.go +++ b/da/da.go @@ -229,7 +229,7 @@ type DataAvailabilityLayerClient interface { GetMaxBlobSizeBytes() uint32 // GetSignerBalance returns the balance for a specific address - GetSignerBalance() (*Balance, error) + GetSignerBalance() (Balance, error) } // BatchRetriever is additional interface that can be implemented by Data Availability Layer Client that is able to retrieve diff --git a/da/grpc/grpc.go b/da/grpc/grpc.go index 4caf42fd0..8636cf583 100644 --- a/da/grpc/grpc.go +++ b/da/grpc/grpc.go @@ -155,8 +155,8 @@ func (d *DataAvailabilityLayerClient) RetrieveBatches(daMetaData *da.DASubmitMet } } -func (d *DataAvailabilityLayerClient) GetSignerBalance() (*da.Balance, error) { - return &da.Balance{ +func (d *DataAvailabilityLayerClient) GetSignerBalance() (da.Balance, error) { + return da.Balance{ Amount: math.ZeroInt(), Denom: "adym", }, nil diff --git a/da/local/local.go b/da/local/local.go index 489e72f9c..3852b2797 100644 --- a/da/local/local.go +++ b/da/local/local.go @@ -183,8 +183,8 @@ func (d *DataAvailabilityLayerClient) GetMaxBlobSizeBytes() uint32 { return maxBlobSize } -func (m *DataAvailabilityLayerClient) GetSignerBalance() (*da.Balance, error) { - return &da.Balance{ +func (m *DataAvailabilityLayerClient) GetSignerBalance() (da.Balance, error) { + return da.Balance{ Amount: math.ZeroInt(), Denom: "adym", }, nil diff --git a/mocks/github.com/dymensionxyz/dymint/da/mock_DataAvailabilityLayerClient.go b/mocks/github.com/dymensionxyz/dymint/da/mock_DataAvailabilityLayerClient.go index db4069a22..0c20e64e4 100644 --- a/mocks/github.com/dymensionxyz/dymint/da/mock_DataAvailabilityLayerClient.go +++ b/mocks/github.com/dymensionxyz/dymint/da/mock_DataAvailabilityLayerClient.go @@ -163,24 +163,22 @@ func (_c *MockDataAvailabilityLayerClient_GetMaxBlobSizeBytes_Call) RunAndReturn } // GetSignerBalance provides a mock function with given fields: -func (_m *MockDataAvailabilityLayerClient) GetSignerBalance() (*da.Balance, error) { +func (_m *MockDataAvailabilityLayerClient) GetSignerBalance() (da.Balance, error) { ret := _m.Called() if len(ret) == 0 { panic("no return value specified for GetSignerBalance") } - var r0 *da.Balance + var r0 da.Balance var r1 error - if rf, ok := ret.Get(0).(func() (*da.Balance, error)); ok { + if rf, ok := ret.Get(0).(func() (da.Balance, error)); ok { return rf() } - if rf, ok := ret.Get(0).(func() *da.Balance); ok { + if rf, ok := ret.Get(0).(func() da.Balance); ok { r0 = rf() } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*da.Balance) - } + r0 = ret.Get(0).(da.Balance) } if rf, ok := ret.Get(1).(func() error); ok { @@ -209,12 +207,12 @@ func (_c *MockDataAvailabilityLayerClient_GetSignerBalance_Call) Run(run func()) return _c } -func (_c *MockDataAvailabilityLayerClient_GetSignerBalance_Call) Return(_a0 *da.Balance, _a1 error) *MockDataAvailabilityLayerClient_GetSignerBalance_Call { +func (_c *MockDataAvailabilityLayerClient_GetSignerBalance_Call) Return(_a0 da.Balance, _a1 error) *MockDataAvailabilityLayerClient_GetSignerBalance_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockDataAvailabilityLayerClient_GetSignerBalance_Call) RunAndReturn(run func() (*da.Balance, error)) *MockDataAvailabilityLayerClient_GetSignerBalance_Call { +func (_c *MockDataAvailabilityLayerClient_GetSignerBalance_Call) RunAndReturn(run func() (da.Balance, error)) *MockDataAvailabilityLayerClient_GetSignerBalance_Call { _c.Call.Return(run) return _c } From 2a3248fdae11a1dccd1fa19e446b759f4e28565c Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 22 Nov 2024 12:56:13 +0100 Subject: [PATCH 119/119] fix lint --- block/balance.go | 2 +- da/celestia/rpc.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block/balance.go b/block/balance.go index 8d109b7ce..9c0e301fe 100644 --- a/block/balance.go +++ b/block/balance.go @@ -3,11 +3,11 @@ package block import ( "context" "fmt" - "github.com/cockroachdb/errors" "strconv" "sync" "time" + "github.com/cockroachdb/errors" "github.com/dymensionxyz/dymint/da" "github.com/dymensionxyz/dymint/types" ) diff --git a/da/celestia/rpc.go b/da/celestia/rpc.go index fd6113fef..f4dac9d64 100644 --- a/da/celestia/rpc.go +++ b/da/celestia/rpc.go @@ -2,6 +2,7 @@ package celestia import ( "context" + openrpc "github.com/celestiaorg/celestia-openrpc" "github.com/celestiaorg/celestia-openrpc/types/blob" "github.com/celestiaorg/celestia-openrpc/types/header"