diff --git a/proto/rollkit/rollkit.proto b/proto/rollkit/rollkit.proto index 69831ee064c..22ff7d1b23a 100644 --- a/proto/rollkit/rollkit.proto +++ b/proto/rollkit/rollkit.proto @@ -77,3 +77,9 @@ message Block { SignedHeader signed_header = 1; Data data = 2; } + +message TxWithISRs { + bytes pre_isr = 1; + bytes tx = 2; + bytes post_isr = 3; +} diff --git a/types/pb/rollkit/rollkit.pb.go b/types/pb/rollkit/rollkit.pb.go index 4940b1ba4ae..b4325f18d13 100644 --- a/types/pb/rollkit/rollkit.pb.go +++ b/types/pb/rollkit/rollkit.pb.go @@ -446,6 +446,66 @@ func (m *Block) GetData() *Data { return nil } +type TxWithISRs struct { + PreIsr []byte `protobuf:"bytes,1,opt,name=pre_isr,json=preIsr,proto3" json:"pre_isr,omitempty"` + Tx []byte `protobuf:"bytes,2,opt,name=tx,proto3" json:"tx,omitempty"` + PostIsr []byte `protobuf:"bytes,3,opt,name=post_isr,json=postIsr,proto3" json:"post_isr,omitempty"` +} + +func (m *TxWithISRs) Reset() { *m = TxWithISRs{} } +func (m *TxWithISRs) String() string { return proto.CompactTextString(m) } +func (*TxWithISRs) ProtoMessage() {} +func (*TxWithISRs) Descriptor() ([]byte, []int) { + return fileDescriptor_ed489fb7f4d78b3f, []int{6} +} +func (m *TxWithISRs) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TxWithISRs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TxWithISRs.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 *TxWithISRs) XXX_Merge(src proto.Message) { + xxx_messageInfo_TxWithISRs.Merge(m, src) +} +func (m *TxWithISRs) XXX_Size() int { + return m.Size() +} +func (m *TxWithISRs) XXX_DiscardUnknown() { + xxx_messageInfo_TxWithISRs.DiscardUnknown(m) +} + +var xxx_messageInfo_TxWithISRs proto.InternalMessageInfo + +func (m *TxWithISRs) GetPreIsr() []byte { + if m != nil { + return m.PreIsr + } + return nil +} + +func (m *TxWithISRs) GetTx() []byte { + if m != nil { + return m.Tx + } + return nil +} + +func (m *TxWithISRs) GetPostIsr() []byte { + if m != nil { + return m.PostIsr + } + return nil +} + func init() { proto.RegisterType((*Version)(nil), "rollkit.Version") proto.RegisterType((*Header)(nil), "rollkit.Header") @@ -453,51 +513,55 @@ func init() { proto.RegisterType((*SignedHeader)(nil), "rollkit.SignedHeader") proto.RegisterType((*Data)(nil), "rollkit.Data") proto.RegisterType((*Block)(nil), "rollkit.Block") + proto.RegisterType((*TxWithISRs)(nil), "rollkit.TxWithISRs") } func init() { proto.RegisterFile("rollkit/rollkit.proto", fileDescriptor_ed489fb7f4d78b3f) } var fileDescriptor_ed489fb7f4d78b3f = []byte{ - // 609 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x94, 0x4f, 0x6f, 0xd3, 0x3e, - 0x18, 0xc7, 0x97, 0xb5, 0x6b, 0xbb, 0xa7, 0xdd, 0xd6, 0x9f, 0xf5, 0xdb, 0x94, 0x6d, 0x52, 0x54, - 0x2a, 0x21, 0xc2, 0x90, 0x5a, 0x31, 0x84, 0x84, 0x38, 0x20, 0x31, 0x98, 0x34, 0xae, 0x9e, 0xb4, - 0x03, 0x97, 0xca, 0x4d, 0x4c, 0x62, 0xad, 0x89, 0x23, 0xdb, 0x9d, 0xe0, 0x25, 0x70, 0xe3, 0x25, - 0xf0, 0x12, 0x78, 0x19, 0x1c, 0x77, 0xe4, 0x88, 0xb6, 0x37, 0x82, 0xfc, 0xd8, 0xc9, 0x02, 0x97, - 0xd6, 0xfe, 0x7e, 0x3f, 0xfe, 0xf7, 0xfc, 0x09, 0xec, 0x2b, 0xb9, 0x5a, 0x5d, 0x0b, 0x33, 0xf7, - 0xff, 0xb3, 0x4a, 0x49, 0x23, 0x49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0c, 0x5f, 0x68, 0x63, 0x7f, 0x95, 0x94, 0x46, 0x87, 0x9b, 0x88, 0x1d, 0xb4, 0xfd, - 0x4b, 0x6b, 0x53, 0xeb, 0x92, 0x97, 0x30, 0xe0, 0x37, 0x22, 0xe5, 0x65, 0x62, 0x2b, 0xb1, 0x13, - 0x0f, 0x4f, 0x0f, 0xdb, 0x57, 0xb2, 0x9d, 0x35, 0x3b, 0xf7, 0x00, 0x6d, 0xd0, 0xe9, 0x27, 0xd8, - 0x3a, 0xc3, 0x36, 0x79, 0x0d, 0x3b, 0x1a, 0xc3, 0xb6, 0xf8, 0x2b, 0x5a, 0xfb, 0x4d, 0x10, 0xda, - 0x41, 0xa5, 0x23, 0xdd, 0x0e, 0xf1, 0x23, 0xe8, 0xda, 0x42, 0xf4, 0x71, 0xdb, 0x69, 0x96, 0xd8, - 0x47, 0x52, 0xb4, 0xce, 0xce, 0x7f, 0xde, 0x45, 0xc1, 0xed, 0x5d, 0x14, 0xfc, 0xbe, 0x8b, 0x82, - 0x6f, 0xf7, 0xd1, 0xc6, 0xed, 0x7d, 0xb4, 0xf1, 0xeb, 0x3e, 0xda, 0xf8, 0xf8, 0x2c, 0x13, 0x26, - 0x5f, 0x2f, 0x67, 0x89, 0x2c, 0xe6, 0xff, 0x7c, 0x2a, 0x7c, 0xcb, 0x57, 0xcb, 0x5a, 0x58, 0xf6, - 0xb0, 0xe9, 0x5f, 0xfc, 0x09, 0x00, 0x00, 0xff, 0xff, 0x47, 0x6a, 0xe8, 0x8b, 0x55, 0x04, 0x00, - 0x00, + // 664 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x94, 0xcf, 0x6a, 0xdb, 0x4a, + 0x14, 0xc6, 0x23, 0xdb, 0xb1, 0x9d, 0x63, 0x27, 0xf1, 0x1d, 0x6e, 0x72, 0x95, 0x04, 0x84, 0xaf, + 0xe1, 0x72, 0xdd, 0x14, 0x6c, 0x9a, 0x52, 0x28, 0x5d, 0x14, 0x9a, 0x36, 0x10, 0xef, 0xca, 0xb8, + 0xa4, 0xd0, 0x8d, 0x18, 0x4b, 0x53, 0x69, 0x88, 0xad, 0x19, 0x66, 0xc6, 0xc1, 0x7d, 0x84, 0xee, + 0xfa, 0x08, 0x7d, 0x84, 0x3e, 0x46, 0x97, 0x59, 0x76, 0x59, 0x92, 0x17, 0x29, 0xf3, 0x47, 0x8a, + 0xda, 0x8d, 0x3d, 0xe7, 0xfb, 0x7e, 0x73, 0x66, 0x74, 0xce, 0x91, 0xe0, 0x40, 0xf2, 0xe5, 0xf2, + 0x9a, 0xe9, 0xa9, 0xff, 0x9f, 0x08, 0xc9, 0x35, 0x47, 0x1d, 0x1f, 0x1e, 0x9f, 0x68, 0x5a, 0xa4, + 0x54, 0xae, 0x58, 0xa1, 0xa7, 0x64, 0x91, 0xb0, 0xa9, 0xfe, 0x24, 0xa8, 0x72, 0xd4, 0xf1, 0xb0, + 0x66, 0x5a, 0x7d, 0x7a, 0x43, 0x96, 0x2c, 0x25, 0x9a, 0x4b, 0x47, 0x8c, 0x9e, 0x40, 0xe7, 0x8a, + 0x4a, 0xc5, 0x78, 0x81, 0xfe, 0x86, 0xed, 0xc5, 0x92, 0x27, 0xd7, 0x61, 0x30, 0x0c, 0xc6, 0x2d, + 0xec, 0x02, 0x34, 0x80, 0x26, 0x11, 0x22, 0x6c, 0x58, 0xcd, 0x2c, 0x47, 0xdf, 0x9a, 0xd0, 0xbe, + 0xa4, 0x24, 0xa5, 0x12, 0x9d, 0x42, 0xe7, 0xc6, 0xed, 0xb6, 0x9b, 0x7a, 0x67, 0x83, 0x49, 0x79, + 0x4d, 0x9f, 0x15, 0x97, 0x00, 0x3a, 0x84, 0x76, 0x4e, 0x59, 0x96, 0x6b, 0x9f, 0xcb, 0x47, 0x08, + 0x41, 0x4b, 0xb3, 0x15, 0x0d, 0x9b, 0x56, 0xb5, 0x6b, 0x34, 0x86, 0x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0x4f, 0x1f, 0x37, 0xf4, 0xc6, 0x8c, 0x84, 0xe0, + 0x4a, 0x5b, 0xb2, 0xe9, 0xe6, 0xd5, 0xc4, 0x33, 0x25, 0xcf, 0x2f, 0xbe, 0xdf, 0x45, 0xc1, 0xed, + 0x5d, 0x14, 0xfc, 0xbc, 0x8b, 0x82, 0x2f, 0xf7, 0xd1, 0xd6, 0xed, 0x7d, 0xb4, 0xf5, 0xe3, 0x3e, + 0xda, 0xfa, 0xf0, 0x38, 0x63, 0x3a, 0x5f, 0x2f, 0x26, 0x09, 0x5f, 0x4d, 0xff, 0xf8, 0xf8, 0xf8, + 0x8f, 0x88, 0x58, 0x94, 0xc2, 0xa2, 0x6d, 0x3f, 0x23, 0x4f, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, + 0x66, 0x93, 0xdd, 0xfe, 0xa7, 0x04, 0x00, 0x00, } func (m *Version) Marshal() (dAtA []byte, err error) { @@ -834,6 +898,50 @@ func (m *Block) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TxWithISRs) 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 *TxWithISRs) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TxWithISRs) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PostIsr) > 0 { + i -= len(m.PostIsr) + copy(dAtA[i:], m.PostIsr) + i = encodeVarintRollkit(dAtA, i, uint64(len(m.PostIsr))) + i-- + dAtA[i] = 0x1a + } + if len(m.Tx) > 0 { + i -= len(m.Tx) + copy(dAtA[i:], m.Tx) + i = encodeVarintRollkit(dAtA, i, uint64(len(m.Tx))) + i-- + dAtA[i] = 0x12 + } + if len(m.PreIsr) > 0 { + i -= len(m.PreIsr) + copy(dAtA[i:], m.PreIsr) + i = encodeVarintRollkit(dAtA, i, uint64(len(m.PreIsr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintRollkit(dAtA []byte, offset int, v uint64) int { offset -= sovRollkit(v) base := offset @@ -995,6 +1103,27 @@ func (m *Block) Size() (n int) { return n } +func (m *TxWithISRs) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PreIsr) + if l > 0 { + n += 1 + l + sovRollkit(uint64(l)) + } + l = len(m.Tx) + if l > 0 { + n += 1 + l + sovRollkit(uint64(l)) + } + l = len(m.PostIsr) + if l > 0 { + n += 1 + l + sovRollkit(uint64(l)) + } + return n +} + func sovRollkit(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2027,6 +2156,158 @@ func (m *Block) Unmarshal(dAtA []byte) error { } return nil } +func (m *TxWithISRs) 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 ErrIntOverflowRollkit + } + 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: TxWithISRs: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TxWithISRs: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PreIsr", 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.PreIsr = append(m.PreIsr[:0], dAtA[iNdEx:postIndex]...) + if m.PreIsr == nil { + m.PreIsr = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tx", 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.Tx = append(m.Tx[:0], dAtA[iNdEx:postIndex]...) + if m.Tx == nil { + m.Tx = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PostIsr", 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.PostIsr = append(m.PostIsr[:0], dAtA[iNdEx:postIndex]...) + if m.PostIsr == nil { + m.PostIsr = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRollkit(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRollkit + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipRollkit(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/types/tx.go b/types/tx.go index 46eef82e863..820d3ddcc53 100644 --- a/types/tx.go +++ b/types/tx.go @@ -1,9 +1,13 @@ package types import ( + "fmt" + "github.com/tendermint/tendermint/crypto/merkle" "github.com/tendermint/tendermint/crypto/tmhash" tmbytes "github.com/tendermint/tendermint/libs/bytes" + + pb "github.com/rollkit/rollkit/types/pb/rollkit" ) // Tx represents transactoin. @@ -41,3 +45,22 @@ type TxProof struct { Data Tx `json:"data"` Proof merkle.Proof `json:"proof"` } + +// ToTxsWithISRs converts a slice of transactions and a list of intermediate state roots +// to a slice of TxWithISRs. Note that the length of intermediateStateRoots is +// equal to the length of txs + 1. +func (txs Txs) ToTxsWithISRs(intermediateStateRoots IntermediateStateRoots) ([]pb.TxWithISRs, error) { + expectedISRListLength := len(txs) + 1 + if len(intermediateStateRoots.RawRootsList) != expectedISRListLength { + return nil, fmt.Errorf("invalid length of ISR list: %d, expected length: %d", len(intermediateStateRoots.RawRootsList), expectedISRListLength) + } + txsWithISRs := make([]pb.TxWithISRs, 0, len(txs)) + for i, tx := range txs { + txsWithISRs[i] = pb.TxWithISRs{ + PreIsr: intermediateStateRoots.RawRootsList[i], + Tx: tx, + PostIsr: intermediateStateRoots.RawRootsList[i+1], + } + } + return txsWithISRs, nil +}