From ca7a5a41cfbc4be758dcfef11caa2cda969bffb7 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 19 Sep 2024 16:08:14 +0200 Subject: [PATCH 01/19] temp commit --- block/executor.go | 8 +++++++- go.mod | 5 ++++- proto/types/tendermint/abci/types.proto | 4 ++++ proto/types/tendermint/types/types.proto | 4 ++++ types/block.go | 2 ++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/block/executor.go b/block/executor.go index 28e0fcec4..e857e5720 100644 --- a/block/executor.go +++ b/block/executor.go @@ -92,7 +92,13 @@ func (e *Executor) InitChain(genesis *tmtypes.GenesisDoc, valset []*tmtypes.Vali } // CreateBlock reaps transactions from mempool and builds a block. -func (e *Executor) CreateBlock(height uint64, lastCommit *types.Commit, lastHeaderHash, nextSeqHash [32]byte, state *types.State, maxBlockDataSizeBytes uint64) *types.Block { +func (e *Executor) CreateBlock( + height uint64, + lastCommit *types.Commit, + lastHeaderHash, nextSeqHash [32]byte, + state *types.State, + maxBlockDataSizeBytes uint64, +) *types.Block { maxBlockDataSizeBytes = min(maxBlockDataSizeBytes, uint64(max(minBlockMaxBytes, state.ConsensusParams.Block.MaxBytes))) mempoolTxs := e.mempool.ReapMaxBytesMaxGas(int64(maxBlockDataSizeBytes), state.ConsensusParams.Block.MaxGas) diff --git a/go.mod b/go.mod index 351ed8cd8..06fdd3af6 100644 --- a/go.mod +++ b/go.mod @@ -301,7 +301,10 @@ replace ( github.com/evmos/evmos/v12 => github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 github.com/gorilla/rpc => github.com/dymensionxyz/rpc v1.3.1 - github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20240906143736-1e3959c2826e + // github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20240906143736-1e3959c2826e + github.com/tendermint/tendermint => ../cometbft ) replace github.com/osmosis-labs/osmosis/v15 => github.com/dymensionxyz/osmosis/v15 v15.2.0-dymension-v1.1.2 + + diff --git a/proto/types/tendermint/abci/types.proto b/proto/types/tendermint/abci/types.proto index aa78e5f48..239cf4726 100755 --- a/proto/types/tendermint/abci/types.proto +++ b/proto/types/tendermint/abci/types.proto @@ -11,6 +11,7 @@ import "types/tendermint/crypto/keys.proto"; import "types/tendermint/types/params.proto"; import "google/protobuf/timestamp.proto"; import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; // This file is copied from http://github.com/tendermint/abci // NOTE: When using custom types, mind the warnings. @@ -79,6 +80,9 @@ message RequestBeginBlock { tendermint.types.Header header = 2 [(gogoproto.nullable) = false]; LastCommitInfo last_commit_info = 3 [(gogoproto.nullable) = false]; repeated Evidence byzantine_validators = 4 [(gogoproto.nullable) = false]; + + // New addition: defines any wrapped consensus messages. + google.protobuf.Any consensus_messages = 5; } enum CheckTxType { diff --git a/proto/types/tendermint/types/types.proto b/proto/types/tendermint/types/types.proto index 820a934e2..e8881c815 100755 --- a/proto/types/tendermint/types/types.proto +++ b/proto/types/tendermint/types/types.proto @@ -4,6 +4,7 @@ package tendermint.types; option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; import "google/protobuf/timestamp.proto"; import "types/tendermint/crypto/proof.proto"; import "types/tendermint/version/types.proto"; @@ -87,6 +88,9 @@ message Data { // NOTE: not all txs here are valid. We're just agreeing on the order first. // This means that block.AppHash does not include these txs. repeated bytes txs = 1; + + // NEW: Consensus messages are included as raw Protobuf Any types. + repeated google.protobuf.Any consensus_messages = 2; } // Vote represents a prevote, precommit, or commit vote from validators for diff --git a/types/block.go b/types/block.go index cc63f55db..5b722e41f 100644 --- a/types/block.go +++ b/types/block.go @@ -2,6 +2,7 @@ package types import ( "encoding" + "github.com/gogo/protobuf/types" "time" tmtypes "github.com/tendermint/tendermint/types" @@ -83,6 +84,7 @@ type Data struct { Txs Txs IntermediateStateRoots IntermediateStateRoots Evidence EvidenceData + ConsensusMessages []*types.Any } // EvidenceData defines how evidence is stored in block. From e3828464e50eaca5131539eb66ccd2941f1cfd3c Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Mon, 23 Sep 2024 10:08:03 +0200 Subject: [PATCH 02/19] temp commit --- block/consensus.go | 7 ++ block/executor.go | 17 +++- proto/types/dymint/dymint.proto | 2 + types/pb/dymint/dymint.pb.go | 168 ++++++++++++++++++++++---------- 4 files changed, 138 insertions(+), 56 deletions(-) create mode 100644 block/consensus.go diff --git a/block/consensus.go b/block/consensus.go new file mode 100644 index 000000000..d7d640a1f --- /dev/null +++ b/block/consensus.go @@ -0,0 +1,7 @@ +package block + +import "github.com/gogo/protobuf/proto" + +type ConsensusMessagesStream interface { + GetConsensusMessages() ([]proto.Message, error) +} diff --git a/block/executor.go b/block/executor.go index e857e5720..4716458e0 100644 --- a/block/executor.go +++ b/block/executor.go @@ -21,11 +21,12 @@ const minBlockMaxBytes = 10000 // Executor creates and applies blocks and maintains state. type Executor struct { - localAddress []byte - chainID string - proxyAppConsensusConn proxy.AppConnConsensus - proxyAppQueryConn proxy.AppConnQuery - mempool mempool.Mempool + localAddress []byte + chainID string + proxyAppConsensusConn proxy.AppConnConsensus + proxyAppQueryConn proxy.AppConnQuery + mempool mempool.Mempool + consensusMessagesStream ConsensusMessagesStream eventBus *tmtypes.EventBus @@ -102,6 +103,11 @@ func (e *Executor) CreateBlock( maxBlockDataSizeBytes = min(maxBlockDataSizeBytes, uint64(max(minBlockMaxBytes, state.ConsensusParams.Block.MaxBytes))) mempoolTxs := e.mempool.ReapMaxBytesMaxGas(int64(maxBlockDataSizeBytes), state.ConsensusParams.Block.MaxGas) + consensusMessages, err := e.consensusMessagesStream.GetConsensusMessages() + if err != nil { + e.logger.Error("Failed to get consensus messages", "error", err) + } + block := &types.Block{ Header: types.Header{ Version: types.Version{ @@ -122,6 +128,7 @@ func (e *Executor) CreateBlock( Txs: toDymintTxs(mempoolTxs), IntermediateStateRoots: types.IntermediateStateRoots{RawRootsList: nil}, Evidence: types.EvidenceData{Evidence: nil}, + ConsensusMessages: consensusMessages, }, LastCommit: *lastCommit, } diff --git a/proto/types/dymint/dymint.proto b/proto/types/dymint/dymint.proto index 80e733097..4e8191158 100755 --- a/proto/types/dymint/dymint.proto +++ b/proto/types/dymint/dymint.proto @@ -4,6 +4,7 @@ option go_package = "github.com/dymensionxyz/dymint/types/pb/dymint"; import "types/tendermint/abci/types.proto"; import "types/tendermint/types/types.proto"; import "types/tendermint/types/validator.proto"; +import "google/protobuf/any.proto"; // Version captures the consensus rules for processing a block in the blockchain, // including all blockchain data structures and the rules of the application's @@ -74,6 +75,7 @@ message Data { repeated bytes txs = 1; repeated bytes intermediate_state_roots = 2; repeated tendermint.abci.Evidence evidence = 3; + repeated google.protobuf.Any consensus_messages = 4; } message Block { diff --git a/types/pb/dymint/dymint.pb.go b/types/pb/dymint/dymint.pb.go index f3894f5d5..c47e04a5a 100644 --- a/types/pb/dymint/dymint.pb.go +++ b/types/pb/dymint/dymint.pb.go @@ -8,6 +8,7 @@ import ( proto "github.com/gogo/protobuf/proto" types1 "github.com/tendermint/tendermint/abci/types" types "github.com/tendermint/tendermint/proto/tendermint/types" + anypb "google.golang.org/protobuf/types/known/anypb" io "io" math "math" math_bits "math/bits" @@ -322,6 +323,7 @@ type Data struct { Txs [][]byte `protobuf:"bytes,1,rep,name=txs,proto3" json:"txs,omitempty"` IntermediateStateRoots [][]byte `protobuf:"bytes,2,rep,name=intermediate_state_roots,json=intermediateStateRoots,proto3" json:"intermediate_state_roots,omitempty"` Evidence []*types1.Evidence `protobuf:"bytes,3,rep,name=evidence,proto3" json:"evidence,omitempty"` + ConsensusMessages []*anypb.Any `protobuf:"bytes,4,rep,name=consensus_messages,json=consensusMessages,proto3" json:"consensus_messages,omitempty"` } func (m *Data) Reset() { *m = Data{} } @@ -378,6 +380,13 @@ func (m *Data) GetEvidence() []*types1.Evidence { return nil } +func (m *Data) GetConsensusMessages() []*anypb.Any { + if m != nil { + return m.ConsensusMessages + } + return nil +} + type Block struct { Header *Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` Data *Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` @@ -624,57 +633,60 @@ func init() { func init() { proto.RegisterFile("types/dymint/dymint.proto", fileDescriptor_fe69c538ded4b87f) } var fileDescriptor_fe69c538ded4b87f = []byte{ - // 797 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x95, 0x4d, 0x4f, 0xdb, 0x48, - 0x18, 0xc7, 0x31, 0x09, 0x79, 0x79, 0x1c, 0x02, 0x99, 0x5d, 0x21, 0x07, 0xb4, 0xd9, 0x60, 0x09, - 0x14, 0x56, 0xc2, 0x88, 0xac, 0x56, 0xda, 0xbd, 0xac, 0xb4, 0x6c, 0x2b, 0x85, 0xeb, 0x44, 0xe2, - 0xd0, 0x4b, 0x34, 0xb1, 0x47, 0xb1, 0xd5, 0xf8, 0xa5, 0x9e, 0x09, 0x82, 0x1e, 0xb9, 0xf5, 0xd6, - 0x73, 0x6f, 0xfd, 0x36, 0x3d, 0x72, 0xec, 0xb1, 0x82, 0x2f, 0x52, 0xcd, 0x33, 0x63, 0xc7, 0x50, - 0x7a, 0x01, 0xcf, 0xff, 0xff, 0xf3, 0xcc, 0xe3, 0xe7, 0x65, 0x02, 0x7d, 0x79, 0x9b, 0x71, 0x71, - 0x16, 0xdc, 0xc6, 0x51, 0x22, 0xcd, 0x3f, 0x2f, 0xcb, 0x53, 0x99, 0x92, 0x86, 0x5e, 0xed, 0x1f, - 0x6a, 0x44, 0xf2, 0x24, 0xe0, 0x39, 0x62, 0x6c, 0xee, 0x47, 0x67, 0xa8, 0x6a, 0x74, 0xdf, 0xfd, - 0x01, 0x31, 0x42, 0x85, 0x39, 0xfe, 0x09, 0x73, 0xcd, 0x96, 0x51, 0xc0, 0x64, 0x9a, 0x6b, 0xce, - 0x3d, 0x87, 0xe6, 0x15, 0xcf, 0x45, 0x94, 0x26, 0xe4, 0x57, 0xd8, 0x9a, 0x2f, 0x53, 0xff, 0xad, - 0x63, 0x0d, 0xad, 0x51, 0x9d, 0xea, 0x05, 0xd9, 0x85, 0x1a, 0xcb, 0x32, 0x67, 0x13, 0x35, 0xf5, - 0xe8, 0xde, 0xd5, 0xa1, 0x31, 0xe1, 0x2c, 0xe0, 0x39, 0x39, 0x81, 0xe6, 0xb5, 0x7e, 0x1b, 0x5f, - 0xb2, 0xc7, 0x3b, 0x9e, 0xf9, 0x28, 0xb3, 0x29, 0x2d, 0x7c, 0x72, 0x04, 0x9d, 0x84, 0xc5, 0x5c, - 0x64, 0xcc, 0xe7, 0xb3, 0x28, 0xc0, 0x0d, 0x3b, 0x17, 0x9b, 0x8e, 0x45, 0xed, 0x52, 0xbf, 0x0c, - 0xc8, 0x1e, 0x34, 0x42, 0x1e, 0x2d, 0x42, 0xe9, 0xd4, 0xf0, 0x44, 0xb3, 0x22, 0x04, 0xea, 0x32, - 0x8a, 0xb9, 0x53, 0x47, 0x15, 0x9f, 0xc9, 0x08, 0x76, 0x97, 0x4c, 0xc8, 0x59, 0x88, 0xc1, 0xcc, - 0x42, 0x26, 0x42, 0x67, 0x4b, 0x6d, 0x4b, 0xbb, 0x4a, 0xd7, 0x31, 0x4e, 0x98, 0x08, 0x4b, 0xd2, - 0x4f, 0xe3, 0x38, 0x92, 0x9a, 0x6c, 0xac, 0xc9, 0xff, 0x51, 0x46, 0xf2, 0x00, 0xda, 0x01, 0x93, - 0x4c, 0x23, 0x4d, 0x44, 0x5a, 0x4a, 0x40, 0xf3, 0x08, 0xba, 0x7e, 0x9a, 0x08, 0x9e, 0x88, 0x95, - 0xd0, 0x44, 0x0b, 0x89, 0xed, 0x52, 0x45, 0xac, 0x0f, 0x2d, 0x96, 0x65, 0x1a, 0x68, 0x23, 0xd0, - 0x64, 0x59, 0x86, 0xd6, 0x1f, 0xd0, 0xc3, 0x40, 0x72, 0x2e, 0x56, 0x4b, 0x69, 0x36, 0x01, 0x64, - 0x76, 0x94, 0x41, 0xb5, 0x8e, 0xec, 0x09, 0xec, 0x66, 0x79, 0x9a, 0xa5, 0x82, 0xe7, 0x33, 0x16, - 0x04, 0x39, 0x17, 0xc2, 0xb1, 0x35, 0x5a, 0xe8, 0xff, 0x69, 0x59, 0x05, 0x26, 0xf8, 0xbb, 0x15, - 0x4f, 0xfc, 0x22, 0x0f, 0x1d, 0x1d, 0x58, 0xa9, 0xe2, 0x8e, 0x1e, 0xfc, 0x92, 0xf0, 0x1b, 0x39, - 0x7b, 0xc6, 0x76, 0x91, 0xed, 0x29, 0x6b, 0xfa, 0x84, 0xef, 0x43, 0xcb, 0x0f, 0x59, 0x94, 0xa8, - 0x7a, 0x6d, 0x0f, 0xad, 0x51, 0x9b, 0x36, 0x71, 0x7d, 0x19, 0xb8, 0x9f, 0x2d, 0x68, 0xe8, 0xb4, - 0x55, 0x4a, 0x66, 0x3d, 0x29, 0xd9, 0xef, 0x60, 0x57, 0x2b, 0x83, 0x05, 0xa7, 0x10, 0xae, 0xab, - 0x32, 0x00, 0x10, 0xd1, 0x22, 0x61, 0x72, 0x95, 0x73, 0xe1, 0xd4, 0x86, 0x35, 0xe5, 0xaf, 0x15, - 0xf2, 0x2f, 0x74, 0x64, 0x3c, 0x2b, 0x05, 0xac, 0xbd, 0x3d, 0x3e, 0xf0, 0xd6, 0x4d, 0xed, 0xe9, - 0x96, 0xd7, 0x81, 0x4c, 0xa3, 0x05, 0xb5, 0x65, 0x3c, 0x2d, 0x78, 0xf7, 0x83, 0x05, 0xf5, 0x57, - 0x4c, 0x32, 0xd5, 0xc3, 0xf2, 0x46, 0x38, 0x16, 0x9e, 0xa0, 0x1e, 0xc9, 0xdf, 0xe0, 0x44, 0x89, - 0xe4, 0x79, 0xcc, 0x83, 0x88, 0x49, 0x3e, 0x13, 0x52, 0xfd, 0xcd, 0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aa, 0x40, 0xe8, 0x9a, 0x76, 0x33, 0xe8, 0x94, 0xc7, 0x4e, 0xb9, 0x24, 0xe7, 0x00, 0xe5, 0x78, - 0xe8, 0x96, 0xb1, 0xc7, 0xbd, 0x22, 0xe6, 0x92, 0xa4, 0x15, 0x88, 0x9c, 0x42, 0xab, 0x18, 0x48, - 0x73, 0xf8, 0x0b, 0x2f, 0x94, 0xc8, 0xc5, 0xe4, 0xcb, 0xc3, 0xc0, 0xba, 0x7f, 0x18, 0x58, 0xdf, - 0x1e, 0x06, 0xd6, 0xc7, 0xc7, 0xc1, 0xc6, 0xfd, 0xe3, 0x60, 0xe3, 0xeb, 0xe3, 0x60, 0xe3, 0x8d, - 0xb7, 0x88, 0x64, 0xb8, 0x9a, 0x7b, 0x7e, 0x1a, 0xab, 0x1f, 0x07, 0x9e, 0xa8, 0x9b, 0xf3, 0xe6, - 0xf6, 0x7d, 0xf1, 0x83, 0xa1, 0xaf, 0xf0, 0x6c, 0x6e, 0xd6, 0xf3, 0x06, 0xde, 0xe1, 0x7f, 0x7e, - 0x0f, 0x00, 0x00, 0xff, 0xff, 0xc4, 0xde, 0x10, 0x30, 0x57, 0x06, 0x00, 0x00, + // 845 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x95, 0xcf, 0x6f, 0xdb, 0x36, + 0x14, 0xc7, 0xa3, 0xc4, 0xf1, 0x8f, 0x27, 0x27, 0x8d, 0xb9, 0xa2, 0x90, 0x5b, 0xcc, 0x4b, 0x05, + 0xa4, 0x48, 0x07, 0x54, 0x46, 0x3d, 0x0c, 0xd8, 0x2e, 0x03, 0x9a, 0x6e, 0x80, 0x7b, 0xd8, 0x85, + 0x06, 0x7a, 0xd8, 0xc5, 0xa0, 0xa5, 0x37, 0x4b, 0x98, 0x45, 0x69, 0x22, 0x1d, 0xc4, 0x3b, 0xf6, + 0x2f, 0xd8, 0x79, 0xb7, 0xfd, 0x37, 0x3b, 0x0d, 0x3d, 0xee, 0x38, 0x24, 0xff, 0xc8, 0xc0, 0x47, + 0x4a, 0x56, 0xbb, 0xf4, 0x92, 0x88, 0xdf, 0xef, 0x47, 0xe4, 0xf3, 0xfb, 0x41, 0xc1, 0x58, 0xef, + 0x4a, 0x54, 0xd3, 0x64, 0x97, 0x67, 0x52, 0xbb, 0x7f, 0x51, 0x59, 0x15, 0xba, 0x60, 0x5d, 0xbb, + 0x7a, 0xfc, 0xd4, 0x22, 0x1a, 0x65, 0x82, 0x15, 0x61, 0x62, 0x15, 0x67, 0x53, 0x52, 0x2d, 0xfa, + 0x38, 0xfc, 0x1f, 0xe2, 0x84, 0x16, 0xf3, 0xec, 0x13, 0xcc, 0xb5, 0xd8, 0x64, 0x89, 0xd0, 0x45, + 0xe5, 0xb8, 0xf1, 0xba, 0x28, 0xd6, 0x1b, 0x9c, 0xd2, 0x6a, 0xb5, 0xfd, 0x79, 0x2a, 0xe4, 0xce, + 0x5a, 0xe1, 0x4b, 0xe8, 0xbd, 0xc5, 0x4a, 0x65, 0x85, 0x64, 0x0f, 0xe1, 0x78, 0xb5, 0x29, 0xe2, + 0x5f, 0x02, 0xef, 0xdc, 0xbb, 0xec, 0x70, 0xbb, 0x60, 0x67, 0x70, 0x24, 0xca, 0x32, 0x38, 0x24, + 0xcd, 0x3c, 0x86, 0xef, 0x3a, 0xd0, 0x9d, 0xa3, 0x48, 0xb0, 0x62, 0xcf, 0xa1, 0x77, 0x6d, 0xdf, + 0xa6, 0x97, 0xfc, 0xd9, 0x83, 0xc8, 0xfd, 0x5e, 0xb7, 0x29, 0xaf, 0x7d, 0x76, 0x01, 0x43, 0x29, + 0x72, 0x54, 0xa5, 0x88, 0x71, 0x99, 0x25, 0xb4, 0xe1, 0xf0, 0xea, 0x30, 0xf0, 0xb8, 0xdf, 0xe8, + 0x6f, 0x12, 0xf6, 0x08, 0xba, 0x29, 0x66, 0xeb, 0x54, 0x07, 0x47, 0x74, 0xa2, 0x5b, 0x31, 0x06, + 0x1d, 0x9d, 0xe5, 0x18, 0x74, 0x48, 0xa5, 0x67, 0x76, 0x09, 0x67, 0x1b, 0xa1, 0xf4, 0x32, 0xa5, + 0x60, 0x96, 0xa9, 0x50, 0x69, 0x70, 0x6c, 0xb6, 0xe5, 0xa7, 0x46, 0xb7, 0x31, 0xce, 0x85, 0x4a, + 0x1b, 0x32, 0x2e, 0xf2, 0x3c, 0xd3, 0x96, 0xec, 0xee, 0xc9, 0xd7, 0x24, 0x13, 0xf9, 0x04, 0x06, + 0x89, 0xd0, 0xc2, 0x22, 0x3d, 0x42, 0xfa, 0x46, 0x20, 0xf3, 0x02, 0x4e, 0xe3, 0x42, 0x2a, 0x94, + 0x6a, 0xab, 0x2c, 0xd1, 0x27, 0xe2, 0xa4, 0x51, 0x09, 0x1b, 0x43, 0x5f, 0x94, 0xa5, 0x05, 0x06, + 0x04, 0xf4, 0x44, 0x59, 0x92, 0xf5, 0x25, 0x8c, 0x28, 0x90, 0x0a, 0xd5, 0x76, 0xa3, 0xdd, 0x26, + 0x40, 0xcc, 0x03, 0x63, 0x70, 0xab, 0x13, 0xfb, 0x1c, 0xce, 0xca, 0xaa, 0x28, 0x0b, 0x85, 0xd5, + 0x52, 0x24, 0x49, 0x85, 0x4a, 0x05, 0xbe, 0x45, 0x6b, 0xfd, 0x95, 0x95, 0x4d, 0x60, 0x0a, 0x7f, + 0xdd, 0xa2, 0x8c, 0xeb, 0x3c, 0x0c, 0x6d, 0x60, 0x8d, 0x4a, 0x3b, 0x46, 0xf0, 0x99, 0xc4, 0x1b, + 0xbd, 0xfc, 0x88, 0x3d, 0x25, 0x76, 0x64, 0xac, 0xc5, 0x07, 0xfc, 0x18, 0xfa, 0x71, 0x2a, 0x32, + 0x69, 0xea, 0x75, 0x72, 0xee, 0x5d, 0x0e, 0x78, 0x8f, 0xd6, 0x6f, 0x92, 0xf0, 0x4f, 0x0f, 0xba, + 0x36, 0x6d, 0xad, 0x92, 0x79, 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0x5a, 0x67, 0x3a, 0xdd, 0xae, 0xa2, 0xb8, 0xc8, 0xcd, 0xc7, 0x07, 0xa5, 0xb9, 0x7e, 0x6f, 0x76, + 0xbf, 0xd5, 0x1f, 0x24, 0xfb, 0x89, 0x28, 0x57, 0x6e, 0xbd, 0xea, 0x52, 0xd7, 0x7d, 0xf5, 0x5f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x74, 0x19, 0x14, 0x49, 0xb7, 0x06, 0x00, 0x00, } func (m *Version) Marshal() (dAtA []byte, err error) { @@ -908,6 +920,20 @@ func (m *Data) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ConsensusMessages) > 0 { + for iNdEx := len(m.ConsensusMessages) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ConsensusMessages[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDymint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } if len(m.Evidence) > 0 { for iNdEx := len(m.Evidence) - 1; iNdEx >= 0; iNdEx-- { { @@ -1293,6 +1319,12 @@ func (m *Data) Size() (n int) { n += 1 + l + sovDymint(uint64(l)) } } + if len(m.ConsensusMessages) > 0 { + for _, e := range m.ConsensusMessages { + l = e.Size() + n += 1 + l + sovDymint(uint64(l)) + } + } return n } @@ -2268,6 +2300,40 @@ func (m *Data) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusMessages", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDymint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDymint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDymint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsensusMessages = append(m.ConsensusMessages, &anypb.Any{}) + if err := m.ConsensusMessages[len(m.ConsensusMessages)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipDymint(dAtA[iNdEx:]) From c6639e7e42ff58b42dbf4721dd156b35437fb51f Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Mon, 23 Sep 2024 10:32:26 +0200 Subject: [PATCH 03/19] add consensus messages to the block data --- block/consensus.go | 2 +- block/executor.go | 23 ++++++++++++++++++++++- types/block.go | 4 ++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/block/consensus.go b/block/consensus.go index d7d640a1f..23843e84a 100644 --- a/block/consensus.go +++ b/block/consensus.go @@ -1,6 +1,6 @@ package block -import "github.com/gogo/protobuf/proto" +import "google.golang.org/protobuf/proto" type ConsensusMessagesStream interface { GetConsensusMessages() ([]proto.Message, error) diff --git a/block/executor.go b/block/executor.go index 4716458e0..7108209a4 100644 --- a/block/executor.go +++ b/block/executor.go @@ -2,6 +2,8 @@ package block import ( "errors" + proto "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" "time" abci "github.com/tendermint/tendermint/abci/types" @@ -108,6 +110,8 @@ func (e *Executor) CreateBlock( e.logger.Error("Failed to get consensus messages", "error", err) } + consensusAnyMessages := fromProtoMsgSliceToAnySlice(consensusMessages) + block := &types.Block{ Header: types.Header{ Version: types.Version{ @@ -128,7 +132,7 @@ func (e *Executor) CreateBlock( Txs: toDymintTxs(mempoolTxs), IntermediateStateRoots: types.IntermediateStateRoots{RawRootsList: nil}, Evidence: types.EvidenceData{Evidence: nil}, - ConsensusMessages: consensusMessages, + ConsensusMessages: consensusAnyMessages, }, LastCommit: *lastCommit, } @@ -297,3 +301,20 @@ func fromDymintTxs(optiTxs types.Txs) tmtypes.Txs { } return txs } + +func fromProtoMsgToAny(msg proto.Message) *anypb.Any { + anyType, err := anypb.New(msg) + if err != nil { + panic(err) + } + + return anyType +} + +func fromProtoMsgSliceToAnySlice(msgs []proto.Message) []*anypb.Any { + result := make([]*anypb.Any, len(msgs)) + for i, msg := range msgs { + result[i] = fromProtoMsgToAny(msg) + } + return result +} diff --git a/types/block.go b/types/block.go index 5b722e41f..d6d6b8935 100644 --- a/types/block.go +++ b/types/block.go @@ -2,7 +2,7 @@ package types import ( "encoding" - "github.com/gogo/protobuf/types" + "google.golang.org/protobuf/types/known/anypb" "time" tmtypes "github.com/tendermint/tendermint/types" @@ -84,7 +84,7 @@ type Data struct { Txs Txs IntermediateStateRoots IntermediateStateRoots Evidence EvidenceData - ConsensusMessages []*types.Any + ConsensusMessages []*anypb.Any } // EvidenceData defines how evidence is stored in block. From 336e3ca12d20b4cadf9a776a2e41d4ce44436e5d Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Mon, 23 Sep 2024 10:47:17 +0200 Subject: [PATCH 04/19] Execute block --- block/executor.go | 1 + 1 file changed, 1 insertion(+) diff --git a/block/executor.go b/block/executor.go index 7108209a4..22358619d 100644 --- a/block/executor.go +++ b/block/executor.go @@ -226,6 +226,7 @@ func (e *Executor) ExecuteBlock(state *types.State, block *types.Block) (*tmstat Votes: nil, }, ByzantineValidators: nil, + ConsensusMessages: block.Data.ConsensusMessages, }) if err != nil { return nil, err From 9209ab6c8658c013e2fc6e1c563af97c4fe40940 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Mon, 23 Sep 2024 13:02:56 +0200 Subject: [PATCH 05/19] previous proto gen --- block/executor_test.go | 90 ++++++++++++++++++++++++++++++++++++ buf.gen.yaml | 3 +- go.mod | 4 +- go.sum | 2 - types/pb/dymint/dymint.pb.go | 8 ++-- 5 files changed, 97 insertions(+), 10 deletions(-) diff --git a/block/executor_test.go b/block/executor_test.go index ffe22754c..98b35b2ca 100644 --- a/block/executor_test.go +++ b/block/executor_test.go @@ -3,6 +3,9 @@ package block_test import ( "context" "crypto/rand" + "github.com/golang/groupcache/testpb" + "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" "testing" "time" @@ -86,6 +89,93 @@ func TestCreateBlock(t *testing.T) { assert.Len(block.Data.Txs, 2) } +func TestCreateBlockWithConsensusMessages(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + logger := log.TestingLogger() + app := &tmmocks.MockApplication{} + app.On("CheckTx", mock.Anything).Return(abci.ResponseCheckTx{}) + clientCreator := proxy.NewLocalClientCreator(app) + abciClient, err := clientCreator.NewABCIClient() + require.NoError(err) + require.NotNil(clientCreator) + require.NotNil(abciClient) + mpool := mempoolv1.NewTxMempool(logger, cfg.DefaultMempoolConfig(), proxy.NewAppConnMempool(abciClient), 0) + + name, city := "test1", "" + theMsg1 := &testpb.TestMessage{ + Name: &name, + City: &city, + } + + name, city = "test2", "" + theMsg2 := &testpb.TestMessage{ + Name: &name, + City: &city, + } + + // Create a mock ConsensusMessagesStream + mockStream := &MockConsensusMessagesStream{} + mockStream.On("GetConsensusMessages").Return([]proto.Message{ + theMsg1, + theMsg2, + }, nil) + + executor, err := block.NewExecutor([]byte("test address"), "test", mpool, proxy.NewAppConns(clientCreator), nil, logger) + assert.NoError(err) + + maxBytes := uint64(1000) + proposerKey := ed25519.GenPrivKey() + tmPubKey, err := cryptocodec.ToTmPubKeyInterface(proposerKey.PubKey()) + require.NoError(err) + + state := &types.State{} + state.Sequencers.SetProposer(types.NewSequencerFromValidator(*tmtypes.NewValidator(tmPubKey, 1))) + state.ConsensusParams.Block.MaxBytes = int64(maxBytes) + state.ConsensusParams.Block.MaxGas = 100000 + + block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, [32]byte(state.Sequencers.ProposerHash()[:]), state, maxBytes) + + require.NotNil(block) + assert.Empty(block.Data.Txs) + assert.Equal(uint64(1), block.Header.Height) + assert.Len(block.Data.ConsensusMessages, 2) + + // Verify the content of ConsensusMessages + theType, err := proto.Marshal(theMsg1) + require.NoError(err) + + anyMsg1 := anypb.Any{ + TypeUrl: proto.MessageName(theMsg1), + Value: theType, + } + require.NoError(err) + + theType, err = proto.Marshal(theMsg2) + require.NoError(err) + + anyMsg2 := anypb.Any{ + TypeUrl: proto.MessageName(theMsg2), + Value: theType, + } + require.NoError(err) + + assert.Equal(anyMsg1, block.Data.ConsensusMessages[0]) + assert.Equal(anyMsg2, block.Data.ConsensusMessages[1]) + + mockStream.AssertExpectations(t) +} + +// MockConsensusMessagesStream is a mock implementation of ConsensusMessagesStream +type MockConsensusMessagesStream struct { + mock.Mock +} + +func (m *MockConsensusMessagesStream) GetConsensusMessages() ([]proto.Message, error) { + args := m.Called() + return args.Get(0).([]proto.Message), args.Error(1) +} + func TestApplyBlock(t *testing.T) { assert := assert.New(t) require := require.New(t) diff --git a/buf.gen.yaml b/buf.gen.yaml index 8aa0891d8..251111a36 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -7,4 +7,5 @@ plugins: # The relative output directory. out: proto/pb # Any options to provide to the plugin. - opt: plugins=grpc,paths=source_relative + opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,paths=source_relative + diff --git a/go.mod b/go.mod index 06fdd3af6..a1910b717 100644 --- a/go.mod +++ b/go.mod @@ -155,7 +155,7 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/golang/glog v1.2.0 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da github.com/golang/protobuf v1.5.4 github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/btree v1.1.2 // indirect @@ -306,5 +306,3 @@ replace ( ) replace github.com/osmosis-labs/osmosis/v15 => github.com/dymensionxyz/osmosis/v15 v15.2.0-dymension-v1.1.2 - - diff --git a/go.sum b/go.sum index b4f585883..69952cc0c 100644 --- a/go.sum +++ b/go.sum @@ -305,8 +305,6 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= -github.com/dymensionxyz/cometbft v0.34.29-0.20240906143736-1e3959c2826e h1:A5FIvuFPvdxShuf9mSHfDUEL7I/oKVcSr1AtSlmgskA= -github.com/dymensionxyz/cometbft v0.34.29-0.20240906143736-1e3959c2826e/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw= github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13 h1:u5yeve5jZR6TdRjjR+vYT/8PWKbhwCZxUmAu+/Tnxyg= github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13/go.mod h1:jabDQYXrccscSE0fXkh7eQFYPWJCRiuWKonFGObVq6s= github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56 h1:cmpJYdRviuUfmlJdHrcAND8Jd6JIY4rp63bWAQzPr54= diff --git a/types/pb/dymint/dymint.pb.go b/types/pb/dymint/dymint.pb.go index c47e04a5a..3fbb84df3 100644 --- a/types/pb/dymint/dymint.pb.go +++ b/types/pb/dymint/dymint.pb.go @@ -6,9 +6,9 @@ package dymint import ( fmt "fmt" proto "github.com/gogo/protobuf/proto" + types2 "github.com/gogo/protobuf/types" types1 "github.com/tendermint/tendermint/abci/types" types "github.com/tendermint/tendermint/proto/tendermint/types" - anypb "google.golang.org/protobuf/types/known/anypb" io "io" math "math" math_bits "math/bits" @@ -323,7 +323,7 @@ type Data struct { Txs [][]byte `protobuf:"bytes,1,rep,name=txs,proto3" json:"txs,omitempty"` IntermediateStateRoots [][]byte `protobuf:"bytes,2,rep,name=intermediate_state_roots,json=intermediateStateRoots,proto3" json:"intermediate_state_roots,omitempty"` Evidence []*types1.Evidence `protobuf:"bytes,3,rep,name=evidence,proto3" json:"evidence,omitempty"` - ConsensusMessages []*anypb.Any `protobuf:"bytes,4,rep,name=consensus_messages,json=consensusMessages,proto3" json:"consensus_messages,omitempty"` + ConsensusMessages []*types2.Any `protobuf:"bytes,4,rep,name=consensus_messages,json=consensusMessages,proto3" json:"consensus_messages,omitempty"` } func (m *Data) Reset() { *m = Data{} } @@ -380,7 +380,7 @@ func (m *Data) GetEvidence() []*types1.Evidence { return nil } -func (m *Data) GetConsensusMessages() []*anypb.Any { +func (m *Data) GetConsensusMessages() []*types2.Any { if m != nil { return m.ConsensusMessages } @@ -2329,7 +2329,7 @@ func (m *Data) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ConsensusMessages = append(m.ConsensusMessages, &anypb.Any{}) + m.ConsensusMessages = append(m.ConsensusMessages, &types2.Any{}) if err := m.ConsensusMessages[len(m.ConsensusMessages)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } From d08e81bcbfd5f9dd735bb1ff450f35ce8307a7c5 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Tue, 24 Sep 2024 08:20:16 +0200 Subject: [PATCH 06/19] add consensus messages stream --- block/consensus.go | 4 ++- block/executor.go | 57 ++++++++++++++++++++++++++---------------- block/executor_test.go | 18 ++++++------- block/manager.go | 4 +-- p2p/validator_test.go | 2 +- types/block.go | 4 +-- 6 files changed, 53 insertions(+), 36 deletions(-) diff --git a/block/consensus.go b/block/consensus.go index 23843e84a..1078fa1ee 100644 --- a/block/consensus.go +++ b/block/consensus.go @@ -1,6 +1,8 @@ package block -import "google.golang.org/protobuf/proto" +import ( + "github.com/gogo/protobuf/proto" +) type ConsensusMessagesStream interface { GetConsensusMessages() ([]proto.Message, error) diff --git a/block/executor.go b/block/executor.go index 22358619d..590b7133e 100644 --- a/block/executor.go +++ b/block/executor.go @@ -2,8 +2,8 @@ package block import ( "errors" - proto "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/anypb" + proto2 "github.com/gogo/protobuf/proto" + proto "github.com/gogo/protobuf/types" "time" abci "github.com/tendermint/tendermint/abci/types" @@ -37,15 +37,24 @@ type Executor struct { // NewExecutor creates new instance of BlockExecutor. // localAddress will be used in sequencer mode only. -func NewExecutor(localAddress []byte, chainID string, mempool mempool.Mempool, proxyApp proxy.AppConns, eventBus *tmtypes.EventBus, logger types.Logger) (*Executor, error) { +func NewExecutor( + localAddress []byte, + chainID string, + mempool mempool.Mempool, + proxyApp proxy.AppConns, + eventBus *tmtypes.EventBus, + consensusMessagesStream ConsensusMessagesStream, + logger types.Logger, +) (*Executor, error) { be := Executor{ - localAddress: localAddress, - chainID: chainID, - proxyAppConsensusConn: proxyApp.Consensus(), - proxyAppQueryConn: proxyApp.Query(), - mempool: mempool, - eventBus: eventBus, - logger: logger, + localAddress: localAddress, + chainID: chainID, + proxyAppConsensusConn: proxyApp.Consensus(), + proxyAppQueryConn: proxyApp.Query(), + mempool: mempool, + eventBus: eventBus, + consensusMessagesStream: consensusMessagesStream, + logger: logger, } return &be, nil } @@ -105,12 +114,15 @@ func (e *Executor) CreateBlock( maxBlockDataSizeBytes = min(maxBlockDataSizeBytes, uint64(max(minBlockMaxBytes, state.ConsensusParams.Block.MaxBytes))) mempoolTxs := e.mempool.ReapMaxBytesMaxGas(int64(maxBlockDataSizeBytes), state.ConsensusParams.Block.MaxGas) - consensusMessages, err := e.consensusMessagesStream.GetConsensusMessages() - if err != nil { - e.logger.Error("Failed to get consensus messages", "error", err) - } + var consensusAnyMessages []*proto.Any + if e.consensusMessagesStream != nil { + consensusMessages, err := e.consensusMessagesStream.GetConsensusMessages() + if err != nil { + e.logger.Error("Failed to get consensus messages", "error", err) + } - consensusAnyMessages := fromProtoMsgSliceToAnySlice(consensusMessages) + consensusAnyMessages = fromProtoMsgSliceToAnySlice(consensusMessages) + } block := &types.Block{ Header: types.Header{ @@ -303,17 +315,20 @@ func fromDymintTxs(optiTxs types.Txs) tmtypes.Txs { return txs } -func fromProtoMsgToAny(msg proto.Message) *anypb.Any { - anyType, err := anypb.New(msg) +func fromProtoMsgToAny(msg proto2.Message) *proto.Any { + theType, err := proto2.Marshal(msg) if err != nil { - panic(err) + return nil } - return anyType + return &proto.Any{ + TypeUrl: proto2.MessageName(msg), + Value: theType, + } } -func fromProtoMsgSliceToAnySlice(msgs []proto.Message) []*anypb.Any { - result := make([]*anypb.Any, len(msgs)) +func fromProtoMsgSliceToAnySlice(msgs []proto2.Message) []*proto.Any { + result := make([]*proto.Any, len(msgs)) for i, msg := range msgs { result[i] = fromProtoMsgToAny(msg) } diff --git a/block/executor_test.go b/block/executor_test.go index 98b35b2ca..1938a8fa5 100644 --- a/block/executor_test.go +++ b/block/executor_test.go @@ -3,9 +3,9 @@ package block_test import ( "context" "crypto/rand" + "github.com/gogo/protobuf/proto" + prototypes "github.com/gogo/protobuf/types" "github.com/golang/groupcache/testpb" - "github.com/golang/protobuf/proto" - "google.golang.org/protobuf/types/known/anypb" "testing" "time" @@ -50,7 +50,7 @@ func TestCreateBlock(t *testing.T) { require.NotNil(abciClient) mpool := mempoolv1.NewTxMempool(logger, cfg.DefaultMempoolConfig(), proxy.NewAppConnMempool(abciClient), 0) - executor, err := block.NewExecutor([]byte("test address"), "test", mpool, proxy.NewAppConns(clientCreator), nil, logger) + executor, err := block.NewExecutor([]byte("test address"), "test", mpool, proxy.NewAppConns(clientCreator), nil, nil, logger) assert.NoError(err) maxBytes := uint64(100) @@ -121,7 +121,7 @@ func TestCreateBlockWithConsensusMessages(t *testing.T) { theMsg2, }, nil) - executor, err := block.NewExecutor([]byte("test address"), "test", mpool, proxy.NewAppConns(clientCreator), nil, logger) + executor, err := block.NewExecutor([]byte("test address"), "test", mpool, proxy.NewAppConns(clientCreator), nil, mockStream, logger) assert.NoError(err) maxBytes := uint64(1000) @@ -145,7 +145,7 @@ func TestCreateBlockWithConsensusMessages(t *testing.T) { theType, err := proto.Marshal(theMsg1) require.NoError(err) - anyMsg1 := anypb.Any{ + anyMsg1 := &prototypes.Any{ TypeUrl: proto.MessageName(theMsg1), Value: theType, } @@ -154,14 +154,14 @@ func TestCreateBlockWithConsensusMessages(t *testing.T) { theType, err = proto.Marshal(theMsg2) require.NoError(err) - anyMsg2 := anypb.Any{ + anyMsg2 := &prototypes.Any{ TypeUrl: proto.MessageName(theMsg2), Value: theType, } require.NoError(err) - assert.Equal(anyMsg1, block.Data.ConsensusMessages[0]) - assert.Equal(anyMsg2, block.Data.ConsensusMessages[1]) + assert.True(proto.Equal(anyMsg1, block.Data.ConsensusMessages[0])) + assert.True(proto.Equal(anyMsg2, block.Data.ConsensusMessages[1])) mockStream.AssertExpectations(t) } @@ -228,7 +228,7 @@ func TestApplyBlock(t *testing.T) { appConns := &tmmocksproxy.MockAppConns{} appConns.On("Consensus").Return(abciClient) appConns.On("Query").Return(abciClient) - executor, err := block.NewExecutor([]byte("test address"), chainID, mpool, appConns, eventBus, logger) + executor, err := block.NewExecutor([]byte("test address"), chainID, mpool, appConns, eventBus, nil, logger) assert.NoError(err) // Subscribe to tx events diff --git a/block/manager.go b/block/manager.go index cc17905df..746db023c 100644 --- a/block/manager.go +++ b/block/manager.go @@ -98,7 +98,7 @@ func NewManager( if err != nil { return nil, err } - exec, err := NewExecutor(localAddress, genesis.ChainID, mempool, proxyApp, eventBus, logger) + exec, err := NewExecutor(localAddress, genesis.ChainID, mempool, proxyApp, eventBus, nil, logger) // TODO add ConsensusMessagesStream if err != nil { return nil, fmt.Errorf("create block executor: %w", err) } @@ -177,7 +177,7 @@ func (m *Manager) Start(ctx context.Context) error { } /* ----------------------------- sequencer mode ----------------------------- */ - // Subscribe to batch events, to update last submitted height in case batch confirmation was lost. This could happen if the sequencer crash/restarted just after submitting a batch to the settelement and by the time we query the last batch, this batch wasn't accepted yet. + // Subscribe to batch events, to update last submitted height in case batch confirmation was lost. This could happen if the sequencer crash/restarted just after submitting a batch to the settelement and by the time we query the last batch, this batch wasn't accepted yet. go uevent.MustSubscribe(ctx, m.Pubsub, "updateSubmittedHeightLoop", settlement.EventQueryNewSettlementBatchAccepted, m.UpdateLastSubmittedHeight, m.logger) // Sequencer must wait till DA is synced to start submitting blobs diff --git a/p2p/validator_test.go b/p2p/validator_test.go index 9c684eb74..3533926b7 100644 --- a/p2p/validator_test.go +++ b/p2p/validator_test.go @@ -125,7 +125,7 @@ func TestValidator_BlockValidator(t *testing.T) { require.NotNil(t, clientCreator) require.NotNil(t, abciClient) mpool := mempoolv1.NewTxMempool(logger, cfg.DefaultMempoolConfig(), proxy.NewAppConnMempool(abciClient), 0) - executor, err := block.NewExecutor([]byte("test address"), "test", mpool, proxy.NewAppConns(clientCreator), nil, logger) + executor, err := block.NewExecutor([]byte("test address"), "test", mpool, proxy.NewAppConns(clientCreator), nil, nil, logger) assert.NoError(t, err) // Create state diff --git a/types/block.go b/types/block.go index d6d6b8935..060a7445f 100644 --- a/types/block.go +++ b/types/block.go @@ -2,9 +2,9 @@ package types import ( "encoding" - "google.golang.org/protobuf/types/known/anypb" "time" + proto "github.com/gogo/protobuf/types" tmtypes "github.com/tendermint/tendermint/types" ) @@ -84,7 +84,7 @@ type Data struct { Txs Txs IntermediateStateRoots IntermediateStateRoots Evidence EvidenceData - ConsensusMessages []*anypb.Any + ConsensusMessages []*proto.Any } // EvidenceData defines how evidence is stored in block. From 45164f1056bf51d7d21a4a6f45d87a8491e9e33e Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Thu, 26 Sep 2024 19:00:41 +0200 Subject: [PATCH 07/19] add some fixes --- block/executor.go | 4 +++- block/manager.go | 10 +++++++++- proto/types/tendermint/abci/types.proto | 10 ++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/block/executor.go b/block/executor.go index 590b7133e..a54844494 100644 --- a/block/executor.go +++ b/block/executor.go @@ -121,7 +121,9 @@ func (e *Executor) CreateBlock( e.logger.Error("Failed to get consensus messages", "error", err) } - consensusAnyMessages = fromProtoMsgSliceToAnySlice(consensusMessages) + if consensusMessages != nil { + consensusAnyMessages = fromProtoMsgSliceToAnySlice(consensusMessages) + } } block := &types.Block{ diff --git a/block/manager.go b/block/manager.go index 746db023c..7a6e4b19b 100644 --- a/block/manager.go +++ b/block/manager.go @@ -98,7 +98,15 @@ func NewManager( if err != nil { return nil, err } - exec, err := NewExecutor(localAddress, genesis.ChainID, mempool, proxyApp, eventBus, nil, logger) // TODO add ConsensusMessagesStream + exec, err := NewExecutor( + localAddress, + genesis.ChainID, + mempool, + proxyApp, + eventBus, + nil, // TODO add ConsensusMessagesStream + logger, + ) if err != nil { return nil, fmt.Errorf("create block executor: %w", err) } diff --git a/proto/types/tendermint/abci/types.proto b/proto/types/tendermint/abci/types.proto index 239cf4726..48056e387 100755 --- a/proto/types/tendermint/abci/types.proto +++ b/proto/types/tendermint/abci/types.proto @@ -204,6 +204,16 @@ message ResponseQuery { message ResponseBeginBlock { repeated Event events = 1 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; + + // Defines responses for consensus messages in order. + repeated ConsensusMessageResponse consensus_messages_responses = 2; +} + +message ConsensusMessageResponse { + oneof response { + string error = 1; // Error message if execution fails. + google.protobuf.Any ok = 2; // Success response. + } } message ResponseCheckTx { From adb695cead25550353b383ed4769379d9700a1f7 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 4 Oct 2024 08:39:43 +0200 Subject: [PATCH 08/19] goimports --- block/executor.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/executor.go b/block/executor.go index a54844494..570fc8470 100644 --- a/block/executor.go +++ b/block/executor.go @@ -2,9 +2,10 @@ package block import ( "errors" + "time" + proto2 "github.com/gogo/protobuf/proto" proto "github.com/gogo/protobuf/types" - "time" abci "github.com/tendermint/tendermint/abci/types" tmcrypto "github.com/tendermint/tendermint/crypto/encoding" From f24ea2f167b411c53a180457c3d82a1b43193085 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 4 Oct 2024 08:43:59 +0200 Subject: [PATCH 09/19] remove nil check --- block/executor.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/block/executor.go b/block/executor.go index 570fc8470..b5484c040 100644 --- a/block/executor.go +++ b/block/executor.go @@ -122,9 +122,7 @@ func (e *Executor) CreateBlock( e.logger.Error("Failed to get consensus messages", "error", err) } - if consensusMessages != nil { - consensusAnyMessages = fromProtoMsgSliceToAnySlice(consensusMessages) - } + consensusAnyMessages = fromProtoMsgSliceToAnySlice(consensusMessages) } block := &types.Block{ From 0fa4c8d38e4a8d8e3fe9771abd02efb1fd1dc6ac Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 4 Oct 2024 08:44:38 +0200 Subject: [PATCH 10/19] goimports --- block/executor_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/executor_test.go b/block/executor_test.go index 1938a8fa5..e7888576e 100644 --- a/block/executor_test.go +++ b/block/executor_test.go @@ -3,11 +3,12 @@ package block_test import ( "context" "crypto/rand" + "testing" + "time" + "github.com/gogo/protobuf/proto" prototypes "github.com/gogo/protobuf/types" "github.com/golang/groupcache/testpb" - "testing" - "time" "github.com/dymensionxyz/dymint/block" From 4b061ecaf7d2ef806fe138008ba94635b197026f Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 4 Oct 2024 08:45:46 +0200 Subject: [PATCH 11/19] remove line from proto --- proto/types/tendermint/abci/types.proto | 1 - 1 file changed, 1 deletion(-) diff --git a/proto/types/tendermint/abci/types.proto b/proto/types/tendermint/abci/types.proto index 48056e387..9b546969f 100755 --- a/proto/types/tendermint/abci/types.proto +++ b/proto/types/tendermint/abci/types.proto @@ -81,7 +81,6 @@ message RequestBeginBlock { LastCommitInfo last_commit_info = 3 [(gogoproto.nullable) = false]; repeated Evidence byzantine_validators = 4 [(gogoproto.nullable) = false]; - // New addition: defines any wrapped consensus messages. google.protobuf.Any consensus_messages = 5; } From 038a2a32d3b648055a88540f0fdb1badeb0d59d6 Mon Sep 17 00:00:00 2001 From: Faulty Tolly <@faulttolerance.net> Date: Fri, 4 Oct 2024 08:48:29 +0200 Subject: [PATCH 12/19] remove proto comment --- proto/types/tendermint/types/types.proto | 1 - 1 file changed, 1 deletion(-) diff --git a/proto/types/tendermint/types/types.proto b/proto/types/tendermint/types/types.proto index e8881c815..5bf0e10fa 100755 --- a/proto/types/tendermint/types/types.proto +++ b/proto/types/tendermint/types/types.proto @@ -89,7 +89,6 @@ message Data { // This means that block.AppHash does not include these txs. repeated bytes txs = 1; - // NEW: Consensus messages are included as raw Protobuf Any types. repeated google.protobuf.Any consensus_messages = 2; } From 102fa8e0d8ad4b1591f2a7ff3570b17ffbe63a40 Mon Sep 17 00:00:00 2001 From: keruch Date: Fri, 4 Oct 2024 09:27:42 +0200 Subject: [PATCH 13/19] merge commit --- go.mod | 1 - types/pb/dymint/dymint.pb.go | 171 ++++++++++++++++++++++++----------- types/pb/dymint/state.pb.go | 2 +- 3 files changed, 119 insertions(+), 55 deletions(-) diff --git a/go.mod b/go.mod index 3be5713d9..903f622d9 100644 --- a/go.mod +++ b/go.mod @@ -156,7 +156,6 @@ require ( github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect - github.com/golang/glog v1.2.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da github.com/golang/protobuf v1.5.4 github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect diff --git a/types/pb/dymint/dymint.pb.go b/types/pb/dymint/dymint.pb.go index 45b8ad00c..eb1bb5942 100644 --- a/types/pb/dymint/dymint.pb.go +++ b/types/pb/dymint/dymint.pb.go @@ -6,6 +6,7 @@ package dymint import ( fmt "fmt" proto "github.com/gogo/protobuf/proto" + types2 "github.com/gogo/protobuf/types" types1 "github.com/tendermint/tendermint/abci/types" types "github.com/tendermint/tendermint/proto/tendermint/types" io "io" @@ -322,6 +323,7 @@ type Data struct { Txs [][]byte `protobuf:"bytes,1,rep,name=txs,proto3" json:"txs,omitempty"` IntermediateStateRoots [][]byte `protobuf:"bytes,2,rep,name=intermediate_state_roots,json=intermediateStateRoots,proto3" json:"intermediate_state_roots,omitempty"` Evidence []*types1.Evidence `protobuf:"bytes,3,rep,name=evidence,proto3" json:"evidence,omitempty"` + ConsensusMessages []*types2.Any `protobuf:"bytes,4,rep,name=consensus_messages,json=consensusMessages,proto3" json:"consensus_messages,omitempty"` } func (m *Data) Reset() { *m = Data{} } @@ -378,6 +380,13 @@ func (m *Data) GetEvidence() []*types1.Evidence { return nil } +func (m *Data) GetConsensusMessages() []*types2.Any { + if m != nil { + return m.ConsensusMessages + } + return nil +} + type Block struct { Header *Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` Data *Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` @@ -669,59 +678,61 @@ func init() { func init() { proto.RegisterFile("types/dymint/dymint.proto", fileDescriptor_fe69c538ded4b87f) } var fileDescriptor_fe69c538ded4b87f = []byte{ - // 819 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x95, 0xbf, 0x6f, 0xdb, 0x46, - 0x14, 0xc7, 0x4d, 0x4b, 0xd6, 0x8f, 0x47, 0x59, 0xb1, 0xae, 0x45, 0x40, 0x25, 0xa8, 0xa2, 0x10, - 0x70, 0xa0, 0x14, 0x08, 0x8d, 0xa8, 0x28, 0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- 0xdf, 0x77, 0x93, 0x93, 0x9f, 0x83, 0x4d, 0xa2, 0xe3, 0xdd, 0x3a, 0x08, 0xb3, 0xd4, 0xfc, 0x7a, - 0xa0, 0x34, 0x57, 0xeb, 0xcd, 0xe1, 0xd7, 0xea, 0x17, 0xc5, 0xde, 0xf1, 0xf9, 0xba, 0x5c, 0xaf, - 0x3b, 0x74, 0xc9, 0x7f, 0xf5, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x34, 0x75, 0x40, 0x78, - 0x06, 0x00, 0x00, + // 864 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x95, 0xcf, 0x6f, 0xdb, 0x36, + 0x14, 0xc7, 0xa3, 0xc4, 0xf1, 0x8f, 0x27, 0x27, 0x8d, 0xb9, 0xa2, 0x90, 0x5b, 0xcc, 0x4d, 0x05, + 0xa4, 0x48, 0x07, 0x54, 0x46, 0x3d, 0x0c, 0xd8, 0x2e, 0x03, 0x9a, 0xae, 0x40, 0x8a, 0x61, 0x17, + 0x19, 0xe8, 0x61, 0x17, 0x83, 0x96, 0xde, 0x2c, 0xa1, 0x16, 0xa5, 0x89, 0x74, 0x10, 0xef, 0xd8, + 0xbf, 0x60, 0xe7, 0xdd, 0xf6, 0xdf, 0xec, 0x34, 0xf4, 0xb8, 0xe3, 0x90, 0xfc, 0x23, 0x03, 0x1f, + 0x49, 0x59, 0xed, 0xd2, 0x4b, 0x22, 0x7e, 0xbf, 0x1f, 0x91, 0xcf, 0xef, 0x07, 0x05, 0x63, 0xb5, + 0xad, 0x50, 0x4e, 0xd3, 0x6d, 0x91, 0x0b, 0x65, 0xff, 0x45, 0x55, 0x5d, 0xaa, 0x92, 0x75, 0xcd, + 0xea, 0xe1, 0x13, 0x83, 0x28, 0x14, 0x29, 0xd6, 0x84, 0xf1, 0x65, 0x92, 0x4f, 0x49, 0x35, 0xe8, + 0xc3, 0xf0, 0x7f, 0x88, 0x15, 0x5a, 0xcc, 0xd3, 0xcf, 0x30, 0x57, 0x7c, 0x9d, 0xa7, 0x5c, 0x95, + 0xb5, 0xe5, 0xc6, 0xab, 0xb2, 0x5c, 0xad, 0x71, 0x4a, 0xab, 0xe5, 0xe6, 0x97, 0x29, 0x17, 0x5b, + 0x63, 0x85, 0x2f, 0xa0, 0xf7, 0x16, 0x6b, 0x99, 0x97, 0x82, 0xdd, 0x87, 0xc3, 0xe5, 0xba, 0x4c, + 0xde, 0x05, 0xde, 0xa9, 0x77, 0xde, 0x89, 0xcd, 0x82, 0x9d, 0xc0, 0x01, 0xaf, 0xaa, 0x60, 0x9f, + 0x34, 0xfd, 0x18, 0xbe, 0xef, 0x40, 0xf7, 0x12, 0x79, 0x8a, 0x35, 0x7b, 0x06, 0xbd, 0x2b, 0xf3, + 0x36, 0xbd, 0xe4, 0xcf, 0xee, 0x45, 0xf6, 0xf7, 0xda, 0x4d, 0x63, 0xe7, 0xb3, 0x33, 0x18, 0x0a, + 0x5e, 0xa0, 0xac, 0x78, 0x82, 0x8b, 0x3c, 0xa5, 0x0d, 0x87, 0x17, 0xfb, 0x81, 0x17, 0xfb, 0x8d, + 0xfe, 0x26, 0x65, 0x0f, 0xa0, 0x9b, 0x61, 0xbe, 0xca, 0x54, 0x70, 0x40, 0x27, 0xda, 0x15, 0x63, + 0xd0, 0x51, 0x79, 0x81, 0x41, 0x87, 0x54, 0x7a, 0x66, 0xe7, 0x70, 0xb2, 0xe6, 0x52, 0x2d, 0x32, + 0x0a, 0x66, 0x91, 0x71, 0x99, 0x05, 0x87, 0x7a, 0xdb, 0xf8, 0x58, 0xeb, 0x26, 0xc6, 0x4b, 0x2e, + 0xb3, 0x86, 0x4c, 0xca, 0xa2, 0xc8, 0x95, 0x21, 0xbb, 0x3b, 0xf2, 0x15, 0xc9, 0x44, 0x3e, 0x82, + 0x41, 0xca, 0x15, 0x37, 0x48, 0x8f, 0x90, 0xbe, 0x16, 0xc8,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x06, 0x00, 0x00, } func (m *Version) Marshal() (dAtA []byte, err error) { @@ -955,6 +966,20 @@ func (m *Data) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ConsensusMessages) > 0 { + for iNdEx := len(m.ConsensusMessages) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ConsensusMessages[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDymint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } if len(m.Evidence) > 0 { for iNdEx := len(m.Evidence) - 1; iNdEx >= 0; iNdEx-- { { @@ -1372,6 +1397,12 @@ func (m *Data) Size() (n int) { n += 1 + l + sovDymint(uint64(l)) } } + if len(m.ConsensusMessages) > 0 { + for _, e := range m.ConsensusMessages { + l = e.Size() + n += 1 + l + sovDymint(uint64(l)) + } + } return n } @@ -2362,6 +2393,40 @@ func (m *Data) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusMessages", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDymint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDymint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDymint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsensusMessages = append(m.ConsensusMessages, &types2.Any{}) + if err := m.ConsensusMessages[len(m.ConsensusMessages)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipDymint(dAtA[iNdEx:]) diff --git a/types/pb/dymint/state.pb.go b/types/pb/dymint/state.pb.go index 4b318b849..1cb1dfca9 100644 --- a/types/pb/dymint/state.pb.go +++ b/types/pb/dymint/state.pb.go @@ -195,7 +195,7 @@ func (m *State) GetRollappParams() RollappParams { return RollappParams{} } -// rollapp params defined in genesis and updated via gov proposal +//rollapp params defined in genesis and updated via gov proposal type RollappParams struct { //data availability type (e.g. celestia) used in the rollapp Da string `protobuf:"bytes,1,opt,name=da,proto3" json:"da,omitempty"` From dc2cafe1b4db241887321f69972820ffd6504d40 Mon Sep 17 00:00:00 2001 From: keruch Date: Fri, 4 Oct 2024 19:42:43 +0200 Subject: [PATCH 14/19] feat(executor): added MsgUpsertSequencer consensus message --- block/executor.go | 29 +- proto/protoc.sh | 1 + proto/types/rollapp/sequencers/tx.proto | 45 + settlement/dymension/events.go | 4 +- types/pb/rollapp/sequencers/tx.pb.go | 1314 +++++++++++++++++++++++ 5 files changed, 1390 insertions(+), 3 deletions(-) create mode 100644 proto/types/rollapp/sequencers/tx.proto create mode 100644 types/pb/rollapp/sequencers/tx.pb.go diff --git a/block/executor.go b/block/executor.go index b5484c040..dcdf60fa6 100644 --- a/block/executor.go +++ b/block/executor.go @@ -4,6 +4,8 @@ import ( "errors" "time" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/bech32" proto2 "github.com/gogo/protobuf/proto" proto "github.com/gogo/protobuf/types" @@ -17,6 +19,7 @@ import ( "github.com/dymensionxyz/dymint/mempool" "github.com/dymensionxyz/dymint/types" + "github.com/dymensionxyz/dymint/types/pb/rollapp/sequencers" ) // 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. @@ -122,7 +125,29 @@ func (e *Executor) CreateBlock( e.logger.Error("Failed to get consensus messages", "error", err) } - consensusAnyMessages = fromProtoMsgSliceToAnySlice(consensusMessages) + consensusAnyMessages = fromProtoMsgSliceToAnySlice(consensusMessages...) + } + // Set the initial sequencer reward address on the very first block after the genesis + const rotationBlock = false + if state.LastBlockHeight.Load() == 1 { + val, _ := state.Sequencers.Proposer.TMValidator() + tmPubKey, err := tmcrypto.PubKeyToProto(val.PubKey) + if err != nil { + return nil + } + anyTmPubKey, err := codectypes.NewAnyWithValue(&tmPubKey) + if err != nil { + return nil + } + _, addrBytes, err := bech32.DecodeAndConvert(state.Sequencers.Proposer.SettlementAddress) + if err != nil { + return nil + } + consensusAnyMessages = append(consensusAnyMessages, fromProtoMsgSliceToAnySlice(&sequencers.MsgUpsertSequencer{ + Operator: val.Address.String(), // ?? + ConsPubKey: anyTmPubKey, + RewardAddrBytes: addrBytes, + })...) } block := &types.Block{ @@ -328,7 +353,7 @@ func fromProtoMsgToAny(msg proto2.Message) *proto.Any { } } -func fromProtoMsgSliceToAnySlice(msgs []proto2.Message) []*proto.Any { +func fromProtoMsgSliceToAnySlice(msgs ...proto2.Message) []*proto.Any { result := make([]*proto.Any, len(msgs)) for i, msg := range msgs { result[i] = fromProtoMsgToAny(msg) diff --git a/proto/protoc.sh b/proto/protoc.sh index 4b23b9743..2937453b7 100755 --- a/proto/protoc.sh +++ b/proto/protoc.sh @@ -7,6 +7,7 @@ buf generate --path="./proto/types/dalc" --template="buf.gen.yaml" --config="buf buf generate --path="./proto/types/dymint" --template="buf.gen.yaml" --config="buf.yaml" buf generate --path="./proto/types/interchain_da" --template="buf.gen.yaml" --config="buf.yaml" buf generate --path="./proto/types/dymensionxyz" --template="buf.gen.yaml" --config="buf.yaml" +buf generate --path="./proto/types/rollapp" --template="buf.gen.yaml" --config="buf.yaml" # Generate the `test` proto files buf generate --path="./proto/test" --template="buf.gen.yaml" --config="buf.yaml" diff --git a/proto/types/rollapp/sequencers/tx.proto b/proto/types/rollapp/sequencers/tx.proto new file mode 100644 index 000000000..2db0f029d --- /dev/null +++ b/proto/types/rollapp/sequencers/tx.proto @@ -0,0 +1,45 @@ +// This file is a modified copy of the dymension-rdk/sequencers module proto contract. Source: +// https://github.com/dymensionxyz/dymension-rdk/blob/28628bcb329ac7b4cdd6d19f1c43f26d03410f84/proto/sequencers/tx.proto. +// It contains only message definitions but without the Msg service. +syntax = "proto3"; +package rollapp.sequencers.types; + +import "gogoproto/gogo.proto"; +import "types/cosmos/msg/v1/msg.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/dymensionxyz/dymint/types/pb/rollapp/sequencers"; + +message MsgCreateSequencer { + option (cosmos.msg.v1.signer) = "operator"; + // Operator is the bech32-encoded address of the actor sending the update - must be val addr + string operator = 1; + // PubKey is a tendermint consensus pub key + google.protobuf.Any pub_key = 2; + // Signature is operator signed with the private key of pub_key + bytes signature = 3; +} + +message MsgCreateSequencerResponse {} + +message MsgUpsertSequencer { + option (cosmos.msg.v1.signer) = "operator"; + // Operator is the bech32-encoded address of the actor sending the update - must be val addr + string operator = 1; + // ConsPubKey is a tendermint consensus pub key + google.protobuf.Any cons_pub_key = 2; + // RewardAddrBytes is the bytes representation of the sequencer's reward account + bytes reward_addr_bytes = 3; +} + +message MsgUpsertSequencerResponse {} + +message MsgUpdateSequencer { + option (cosmos.msg.v1.signer) = "operator"; + // Operator is the bech32-encoded address of the actor sending the update - must be val addr + string operator = 1; + // RewardAddr is a bech32 encoded sdk acc address + string reward_addr = 3; +} + +message MsgUpdateSequencerResponse {} diff --git a/settlement/dymension/events.go b/settlement/dymension/events.go index 18f53cdef..abe8ee2c3 100644 --- a/settlement/dymension/events.go +++ b/settlement/dymension/events.go @@ -158,5 +158,7 @@ func convertToRotationStartedEvent(rawEventData ctypes.ResultEvent) (*settlement rotationStartedEvent := &settlement.EventDataRotationStarted{ NextSeqAddr: nextProposer, } - return rotationStartedEvent, nil + return &settlement.EventDataRotationStarted{ + NextSeqAddr: nextProposer, + }, nil } diff --git a/types/pb/rollapp/sequencers/tx.pb.go b/types/pb/rollapp/sequencers/tx.pb.go new file mode 100644 index 000000000..60210f738 --- /dev/null +++ b/types/pb/rollapp/sequencers/tx.pb.go @@ -0,0 +1,1314 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: types/rollapp/sequencers/tx.proto + +package sequencers + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + types "github.com/gogo/protobuf/types" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgCreateSequencer struct { + // Operator is the bech32-encoded address of the actor sending the update - must be val addr + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // PubKey is a tendermint consensus pub key + PubKey *types.Any `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` + // Signature is operator signed with the private key of pub_key + Signature []byte `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"` +} + +func (m *MsgCreateSequencer) Reset() { *m = MsgCreateSequencer{} } +func (m *MsgCreateSequencer) String() string { return proto.CompactTextString(m) } +func (*MsgCreateSequencer) ProtoMessage() {} +func (*MsgCreateSequencer) Descriptor() ([]byte, []int) { + return fileDescriptor_30467481bc397351, []int{0} +} +func (m *MsgCreateSequencer) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateSequencer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateSequencer.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 *MsgCreateSequencer) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateSequencer.Merge(m, src) +} +func (m *MsgCreateSequencer) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateSequencer) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateSequencer.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateSequencer proto.InternalMessageInfo + +func (m *MsgCreateSequencer) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *MsgCreateSequencer) GetPubKey() *types.Any { + if m != nil { + return m.PubKey + } + return nil +} + +func (m *MsgCreateSequencer) GetSignature() []byte { + if m != nil { + return m.Signature + } + return nil +} + +type MsgCreateSequencerResponse struct { +} + +func (m *MsgCreateSequencerResponse) Reset() { *m = MsgCreateSequencerResponse{} } +func (m *MsgCreateSequencerResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateSequencerResponse) ProtoMessage() {} +func (*MsgCreateSequencerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_30467481bc397351, []int{1} +} +func (m *MsgCreateSequencerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateSequencerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateSequencerResponse.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 *MsgCreateSequencerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateSequencerResponse.Merge(m, src) +} +func (m *MsgCreateSequencerResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateSequencerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateSequencerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateSequencerResponse proto.InternalMessageInfo + +type MsgUpsertSequencer struct { + // Operator is the bech32-encoded address of the actor sending the update - must be val addr + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // ConsPubKey is a tendermint consensus pub key + ConsPubKey *types.Any `protobuf:"bytes,2,opt,name=cons_pub_key,json=consPubKey,proto3" json:"cons_pub_key,omitempty"` + // RewardAddrBytes is the bytes representation of the sequencer's reward account + RewardAddrBytes []byte `protobuf:"bytes,3,opt,name=reward_addr_bytes,json=rewardAddrBytes,proto3" json:"reward_addr_bytes,omitempty"` +} + +func (m *MsgUpsertSequencer) Reset() { *m = MsgUpsertSequencer{} } +func (m *MsgUpsertSequencer) String() string { return proto.CompactTextString(m) } +func (*MsgUpsertSequencer) ProtoMessage() {} +func (*MsgUpsertSequencer) Descriptor() ([]byte, []int) { + return fileDescriptor_30467481bc397351, []int{2} +} +func (m *MsgUpsertSequencer) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpsertSequencer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpsertSequencer.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 *MsgUpsertSequencer) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpsertSequencer.Merge(m, src) +} +func (m *MsgUpsertSequencer) XXX_Size() int { + return m.Size() +} +func (m *MsgUpsertSequencer) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpsertSequencer.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpsertSequencer proto.InternalMessageInfo + +func (m *MsgUpsertSequencer) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *MsgUpsertSequencer) GetConsPubKey() *types.Any { + if m != nil { + return m.ConsPubKey + } + return nil +} + +func (m *MsgUpsertSequencer) GetRewardAddrBytes() []byte { + if m != nil { + return m.RewardAddrBytes + } + return nil +} + +type MsgUpsertSequencerResponse struct { +} + +func (m *MsgUpsertSequencerResponse) Reset() { *m = MsgUpsertSequencerResponse{} } +func (m *MsgUpsertSequencerResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpsertSequencerResponse) ProtoMessage() {} +func (*MsgUpsertSequencerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_30467481bc397351, []int{3} +} +func (m *MsgUpsertSequencerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpsertSequencerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpsertSequencerResponse.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 *MsgUpsertSequencerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpsertSequencerResponse.Merge(m, src) +} +func (m *MsgUpsertSequencerResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpsertSequencerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpsertSequencerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpsertSequencerResponse proto.InternalMessageInfo + +type MsgUpdateSequencer struct { + // Operator is the bech32-encoded address of the actor sending the update - must be val addr + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // RewardAddr is a bech32 encoded sdk acc address + RewardAddr string `protobuf:"bytes,3,opt,name=reward_addr,json=rewardAddr,proto3" json:"reward_addr,omitempty"` +} + +func (m *MsgUpdateSequencer) Reset() { *m = MsgUpdateSequencer{} } +func (m *MsgUpdateSequencer) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateSequencer) ProtoMessage() {} +func (*MsgUpdateSequencer) Descriptor() ([]byte, []int) { + return fileDescriptor_30467481bc397351, []int{4} +} +func (m *MsgUpdateSequencer) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateSequencer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateSequencer.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 *MsgUpdateSequencer) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateSequencer.Merge(m, src) +} +func (m *MsgUpdateSequencer) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateSequencer) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateSequencer.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateSequencer proto.InternalMessageInfo + +func (m *MsgUpdateSequencer) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *MsgUpdateSequencer) GetRewardAddr() string { + if m != nil { + return m.RewardAddr + } + return "" +} + +type MsgUpdateSequencerResponse struct { +} + +func (m *MsgUpdateSequencerResponse) Reset() { *m = MsgUpdateSequencerResponse{} } +func (m *MsgUpdateSequencerResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateSequencerResponse) ProtoMessage() {} +func (*MsgUpdateSequencerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_30467481bc397351, []int{5} +} +func (m *MsgUpdateSequencerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateSequencerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateSequencerResponse.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 *MsgUpdateSequencerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateSequencerResponse.Merge(m, src) +} +func (m *MsgUpdateSequencerResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateSequencerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateSequencerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateSequencerResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreateSequencer)(nil), "rollapp.sequencers.types.MsgCreateSequencer") + proto.RegisterType((*MsgCreateSequencerResponse)(nil), "rollapp.sequencers.types.MsgCreateSequencerResponse") + proto.RegisterType((*MsgUpsertSequencer)(nil), "rollapp.sequencers.types.MsgUpsertSequencer") + proto.RegisterType((*MsgUpsertSequencerResponse)(nil), "rollapp.sequencers.types.MsgUpsertSequencerResponse") + proto.RegisterType((*MsgUpdateSequencer)(nil), "rollapp.sequencers.types.MsgUpdateSequencer") + proto.RegisterType((*MsgUpdateSequencerResponse)(nil), "rollapp.sequencers.types.MsgUpdateSequencerResponse") +} + +func init() { proto.RegisterFile("types/rollapp/sequencers/tx.proto", fileDescriptor_30467481bc397351) } + +var fileDescriptor_30467481bc397351 = []byte{ + // 395 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xb1, 0xce, 0xd3, 0x30, + 0x10, 0xc7, 0x6b, 0x90, 0x0a, 0x75, 0x8b, 0x10, 0x51, 0x87, 0x10, 0x95, 0x50, 0x3a, 0x55, 0x95, + 0x88, 0x05, 0x48, 0x0c, 0xdd, 0x5a, 0x46, 0x84, 0x84, 0x02, 0x2c, 0x2c, 0x21, 0x89, 0x0f, 0x13, + 0xd1, 0xd8, 0xc6, 0x76, 0xa0, 0x66, 0x64, 0x66, 0xe0, 0x1d, 0x78, 0x01, 0x1e, 0x83, 0xb1, 0x23, + 0x23, 0x6a, 0x07, 0x5e, 0x03, 0x25, 0x4e, 0x5b, 0xc4, 0xd7, 0x4f, 0xea, 0x94, 0xdc, 0xfd, 0xcf, + 0xff, 0xfb, 0xdd, 0xe9, 0xf0, 0x3d, 0x63, 0x25, 0x68, 0xa2, 0xc4, 0x6a, 0x95, 0x4a, 0x49, 0x34, + 0x7c, 0xa8, 0x80, 0xe7, 0xa0, 0x34, 0x31, 0xeb, 0x48, 0x2a, 0x61, 0x84, 0xe7, 0xb7, 0x62, 0x74, + 0x14, 0xa3, 0xe6, 0x55, 0x30, 0x64, 0x82, 0x89, 0xa6, 0x88, 0xd4, 0x7f, 0xae, 0x3e, 0xb8, 0xe3, + 0x2c, 0x73, 0xa1, 0x4b, 0xa1, 0x49, 0xa9, 0x19, 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0xc6, 0x47, 0x88, + 0xcb, 0xfa, 0xd3, 0x53, 0x3b, 0x5c, 0xbe, 0xfc, 0xb9, 0x0d, 0xd1, 0x66, 0x1b, 0xa2, 0xdf, 0xdb, + 0x10, 0x7d, 0xdb, 0x85, 0x9d, 0xcd, 0x2e, 0xec, 0xfc, 0xda, 0x85, 0x9d, 0xd7, 0x73, 0x56, 0x98, + 0x77, 0x55, 0x16, 0xe5, 0xa2, 0x24, 0xd4, 0x96, 0xc0, 0x75, 0x21, 0xf8, 0xda, 0x7e, 0xae, 0x83, + 0x82, 0x1b, 0xe2, 0x6e, 0x4c, 0x66, 0x27, 0x2e, 0x37, 0xeb, 0x36, 0x8b, 0x7c, 0xf4, 0x37, 0x00, + 0x00, 0xff, 0xff, 0xa1, 0x43, 0x69, 0xfb, 0xdc, 0x02, 0x00, 0x00, +} + +func (m *MsgCreateSequencer) 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 *MsgCreateSequencer) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateSequencer) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signature) > 0 { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0x1a + } + if m.PubKey != nil { + { + size, err := m.PubKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateSequencerResponse) 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 *MsgCreateSequencerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateSequencerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpsertSequencer) 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 *MsgUpsertSequencer) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpsertSequencer) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RewardAddrBytes) > 0 { + i -= len(m.RewardAddrBytes) + copy(dAtA[i:], m.RewardAddrBytes) + i = encodeVarintTx(dAtA, i, uint64(len(m.RewardAddrBytes))) + i-- + dAtA[i] = 0x1a + } + if m.ConsPubKey != nil { + { + size, err := m.ConsPubKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpsertSequencerResponse) 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 *MsgUpsertSequencerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpsertSequencerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateSequencer) 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 *MsgUpdateSequencer) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateSequencer) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RewardAddr) > 0 { + i -= len(m.RewardAddr) + copy(dAtA[i:], m.RewardAddr) + i = encodeVarintTx(dAtA, i, uint64(len(m.RewardAddr))) + i-- + dAtA[i] = 0x1a + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateSequencerResponse) 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 *MsgUpdateSequencerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateSequencerResponse) 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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreateSequencer) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PubKey != nil { + l = m.PubKey.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signature) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateSequencerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpsertSequencer) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.ConsPubKey != nil { + l = m.ConsPubKey.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.RewardAddrBytes) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpsertSequencerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateSequencer) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.RewardAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateSequencerResponse) 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 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreateSequencer) 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: MsgCreateSequencer: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateSequencer: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PubKey == nil { + m.PubKey = &types.Any{} + } + if err := m.PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) + if m.Signature == nil { + m.Signature = []byte{} + } + 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 *MsgCreateSequencerResponse) 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: MsgCreateSequencerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateSequencerResponse: 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 *MsgUpsertSequencer) 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: MsgUpsertSequencer: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpsertSequencer: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsPubKey", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ConsPubKey == nil { + m.ConsPubKey = &types.Any{} + } + if err := m.ConsPubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardAddrBytes", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardAddrBytes = append(m.RewardAddrBytes[:0], dAtA[iNdEx:postIndex]...) + if m.RewardAddrBytes == nil { + m.RewardAddrBytes = []byte{} + } + 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 *MsgUpsertSequencerResponse) 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: MsgUpsertSequencerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpsertSequencerResponse: 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 *MsgUpdateSequencer) 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: MsgUpdateSequencer: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateSequencer: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardAddr", 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.RewardAddr = 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 *MsgUpdateSequencerResponse) 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: MsgUpdateSequencerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateSequencerResponse: 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From 9f507a4f7a642fcb35f76db0da2763ccc1a387e3 Mon Sep 17 00:00:00 2001 From: keruch Date: Mon, 7 Oct 2024 17:31:04 +0200 Subject: [PATCH 15/19] feat(executor): MsgUpsertSequecner --- block/executor.go | 36 ++----------- block/produce.go | 97 ++++++++++++++++++++++++++++------ block/sequencers.go | 11 ++-- go.mod | 20 +++---- go.sum | 26 +++++++-- settlement/dymension/events.go | 4 +- 6 files changed, 127 insertions(+), 67 deletions(-) diff --git a/block/executor.go b/block/executor.go index dcdf60fa6..feeaadd18 100644 --- a/block/executor.go +++ b/block/executor.go @@ -4,11 +4,8 @@ import ( "errors" "time" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/types/bech32" proto2 "github.com/gogo/protobuf/proto" proto "github.com/gogo/protobuf/types" - abci "github.com/tendermint/tendermint/abci/types" tmcrypto "github.com/tendermint/tendermint/crypto/encoding" tmstate "github.com/tendermint/tendermint/proto/tendermint/state" @@ -19,7 +16,6 @@ import ( "github.com/dymensionxyz/dymint/mempool" "github.com/dymensionxyz/dymint/types" - "github.com/dymensionxyz/dymint/types/pb/rollapp/sequencers" ) // 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. @@ -107,47 +103,25 @@ func (e *Executor) InitChain(genesis *tmtypes.GenesisDoc, valset []*tmtypes.Vali }) } -// CreateBlock reaps transactions from mempool and builds a block. +// CreateBlock reaps transactions from mempool and builds a block. Optionally, executes consensus messages that +// gets from the consensus messages stream or from the method args. func (e *Executor) CreateBlock( height uint64, lastCommit *types.Commit, lastHeaderHash, nextSeqHash [32]byte, state *types.State, maxBlockDataSizeBytes uint64, + consensusMsgs ...proto2.Message, ) *types.Block { maxBlockDataSizeBytes = min(maxBlockDataSizeBytes, uint64(max(minBlockMaxBytes, state.ConsensusParams.Block.MaxBytes))) mempoolTxs := e.mempool.ReapMaxBytesMaxGas(int64(maxBlockDataSizeBytes), state.ConsensusParams.Block.MaxGas) - var consensusAnyMessages []*proto.Any if e.consensusMessagesStream != nil { consensusMessages, err := e.consensusMessagesStream.GetConsensusMessages() if err != nil { e.logger.Error("Failed to get consensus messages", "error", err) } - - consensusAnyMessages = fromProtoMsgSliceToAnySlice(consensusMessages...) - } - // Set the initial sequencer reward address on the very first block after the genesis - const rotationBlock = false - if state.LastBlockHeight.Load() == 1 { - val, _ := state.Sequencers.Proposer.TMValidator() - tmPubKey, err := tmcrypto.PubKeyToProto(val.PubKey) - if err != nil { - return nil - } - anyTmPubKey, err := codectypes.NewAnyWithValue(&tmPubKey) - if err != nil { - return nil - } - _, addrBytes, err := bech32.DecodeAndConvert(state.Sequencers.Proposer.SettlementAddress) - if err != nil { - return nil - } - consensusAnyMessages = append(consensusAnyMessages, fromProtoMsgSliceToAnySlice(&sequencers.MsgUpsertSequencer{ - Operator: val.Address.String(), // ?? - ConsPubKey: anyTmPubKey, - RewardAddrBytes: addrBytes, - })...) + consensusMsgs = append(consensusMsgs, consensusMessages...) } block := &types.Block{ @@ -170,7 +144,7 @@ func (e *Executor) CreateBlock( Txs: toDymintTxs(mempoolTxs), IntermediateStateRoots: types.IntermediateStateRoots{RawRootsList: nil}, Evidence: types.EvidenceData{Evidence: nil}, - ConsensusMessages: consensusAnyMessages, + ConsensusMessages: fromProtoMsgSliceToAnySlice(consensusMsgs...), }, LastCommit: *lastCommit, } diff --git a/block/produce.go b/block/produce.go index e9c77a909..1a8ea9d86 100644 --- a/block/produce.go +++ b/block/produce.go @@ -6,18 +6,21 @@ import ( "fmt" "time" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/bech32" + sequencertypes "github.com/dymensionxyz/dymension-rdk/x/sequencers/types" "github.com/dymensionxyz/gerr-cosmos/gerrc" - - "github.com/dymensionxyz/dymint/node/events" - "github.com/dymensionxyz/dymint/store" - uevent "github.com/dymensionxyz/dymint/utils/event" - + "github.com/gogo/protobuf/proto" tmed25519 "github.com/tendermint/tendermint/crypto/ed25519" + tmcrypto "github.com/tendermint/tendermint/crypto/encoding" cmtproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" tmtime "github.com/tendermint/tendermint/types/time" + "github.com/dymensionxyz/dymint/node/events" + "github.com/dymensionxyz/dymint/store" "github.com/dymensionxyz/dymint/types" + uevent "github.com/dymensionxyz/dymint/utils/event" ) // ProduceBlockLoop is calling publishBlock in a loop as long as we're synced. @@ -96,9 +99,17 @@ func (m *Manager) ProduceBlockLoop(ctx context.Context, bytesProducedC chan int) } } +// nextProposerInfo holds information about the next proposer. +type nextProposerInfo struct { + // nextProposerHash is a tendermint-compatible hash of the sequencer. + nextProposerHash [32]byte + // nextProposerAddr is a sequencer's settlement address. + nextProposerAddr string +} + // 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) +func (m *Manager) ProduceApplyGossipLastBlock(ctx context.Context, nextProposerInfo nextProposerInfo) (err error) { + _, _, err = m.produceApplyGossip(ctx, true, &nextProposerInfo) return err } @@ -106,8 +117,8 @@ func (m *Manager) ProduceApplyGossipBlock(ctx context.Context, allowEmpty bool) return m.produceApplyGossip(ctx, allowEmpty, nil) } -func (m *Manager) produceApplyGossip(ctx context.Context, allowEmpty bool, nextProposerHash *[32]byte) (block *types.Block, commit *types.Commit, err error) { - block, commit, err = m.produceBlock(allowEmpty, nextProposerHash) +func (m *Manager) produceApplyGossip(ctx context.Context, allowEmpty bool, nextProposerInfo *nextProposerInfo) (block *types.Block, commit *types.Commit, err error) { + block, commit, err = m.produceBlock(allowEmpty, nextProposerInfo) if err != nil { return nil, nil, fmt.Errorf("produce block: %w", err) } @@ -123,7 +134,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, nextProposerInfo *nextProposerInfo) (*types.Block, *types.Commit, error) { newHeight := m.State.NextHeight() lastHeaderHash, lastCommit, err := m.GetPreviousBlockHashes(newHeight) if err != nil { @@ -148,14 +159,24 @@ func (m *Manager) produceBlock(allowEmpty bool, nextProposerHash *[32]byte) (*ty return nil, nil, fmt.Errorf("load block: height: %d: %w: %w", newHeight, err, ErrNonRecoverable) } - maxBlockDataSize := uint64(float64(m.Conf.BatchSubmitBytes) * types.MaxBlockSizeAdjustment) - proposerHashForBlock := [32]byte(m.State.Sequencers.ProposerHash()) - // if nextProposerHash is set, we create a last block - if nextProposerHash != nil { + var ( + maxBlockDataSize = uint64(float64(m.Conf.BatchSubmitBytes) * types.MaxBlockSizeAdjustment) + proposerHashForBlock = [32]byte(m.State.Sequencers.ProposerHash()) + nextProposerAddr = m.State.Sequencers.Proposer.SettlementAddress + lastProposerBlock = false // Indicates that the block is the last for the current seq. True during the rotation. + ) + // if nextProposerInfo is set, we create a last block + if nextProposerInfo != nil { maxBlockDataSize = 0 - proposerHashForBlock = *nextProposerHash + proposerHashForBlock = nextProposerInfo.nextProposerHash + nextProposerAddr = nextProposerInfo.nextProposerAddr + lastProposerBlock = true } - block = m.Executor.CreateBlock(newHeight, lastCommit, lastHeaderHash, proposerHashForBlock, m.State, maxBlockDataSize) + consensusMsgs, err := m.consensusMsgsOnCreateBlock(nextProposerAddr, lastProposerBlock) + if err != nil { + return nil, nil, fmt.Errorf("create consensus msgs for create block: %w: %w", err, ErrNonRecoverable) + } + block = m.Executor.CreateBlock(newHeight, lastCommit, lastHeaderHash, proposerHashForBlock, m.State, maxBlockDataSize, consensusMsgs...) if !allowEmpty && len(block.Data.Txs) == 0 { return nil, nil, fmt.Errorf("%w: %w", types.ErrEmptyBlock, ErrRecoverable) } @@ -171,6 +192,50 @@ func (m *Manager) produceBlock(allowEmpty bool, nextProposerHash *[32]byte) (*ty return block, commit, nil } +// consensusMsgsOnCreateBlock forms a list of consensus messages that need execution on rollapp's BeginBlock. +// Currently, we need to create a sequencer in the rollapp if it doesn't exist in the following cases: +// - On the very first block after the genesis or +// - On the last block of the current sequencer (eg, during the rotation). +func (m *Manager) consensusMsgsOnCreateBlock( + nextProposerSettlementAddr string, + lastSeqBlock bool, // Indicates that the block is the last for the current seq. True during the rotation. +) ([]proto.Message, error) { + if m.State.IsGenesis() || lastSeqBlock { + nextSeq := m.State.Sequencers.GetByAddress(nextProposerSettlementAddr) + // Sanity check. Must never happen in practice. The sequencer's existence is verified beforehand in Manager.CompleteRotation. + if nextSeq == nil { + panic(fmt.Errorf("no sequencer found for address while creating a new block %s", nextProposerSettlementAddr)) + } + + // Get proposer's consensus public key and convert it to proto.Any + val, err := nextSeq.TMValidator() + if err != nil { + return nil, fmt.Errorf("convert next squencer to tendermint validator: %w", err) + } + pubKey, err := tmcrypto.PubKeyToProto(val.PubKey) + if err != nil { + return nil, fmt.Errorf("next squencer pub key to proto: %w", err) + } + anyPubKey, err := codectypes.NewAnyWithValue(&pubKey) + if err != nil { + return nil, fmt.Errorf("next squencer pubkey to proto any: %w", err) + } + + // Get raw bytes of the proposer's settlement address. These bytes are to be converted to the rollapp format later. + _, addrBytes, err := bech32.DecodeAndConvert(nextProposerSettlementAddr) + if err != nil { + return nil, fmt.Errorf("next squencer settlement addr to bech32: %w", err) + } + + return []proto.Message{&sequencertypes.MsgUpsertSequencer{ + Operator: nextProposerSettlementAddr, + ConsPubKey: anyPubKey, + RewardAddrBytes: addrBytes, + }}, nil + } + return nil, nil +} + // create commit for block func (m *Manager) createCommit(block *types.Block) (*types.Commit, error) { abciHeaderPb := types.ToABCIHeaderPB(&block.Header) diff --git a/block/sequencers.go b/block/sequencers.go index 4c98c4f3b..5e10b4a48 100644 --- a/block/sequencers.go +++ b/block/sequencers.go @@ -119,7 +119,10 @@ func (m *Manager) CompleteRotation(ctx context.Context, nextSeqAddr string) erro copy(nextSeqHash[:], seq.Hash()) } - err := m.CreateAndPostLastBatch(ctx, nextSeqHash) + err := m.CreateAndPostLastBatch(ctx, nextProposerInfo{ + nextProposerHash: nextSeqHash, + nextProposerAddr: nextSeqAddr, + }) if err != nil { return fmt.Errorf("create and post last batch: %w", err) } @@ -130,7 +133,7 @@ func (m *Manager) CompleteRotation(ctx context.Context, nextSeqAddr string) erro // CreateAndPostLastBatch creates and posts the last batch to the hub // this called after manager shuts down the block producer and submitter -func (m *Manager) CreateAndPostLastBatch(ctx context.Context, nextSeqHash [32]byte) error { +func (m *Manager) CreateAndPostLastBatch(ctx context.Context, nextProposerInfo nextProposerInfo) error { h := m.State.Height() block, err := m.Store.LoadBlock(h) if err != nil { @@ -138,10 +141,10 @@ func (m *Manager) CreateAndPostLastBatch(ctx context.Context, nextSeqHash [32]by } // check if the last block already produced with nextProposerHash set - if bytes.Equal(block.Header.NextSequencersHash[:], nextSeqHash[:]) { + if bytes.Equal(block.Header.NextSequencersHash[:], nextProposerInfo.nextProposerHash[:]) { m.logger.Debug("Last block already produced and applied.") } else { - err := m.ProduceApplyGossipLastBlock(ctx, nextSeqHash) + err := m.ProduceApplyGossipLastBlock(ctx, nextProposerInfo) if err != nil { return fmt.Errorf("produce apply gossip last block: %w", err) } diff --git a/go.mod b/go.mod index 903f622d9..cff87fc44 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +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 github.com/dymensionxyz/gerr-cosmos v1.0.0 github.com/go-kit/kit v0.12.0 github.com/gofrs/uuid v4.3.0+incompatible @@ -42,18 +43,14 @@ require ( ) require ( - cloud.google.com/go v0.112.1 // indirect - cloud.google.com/go/storage v1.38.0 // indirect github.com/celestiaorg/go-square v1.0.1 // indirect github.com/celestiaorg/go-square/merkle v0.0.0-20240429192549-dea967e1533b // indirect github.com/cskr/pubsub v1.0.2 // indirect github.com/dgraph-io/badger/v3 v3.2103.3 // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect github.com/hashicorp/go-getter v1.7.5 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/ipfs/go-block-format v0.2.0 // indirect - github.com/tklauser/go-sysconf v0.3.11 // indirect - google.golang.org/api v0.169.0 // indirect + github.com/tklauser/numcpus v0.6.0 // indirect ) require ( @@ -257,7 +254,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 @@ -267,10 +264,9 @@ require ( github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect - 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 @@ -296,11 +292,17 @@ require ( ) replace ( + // This replacement is needed in order to import dymension-rdk properly. It's inherited from + // https://github.com/dymensionxyz/dymension-rdk/blob/82c4d5f8c09365b20b4378c0cc459b414fd306e8/go.mod#L315. + github.com/CosmWasm/wasmd => github.com/decentrio/wasmd v0.33.0-sdk46.2 github.com/centrifuge/go-substrate-rpc-client/v4 => github.com/availproject/go-substrate-rpc-client/v4 v4.0.12-avail-1.4.0-rc1-5e286e3 - github.com/dymensionxyz/dymension-rdk => github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240827102903-08636e7ab3f8 + // TODO: uncomment after https://github.com/dymensionxyz/dymension-rdk/pull/563 is merged + // github.com/dymensionxyz/dymension-rdk => github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240827102903-08636e7ab3f8 + 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 + // TODO: uncomment after https://github.com/dymensionxyz/cometbft/pull/9 is merged // github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20240906143736-1e3959c2826e github.com/tendermint/tendermint => ../cometbft ) diff --git a/go.sum b/go.sum index 85c734c3a..138a23d43 100644 --- a/go.sum +++ b/go.sum @@ -189,6 +189,14 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= +cosmossdk.io/api v0.7.0 h1:QsEMIWuv9xWDbF2HZnW4Lpu1/SejCztPu0LQx7t6MN4= +cosmossdk.io/api v0.7.0/go.mod h1:kJFAEMLN57y0viszHDPLMmieF0471o5QAwwApa+270M= +cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= +cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU= +cosmossdk.io/core v0.12.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= +cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= +cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= @@ -211,9 +219,11 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= 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/CosmWasm/wasmvm v1.2.3 h1:OKYlobwmVGbl0eSn0mXoAAjE5hIuXnQCLPjbNd91sVY= +github.com/CosmWasm/wasmvm v1.2.3/go.mod h1:vW/E3h8j9xBQs9bCoijDuawKo9kCtxOaS8N8J7KFtkc= 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= @@ -374,6 +384,8 @@ github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8 github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= +github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0E= +github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= github.com/cosmos/cosmos-sdk v0.46.16 h1:RVGv1+RulLZeNyfCaPZrZtv0kY7ZZNAI6JGpub0Uh6o= @@ -411,6 +423,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR6AkioZ1ySsx5yxlDQZ8stG2b88gTPxgJU= github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= +github.com/decentrio/wasmd v0.33.0-sdk46.2 h1:cUgYN8crDXiQiKLBYfGR5IXg77Z/QrvZBoU9Fg/1ACo= +github.com/decentrio/wasmd v0.33.0-sdk46.2/go.mod h1:mPBiB+54La70eS2HHzvK2Vn7Frgf7rjnxDo70oopw+w= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= @@ -443,6 +457,8 @@ github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/docker/cli v23.0.1+incompatible h1:LRyWITpGzl2C9e9uGxzisptnxAn1zfZKXy13Ul2Q5oM= github.com/docker/cli v23.0.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v23.0.1+incompatible h1:vjgvJZxprTTE1A37nm+CLNAdwu6xZekyoiVlUZEINcY= github.com/docker/docker v23.0.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= @@ -465,6 +481,8 @@ github.com/dymensionxyz/gerr-cosmos v1.0.0 h1:oi91rgOkpJWr41oX9JOyjvvBnhGY54tj51 github.com/dymensionxyz/gerr-cosmos v1.0.0/go.mod h1:n+0olxPogzWqFKba45mCpvrHLGmeS8W9UZjggHnWk6c= github.com/dymensionxyz/rpc v1.3.1 h1:7EXWIobaBes5zldRvTIg7TmNsEKjicrWA/OjCc0NaGs= github.com/dymensionxyz/rpc v1.3.1/go.mod h1:f+WpX8ysy8wt95iGc6auYlHcnHj2bUkhiRVkkKNys8c= +github.com/dymensionxyz/sdk-utils v0.1.2-0.20240905104639-19dc09f5c6f5 h1:o6Jh8D4QZ7yifvOWV7/uoIugLZE0mTSOdz05ScaNNdU= +github.com/dymensionxyz/sdk-utils v0.1.2-0.20240905104639-19dc09f5c6f5/go.mod h1:5fmenxP75quS5D1gPynbmh5qE6vla64Kks2O/hM+gi4= github.com/elastic/gosigar v0.12.0/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/4= github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= @@ -507,8 +525,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= diff --git a/settlement/dymension/events.go b/settlement/dymension/events.go index abe8ee2c3..18f53cdef 100644 --- a/settlement/dymension/events.go +++ b/settlement/dymension/events.go @@ -158,7 +158,5 @@ func convertToRotationStartedEvent(rawEventData ctypes.ResultEvent) (*settlement rotationStartedEvent := &settlement.EventDataRotationStarted{ NextSeqAddr: nextProposer, } - return &settlement.EventDataRotationStarted{ - NextSeqAddr: nextProposer, - }, nil + return rotationStartedEvent, nil } From d55070b17ed82a1e80462b1c29257aa115db8b4e Mon Sep 17 00:00:00 2001 From: keruch Date: Mon, 7 Oct 2024 18:46:46 +0200 Subject: [PATCH 16/19] tests fix 1 --- block/produce.go | 4 ++-- settlement/grpc/grpc.go | 12 +++++++++++- settlement/local/local.go | 13 +++++++++++-- types/sequencer_set.go | 4 ++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/block/produce.go b/block/produce.go index 1a8ea9d86..77492508d 100644 --- a/block/produce.go +++ b/block/produce.go @@ -174,7 +174,7 @@ func (m *Manager) produceBlock(allowEmpty bool, nextProposerInfo *nextProposerIn } consensusMsgs, err := m.consensusMsgsOnCreateBlock(nextProposerAddr, lastProposerBlock) if err != nil { - return nil, nil, fmt.Errorf("create consensus msgs for create block: %w: %w", err, ErrNonRecoverable) + return nil, nil, fmt.Errorf("create consensus msgs for create block: last proposer block: %v, height: %d, next proposer addr: %s: %w: %w", lastProposerBlock, newHeight, nextProposerAddr, err, ErrNonRecoverable) } block = m.Executor.CreateBlock(newHeight, lastCommit, lastHeaderHash, proposerHashForBlock, m.State, maxBlockDataSize, consensusMsgs...) if !allowEmpty && len(block.Data.Txs) == 0 { @@ -204,7 +204,7 @@ func (m *Manager) consensusMsgsOnCreateBlock( nextSeq := m.State.Sequencers.GetByAddress(nextProposerSettlementAddr) // Sanity check. Must never happen in practice. The sequencer's existence is verified beforehand in Manager.CompleteRotation. if nextSeq == nil { - panic(fmt.Errorf("no sequencer found for address while creating a new block %s", nextProposerSettlementAddr)) + return nil, fmt.Errorf("no sequencer found for address while creating a new block: %s", nextProposerSettlementAddr) } // Get proposer's consensus public key and convert it to proto.Any diff --git a/settlement/grpc/grpc.go b/settlement/grpc/grpc.go index 67c62e0d3..37b32ba78 100644 --- a/settlement/grpc/grpc.go +++ b/settlement/grpc/grpc.go @@ -14,6 +14,7 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/types/bech32" "github.com/dymensionxyz/gerr-cosmos/gerrc" "github.com/libp2p/go-libp2p/core/crypto" "github.com/tendermint/tendermint/libs/pubsub" @@ -28,6 +29,10 @@ import ( rollapptypes "github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp" ) +const ( + addressPrefix = "dym" +) + // Client is an extension of the base settlement layer client // for usage in tests and local development. type Client struct { @@ -225,7 +230,12 @@ func (c *Client) GetProposer() *types.Sequencer { c.logger.Error("Error converting to tendermint pubkey", "err", err) return nil } - return types.NewSequencer(tmPubKey, pubKey.Address().String()) + settlementAddr, err := bech32.ConvertAndEncode(addressPrefix, pubKeyBytes) + if err != nil { + c.logger.Error("Error converting pubkey to settlement address", "err", err) + return nil + } + return types.NewSequencer(tmPubKey, settlementAddr) } // GetAllSequencers implements settlement.ClientI. diff --git a/settlement/local/local.go b/settlement/local/local.go index b085a567b..6cf97ed0a 100644 --- a/settlement/local/local.go +++ b/settlement/local/local.go @@ -15,6 +15,7 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/types/bech32" "github.com/dymensionxyz/gerr-cosmos/gerrc" "github.com/libp2p/go-libp2p/core/crypto" "github.com/tendermint/tendermint/libs/pubsub" @@ -28,7 +29,10 @@ import ( uevent "github.com/dymensionxyz/dymint/utils/event" ) -const kvStoreDBName = "settlement" +const ( + kvStoreDBName = "settlement" + addressPrefix = "dym" +) var ( settlementKVPrefix = []byte{0} @@ -203,7 +207,12 @@ func (c *Client) GetProposer() *types.Sequencer { c.logger.Error("Error converting to tendermint pubkey", "err", err) return nil } - return types.NewSequencer(tmPubKey, pubKey.Address().String()) + settlementAddr, err := bech32.ConvertAndEncode(addressPrefix, pubKeyBytes) + if err != nil { + c.logger.Error("Error converting pubkey to settlement address", "err", err) + return nil + } + return types.NewSequencer(tmPubKey, settlementAddr) } // GetAllSequencers implements settlement.ClientI. diff --git a/types/sequencer_set.go b/types/sequencer_set.go index 45ab8447b..b557147a0 100644 --- a/types/sequencer_set.go +++ b/types/sequencer_set.go @@ -52,6 +52,10 @@ func (s Sequencer) Hash() []byte { return tempProposerSet.Hash() } +func (s Sequencer) String() string { + return fmt.Sprintf("Sequencer{SettlementAddress: %s Validator: %s}", s.SettlementAddress, s.val.String()) +} + // SequencerSet is a set of rollapp sequencers and a proposer. type SequencerSet struct { // Sequencers is the set of sequencers registered in the settlement layer From ef2a708cee1731a3b87b11fec57fb598fa3c9936 Mon Sep 17 00:00:00 2001 From: keruch Date: Mon, 7 Oct 2024 19:10:11 +0200 Subject: [PATCH 17/19] tests fix 2 --- block/produce.go | 2 +- p2p/client_test.go | 4 +- proto/protoc.sh | 1 - proto/types/rollapp/sequencers/tx.proto | 45 - testutil/types.go | 21 +- types/pb/rollapp/sequencers/tx.pb.go | 1314 ----------------------- 6 files changed, 21 insertions(+), 1366 deletions(-) delete mode 100644 proto/types/rollapp/sequencers/tx.proto delete mode 100644 types/pb/rollapp/sequencers/tx.pb.go diff --git a/block/produce.go b/block/produce.go index 77492508d..95f825361 100644 --- a/block/produce.go +++ b/block/produce.go @@ -221,7 +221,7 @@ func (m *Manager) consensusMsgsOnCreateBlock( return nil, fmt.Errorf("next squencer pubkey to proto any: %w", err) } - // Get raw bytes of the proposer's settlement address. These bytes are to be converted to the rollapp format later. + // Get raw bytes of the proposer's settlement address. These bytes will to be converted to the rollapp format in the app. _, addrBytes, err := bech32.DecodeAndConvert(nextProposerSettlementAddr) if err != nil { return nil, fmt.Errorf("next squencer settlement addr to bech32: %w", err) diff --git a/p2p/client_test.go b/p2p/client_test.go index 020d6a052..fcf2ab293 100644 --- a/p2p/client_test.go +++ b/p2p/client_test.go @@ -17,10 +17,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/dymensionxyz/dymint/store" "github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/pubsub" + "github.com/dymensionxyz/dymint/store" + "github.com/dymensionxyz/dymint/config" "github.com/dymensionxyz/dymint/p2p" "github.com/dymensionxyz/dymint/testutil" @@ -49,6 +50,7 @@ func TestClientStartup(t *testing.T) { assert.NoError(err) } +// TestBootstrapping TODO: this test is flaky in main. Try running it 100 times to reproduce. func TestBootstrapping(t *testing.T) { assert := assert.New(t) logger := log.TestingLogger() diff --git a/proto/protoc.sh b/proto/protoc.sh index 2937453b7..4b23b9743 100755 --- a/proto/protoc.sh +++ b/proto/protoc.sh @@ -7,7 +7,6 @@ buf generate --path="./proto/types/dalc" --template="buf.gen.yaml" --config="buf buf generate --path="./proto/types/dymint" --template="buf.gen.yaml" --config="buf.yaml" buf generate --path="./proto/types/interchain_da" --template="buf.gen.yaml" --config="buf.yaml" buf generate --path="./proto/types/dymensionxyz" --template="buf.gen.yaml" --config="buf.yaml" -buf generate --path="./proto/types/rollapp" --template="buf.gen.yaml" --config="buf.yaml" # Generate the `test` proto files buf generate --path="./proto/test" --template="buf.gen.yaml" --config="buf.yaml" diff --git a/proto/types/rollapp/sequencers/tx.proto b/proto/types/rollapp/sequencers/tx.proto deleted file mode 100644 index 2db0f029d..000000000 --- a/proto/types/rollapp/sequencers/tx.proto +++ /dev/null @@ -1,45 +0,0 @@ -// This file is a modified copy of the dymension-rdk/sequencers module proto contract. Source: -// https://github.com/dymensionxyz/dymension-rdk/blob/28628bcb329ac7b4cdd6d19f1c43f26d03410f84/proto/sequencers/tx.proto. -// It contains only message definitions but without the Msg service. -syntax = "proto3"; -package rollapp.sequencers.types; - -import "gogoproto/gogo.proto"; -import "types/cosmos/msg/v1/msg.proto"; -import "google/protobuf/any.proto"; - -option go_package = "github.com/dymensionxyz/dymint/types/pb/rollapp/sequencers"; - -message MsgCreateSequencer { - option (cosmos.msg.v1.signer) = "operator"; - // Operator is the bech32-encoded address of the actor sending the update - must be val addr - string operator = 1; - // PubKey is a tendermint consensus pub key - google.protobuf.Any pub_key = 2; - // Signature is operator signed with the private key of pub_key - bytes signature = 3; -} - -message MsgCreateSequencerResponse {} - -message MsgUpsertSequencer { - option (cosmos.msg.v1.signer) = "operator"; - // Operator is the bech32-encoded address of the actor sending the update - must be val addr - string operator = 1; - // ConsPubKey is a tendermint consensus pub key - google.protobuf.Any cons_pub_key = 2; - // RewardAddrBytes is the bytes representation of the sequencer's reward account - bytes reward_addr_bytes = 3; -} - -message MsgUpsertSequencerResponse {} - -message MsgUpdateSequencer { - option (cosmos.msg.v1.signer) = "operator"; - // Operator is the bech32-encoded address of the actor sending the update - must be val addr - string operator = 1; - // RewardAddr is a bech32 encoded sdk acc address - string reward_addr = 3; -} - -message MsgUpdateSequencerResponse {} diff --git a/testutil/types.go b/testutil/types.go index e019fc0bc..0952a8456 100644 --- a/testutil/types.go +++ b/testutil/types.go @@ -5,9 +5,7 @@ import ( "math/big" "time" - "github.com/dymensionxyz/dymint/types" - "github.com/dymensionxyz/dymint/types/pb/dymint" - dymintversion "github.com/dymensionxyz/dymint/version" + "github.com/cosmos/cosmos-sdk/types/bech32" "github.com/libp2p/go-libp2p/core/crypto" abci "github.com/tendermint/tendermint/abci/types" tmcrypto "github.com/tendermint/tendermint/crypto" @@ -16,6 +14,10 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" version "github.com/tendermint/tendermint/proto/tendermint/version" tmtypes "github.com/tendermint/tendermint/types" + + "github.com/dymensionxyz/dymint/types" + "github.com/dymensionxyz/dymint/types/pb/dymint" + dymintversion "github.com/dymensionxyz/dymint/version" ) const ( @@ -23,6 +25,8 @@ const ( BlockVersion = 1 // AppVersion is the default app version for testing AppVersion = 2 + + SettlementAccountPrefix = "dym" ) func createRandomHashes() [][32]byte { @@ -38,6 +42,15 @@ func createRandomHashes() [][32]byte { return h } +func GenerateSettlementAddress() string { + addrBytes := ed25519.GenPrivKey().PubKey().Address().Bytes() + addr, err := bech32.ConvertAndEncode(SettlementAccountPrefix, addrBytes) + if err != nil { + panic(err) + } + return addr +} + func GetRandomTx() types.Tx { n, _ := rand.Int(rand.Reader, big.NewInt(100)) size := uint64(n.Int64()) + 100 @@ -247,7 +260,7 @@ func GenerateStateWithSequencer(initialHeight int64, lastBlockHeight int64, pubk }, }, } - s.Sequencers.SetProposer(types.NewSequencer(pubkey, "")) + s.Sequencers.SetProposer(types.NewSequencer(pubkey, GenerateSettlementAddress())) s.SetHeight(uint64(lastBlockHeight)) return s } diff --git a/types/pb/rollapp/sequencers/tx.pb.go b/types/pb/rollapp/sequencers/tx.pb.go deleted file mode 100644 index 60210f738..000000000 --- a/types/pb/rollapp/sequencers/tx.pb.go +++ /dev/null @@ -1,1314 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: types/rollapp/sequencers/tx.proto - -package sequencers - -import ( - fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - types "github.com/gogo/protobuf/types" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type MsgCreateSequencer struct { - // Operator is the bech32-encoded address of the actor sending the update - must be val addr - Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` - // PubKey is a tendermint consensus pub key - PubKey *types.Any `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` - // Signature is operator signed with the private key of pub_key - Signature []byte `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"` -} - -func (m *MsgCreateSequencer) Reset() { *m = MsgCreateSequencer{} } -func (m *MsgCreateSequencer) String() string { return proto.CompactTextString(m) } -func (*MsgCreateSequencer) ProtoMessage() {} -func (*MsgCreateSequencer) Descriptor() ([]byte, []int) { - return fileDescriptor_30467481bc397351, []int{0} -} -func (m *MsgCreateSequencer) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgCreateSequencer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgCreateSequencer.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 *MsgCreateSequencer) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateSequencer.Merge(m, src) -} -func (m *MsgCreateSequencer) XXX_Size() int { - return m.Size() -} -func (m *MsgCreateSequencer) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateSequencer.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgCreateSequencer proto.InternalMessageInfo - -func (m *MsgCreateSequencer) GetOperator() string { - if m != nil { - return m.Operator - } - return "" -} - -func (m *MsgCreateSequencer) GetPubKey() *types.Any { - if m != nil { - return m.PubKey - } - return nil -} - -func (m *MsgCreateSequencer) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil -} - -type MsgCreateSequencerResponse struct { -} - -func (m *MsgCreateSequencerResponse) Reset() { *m = MsgCreateSequencerResponse{} } -func (m *MsgCreateSequencerResponse) String() string { return proto.CompactTextString(m) } -func (*MsgCreateSequencerResponse) ProtoMessage() {} -func (*MsgCreateSequencerResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_30467481bc397351, []int{1} -} -func (m *MsgCreateSequencerResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgCreateSequencerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgCreateSequencerResponse.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 *MsgCreateSequencerResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateSequencerResponse.Merge(m, src) -} -func (m *MsgCreateSequencerResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgCreateSequencerResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateSequencerResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgCreateSequencerResponse proto.InternalMessageInfo - -type MsgUpsertSequencer struct { - // Operator is the bech32-encoded address of the actor sending the update - must be val addr - Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` - // ConsPubKey is a tendermint consensus pub key - ConsPubKey *types.Any `protobuf:"bytes,2,opt,name=cons_pub_key,json=consPubKey,proto3" json:"cons_pub_key,omitempty"` - // RewardAddrBytes is the bytes representation of the sequencer's reward account - RewardAddrBytes []byte `protobuf:"bytes,3,opt,name=reward_addr_bytes,json=rewardAddrBytes,proto3" json:"reward_addr_bytes,omitempty"` -} - -func (m *MsgUpsertSequencer) Reset() { *m = MsgUpsertSequencer{} } -func (m *MsgUpsertSequencer) String() string { return proto.CompactTextString(m) } -func (*MsgUpsertSequencer) ProtoMessage() {} -func (*MsgUpsertSequencer) Descriptor() ([]byte, []int) { - return fileDescriptor_30467481bc397351, []int{2} -} -func (m *MsgUpsertSequencer) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpsertSequencer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpsertSequencer.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 *MsgUpsertSequencer) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpsertSequencer.Merge(m, src) -} -func (m *MsgUpsertSequencer) XXX_Size() int { - return m.Size() -} -func (m *MsgUpsertSequencer) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpsertSequencer.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpsertSequencer proto.InternalMessageInfo - -func (m *MsgUpsertSequencer) GetOperator() string { - if m != nil { - return m.Operator - } - return "" -} - -func (m *MsgUpsertSequencer) GetConsPubKey() *types.Any { - if m != nil { - return m.ConsPubKey - } - return nil -} - -func (m *MsgUpsertSequencer) GetRewardAddrBytes() []byte { - if m != nil { - return m.RewardAddrBytes - } - return nil -} - -type MsgUpsertSequencerResponse struct { -} - -func (m *MsgUpsertSequencerResponse) Reset() { *m = MsgUpsertSequencerResponse{} } -func (m *MsgUpsertSequencerResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpsertSequencerResponse) ProtoMessage() {} -func (*MsgUpsertSequencerResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_30467481bc397351, []int{3} -} -func (m *MsgUpsertSequencerResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpsertSequencerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpsertSequencerResponse.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 *MsgUpsertSequencerResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpsertSequencerResponse.Merge(m, src) -} -func (m *MsgUpsertSequencerResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpsertSequencerResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpsertSequencerResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpsertSequencerResponse proto.InternalMessageInfo - -type MsgUpdateSequencer struct { - // Operator is the bech32-encoded address of the actor sending the update - must be val addr - Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` - // RewardAddr is a bech32 encoded sdk acc address - RewardAddr string `protobuf:"bytes,3,opt,name=reward_addr,json=rewardAddr,proto3" json:"reward_addr,omitempty"` -} - -func (m *MsgUpdateSequencer) Reset() { *m = MsgUpdateSequencer{} } -func (m *MsgUpdateSequencer) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateSequencer) ProtoMessage() {} -func (*MsgUpdateSequencer) Descriptor() ([]byte, []int) { - return fileDescriptor_30467481bc397351, []int{4} -} -func (m *MsgUpdateSequencer) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateSequencer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateSequencer.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 *MsgUpdateSequencer) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateSequencer.Merge(m, src) -} -func (m *MsgUpdateSequencer) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateSequencer) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateSequencer.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateSequencer proto.InternalMessageInfo - -func (m *MsgUpdateSequencer) GetOperator() string { - if m != nil { - return m.Operator - } - return "" -} - -func (m *MsgUpdateSequencer) GetRewardAddr() string { - if m != nil { - return m.RewardAddr - } - return "" -} - -type MsgUpdateSequencerResponse struct { -} - -func (m *MsgUpdateSequencerResponse) Reset() { *m = MsgUpdateSequencerResponse{} } -func (m *MsgUpdateSequencerResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateSequencerResponse) ProtoMessage() {} -func (*MsgUpdateSequencerResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_30467481bc397351, []int{5} -} -func (m *MsgUpdateSequencerResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateSequencerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateSequencerResponse.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 *MsgUpdateSequencerResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateSequencerResponse.Merge(m, src) -} -func (m *MsgUpdateSequencerResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateSequencerResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateSequencerResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateSequencerResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgCreateSequencer)(nil), "rollapp.sequencers.types.MsgCreateSequencer") - proto.RegisterType((*MsgCreateSequencerResponse)(nil), "rollapp.sequencers.types.MsgCreateSequencerResponse") - proto.RegisterType((*MsgUpsertSequencer)(nil), "rollapp.sequencers.types.MsgUpsertSequencer") - proto.RegisterType((*MsgUpsertSequencerResponse)(nil), "rollapp.sequencers.types.MsgUpsertSequencerResponse") - proto.RegisterType((*MsgUpdateSequencer)(nil), "rollapp.sequencers.types.MsgUpdateSequencer") - proto.RegisterType((*MsgUpdateSequencerResponse)(nil), "rollapp.sequencers.types.MsgUpdateSequencerResponse") -} - -func init() { proto.RegisterFile("types/rollapp/sequencers/tx.proto", fileDescriptor_30467481bc397351) } - -var fileDescriptor_30467481bc397351 = []byte{ - // 395 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xb1, 0xce, 0xd3, 0x30, - 0x10, 0xc7, 0x6b, 0x90, 0x0a, 0x75, 0x8b, 0x10, 0x51, 0x87, 0x10, 0x95, 0x50, 0x3a, 0x55, 0x95, - 0x88, 0x05, 0x48, 0x0c, 0xdd, 0x5a, 0x46, 0x84, 0x84, 0x02, 0x2c, 0x2c, 0x21, 0x89, 0x0f, 0x13, - 0xd1, 0xd8, 0xc6, 0x76, 0xa0, 0x66, 0x64, 0x66, 0xe0, 0x1d, 0x78, 0x01, 0x1e, 0x83, 0xb1, 0x23, - 0x23, 0x6a, 0x07, 0x5e, 0x03, 0x25, 0x4e, 0x5b, 0xc4, 0xd7, 0x4f, 0xea, 0x94, 0xdc, 0xfd, 0xcf, - 0xff, 0xfb, 0xdd, 0xe9, 0xf0, 0x3d, 0x63, 0x25, 0x68, 0xa2, 0xc4, 0x6a, 0x95, 0x4a, 0x49, 0x34, - 0x7c, 0xa8, 0x80, 0xe7, 0xa0, 0x34, 0x31, 0xeb, 0x48, 0x2a, 0x61, 0x84, 0xe7, 0xb7, 0x62, 0x74, - 0x14, 0xa3, 0xe6, 0x55, 0x30, 0x64, 0x82, 0x89, 0xa6, 0x88, 0xd4, 0x7f, 0xae, 0x3e, 0xb8, 0xe3, - 0x2c, 0x73, 0xa1, 0x4b, 0xa1, 0x49, 0xa9, 0x19, 0xf9, 0xf8, 0xa0, 0xfe, 0xb4, 0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d3, 0x53, 0x3b, 0x5c, 0xbe, 0xfc, 0xb9, 0x0d, 0xd1, 0x66, 0x1b, 0xa2, 0xdf, 0xdb, - 0x10, 0x7d, 0xdb, 0x85, 0x9d, 0xcd, 0x2e, 0xec, 0xfc, 0xda, 0x85, 0x9d, 0xd7, 0x73, 0x56, 0x98, - 0x77, 0x55, 0x16, 0xe5, 0xa2, 0x24, 0xd4, 0x96, 0xc0, 0x75, 0x21, 0xf8, 0xda, 0x7e, 0xae, 0x83, - 0x82, 0x1b, 0xe2, 0x6e, 0x4c, 0x66, 0x27, 0x2e, 0x37, 0xeb, 0x36, 0x8b, 0x7c, 0xf4, 0x37, 0x00, - 0x00, 0xff, 0xff, 0xa1, 0x43, 0x69, 0xfb, 0xdc, 0x02, 0x00, 0x00, -} - -func (m *MsgCreateSequencer) 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 *MsgCreateSequencer) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreateSequencer) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x1a - } - if m.PubKey != nil { - { - size, err := m.PubKey.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Operator) > 0 { - i -= len(m.Operator) - copy(dAtA[i:], m.Operator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgCreateSequencerResponse) 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 *MsgCreateSequencerResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreateSequencerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgUpsertSequencer) 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 *MsgUpsertSequencer) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpsertSequencer) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.RewardAddrBytes) > 0 { - i -= len(m.RewardAddrBytes) - copy(dAtA[i:], m.RewardAddrBytes) - i = encodeVarintTx(dAtA, i, uint64(len(m.RewardAddrBytes))) - i-- - dAtA[i] = 0x1a - } - if m.ConsPubKey != nil { - { - size, err := m.ConsPubKey.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Operator) > 0 { - i -= len(m.Operator) - copy(dAtA[i:], m.Operator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpsertSequencerResponse) 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 *MsgUpsertSequencerResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpsertSequencerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgUpdateSequencer) 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 *MsgUpdateSequencer) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateSequencer) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.RewardAddr) > 0 { - i -= len(m.RewardAddr) - copy(dAtA[i:], m.RewardAddr) - i = encodeVarintTx(dAtA, i, uint64(len(m.RewardAddr))) - i-- - dAtA[i] = 0x1a - } - if len(m.Operator) > 0 { - i -= len(m.Operator) - copy(dAtA[i:], m.Operator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateSequencerResponse) 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 *MsgUpdateSequencerResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateSequencerResponse) 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 - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgCreateSequencer) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Operator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.PubKey != nil { - l = m.PubKey.Size() - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgCreateSequencerResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgUpsertSequencer) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Operator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.ConsPubKey != nil { - l = m.ConsPubKey.Size() - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.RewardAddrBytes) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgUpsertSequencerResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgUpdateSequencer) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Operator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.RewardAddr) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgUpdateSequencerResponse) 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 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgCreateSequencer) 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: MsgCreateSequencer: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateSequencer: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.PubKey == nil { - m.PubKey = &types.Any{} - } - if err := m.PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) - if m.Signature == nil { - m.Signature = []byte{} - } - 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 *MsgCreateSequencerResponse) 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: MsgCreateSequencerResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateSequencerResponse: 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 *MsgUpsertSequencer) 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: MsgUpsertSequencer: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpsertSequencer: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsPubKey", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ConsPubKey == nil { - m.ConsPubKey = &types.Any{} - } - if err := m.ConsPubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardAddrBytes", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RewardAddrBytes = append(m.RewardAddrBytes[:0], dAtA[iNdEx:postIndex]...) - if m.RewardAddrBytes == nil { - m.RewardAddrBytes = []byte{} - } - 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 *MsgUpsertSequencerResponse) 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: MsgUpsertSequencerResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpsertSequencerResponse: 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 *MsgUpdateSequencer) 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: MsgUpdateSequencer: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateSequencer: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardAddr", 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.RewardAddr = 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 *MsgUpdateSequencerResponse) 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: MsgUpdateSequencerResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateSequencerResponse: 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 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTx - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTx - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTx - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") -) From f357f7d13700209700f771109e7a931830fbf012 Mon Sep 17 00:00:00 2001 From: omritoptix Date: Tue, 8 Oct 2024 16:26:16 +0200 Subject: [PATCH 18/19] Updated cometbft version. --- go.mod | 3 +-- go.sum | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 903f622d9..c342ffd4b 100644 --- a/go.mod +++ b/go.mod @@ -301,8 +301,7 @@ replace ( github.com/evmos/evmos/v12 => github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 github.com/gorilla/rpc => github.com/dymensionxyz/rpc v1.3.1 - // github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20240906143736-1e3959c2826e - github.com/tendermint/tendermint => ../cometbft + github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20241008141942-63af9d24107f ) replace github.com/osmosis-labs/osmosis/v15 => github.com/dymensionxyz/osmosis/v15 v15.2.0-dymension-v1.1.2 diff --git a/go.sum b/go.sum index 85c734c3a..cba754ced 100644 --- a/go.sum +++ b/go.sum @@ -457,6 +457,8 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= +github.com/dymensionxyz/cometbft v0.34.29-0.20241008141942-63af9d24107f h1:CclWJWRydsd8D4/R1IegIkcWtL4wqTA3MWtXrx1a6y4= +github.com/dymensionxyz/cometbft v0.34.29-0.20241008141942-63af9d24107f/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/evmos/v12 v12.1.6-dymension-v0.3 h1:vmAdUGUc4rTIiO3Phezr7vGq+0uPDVKSA4WAe8+yl6w= From ae841598af2f53ae1c1b5f8619e6f911378152be Mon Sep 17 00:00:00 2001 From: keruch Date: Wed, 9 Oct 2024 17:07:43 +0200 Subject: [PATCH 19/19] linked tasks --- block/manager.go | 2 +- block/produce.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/block/manager.go b/block/manager.go index 89ee16df0..e89b4db87 100644 --- a/block/manager.go +++ b/block/manager.go @@ -112,7 +112,7 @@ func NewManager( mempool, proxyApp, eventBus, - nil, // TODO add ConsensusMessagesStream + nil, // TODO add ConsensusMessagesStream: https://github.com/dymensionxyz/dymint/issues/1125 logger, ) if err != nil { diff --git a/block/produce.go b/block/produce.go index 95f825361..5762c2172 100644 --- a/block/produce.go +++ b/block/produce.go @@ -172,6 +172,10 @@ func (m *Manager) produceBlock(allowEmpty bool, nextProposerInfo *nextProposerIn nextProposerAddr = nextProposerInfo.nextProposerAddr lastProposerBlock = true } + // TODO: Ideally, there should be only one point for adding consensus messages. Given that they come from + // ConsensusMessagesStream, this should send them there instead of having to ways of sending consensusMessages. + // There is no implementation of the stream as of now. Unify the approach of adding consensus messages when + // the stream is implemented! https://github.com/dymensionxyz/dymint/issues/1125 consensusMsgs, err := m.consensusMsgsOnCreateBlock(nextProposerAddr, lastProposerBlock) if err != nil { return nil, nil, fmt.Errorf("create consensus msgs for create block: last proposer block: %v, height: %d, next proposer addr: %s: %w: %w", lastProposerBlock, newHeight, nextProposerAddr, err, ErrNonRecoverable)