From 158ecb057f1c335ede4fce50fb4992e086feb8eb Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Fri, 8 Sep 2023 14:47:37 +0300 Subject: [PATCH 01/27] inner transactions on transaction --- data/interface.go | 1 + data/transaction/apiTransactionResult.go | 1 + data/transaction/frontendTransaction.go | 31 ++--- data/transaction/transaction.go | 58 +++++++--- data/transaction/transaction.pb.go | 137 ++++++++++++++++------- data/transaction/transaction.proto | 1 + data/transaction/transaction_test.go | 107 +++++++++++++++--- 7 files changed, 256 insertions(+), 80 deletions(-) diff --git a/data/interface.go b/data/interface.go index 80b039da2..748868fe7 100644 --- a/data/interface.go +++ b/data/interface.go @@ -296,6 +296,7 @@ type Encoder interface { // Marshaller is able to encode an object to its byte slice representation type Marshaller interface { Marshal(obj interface{}) ([]byte, error) + Unmarshal(obj interface{}, buff []byte) error IsInterfaceNil() bool } diff --git a/data/transaction/apiTransactionResult.go b/data/transaction/apiTransactionResult.go index ca9671b10..8f619d064 100644 --- a/data/transaction/apiTransactionResult.go +++ b/data/transaction/apiTransactionResult.go @@ -69,6 +69,7 @@ type ApiTransactionResult struct { Options uint32 `json:"options"` GuardianAddr string `json:"guardian,omitempty"` GuardianSignature string `json:"guardianSignature,omitempty"` + InnerTransactions []data.TransactionHandler `json:"innerTransactions,omitempty"` } // ApiSmartContractResult represents a smart contract result with changed fields' types in order to make it friendly for API's json diff --git a/data/transaction/frontendTransaction.go b/data/transaction/frontendTransaction.go index b5b55c2a4..8b706e767 100644 --- a/data/transaction/frontendTransaction.go +++ b/data/transaction/frontendTransaction.go @@ -2,19 +2,20 @@ package transaction // FrontendTransaction represents the DTO used in transaction signing/validation. type FrontendTransaction struct { - Nonce uint64 `json:"nonce"` - Value string `json:"value"` - Receiver string `json:"receiver"` - Sender string `json:"sender"` - SenderUsername []byte `json:"senderUsername,omitempty"` - ReceiverUsername []byte `json:"receiverUsername,omitempty"` - GasPrice uint64 `json:"gasPrice"` - GasLimit uint64 `json:"gasLimit"` - Data []byte `json:"data,omitempty"` - Signature string `json:"signature,omitempty"` - ChainID string `json:"chainID"` - Version uint32 `json:"version"` - Options uint32 `json:"options,omitempty"` - GuardianAddr string `json:"guardian,omitempty"` - GuardianSignature string `json:"guardianSignature,omitempty"` + Nonce uint64 `json:"nonce"` + Value string `json:"value"` + Receiver string `json:"receiver"` + Sender string `json:"sender"` + SenderUsername []byte `json:"senderUsername,omitempty"` + ReceiverUsername []byte `json:"receiverUsername,omitempty"` + GasPrice uint64 `json:"gasPrice"` + GasLimit uint64 `json:"gasLimit"` + Data []byte `json:"data,omitempty"` + Signature string `json:"signature,omitempty"` + ChainID string `json:"chainID"` + Version uint32 `json:"version"` + Options uint32 `json:"options,omitempty"` + GuardianAddr string `json:"guardian,omitempty"` + GuardianSignature string `json:"guardianSignature,omitempty"` + InnerTransactions []*FrontendTransaction `json:"innerTransactions,omitempty"` } diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index b5b42531c..83f78153d 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -2,6 +2,7 @@ package transaction import ( + "encoding/hex" "math/big" "github.com/multiversx/mx-chain-core-go/core" @@ -36,6 +37,11 @@ func (tx *Transaction) SetSndAddr(addr []byte) { tx.SndAddr = addr } +// SetInnerTransactions sets the inner transactions of the transaction +func (tx *Transaction) SetInnerTransactions(innerTransactions []byte) { + tx.InnerTransactions = innerTransactions +} + // TrimSlicePtr creates a copy of the provided slice without the excess capacity func TrimSlicePtr(in []*Transaction) []*Transaction { if len(in) == 0 { @@ -68,6 +74,44 @@ func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.M return nil, ErrNilHasher } + ftx, err := tx.prepareTx(encoder) + if err != nil { + return nil, err + } + + innerTxs := make([]*Transaction, 0) + err = marshaller.Unmarshal(&innerTxs, tx.InnerTransactions) + if err != nil { + return nil, err + } + for _, innerTx := range innerTxs { + innerFtx, innerErr := innerTx.prepareTx(encoder) + if innerErr != nil { + return nil, err + } + + innerFtx.Signature = hex.EncodeToString(innerTx.Signature) + innerFtx.GuardianSignature = hex.EncodeToString(innerTx.GuardianSignature) + + ftx.InnerTransactions = append(ftx.InnerTransactions, innerFtx) + } + + ftxBytes, err := marshaller.Marshal(ftx) + if err != nil { + return nil, err + } + + shouldSignOnTxHash := tx.Version > core.InitialVersionOfTransaction && tx.HasOptionHashSignSet() + if !shouldSignOnTxHash { + return ftxBytes, nil + } + + ftxHash := hasher.Compute(string(ftxBytes)) + + return ftxHash, nil +} + +func (tx *Transaction) prepareTx(encoder data.Encoder) (*FrontendTransaction, error) { receiverAddr, err := encoder.Encode(tx.RcvAddr) if err != nil { return nil, err @@ -102,19 +146,7 @@ func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.M ftx.GuardianAddr = guardianAddr } - ftxBytes, err := marshaller.Marshal(ftx) - if err != nil { - return nil, err - } - - shouldSignOnTxHash := tx.Version > core.InitialVersionOfTransaction && tx.HasOptionHashSignSet() - if !shouldSignOnTxHash { - return ftxBytes, nil - } - - ftxHash := hasher.Compute(string(ftxBytes)) - - return ftxHash, nil + return ftx, nil } // HasOptionGuardianSet returns true if the guarded transaction option is set diff --git a/data/transaction/transaction.pb.go b/data/transaction/transaction.pb.go index a8b2dd871..c6dfba036 100644 --- a/data/transaction/transaction.pb.go +++ b/data/transaction/transaction.pb.go @@ -45,6 +45,7 @@ type Transaction struct { Options uint32 `protobuf:"varint,13,opt,name=Options,proto3" json:"options,omitempty"` GuardianAddr []byte `protobuf:"bytes,14,opt,name=GuardianAddr,proto3" json:"guardian,omitempty"` GuardianSignature []byte `protobuf:"bytes,15,opt,name=GuardianSignature,proto3" json:"guardianSignature,omitempty"` + InnerTransactions []byte `protobuf:"bytes,16,opt,name=InnerTransactions,proto3" json:"innerTransactions,omitempty"` } func (m *Transaction) Reset() { *m = Transaction{} } @@ -180,6 +181,13 @@ func (m *Transaction) GetGuardianSignature() []byte { return nil } +func (m *Transaction) GetInnerTransactions() []byte { + if m != nil { + return m.InnerTransactions + } + return nil +} + func init() { proto.RegisterType((*Transaction)(nil), "proto.Transaction") } @@ -187,43 +195,44 @@ func init() { func init() { proto.RegisterFile("transaction.proto", fileDescriptor_2cc4e03d2c28c490) } var fileDescriptor_2cc4e03d2c28c490 = []byte{ - // 573 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x31, 0x6f, 0xd4, 0x3e, - 0x18, 0xc6, 0xe3, 0xff, 0xbf, 0x77, 0x69, 0x7d, 0xd7, 0xa2, 0x1a, 0x15, 0x02, 0x48, 0x76, 0x85, - 0xa0, 0xea, 0xc0, 0x5d, 0x24, 0x10, 0x0b, 0x9d, 0xb8, 0x16, 0x55, 0x95, 0xa0, 0xa0, 0x14, 0x3a, - 0xb0, 0xf9, 0x12, 0x93, 0xb3, 0xd4, 0xd8, 0x95, 0xe3, 0x9c, 0xca, 0x80, 0xc4, 0x47, 0xe0, 0x63, - 0x20, 0x36, 0xbe, 0x05, 0x63, 0xc7, 0x4e, 0x81, 0xe6, 0x16, 0x94, 0xa9, 0x1f, 0x01, 0xc5, 0xb9, - 0x34, 0x6e, 0x99, 0x98, 0x62, 0xff, 0xde, 0xe7, 0x79, 0x1f, 0xcb, 0xce, 0x0b, 0x57, 0xb5, 0xa2, - 0x22, 0xa5, 0xa1, 0xe6, 0x52, 0x0c, 0x8f, 0x95, 0xd4, 0x12, 0x75, 0xcc, 0xe7, 0xee, 0x20, 0xe6, - 0x7a, 0x92, 0x8d, 0x87, 0xa1, 0x4c, 0xfc, 0x58, 0xc6, 0xd2, 0x37, 0x78, 0x9c, 0x7d, 0x30, 0x3b, - 0xb3, 0x31, 0xab, 0xda, 0x75, 0xff, 0x7b, 0x17, 0xf6, 0xde, 0xb6, 0xbd, 0x10, 0x81, 0x9d, 0x7d, - 0x29, 0x42, 0xe6, 0x81, 0x75, 0xb0, 0xb9, 0x30, 0x5a, 0x2a, 0x73, 0xd2, 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0x2d, 0x30, 0x38, 0x2b, 0x30, 0xf8, 0x55, 0x60, 0xf0, - 0xbb, 0xc0, 0xce, 0x45, 0x81, 0xc1, 0x97, 0x19, 0x76, 0x4e, 0x67, 0xd8, 0x39, 0x9b, 0x61, 0xe7, - 0xfd, 0xf6, 0x3f, 0xcc, 0x84, 0x6f, 0x8d, 0xf8, 0x96, 0xb5, 0x1e, 0x77, 0xcd, 0xe4, 0x3e, 0xf9, - 0x13, 0x00, 0x00, 0xff, 0xff, 0x38, 0xda, 0x76, 0x84, 0x04, 0x04, 0x00, 0x00, + // 587 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcf, 0x4e, 0x14, 0x3d, + 0x00, 0xdf, 0x7e, 0x1f, 0xcb, 0x40, 0x77, 0x41, 0xa9, 0x41, 0xab, 0x26, 0x2d, 0x31, 0x4a, 0x38, + 0xb8, 0x3b, 0x89, 0xc6, 0x8b, 0x9c, 0x5c, 0x30, 0x64, 0x13, 0x45, 0x33, 0x28, 0x07, 0x6f, 0xdd, + 0x99, 0x3a, 0xdb, 0x84, 0x69, 0x49, 0xa7, 0xbb, 0xc1, 0x83, 0x09, 0x8f, 0xe0, 0x63, 0x18, 0x9f, + 0xc4, 0x23, 0x47, 0x4e, 0xa3, 0x0c, 0x17, 0x33, 0x27, 0x1e, 0xc1, 0x4c, 0x67, 0x87, 0x29, 0x70, + 0xf2, 0x34, 0xed, 0xef, 0x6f, 0xd3, 0x4e, 0x0b, 0x57, 0x8c, 0x66, 0x32, 0x65, 0xa1, 0x11, 0x4a, + 0xf6, 0x0f, 0xb5, 0x32, 0x0a, 0xb5, 0xed, 0xe7, 0x41, 0x2f, 0x16, 0x66, 0x3c, 0x19, 0xf5, 0x43, + 0x95, 0xf8, 0xb1, 0x8a, 0x95, 0x6f, 0xe1, 0xd1, 0xe4, 0xb3, 0x9d, 0xd9, 0x89, 0x1d, 0x55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 0xcb, 0xb8, 0xa1, 0x94, 0x5c, + 0x3b, 0xf7, 0x26, 0xc5, 0xb7, 0x9b, 0x38, 0x71, 0x9d, 0x74, 0xe3, 0x6e, 0x38, 0x07, 0x5f, 0x4f, + 0xce, 0x48, 0xeb, 0xf4, 0x8c, 0xb4, 0x2e, 0xce, 0x08, 0x38, 0xce, 0x09, 0xf8, 0x9e, 0x13, 0xf0, + 0x33, 0x27, 0xe0, 0x24, 0x27, 0xe0, 0x34, 0x27, 0xe0, 0x77, 0x4e, 0xc0, 0x9f, 0x9c, 0xb4, 0x2e, + 0x72, 0x02, 0xbe, 0x9d, 0x93, 0xd6, 0xc9, 0x39, 0x69, 0x9d, 0x9e, 0x93, 0xd6, 0xa7, 0xad, 0x7f, + 0xb8, 0x62, 0xbe, 0xf3, 0x62, 0x6c, 0x3a, 0xe3, 0xd1, 0xbc, 0x7d, 0x08, 0x9e, 0xff, 0x0d, 0x00, + 0x00, 0xff, 0xff, 0x89, 0xbf, 0x61, 0x05, 0x53, 0x04, 0x00, 0x00, } func (this *Transaction) Equal(that interface{}) bool { @@ -293,13 +302,16 @@ func (this *Transaction) Equal(that interface{}) bool { if !bytes.Equal(this.GuardianSignature, that1.GuardianSignature) { return false } + if !bytes.Equal(this.InnerTransactions, that1.InnerTransactions) { + return false + } return true } func (this *Transaction) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 19) + s := make([]string, 0, 20) s = append(s, "&transaction.Transaction{") s = append(s, "Nonce: "+fmt.Sprintf("%#v", this.Nonce)+",\n") s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") @@ -316,6 +328,7 @@ func (this *Transaction) GoString() string { s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n") s = append(s, "GuardianAddr: "+fmt.Sprintf("%#v", this.GuardianAddr)+",\n") s = append(s, "GuardianSignature: "+fmt.Sprintf("%#v", this.GuardianSignature)+",\n") + s = append(s, "InnerTransactions: "+fmt.Sprintf("%#v", this.InnerTransactions)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -347,6 +360,15 @@ func (m *Transaction) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.InnerTransactions) > 0 { + i -= len(m.InnerTransactions) + copy(dAtA[i:], m.InnerTransactions) + i = encodeVarintTransaction(dAtA, i, uint64(len(m.InnerTransactions))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + } if len(m.GuardianSignature) > 0 { i -= len(m.GuardianSignature) copy(dAtA[i:], m.GuardianSignature) @@ -522,6 +544,10 @@ func (m *Transaction) Size() (n int) { if l > 0 { n += 1 + l + sovTransaction(uint64(l)) } + l = len(m.InnerTransactions) + if l > 0 { + n += 2 + l + sovTransaction(uint64(l)) + } return n } @@ -551,6 +577,7 @@ func (this *Transaction) String() string { `Options:` + fmt.Sprintf("%v", this.Options) + `,`, `GuardianAddr:` + fmt.Sprintf("%v", this.GuardianAddr) + `,`, `GuardianSignature:` + fmt.Sprintf("%v", this.GuardianSignature) + `,`, + `InnerTransactions:` + fmt.Sprintf("%v", this.InnerTransactions) + `,`, `}`, }, "") return s @@ -1031,6 +1058,40 @@ func (m *Transaction) Unmarshal(dAtA []byte) error { m.GuardianSignature = []byte{} } iNdEx = postIndex + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InnerTransactions", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTransaction + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTransaction + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTransaction + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InnerTransactions = append(m.InnerTransactions[:0], dAtA[iNdEx:postIndex]...) + if m.InnerTransactions == nil { + m.InnerTransactions = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTransaction(dAtA[iNdEx:]) diff --git a/data/transaction/transaction.proto b/data/transaction/transaction.proto index 2e8e168d5..d1a156ae2 100644 --- a/data/transaction/transaction.proto +++ b/data/transaction/transaction.proto @@ -30,4 +30,5 @@ message Transaction { uint32 Options = 13 [(gogoproto.jsontag) = "options,omitempty"]; bytes GuardianAddr = 14 [(gogoproto.jsontag) = "guardian,omitempty"]; bytes GuardianSignature = 15 [(gogoproto.jsontag) = "guardianSignature,omitempty"]; + bytes InnerTransactions = 16 [(gogoproto.jsontag) = "innerTransactions,omitempty"]; } diff --git a/data/transaction/transaction_test.go b/data/transaction/transaction_test.go index 023066537..7da781ffe 100644 --- a/data/transaction/transaction_test.go +++ b/data/transaction/transaction_test.go @@ -23,6 +23,7 @@ func TestTransaction_SettersAndGetters(t *testing.T) { gasLimit := uint64(5) sender := []byte("sndr") receiver := []byte("receiver") + innerTxs := []byte("inner txs") tx := &transaction.Transaction{ Nonce: nonce, @@ -35,6 +36,7 @@ func TestTransaction_SettersAndGetters(t *testing.T) { tx.SetData(txData) tx.SetValue(value) tx.SetRcvAddr(receiver) + tx.SetInnerTransactions(innerTxs) assert.Equal(t, nonce, tx.GetNonce()) assert.Equal(t, value, tx.GetValue()) @@ -43,6 +45,7 @@ func TestTransaction_SettersAndGetters(t *testing.T) { assert.Equal(t, gasLimit, tx.GetGasLimit()) assert.Equal(t, sender, tx.GetSndAddr()) assert.Equal(t, receiver, tx.GetRcvAddr()) + assert.Equal(t, innerTxs, tx.GetInnerTransactions()) } func TestTransaction_MarshalUnmarshalJsonShouldWork(t *testing.T) { @@ -50,14 +53,15 @@ func TestTransaction_MarshalUnmarshalJsonShouldWork(t *testing.T) { value := big.NewInt(445566) tx := &transaction.Transaction{ - Nonce: 112233, - Value: new(big.Int).Set(value), - RcvAddr: []byte("receiver"), - SndAddr: []byte("sender"), - GasPrice: 1234, - GasLimit: 5678, - Data: []byte("data"), - Signature: []byte("signature"), + Nonce: 112233, + Value: new(big.Int).Set(value), + RcvAddr: []byte("receiver"), + SndAddr: []byte("sender"), + GasPrice: 1234, + GasLimit: 5678, + Data: []byte("data"), + Signature: []byte("signature"), + InnerTransactions: []byte("inner txs"), } buff, err := json.Marshal(tx) @@ -220,7 +224,8 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { tx := &transaction.Transaction{} numEncodeCalled := 0 - marshalizerWasCalled := false + marshallWasCalled := false + unmarshallWasCalled := false hasherWasCalled := false buff, err := tx.GetDataForSigning( &mock.PubkeyConverterStub{ @@ -231,10 +236,15 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { }, &mock.MarshalizerStub{ MarshalCalled: func(obj interface{}) (bytes []byte, err error) { - marshalizerWasCalled = true + marshallWasCalled = true return make([]byte, 0), nil }, + UnmarshalCalled: func(obj interface{}, buff []byte) error { + unmarshallWasCalled = true + + return nil + }, }, &mock.HasherStub{ ComputeCalled: func(s string) []byte { @@ -247,11 +257,73 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { assert.Equal(t, 0, len(buff)) assert.Nil(t, err) - assert.True(t, marshalizerWasCalled) + assert.True(t, marshallWasCalled) + assert.True(t, unmarshallWasCalled) assert.False(t, hasherWasCalled) assert.Equal(t, 2, numEncodeCalled) }) + t.Run("inner txs, without hash sign option set", func(t *testing.T) { + t.Parallel() + + tx1 := &transaction.Transaction{ + Nonce: 1, + } + tx2 := &transaction.Transaction{ + Nonce: 2, + } + innerTxsBuff, err := json.Marshal([]*transaction.Transaction{tx1, tx2}) + assert.NoError(t, err) + tx := &transaction.Transaction{ + Nonce: 3, + InnerTransactions: innerTxsBuff, + } + + numEncodeCalled := 0 + marshallWasCalled := false + unmarshallWasCalled := false + hasherWasCalled := false + buff, err := tx.GetDataForSigning( + &mock.PubkeyConverterStub{ + EncodeCalled: func(pkBytes []byte) (string, error) { + numEncodeCalled++ + return "", nil + }, + }, + &mock.MarshalizerStub{ + MarshalCalled: func(obj interface{}) (bytes []byte, err error) { + marshallWasCalled = true + + return json.Marshal(obj) + }, + UnmarshalCalled: func(obj interface{}, buff []byte) error { + unmarshallWasCalled = true + + return json.Unmarshal(buff, obj) + }, + }, + &mock.HasherStub{ + ComputeCalled: func(s string) []byte { + hasherWasCalled = true + + return make([]byte, 0) + }, + }, + ) + + assert.Nil(t, err) + + var ftx transaction.FrontendTransaction + err = json.Unmarshal(buff, &ftx) + assert.Nil(t, err) + assert.Equal(t, 2, len(ftx.InnerTransactions)) + + assert.True(t, marshallWasCalled) + assert.True(t, unmarshallWasCalled) + assert.False(t, hasherWasCalled) + assert.Equal(t, 6, numEncodeCalled) + }) + t.Run("with hash sign option set", func(t *testing.T) { t.Parallel() @@ -260,7 +332,8 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { tx.Options ^= transaction.MaskSignedWithHash numEncodeCalled := 0 - marshalizerWasCalled := false + marshallWasCalled := false + unmarshallWasCalled := false hasherWasCalled := false expectedHash := []byte("expectedHash") buff, err := tx.GetDataForSigning( @@ -272,10 +345,15 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { }, &mock.MarshalizerStub{ MarshalCalled: func(obj interface{}) (bytes []byte, err error) { - marshalizerWasCalled = true + marshallWasCalled = true return make([]byte, 0), nil }, + UnmarshalCalled: func(obj interface{}, buff []byte) error { + unmarshallWasCalled = true + + return nil + }, }, &mock.HasherStub{ ComputeCalled: func(s string) []byte { @@ -287,7 +365,8 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { ) assert.Nil(t, err) - assert.True(t, marshalizerWasCalled) + assert.True(t, marshallWasCalled) + assert.True(t, unmarshallWasCalled) assert.True(t, hasherWasCalled) assert.Equal(t, expectedHash, buff) assert.Equal(t, 2, numEncodeCalled) From 6ac41d9be0a3f5ed99cef8dfea97d53cfc2a29f6 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Fri, 8 Sep 2023 14:50:59 +0300 Subject: [PATCH 02/27] fix test --- data/transaction/transaction_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/transaction/transaction_test.go b/data/transaction/transaction_test.go index 7da781ffe..ff4221254 100644 --- a/data/transaction/transaction_test.go +++ b/data/transaction/transaction_test.go @@ -186,6 +186,9 @@ func TestTransaction_GetDataForSigningMarshalizerErrShouldErr(t *testing.T) { MarshalCalled: func(obj interface{}) (bytes []byte, err error) { return nil, expectedErr }, + UnmarshalCalled: func(obj interface{}, buff []byte) error { + return nil + }, }, &mock.HasherMock{}, ) From b0fb32803ee5a28f9061ec5f85e0e540db39f90f Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Fri, 8 Sep 2023 15:20:56 +0300 Subject: [PATCH 03/27] added extra check --- data/transaction/transaction.go | 89 ++++++++++++++++------------ data/transaction/transaction_test.go | 14 ----- 2 files changed, 51 insertions(+), 52 deletions(-) diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 83f78153d..4851ff6f1 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -79,21 +79,11 @@ func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.M return nil, err } - innerTxs := make([]*Transaction, 0) - err = marshaller.Unmarshal(&innerTxs, tx.InnerTransactions) - if err != nil { - return nil, err - } - for _, innerTx := range innerTxs { - innerFtx, innerErr := innerTx.prepareTx(encoder) - if innerErr != nil { + if len(tx.InnerTransactions) > 0 { + ftx.InnerTransactions, err = tx.prepareInnerTxs(encoder, marshaller) + if err != nil { return nil, err } - - innerFtx.Signature = hex.EncodeToString(innerTx.Signature) - innerFtx.GuardianSignature = hex.EncodeToString(innerTx.GuardianSignature) - - ftx.InnerTransactions = append(ftx.InnerTransactions, innerFtx) } ftxBytes, err := marshaller.Marshal(ftx) @@ -111,6 +101,37 @@ func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.M return ftxHash, nil } +// HasOptionGuardianSet returns true if the guarded transaction option is set +func (tx *Transaction) HasOptionGuardianSet() bool { + return tx.Options&MaskGuardedTransaction > 0 +} + +// HasOptionHashSignSet returns true if the signed with hash option is set +func (tx *Transaction) HasOptionHashSignSet() bool { + return tx.Options&MaskSignedWithHash > 0 +} + +// CheckIntegrity checks for not nil fields and negative value +func (tx *Transaction) CheckIntegrity() error { + if tx.Signature == nil { + return data.ErrNilSignature + } + if tx.Value == nil { + return data.ErrNilValue + } + if tx.Value.Sign() < 0 { + return data.ErrNegativeValue + } + if len(tx.RcvUserName) > core.MaxUserNameLength { + return data.ErrInvalidUserNameLength + } + if len(tx.SndUserName) > core.MaxUserNameLength { + return data.ErrInvalidUserNameLength + } + + return nil +} + func (tx *Transaction) prepareTx(encoder data.Encoder) (*FrontendTransaction, error) { receiverAddr, err := encoder.Encode(tx.RcvAddr) if err != nil { @@ -149,33 +170,25 @@ func (tx *Transaction) prepareTx(encoder data.Encoder) (*FrontendTransaction, er return ftx, nil } -// HasOptionGuardianSet returns true if the guarded transaction option is set -func (tx *Transaction) HasOptionGuardianSet() bool { - return tx.Options&MaskGuardedTransaction > 0 -} +func (tx *Transaction) prepareInnerTxs(encoder data.Encoder, marshaller data.Marshaller) ([]*FrontendTransaction, error) { + innerTxs := make([]*Transaction, 0) + err := marshaller.Unmarshal(&innerTxs, tx.InnerTransactions) + if err != nil { + return nil, err + } -// HasOptionHashSignSet returns true if the signed with hash option is set -func (tx *Transaction) HasOptionHashSignSet() bool { - return tx.Options&MaskSignedWithHash > 0 -} + innerFtxs := make([]*FrontendTransaction, 0, len(innerTxs)) + for _, innerTx := range innerTxs { + innerFtx, innerErr := innerTx.prepareTx(encoder) + if innerErr != nil { + return nil, err + } -// CheckIntegrity checks for not nil fields and negative value -func (tx *Transaction) CheckIntegrity() error { - if tx.Signature == nil { - return data.ErrNilSignature - } - if tx.Value == nil { - return data.ErrNilValue - } - if tx.Value.Sign() < 0 { - return data.ErrNegativeValue - } - if len(tx.RcvUserName) > core.MaxUserNameLength { - return data.ErrInvalidUserNameLength - } - if len(tx.SndUserName) > core.MaxUserNameLength { - return data.ErrInvalidUserNameLength + innerFtx.Signature = hex.EncodeToString(innerTx.Signature) + innerFtx.GuardianSignature = hex.EncodeToString(innerTx.GuardianSignature) + + innerFtxs = append(innerFtxs, innerFtx) } - return nil + return innerFtxs, nil } diff --git a/data/transaction/transaction_test.go b/data/transaction/transaction_test.go index ff4221254..79314f833 100644 --- a/data/transaction/transaction_test.go +++ b/data/transaction/transaction_test.go @@ -228,7 +228,6 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { numEncodeCalled := 0 marshallWasCalled := false - unmarshallWasCalled := false hasherWasCalled := false buff, err := tx.GetDataForSigning( &mock.PubkeyConverterStub{ @@ -243,11 +242,6 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { return make([]byte, 0), nil }, - UnmarshalCalled: func(obj interface{}, buff []byte) error { - unmarshallWasCalled = true - - return nil - }, }, &mock.HasherStub{ ComputeCalled: func(s string) []byte { @@ -261,7 +255,6 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { assert.Equal(t, 0, len(buff)) assert.Nil(t, err) assert.True(t, marshallWasCalled) - assert.True(t, unmarshallWasCalled) assert.False(t, hasherWasCalled) assert.Equal(t, 2, numEncodeCalled) }) @@ -336,7 +329,6 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { numEncodeCalled := 0 marshallWasCalled := false - unmarshallWasCalled := false hasherWasCalled := false expectedHash := []byte("expectedHash") buff, err := tx.GetDataForSigning( @@ -352,11 +344,6 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { return make([]byte, 0), nil }, - UnmarshalCalled: func(obj interface{}, buff []byte) error { - unmarshallWasCalled = true - - return nil - }, }, &mock.HasherStub{ ComputeCalled: func(s string) []byte { @@ -369,7 +356,6 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { assert.Nil(t, err) assert.True(t, marshallWasCalled) - assert.True(t, unmarshallWasCalled) assert.True(t, hasherWasCalled) assert.Equal(t, expectedHash, buff) assert.Equal(t, 2, numEncodeCalled) From 132204ad0b6c286d390f10e2555ca7959a6a5cc3 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Fri, 8 Sep 2023 16:43:37 +0300 Subject: [PATCH 04/27] added RelayedV3TransactionHandler --- data/interface.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/data/interface.go b/data/interface.go index 748868fe7..169c39543 100644 --- a/data/interface.go +++ b/data/interface.go @@ -408,3 +408,8 @@ type UserAccountHandler interface { AddressBytes() []byte IsInterfaceNil() bool } + +// RelayedV3TransactionHandler defines functionality for relayed v3 transaction +type RelayedV3TransactionHandler interface { + GetInnerTransactions() []byte +} From 8f1a3790459a7709d2db6efefde93f511f27eb7f Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Wed, 20 Sep 2023 09:42:55 +0300 Subject: [PATCH 05/27] only one inner tx --- data/interface.go | 2 +- data/transaction/apiTransactionResult.go | 2 +- data/transaction/frontendTransaction.go | 32 +++---- data/transaction/transaction.go | 35 ++++---- data/transaction/transaction.pb.go | 106 +++++++++++------------ data/transaction/transaction.proto | 2 +- data/transaction/transaction_test.go | 36 ++++---- 7 files changed, 103 insertions(+), 112 deletions(-) diff --git a/data/interface.go b/data/interface.go index 169c39543..a554675cd 100644 --- a/data/interface.go +++ b/data/interface.go @@ -411,5 +411,5 @@ type UserAccountHandler interface { // RelayedV3TransactionHandler defines functionality for relayed v3 transaction type RelayedV3TransactionHandler interface { - GetInnerTransactions() []byte + GetInnerTransaction() []byte } diff --git a/data/transaction/apiTransactionResult.go b/data/transaction/apiTransactionResult.go index 8f619d064..20e86eb1d 100644 --- a/data/transaction/apiTransactionResult.go +++ b/data/transaction/apiTransactionResult.go @@ -69,7 +69,7 @@ type ApiTransactionResult struct { Options uint32 `json:"options"` GuardianAddr string `json:"guardian,omitempty"` GuardianSignature string `json:"guardianSignature,omitempty"` - InnerTransactions []data.TransactionHandler `json:"innerTransactions,omitempty"` + InnerTransaction data.TransactionHandler `json:"innerTransaction,omitempty"` } // ApiSmartContractResult represents a smart contract result with changed fields' types in order to make it friendly for API's json diff --git a/data/transaction/frontendTransaction.go b/data/transaction/frontendTransaction.go index 8b706e767..c627a5164 100644 --- a/data/transaction/frontendTransaction.go +++ b/data/transaction/frontendTransaction.go @@ -2,20 +2,20 @@ package transaction // FrontendTransaction represents the DTO used in transaction signing/validation. type FrontendTransaction struct { - Nonce uint64 `json:"nonce"` - Value string `json:"value"` - Receiver string `json:"receiver"` - Sender string `json:"sender"` - SenderUsername []byte `json:"senderUsername,omitempty"` - ReceiverUsername []byte `json:"receiverUsername,omitempty"` - GasPrice uint64 `json:"gasPrice"` - GasLimit uint64 `json:"gasLimit"` - Data []byte `json:"data,omitempty"` - Signature string `json:"signature,omitempty"` - ChainID string `json:"chainID"` - Version uint32 `json:"version"` - Options uint32 `json:"options,omitempty"` - GuardianAddr string `json:"guardian,omitempty"` - GuardianSignature string `json:"guardianSignature,omitempty"` - InnerTransactions []*FrontendTransaction `json:"innerTransactions,omitempty"` + Nonce uint64 `json:"nonce"` + Value string `json:"value"` + Receiver string `json:"receiver"` + Sender string `json:"sender"` + SenderUsername []byte `json:"senderUsername,omitempty"` + ReceiverUsername []byte `json:"receiverUsername,omitempty"` + GasPrice uint64 `json:"gasPrice"` + GasLimit uint64 `json:"gasLimit"` + Data []byte `json:"data,omitempty"` + Signature string `json:"signature,omitempty"` + ChainID string `json:"chainID"` + Version uint32 `json:"version"` + Options uint32 `json:"options,omitempty"` + GuardianAddr string `json:"guardian,omitempty"` + GuardianSignature string `json:"guardianSignature,omitempty"` + InnerTransaction *FrontendTransaction `json:"innerTransaction,omitempty"` } diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 4851ff6f1..6dc9d14ea 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -37,9 +37,9 @@ func (tx *Transaction) SetSndAddr(addr []byte) { tx.SndAddr = addr } -// SetInnerTransactions sets the inner transactions of the transaction -func (tx *Transaction) SetInnerTransactions(innerTransactions []byte) { - tx.InnerTransactions = innerTransactions +// SetInnerTransaction sets the inner transaction of the transaction +func (tx *Transaction) SetInnerTransaction(innerTransaction []byte) { + tx.InnerTransaction = innerTransaction } // TrimSlicePtr creates a copy of the provided slice without the excess capacity @@ -79,8 +79,8 @@ func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.M return nil, err } - if len(tx.InnerTransactions) > 0 { - ftx.InnerTransactions, err = tx.prepareInnerTxs(encoder, marshaller) + if len(tx.InnerTransaction) > 0 { + ftx.InnerTransaction, err = tx.prepareInnerTx(encoder, marshaller) if err != nil { return nil, err } @@ -170,25 +170,20 @@ func (tx *Transaction) prepareTx(encoder data.Encoder) (*FrontendTransaction, er return ftx, nil } -func (tx *Transaction) prepareInnerTxs(encoder data.Encoder, marshaller data.Marshaller) ([]*FrontendTransaction, error) { - innerTxs := make([]*Transaction, 0) - err := marshaller.Unmarshal(&innerTxs, tx.InnerTransactions) +func (tx *Transaction) prepareInnerTx(encoder data.Encoder, marshaller data.Marshaller) (*FrontendTransaction, error) { + var innerTx Transaction + err := marshaller.Unmarshal(&innerTx, tx.InnerTransaction) if err != nil { return nil, err } - innerFtxs := make([]*FrontendTransaction, 0, len(innerTxs)) - for _, innerTx := range innerTxs { - innerFtx, innerErr := innerTx.prepareTx(encoder) - if innerErr != nil { - return nil, err - } - - innerFtx.Signature = hex.EncodeToString(innerTx.Signature) - innerFtx.GuardianSignature = hex.EncodeToString(innerTx.GuardianSignature) - - innerFtxs = append(innerFtxs, innerFtx) + ftx, err := tx.prepareTx(encoder) + if err != nil { + return nil, err } - return innerFtxs, nil + ftx.Signature = hex.EncodeToString(innerTx.Signature) + ftx.GuardianSignature = hex.EncodeToString(innerTx.GuardianSignature) + + return ftx, nil } diff --git a/data/transaction/transaction.pb.go b/data/transaction/transaction.pb.go index c6dfba036..389b7526e 100644 --- a/data/transaction/transaction.pb.go +++ b/data/transaction/transaction.pb.go @@ -45,7 +45,7 @@ type Transaction struct { Options uint32 `protobuf:"varint,13,opt,name=Options,proto3" json:"options,omitempty"` GuardianAddr []byte `protobuf:"bytes,14,opt,name=GuardianAddr,proto3" json:"guardian,omitempty"` GuardianSignature []byte `protobuf:"bytes,15,opt,name=GuardianSignature,proto3" json:"guardianSignature,omitempty"` - InnerTransactions []byte `protobuf:"bytes,16,opt,name=InnerTransactions,proto3" json:"innerTransactions,omitempty"` + InnerTransaction []byte `protobuf:"bytes,16,opt,name=InnerTransaction,proto3" json:"innerTransaction,omitempty"` } func (m *Transaction) Reset() { *m = Transaction{} } @@ -181,9 +181,9 @@ func (m *Transaction) GetGuardianSignature() []byte { return nil } -func (m *Transaction) GetInnerTransactions() []byte { +func (m *Transaction) GetInnerTransaction() []byte { if m != nil { - return m.InnerTransactions + return m.InnerTransaction } return nil } @@ -195,44 +195,44 @@ func init() { func init() { proto.RegisterFile("transaction.proto", fileDescriptor_2cc4e03d2c28c490) } var fileDescriptor_2cc4e03d2c28c490 = []byte{ - // 587 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcf, 0x4e, 0x14, 0x3d, - 0x00, 0xdf, 0x7e, 0x1f, 0xcb, 0x40, 0x77, 0x41, 0xa9, 0x41, 0xab, 0x26, 0x2d, 0x31, 0x4a, 0x38, - 0xb8, 0x3b, 0x89, 0xc6, 0x8b, 0x9c, 0x5c, 0x30, 0x64, 0x13, 0x45, 0x33, 0x28, 0x07, 0x6f, 0xdd, - 0x99, 0x3a, 0xdb, 0x84, 0x69, 0x49, 0xa7, 0xbb, 0xc1, 0x83, 0x09, 0x8f, 0xe0, 0x63, 0x18, 0x9f, - 0xc4, 0x23, 0x47, 0x4e, 0xa3, 0x0c, 0x17, 0x33, 0x27, 0x1e, 0xc1, 0x4c, 0x67, 0x87, 0x29, 0x70, - 0xf2, 0x34, 0xed, 0xef, 0x6f, 0xd3, 0x4e, 0x0b, 0x57, 0x8c, 0x66, 0x32, 0x65, 0xa1, 0x11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, 0x3d, 0xad, 0x65, 0x5b, 0x55, - 0xed, 0xca, 0x0c, 0x77, 0x6c, 0x57, 0xb4, 0xe8, 0x2d, 0x5c, 0xa9, 0xe7, 0xcd, 0x5a, 0x6f, 0xd9, - 0x00, 0x5a, 0x64, 0xf4, 0x61, 0x7c, 0x9d, 0x74, 0x92, 0x6e, 0x3a, 0xcb, 0xb8, 0xa1, 0x94, 0x5c, - 0x3b, 0xf7, 0x26, 0xc5, 0xb7, 0x9b, 0x38, 0x71, 0x9d, 0x74, 0xe3, 0x6e, 0x38, 0x07, 0x5f, 0x4f, - 0xce, 0x48, 0xeb, 0xf4, 0x8c, 0xb4, 0x2e, 0xce, 0x08, 0x38, 0xce, 0x09, 0xf8, 0x9e, 0x13, 0xf0, - 0x33, 0x27, 0xe0, 0x24, 0x27, 0xe0, 0x34, 0x27, 0xe0, 0x77, 0x4e, 0xc0, 0x9f, 0x9c, 0xb4, 0x2e, - 0x72, 0x02, 0xbe, 0x9d, 0x93, 0xd6, 0xc9, 0x39, 0x69, 0x9d, 0x9e, 0x93, 0xd6, 0xa7, 0xad, 0x7f, - 0xb8, 0x62, 0xbe, 0xf3, 0x62, 0x6c, 0x3a, 0xe3, 0xd1, 0xbc, 0x7d, 0x08, 0x9e, 0xff, 0x0d, 0x00, - 0x00, 0xff, 0xff, 0x89, 0xbf, 0x61, 0x05, 0x53, 0x04, 0x00, 0x00, + // 592 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x6e, 0xd3, 0x30, + 0x00, 0xae, 0x61, 0x6d, 0x37, 0xb7, 0x1b, 0x9b, 0xd1, 0xc0, 0x0c, 0xc9, 0x9e, 0x10, 0x4c, 0x3b, + 0xd0, 0x46, 0x02, 0x71, 0x61, 0x27, 0xba, 0xa1, 0xa9, 0x08, 0x06, 0xca, 0x60, 0x07, 0x6e, 0x6e, + 0x62, 0x52, 0x4b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cd, + 0x71, 0xdb, 0xe6, 0xdd, 0xcd, 0x53, 0x7a, 0x3b, 0x99, 0x82, 0x4e, 0x7f, 0xa5, 0x44, 0x1e, 0x6c, + 0xbe, 0x3d, 0x2a, 0xfe, 0xb8, 0x04, 0x2f, 0xda, 0xf4, 0xd5, 0x3c, 0xa5, 0x2b, 0xaa, 0x84, 0x1c, + 0xcb, 0x54, 0x85, 0x9e, 0xc3, 0xf6, 0xee, 0x88, 0xe9, 0x50, 0x30, 0x69, 0x4f, 0x6b, 0xc9, 0x56, + 0x95, 0xbb, 0x32, 0xc1, 0x1d, 0xdb, 0x15, 0x2d, 0x7a, 0x03, 0x57, 0xa6, 0xf3, 0x6a, 0xad, 0xb7, + 0x6c, 0x00, 0xcd, 0x53, 0x7a, 0x3f, 0x9a, 0x25, 0x9d, 0xa4, 0xeb, 0x4e, 0xf4, 0x0a, 0x2e, 0xf7, + 0xa5, 0xe4, 0xda, 0xb9, 0x37, 0x78, 0xd9, 0xa6, 0x91, 0x3c, 0xa5, 0x6b, 0x62, 0x86, 0x73, 0xc2, + 0xae, 0xf9, 0x7a, 0x5f, 0x4e, 0xce, 0x48, 0xed, 0xf4, 0x8c, 0xd4, 0x2e, 0xce, 0x08, 0xf8, 0x9a, + 0x11, 0xf0, 0x3d, 0x23, 0xe0, 0x67, 0x46, 0xc0, 0x49, 0x46, 0xc0, 0x69, 0x46, 0xc0, 0xef, 0x8c, + 0x80, 0x3f, 0x19, 0xa9, 0x5d, 0x64, 0x04, 0x7c, 0x3b, 0x27, 0xb5, 0x93, 0x73, 0x52, 0x3b, 0x3d, + 0x27, 0xb5, 0x8f, 0xdb, 0xff, 0x71, 0xbf, 0x3c, 0xe7, 0xb9, 0xd8, 0x72, 0xc6, 0x83, 0x86, 0x7d, + 0x05, 0x9e, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xe8, 0x47, 0x21, 0xb0, 0x50, 0x04, 0x00, 0x00, } func (this *Transaction) Equal(that interface{}) bool { @@ -302,7 +302,7 @@ func (this *Transaction) Equal(that interface{}) bool { if !bytes.Equal(this.GuardianSignature, that1.GuardianSignature) { return false } - if !bytes.Equal(this.InnerTransactions, that1.InnerTransactions) { + if !bytes.Equal(this.InnerTransaction, that1.InnerTransaction) { return false } return true @@ -328,7 +328,7 @@ func (this *Transaction) GoString() string { s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n") s = append(s, "GuardianAddr: "+fmt.Sprintf("%#v", this.GuardianAddr)+",\n") s = append(s, "GuardianSignature: "+fmt.Sprintf("%#v", this.GuardianSignature)+",\n") - s = append(s, "InnerTransactions: "+fmt.Sprintf("%#v", this.InnerTransactions)+",\n") + s = append(s, "InnerTransaction: "+fmt.Sprintf("%#v", this.InnerTransaction)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -360,10 +360,10 @@ func (m *Transaction) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.InnerTransactions) > 0 { - i -= len(m.InnerTransactions) - copy(dAtA[i:], m.InnerTransactions) - i = encodeVarintTransaction(dAtA, i, uint64(len(m.InnerTransactions))) + if len(m.InnerTransaction) > 0 { + i -= len(m.InnerTransaction) + copy(dAtA[i:], m.InnerTransaction) + i = encodeVarintTransaction(dAtA, i, uint64(len(m.InnerTransaction))) i-- dAtA[i] = 0x1 i-- @@ -544,7 +544,7 @@ func (m *Transaction) Size() (n int) { if l > 0 { n += 1 + l + sovTransaction(uint64(l)) } - l = len(m.InnerTransactions) + l = len(m.InnerTransaction) if l > 0 { n += 2 + l + sovTransaction(uint64(l)) } @@ -577,7 +577,7 @@ func (this *Transaction) String() string { `Options:` + fmt.Sprintf("%v", this.Options) + `,`, `GuardianAddr:` + fmt.Sprintf("%v", this.GuardianAddr) + `,`, `GuardianSignature:` + fmt.Sprintf("%v", this.GuardianSignature) + `,`, - `InnerTransactions:` + fmt.Sprintf("%v", this.InnerTransactions) + `,`, + `InnerTransaction:` + fmt.Sprintf("%v", this.InnerTransaction) + `,`, `}`, }, "") return s @@ -1060,7 +1060,7 @@ func (m *Transaction) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 16: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InnerTransactions", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field InnerTransaction", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1087,9 +1087,9 @@ func (m *Transaction) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.InnerTransactions = append(m.InnerTransactions[:0], dAtA[iNdEx:postIndex]...) - if m.InnerTransactions == nil { - m.InnerTransactions = []byte{} + m.InnerTransaction = append(m.InnerTransaction[:0], dAtA[iNdEx:postIndex]...) + if m.InnerTransaction == nil { + m.InnerTransaction = []byte{} } iNdEx = postIndex default: diff --git a/data/transaction/transaction.proto b/data/transaction/transaction.proto index d1a156ae2..39180eefb 100644 --- a/data/transaction/transaction.proto +++ b/data/transaction/transaction.proto @@ -30,5 +30,5 @@ message Transaction { uint32 Options = 13 [(gogoproto.jsontag) = "options,omitempty"]; bytes GuardianAddr = 14 [(gogoproto.jsontag) = "guardian,omitempty"]; bytes GuardianSignature = 15 [(gogoproto.jsontag) = "guardianSignature,omitempty"]; - bytes InnerTransactions = 16 [(gogoproto.jsontag) = "innerTransactions,omitempty"]; + bytes InnerTransaction = 16 [(gogoproto.jsontag) = "innerTransaction,omitempty"]; } diff --git a/data/transaction/transaction_test.go b/data/transaction/transaction_test.go index 79314f833..f3adf5dad 100644 --- a/data/transaction/transaction_test.go +++ b/data/transaction/transaction_test.go @@ -23,7 +23,7 @@ func TestTransaction_SettersAndGetters(t *testing.T) { gasLimit := uint64(5) sender := []byte("sndr") receiver := []byte("receiver") - innerTxs := []byte("inner txs") + innerTx := []byte("inner tx") tx := &transaction.Transaction{ Nonce: nonce, @@ -36,7 +36,7 @@ func TestTransaction_SettersAndGetters(t *testing.T) { tx.SetData(txData) tx.SetValue(value) tx.SetRcvAddr(receiver) - tx.SetInnerTransactions(innerTxs) + tx.SetInnerTransaction(innerTx) assert.Equal(t, nonce, tx.GetNonce()) assert.Equal(t, value, tx.GetValue()) @@ -45,7 +45,7 @@ func TestTransaction_SettersAndGetters(t *testing.T) { assert.Equal(t, gasLimit, tx.GetGasLimit()) assert.Equal(t, sender, tx.GetSndAddr()) assert.Equal(t, receiver, tx.GetRcvAddr()) - assert.Equal(t, innerTxs, tx.GetInnerTransactions()) + assert.Equal(t, innerTx, tx.GetInnerTransaction()) } func TestTransaction_MarshalUnmarshalJsonShouldWork(t *testing.T) { @@ -53,15 +53,15 @@ func TestTransaction_MarshalUnmarshalJsonShouldWork(t *testing.T) { value := big.NewInt(445566) tx := &transaction.Transaction{ - Nonce: 112233, - Value: new(big.Int).Set(value), - RcvAddr: []byte("receiver"), - SndAddr: []byte("sender"), - GasPrice: 1234, - GasLimit: 5678, - Data: []byte("data"), - Signature: []byte("signature"), - InnerTransactions: []byte("inner txs"), + Nonce: 112233, + Value: new(big.Int).Set(value), + RcvAddr: []byte("receiver"), + SndAddr: []byte("sender"), + GasPrice: 1234, + GasLimit: 5678, + Data: []byte("data"), + Signature: []byte("signature"), + InnerTransaction: []byte("inner tx"), } buff, err := json.Marshal(tx) @@ -265,14 +265,11 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { tx1 := &transaction.Transaction{ Nonce: 1, } - tx2 := &transaction.Transaction{ - Nonce: 2, - } - innerTxsBuff, err := json.Marshal([]*transaction.Transaction{tx1, tx2}) + innerTxBuff, err := json.Marshal(tx1) assert.NoError(t, err) tx := &transaction.Transaction{ - Nonce: 3, - InnerTransactions: innerTxsBuff, + Nonce: 3, + InnerTransaction: innerTxBuff, } numEncodeCalled := 0 @@ -312,12 +309,11 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { var ftx transaction.FrontendTransaction err = json.Unmarshal(buff, &ftx) assert.Nil(t, err) - assert.Equal(t, 2, len(ftx.InnerTransactions)) assert.True(t, marshallWasCalled) assert.True(t, unmarshallWasCalled) assert.False(t, hasherWasCalled) - assert.Equal(t, 6, numEncodeCalled) + assert.Equal(t, 4, numEncodeCalled) }) t.Run("with hash sign option set", func(t *testing.T) { From 6724a647cd71dc03bc17e46dbb7e8510a4a9d158 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Wed, 20 Sep 2023 12:47:28 +0300 Subject: [PATCH 06/27] added missing pointer --- data/transaction/transaction.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 6dc9d14ea..2f550fd80 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -171,7 +171,7 @@ func (tx *Transaction) prepareTx(encoder data.Encoder) (*FrontendTransaction, er } func (tx *Transaction) prepareInnerTx(encoder data.Encoder, marshaller data.Marshaller) (*FrontendTransaction, error) { - var innerTx Transaction + var innerTx *Transaction err := marshaller.Unmarshal(&innerTx, tx.InnerTransaction) if err != nil { return nil, err From 978c5de1b9196faabcb8faa0653f3f7cec3b1fdc Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Wed, 20 Sep 2023 12:50:32 +0300 Subject: [PATCH 07/27] prepare proper inner tx --- data/transaction/transaction.go | 2 +- data/transaction/transaction_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 2f550fd80..5f1a0eb4b 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -177,7 +177,7 @@ func (tx *Transaction) prepareInnerTx(encoder data.Encoder, marshaller data.Mars return nil, err } - ftx, err := tx.prepareTx(encoder) + ftx, err := innerTx.prepareTx(encoder) if err != nil { return nil, err } diff --git a/data/transaction/transaction_test.go b/data/transaction/transaction_test.go index f3adf5dad..bcc78e180 100644 --- a/data/transaction/transaction_test.go +++ b/data/transaction/transaction_test.go @@ -259,7 +259,7 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { assert.Equal(t, 2, numEncodeCalled) }) - t.Run("inner txs, without hash sign option set", func(t *testing.T) { + t.Run("inner tx, without hash sign option set", func(t *testing.T) { t.Parallel() tx1 := &transaction.Transaction{ From d7df5756e9e9fb304bdb093c0e48f2c29ab142a7 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Wed, 20 Sep 2023 13:01:04 +0300 Subject: [PATCH 08/27] fix unmarshal of inner --- data/transaction/transaction.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 5f1a0eb4b..683998bf9 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -171,8 +171,8 @@ func (tx *Transaction) prepareTx(encoder data.Encoder) (*FrontendTransaction, er } func (tx *Transaction) prepareInnerTx(encoder data.Encoder, marshaller data.Marshaller) (*FrontendTransaction, error) { - var innerTx *Transaction - err := marshaller.Unmarshal(&innerTx, tx.InnerTransaction) + innerTx := &Transaction{} + err := marshaller.Unmarshal(innerTx, tx.InnerTransaction) if err != nil { return nil, err } From 2791fda6508712015566597e0434fac11f8eecf4 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Wed, 20 Sep 2023 16:55:40 +0300 Subject: [PATCH 09/27] proper implementation --- data/interface.go | 5 -- data/transaction/transaction.go | 25 +----- data/transaction/transaction.pb.go | 120 +++++++++++++++------------ data/transaction/transaction.proto | 32 +++---- data/transaction/transaction_test.go | 35 ++++---- 5 files changed, 99 insertions(+), 118 deletions(-) diff --git a/data/interface.go b/data/interface.go index a554675cd..748868fe7 100644 --- a/data/interface.go +++ b/data/interface.go @@ -408,8 +408,3 @@ type UserAccountHandler interface { AddressBytes() []byte IsInterfaceNil() bool } - -// RelayedV3TransactionHandler defines functionality for relayed v3 transaction -type RelayedV3TransactionHandler interface { - GetInnerTransaction() []byte -} diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 683998bf9..7c5040c40 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -2,7 +2,6 @@ package transaction import ( - "encoding/hex" "math/big" "github.com/multiversx/mx-chain-core-go/core" @@ -38,7 +37,7 @@ func (tx *Transaction) SetSndAddr(addr []byte) { } // SetInnerTransaction sets the inner transaction of the transaction -func (tx *Transaction) SetInnerTransaction(innerTransaction []byte) { +func (tx *Transaction) SetInnerTransaction(innerTransaction *Transaction) { tx.InnerTransaction = innerTransaction } @@ -79,8 +78,8 @@ func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.M return nil, err } - if len(tx.InnerTransaction) > 0 { - ftx.InnerTransaction, err = tx.prepareInnerTx(encoder, marshaller) + if tx.InnerTransaction != nil { + ftx.InnerTransaction, err = tx.prepareTx(encoder) if err != nil { return nil, err } @@ -169,21 +168,3 @@ func (tx *Transaction) prepareTx(encoder data.Encoder) (*FrontendTransaction, er return ftx, nil } - -func (tx *Transaction) prepareInnerTx(encoder data.Encoder, marshaller data.Marshaller) (*FrontendTransaction, error) { - innerTx := &Transaction{} - err := marshaller.Unmarshal(innerTx, tx.InnerTransaction) - if err != nil { - return nil, err - } - - ftx, err := innerTx.prepareTx(encoder) - if err != nil { - return nil, err - } - - ftx.Signature = hex.EncodeToString(innerTx.Signature) - ftx.GuardianSignature = hex.EncodeToString(innerTx.GuardianSignature) - - return ftx, nil -} diff --git a/data/transaction/transaction.pb.go b/data/transaction/transaction.pb.go index 389b7526e..95f6b9597 100644 --- a/data/transaction/transaction.pb.go +++ b/data/transaction/transaction.pb.go @@ -45,7 +45,7 @@ type Transaction struct { Options uint32 `protobuf:"varint,13,opt,name=Options,proto3" json:"options,omitempty"` GuardianAddr []byte `protobuf:"bytes,14,opt,name=GuardianAddr,proto3" json:"guardian,omitempty"` GuardianSignature []byte `protobuf:"bytes,15,opt,name=GuardianSignature,proto3" json:"guardianSignature,omitempty"` - InnerTransaction []byte `protobuf:"bytes,16,opt,name=InnerTransaction,proto3" json:"innerTransaction,omitempty"` + InnerTransaction *Transaction `protobuf:"bytes,16,opt,name=InnerTransaction,proto3" json:"innerTransaction,omitempty"` } func (m *Transaction) Reset() { *m = Transaction{} } @@ -181,7 +181,7 @@ func (m *Transaction) GetGuardianSignature() []byte { return nil } -func (m *Transaction) GetInnerTransaction() []byte { +func (m *Transaction) GetInnerTransaction() *Transaction { if m != nil { return m.InnerTransaction } @@ -195,44 +195,45 @@ func init() { func init() { proto.RegisterFile("transaction.proto", fileDescriptor_2cc4e03d2c28c490) } var fileDescriptor_2cc4e03d2c28c490 = []byte{ - // 592 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x6e, 0xd3, 0x30, - 0x00, 0xae, 0x61, 0x6d, 0x37, 0xb7, 0x1b, 0x9b, 0xd1, 0xc0, 0x0c, 0xc9, 0x9e, 0x10, 0x4c, 0x3b, - 0xd0, 0x46, 0x02, 0x71, 0x61, 0x27, 0xba, 0xa1, 0xa9, 0x08, 0x06, 0xca, 0x60, 0x07, 0x6e, 0x6e, - 0x62, 0x52, 0x4b, 0x8b, 0x3d, 0x39, 0x6e, 0x35, 0x0e, 0x48, 0x3c, 0x02, 0x8f, 0x81, 0x78, 0x12, - 0x8e, 0x3b, 0xee, 0x14, 0x58, 0x76, 0x41, 0x39, 0xed, 0x05, 0x90, 0x50, 0x9c, 0x76, 0xf1, 0xba, - 0x13, 0xa7, 0xd8, 0xdf, 0xaf, 0x65, 0xc7, 0x86, 0x2b, 0x46, 0x33, 0x99, 0xb0, 0xc0, 0x08, 0x25, - 0xbb, 0x47, 0x5a, 0x19, 0x85, 0xea, 0xf6, 0xb3, 0xd6, 0x89, 0x84, 0x19, 0x8e, 0x06, 0xdd, 0x40, - 0xc5, 0x5e, 0xa4, 0x22, 0xe5, 0x59, 0x78, 0x30, 0xfa, 0x64, 0x67, 0x76, 0x62, 0x47, 0xa5, 0xeb, - 0xc1, 0xdf, 0x06, 0x6c, 0xbd, 0xaf, 0xb2, 0x10, 0x85, 0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 0xda, 0xb9, 0x37, 0x78, 0xd9, 0xa6, 0x91, 0x3c, 0xa5, 0x6b, 0x62, 0x86, 0x73, 0xc2, - 0xae, 0xf9, 0x7a, 0x5f, 0x4e, 0xce, 0x48, 0xed, 0xf4, 0x8c, 0xd4, 0x2e, 0xce, 0x08, 0xf8, 0x9a, - 0x11, 0xf0, 0x3d, 0x23, 0xe0, 0x67, 0x46, 0xc0, 0x49, 0x46, 0xc0, 0x69, 0x46, 0xc0, 0xef, 0x8c, - 0x80, 0x3f, 0x19, 0xa9, 0x5d, 0x64, 0x04, 0x7c, 0x3b, 0x27, 0xb5, 0x93, 0x73, 0x52, 0x3b, 0x3d, - 0x27, 0xb5, 0x8f, 0xdb, 0xff, 0x71, 0xbf, 0x3c, 0xe7, 0xb9, 0xd8, 0x72, 0xc6, 0x83, 0x86, 0x7d, - 0x05, 0x9e, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xe8, 0x47, 0x21, 0xb0, 0x50, 0x04, 0x00, 0x00, + // 607 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x41, 0x6f, 0xd3, 0x3c, + 0x1c, 0xc6, 0xeb, 0xf7, 0x5d, 0x97, 0xcd, 0xed, 0xc6, 0x66, 0x34, 0x30, 0x43, 0xb2, 0x2b, 0x04, + 0x53, 0x0f, 0xb4, 0x91, 0x86, 0xb8, 0xb0, 0x13, 0xdd, 0xd0, 0x54, 0x09, 0x06, 0xca, 0x60, 0x07, + 0x0e, 0x48, 0x6e, 0x62, 0x52, 0x4b, 0x8b, 0x3d, 0x39, 0x6e, 0x35, 0x0e, 0x48, 0x7c, 0x04, 0xf8, + 0x16, 0x88, 0x4f, 0xc2, 0x71, 0xc7, 0x9d, 0x02, 0xcb, 0x2e, 0x28, 0xa7, 0x7d, 0x04, 0x14, 0xa7, + 0x5d, 0xbd, 0xed, 0xc4, 0x29, 0xf6, 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 0x42, 0x8e, 0x65, 0xaa, 0x42, 0xcf, 0x60, 0x73, 0x77, 0xc4, 0x74, 0x24, 0x98, + 0xb4, 0xa7, 0xb5, 0x6c, 0xa3, 0xaa, 0x5d, 0x99, 0x70, 0xc7, 0x76, 0x45, 0x8b, 0x5e, 0xc1, 0xd5, + 0xe9, 0x7c, 0xb6, 0xd6, 0x5b, 0xb6, 0x01, 0x2d, 0x32, 0x7a, 0x3f, 0xbe, 0x5e, 0x74, 0x3a, 0xdd, + 0x74, 0xa2, 0x0f, 0x70, 0xa5, 0x2f, 0x25, 0xd7, 0xce, 0xbd, 0xc1, 0x2b, 0x2d, 0xd0, 0x6e, 0x6c, + 0xa2, 0xea, 0x56, 0x75, 0x9d, 0x4a, 0x8f, 0x14, 0x19, 0x5d, 0x17, 0xd7, 0xf4, 0x4e, 0xc0, 0x8d, + 0x5e, 0xbd, 0xcf, 0x27, 0x67, 0xa4, 0x76, 0x7a, 0x46, 0x6a, 0x17, 0x67, 0x04, 0x7c, 0xc9, 0x09, + 0xf8, 0x9e, 0x13, 0xf0, 0x33, 0x27, 0xe0, 0x24, 0x27, 0xe0, 0x34, 0x27, 0xe0, 0x77, 0x4e, 0xc0, + 0x9f, 0x9c, 0xd4, 0x2e, 0x72, 0x02, 0xbe, 0x9e, 0x93, 0xda, 0xc9, 0x39, 0xa9, 0x9d, 0x9e, 0x93, + 0xda, 0xfb, 0xed, 0x7f, 0xb8, 0x73, 0xbe, 0xf3, 0x0b, 0xd9, 0x72, 0xc6, 0x83, 0x79, 0xfb, 0x0e, + 0x4f, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0xd6, 0x91, 0x2c, 0x8b, 0x64, 0x04, 0x00, 0x00, } func (this *Transaction) Equal(that interface{}) bool { @@ -302,7 +303,7 @@ func (this *Transaction) Equal(that interface{}) bool { if !bytes.Equal(this.GuardianSignature, that1.GuardianSignature) { return false } - if !bytes.Equal(this.InnerTransaction, that1.InnerTransaction) { + if !this.InnerTransaction.Equal(that1.InnerTransaction) { return false } return true @@ -328,7 +329,9 @@ func (this *Transaction) GoString() string { s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n") s = append(s, "GuardianAddr: "+fmt.Sprintf("%#v", this.GuardianAddr)+",\n") s = append(s, "GuardianSignature: "+fmt.Sprintf("%#v", this.GuardianSignature)+",\n") - s = append(s, "InnerTransaction: "+fmt.Sprintf("%#v", this.InnerTransaction)+",\n") + if this.InnerTransaction != nil { + s = append(s, "InnerTransaction: "+fmt.Sprintf("%#v", this.InnerTransaction)+",\n") + } s = append(s, "}") return strings.Join(s, "") } @@ -360,10 +363,15 @@ func (m *Transaction) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.InnerTransaction) > 0 { - i -= len(m.InnerTransaction) - copy(dAtA[i:], m.InnerTransaction) - i = encodeVarintTransaction(dAtA, i, uint64(len(m.InnerTransaction))) + if m.InnerTransaction != nil { + { + size, err := m.InnerTransaction.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTransaction(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0x1 i-- @@ -544,8 +552,8 @@ func (m *Transaction) Size() (n int) { if l > 0 { n += 1 + l + sovTransaction(uint64(l)) } - l = len(m.InnerTransaction) - if l > 0 { + if m.InnerTransaction != nil { + l = m.InnerTransaction.Size() n += 2 + l + sovTransaction(uint64(l)) } return n @@ -577,7 +585,7 @@ func (this *Transaction) String() string { `Options:` + fmt.Sprintf("%v", this.Options) + `,`, `GuardianAddr:` + fmt.Sprintf("%v", this.GuardianAddr) + `,`, `GuardianSignature:` + fmt.Sprintf("%v", this.GuardianSignature) + `,`, - `InnerTransaction:` + fmt.Sprintf("%v", this.InnerTransaction) + `,`, + `InnerTransaction:` + strings.Replace(this.InnerTransaction.String(), "Transaction", "Transaction", 1) + `,`, `}`, }, "") return s @@ -1062,7 +1070,7 @@ func (m *Transaction) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field InnerTransaction", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTransaction @@ -1072,24 +1080,26 @@ func (m *Transaction) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthTransaction } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTransaction } if postIndex > l { return io.ErrUnexpectedEOF } - m.InnerTransaction = append(m.InnerTransaction[:0], dAtA[iNdEx:postIndex]...) if m.InnerTransaction == nil { - m.InnerTransaction = []byte{} + m.InnerTransaction = &Transaction{} + } + if err := m.InnerTransaction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex default: diff --git a/data/transaction/transaction.proto b/data/transaction/transaction.proto index 39180eefb..584d0a17d 100644 --- a/data/transaction/transaction.proto +++ b/data/transaction/transaction.proto @@ -15,20 +15,20 @@ import "github.com/gogo/protobuf/gogoproto/gogo.proto"; // Transaction holds all the data needed for a value transfer or SC call message Transaction { - uint64 Nonce = 1 [(gogoproto.jsontag) = "nonce"]; - bytes Value = 2 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; - bytes RcvAddr = 3 [(gogoproto.jsontag) = "receiver"]; - bytes RcvUserName = 4 [(gogoproto.jsontag) = "rcvUserName,omitempty"]; - bytes SndAddr = 5 [(gogoproto.jsontag) = "sender"]; - bytes SndUserName = 6 [(gogoproto.jsontag) = "sndUserName,omitempty"]; - uint64 GasPrice = 7 [(gogoproto.jsontag) = "gasPrice,omitempty"]; - uint64 GasLimit = 8 [(gogoproto.jsontag) = "gasLimit,omitempty"]; - bytes Data = 9 [(gogoproto.jsontag) = "data,omitempty"]; - bytes ChainID = 10 [(gogoproto.jsontag) = "chainID"]; - uint32 Version = 11 [(gogoproto.jsontag) = "version"]; - bytes Signature = 12 [(gogoproto.jsontag) = "signature,omitempty"]; - uint32 Options = 13 [(gogoproto.jsontag) = "options,omitempty"]; - bytes GuardianAddr = 14 [(gogoproto.jsontag) = "guardian,omitempty"]; - bytes GuardianSignature = 15 [(gogoproto.jsontag) = "guardianSignature,omitempty"]; - bytes InnerTransaction = 16 [(gogoproto.jsontag) = "innerTransaction,omitempty"]; + uint64 Nonce = 1 [(gogoproto.jsontag) = "nonce"]; + bytes Value = 2 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes RcvAddr = 3 [(gogoproto.jsontag) = "receiver"]; + bytes RcvUserName = 4 [(gogoproto.jsontag) = "rcvUserName,omitempty"]; + bytes SndAddr = 5 [(gogoproto.jsontag) = "sender"]; + bytes SndUserName = 6 [(gogoproto.jsontag) = "sndUserName,omitempty"]; + uint64 GasPrice = 7 [(gogoproto.jsontag) = "gasPrice,omitempty"]; + uint64 GasLimit = 8 [(gogoproto.jsontag) = "gasLimit,omitempty"]; + bytes Data = 9 [(gogoproto.jsontag) = "data,omitempty"]; + bytes ChainID = 10 [(gogoproto.jsontag) = "chainID"]; + uint32 Version = 11 [(gogoproto.jsontag) = "version"]; + bytes Signature = 12 [(gogoproto.jsontag) = "signature,omitempty"]; + uint32 Options = 13 [(gogoproto.jsontag) = "options,omitempty"]; + bytes GuardianAddr = 14 [(gogoproto.jsontag) = "guardian,omitempty"]; + bytes GuardianSignature = 15 [(gogoproto.jsontag) = "guardianSignature,omitempty"]; + Transaction InnerTransaction = 16 [(gogoproto.jsontag) = "innerTransaction,omitempty"]; } diff --git a/data/transaction/transaction_test.go b/data/transaction/transaction_test.go index bcc78e180..8c89fac5d 100644 --- a/data/transaction/transaction_test.go +++ b/data/transaction/transaction_test.go @@ -23,7 +23,9 @@ func TestTransaction_SettersAndGetters(t *testing.T) { gasLimit := uint64(5) sender := []byte("sndr") receiver := []byte("receiver") - innerTx := []byte("inner tx") + innerTx := &transaction.Transaction{ + Nonce: 123, + } tx := &transaction.Transaction{ Nonce: nonce, @@ -53,15 +55,17 @@ func TestTransaction_MarshalUnmarshalJsonShouldWork(t *testing.T) { value := big.NewInt(445566) tx := &transaction.Transaction{ - Nonce: 112233, - Value: new(big.Int).Set(value), - RcvAddr: []byte("receiver"), - SndAddr: []byte("sender"), - GasPrice: 1234, - GasLimit: 5678, - Data: []byte("data"), - Signature: []byte("signature"), - InnerTransaction: []byte("inner tx"), + Nonce: 112233, + Value: new(big.Int).Set(value), + RcvAddr: []byte("receiver"), + SndAddr: []byte("sender"), + GasPrice: 1234, + GasLimit: 5678, + Data: []byte("data"), + Signature: []byte("signature"), + InnerTransaction: &transaction.Transaction{ + Nonce: 123, + }, } buff, err := json.Marshal(tx) @@ -265,16 +269,13 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { tx1 := &transaction.Transaction{ Nonce: 1, } - innerTxBuff, err := json.Marshal(tx1) - assert.NoError(t, err) tx := &transaction.Transaction{ Nonce: 3, - InnerTransaction: innerTxBuff, + InnerTransaction: tx1, } numEncodeCalled := 0 marshallWasCalled := false - unmarshallWasCalled := false hasherWasCalled := false buff, err := tx.GetDataForSigning( &mock.PubkeyConverterStub{ @@ -289,11 +290,6 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { return json.Marshal(obj) }, - UnmarshalCalled: func(obj interface{}, buff []byte) error { - unmarshallWasCalled = true - - return json.Unmarshal(buff, obj) - }, }, &mock.HasherStub{ ComputeCalled: func(s string) []byte { @@ -311,7 +307,6 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { assert.Nil(t, err) assert.True(t, marshallWasCalled) - assert.True(t, unmarshallWasCalled) assert.False(t, hasherWasCalled) assert.Equal(t, 4, numEncodeCalled) }) From 4b6ee196f511b20e82fcefb223593c9d1fdcd801 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Wed, 20 Sep 2023 17:47:52 +0300 Subject: [PATCH 10/27] fixed inner tx preparation --- data/transaction/transaction.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 7c5040c40..192fd640c 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -79,7 +79,7 @@ func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.M } if tx.InnerTransaction != nil { - ftx.InnerTransaction, err = tx.prepareTx(encoder) + ftx.InnerTransaction, err = tx.InnerTransaction.prepareTx(encoder) if err != nil { return nil, err } From 7aa5258279f742238ff1e2a3561b96ecd9ef1ad1 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Wed, 20 Sep 2023 18:20:19 +0300 Subject: [PATCH 11/27] use inner tx signature when returning data for signing --- data/transaction/transaction.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 192fd640c..6b9e4debb 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -2,6 +2,7 @@ package transaction import ( + "encoding/hex" "math/big" "github.com/multiversx/mx-chain-core-go/core" @@ -83,6 +84,9 @@ func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.M if err != nil { return nil, err } + + ftx.InnerTransaction.Signature = hex.EncodeToString(tx.InnerTransaction.Signature) + ftx.InnerTransaction.GuardianSignature = hex.EncodeToString(tx.InnerTransaction.GuardianSignature) } ftxBytes, err := marshaller.Marshal(ftx) From afd6941049cf79499ec2375923dc8027bedb7272 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Thu, 21 Sep 2023 11:17:23 +0300 Subject: [PATCH 12/27] added optional relayer address on tx --- data/transaction/frontendTransaction.go | 1 + data/transaction/transaction.go | 14 ++- data/transaction/transaction.pb.go | 144 +++++++++++++++++------- data/transaction/transaction.proto | 3 +- data/transaction/transaction_test.go | 12 +- 5 files changed, 122 insertions(+), 52 deletions(-) diff --git a/data/transaction/frontendTransaction.go b/data/transaction/frontendTransaction.go index c627a5164..820014f73 100644 --- a/data/transaction/frontendTransaction.go +++ b/data/transaction/frontendTransaction.go @@ -17,5 +17,6 @@ type FrontendTransaction struct { Options uint32 `json:"options,omitempty"` GuardianAddr string `json:"guardian,omitempty"` GuardianSignature string `json:"guardianSignature,omitempty"` + Relayer string `json:"relayer,omitempty"` InnerTransaction *FrontendTransaction `json:"innerTransaction,omitempty"` } diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 6b9e4debb..575f3b80f 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -37,11 +37,6 @@ func (tx *Transaction) SetSndAddr(addr []byte) { tx.SndAddr = addr } -// SetInnerTransaction sets the inner transaction of the transaction -func (tx *Transaction) SetInnerTransaction(innerTransaction *Transaction) { - tx.InnerTransaction = innerTransaction -} - // TrimSlicePtr creates a copy of the provided slice without the excess capacity func TrimSlicePtr(in []*Transaction) []*Transaction { if len(in) == 0 { @@ -161,6 +156,15 @@ func (tx *Transaction) prepareTx(encoder data.Encoder) (*FrontendTransaction, er Options: tx.Options, } + if len(tx.RelayedAddr) > 0 { + relayerAddr, errRelayer := encoder.Encode(tx.RelayedAddr) + if errRelayer != nil { + return nil, errRelayer + } + + ftx.Relayer = relayerAddr + } + if len(tx.GuardianAddr) > 0 { guardianAddr, errGuardian := encoder.Encode(tx.GuardianAddr) if errGuardian != nil { diff --git a/data/transaction/transaction.pb.go b/data/transaction/transaction.pb.go index 95f6b9597..48783a2b4 100644 --- a/data/transaction/transaction.pb.go +++ b/data/transaction/transaction.pb.go @@ -45,7 +45,8 @@ type Transaction struct { Options uint32 `protobuf:"varint,13,opt,name=Options,proto3" json:"options,omitempty"` GuardianAddr []byte `protobuf:"bytes,14,opt,name=GuardianAddr,proto3" json:"guardian,omitempty"` GuardianSignature []byte `protobuf:"bytes,15,opt,name=GuardianSignature,proto3" json:"guardianSignature,omitempty"` - InnerTransaction *Transaction `protobuf:"bytes,16,opt,name=InnerTransaction,proto3" json:"innerTransaction,omitempty"` + RelayedAddr []byte `protobuf:"bytes,16,opt,name=RelayedAddr,proto3" json:"relayer,omitempty"` + InnerTransaction *Transaction `protobuf:"bytes,17,opt,name=InnerTransaction,proto3" json:"innerTransaction,omitempty"` } func (m *Transaction) Reset() { *m = Transaction{} } @@ -181,6 +182,13 @@ func (m *Transaction) GetGuardianSignature() []byte { return nil } +func (m *Transaction) GetRelayedAddr() []byte { + if m != nil { + return m.RelayedAddr + } + return nil +} + func (m *Transaction) GetInnerTransaction() *Transaction { if m != nil { return m.InnerTransaction @@ -195,45 +203,47 @@ func init() { func init() { proto.RegisterFile("transaction.proto", fileDescriptor_2cc4e03d2c28c490) } var fileDescriptor_2cc4e03d2c28c490 = []byte{ - // 607 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x41, 0x6f, 0xd3, 0x3c, - 0x1c, 0xc6, 0xeb, 0xf7, 0x5d, 0x97, 0xcd, 0xed, 0xc6, 0x66, 0x34, 0x30, 0x43, 0xb2, 0x2b, 0x04, - 0x53, 0x0f, 0xb4, 0x91, 0x86, 0xb8, 0xb0, 0x13, 0xdd, 0xd0, 0x54, 0x09, 0x06, 0xca, 0x60, 0x07, - 0x0e, 0x48, 0x6e, 0x62, 0x52, 0x4b, 0x8b, 0x3d, 0x39, 0x6e, 0x35, 0x0e, 0x48, 0x7c, 0x04, 0xf8, - 0x16, 0x88, 0x4f, 0xc2, 0x71, 0xc7, 0x9d, 0x02, 0xcb, 0x2e, 0x28, 0xa7, 0x7d, 0x04, 0x14, 0xa7, - 0x5d, 0xbd, 0xed, 0xc4, 0x29, 0xf6, 0xef, 0xff, 0x3c, 0xff, 0xc7, 0xb1, 0xe3, 0xc0, 0x55, 0xa3, - 0x99, 0x4c, 0x59, 0x68, 0x84, 0x92, 0xdd, 0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0xa3, 0xaa, 0x5d, 0x99, 0x70, 0xc7, 0x76, 0x45, 0x8b, 0x5e, 0xc1, 0xd5, - 0xe9, 0x7c, 0xb6, 0xd6, 0x5b, 0xb6, 0x01, 0x2d, 0x32, 0x7a, 0x3f, 0xbe, 0x5e, 0x74, 0x3a, 0xdd, - 0x74, 0xa2, 0x0f, 0x70, 0xa5, 0x2f, 0x25, 0xd7, 0xce, 0xbd, 0xc1, 0x2b, 0x2d, 0xd0, 0x6e, 0x6c, - 0xa2, 0xea, 0x56, 0x75, 0x9d, 0x4a, 0x8f, 0x14, 0x19, 0x5d, 0x17, 0xd7, 0xf4, 0x4e, 0xc0, 0x8d, - 0x5e, 0xbd, 0xcf, 0x27, 0x67, 0xa4, 0x76, 0x7a, 0x46, 0x6a, 0x17, 0x67, 0x04, 0x7c, 0xc9, 0x09, - 0xf8, 0x9e, 0x13, 0xf0, 0x33, 0x27, 0xe0, 0x24, 0x27, 0xe0, 0x34, 0x27, 0xe0, 0x77, 0x4e, 0xc0, - 0x9f, 0x9c, 0xd4, 0x2e, 0x72, 0x02, 0xbe, 0x9e, 0x93, 0xda, 0xc9, 0x39, 0xa9, 0x9d, 0x9e, 0x93, - 0xda, 0xfb, 0xed, 0x7f, 0xb8, 0x73, 0xbe, 0xf3, 0x0b, 0xd9, 0x72, 0xc6, 0x83, 0x79, 0xfb, 0x0e, - 0x4f, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0xd6, 0x91, 0x2c, 0x8b, 0x64, 0x04, 0x00, 0x00, + // 627 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcf, 0x6e, 0xd3, 0x3e, + 0x1c, 0xaf, 0x7f, 0xbf, 0x75, 0xd9, 0xdc, 0x6e, 0xac, 0x46, 0x83, 0x30, 0x24, 0xbb, 0x42, 0x30, + 0xf5, 0x40, 0x1b, 0x69, 0x08, 0x21, 0xb1,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0, 0xeb, 0x39, 0xae, 0x9d, 0x9c, 0xe3, + 0xda, 0xe9, 0x39, 0xae, 0x7d, 0xd8, 0xfa, 0x87, 0xcb, 0xea, 0x59, 0xdf, 0x9e, 0x4d, 0xeb, 0x79, + 0x38, 0x6f, 0xfe, 0xc3, 0x93, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xee, 0x17, 0x8f, 0x8e, 0x9d, + 0x04, 0x00, 0x00, } func (this *Transaction) Equal(that interface{}) bool { @@ -303,6 +313,9 @@ func (this *Transaction) Equal(that interface{}) bool { if !bytes.Equal(this.GuardianSignature, that1.GuardianSignature) { return false } + if !bytes.Equal(this.RelayedAddr, that1.RelayedAddr) { + return false + } if !this.InnerTransaction.Equal(that1.InnerTransaction) { return false } @@ -312,7 +325,7 @@ func (this *Transaction) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 20) + s := make([]string, 0, 21) s = append(s, "&transaction.Transaction{") s = append(s, "Nonce: "+fmt.Sprintf("%#v", this.Nonce)+",\n") s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") @@ -329,6 +342,7 @@ func (this *Transaction) GoString() string { s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n") s = append(s, "GuardianAddr: "+fmt.Sprintf("%#v", this.GuardianAddr)+",\n") s = append(s, "GuardianSignature: "+fmt.Sprintf("%#v", this.GuardianSignature)+",\n") + s = append(s, "RelayedAddr: "+fmt.Sprintf("%#v", this.RelayedAddr)+",\n") if this.InnerTransaction != nil { s = append(s, "InnerTransaction: "+fmt.Sprintf("%#v", this.InnerTransaction)+",\n") } @@ -375,6 +389,15 @@ func (m *Transaction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1 i-- + dAtA[i] = 0x8a + } + if len(m.RelayedAddr) > 0 { + i -= len(m.RelayedAddr) + copy(dAtA[i:], m.RelayedAddr) + i = encodeVarintTransaction(dAtA, i, uint64(len(m.RelayedAddr))) + i-- + dAtA[i] = 0x1 + i-- dAtA[i] = 0x82 } if len(m.GuardianSignature) > 0 { @@ -552,6 +575,10 @@ func (m *Transaction) Size() (n int) { if l > 0 { n += 1 + l + sovTransaction(uint64(l)) } + l = len(m.RelayedAddr) + if l > 0 { + n += 2 + l + sovTransaction(uint64(l)) + } if m.InnerTransaction != nil { l = m.InnerTransaction.Size() n += 2 + l + sovTransaction(uint64(l)) @@ -585,6 +612,7 @@ func (this *Transaction) String() string { `Options:` + fmt.Sprintf("%v", this.Options) + `,`, `GuardianAddr:` + fmt.Sprintf("%v", this.GuardianAddr) + `,`, `GuardianSignature:` + fmt.Sprintf("%v", this.GuardianSignature) + `,`, + `RelayedAddr:` + fmt.Sprintf("%v", this.RelayedAddr) + `,`, `InnerTransaction:` + strings.Replace(this.InnerTransaction.String(), "Transaction", "Transaction", 1) + `,`, `}`, }, "") @@ -1067,6 +1095,40 @@ func (m *Transaction) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RelayedAddr", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTransaction + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTransaction + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTransaction + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RelayedAddr = append(m.RelayedAddr[:0], dAtA[iNdEx:postIndex]...) + if m.RelayedAddr == nil { + m.RelayedAddr = []byte{} + } + iNdEx = postIndex + case 17: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field InnerTransaction", wireType) } diff --git a/data/transaction/transaction.proto b/data/transaction/transaction.proto index 584d0a17d..f727b853f 100644 --- a/data/transaction/transaction.proto +++ b/data/transaction/transaction.proto @@ -30,5 +30,6 @@ message Transaction { uint32 Options = 13 [(gogoproto.jsontag) = "options,omitempty"]; bytes GuardianAddr = 14 [(gogoproto.jsontag) = "guardian,omitempty"]; bytes GuardianSignature = 15 [(gogoproto.jsontag) = "guardianSignature,omitempty"]; - Transaction InnerTransaction = 16 [(gogoproto.jsontag) = "innerTransaction,omitempty"]; + bytes RelayedAddr = 16 [(gogoproto.jsontag) = "relayer,omitempty"]; + Transaction InnerTransaction = 17 [(gogoproto.jsontag) = "innerTransaction,omitempty"]; } diff --git a/data/transaction/transaction_test.go b/data/transaction/transaction_test.go index 8c89fac5d..38be7fbed 100644 --- a/data/transaction/transaction_test.go +++ b/data/transaction/transaction_test.go @@ -24,13 +24,15 @@ func TestTransaction_SettersAndGetters(t *testing.T) { sender := []byte("sndr") receiver := []byte("receiver") innerTx := &transaction.Transaction{ - Nonce: 123, + Nonce: 123, + RelayedAddr: sender, } tx := &transaction.Transaction{ - Nonce: nonce, - GasPrice: gasPrice, - GasLimit: gasLimit, + Nonce: nonce, + GasPrice: gasPrice, + GasLimit: gasLimit, + InnerTransaction: innerTx, } assert.False(t, check.IfNil(tx)) @@ -38,7 +40,6 @@ func TestTransaction_SettersAndGetters(t *testing.T) { tx.SetData(txData) tx.SetValue(value) tx.SetRcvAddr(receiver) - tx.SetInnerTransaction(innerTx) assert.Equal(t, nonce, tx.GetNonce()) assert.Equal(t, value, tx.GetValue()) @@ -48,6 +49,7 @@ func TestTransaction_SettersAndGetters(t *testing.T) { assert.Equal(t, sender, tx.GetSndAddr()) assert.Equal(t, receiver, tx.GetRcvAddr()) assert.Equal(t, innerTx, tx.GetInnerTransaction()) + assert.Equal(t, sender, tx.GetInnerTransaction().GetRelayedAddr()) } func TestTransaction_MarshalUnmarshalJsonShouldWork(t *testing.T) { From 48fd7cc48186c18c1814086b634bf11d3e30f92c Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Thu, 21 Sep 2023 11:20:11 +0300 Subject: [PATCH 13/27] removed previously added method from interface --- data/interface.go | 1 - 1 file changed, 1 deletion(-) diff --git a/data/interface.go b/data/interface.go index 748868fe7..80b039da2 100644 --- a/data/interface.go +++ b/data/interface.go @@ -296,7 +296,6 @@ type Encoder interface { // Marshaller is able to encode an object to its byte slice representation type Marshaller interface { Marshal(obj interface{}) ([]byte, error) - Unmarshal(obj interface{}, buff []byte) error IsInterfaceNil() bool } From 1e73b4f43019546bef32ca0f91d5577b9709157a Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Mon, 25 Sep 2023 12:19:36 +0300 Subject: [PATCH 14/27] fix typo after self review --- data/transaction/transaction.go | 4 +-- data/transaction/transaction.pb.go | 50 ++++++++++++++-------------- data/transaction/transaction.proto | 2 +- data/transaction/transaction_test.go | 4 +-- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 575f3b80f..1c62c7f7e 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -156,8 +156,8 @@ func (tx *Transaction) prepareTx(encoder data.Encoder) (*FrontendTransaction, er Options: tx.Options, } - if len(tx.RelayedAddr) > 0 { - relayerAddr, errRelayer := encoder.Encode(tx.RelayedAddr) + if len(tx.RelayerAddr) > 0 { + relayerAddr, errRelayer := encoder.Encode(tx.RelayerAddr) if errRelayer != nil { return nil, errRelayer } diff --git a/data/transaction/transaction.pb.go b/data/transaction/transaction.pb.go index 48783a2b4..b19e9438f 100644 --- a/data/transaction/transaction.pb.go +++ b/data/transaction/transaction.pb.go @@ -45,7 +45,7 @@ type Transaction struct { Options uint32 `protobuf:"varint,13,opt,name=Options,proto3" json:"options,omitempty"` GuardianAddr []byte `protobuf:"bytes,14,opt,name=GuardianAddr,proto3" json:"guardian,omitempty"` GuardianSignature []byte `protobuf:"bytes,15,opt,name=GuardianSignature,proto3" json:"guardianSignature,omitempty"` - RelayedAddr []byte `protobuf:"bytes,16,opt,name=RelayedAddr,proto3" json:"relayer,omitempty"` + RelayerAddr []byte `protobuf:"bytes,16,opt,name=RelayerAddr,proto3" json:"relayer,omitempty"` InnerTransaction *Transaction `protobuf:"bytes,17,opt,name=InnerTransaction,proto3" json:"innerTransaction,omitempty"` } @@ -182,9 +182,9 @@ func (m *Transaction) GetGuardianSignature() []byte { return nil } -func (m *Transaction) GetRelayedAddr() []byte { +func (m *Transaction) GetRelayerAddr() []byte { if m != nil { - return m.RelayedAddr + return m.RelayerAddr } return nil } @@ -203,7 +203,7 @@ func init() { func init() { proto.RegisterFile("transaction.proto", fileDescriptor_2cc4e03d2c28c490) } var fileDescriptor_2cc4e03d2c28c490 = []byte{ - // 627 bytes of a gzipped FileDescriptorProto + // 626 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcf, 0x6e, 0xd3, 0x3e, 0x1c, 0xaf, 0x7f, 0xbf, 0x75, 0xd9, 0xdc, 0x6e, 0xac, 0x46, 0x83, 0x30, 0x24, 0xbb, 0x42, 0x30, 0xf5, 0x40, 0x1b, 0x69, 0x08, 0x21, 0xb1, 0x13, 0xdd, 0xd0, 0x54, 0x09, 0x06, 0xca, 0x60, 0x07, @@ -235,15 +235,15 @@ var fileDescriptor_2cc4e03d2c28c490 = []byte{ 0x92, 0x25, 0x64, 0x59, 0x66, 0x2a, 0xf4, 0x1c, 0x36, 0x77, 0xc6, 0x54, 0x85, 0x9c, 0x0a, 0xf3, 0xb6, 0x96, 0x4d, 0x55, 0xb9, 0x2b, 0x53, 0xdc, 0xb2, 0x5d, 0xd1, 0xa2, 0xd7, 0xb0, 0x35, 0x5b, 0x57, 0xb3, 0xde, 0x32, 0x01, 0x24, 0x4f, 0xc9, 0xfd, 0xe8, 0x3a, 0x69, 0x25, 0xdd, 0x74, 0xa2, - 0x67, 0xb0, 0xe1, 0xb3, 0x03, 0x7a, 0xcc, 0xca, 0x73, 0xb3, 0x62, 0x82, 0xcc, 0xfc, 0xca, 0xc0, - 0xea, 0xca, 0x61, 0x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 0x47, 0x86, 0xc1, 0x49, 0x86, 0xc1, 0x69, 0x86, 0xc1, + 0xef, 0x0c, 0x83, 0x3f, 0x19, 0xae, 0x5d, 0x64, 0x18, 0x7c, 0x3d, 0xc7, 0xb5, 0x93, 0x73, 0x5c, + 0x3b, 0x3d, 0xc7, 0xb5, 0x0f, 0x5b, 0xff, 0x70, 0x59, 0x3d, 0xeb, 0xdb, 0xb3, 0x69, 0x3d, 0x0f, + 0xe7, 0xcd, 0x7f, 0x78, 0xf2, 0x37, 0x00, 0x00, 0xff, 0xff, 0x2a, 0xdc, 0x62, 0xaa, 0x9d, 0x04, + 0x00, 0x00, } func (this *Transaction) Equal(that interface{}) bool { @@ -313,7 +313,7 @@ func (this *Transaction) Equal(that interface{}) bool { if !bytes.Equal(this.GuardianSignature, that1.GuardianSignature) { return false } - if !bytes.Equal(this.RelayedAddr, that1.RelayedAddr) { + if !bytes.Equal(this.RelayerAddr, that1.RelayerAddr) { return false } if !this.InnerTransaction.Equal(that1.InnerTransaction) { @@ -342,7 +342,7 @@ func (this *Transaction) GoString() string { s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n") s = append(s, "GuardianAddr: "+fmt.Sprintf("%#v", this.GuardianAddr)+",\n") s = append(s, "GuardianSignature: "+fmt.Sprintf("%#v", this.GuardianSignature)+",\n") - s = append(s, "RelayedAddr: "+fmt.Sprintf("%#v", this.RelayedAddr)+",\n") + s = append(s, "RelayerAddr: "+fmt.Sprintf("%#v", this.RelayerAddr)+",\n") if this.InnerTransaction != nil { s = append(s, "InnerTransaction: "+fmt.Sprintf("%#v", this.InnerTransaction)+",\n") } @@ -391,10 +391,10 @@ func (m *Transaction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x8a } - if len(m.RelayedAddr) > 0 { - i -= len(m.RelayedAddr) - copy(dAtA[i:], m.RelayedAddr) - i = encodeVarintTransaction(dAtA, i, uint64(len(m.RelayedAddr))) + if len(m.RelayerAddr) > 0 { + i -= len(m.RelayerAddr) + copy(dAtA[i:], m.RelayerAddr) + i = encodeVarintTransaction(dAtA, i, uint64(len(m.RelayerAddr))) i-- dAtA[i] = 0x1 i-- @@ -575,7 +575,7 @@ func (m *Transaction) Size() (n int) { if l > 0 { n += 1 + l + sovTransaction(uint64(l)) } - l = len(m.RelayedAddr) + l = len(m.RelayerAddr) if l > 0 { n += 2 + l + sovTransaction(uint64(l)) } @@ -612,7 +612,7 @@ func (this *Transaction) String() string { `Options:` + fmt.Sprintf("%v", this.Options) + `,`, `GuardianAddr:` + fmt.Sprintf("%v", this.GuardianAddr) + `,`, `GuardianSignature:` + fmt.Sprintf("%v", this.GuardianSignature) + `,`, - `RelayedAddr:` + fmt.Sprintf("%v", this.RelayedAddr) + `,`, + `RelayerAddr:` + fmt.Sprintf("%v", this.RelayerAddr) + `,`, `InnerTransaction:` + strings.Replace(this.InnerTransaction.String(), "Transaction", "Transaction", 1) + `,`, `}`, }, "") @@ -1096,7 +1096,7 @@ func (m *Transaction) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 16: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RelayedAddr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RelayerAddr", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1123,9 +1123,9 @@ func (m *Transaction) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RelayedAddr = append(m.RelayedAddr[:0], dAtA[iNdEx:postIndex]...) - if m.RelayedAddr == nil { - m.RelayedAddr = []byte{} + m.RelayerAddr = append(m.RelayerAddr[:0], dAtA[iNdEx:postIndex]...) + if m.RelayerAddr == nil { + m.RelayerAddr = []byte{} } iNdEx = postIndex case 17: diff --git a/data/transaction/transaction.proto b/data/transaction/transaction.proto index f727b853f..626e6e432 100644 --- a/data/transaction/transaction.proto +++ b/data/transaction/transaction.proto @@ -30,6 +30,6 @@ message Transaction { uint32 Options = 13 [(gogoproto.jsontag) = "options,omitempty"]; bytes GuardianAddr = 14 [(gogoproto.jsontag) = "guardian,omitempty"]; bytes GuardianSignature = 15 [(gogoproto.jsontag) = "guardianSignature,omitempty"]; - bytes RelayedAddr = 16 [(gogoproto.jsontag) = "relayer,omitempty"]; + bytes RelayerAddr = 16 [(gogoproto.jsontag) = "relayer,omitempty"]; Transaction InnerTransaction = 17 [(gogoproto.jsontag) = "innerTransaction,omitempty"]; } diff --git a/data/transaction/transaction_test.go b/data/transaction/transaction_test.go index 38be7fbed..15ceb09ba 100644 --- a/data/transaction/transaction_test.go +++ b/data/transaction/transaction_test.go @@ -25,7 +25,7 @@ func TestTransaction_SettersAndGetters(t *testing.T) { receiver := []byte("receiver") innerTx := &transaction.Transaction{ Nonce: 123, - RelayedAddr: sender, + RelayerAddr: sender, } tx := &transaction.Transaction{ @@ -49,7 +49,7 @@ func TestTransaction_SettersAndGetters(t *testing.T) { assert.Equal(t, sender, tx.GetSndAddr()) assert.Equal(t, receiver, tx.GetRcvAddr()) assert.Equal(t, innerTx, tx.GetInnerTransaction()) - assert.Equal(t, sender, tx.GetInnerTransaction().GetRelayedAddr()) + assert.Equal(t, sender, tx.GetInnerTransaction().GetRelayerAddr()) } func TestTransaction_MarshalUnmarshalJsonShouldWork(t *testing.T) { From ab2114ef6c2826a3cd1cd8280ddb4cedba49e497 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Tue, 26 Sep 2023 12:40:53 +0300 Subject: [PATCH 15/27] fixes after first review --- data/interface.go | 1 + data/receipt/receipt.go | 5 +++++ data/receipt/receipt_test.go | 1 + data/rewardTx/rewardTx.go | 5 +++++ data/rewardTx/rewardTx_test.go | 1 + data/smartContractResult/smartContractResult.go | 5 +++++ data/smartContractResult/smartContractResult_test.go | 1 + data/transaction/transaction.go | 5 +++++ data/transaction/transaction_test.go | 2 +- 9 files changed, 25 insertions(+), 1 deletion(-) diff --git a/data/interface.go b/data/interface.go index 80b039da2..259277e48 100644 --- a/data/interface.go +++ b/data/interface.go @@ -271,6 +271,7 @@ type TransactionHandler interface { GetSndAddr() []byte GetGasLimit() uint64 GetGasPrice() uint64 + GetUserTransaction() TransactionHandler SetValue(*big.Int) SetData([]byte) diff --git a/data/receipt/receipt.go b/data/receipt/receipt.go index 992e49322..acff06aae 100644 --- a/data/receipt/receipt.go +++ b/data/receipt/receipt.go @@ -58,6 +58,11 @@ func (_ *Receipt) GetRcvUserName() []byte { return nil } +// GetUserTransaction returns nil as Receipt does not have user transaction +func (rpt *Receipt) GetUserTransaction() data.TransactionHandler { + return nil +} + // CheckIntegrity checks for not nil fields and negative value func (rpt *Receipt) CheckIntegrity() error { return nil diff --git a/data/receipt/receipt_test.go b/data/receipt/receipt_test.go index 84f689413..5621c968c 100644 --- a/data/receipt/receipt_test.go +++ b/data/receipt/receipt_test.go @@ -29,6 +29,7 @@ func TestReceipt_SettersAndGetters(t *testing.T) { assert.Equal(t, uint64(0), r.GetNonce()) assert.Equal(t, uint64(0), r.GetGasPrice()) assert.Equal(t, uint64(0), r.GetGasLimit()) + assert.Nil(t, r.GetUserTransaction()) } func TestReceipt_CheckIntegrityReturnsNil(t *testing.T) { diff --git a/data/rewardTx/rewardTx.go b/data/rewardTx/rewardTx.go index 0ccb44a5e..35ec718ba 100644 --- a/data/rewardTx/rewardTx.go +++ b/data/rewardTx/rewardTx.go @@ -62,6 +62,11 @@ func (rtx *RewardTx) GetRcvUserName() []byte { return nil } +// GetUserTransaction returns nil as RewardTx does not have user transaction +func (rtx *RewardTx) GetUserTransaction() data.TransactionHandler { + return nil +} + // CheckIntegrity checks for not nil fields and negative value func (rtx *RewardTx) CheckIntegrity() error { if len(rtx.RcvAddr) == 0 { diff --git a/data/rewardTx/rewardTx_test.go b/data/rewardTx/rewardTx_test.go index 2f8680e26..70d24bf63 100644 --- a/data/rewardTx/rewardTx_test.go +++ b/data/rewardTx/rewardTx_test.go @@ -27,6 +27,7 @@ func TestRewardTx_GettersAndSetters(t *testing.T) { assert.Equal(t, uint64(0), rwdTx.GetGasLimit()) assert.Equal(t, uint64(0), rwdTx.GetGasPrice()) assert.Equal(t, uint64(0), rwdTx.GetNonce()) + assert.Nil(t, rwdTx.GetUserTransaction()) } func TestRewardTx_CheckIntegrityShouldWork(t *testing.T) { diff --git a/data/smartContractResult/smartContractResult.go b/data/smartContractResult/smartContractResult.go index 2c2481761..198aac81f 100644 --- a/data/smartContractResult/smartContractResult.go +++ b/data/smartContractResult/smartContractResult.go @@ -39,6 +39,11 @@ func (_ *SmartContractResult) GetRcvUserName() []byte { return nil } +// GetUserTransaction returns nil as SmartContractResult does not have user transaction +func (scr *SmartContractResult) GetUserTransaction() data.TransactionHandler { + return nil +} + // TrimSlicePtr creates a copy of the provided slice without the excess capacity func TrimSlicePtr(in []*SmartContractResult) []*SmartContractResult { if len(in) == 0 { diff --git a/data/smartContractResult/smartContractResult_test.go b/data/smartContractResult/smartContractResult_test.go index 75eba8287..d477b6309 100644 --- a/data/smartContractResult/smartContractResult_test.go +++ b/data/smartContractResult/smartContractResult_test.go @@ -38,6 +38,7 @@ func TestSmartContractResult_SettersAndGetters(t *testing.T) { assert.Equal(t, gasLimit, scr.GetGasLimit()) assert.Equal(t, gasPrice, scr.GetGasPrice()) assert.Equal(t, nonce, scr.GetNonce()) + assert.Nil(t, scr.GetUserTransaction()) } func TestTrimSlicePtr(t *testing.T) { diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 1c62c7f7e..b261a7fa3 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -37,6 +37,11 @@ func (tx *Transaction) SetSndAddr(addr []byte) { tx.SndAddr = addr } +// GetUserTransaction returns the inner transaction +func (tx *Transaction) GetUserTransaction() data.TransactionHandler { + return tx.GetInnerTransaction() +} + // TrimSlicePtr creates a copy of the provided slice without the excess capacity func TrimSlicePtr(in []*Transaction) []*Transaction { if len(in) == 0 { diff --git a/data/transaction/transaction_test.go b/data/transaction/transaction_test.go index 15ceb09ba..ce8e70aea 100644 --- a/data/transaction/transaction_test.go +++ b/data/transaction/transaction_test.go @@ -48,7 +48,7 @@ func TestTransaction_SettersAndGetters(t *testing.T) { assert.Equal(t, gasLimit, tx.GetGasLimit()) assert.Equal(t, sender, tx.GetSndAddr()) assert.Equal(t, receiver, tx.GetRcvAddr()) - assert.Equal(t, innerTx, tx.GetInnerTransaction()) + assert.Equal(t, innerTx, tx.GetUserTransaction()) assert.Equal(t, sender, tx.GetInnerTransaction().GetRelayerAddr()) } From 61487cb5f8ad4f725b6ad5cac923e7eda9c6406e Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Thu, 5 Oct 2023 13:01:18 +0300 Subject: [PATCH 16/27] switched the innerTransaction field to a slice of transactions --- data/interface.go | 2 +- data/receipt/receipt.go | 4 +- data/receipt/receipt_test.go | 2 +- data/rewardTx/rewardTx.go | 4 +- data/rewardTx/rewardTx_test.go | 2 +- .../smartContractResult.go | 4 +- .../smartContractResult_test.go | 2 +- data/transaction/frontendTransaction.go | 34 ++-- data/transaction/transaction.go | 31 ++- data/transaction/transaction.pb.go | 178 ++++++++++-------- data/transaction/transaction.proto | 34 ++-- data/transaction/transaction_test.go | 32 ++-- 12 files changed, 179 insertions(+), 150 deletions(-) diff --git a/data/interface.go b/data/interface.go index 259277e48..d91079d60 100644 --- a/data/interface.go +++ b/data/interface.go @@ -271,7 +271,7 @@ type TransactionHandler interface { GetSndAddr() []byte GetGasLimit() uint64 GetGasPrice() uint64 - GetUserTransaction() TransactionHandler + GetUserTransactions() []TransactionHandler SetValue(*big.Int) SetData([]byte) diff --git a/data/receipt/receipt.go b/data/receipt/receipt.go index acff06aae..d19933df8 100644 --- a/data/receipt/receipt.go +++ b/data/receipt/receipt.go @@ -58,8 +58,8 @@ func (_ *Receipt) GetRcvUserName() []byte { return nil } -// GetUserTransaction returns nil as Receipt does not have user transaction -func (rpt *Receipt) GetUserTransaction() data.TransactionHandler { +// GetUserTransactions returns nil as Receipt does not have user transactions +func (rpt *Receipt) GetUserTransactions() []data.TransactionHandler { return nil } diff --git a/data/receipt/receipt_test.go b/data/receipt/receipt_test.go index 5621c968c..eda8ebc78 100644 --- a/data/receipt/receipt_test.go +++ b/data/receipt/receipt_test.go @@ -29,7 +29,7 @@ func TestReceipt_SettersAndGetters(t *testing.T) { assert.Equal(t, uint64(0), r.GetNonce()) assert.Equal(t, uint64(0), r.GetGasPrice()) assert.Equal(t, uint64(0), r.GetGasLimit()) - assert.Nil(t, r.GetUserTransaction()) + assert.Nil(t, r.GetUserTransactions()) } func TestReceipt_CheckIntegrityReturnsNil(t *testing.T) { diff --git a/data/rewardTx/rewardTx.go b/data/rewardTx/rewardTx.go index 35ec718ba..c9b140743 100644 --- a/data/rewardTx/rewardTx.go +++ b/data/rewardTx/rewardTx.go @@ -62,8 +62,8 @@ func (rtx *RewardTx) GetRcvUserName() []byte { return nil } -// GetUserTransaction returns nil as RewardTx does not have user transaction -func (rtx *RewardTx) GetUserTransaction() data.TransactionHandler { +// GetUserTransactions returns nil as RewardTx does not have user transactions +func (rtx *RewardTx) GetUserTransactions() []data.TransactionHandler { return nil } diff --git a/data/rewardTx/rewardTx_test.go b/data/rewardTx/rewardTx_test.go index 70d24bf63..043d10586 100644 --- a/data/rewardTx/rewardTx_test.go +++ b/data/rewardTx/rewardTx_test.go @@ -27,7 +27,7 @@ func TestRewardTx_GettersAndSetters(t *testing.T) { assert.Equal(t, uint64(0), rwdTx.GetGasLimit()) assert.Equal(t, uint64(0), rwdTx.GetGasPrice()) assert.Equal(t, uint64(0), rwdTx.GetNonce()) - assert.Nil(t, rwdTx.GetUserTransaction()) + assert.Nil(t, rwdTx.GetUserTransactions()) } func TestRewardTx_CheckIntegrityShouldWork(t *testing.T) { diff --git a/data/smartContractResult/smartContractResult.go b/data/smartContractResult/smartContractResult.go index 198aac81f..f8ea3324e 100644 --- a/data/smartContractResult/smartContractResult.go +++ b/data/smartContractResult/smartContractResult.go @@ -39,8 +39,8 @@ func (_ *SmartContractResult) GetRcvUserName() []byte { return nil } -// GetUserTransaction returns nil as SmartContractResult does not have user transaction -func (scr *SmartContractResult) GetUserTransaction() data.TransactionHandler { +// GetUserTransactions returns nil as SmartContractResult does not have user transactions +func (scr *SmartContractResult) GetUserTransactions() []data.TransactionHandler { return nil } diff --git a/data/smartContractResult/smartContractResult_test.go b/data/smartContractResult/smartContractResult_test.go index d477b6309..50e261431 100644 --- a/data/smartContractResult/smartContractResult_test.go +++ b/data/smartContractResult/smartContractResult_test.go @@ -38,7 +38,7 @@ func TestSmartContractResult_SettersAndGetters(t *testing.T) { assert.Equal(t, gasLimit, scr.GetGasLimit()) assert.Equal(t, gasPrice, scr.GetGasPrice()) assert.Equal(t, nonce, scr.GetNonce()) - assert.Nil(t, scr.GetUserTransaction()) + assert.Nil(t, scr.GetUserTransactions()) } func TestTrimSlicePtr(t *testing.T) { diff --git a/data/transaction/frontendTransaction.go b/data/transaction/frontendTransaction.go index 820014f73..267d7e9c6 100644 --- a/data/transaction/frontendTransaction.go +++ b/data/transaction/frontendTransaction.go @@ -2,21 +2,21 @@ package transaction // FrontendTransaction represents the DTO used in transaction signing/validation. type FrontendTransaction struct { - Nonce uint64 `json:"nonce"` - Value string `json:"value"` - Receiver string `json:"receiver"` - Sender string `json:"sender"` - SenderUsername []byte `json:"senderUsername,omitempty"` - ReceiverUsername []byte `json:"receiverUsername,omitempty"` - GasPrice uint64 `json:"gasPrice"` - GasLimit uint64 `json:"gasLimit"` - Data []byte `json:"data,omitempty"` - Signature string `json:"signature,omitempty"` - ChainID string `json:"chainID"` - Version uint32 `json:"version"` - Options uint32 `json:"options,omitempty"` - GuardianAddr string `json:"guardian,omitempty"` - GuardianSignature string `json:"guardianSignature,omitempty"` - Relayer string `json:"relayer,omitempty"` - InnerTransaction *FrontendTransaction `json:"innerTransaction,omitempty"` + Nonce uint64 `json:"nonce"` + Value string `json:"value"` + Receiver string `json:"receiver"` + Sender string `json:"sender"` + SenderUsername []byte `json:"senderUsername,omitempty"` + ReceiverUsername []byte `json:"receiverUsername,omitempty"` + GasPrice uint64 `json:"gasPrice"` + GasLimit uint64 `json:"gasLimit"` + Data []byte `json:"data,omitempty"` + Signature string `json:"signature,omitempty"` + ChainID string `json:"chainID"` + Version uint32 `json:"version"` + Options uint32 `json:"options,omitempty"` + GuardianAddr string `json:"guardian,omitempty"` + GuardianSignature string `json:"guardianSignature,omitempty"` + Relayer string `json:"relayer,omitempty"` + InnerTransactions []*FrontendTransaction `json:"innerTransactions,omitempty"` } diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index b261a7fa3..5680523aa 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -37,9 +37,15 @@ func (tx *Transaction) SetSndAddr(addr []byte) { tx.SndAddr = addr } -// GetUserTransaction returns the inner transaction -func (tx *Transaction) GetUserTransaction() data.TransactionHandler { - return tx.GetInnerTransaction() +// GetUserTransactions returns the inner transactions +func (tx *Transaction) GetUserTransactions() []data.TransactionHandler { + innerTxs := tx.GetInnerTransactions() + txsHandlers := make([]data.TransactionHandler, len(innerTxs)) + for i := 0; i < len(innerTxs); i++ { + txsHandlers[i] = innerTxs[i] + } + + return txsHandlers } // TrimSlicePtr creates a copy of the provided slice without the excess capacity @@ -79,14 +85,21 @@ func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.M return nil, err } - if tx.InnerTransaction != nil { - ftx.InnerTransaction, err = tx.InnerTransaction.prepareTx(encoder) - if err != nil { - return nil, err + numInnerTxs := len(tx.InnerTransactions) + if numInnerTxs > 0 { + ftx.InnerTransactions = make([]*FrontendTransaction, numInnerTxs) + for i := 0; i < numInnerTxs; i++ { + innerFtx, errPrepare := tx.InnerTransactions[i].prepareTx(encoder) + if errPrepare != nil { + return nil, errPrepare + } + + innerFtx.Signature = hex.EncodeToString(tx.InnerTransactions[i].Signature) + innerFtx.GuardianSignature = hex.EncodeToString(tx.InnerTransactions[i].GuardianSignature) + + ftx.InnerTransactions[i] = innerFtx } - ftx.InnerTransaction.Signature = hex.EncodeToString(tx.InnerTransaction.Signature) - ftx.InnerTransaction.GuardianSignature = hex.EncodeToString(tx.InnerTransaction.GuardianSignature) } ftxBytes, err := marshaller.Marshal(ftx) diff --git a/data/transaction/transaction.pb.go b/data/transaction/transaction.pb.go index b19e9438f..90e14b7fd 100644 --- a/data/transaction/transaction.pb.go +++ b/data/transaction/transaction.pb.go @@ -30,23 +30,23 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Transaction holds all the data needed for a value transfer or SC call type Transaction struct { - Nonce uint64 `protobuf:"varint,1,opt,name=Nonce,proto3" json:"nonce"` - Value *math_big.Int `protobuf:"bytes,2,opt,name=Value,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"value"` - RcvAddr []byte `protobuf:"bytes,3,opt,name=RcvAddr,proto3" json:"receiver"` - RcvUserName []byte `protobuf:"bytes,4,opt,name=RcvUserName,proto3" json:"rcvUserName,omitempty"` - SndAddr []byte `protobuf:"bytes,5,opt,name=SndAddr,proto3" json:"sender"` - SndUserName []byte `protobuf:"bytes,6,opt,name=SndUserName,proto3" json:"sndUserName,omitempty"` - GasPrice uint64 `protobuf:"varint,7,opt,name=GasPrice,proto3" json:"gasPrice,omitempty"` - GasLimit uint64 `protobuf:"varint,8,opt,name=GasLimit,proto3" json:"gasLimit,omitempty"` - Data []byte `protobuf:"bytes,9,opt,name=Data,proto3" json:"data,omitempty"` - ChainID []byte `protobuf:"bytes,10,opt,name=ChainID,proto3" json:"chainID"` - Version uint32 `protobuf:"varint,11,opt,name=Version,proto3" json:"version"` - Signature []byte `protobuf:"bytes,12,opt,name=Signature,proto3" json:"signature,omitempty"` - Options uint32 `protobuf:"varint,13,opt,name=Options,proto3" json:"options,omitempty"` - GuardianAddr []byte `protobuf:"bytes,14,opt,name=GuardianAddr,proto3" json:"guardian,omitempty"` - GuardianSignature []byte `protobuf:"bytes,15,opt,name=GuardianSignature,proto3" json:"guardianSignature,omitempty"` - RelayerAddr []byte `protobuf:"bytes,16,opt,name=RelayerAddr,proto3" json:"relayer,omitempty"` - InnerTransaction *Transaction `protobuf:"bytes,17,opt,name=InnerTransaction,proto3" json:"innerTransaction,omitempty"` + Nonce uint64 `protobuf:"varint,1,opt,name=Nonce,proto3" json:"nonce"` + Value *math_big.Int `protobuf:"bytes,2,opt,name=Value,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"value"` + RcvAddr []byte `protobuf:"bytes,3,opt,name=RcvAddr,proto3" json:"receiver"` + RcvUserName []byte `protobuf:"bytes,4,opt,name=RcvUserName,proto3" json:"rcvUserName,omitempty"` + SndAddr []byte `protobuf:"bytes,5,opt,name=SndAddr,proto3" json:"sender"` + SndUserName []byte `protobuf:"bytes,6,opt,name=SndUserName,proto3" json:"sndUserName,omitempty"` + GasPrice uint64 `protobuf:"varint,7,opt,name=GasPrice,proto3" json:"gasPrice,omitempty"` + GasLimit uint64 `protobuf:"varint,8,opt,name=GasLimit,proto3" json:"gasLimit,omitempty"` + Data []byte `protobuf:"bytes,9,opt,name=Data,proto3" json:"data,omitempty"` + ChainID []byte `protobuf:"bytes,10,opt,name=ChainID,proto3" json:"chainID"` + Version uint32 `protobuf:"varint,11,opt,name=Version,proto3" json:"version"` + Signature []byte `protobuf:"bytes,12,opt,name=Signature,proto3" json:"signature,omitempty"` + Options uint32 `protobuf:"varint,13,opt,name=Options,proto3" json:"options,omitempty"` + GuardianAddr []byte `protobuf:"bytes,14,opt,name=GuardianAddr,proto3" json:"guardian,omitempty"` + GuardianSignature []byte `protobuf:"bytes,15,opt,name=GuardianSignature,proto3" json:"guardianSignature,omitempty"` + RelayerAddr []byte `protobuf:"bytes,16,opt,name=RelayerAddr,proto3" json:"relayer,omitempty"` + InnerTransactions []*Transaction `protobuf:"bytes,17,rep,name=InnerTransactions,proto3" json:"innerTransactions,omitempty"` } func (m *Transaction) Reset() { *m = Transaction{} } @@ -189,9 +189,9 @@ func (m *Transaction) GetRelayerAddr() []byte { return nil } -func (m *Transaction) GetInnerTransaction() *Transaction { +func (m *Transaction) GetInnerTransactions() []*Transaction { if m != nil { - return m.InnerTransaction + return m.InnerTransactions } return nil } @@ -203,47 +203,47 @@ func init() { func init() { proto.RegisterFile("transaction.proto", fileDescriptor_2cc4e03d2c28c490) } var fileDescriptor_2cc4e03d2c28c490 = []byte{ - // 626 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcf, 0x6e, 0xd3, 0x3e, - 0x1c, 0xaf, 0x7f, 0xbf, 0x75, 0xd9, 0xdc, 0x6e, 0xac, 0x46, 0x83, 0x30, 0x24, 0xbb, 0x42, 0x30, - 0xf5, 0x40, 0x1b, 0x69, 0x08, 0x21, 0xb1, 0x13, 0xdd, 0xd0, 0x54, 0x09, 0x06, 0xca, 0x60, 0x07, - 0x0e, 0x48, 0x6e, 0x62, 0x52, 0x4b, 0x8b, 0x3d, 0x39, 0x6e, 0xb5, 0x1d, 0x90, 0x78, 0x04, 0x1e, - 0x03, 0xf1, 0x24, 0x88, 0xd3, 0x8e, 0x3b, 0x05, 0x96, 0x5d, 0x50, 0x4e, 0x7b, 0x04, 0x14, 0xa7, - 0x5d, 0xbc, 0xed, 0xc4, 0xa9, 0xf1, 0xe7, 0xef, 0xb7, 0x8e, 0x1d, 0xd8, 0xd2, 0x8a, 0x8a, 0x84, - 0x06, 0x9a, 0x4b, 0xd1, 0x3b, 0x54, 0x52, 0x4b, 0x54, 0x37, 0x3f, 0x6b, 0xdd, 0x88, 0xeb, 0xd1, - 0x78, 0xd8, 0x0b, 0x64, 0xec, 0x45, 0x32, 0x92, 0x9e, 0x81, 0x87, 0xe3, 0x4f, 0x66, 0x65, 0x16, - 0xe6, 0xa9, 0x74, 0x3d, 0xf8, 0xe9, 0xc0, 0xc6, 0xbb, 0x2a, 0x0b, 0x11, 0x58, 0xdf, 0x95, 0x22, - 0x60, 0x2e, 0x68, 0x83, 0xce, 0x5c, 0x7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, 0x95, 0x12, 0x7d, 0x84, 0x2b, 0x03, 0x21, 0x98, 0xb2, 0x2e, 0x9c, 0xdb, 0x6a, - 0x83, 0x4e, 0x63, 0x03, 0x95, 0xd7, 0xb1, 0x67, 0x31, 0x7d, 0x9c, 0xa7, 0x64, 0x8d, 0x5f, 0xd3, - 0x5b, 0xd1, 0x37, 0xb2, 0xfa, 0x9f, 0x4f, 0xce, 0x70, 0xed, 0xf4, 0x0c, 0xd7, 0x2e, 0xce, 0x30, - 0xf8, 0x92, 0x61, 0xf0, 0x2d, 0xc3, 0xe0, 0x47, 0x86, 0xc1, 0x49, 0x86, 0xc1, 0x69, 0x86, 0xc1, - 0xef, 0x0c, 0x83, 0x3f, 0x19, 0xae, 0x5d, 0x64, 0x18, 0x7c, 0x3d, 0xc7, 0xb5, 0x93, 0x73, 0x5c, - 0x3b, 0x3d, 0xc7, 0xb5, 0x0f, 0x5b, 0xff, 0x70, 0x59, 0x3d, 0xeb, 0xdb, 0xb3, 0x69, 0x3d, 0x0f, - 0xe7, 0xcd, 0x7f, 0x78, 0xf2, 0x37, 0x00, 0x00, 0xff, 0xff, 0x2a, 0xdc, 0x62, 0xaa, 0x9d, 0x04, - 0x00, 0x00, + // 628 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x41, 0x6f, 0xd3, 0x3e, + 0x18, 0xc6, 0x9b, 0xff, 0xd6, 0x65, 0x73, 0xbb, 0xfd, 0xa9, 0xd1, 0x20, 0x80, 0x64, 0x57, 0x08, + 0xa6, 0x1e, 0x68, 0x23, 0x0d, 0x21, 0x24, 0x76, 0xa2, 0x1b, 0x9a, 0x2a, 0xc1, 0x40, 0x19, 0xec, + 0xc0, 0xcd, 0x4d, 0x4c, 0x6a, 0x69, 0x71, 0x26, 0xc7, 0xad, 0xb6, 0x03, 0x12, 0x1f, 0x81, 0x8f, + 0x81, 0xf8, 0x24, 0x5c,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, 0x00, 0x00, 0x00, 0xff, 0xff, 0xee, 0xb2, 0x15, 0x7c, + 0xa0, 0x04, 0x00, 0x00, } func (this *Transaction) Equal(that interface{}) bool { @@ -316,9 +316,14 @@ func (this *Transaction) Equal(that interface{}) bool { if !bytes.Equal(this.RelayerAddr, that1.RelayerAddr) { return false } - if !this.InnerTransaction.Equal(that1.InnerTransaction) { + if len(this.InnerTransactions) != len(that1.InnerTransactions) { return false } + for i := range this.InnerTransactions { + if !this.InnerTransactions[i].Equal(that1.InnerTransactions[i]) { + return false + } + } return true } func (this *Transaction) GoString() string { @@ -343,8 +348,8 @@ func (this *Transaction) GoString() string { s = append(s, "GuardianAddr: "+fmt.Sprintf("%#v", this.GuardianAddr)+",\n") s = append(s, "GuardianSignature: "+fmt.Sprintf("%#v", this.GuardianSignature)+",\n") s = append(s, "RelayerAddr: "+fmt.Sprintf("%#v", this.RelayerAddr)+",\n") - if this.InnerTransaction != nil { - s = append(s, "InnerTransaction: "+fmt.Sprintf("%#v", this.InnerTransaction)+",\n") + if this.InnerTransactions != nil { + s = append(s, "InnerTransactions: "+fmt.Sprintf("%#v", this.InnerTransactions)+",\n") } s = append(s, "}") return strings.Join(s, "") @@ -377,19 +382,21 @@ func (m *Transaction) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.InnerTransaction != nil { - { - size, err := m.InnerTransaction.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.InnerTransactions) > 0 { + for iNdEx := len(m.InnerTransactions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.InnerTransactions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTransaction(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintTransaction(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x8a } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x8a } if len(m.RelayerAddr) > 0 { i -= len(m.RelayerAddr) @@ -579,9 +586,11 @@ func (m *Transaction) Size() (n int) { if l > 0 { n += 2 + l + sovTransaction(uint64(l)) } - if m.InnerTransaction != nil { - l = m.InnerTransaction.Size() - n += 2 + l + sovTransaction(uint64(l)) + if len(m.InnerTransactions) > 0 { + for _, e := range m.InnerTransactions { + l = e.Size() + n += 2 + l + sovTransaction(uint64(l)) + } } return n } @@ -596,6 +605,11 @@ func (this *Transaction) String() string { if this == nil { return "nil" } + repeatedStringForInnerTransactions := "[]*Transaction{" + for _, f := range this.InnerTransactions { + repeatedStringForInnerTransactions += strings.Replace(f.String(), "Transaction", "Transaction", 1) + "," + } + repeatedStringForInnerTransactions += "}" s := strings.Join([]string{`&Transaction{`, `Nonce:` + fmt.Sprintf("%v", this.Nonce) + `,`, `Value:` + fmt.Sprintf("%v", this.Value) + `,`, @@ -613,7 +627,7 @@ func (this *Transaction) String() string { `GuardianAddr:` + fmt.Sprintf("%v", this.GuardianAddr) + `,`, `GuardianSignature:` + fmt.Sprintf("%v", this.GuardianSignature) + `,`, `RelayerAddr:` + fmt.Sprintf("%v", this.RelayerAddr) + `,`, - `InnerTransaction:` + strings.Replace(this.InnerTransaction.String(), "Transaction", "Transaction", 1) + `,`, + `InnerTransactions:` + repeatedStringForInnerTransactions + `,`, `}`, }, "") return s @@ -1130,7 +1144,7 @@ func (m *Transaction) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 17: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InnerTransaction", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field InnerTransactions", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1157,10 +1171,8 @@ func (m *Transaction) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.InnerTransaction == nil { - m.InnerTransaction = &Transaction{} - } - if err := m.InnerTransaction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.InnerTransactions = append(m.InnerTransactions, &Transaction{}) + if err := m.InnerTransactions[len(m.InnerTransactions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/data/transaction/transaction.proto b/data/transaction/transaction.proto index 626e6e432..5912769de 100644 --- a/data/transaction/transaction.proto +++ b/data/transaction/transaction.proto @@ -15,21 +15,21 @@ import "github.com/gogo/protobuf/gogoproto/gogo.proto"; // Transaction holds all the data needed for a value transfer or SC call message Transaction { - uint64 Nonce = 1 [(gogoproto.jsontag) = "nonce"]; - bytes Value = 2 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; - bytes RcvAddr = 3 [(gogoproto.jsontag) = "receiver"]; - bytes RcvUserName = 4 [(gogoproto.jsontag) = "rcvUserName,omitempty"]; - bytes SndAddr = 5 [(gogoproto.jsontag) = "sender"]; - bytes SndUserName = 6 [(gogoproto.jsontag) = "sndUserName,omitempty"]; - uint64 GasPrice = 7 [(gogoproto.jsontag) = "gasPrice,omitempty"]; - uint64 GasLimit = 8 [(gogoproto.jsontag) = "gasLimit,omitempty"]; - bytes Data = 9 [(gogoproto.jsontag) = "data,omitempty"]; - bytes ChainID = 10 [(gogoproto.jsontag) = "chainID"]; - uint32 Version = 11 [(gogoproto.jsontag) = "version"]; - bytes Signature = 12 [(gogoproto.jsontag) = "signature,omitempty"]; - uint32 Options = 13 [(gogoproto.jsontag) = "options,omitempty"]; - bytes GuardianAddr = 14 [(gogoproto.jsontag) = "guardian,omitempty"]; - bytes GuardianSignature = 15 [(gogoproto.jsontag) = "guardianSignature,omitempty"]; - bytes RelayerAddr = 16 [(gogoproto.jsontag) = "relayer,omitempty"]; - Transaction InnerTransaction = 17 [(gogoproto.jsontag) = "innerTransaction,omitempty"]; + uint64 Nonce = 1 [(gogoproto.jsontag) = "nonce"]; + bytes Value = 2 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes RcvAddr = 3 [(gogoproto.jsontag) = "receiver"]; + bytes RcvUserName = 4 [(gogoproto.jsontag) = "rcvUserName,omitempty"]; + bytes SndAddr = 5 [(gogoproto.jsontag) = "sender"]; + bytes SndUserName = 6 [(gogoproto.jsontag) = "sndUserName,omitempty"]; + uint64 GasPrice = 7 [(gogoproto.jsontag) = "gasPrice,omitempty"]; + uint64 GasLimit = 8 [(gogoproto.jsontag) = "gasLimit,omitempty"]; + bytes Data = 9 [(gogoproto.jsontag) = "data,omitempty"]; + bytes ChainID = 10 [(gogoproto.jsontag) = "chainID"]; + uint32 Version = 11 [(gogoproto.jsontag) = "version"]; + bytes Signature = 12 [(gogoproto.jsontag) = "signature,omitempty"]; + uint32 Options = 13 [(gogoproto.jsontag) = "options,omitempty"]; + bytes GuardianAddr = 14 [(gogoproto.jsontag) = "guardian,omitempty"]; + bytes GuardianSignature = 15 [(gogoproto.jsontag) = "guardianSignature,omitempty"]; + bytes RelayerAddr = 16 [(gogoproto.jsontag) = "relayer,omitempty"]; + repeated Transaction InnerTransactions = 17 [(gogoproto.jsontag) = "innerTransactions,omitempty"]; } diff --git a/data/transaction/transaction_test.go b/data/transaction/transaction_test.go index ce8e70aea..792eacc89 100644 --- a/data/transaction/transaction_test.go +++ b/data/transaction/transaction_test.go @@ -23,16 +23,18 @@ func TestTransaction_SettersAndGetters(t *testing.T) { gasLimit := uint64(5) sender := []byte("sndr") receiver := []byte("receiver") - innerTx := &transaction.Transaction{ - Nonce: 123, - RelayerAddr: sender, + innerTxs := []*transaction.Transaction{ + { + Nonce: 123, + RelayerAddr: sender, + }, } tx := &transaction.Transaction{ - Nonce: nonce, - GasPrice: gasPrice, - GasLimit: gasLimit, - InnerTransaction: innerTx, + Nonce: nonce, + GasPrice: gasPrice, + GasLimit: gasLimit, + InnerTransactions: innerTxs, } assert.False(t, check.IfNil(tx)) @@ -48,8 +50,8 @@ func TestTransaction_SettersAndGetters(t *testing.T) { assert.Equal(t, gasLimit, tx.GetGasLimit()) assert.Equal(t, sender, tx.GetSndAddr()) assert.Equal(t, receiver, tx.GetRcvAddr()) - assert.Equal(t, innerTx, tx.GetUserTransaction()) - assert.Equal(t, sender, tx.GetInnerTransaction().GetRelayerAddr()) + assert.Equal(t, innerTxs[0], tx.GetUserTransactions()[0]) + assert.Equal(t, sender, tx.GetInnerTransactions()[0].GetRelayerAddr()) } func TestTransaction_MarshalUnmarshalJsonShouldWork(t *testing.T) { @@ -65,8 +67,10 @@ func TestTransaction_MarshalUnmarshalJsonShouldWork(t *testing.T) { GasLimit: 5678, Data: []byte("data"), Signature: []byte("signature"), - InnerTransaction: &transaction.Transaction{ - Nonce: 123, + InnerTransactions: []*transaction.Transaction{ + { + Nonce: 123, + }, }, } @@ -265,15 +269,15 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { assert.Equal(t, 2, numEncodeCalled) }) - t.Run("inner tx, without hash sign option set", func(t *testing.T) { + t.Run("inner txs, without hash sign option set", func(t *testing.T) { t.Parallel() tx1 := &transaction.Transaction{ Nonce: 1, } tx := &transaction.Transaction{ - Nonce: 3, - InnerTransaction: tx1, + Nonce: 3, + InnerTransactions: []*transaction.Transaction{tx1}, } numEncodeCalled := 0 From 48e2da52259e97a818d9a1335cbccd1863ef10d1 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Thu, 4 Apr 2024 21:13:42 +0300 Subject: [PATCH 17/27] update ApiTransactionResult as well --- data/transaction/apiTransactionResult.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/transaction/apiTransactionResult.go b/data/transaction/apiTransactionResult.go index 20e86eb1d..8f619d064 100644 --- a/data/transaction/apiTransactionResult.go +++ b/data/transaction/apiTransactionResult.go @@ -69,7 +69,7 @@ type ApiTransactionResult struct { Options uint32 `json:"options"` GuardianAddr string `json:"guardian,omitempty"` GuardianSignature string `json:"guardianSignature,omitempty"` - InnerTransaction data.TransactionHandler `json:"innerTransaction,omitempty"` + InnerTransactions []data.TransactionHandler `json:"innerTransactions,omitempty"` } // ApiSmartContractResult represents a smart contract result with changed fields' types in order to make it friendly for API's json From 8b6faa711b232f24a9bcdc5e319f544056e8de61 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Tue, 28 May 2024 16:27:12 +0300 Subject: [PATCH 18/27] update ApiTransactionResult to use FrontEndTransaction for better visibility --- data/transaction/apiTransactionResult.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/transaction/apiTransactionResult.go b/data/transaction/apiTransactionResult.go index 8f619d064..1dd23f4c9 100644 --- a/data/transaction/apiTransactionResult.go +++ b/data/transaction/apiTransactionResult.go @@ -69,7 +69,7 @@ type ApiTransactionResult struct { Options uint32 `json:"options"` GuardianAddr string `json:"guardian,omitempty"` GuardianSignature string `json:"guardianSignature,omitempty"` - InnerTransactions []data.TransactionHandler `json:"innerTransactions,omitempty"` + InnerTransactions []*FrontendTransaction `json:"innerTransactions,omitempty"` } // ApiSmartContractResult represents a smart contract result with changed fields' types in order to make it friendly for API's json From 1559f923a59de7daa315a64130e1afe6392b71dd Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Wed, 29 May 2024 11:54:08 +0300 Subject: [PATCH 19/27] added RelayedTransactionV3 constant --- core/constants.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/constants.go b/core/constants.go index e022eea34..839f3ce1c 100644 --- a/core/constants.go +++ b/core/constants.go @@ -250,6 +250,9 @@ const RelayedTransaction = "relayedTx" // RelayedTransactionV2 is the key for the optimized electronic meta/gassless/relayed transaction standard const RelayedTransactionV2 = "relayedTxV2" +// RelayedTransactionV3 is the key for the optimized electronic meta/gassless/relayed transaction standard +const RelayedTransactionV3 = "relayedTxV3" + // SCDeployInitFunctionName is the key for the function which is called at smart contract deploy time const SCDeployInitFunctionName = "_init" From 139a833706a1ce6ebeddd46ab32d8a4545db8efc Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Wed, 29 May 2024 13:00:34 +0300 Subject: [PATCH 20/27] reverted last commit --- core/constants.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/constants.go b/core/constants.go index 839f3ce1c..e022eea34 100644 --- a/core/constants.go +++ b/core/constants.go @@ -250,9 +250,6 @@ const RelayedTransaction = "relayedTx" // RelayedTransactionV2 is the key for the optimized electronic meta/gassless/relayed transaction standard const RelayedTransactionV2 = "relayedTxV2" -// RelayedTransactionV3 is the key for the optimized electronic meta/gassless/relayed transaction standard -const RelayedTransactionV3 = "relayedTxV3" - // SCDeployInitFunctionName is the key for the function which is called at smart contract deploy time const SCDeployInitFunctionName = "_init" From f6c188ad86c2077a445cc08c3af620ac6dd0b6ae Mon Sep 17 00:00:00 2001 From: miiu Date: Thu, 30 May 2024 13:34:21 +0300 Subject: [PATCH 21/27] type in altered account --- data/alteredAccount/alteredAccount.pb.go | 164 +++++++++++++++-------- data/alteredAccount/alteredAccount.proto | 1 + 2 files changed, 112 insertions(+), 53 deletions(-) diff --git a/data/alteredAccount/alteredAccount.pb.go b/data/alteredAccount/alteredAccount.pb.go index 231e1957f..882eacefe 100644 --- a/data/alteredAccount/alteredAccount.pb.go +++ b/data/alteredAccount/alteredAccount.pb.go @@ -104,6 +104,7 @@ type AccountTokenData struct { Properties string `protobuf:"bytes,4,opt,name=Properties,proto3" json:"properties"` MetaData *TokenMetaData `protobuf:"bytes,5,opt,name=MetaData,proto3" json:"metaData,omitempty"` AdditionalData *AdditionalAccountTokenData `protobuf:"bytes,6,opt,name=AdditionalData,proto3" json:"additionalData,omitempty"` + Type string `protobuf:"bytes,7,opt,name=Type,proto3" json:"type,omitempty"` } func (m *AccountTokenData) Reset() { *m = AccountTokenData{} } @@ -176,6 +177,13 @@ func (m *AccountTokenData) GetAdditionalData() *AdditionalAccountTokenData { return nil } +func (m *AccountTokenData) GetType() string { + if m != nil { + return m.Type + } + return "" +} + type TokenMetaData struct { Nonce uint64 `protobuf:"varint,1,opt,name=Nonce,proto3" json:"nonce"` Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"name"` @@ -408,58 +416,60 @@ func init() { func init() { proto.RegisterFile("alteredAccount.proto", fileDescriptor_804e04a1cde31bca) } var fileDescriptor_804e04a1cde31bca = []byte{ - // 810 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x95, 0xcd, 0x6a, 0xeb, 0x46, - 0x14, 0xc7, 0x2d, 0x7f, 0x7b, 0x9c, 0x98, 0x54, 0x24, 0xa9, 0x6b, 0x82, 0xe4, 0xba, 0x14, 0x0c, - 0xad, 0x6d, 0x48, 0x97, 0x81, 0x82, 0xe5, 0xb4, 0xc4, 0x85, 0xa6, 0x45, 0x4d, 0x16, 0xed, 0x6e, - 0x2c, 0x4d, 0x6c, 0x51, 0x4b, 0x63, 0x46, 0xa3, 0x7c, 0xec, 0x0a, 0xdd, 0x97, 0x3e, 0x46, 0xdf, - 0xa1, 0x2f, 0xd0, 0x65, 0x96, 0x59, 0x89, 0x46, 0xd9, 0x5c, 0x04, 0x17, 0xb2, 0xbd, 0xbb, 0xcb, - 0x1c, 0x49, 0xf6, 0x28, 0x1f, 0xf7, 0xae, 0x92, 0xf9, 0x9f, 0x73, 0xfe, 0xe7, 0xf8, 0x77, 0x66, - 0x6c, 0xb4, 0x8b, 0x97, 0x9c, 0x30, 0x62, 0x8f, 0x2d, 0x8b, 0x06, 0x1e, 0x1f, 0xae, 0x18, 0xe5, - 0x54, 0xad, 0xc0, 0x9f, 0xce, 0x60, 0xee, 0xf0, 0x45, 0x30, 0x1b, 0x5a, 0xd4, 0x1d, 0xcd, 0xe9, - 0x9c, 0x8e, 0x40, 0x9e, 0x05, 0x17, 0x70, 0x82, 0x03, 0xfc, 0x97, 0x54, 0xf5, 0xfe, 0x2d, 0xa2, - 0xd6, 0x38, 0x67, 0xa7, 0x7e, 0x89, 0x6a, 0x63, 0xdb, 0x66, 0xc4, 0xf7, 0xdb, 0x4a, 0x57, 0xe9, - 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, 0xad, 0x70, 0x77, 0xaf, 0x15, 0x1e, 0xef, 0x35, 0xe5, 0x8f, 0x48, - 0x53, 0xfe, 0x89, 0x34, 0xe5, 0xbf, 0x48, 0x53, 0x6e, 0x23, 0x4d, 0xb9, 0x8b, 0x34, 0xe5, 0xff, - 0x48, 0x53, 0xde, 0x44, 0x5a, 0xe1, 0x31, 0xd2, 0x94, 0xbf, 0x1f, 0xb4, 0xc2, 0xed, 0x83, 0x56, - 0xb8, 0x7b, 0xd0, 0x0a, 0xbf, 0x4d, 0xa5, 0xdf, 0x1f, 0x37, 0x58, 0x72, 0xe7, 0x92, 0x30, 0xff, - 0x7a, 0xe4, 0x5e, 0x0f, 0xac, 0x05, 0x76, 0xbc, 0x81, 0x45, 0x19, 0x19, 0xcc, 0xe9, 0x48, 0xf4, - 0x19, 0xe5, 0x7f, 0xc8, 0x8e, 0xf2, 0xc7, 0x59, 0x15, 0xbe, 0x3d, 0xbe, 0x79, 0x1f, 0x00, 0x00, - 0xff, 0xff, 0xf3, 0xb4, 0x64, 0x47, 0xf0, 0x06, 0x00, 0x00, + // 833 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x55, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0x8e, 0x9b, 0x34, 0x1f, 0xd3, 0x36, 0x2a, 0xa3, 0x76, 0x09, 0x51, 0xe5, 0x09, 0x41, 0xa0, + 0x48, 0x90, 0x44, 0x2a, 0xc7, 0x95, 0x90, 0xe2, 0x14, 0xb4, 0x41, 0xa2, 0x20, 0xd3, 0x3d, 0xc0, + 0x6d, 0x62, 0xcf, 0x26, 0x16, 0xb1, 0x27, 0x1a, 0x8f, 0x77, 0x37, 0x37, 0x24, 0xee, 0x88, 0x0b, + 0xff, 0x81, 0xff, 0xc0, 0x1f, 0xe0, 0xd8, 0x63, 0x4f, 0x16, 0x75, 0x2f, 0xc8, 0xa7, 0xbd, 0x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0x80, 0xfa, 0xcc, 0x06, 0x54, 0x59, 0x30, + 0x15, 0x8c, 0x4a, 0x2e, 0x74, 0x0b, 0x9c, 0x0c, 0xb2, 0x8b, 0x18, 0xfe, 0x14, 0xb5, 0x6c, 0xbe, + 0xa1, 0xab, 0xad, 0x03, 0x27, 0xd6, 0x49, 0x1a, 0x93, 0x96, 0x28, 0x40, 0x7b, 0x17, 0x57, 0x1d, + 0x9f, 0xd1, 0x70, 0x09, 0xda, 0x1f, 0x67, 0x1d, 0x97, 0x34, 0x5c, 0xda, 0x80, 0xaa, 0xe8, 0x73, + 0x7b, 0x16, 0x76, 0xea, 0xbd, 0x6a, 0x11, 0x8d, 0x84, 0x17, 0xda, 0x80, 0x2a, 0xaf, 0x27, 0x52, + 0x0a, 0x6f, 0x1e, 0x49, 0x16, 0x82, 0x1c, 0xc7, 0x99, 0xd7, 0x74, 0x8b, 0xda, 0x1a, 0xa3, 0xff, + 0x03, 0xea, 0xee, 0x37, 0x01, 0x3f, 0x45, 0x47, 0xb3, 0xf0, 0xfa, 0xab, 0x1b, 0xb8, 0x46, 0x26, + 0x51, 0xd3, 0xfa, 0x20, 0x8d, 0xc9, 0xb9, 0xb7, 0x83, 0x35, 0x91, 0x75, 0x76, 0xff, 0xdf, 0x2a, + 0x3a, 0x7f, 0xe7, 0x93, 0xc2, 0x97, 0xa8, 0x39, 0x0b, 0xbf, 0x67, 0x81, 0xcb, 0x44, 0x5e, 0x13, + 0x56, 0xc9, 0xcb, 0x31, 0x7d, 0x95, 0x0a, 0x1e, 0xbe, 0x42, 0xed, 0x7c, 0x9f, 0xa7, 0x4b, 0x1a, + 0x2c, 0x98, 0x0b, 0x86, 0x34, 0xb3, 0x3d, 0x99, 0x97, 0x22, 0xfa, 0x9e, 0x94, 0x73, 0xf0, 0x17, + 0xe8, 0x78, 0x1a, 0x09, 0xc1, 0x02, 0xf9, 0xed, 0xab, 0x80, 0x15, 0x9e, 0x75, 0xd3, 0x98, 0x3c, + 0x71, 0x34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x2e, 0x7f, 0xf0, 0x9e, 0x96, 0x8f, 0xf3, 0x3a, 0xfc, + 0xca, 0x7c, 0xfe, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbe, 0xdc, 0x2f, 0xaa, 0x18, 0x07, 0x00, + 0x00, } func (this *AlteredAccount) Equal(that interface{}) bool { @@ -540,6 +550,9 @@ func (this *AccountTokenData) Equal(that interface{}) bool { if !this.AdditionalData.Equal(that1.AdditionalData) { return false } + if this.Type != that1.Type { + return false + } return true } func (this *TokenMetaData) Equal(that interface{}) bool { @@ -680,7 +693,7 @@ func (this *AccountTokenData) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 10) + s := make([]string, 0, 11) s = append(s, "&alteredAccount.AccountTokenData{") s = append(s, "Nonce: "+fmt.Sprintf("%#v", this.Nonce)+",\n") s = append(s, "Identifier: "+fmt.Sprintf("%#v", this.Identifier)+",\n") @@ -692,6 +705,7 @@ func (this *AccountTokenData) GoString() string { if this.AdditionalData != nil { s = append(s, "AdditionalData: "+fmt.Sprintf("%#v", this.AdditionalData)+",\n") } + s = append(s, "Type: "+fmt.Sprintf("%#v", this.Type)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -834,6 +848,13 @@ func (m *AccountTokenData) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0x3a + } if m.AdditionalData != nil { { size, err := m.AdditionalData.MarshalToSizedBuffer(dAtA[:i]) @@ -1145,6 +1166,10 @@ func (m *AccountTokenData) Size() (n int) { l = m.AdditionalData.Size() n += 1 + l + sovAlteredAccount(uint64(l)) } + l = len(m.Type) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } return n } @@ -1272,6 +1297,7 @@ func (this *AccountTokenData) String() string { `Properties:` + fmt.Sprintf("%v", this.Properties) + `,`, `MetaData:` + strings.Replace(this.MetaData.String(), "TokenMetaData", "TokenMetaData", 1) + `,`, `AdditionalData:` + strings.Replace(this.AdditionalData.String(), "AdditionalAccountTokenData", "AdditionalAccountTokenData", 1) + `,`, + `Type:` + fmt.Sprintf("%v", this.Type) + `,`, `}`, }, "") return s @@ -1749,6 +1775,38 @@ func (m *AccountTokenData) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + 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 ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Type = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipAlteredAccount(dAtA[iNdEx:]) diff --git a/data/alteredAccount/alteredAccount.proto b/data/alteredAccount/alteredAccount.proto index 08e6c0af0..01242c11d 100644 --- a/data/alteredAccount/alteredAccount.proto +++ b/data/alteredAccount/alteredAccount.proto @@ -22,6 +22,7 @@ message AccountTokenData { string Properties = 4 [(gogoproto.jsontag) = "properties"]; TokenMetaData MetaData = 5 [(gogoproto.jsontag) = "metaData,omitempty"]; AdditionalAccountTokenData AdditionalData = 6 [(gogoproto.jsontag) = "additionalData,omitempty"]; + string Type = 7 [(gogoproto.jsontag) = "type,omitempty"]; } message TokenMetaData { From 45870512bfbeb21300e241c9d8345ede72fc1824 Mon Sep 17 00:00:00 2001 From: miiu Date: Thu, 30 May 2024 14:12:58 +0300 Subject: [PATCH 22/27] string method --- core/constants.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/constants.go b/core/constants.go index e022eea34..e1861bee3 100644 --- a/core/constants.go +++ b/core/constants.go @@ -214,6 +214,30 @@ const ( DynamicMeta ) +// String will convert number type in string +func (t ESDTType) String() string { + switch t { + case Fungible: + return FungibleESDT + case NonFungible: + return NonFungibleESDT + case NonFungibleV2: + return NonFungibleESDTv2 + case SemiFungible: + return SemiFungibleESDT + case MetaFungible: + return MetaESDT + case DynamicNFT: + return DynamicNFTESDT + case DynamicSFT: + return DynamicSFTESDT + case DynamicMeta: + return DynamicMetaESDT + default: + return "Unknown" + } +} + // FungibleESDT defines the string for the token type of fungible ESDT const FungibleESDT = "FungibleESDT" From 88bd243c9240132ebfd78daca26d717b8fbf874d Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Tue, 4 Jun 2024 10:53:37 +0300 Subject: [PATCH 23/27] fixes after review --- data/transaction/transaction.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 5680523aa..d7fd3843c 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -88,16 +88,15 @@ func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.M numInnerTxs := len(tx.InnerTransactions) if numInnerTxs > 0 { ftx.InnerTransactions = make([]*FrontendTransaction, numInnerTxs) + var errPrepare error for i := 0; i < numInnerTxs; i++ { - innerFtx, errPrepare := tx.InnerTransactions[i].prepareTx(encoder) + ftx.InnerTransactions[i], errPrepare = tx.InnerTransactions[i].prepareTx(encoder) if errPrepare != nil { return nil, errPrepare } - innerFtx.Signature = hex.EncodeToString(tx.InnerTransactions[i].Signature) - innerFtx.GuardianSignature = hex.EncodeToString(tx.InnerTransactions[i].GuardianSignature) - - ftx.InnerTransactions[i] = innerFtx + ftx.InnerTransactions[i].Signature = hex.EncodeToString(tx.InnerTransactions[i].Signature) + ftx.InnerTransactions[i].GuardianSignature = hex.EncodeToString(tx.InnerTransactions[i].GuardianSignature) } } From 86ff8cd5798bbc167e7ae54f6b9983f0a21bf176 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Tue, 11 Jun 2024 14:14:33 +0300 Subject: [PATCH 24/27] added GetUserTransactions on TransactionWithFeeHandler --- data/interface.go | 1 + 1 file changed, 1 insertion(+) diff --git a/data/interface.go b/data/interface.go index 0a694b469..cbfd50c80 100644 --- a/data/interface.go +++ b/data/interface.go @@ -399,6 +399,7 @@ type TransactionWithFeeHandler interface { GetData() []byte GetRcvAddr() []byte GetValue() *big.Int + GetUserTransactions() []TransactionHandler } // UserAccountHandler models a user account From 8c8c4029d642591ff6573400c02402ada2107cd3 Mon Sep 17 00:00:00 2001 From: BeniaminDrasovean Date: Fri, 23 Aug 2024 12:18:17 +0300 Subject: [PATCH 25/27] generate MetaDataVersion struct --- data/esdt/esdt.pb.go | 465 ++++++++++++++++++++++++++++++++++--- data/esdt/proto/esdt.proto | 9 + 2 files changed, 441 insertions(+), 33 deletions(-) diff --git a/data/esdt/esdt.pb.go b/data/esdt/esdt.pb.go index 64f66dd36..7512924bb 100644 --- a/data/esdt/esdt.pb.go +++ b/data/esdt/esdt.pb.go @@ -228,48 +228,131 @@ func (m *MetaData) GetAttributes() []byte { return nil } +type MetaDataVersion struct { + Name uint64 `protobuf:"varint,1,opt,name=Name,proto3" json:"Name"` + Creator uint64 `protobuf:"varint,2,opt,name=Creator,proto3" json:"Creator"` + Royalties uint64 `protobuf:"varint,3,opt,name=Royalties,proto3" json:"Royalties"` + Hash uint64 `protobuf:"varint,4,opt,name=Hash,proto3" json:"Hash"` + URIs uint64 `protobuf:"varint,5,opt,name=URIs,proto3" json:"URIs"` + Attributes uint64 `protobuf:"varint,6,opt,name=Attributes,proto3" json:"Attributes"` +} + +func (m *MetaDataVersion) Reset() { *m = MetaDataVersion{} } +func (*MetaDataVersion) ProtoMessage() {} +func (*MetaDataVersion) Descriptor() ([]byte, []int) { + return fileDescriptor_e413e402abc6a34c, []int{3} +} +func (m *MetaDataVersion) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MetaDataVersion) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *MetaDataVersion) XXX_Merge(src proto.Message) { + xxx_messageInfo_MetaDataVersion.Merge(m, src) +} +func (m *MetaDataVersion) XXX_Size() int { + return m.Size() +} +func (m *MetaDataVersion) XXX_DiscardUnknown() { + xxx_messageInfo_MetaDataVersion.DiscardUnknown(m) +} + +var xxx_messageInfo_MetaDataVersion proto.InternalMessageInfo + +func (m *MetaDataVersion) GetName() uint64 { + if m != nil { + return m.Name + } + return 0 +} + +func (m *MetaDataVersion) GetCreator() uint64 { + if m != nil { + return m.Creator + } + return 0 +} + +func (m *MetaDataVersion) GetRoyalties() uint64 { + if m != nil { + return m.Royalties + } + return 0 +} + +func (m *MetaDataVersion) GetHash() uint64 { + if m != nil { + return m.Hash + } + return 0 +} + +func (m *MetaDataVersion) GetURIs() uint64 { + if m != nil { + return m.URIs + } + return 0 +} + +func (m *MetaDataVersion) GetAttributes() uint64 { + if m != nil { + return m.Attributes + } + return 0 +} + func init() { proto.RegisterType((*ESDigitalToken)(nil), "protoBuiltInFunctions.ESDigitalToken") proto.RegisterType((*ESDTRoles)(nil), "protoBuiltInFunctions.ESDTRoles") proto.RegisterType((*MetaData)(nil), "protoBuiltInFunctions.MetaData") + proto.RegisterType((*MetaDataVersion)(nil), "protoBuiltInFunctions.MetaDataVersion") } func init() { proto.RegisterFile("esdt.proto", fileDescriptor_e413e402abc6a34c) } var fileDescriptor_e413e402abc6a34c = []byte{ - // 513 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0xce, 0x74, 0xdb, 0xdd, 0x76, 0xb6, 0xd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, 0xaf, 0x59, 0x08, 0x76, 0x56, 0x21, 0xdc, 0x56, 0x9e, 0xba, 0x7b, - 0x91, 0xee, 0xa1, 0x99, 0xf8, 0x86, 0xc5, 0x8b, 0xdb, 0x9d, 0x61, 0xa2, 0xe1, 0x14, 0xaa, 0x39, - 0x7d, 0x4f, 0x47, 0xb1, 0x73, 0x0c, 0xdb, 0xc1, 0xa9, 0xe1, 0x14, 0xaa, 0x09, 0xee, 0x95, 0xd6, - 0x4a, 0x4c, 0x13, 0xcd, 0x63, 0xe7, 0x64, 0x1f, 0xdc, 0x5e, 0xa5, 0x07, 0xd8, 0x7f, 0xb9, 0xde, - 0x12, 0x6b, 0xb3, 0x25, 0xd6, 0xcd, 0x96, 0xa0, 0x2f, 0x19, 0x41, 0xdf, 0x33, 0x82, 0x7e, 0x65, - 0x04, 0xad, 0x33, 0x82, 0x36, 0x19, 0x41, 0x7f, 0x32, 0x82, 0xfe, 0x66, 0xc4, 0xba, 0xc9, 0x08, - 0xfa, 0xb6, 0x23, 0xd6, 0x7a, 0x47, 0xac, 0xcd, 0x8e, 0x58, 0x1f, 0xab, 0xe6, 0x7f, 0x98, 0x1e, - 0x43, 0xc0, 0xcf, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0xb8, 0x8c, 0x59, 0x17, 0x1e, 0x03, 0x00, + // 561 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcf, 0x8b, 0xd3, 0x40, + 0x14, 0xce, 0x74, 0xd3, 0xfd, 0x31, 0xfb, 0x43, 0x08, 0x08, 0x41, 0x64, 0x52, 0x0a, 0x42, 0x41, + 0x9b, 0x82, 0x1e, 0x05, 0xc1, 0xec, 0x56, 0xec, 0xc1, 0x45, 0xa6, 0x75, 0x0f, 0xde, 0xa6, 0xed, + 0x98, 0x0e, 0xa6, 0x99, 0x32, 0x99, 0x2c, 0xbb, 0x37, 0xaf, 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, 0x7b, 0x91, 0xbd, 0x0d, 0xee, 0xe0, 0x34, 0xc7, 0x14, 0x6a, + 0xbe, 0xb8, 0xe7, 0x5a, 0x2b, 0x31, 0x8c, 0x35, 0x8f, 0xec, 0x9d, 0x6a, 0x71, 0x15, 0x4b, 0x37, + 0xfa, 0xe6, 0x2f, 0x84, 0xef, 0x94, 0x59, 0x9c, 0x71, 0x15, 0x09, 0x19, 0xae, 0x1d, 0x17, 0x89, + 0xdc, 0xe2, 0xb8, 0x06, 0x82, 0xff, 0x70, 0xbc, 0x05, 0xc2, 0x7f, 0x3b, 0x36, 0xab, 0x89, 0x37, + 0x38, 0xae, 0x57, 0xa7, 0x7f, 0x75, 0xbc, 0x0d, 0x9a, 0x5b, 0x1c, 0x7b, 0xcf, 0xe6, 0x4b, 0x62, + 0x2c, 0x96, 0xc4, 0xb8, 0x5a, 0x12, 0xf4, 0x21, 0x25, 0xe8, 0x73, 0x4a, 0xd0, 0xb7, 0x94, 0xa0, + 0x79, 0x4a, 0xd0, 0x22, 0x25, 0xe8, 0x47, 0x4a, 0xd0, 0xcf, 0x94, 0x18, 0x57, 0x29, 0x41, 0x9f, + 0x56, 0xc4, 0x98, 0xaf, 0x88, 0xb1, 0x58, 0x11, 0xe3, 0xad, 0x99, 0xff, 0x03, 0x0c, 0xb7, 0xe1, + 0x27, 0xfd, 0xe4, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8c, 0xee, 0x3e, 0x3a, 0x10, 0x04, 0x00, 0x00, } @@ -388,6 +471,45 @@ func (this *MetaData) Equal(that interface{}) bool { } return true } +func (this *MetaDataVersion) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MetaDataVersion) + if !ok { + that2, ok := that.(MetaDataVersion) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Name != that1.Name { + return false + } + if this.Creator != that1.Creator { + return false + } + if this.Royalties != that1.Royalties { + return false + } + if this.Hash != that1.Hash { + return false + } + if this.URIs != that1.URIs { + return false + } + if this.Attributes != that1.Attributes { + return false + } + return true +} func (this *ESDigitalToken) GoString() string { if this == nil { return "nil" @@ -430,6 +552,21 @@ func (this *MetaData) GoString() string { s = append(s, "}") return strings.Join(s, "") } +func (this *MetaDataVersion) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 10) + s = append(s, "&esdt.MetaDataVersion{") + s = append(s, "Name: "+fmt.Sprintf("%#v", this.Name)+",\n") + s = append(s, "Creator: "+fmt.Sprintf("%#v", this.Creator)+",\n") + s = append(s, "Royalties: "+fmt.Sprintf("%#v", this.Royalties)+",\n") + s = append(s, "Hash: "+fmt.Sprintf("%#v", this.Hash)+",\n") + s = append(s, "URIs: "+fmt.Sprintf("%#v", this.URIs)+",\n") + s = append(s, "Attributes: "+fmt.Sprintf("%#v", this.Attributes)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} func valueToGoStringEsdt(v interface{}, typ string) string { rv := reflect.ValueOf(v) if rv.IsNil() { @@ -605,6 +742,59 @@ func (m *MetaData) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MetaDataVersion) 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 *MetaDataVersion) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MetaDataVersion) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Attributes != 0 { + i = encodeVarintEsdt(dAtA, i, uint64(m.Attributes)) + i-- + dAtA[i] = 0x30 + } + if m.URIs != 0 { + i = encodeVarintEsdt(dAtA, i, uint64(m.URIs)) + i-- + dAtA[i] = 0x28 + } + if m.Hash != 0 { + i = encodeVarintEsdt(dAtA, i, uint64(m.Hash)) + i-- + dAtA[i] = 0x20 + } + if m.Royalties != 0 { + i = encodeVarintEsdt(dAtA, i, uint64(m.Royalties)) + i-- + dAtA[i] = 0x18 + } + if m.Creator != 0 { + i = encodeVarintEsdt(dAtA, i, uint64(m.Creator)) + i-- + dAtA[i] = 0x10 + } + if m.Name != 0 { + i = encodeVarintEsdt(dAtA, i, uint64(m.Name)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintEsdt(dAtA []byte, offset int, v uint64) int { offset -= sovEsdt(v) base := offset @@ -697,6 +887,33 @@ func (m *MetaData) Size() (n int) { return n } +func (m *MetaDataVersion) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Name != 0 { + n += 1 + sovEsdt(uint64(m.Name)) + } + if m.Creator != 0 { + n += 1 + sovEsdt(uint64(m.Creator)) + } + if m.Royalties != 0 { + n += 1 + sovEsdt(uint64(m.Royalties)) + } + if m.Hash != 0 { + n += 1 + sovEsdt(uint64(m.Hash)) + } + if m.URIs != 0 { + n += 1 + sovEsdt(uint64(m.URIs)) + } + if m.Attributes != 0 { + n += 1 + sovEsdt(uint64(m.Attributes)) + } + return n +} + func sovEsdt(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -743,6 +960,21 @@ func (this *MetaData) String() string { }, "") return s } +func (this *MetaDataVersion) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&MetaDataVersion{`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `Creator:` + fmt.Sprintf("%v", this.Creator) + `,`, + `Royalties:` + fmt.Sprintf("%v", this.Royalties) + `,`, + `Hash:` + fmt.Sprintf("%v", this.Hash) + `,`, + `URIs:` + fmt.Sprintf("%v", this.URIs) + `,`, + `Attributes:` + fmt.Sprintf("%v", this.Attributes) + `,`, + `}`, + }, "") + return s +} func valueToStringEsdt(v interface{}) string { rv := reflect.ValueOf(v) if rv.IsNil() { @@ -1309,6 +1541,173 @@ func (m *MetaData) Unmarshal(dAtA []byte) error { } return nil } +func (m *MetaDataVersion) 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 ErrIntOverflowEsdt + } + 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: MetaDataVersion: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MetaDataVersion: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + m.Name = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEsdt + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Name |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + m.Creator = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEsdt + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Creator |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Royalties", wireType) + } + m.Royalties = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEsdt + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Royalties |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + m.Hash = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEsdt + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Hash |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field URIs", wireType) + } + m.URIs = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEsdt + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.URIs |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + m.Attributes = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEsdt + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Attributes |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEsdt(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthEsdt + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthEsdt + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipEsdt(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/data/esdt/proto/esdt.proto b/data/esdt/proto/esdt.proto index 0583bb166..c29596063 100644 --- a/data/esdt/proto/esdt.proto +++ b/data/esdt/proto/esdt.proto @@ -32,3 +32,12 @@ message MetaData { repeated bytes URIs = 6 [(gogoproto.jsontag) = "URIs"]; bytes Attributes = 7 [(gogoproto.jsontag) = "Attributes"]; } + +message MetaDataVersion { + uint64 Name = 1 [(gogoproto.jsontag) = "Name"]; + uint64 Creator = 2 [(gogoproto.jsontag) = "Creator"]; + uint64 Royalties = 3 [(gogoproto.jsontag) = "Royalties"]; + uint64 Hash = 4 [(gogoproto.jsontag) = "Hash"]; + uint64 URIs = 5 [(gogoproto.jsontag) = "URIs"]; + uint64 Attributes = 6 [(gogoproto.jsontag) = "Attributes"]; +} \ No newline at end of file From 22b700471ada416c886f7104875774f5c0428b98 Mon Sep 17 00:00:00 2001 From: BeniaminDrasovean Date: Fri, 23 Aug 2024 12:19:30 +0300 Subject: [PATCH 26/27] add empty line --- data/esdt/proto/esdt.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/esdt/proto/esdt.proto b/data/esdt/proto/esdt.proto index c29596063..84338addb 100644 --- a/data/esdt/proto/esdt.proto +++ b/data/esdt/proto/esdt.proto @@ -40,4 +40,4 @@ message MetaDataVersion { uint64 Hash = 4 [(gogoproto.jsontag) = "Hash"]; uint64 URIs = 5 [(gogoproto.jsontag) = "URIs"]; uint64 Attributes = 6 [(gogoproto.jsontag) = "Attributes"]; -} \ No newline at end of file +} From 50ac1ae238242de58dc03f8655c5f9cae83b6be3 Mon Sep 17 00:00:00 2001 From: Marius C Date: Mon, 7 Oct 2024 14:33:00 +0300 Subject: [PATCH 27/27] CLN: Delete sovereign tx --- data/sovereignTx/sovereignTx.go | 57 --- data/sovereignTx/sovereignTx.pb.go | 701 --------------------------- data/sovereignTx/sovereignTx.proto | 19 - data/sovereignTx/sovereignTx_test.go | 90 ---- 4 files changed, 867 deletions(-) delete mode 100644 data/sovereignTx/sovereignTx.go delete mode 100644 data/sovereignTx/sovereignTx.pb.go delete mode 100644 data/sovereignTx/sovereignTx.proto delete mode 100644 data/sovereignTx/sovereignTx_test.go diff --git a/data/sovereignTx/sovereignTx.go b/data/sovereignTx/sovereignTx.go deleted file mode 100644 index a2fedab14..000000000 --- a/data/sovereignTx/sovereignTx.go +++ /dev/null @@ -1,57 +0,0 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. sovereignTx.proto -package sovereignTx - -import ( - "github.com/multiversx/mx-chain-core-go/data" - "math/big" -) - -var _ = data.TransactionHandler(&SovereignTx{}) - -// IsInterfaceNil verifies if underlying object is nil -func (stx *SovereignTx) IsInterfaceNil() bool { - return stx == nil -} - -// SetValue sets the value of the sovereign transaction -func (stx *SovereignTx) SetValue(value *big.Int) { - stx.Value = value -} - -// SetData sets the data of the sovereign transaction -func (stx *SovereignTx) SetData(data []byte) { - stx.Data = data -} - -// SetRcvAddr sets the receiver address of the sovereign transaction -func (stx *SovereignTx) SetRcvAddr(addr []byte) { - stx.RcvAddr = addr -} - -// SetSndAddr sets the sender address of the sovereign transaction -func (stx *SovereignTx) SetSndAddr(addr []byte) { - stx.SndAddr = addr -} - -// GetRcvUserName returns nil for sovereign transaction -func (stx *SovereignTx) GetRcvUserName() []byte { - return nil -} - -// CheckIntegrity checks the integrity of sovereign transaction's fields -func (stx *SovereignTx) CheckIntegrity() error { - if len(stx.RcvAddr) == 0 { - return data.ErrNilRcvAddr - } - if len(stx.SndAddr) == 0 { - return data.ErrNilSndAddr - } - if stx.Value == nil { - return data.ErrNilValue - } - if stx.Value.Sign() < 0 { - return data.ErrNegativeValue - } - - return nil -} diff --git a/data/sovereignTx/sovereignTx.pb.go b/data/sovereignTx/sovereignTx.pb.go deleted file mode 100644 index a3f4a3e35..000000000 --- a/data/sovereignTx/sovereignTx.pb.go +++ /dev/null @@ -1,701 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: sovereignTx.proto - -package sovereignTx - -import ( - bytes "bytes" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - github_com_multiversx_mx_chain_core_go_data "github.com/multiversx/mx-chain-core-go/data" - io "io" - math "math" - math_big "math/big" - math_bits "math/bits" - reflect "reflect" - strings "strings" -) - -// 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 SovereignTx struct { - Nonce uint64 `protobuf:"varint,1,opt,name=Nonce,proto3" json:"nonce"` - Value *math_big.Int `protobuf:"bytes,2,opt,name=Value,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"value"` - RcvAddr []byte `protobuf:"bytes,3,opt,name=RcvAddr,proto3" json:"receiver"` - SndAddr []byte `protobuf:"bytes,4,opt,name=SndAddr,proto3" json:"sender"` - GasLimit uint64 `protobuf:"varint,5,opt,name=GasLimit,proto3" json:"gasLimit"` - GasPrice uint64 `protobuf:"varint,6,opt,name=GasPrice,proto3" json:"gasPrice"` - Data []byte `protobuf:"bytes,7,opt,name=Data,proto3" json:"data,omitempty"` -} - -func (m *SovereignTx) Reset() { *m = SovereignTx{} } -func (*SovereignTx) ProtoMessage() {} -func (*SovereignTx) Descriptor() ([]byte, []int) { - return fileDescriptor_3309200ee9b6aa5f, []int{0} -} -func (m *SovereignTx) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SovereignTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *SovereignTx) XXX_Merge(src proto.Message) { - xxx_messageInfo_SovereignTx.Merge(m, src) -} -func (m *SovereignTx) XXX_Size() int { - return m.Size() -} -func (m *SovereignTx) XXX_DiscardUnknown() { - xxx_messageInfo_SovereignTx.DiscardUnknown(m) -} - -var xxx_messageInfo_SovereignTx proto.InternalMessageInfo - -func (m *SovereignTx) GetNonce() uint64 { - if m != nil { - return m.Nonce - } - return 0 -} - -func (m *SovereignTx) GetValue() *math_big.Int { - if m != nil { - return m.Value - } - return nil -} - -func (m *SovereignTx) GetRcvAddr() []byte { - if m != nil { - return m.RcvAddr - } - return nil -} - -func (m *SovereignTx) GetSndAddr() []byte { - if m != nil { - return m.SndAddr - } - return nil -} - -func (m *SovereignTx) GetGasLimit() uint64 { - if m != nil { - return m.GasLimit - } - return 0 -} - -func (m *SovereignTx) GetGasPrice() uint64 { - if m != nil { - return m.GasPrice - } - return 0 -} - -func (m *SovereignTx) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -func init() { - proto.RegisterType((*SovereignTx)(nil), "proto.SovereignTx") -} - -func init() { proto.RegisterFile("sovereignTx.proto", fileDescriptor_3309200ee9b6aa5f) } - -var fileDescriptor_3309200ee9b6aa5f = []byte{ - // 385 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x91, 0xb1, 0xae, 0xd3, 0x30, - 0x14, 0x86, 0xe3, 0x4b, 0xd3, 0x5e, 0x7c, 0xaf, 0x90, 0xf0, 0x14, 0x31, 0x38, 0x57, 0x08, 0x5d, - 0x75, 0x20, 0xc9, 0xc0, 0xc8, 0x44, 0xe0, 0x0a, 0x55, 0x42, 0x08, 0xb9, 0x88, 0x81, 0xcd, 0x49, - 0x8c, 0x63, 0xa9, 0xb1, 0x2b, 0xc7, 0x89, 0xca, 0xc6, 0x23, 0xf0, 0x18, 0x88, 0x27, 0x61, 0xec, - 0xd8, 0x29, 0x50, 0x77, 0x41, 0x99, 0xfa, 0x08, 0x28, 0x6e, 0x29, 0x65, 0xb2, 0xcf, 0xff, 0x7f, - 0x3e, 0xbf, 0x8f, 0x0e, 0x7c, 0x58, 0xab, 0x96, 0x69, 0x26, 0xb8, 0x7c, 0xbf, 0x8a, 0x97, 0x5a, - 0x19, 0x85, 0x7c, 0x77, 0x3c, 0x8a, 0xb8, 0x30, 0x65, 0x93, 0xc5, 0xb9, 0xaa, 0x12, 0xae, 0xb8, - 0x4a, 0x9c, 0x9c, 0x35, 0x9f, 0x5c, 0xe5, 0x0a, 0x77, 0x3b, 0xbc, 0x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x60, 0x98, 0xe6, 0xa9, 0xaa, 0x84, 0x61, 0xd5, 0xd2, 0x7c, 0x26, 0xce, 0x4f, 0xef, 0xd6, - 0x5b, 0xec, 0x6d, 0xb6, 0xd8, 0xdb, 0x6f, 0x31, 0xf8, 0x62, 0x31, 0xf8, 0x66, 0x31, 0xf8, 0x61, - 0x31, 0x58, 0x5b, 0x0c, 0x36, 0x16, 0x83, 0x5f, 0x16, 0x83, 0xdf, 0x16, 0x7b, 0x7b, 0x8b, 0xc1, - 0xd7, 0x1d, 0xf6, 0xd6, 0x3b, 0xec, 0x6d, 0x76, 0xd8, 0xfb, 0x78, 0x75, 0xb6, 0xe7, 0x6c, 0xec, - 0x56, 0xf6, 0xec, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x87, 0xb5, 0xbe, 0x2f, 0xfd, 0x01, 0x00, - 0x00, -} - -func (this *SovereignTx) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*SovereignTx) - if !ok { - that2, ok := that.(SovereignTx) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.Nonce != that1.Nonce { - return false - } - { - __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} - if !__caster.Equal(this.Value, that1.Value) { - return false - } - } - if !bytes.Equal(this.RcvAddr, that1.RcvAddr) { - return false - } - if !bytes.Equal(this.SndAddr, that1.SndAddr) { - return false - } - if this.GasLimit != that1.GasLimit { - return false - } - if this.GasPrice != that1.GasPrice { - return false - } - if !bytes.Equal(this.Data, that1.Data) { - return false - } - return true -} -func (this *SovereignTx) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 11) - s = append(s, "&sovereignTx.SovereignTx{") - s = append(s, "Nonce: "+fmt.Sprintf("%#v", this.Nonce)+",\n") - s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") - s = append(s, "RcvAddr: "+fmt.Sprintf("%#v", this.RcvAddr)+",\n") - s = append(s, "SndAddr: "+fmt.Sprintf("%#v", this.SndAddr)+",\n") - s = append(s, "GasLimit: "+fmt.Sprintf("%#v", this.GasLimit)+",\n") - s = append(s, "GasPrice: "+fmt.Sprintf("%#v", this.GasPrice)+",\n") - s = append(s, "Data: "+fmt.Sprintf("%#v", this.Data)+",\n") - s = append(s, "}") - return strings.Join(s, "") -} -func valueToGoStringSovereignTx(v interface{}, typ string) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" - } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) -} -func (m *SovereignTx) 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 *SovereignTx) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SovereignTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintSovereignTx(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x3a - } - if m.GasPrice != 0 { - i = encodeVarintSovereignTx(dAtA, i, uint64(m.GasPrice)) - i-- - dAtA[i] = 0x30 - } - if m.GasLimit != 0 { - i = encodeVarintSovereignTx(dAtA, i, uint64(m.GasLimit)) - i-- - dAtA[i] = 0x28 - } - if len(m.SndAddr) > 0 { - i -= len(m.SndAddr) - copy(dAtA[i:], m.SndAddr) - i = encodeVarintSovereignTx(dAtA, i, uint64(len(m.SndAddr))) - i-- - dAtA[i] = 0x22 - } - if len(m.RcvAddr) > 0 { - i -= len(m.RcvAddr) - copy(dAtA[i:], m.RcvAddr) - i = encodeVarintSovereignTx(dAtA, i, uint64(len(m.RcvAddr))) - i-- - dAtA[i] = 0x1a - } - { - __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} - size := __caster.Size(m.Value) - i -= size - if _, err := __caster.MarshalTo(m.Value, dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintSovereignTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.Nonce != 0 { - i = encodeVarintSovereignTx(dAtA, i, uint64(m.Nonce)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintSovereignTx(dAtA []byte, offset int, v uint64) int { - offset -= sovSovereignTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *SovereignTx) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Nonce != 0 { - n += 1 + sovSovereignTx(uint64(m.Nonce)) - } - { - __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} - l = __caster.Size(m.Value) - n += 1 + l + sovSovereignTx(uint64(l)) - } - l = len(m.RcvAddr) - if l > 0 { - n += 1 + l + sovSovereignTx(uint64(l)) - } - l = len(m.SndAddr) - if l > 0 { - n += 1 + l + sovSovereignTx(uint64(l)) - } - if m.GasLimit != 0 { - n += 1 + sovSovereignTx(uint64(m.GasLimit)) - } - if m.GasPrice != 0 { - n += 1 + sovSovereignTx(uint64(m.GasPrice)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + sovSovereignTx(uint64(l)) - } - return n -} - -func sovSovereignTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozSovereignTx(x uint64) (n int) { - return sovSovereignTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (this *SovereignTx) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&SovereignTx{`, - `Nonce:` + fmt.Sprintf("%v", this.Nonce) + `,`, - `Value:` + fmt.Sprintf("%v", this.Value) + `,`, - `RcvAddr:` + fmt.Sprintf("%v", this.RcvAddr) + `,`, - `SndAddr:` + fmt.Sprintf("%v", this.SndAddr) + `,`, - `GasLimit:` + fmt.Sprintf("%v", this.GasLimit) + `,`, - `GasPrice:` + fmt.Sprintf("%v", this.GasPrice) + `,`, - `Data:` + fmt.Sprintf("%v", this.Data) + `,`, - `}`, - }, "") - return s -} -func valueToStringSovereignTx(v interface{}) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" - } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("*%v", pv) -} -func (m *SovereignTx) 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 ErrIntOverflowSovereignTx - } - 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: SovereignTx: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SovereignTx: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) - } - m.Nonce = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSovereignTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Nonce |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSovereignTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthSovereignTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthSovereignTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - { - __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} - if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } else { - m.Value = tmp - } - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RcvAddr", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSovereignTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthSovereignTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthSovereignTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RcvAddr = append(m.RcvAddr[:0], dAtA[iNdEx:postIndex]...) - if m.RcvAddr == nil { - m.RcvAddr = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SndAddr", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSovereignTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthSovereignTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthSovereignTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SndAddr = append(m.SndAddr[:0], dAtA[iNdEx:postIndex]...) - if m.SndAddr == nil { - m.SndAddr = []byte{} - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType) - } - m.GasLimit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSovereignTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.GasLimit |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GasPrice", wireType) - } - m.GasPrice = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSovereignTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.GasPrice |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSovereignTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthSovereignTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthSovereignTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSovereignTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthSovereignTx - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthSovereignTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipSovereignTx(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, ErrIntOverflowSovereignTx - } - 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, ErrIntOverflowSovereignTx - } - 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, ErrIntOverflowSovereignTx - } - 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, ErrInvalidLengthSovereignTx - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupSovereignTx - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthSovereignTx - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthSovereignTx = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowSovereignTx = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupSovereignTx = fmt.Errorf("proto: unexpected end of group") -) diff --git a/data/sovereignTx/sovereignTx.proto b/data/sovereignTx/sovereignTx.proto deleted file mode 100644 index 033ec71f9..000000000 --- a/data/sovereignTx/sovereignTx.proto +++ /dev/null @@ -1,19 +0,0 @@ - -syntax = "proto3"; - -package proto; - -option go_package = "sovereignTx"; -option (gogoproto.stable_marshaler_all) = true; - -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -message SovereignTx { - uint64 Nonce = 1 [(gogoproto.jsontag) = "nonce"]; - bytes Value = 2 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; - bytes RcvAddr = 3 [(gogoproto.jsontag) = "receiver"]; - bytes SndAddr = 4 [(gogoproto.jsontag) = "sender"]; - uint64 GasLimit = 5 [(gogoproto.jsontag) = "gasLimit"]; - uint64 GasPrice = 6 [(gogoproto.jsontag) = "gasPrice"]; - bytes Data = 7 [(gogoproto.jsontag) = "data,omitempty"]; -} diff --git a/data/sovereignTx/sovereignTx_test.go b/data/sovereignTx/sovereignTx_test.go deleted file mode 100644 index eaf601d5a..000000000 --- a/data/sovereignTx/sovereignTx_test.go +++ /dev/null @@ -1,90 +0,0 @@ -package sovereignTx_test - -import ( - "math/big" - "testing" - - "github.com/multiversx/mx-chain-core-go/data" - "github.com/multiversx/mx-chain-core-go/data/sovereignTx" - "github.com/stretchr/testify/assert" -) - -func TestSovereignTx_SettersAndGetters(t *testing.T) { - t.Parallel() - - nonce := uint64(5) - gasPrice := uint64(1) - gasLimit := uint64(10) - stx := sovereignTx.SovereignTx{ - Nonce: nonce, - GasPrice: gasPrice, - GasLimit: gasLimit, - } - - rcvAddr := []byte("rcv address") - sndAddr := []byte("snd address") - value := big.NewInt(37) - txData := []byte("data") - - stx.SetRcvAddr(rcvAddr) - stx.SetSndAddr(sndAddr) - stx.SetValue(value) - stx.SetData(txData) - - assert.Equal(t, sndAddr, stx.GetSndAddr()) - assert.Equal(t, rcvAddr, stx.GetRcvAddr()) - assert.Equal(t, value, stx.GetValue()) - assert.Equal(t, txData, stx.GetData()) - assert.Equal(t, gasLimit, stx.GetGasLimit()) - assert.Equal(t, gasPrice, stx.GetGasPrice()) - assert.Equal(t, nonce, stx.GetNonce()) -} - -func createValidSovereignTx() *sovereignTx.SovereignTx { - return &sovereignTx.SovereignTx{ - Nonce: 1, - Value: big.NewInt(10), - GasPrice: 1, - GasLimit: 10, - Data: []byte("data"), - RcvAddr: []byte("rcv-address"), - SndAddr: []byte("snd-address"), - } -} - -func TestSovereignTx_CheckIntegrityShouldWork(t *testing.T) { - t.Parallel() - - stx := createValidSovereignTx() - err := stx.CheckIntegrity() - - assert.Nil(t, err) -} - -func TestSovereignTx_CheckIntegrityShouldErr(t *testing.T) { - t.Parallel() - - stx := createValidSovereignTx() - stx.RcvAddr = nil - err := stx.CheckIntegrity() - - assert.Equal(t, data.ErrNilRcvAddr, err) - - stx = createValidSovereignTx() - stx.SndAddr = nil - err = stx.CheckIntegrity() - - assert.Equal(t, data.ErrNilSndAddr, err) - - stx = createValidSovereignTx() - stx.Value = nil - err = stx.CheckIntegrity() - - assert.Equal(t, data.ErrNilValue, err) - - stx = createValidSovereignTx() - stx.Value = big.NewInt(-1) - err = stx.CheckIntegrity() - - assert.Equal(t, data.ErrNegativeValue, err) -}