From b82de975a97ba079aa8ff6d746eea0567c86adbf Mon Sep 17 00:00:00 2001 From: Manav Aggarwal Date: Thu, 26 Jan 2023 11:04:49 -0500 Subject: [PATCH] Remove namespace ID from header (#718) Closes: #690. --- proto/rollkit/rollkit.proto | 24 ++-- state/executor.go | 1 - types/header.go | 4 - types/pb/rollkit/rollkit.pb.go | 193 ++++++++++++--------------------- types/serialization.go | 16 --- types/serialization_test.go | 1 - 6 files changed, 80 insertions(+), 159 deletions(-) diff --git a/proto/rollkit/rollkit.proto b/proto/rollkit/rollkit.proto index 67082dc3672..abd174f272b 100644 --- a/proto/rollkit/rollkit.proto +++ b/proto/rollkit/rollkit.proto @@ -15,48 +15,46 @@ message Version { message Header { // Block and App version Version version = 1; - // NamespaceID identifies this chain e.g. when connected to other rollups via IBC. - bytes namespace_id = 2; // Block height - uint64 height = 3; + uint64 height = 2; // Block creation time - uint64 time = 4; + uint64 time = 3; // Previous block info - bytes last_header_hash = 5; + bytes last_header_hash = 4; // Commit from aggregator(s) from the last block - bytes last_commit_hash = 6; + bytes last_commit_hash = 5; // Block.Data root aka Transactions - bytes data_hash = 7; + bytes data_hash = 6; // Consensus params for current block - bytes consensus_hash = 8; + bytes consensus_hash = 7; // State after applying txs from the current block - bytes app_hash = 9; + bytes app_hash = 8; // Root hash of all results from the txs from the previous block. // This is ABCI specific but smart-contract chains require some way of committing // to transaction receipts/results. - bytes last_results_hash = 10; + bytes last_results_hash = 9; // Original proposer of the block // Note that the address can be derived from the pubkey which can be derived // from the signature when using secp256k. // We keep this in case users choose another signature format where the // pubkey can't be recovered by the signature (e.g. ed25519). - bytes proposer_address = 11; + bytes proposer_address = 10; // Hash of block aggregator set, at a time of block creation - bytes aggregators_hash = 12; + bytes aggregators_hash = 11; // Chain ID the block belongs to - string chain_id = 13; + string chain_id = 12; } message Commit { diff --git a/state/executor.go b/state/executor.go index 5974b38d7e2..c65f891d327 100644 --- a/state/executor.go +++ b/state/executor.go @@ -109,7 +109,6 @@ func (e *BlockExecutor) CreateBlock(height uint64, lastCommit *types.Commit, las Height: height, Time: uint64(time.Now().Unix()), // TODO(tzdybal): how to get TAI64? }, - NamespaceID: e.namespaceID, //LastHeaderHash: lastHeaderHash, //LastCommitHash: lastCommitHash, DataHash: make(types.Hash, 32), diff --git a/types/header.go b/types/header.go index 805b51cdeed..21614b174e6 100644 --- a/types/header.go +++ b/types/header.go @@ -26,10 +26,6 @@ type Header struct { BaseHeader // Block and App version Version Version - // NamespaceID identifies this chain e.g. when connected to other rollups via IBC. - // TODO(ismail): figure out if we want to use namespace.ID here instead (downside is that it isn't fixed size) - // at least extract the used constants (32, 8) as package variables though. - NamespaceID NamespaceID // prev block info LastHeaderHash Hash diff --git a/types/pb/rollkit/rollkit.pb.go b/types/pb/rollkit/rollkit.pb.go index 8b922b724a6..862d3432649 100644 --- a/types/pb/rollkit/rollkit.pb.go +++ b/types/pb/rollkit/rollkit.pb.go @@ -82,36 +82,34 @@ func (m *Version) GetApp() uint64 { type Header struct { // Block and App version Version *Version `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` - // NamespaceID identifies this chain e.g. when connected to other rollups via IBC. - NamespaceId []byte `protobuf:"bytes,2,opt,name=namespace_id,json=namespaceId,proto3" json:"namespace_id,omitempty"` // Block height - Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` // Block creation time - Time uint64 `protobuf:"varint,4,opt,name=time,proto3" json:"time,omitempty"` + Time uint64 `protobuf:"varint,3,opt,name=time,proto3" json:"time,omitempty"` // Previous block info - LastHeaderHash []byte `protobuf:"bytes,5,opt,name=last_header_hash,json=lastHeaderHash,proto3" json:"last_header_hash,omitempty"` + LastHeaderHash []byte `protobuf:"bytes,4,opt,name=last_header_hash,json=lastHeaderHash,proto3" json:"last_header_hash,omitempty"` // Commit from aggregator(s) from the last block - LastCommitHash []byte `protobuf:"bytes,6,opt,name=last_commit_hash,json=lastCommitHash,proto3" json:"last_commit_hash,omitempty"` + LastCommitHash []byte `protobuf:"bytes,5,opt,name=last_commit_hash,json=lastCommitHash,proto3" json:"last_commit_hash,omitempty"` // Block.Data root aka Transactions - DataHash []byte `protobuf:"bytes,7,opt,name=data_hash,json=dataHash,proto3" json:"data_hash,omitempty"` + DataHash []byte `protobuf:"bytes,6,opt,name=data_hash,json=dataHash,proto3" json:"data_hash,omitempty"` // Consensus params for current block - ConsensusHash []byte `protobuf:"bytes,8,opt,name=consensus_hash,json=consensusHash,proto3" json:"consensus_hash,omitempty"` + ConsensusHash []byte `protobuf:"bytes,7,opt,name=consensus_hash,json=consensusHash,proto3" json:"consensus_hash,omitempty"` // State after applying txs from the current block - AppHash []byte `protobuf:"bytes,9,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` + AppHash []byte `protobuf:"bytes,8,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` // Root hash of all results from the txs from the previous block. // This is ABCI specific but smart-contract chains require some way of committing // to transaction receipts/results. - LastResultsHash []byte `protobuf:"bytes,10,opt,name=last_results_hash,json=lastResultsHash,proto3" json:"last_results_hash,omitempty"` + LastResultsHash []byte `protobuf:"bytes,9,opt,name=last_results_hash,json=lastResultsHash,proto3" json:"last_results_hash,omitempty"` // Original proposer of the block // Note that the address can be derived from the pubkey which can be derived // from the signature when using secp256k. // We keep this in case users choose another signature format where the // pubkey can't be recovered by the signature (e.g. ed25519). - ProposerAddress []byte `protobuf:"bytes,11,opt,name=proposer_address,json=proposerAddress,proto3" json:"proposer_address,omitempty"` + ProposerAddress []byte `protobuf:"bytes,10,opt,name=proposer_address,json=proposerAddress,proto3" json:"proposer_address,omitempty"` // Hash of block aggregator set, at a time of block creation - AggregatorsHash []byte `protobuf:"bytes,12,opt,name=aggregators_hash,json=aggregatorsHash,proto3" json:"aggregators_hash,omitempty"` + AggregatorsHash []byte `protobuf:"bytes,11,opt,name=aggregators_hash,json=aggregatorsHash,proto3" json:"aggregators_hash,omitempty"` // Chain ID the block belongs to - ChainId string `protobuf:"bytes,13,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + ChainId string `protobuf:"bytes,12,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` } func (m *Header) Reset() { *m = Header{} } @@ -154,13 +152,6 @@ func (m *Header) GetVersion() *Version { return nil } -func (m *Header) GetNamespaceId() []byte { - if m != nil { - return m.NamespaceId - } - return nil -} - func (m *Header) GetHeight() uint64 { if m != nil { return m.Height @@ -483,45 +474,44 @@ func init() { func init() { proto.RegisterFile("rollkit/rollkit.proto", fileDescriptor_ed489fb7f4d78b3f) } var fileDescriptor_ed489fb7f4d78b3f = []byte{ - // 603 bytes of a gzipped FileDescriptorProto + // 587 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xc7, 0x97, 0xb5, 0x6b, 0xbb, 0xd7, 0x6e, 0x2b, 0x16, 0x4c, 0x19, 0x93, 0xc2, 0x16, 0x09, - 0x31, 0x86, 0x94, 0xc2, 0x10, 0x12, 0x57, 0x06, 0x93, 0xb6, 0x6b, 0x26, 0x71, 0xe0, 0x52, 0xdc, - 0xc4, 0x4a, 0xac, 0x35, 0xb1, 0x65, 0xbb, 0x13, 0x7c, 0x00, 0x0e, 0xdc, 0xf8, 0x58, 0x1c, 0x27, - 0x71, 0xe1, 0x88, 0xb6, 0x2f, 0x82, 0xfc, 0xec, 0xa6, 0x01, 0x71, 0xe0, 0xd2, 0xda, 0xff, 0xff, - 0x2f, 0xcf, 0xcf, 0xcf, 0xcf, 0x86, 0x07, 0x4a, 0xcc, 0xe7, 0x57, 0xdc, 0x4c, 0xfc, 0x7f, 0x22, - 0x95, 0x30, 0x82, 0xf4, 0xfd, 0xf4, 0xe1, 0xbe, 0x61, 0x75, 0xce, 0x54, 0xc5, 0x6b, 0x33, 0xa1, - 0x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, 0x64, 0xb5, 0xa6, 0xb2, 0xa2, 0x39, 0x23, 0x9a, 0x4e, 0x95, 0x36, + 0xbf, 0x92, 0x73, 0xad, 0xc2, 0x5d, 0xc4, 0x8e, 0x9a, 0xfe, 0x95, 0xb1, 0x53, 0xe3, 0x06, 0x2f, + 0xa1, 0x4b, 0x6f, 0x58, 0x4e, 0xeb, 0x8c, 0xe2, 0xa6, 0xfa, 0x67, 0xc7, 0xc9, 0xb6, 0x5f, 0x12, + 0xd3, 0x2f, 0xc9, 0x85, 0x03, 0xd2, 0x0d, 0x1a, 0x7f, 0xf1, 0x60, 0xef, 0x1c, 0xfb, 0xe3, 0xbf, + 0xf7, 0xf9, 0x10, 0xda, 0xa6, 0xdc, 0xdc, 0x2e, 0xf7, 0x37, 0x98, 0xd9, 0x52, 0x8a, 0x56, 0xf0, + 0x0c, 0xfa, 0x8d, 0x62, 0xc6, 0x8e, 0xf8, 0xc7, 0x79, 0xc0, 0xb6, 0xb0, 0xcf, 0x2f, 0x7e, 0x2c, + 0x23, 0xef, 0x76, 0x19, 0x79, 0xbf, 0x96, 0x91, 0xf7, 0x6d, 0x15, 0xed, 0xdc, 0xae, 0xa2, 0x9d, + 0x9f, 0xab, 0x68, 0xe7, 0xc3, 0xd3, 0x82, 0xe9, 0x72, 0x31, 0x4b, 0x32, 0x5e, 0x4d, 0xfe, 0x7a, + 0x20, 0xec, 0x03, 0x30, 0x11, 0xb3, 0xb5, 0x30, 0xeb, 0xe0, 0x63, 0xf0, 0xe2, 0x77, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x10, 0x12, 0xe8, 0xcc, 0x4b, 0x04, 0x00, 0x00, } func (m *Version) Marshal() (dAtA []byte, err error) { @@ -582,80 +572,73 @@ func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.ChainId) i = encodeVarintRollkit(dAtA, i, uint64(len(m.ChainId))) i-- - dAtA[i] = 0x6a + dAtA[i] = 0x62 } if len(m.AggregatorsHash) > 0 { i -= len(m.AggregatorsHash) copy(dAtA[i:], m.AggregatorsHash) i = encodeVarintRollkit(dAtA, i, uint64(len(m.AggregatorsHash))) i-- - dAtA[i] = 0x62 + dAtA[i] = 0x5a } if len(m.ProposerAddress) > 0 { i -= len(m.ProposerAddress) copy(dAtA[i:], m.ProposerAddress) i = encodeVarintRollkit(dAtA, i, uint64(len(m.ProposerAddress))) i-- - dAtA[i] = 0x5a + dAtA[i] = 0x52 } if len(m.LastResultsHash) > 0 { i -= len(m.LastResultsHash) copy(dAtA[i:], m.LastResultsHash) i = encodeVarintRollkit(dAtA, i, uint64(len(m.LastResultsHash))) i-- - dAtA[i] = 0x52 + dAtA[i] = 0x4a } if len(m.AppHash) > 0 { i -= len(m.AppHash) copy(dAtA[i:], m.AppHash) i = encodeVarintRollkit(dAtA, i, uint64(len(m.AppHash))) i-- - dAtA[i] = 0x4a + dAtA[i] = 0x42 } if len(m.ConsensusHash) > 0 { i -= len(m.ConsensusHash) copy(dAtA[i:], m.ConsensusHash) i = encodeVarintRollkit(dAtA, i, uint64(len(m.ConsensusHash))) i-- - dAtA[i] = 0x42 + dAtA[i] = 0x3a } if len(m.DataHash) > 0 { i -= len(m.DataHash) copy(dAtA[i:], m.DataHash) i = encodeVarintRollkit(dAtA, i, uint64(len(m.DataHash))) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x32 } if len(m.LastCommitHash) > 0 { i -= len(m.LastCommitHash) copy(dAtA[i:], m.LastCommitHash) i = encodeVarintRollkit(dAtA, i, uint64(len(m.LastCommitHash))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x2a } if len(m.LastHeaderHash) > 0 { i -= len(m.LastHeaderHash) copy(dAtA[i:], m.LastHeaderHash) i = encodeVarintRollkit(dAtA, i, uint64(len(m.LastHeaderHash))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x22 } if m.Time != 0 { i = encodeVarintRollkit(dAtA, i, uint64(m.Time)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x18 } if m.Height != 0 { i = encodeVarintRollkit(dAtA, i, uint64(m.Height)) i-- - dAtA[i] = 0x18 - } - if len(m.NamespaceId) > 0 { - i -= len(m.NamespaceId) - copy(dAtA[i:], m.NamespaceId) - i = encodeVarintRollkit(dAtA, i, uint64(len(m.NamespaceId))) - i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if m.Version != nil { { @@ -913,10 +896,6 @@ func (m *Header) Size() (n int) { l = m.Version.Size() n += 1 + l + sovRollkit(uint64(l)) } - l = len(m.NamespaceId) - if l > 0 { - n += 1 + l + sovRollkit(uint64(l)) - } if m.Height != 0 { n += 1 + sovRollkit(uint64(m.Height)) } @@ -1209,40 +1188,6 @@ func (m *Header) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NamespaceId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRollkit - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthRollkit - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthRollkit - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.NamespaceId = append(m.NamespaceId[:0], dAtA[iNdEx:postIndex]...) - if m.NamespaceId == nil { - m.NamespaceId = []byte{} - } - iNdEx = postIndex - case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) } @@ -1261,7 +1206,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { break } } - case 4: + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) } @@ -1280,7 +1225,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { break } } - case 5: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastHeaderHash", wireType) } @@ -1314,7 +1259,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { m.LastHeaderHash = []byte{} } iNdEx = postIndex - case 6: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastCommitHash", wireType) } @@ -1348,7 +1293,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { m.LastCommitHash = []byte{} } iNdEx = postIndex - case 7: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DataHash", wireType) } @@ -1382,7 +1327,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { m.DataHash = []byte{} } iNdEx = postIndex - case 8: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsensusHash", wireType) } @@ -1416,7 +1361,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { m.ConsensusHash = []byte{} } iNdEx = postIndex - case 9: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AppHash", wireType) } @@ -1450,7 +1395,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { m.AppHash = []byte{} } iNdEx = postIndex - case 10: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastResultsHash", wireType) } @@ -1484,7 +1429,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { m.LastResultsHash = []byte{} } iNdEx = postIndex - case 11: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProposerAddress", wireType) } @@ -1518,7 +1463,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { m.ProposerAddress = []byte{} } iNdEx = postIndex - case 12: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AggregatorsHash", wireType) } @@ -1552,7 +1497,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { m.AggregatorsHash = []byte{} } iNdEx = postIndex - case 13: + case 12: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) } diff --git a/types/serialization.go b/types/serialization.go index 6061991e74b..dbf17451aa1 100644 --- a/types/serialization.go +++ b/types/serialization.go @@ -1,8 +1,6 @@ package types import ( - "errors" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/types" @@ -109,7 +107,6 @@ func (h *Header) ToProto() *pb.Header { Block: h.Version.Block, App: h.Version.App, }, - NamespaceId: h.NamespaceID[:], Height: h.BaseHeader.Height, Time: h.BaseHeader.Time, LastHeaderHash: h.LastHeaderHash[:], @@ -129,9 +126,6 @@ func (h *Header) FromProto(other *pb.Header) error { h.Version.Block = other.Version.Block h.Version.App = other.Version.App h.BaseHeader.ChainID = other.ChainId - if !safeCopy(h.NamespaceID[:], other.NamespaceId) { - return errors.New("invalid length of 'NamespaceId'") - } h.BaseHeader.Height = other.Height h.BaseHeader.Time = other.Time h.LastHeaderHash = other.LastHeaderHash @@ -149,16 +143,6 @@ func (h *Header) FromProto(other *pb.Header) error { return nil } -// safeCopy copies bytes from src slice into dst slice if both have same size. -// It returns true if sizes of src and dst are the same. -func safeCopy(dst, src []byte) bool { - if len(src) != len(dst) { - return false - } - _ = copy(dst, src) - return true -} - // ToProto converts Block into protobuf representation and returns it. func (b *Block) ToProto() *pb.Block { return &pb.Block{ diff --git a/types/serialization_test.go b/types/serialization_test.go index 4001f6232af..1a09b2d6d31 100644 --- a/types/serialization_test.go +++ b/types/serialization_test.go @@ -43,7 +43,6 @@ func TestBlockSerializationRoundTrip(t *testing.T) { Block: 1, App: 2, }, - NamespaceID: NamespaceID{0, 1, 2, 3, 4, 5, 6, 7}, BaseHeader: BaseHeader{ Height: 3, Time: 4567,