diff --git a/.gitignore b/.gitignore index a44fa04dc..bd3ce4287 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ proto/pb .DS_Store .vscode .idea +.go-version build diff --git a/block/manager.go b/block/manager.go index 6f2048d90..71f924904 100644 --- a/block/manager.go +++ b/block/manager.go @@ -18,9 +18,10 @@ import ( tmcrypto "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/merkle" "github.com/tendermint/tendermint/libs/pubsub" - "github.com/tendermint/tendermint/proxy" tmtypes "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/proxy" + "github.com/dymensionxyz/dymint/config" "github.com/dymensionxyz/dymint/da" "github.com/dymensionxyz/dymint/log" diff --git a/block/produce.go b/block/produce.go index dc567f2b0..c9988c933 100644 --- a/block/produce.go +++ b/block/produce.go @@ -10,6 +10,10 @@ import ( abciconv "github.com/dymensionxyz/dymint/conv/abci" "github.com/dymensionxyz/dymint/settlement" "github.com/dymensionxyz/dymint/types" + tmed25519 "github.com/tendermint/tendermint/crypto/ed25519" + cmtproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmtypes "github.com/tendermint/tendermint/types" + tmtime "github.com/tendermint/tendermint/types/time" ) // waitForSync enforces the aggregator to be synced before it can produce blocks. @@ -156,14 +160,29 @@ func (m *Manager) produceBlock(ctx context.Context, allowEmpty bool) error { if err != nil { return err } + proposerAddress, err := getAddress(m.proposerKey) + if err != nil { + return err + } sign, err := m.proposerKey.Sign(abciHeaderBytes) if err != nil { return err } + voteTimestamp := tmtime.Now() + tmSignature, err := m.createTMSignature(block, proposerAddress, voteTimestamp) + if err != nil { + return err + } commit = &types.Commit{ Height: block.Header.Height, HeaderHash: block.Header.Hash(), Signatures: []types.Signature{sign}, + TMSignature: tmtypes.CommitSig{ + BlockIDFlag: 2, + ValidatorAddress: proposerAddress, + Timestamp: voteTimestamp, + Signature: tmSignature, + }, } } @@ -181,3 +200,39 @@ func (m *Manager) produceBlock(ctx context.Context, allowEmpty bool) error { rollappHeightGauge.Set(float64(newHeight)) return nil } + +func (m *Manager) createTMSignature(block *types.Block, proposerAddress []byte, voteTimestamp time.Time) ([]byte, error) { + headerHash := block.Header.Hash() + vote := tmtypes.Vote{ + Type: cmtproto.PrecommitType, + Height: int64(block.Header.Height), + Round: 0, + Timestamp: voteTimestamp, + BlockID: tmtypes.BlockID{Hash: headerHash[:], PartSetHeader: tmtypes.PartSetHeader{ + Total: 1, + Hash: headerHash[:], + }}, + ValidatorAddress: proposerAddress, + ValidatorIndex: 0, + } + v := vote.ToProto() + // convert libp2p key to tm key + raw_key, _ := m.proposerKey.Raw() + tmprivkey := tmed25519.PrivKey(raw_key) + tmprivkey.PubKey().Bytes() + // Create a mock validator to sign the vote + tmvalidator := tmtypes.NewMockPVWithParams(tmprivkey, false, false) + err := tmvalidator.SignVote(m.lastState.ChainID, v) + if err != nil { + return nil, err + } + // Update the vote with the signature + vote.Signature = v.Signature + pubKey := tmprivkey.PubKey() + voteSignBytes := tmtypes.VoteSignBytes(m.lastState.ChainID, v) + if !pubKey.VerifySignature(voteSignBytes, vote.Signature) { + return nil, fmt.Errorf("wrong signature") + } + return vote.Signature, nil + +} diff --git a/block/testutil.go b/block/testutil.go index b493e7dd9..29175dc4f 100644 --- a/block/testutil.go +++ b/block/testutil.go @@ -55,6 +55,7 @@ func getManager(conf config.BlockManagerConfig, settlementlc settlement.LayerI, if err != nil { return nil, err } + // Init the settlement layer mock if settlementlc == nil { settlementlc = slregistry.GetClient(slregistry.Mock) diff --git a/conv/abci/block.go b/conv/abci/block.go index 64cfea07b..350b6fb57 100644 --- a/conv/abci/block.go +++ b/conv/abci/block.go @@ -121,28 +121,34 @@ func ToABCIBlockMeta(block *types.Block) (*tmtypes.BlockMeta, error) { // This function only converts fields that are available in Dymint commit. // Other fields (especially ValidatorAddress and Timestamp of Signature) has to be filled by caller. func ToABCICommit(commit *types.Commit, header *types.Header) *tmtypes.Commit { + headerHash := header.Hash() tmCommit := tmtypes.Commit{ Height: int64(commit.Height), Round: 0, BlockID: tmtypes.BlockID{ - Hash: commit.HeaderHash[:], + Hash: headerHash[:], PartSetHeader: tmtypes.PartSetHeader{ Total: 1, - Hash: commit.HeaderHash[:], + Hash: headerHash[:], }, }, } - for _, sig := range commit.Signatures { - commitSig := tmtypes.CommitSig{ - BlockIDFlag: tmtypes.BlockIDFlagCommit, - Signature: sig, + // Check if TMSignature exists. if not use the previous dymint signature for backwards compatibility. + if len(commit.TMSignature.Signature) == 0 { + for _, sig := range commit.Signatures { + commitSig := tmtypes.CommitSig{ + BlockIDFlag: tmtypes.BlockIDFlagCommit, + Signature: sig, + } + tmCommit.Signatures = append(tmCommit.Signatures, commitSig) } - tmCommit.Signatures = append(tmCommit.Signatures, commitSig) - } - // This assumes that we have only one signature - if len(commit.Signatures) == 1 { - tmCommit.Signatures[0].ValidatorAddress = header.ProposerAddress - tmCommit.Signatures[0].Timestamp = time.Unix(0, int64(header.Time)) + // This assumes that we have only one signature + if len(commit.Signatures) == 1 { + tmCommit.Signatures[0].ValidatorAddress = header.ProposerAddress + tmCommit.Signatures[0].Timestamp = time.Unix(0, int64(header.Time)) + } + } else { + tmCommit.Signatures = append(tmCommit.Signatures, commit.TMSignature) } return &tmCommit diff --git a/proto/types/dymint/dymint.proto b/proto/types/dymint/dymint.proto index 22178b4bc..c4ce80ec8 100755 --- a/proto/types/dymint/dymint.proto +++ b/proto/types/dymint/dymint.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package dymint; option go_package = "github.com/dymensionxyz/dymint/types/pb/dymint"; import "types/tendermint/abci/types.proto"; +import "types/tendermint/types/types.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 @@ -63,6 +64,7 @@ message Commit { bytes header_hash = 2; // Note: most of the time this will be a single sinature repeated bytes signatures = 3; + tendermint.types.CommitSig tm_signature = 4; } message Data { diff --git a/types/block.go b/types/block.go index a3654dbe7..8d57df7e0 100644 --- a/types/block.go +++ b/types/block.go @@ -2,6 +2,8 @@ package types import ( "encoding" + + tmtypes "github.com/tendermint/tendermint/types" ) // Header defines the structure of Dymint block header. @@ -82,7 +84,8 @@ type Commit struct { Height uint64 HeaderHash [32]byte // TODO(omritoptix): Change from []Signature to Signature as it should be one signature per block - Signatures []Signature + Signatures []Signature + TMSignature tmtypes.CommitSig } // Signature represents signature of block creator. diff --git a/types/pb/dymint/dymint.pb.go b/types/pb/dymint/dymint.pb.go index a7b4161db..e8811fcbb 100644 --- a/types/pb/dymint/dymint.pb.go +++ b/types/pb/dymint/dymint.pb.go @@ -6,7 +6,8 @@ package dymint import ( fmt "fmt" proto "github.com/gogo/protobuf/proto" - types "github.com/tendermint/tendermint/abci/types" + types1 "github.com/tendermint/tendermint/abci/types" + types "github.com/tendermint/tendermint/proto/tendermint/types" io "io" math "math" math_bits "math/bits" @@ -242,7 +243,8 @@ type Commit struct { Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` HeaderHash []byte `protobuf:"bytes,2,opt,name=header_hash,json=headerHash,proto3" json:"header_hash,omitempty"` // Note: most of the time this will be a single sinature - Signatures [][]byte `protobuf:"bytes,3,rep,name=signatures,proto3" json:"signatures,omitempty"` + Signatures [][]byte `protobuf:"bytes,3,rep,name=signatures,proto3" json:"signatures,omitempty"` + TmSignature *types.CommitSig `protobuf:"bytes,4,opt,name=tm_signature,json=tmSignature,proto3" json:"tm_signature,omitempty"` } func (m *Commit) Reset() { *m = Commit{} } @@ -299,10 +301,17 @@ func (m *Commit) GetSignatures() [][]byte { return nil } +func (m *Commit) GetTmSignature() *types.CommitSig { + if m != nil { + return m.TmSignature + } + return nil +} + 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 []*types.Evidence `protobuf:"bytes,3,rep,name=evidence,proto3" json:"evidence,omitempty"` + 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"` } func (m *Data) Reset() { *m = Data{} } @@ -352,7 +361,7 @@ func (m *Data) GetIntermediateStateRoots() [][]byte { return nil } -func (m *Data) GetEvidence() []*types.Evidence { +func (m *Data) GetEvidence() []*types1.Evidence { if m != nil { return m.Evidence } @@ -499,48 +508,50 @@ func init() { func init() { proto.RegisterFile("types/dymint/dymint.proto", fileDescriptor_fe69c538ded4b87f) } var fileDescriptor_fe69c538ded4b87f = []byte{ - // 646 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x94, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0x97, 0xb5, 0x4b, 0xdb, 0x37, 0xdd, 0x1f, 0x2c, 0x34, 0x65, 0x20, 0x42, 0x57, 0x69, - 0xa8, 0xe3, 0x90, 0x89, 0x21, 0x24, 0xae, 0x0c, 0x90, 0xba, 0x6b, 0x90, 0x38, 0x70, 0xa9, 0xdc, - 0xd8, 0x6a, 0x2c, 0x16, 0x27, 0xb2, 0xdd, 0x69, 0xe3, 0xc8, 0x8d, 0x1b, 0x67, 0x3e, 0x11, 0xc7, - 0x89, 0x13, 0x47, 0xb4, 0x7e, 0x11, 0xe4, 0xd7, 0x4e, 0x1b, 0xb8, 0xb4, 0xf1, 0xf3, 0xfc, 0xe2, - 0xbc, 0x7e, 0xfd, 0xd8, 0x70, 0x64, 0x6e, 0x6b, 0xae, 0xcf, 0xd8, 0x6d, 0x29, 0xa4, 0xf1, 0x7f, - 0x69, 0xad, 0x2a, 0x53, 0x91, 0xd0, 0x8d, 0x1e, 0x1d, 0x3b, 0xc4, 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 0x3b, 0x17, 0x98, 0xef, 0x67, 0x76, 0xb9, 0x76, 0x0d, 0x3e, - 0xc1, 0x7b, 0x4d, 0x82, 0x5d, 0x84, 0x32, 0xef, 0x92, 0x11, 0x74, 0x6d, 0x16, 0x70, 0xdd, 0xd1, - 0xf9, 0xb0, 0xa1, 0xec, 0x82, 0x32, 0x74, 0xc8, 0x19, 0x44, 0xad, 0xa0, 0x61, 0x86, 0x5b, 0xd3, - 0xb9, 0xee, 0x66, 0xb0, 0xc9, 0xdc, 0xf8, 0x87, 0x2d, 0x82, 0x9a, 0xbc, 0xb0, 0x87, 0x43, 0x1b, - 0xaa, 0x6c, 0x9c, 0x5b, 0x9d, 0x8f, 0x50, 0x9b, 0xba, 0xf6, 0x3f, 0x01, 0xe0, 0x92, 0x35, 0x80, - 0x3b, 0x8e, 0x03, 0x2e, 0x99, 0xb7, 0x4f, 0x20, 0xc4, 0xf3, 0xaa, 0x7d, 0x17, 0x76, 0x9b, 0xef, - 0xe2, 0x2a, 0x33, 0x6f, 0x92, 0x09, 0xf4, 0x5c, 0x79, 0x3a, 0xee, 0x22, 0xf7, 0x7f, 0x7d, 0x8d, - 0x7d, 0x31, 0xfd, 0x79, 0x9f, 0x04, 0x77, 0xf7, 0x49, 0xf0, 0xe7, 0x3e, 0x09, 0xbe, 0xaf, 0x92, - 0xad, 0xbb, 0x55, 0xb2, 0xf5, 0x7b, 0x95, 0x6c, 0x7d, 0x4a, 0x17, 0xc2, 0x14, 0xcb, 0x79, 0x9a, - 0x57, 0xa5, 0xbd, 0x76, 0xb8, 0xb4, 0xe7, 0xfb, 0xe6, 0xf6, 0x4b, 0x73, 0x15, 0xb9, 0x4b, 0xa7, - 0x9e, 0xfb, 0xf1, 0x3c, 0xc4, 0x9b, 0xe6, 0xe5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x95, - 0x00, 0xb4, 0xb1, 0x04, 0x00, 0x00, + // 684 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x94, 0x3d, 0x6f, 0xd3, 0x40, + 0x18, 0xc7, 0xeb, 0x26, 0x75, 0x92, 0xc7, 0xe9, 0x0b, 0x27, 0x54, 0xb9, 0xad, 0x30, 0xa9, 0xa5, + 0xa2, 0x94, 0xc1, 0x15, 0x41, 0x48, 0x4c, 0x48, 0x14, 0x90, 0xd2, 0xd5, 0x95, 0x18, 0x58, 0xa2, + 0x8b, 0x7d, 0xb2, 0x4f, 0xd4, 0x2f, 0xba, 0xbb, 0x54, 0x2d, 0x23, 0x1b, 0x1b, 0x33, 0x1b, 0xdf, + 0x86, 0xb1, 0x62, 0x62, 0x44, 0xcd, 0x17, 0x41, 0xf7, 0xdc, 0x39, 0x31, 0xb0, 0x24, 0xbe, 0xff, + 0xff, 0xe7, 0xbb, 0xc7, 0xcf, 0xcb, 0xc1, 0x81, 0xba, 0xad, 0x99, 0x3c, 0x4b, 0x6f, 0x0b, 0x5e, + 0x2a, 0xfb, 0x17, 0xd5, 0xa2, 0x52, 0x15, 0x71, 0xcd, 0xea, 0xf0, 0xd8, 0x20, 0x8a, 0x95, 0x29, + 0x13, 0x88, 0xd1, 0x79, 0xc2, 0xcf, 0x50, 0x35, 0xe8, 0x61, 0xf8, 0x1f, 0x62, 0x85, 0x35, 0x13, + 0x3e, 0x83, 0xde, 0x7b, 0x26, 0x24, 0xaf, 0x4a, 0xf2, 0x10, 0xb6, 0xe6, 0x57, 0x55, 0xf2, 0xd1, + 0x77, 0x46, 0xce, 0xb8, 0x1b, 0x9b, 0x05, 0xd9, 0x83, 0x0e, 0xad, 0x6b, 0x7f, 0x13, 0x35, 0xfd, + 0x18, 0xfe, 0xec, 0x80, 0x3b, 0x65, 0x34, 0x65, 0x82, 0x9c, 0x42, 0xef, 0xda, 0xbc, 0x8d, 0x2f, + 0x79, 0x93, 0xdd, 0xc8, 0x06, 0x6b, 0x37, 0x8d, 0x1b, 0x9f, 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, 0x0c, 0xeb, 0xa6, 0x0d, 0xbf, 0xe9, 0x20, 0xa8, + 0x4a, 0x72, 0x3d, 0x5d, 0x52, 0x51, 0xa1, 0xe7, 0xa1, 0x55, 0x39, 0x0f, 0xb5, 0xa9, 0x29, 0xdf, + 0x23, 0x00, 0x56, 0xa6, 0x0d, 0x60, 0xe6, 0x79, 0xc0, 0xca, 0xd4, 0xda, 0x27, 0xe0, 0xe2, 0xc0, + 0x4b, 0x9b, 0x85, 0xed, 0xe6, 0x5c, 0xfc, 0xca, 0xd8, 0x9a, 0x64, 0x0c, 0x3d, 0x13, 0x9e, 0xf4, + 0xbb, 0xc8, 0xfd, 0x1b, 0x5f, 0x63, 0x9f, 0x4f, 0x7f, 0xdc, 0x07, 0xce, 0xdd, 0x7d, 0xe0, 0xfc, + 0xbe, 0x0f, 0x9c, 0xaf, 0xcb, 0x60, 0xe3, 0x6e, 0x19, 0x6c, 0xfc, 0x5a, 0x06, 0x1b, 0x1f, 0xa2, + 0x8c, 0xab, 0x7c, 0x31, 0x8f, 0x92, 0xaa, 0xd0, 0x77, 0x1b, 0x2b, 0xf5, 0x05, 0x71, 0x73, 0xfb, + 0xa9, 0xb9, 0xef, 0xcc, 0x2d, 0x55, 0xcf, 0xed, 0x7a, 0xee, 0xe2, 0x55, 0xf5, 0xfc, 0x4f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x04, 0xda, 0x66, 0xdf, 0x16, 0x05, 0x00, 0x00, } func (m *Version) Marshal() (dAtA []byte, err error) { @@ -711,6 +722,18 @@ func (m *Commit) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.TmSignature != nil { + { + size, err := m.TmSignature.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDymint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } if len(m.Signatures) > 0 { for iNdEx := len(m.Signatures) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.Signatures[iNdEx]) @@ -1014,6 +1037,10 @@ func (m *Commit) Size() (n int) { n += 1 + l + sovDymint(uint64(l)) } } + if m.TmSignature != nil { + l = m.TmSignature.Size() + n += 1 + l + sovDymint(uint64(l)) + } return n } @@ -1762,6 +1789,42 @@ func (m *Commit) Unmarshal(dAtA []byte) error { m.Signatures = append(m.Signatures, make([]byte, postIndex-iNdEx)) copy(m.Signatures[len(m.Signatures)-1], dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TmSignature", 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 + } + if m.TmSignature == nil { + m.TmSignature = &types.CommitSig{} + } + if err := m.TmSignature.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipDymint(dAtA[iNdEx:]) @@ -1905,7 +1968,7 @@ func (m *Data) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Evidence = append(m.Evidence, &types.Evidence{}) + m.Evidence = append(m.Evidence, &types1.Evidence{}) if err := m.Evidence[len(m.Evidence)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/types/serialization.go b/types/serialization.go index 8cb3266a0..00610b9cd 100644 --- a/types/serialization.go +++ b/types/serialization.go @@ -4,6 +4,7 @@ import ( "errors" abci "github.com/tendermint/tendermint/abci/types" + prototypes "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/tendermint/tendermint/types" pb "github.com/dymensionxyz/dymint/types/pb/dymint" @@ -211,6 +212,12 @@ func (c *Commit) ToProto() *pb.Commit { Height: c.Height, HeaderHash: c.HeaderHash[:], Signatures: signaturesToByteSlices(c.Signatures), + TmSignature: &prototypes.CommitSig{ + BlockIdFlag: prototypes.BlockIDFlag(c.TMSignature.BlockIDFlag), + ValidatorAddress: c.TMSignature.ValidatorAddress, + Timestamp: c.TMSignature.Timestamp, + Signature: c.TMSignature.Signature, + }, } } @@ -221,6 +228,15 @@ func (c *Commit) FromProto(other *pb.Commit) error { return errors.New("invalid length of HeaderHash") } c.Signatures = byteSlicesToSignatures(other.Signatures) + // For backwards compatibility with old state files that don't have this field. + if other.TmSignature != nil { + c.TMSignature = types.CommitSig{ + BlockIDFlag: types.BlockIDFlag(other.TmSignature.BlockIdFlag), + ValidatorAddress: other.TmSignature.ValidatorAddress, + Timestamp: other.TmSignature.Timestamp, + Signature: other.TmSignature.Signature, + } + } return nil }