From 780f9acc238bab1ff6323c53bedac0a5f3463171 Mon Sep 17 00:00:00 2001 From: matei-p Date: Mon, 29 May 2023 10:10:50 +0300 Subject: [PATCH 1/4] log entry api changes --- data/vm/vmOutputApi.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/vm/vmOutputApi.go b/data/vm/vmOutputApi.go index 68c277b42..9eaa89cf7 100644 --- a/data/vm/vmOutputApi.go +++ b/data/vm/vmOutputApi.go @@ -52,7 +52,7 @@ type LogEntryApi struct { Identifier []byte `json:"identifier"` Address string `json:"address"` Topics [][]byte `json:"topics"` - Data []byte `json:"data"` + Data [][]byte `json:"data"` } // GetFirstReturnData is a helper function that returns the first ReturnData of VMOutput, interpreted as specified. From 6b256b073e6280749563e6d13bcb94a5fb49e806 Mon Sep 17 00:00:00 2001 From: matei-p Date: Tue, 30 May 2023 11:14:36 +0300 Subject: [PATCH 2/4] added extra field --- data/vm/vmOutputApi.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/data/vm/vmOutputApi.go b/data/vm/vmOutputApi.go index 9eaa89cf7..f3428b4d9 100644 --- a/data/vm/vmOutputApi.go +++ b/data/vm/vmOutputApi.go @@ -49,10 +49,11 @@ type OutputTransferApi struct { // LogEntryApi is a wrapper over vmcommon's LogEntry type LogEntryApi struct { - Identifier []byte `json:"identifier"` - Address string `json:"address"` - Topics [][]byte `json:"topics"` - Data [][]byte `json:"data"` + Identifier []byte `json:"identifier"` + Address string `json:"address"` + Topics [][]byte `json:"topics"` + Data []byte `json:"data"` + AdditionalData [][]byte `json:"additionalData"` } // GetFirstReturnData is a helper function that returns the first ReturnData of VMOutput, interpreted as specified. From b7bc17bd66fe76e23757957ebf9f68b1736262fa Mon Sep 17 00:00:00 2001 From: matei-p Date: Wed, 31 May 2023 17:09:45 +0300 Subject: [PATCH 3/4] fixes after review --- data/transaction/log.pb.go | 117 +++++++++++++++++++++++++++++-------- data/transaction/log.proto | 9 +-- 2 files changed, 97 insertions(+), 29 deletions(-) diff --git a/data/transaction/log.pb.go b/data/transaction/log.pb.go index eb9e5e23f..0f0b729e8 100644 --- a/data/transaction/log.pb.go +++ b/data/transaction/log.pb.go @@ -28,10 +28,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Event holds all the data needed for an event structure type Event struct { - Address []byte `protobuf:"bytes,1,opt,name=Address,proto3" json:"address"` - Identifier []byte `protobuf:"bytes,2,opt,name=Identifier,proto3" json:"identifier"` - Topics [][]byte `protobuf:"bytes,3,rep,name=Topics,proto3" json:"topics"` - Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"data"` + Address []byte `protobuf:"bytes,1,opt,name=Address,proto3" json:"address"` + Identifier []byte `protobuf:"bytes,2,opt,name=Identifier,proto3" json:"identifier"` + Topics [][]byte `protobuf:"bytes,3,rep,name=Topics,proto3" json:"topics"` + Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"data"` + AdditionalData [][]byte `protobuf:"bytes,5,rep,name=AdditionalData,proto3" json:"additionalData"` } func (m *Event) Reset() { *m = Event{} } @@ -90,6 +91,13 @@ func (m *Event) GetData() []byte { return nil } +func (m *Event) GetAdditionalData() [][]byte { + if m != nil { + return m.AdditionalData + } + return nil +} + // Log holds all the data needed for a log structure type Log struct { Address []byte `protobuf:"bytes,1,opt,name=Address,proto3" json:"address"` @@ -146,26 +154,28 @@ func init() { func init() { proto.RegisterFile("log.proto", fileDescriptor_a153da538f858886) } var fileDescriptor_a153da538f858886 = []byte{ - // 303 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x8f, 0xbf, 0x4e, 0xf3, 0x30, - 0x14, 0xc5, 0xed, 0xa6, 0x4d, 0xbf, 0xcf, 0xad, 0x18, 0x32, 0x45, 0x08, 0xdd, 0x54, 0x91, 0x90, - 0xb2, 0x90, 0x22, 0x78, 0x02, 0x22, 0x3a, 0x20, 0x31, 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c2, 0xf0, - 0x66, 0x67, 0xf3, 0xa1, 0xa8, 0x8f, 0x70, 0x48, 0x4f, 0x51, 0x0f, 0xf7, 0xbe, 0x60, 0x55, 0xb5, - 0x40, 0xea, 0x16, 0xc8, 0xae, 0x05, 0xfa, 0xac, 0x81, 0xbe, 0x69, 0xa0, 0xef, 0x1a, 0x68, 0xa5, - 0x81, 0xd6, 0x1a, 0xe8, 0x87, 0x06, 0xfa, 0xa9, 0x81, 0xec, 0x34, 0xd0, 0x97, 0x0e, 0x48, 0xd5, - 0x01, 0xa9, 0x3b, 0x20, 0xb7, 0x33, 0x55, 0xf0, 0xbc, 0xe4, 0xb1, 0x12, 0x32, 0x8f, 0x4c, 0xcc, - 0x39, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x55, 0xcf, 0x0b, 0x93, 0x01, 0x00, 0x00, + // 327 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0x31, 0x4f, 0xc2, 0x40, + 0x14, 0xc7, 0x7b, 0x14, 0x8a, 0x3e, 0x08, 0xc3, 0x4d, 0x8d, 0x31, 0xaf, 0x84, 0xc4, 0x84, 0xc5, + 0x62, 0x74, 0x73, 0x83, 0xc8, 0x60, 0xe2, 0xd4, 0x38, 0x39, 0x98, 0x1c, 0xb4, 0xd4, 0x4b, 0xb0, + 0x47, 0xda, 0xc3, 0xd9, 0x8f, 0xe0, 0xc7, 0xf0, 0xa3, 0x38, 0x32, 0x32, 0x98, 0x46, 0xae, 0x8b, + 0xe9, 0xc4, 0x47, 0x30, 0xbe, 0xa2, 0x51, 0x27, 0xa7, 0xf6, 0xfd, 0xfe, 0xbf, 0x7b, 0xf7, 0xee, + 0xc1, 0xfe, 0x5c, 0xc5, 0xfe, 0x22, 0x55, 0x5a, 0xf1, 0x06, 0x7d, 0x0e, 0x8e, 0x63, 0xa9, 0xef, + 0x96, 0x13, 0x7f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ec, 0xcd, 0x20, 0x7b, 0x37, 0x68, + 0x6d, 0x0d, 0xb2, 0xa7, 0x02, 0xad, 0x55, 0x81, 0xd6, 0xba, 0x40, 0xeb, 0xa6, 0xa5, 0x53, 0x91, + 0x64, 0x62, 0xfa, 0x39, 0xec, 0xc4, 0xa1, 0x7b, 0xce, 0x3e, 0x02, 0x00, 0x00, 0xff, 0xff, 0xff, + 0xf2, 0x5d, 0xce, 0xcf, 0x01, 0x00, 0x00, } func (this *Event) Equal(that interface{}) bool { @@ -204,6 +214,14 @@ func (this *Event) Equal(that interface{}) bool { if !bytes.Equal(this.Data, that1.Data) { return false } + if len(this.AdditionalData) != len(that1.AdditionalData) { + return false + } + for i := range this.AdditionalData { + if !bytes.Equal(this.AdditionalData[i], that1.AdditionalData[i]) { + return false + } + } return true } func (this *Log) Equal(that interface{}) bool { @@ -242,12 +260,13 @@ func (this *Event) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 8) + s := make([]string, 0, 9) s = append(s, "&transaction.Event{") s = append(s, "Address: "+fmt.Sprintf("%#v", this.Address)+",\n") s = append(s, "Identifier: "+fmt.Sprintf("%#v", this.Identifier)+",\n") s = append(s, "Topics: "+fmt.Sprintf("%#v", this.Topics)+",\n") s = append(s, "Data: "+fmt.Sprintf("%#v", this.Data)+",\n") + s = append(s, "AdditionalData: "+fmt.Sprintf("%#v", this.AdditionalData)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -292,6 +311,15 @@ func (m *Event) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AdditionalData) > 0 { + for iNdEx := len(m.AdditionalData) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AdditionalData[iNdEx]) + copy(dAtA[i:], m.AdditionalData[iNdEx]) + i = encodeVarintLog(dAtA, i, uint64(len(m.AdditionalData[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } if len(m.Data) > 0 { i -= len(m.Data) copy(dAtA[i:], m.Data) @@ -404,6 +432,12 @@ func (m *Event) Size() (n int) { if l > 0 { n += 1 + l + sovLog(uint64(l)) } + if len(m.AdditionalData) > 0 { + for _, b := range m.AdditionalData { + l = len(b) + n += 1 + l + sovLog(uint64(l)) + } + } return n } @@ -441,6 +475,7 @@ func (this *Event) String() string { `Identifier:` + fmt.Sprintf("%v", this.Identifier) + `,`, `Topics:` + fmt.Sprintf("%v", this.Topics) + `,`, `Data:` + fmt.Sprintf("%v", this.Data) + `,`, + `AdditionalData:` + fmt.Sprintf("%v", this.AdditionalData) + `,`, `}`, }, "") return s @@ -632,6 +667,38 @@ func (m *Event) Unmarshal(dAtA []byte) error { m.Data = []byte{} } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AdditionalData", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLog + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthLog + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthLog + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AdditionalData = append(m.AdditionalData, make([]byte, postIndex-iNdEx)) + copy(m.AdditionalData[len(m.AdditionalData)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipLog(dAtA[iNdEx:]) diff --git a/data/transaction/log.proto b/data/transaction/log.proto index 1aaa0a3ff..706683dd8 100644 --- a/data/transaction/log.proto +++ b/data/transaction/log.proto @@ -10,10 +10,11 @@ import "github.com/gogo/protobuf/gogoproto/gogo.proto"; // Event holds all the data needed for an event structure message Event { - bytes Address = 1 [(gogoproto.jsontag) = "address"]; - bytes Identifier = 2 [(gogoproto.jsontag) = "identifier"]; - repeated bytes Topics = 3 [(gogoproto.jsontag) = "topics"]; - bytes Data = 4 [(gogoproto.jsontag) = "data"]; + bytes Address = 1 [(gogoproto.jsontag) = "address"]; + bytes Identifier = 2 [(gogoproto.jsontag) = "identifier"]; + repeated bytes Topics = 3 [(gogoproto.jsontag) = "topics"]; + bytes Data = 4 [(gogoproto.jsontag) = "data"]; + repeated bytes AdditionalData = 5 [(gogoproto.jsontag) = "additionalData"]; } // Log holds all the data needed for a log structure From 8fbe8e75cf82853466e1782821e4ad1ff73d6cee Mon Sep 17 00:00:00 2001 From: matei-p Date: Tue, 11 Jul 2023 17:27:23 +0300 Subject: [PATCH 4/4] update Events structure --- data/transaction/apiTransactionResult.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/data/transaction/apiTransactionResult.go b/data/transaction/apiTransactionResult.go index 17e2d5b9e..ca9671b10 100644 --- a/data/transaction/apiTransactionResult.go +++ b/data/transaction/apiTransactionResult.go @@ -117,10 +117,11 @@ type ApiLogs struct { // Events represents the events generated by a transaction with changed fields' types in order to make it friendly for API's json type Events struct { - Address string `json:"address"` - Identifier string `json:"identifier"` - Topics [][]byte `json:"topics"` - Data []byte `json:"data"` + Address string `json:"address"` + Identifier string `json:"identifier"` + Topics [][]byte `json:"topics"` + Data []byte `json:"data"` + AdditionalData [][]byte `json:"additionalData"` } // CostResponse is structure used to return the transaction cost in gas units