diff --git a/CHANGELOG.md b/CHANGELOG.md index c3ed2eff9..3f97c8a21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,8 @@ - [\#512](https://github.com/cosmos/evm/pull/512) Add integration test for appside mempool. - [\#568](https://github.com/cosmos/evm/pull/568) Avoid unnecessary block notifications when the event bus is already set up. - [\#511](https://github.com/cosmos/evm/pull/511) Minor code cleanup for `AddPrecompileFn`. -- [\#544](https://github.com/cosmos/evm/pull/544) Parse logs from the txResult.Data and avoid emitting EVM events to cosmos-sdk events. +- [\#576](https://github.com/cosmos/evm/pull/576) Parse logs from the txResult.Data and avoid emitting EVM events to cosmos-sdk events. +- [\#584](https://github.com/cosmos/evm/pull/584) Fill block hash and timestamp for json rpc. - [\#582](https://github.com/cosmos/evm/pull/582) Add block max-gas (from genesis.json) and new min-tip (from app.toml/flags) ingestion into mempool config - [\#598](https://github.com/cosmos/evm/pull/598) Reduce number of times CreateQueryContext in mempool. - [\#606](https://github.com/cosmos/evm/pull/606) Regenerate mock file for bank keeper related test. diff --git a/api/cosmos/evm/vm/v1/tx.pulsar.go b/api/cosmos/evm/vm/v1/tx.pulsar.go index 01c31e38d..f39f7451e 100644 --- a/api/cosmos/evm/vm/v1/tx.pulsar.go +++ b/api/cosmos/evm/vm/v1/tx.pulsar.go @@ -913,13 +913,15 @@ func (x *_MsgEthereumTxResponse_2_list) IsValid() bool { } var ( - md_MsgEthereumTxResponse protoreflect.MessageDescriptor - fd_MsgEthereumTxResponse_hash protoreflect.FieldDescriptor - fd_MsgEthereumTxResponse_logs protoreflect.FieldDescriptor - fd_MsgEthereumTxResponse_ret protoreflect.FieldDescriptor - fd_MsgEthereumTxResponse_vm_error protoreflect.FieldDescriptor - fd_MsgEthereumTxResponse_gas_used protoreflect.FieldDescriptor - fd_MsgEthereumTxResponse_max_used_gas protoreflect.FieldDescriptor + md_MsgEthereumTxResponse protoreflect.MessageDescriptor + fd_MsgEthereumTxResponse_hash protoreflect.FieldDescriptor + fd_MsgEthereumTxResponse_logs protoreflect.FieldDescriptor + fd_MsgEthereumTxResponse_ret protoreflect.FieldDescriptor + fd_MsgEthereumTxResponse_vm_error protoreflect.FieldDescriptor + fd_MsgEthereumTxResponse_gas_used protoreflect.FieldDescriptor + fd_MsgEthereumTxResponse_max_used_gas protoreflect.FieldDescriptor + fd_MsgEthereumTxResponse_block_hash protoreflect.FieldDescriptor + fd_MsgEthereumTxResponse_block_timestamp protoreflect.FieldDescriptor ) func init() { @@ -931,6 +933,8 @@ func init() { fd_MsgEthereumTxResponse_vm_error = md_MsgEthereumTxResponse.Fields().ByName("vm_error") fd_MsgEthereumTxResponse_gas_used = md_MsgEthereumTxResponse.Fields().ByName("gas_used") fd_MsgEthereumTxResponse_max_used_gas = md_MsgEthereumTxResponse.Fields().ByName("max_used_gas") + fd_MsgEthereumTxResponse_block_hash = md_MsgEthereumTxResponse.Fields().ByName("block_hash") + fd_MsgEthereumTxResponse_block_timestamp = md_MsgEthereumTxResponse.Fields().ByName("block_timestamp") } var _ protoreflect.Message = (*fastReflection_MsgEthereumTxResponse)(nil) @@ -1034,6 +1038,18 @@ func (x *fastReflection_MsgEthereumTxResponse) Range(f func(protoreflect.FieldDe return } } + if len(x.BlockHash) != 0 { + value := protoreflect.ValueOfBytes(x.BlockHash) + if !f(fd_MsgEthereumTxResponse_block_hash, value) { + return + } + } + if x.BlockTimestamp != uint64(0) { + value := protoreflect.ValueOfUint64(x.BlockTimestamp) + if !f(fd_MsgEthereumTxResponse_block_timestamp, value) { + return + } + } } // Has reports whether a field is populated. @@ -1061,6 +1077,10 @@ func (x *fastReflection_MsgEthereumTxResponse) Has(fd protoreflect.FieldDescript return x.GasUsed != uint64(0) case "cosmos.evm.vm.v1.MsgEthereumTxResponse.max_used_gas": return x.MaxUsedGas != uint64(0) + case "cosmos.evm.vm.v1.MsgEthereumTxResponse.block_hash": + return len(x.BlockHash) != 0 + case "cosmos.evm.vm.v1.MsgEthereumTxResponse.block_timestamp": + return x.BlockTimestamp != uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.evm.vm.v1.MsgEthereumTxResponse")) @@ -1089,6 +1109,10 @@ func (x *fastReflection_MsgEthereumTxResponse) Clear(fd protoreflect.FieldDescri x.GasUsed = uint64(0) case "cosmos.evm.vm.v1.MsgEthereumTxResponse.max_used_gas": x.MaxUsedGas = uint64(0) + case "cosmos.evm.vm.v1.MsgEthereumTxResponse.block_hash": + x.BlockHash = nil + case "cosmos.evm.vm.v1.MsgEthereumTxResponse.block_timestamp": + x.BlockTimestamp = uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.evm.vm.v1.MsgEthereumTxResponse")) @@ -1126,6 +1150,12 @@ func (x *fastReflection_MsgEthereumTxResponse) Get(descriptor protoreflect.Field case "cosmos.evm.vm.v1.MsgEthereumTxResponse.max_used_gas": value := x.MaxUsedGas return protoreflect.ValueOfUint64(value) + case "cosmos.evm.vm.v1.MsgEthereumTxResponse.block_hash": + value := x.BlockHash + return protoreflect.ValueOfBytes(value) + case "cosmos.evm.vm.v1.MsgEthereumTxResponse.block_timestamp": + value := x.BlockTimestamp + return protoreflect.ValueOfUint64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.evm.vm.v1.MsgEthereumTxResponse")) @@ -1160,6 +1190,10 @@ func (x *fastReflection_MsgEthereumTxResponse) Set(fd protoreflect.FieldDescript x.GasUsed = value.Uint() case "cosmos.evm.vm.v1.MsgEthereumTxResponse.max_used_gas": x.MaxUsedGas = value.Uint() + case "cosmos.evm.vm.v1.MsgEthereumTxResponse.block_hash": + x.BlockHash = value.Bytes() + case "cosmos.evm.vm.v1.MsgEthereumTxResponse.block_timestamp": + x.BlockTimestamp = value.Uint() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.evm.vm.v1.MsgEthereumTxResponse")) @@ -1196,6 +1230,10 @@ func (x *fastReflection_MsgEthereumTxResponse) Mutable(fd protoreflect.FieldDesc panic(fmt.Errorf("field gas_used of message cosmos.evm.vm.v1.MsgEthereumTxResponse is not mutable")) case "cosmos.evm.vm.v1.MsgEthereumTxResponse.max_used_gas": panic(fmt.Errorf("field max_used_gas of message cosmos.evm.vm.v1.MsgEthereumTxResponse is not mutable")) + case "cosmos.evm.vm.v1.MsgEthereumTxResponse.block_hash": + panic(fmt.Errorf("field block_hash of message cosmos.evm.vm.v1.MsgEthereumTxResponse is not mutable")) + case "cosmos.evm.vm.v1.MsgEthereumTxResponse.block_timestamp": + panic(fmt.Errorf("field block_timestamp of message cosmos.evm.vm.v1.MsgEthereumTxResponse is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.evm.vm.v1.MsgEthereumTxResponse")) @@ -1222,6 +1260,10 @@ func (x *fastReflection_MsgEthereumTxResponse) NewField(fd protoreflect.FieldDes return protoreflect.ValueOfUint64(uint64(0)) case "cosmos.evm.vm.v1.MsgEthereumTxResponse.max_used_gas": return protoreflect.ValueOfUint64(uint64(0)) + case "cosmos.evm.vm.v1.MsgEthereumTxResponse.block_hash": + return protoreflect.ValueOfBytes(nil) + case "cosmos.evm.vm.v1.MsgEthereumTxResponse.block_timestamp": + return protoreflect.ValueOfUint64(uint64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.evm.vm.v1.MsgEthereumTxResponse")) @@ -1315,6 +1357,13 @@ func (x *fastReflection_MsgEthereumTxResponse) ProtoMethods() *protoiface.Method if x.MaxUsedGas != 0 { n += 1 + runtime.Sov(uint64(x.MaxUsedGas)) } + l = len(x.BlockHash) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.BlockTimestamp != 0 { + n += 1 + runtime.Sov(uint64(x.BlockTimestamp)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -1344,6 +1393,18 @@ func (x *fastReflection_MsgEthereumTxResponse) ProtoMethods() *protoiface.Method i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if x.BlockTimestamp != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.BlockTimestamp)) + i-- + dAtA[i] = 0x40 + } + if len(x.BlockHash) > 0 { + i -= len(x.BlockHash) + copy(dAtA[i:], x.BlockHash) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.BlockHash))) + i-- + dAtA[i] = 0x3a + } if x.MaxUsedGas != 0 { i = runtime.EncodeVarint(dAtA, i, uint64(x.MaxUsedGas)) i-- @@ -1610,6 +1671,59 @@ func (x *fastReflection_MsgEthereumTxResponse) ProtoMethods() *protoiface.Method break } } + case 7: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BlockHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.BlockHash = append(x.BlockHash[:0], dAtA[iNdEx:postIndex]...) + if x.BlockHash == nil { + x.BlockHash = []byte{} + } + iNdEx = postIndex + case 8: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BlockTimestamp", wireType) + } + x.BlockTimestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.BlockTimestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -3524,6 +3638,10 @@ type MsgEthereumTxResponse struct { GasUsed uint64 `protobuf:"varint,5,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` // max_used_gas specifies the gas consumed by the transaction, not including refunds MaxUsedGas uint64 `protobuf:"varint,6,opt,name=max_used_gas,json=maxUsedGas,proto3" json:"max_used_gas,omitempty"` + // include the block hash for json-rpc to use + BlockHash []byte `protobuf:"bytes,7,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` + // include the block timestamp for json-rpc to use + BlockTimestamp uint64 `protobuf:"varint,8,opt,name=block_timestamp,json=blockTimestamp,proto3" json:"block_timestamp,omitempty"` } func (x *MsgEthereumTxResponse) Reset() { @@ -3588,6 +3706,20 @@ func (x *MsgEthereumTxResponse) GetMaxUsedGas() uint64 { return 0 } +func (x *MsgEthereumTxResponse) GetBlockHash() []byte { + if x != nil { + return x.BlockHash + } + return nil +} + +func (x *MsgEthereumTxResponse) GetBlockTimestamp() uint64 { + if x != nil { + return x.BlockTimestamp + } + return 0 +} + // MsgUpdateParams defines a Msg for updating the x/vm module parameters. type MsgUpdateParams struct { state protoimpl.MessageState @@ -3763,7 +3895,7 @@ var file_cosmos_evm_vm_v1_tx_proto_rawDesc = []byte{ 0x04, 0x08, 0x03, 0x10, 0x04, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x22, 0x22, 0x0a, 0x1a, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x54, 0x78, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, - 0xc6, 0x01, 0x0a, 0x15, 0x4d, 0x73, 0x67, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x54, + 0x8e, 0x02, 0x0a, 0x15, 0x4d, 0x73, 0x67, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x54, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x29, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x63, 0x6f, @@ -3775,69 +3907,74 @@ var file_cosmos_evm_vm_v1_tx_proto_rawDesc = []byte{ 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x12, 0x20, 0x0a, 0x0c, 0x6d, 0x61, 0x78, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x5f, 0x67, 0x61, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x6d, 0x61, 0x78, 0x55, 0x73, 0x65, 0x64, 0x47, - 0x61, 0x73, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0xba, 0x01, 0x0a, 0x0f, 0x4d, 0x73, 0x67, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x36, 0x0a, 0x09, - 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, - 0x72, 0x69, 0x74, 0x79, 0x12, 0x3b, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, - 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x09, - 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x3a, 0x32, 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, - 0x79, 0x8a, 0xe7, 0xb0, 0x2a, 0x1f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x6d, - 0x2f, 0x78, 0x2f, 0x76, 0x6d, 0x2f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0xd6, 0x01, 0x0a, 0x16, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, - 0x50, 0x72, 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x73, 0x12, 0x36, 0x0a, 0x09, 0x61, - 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, - 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, - 0x69, 0x74, 0x79, 0x12, 0x49, 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, - 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x65, 0x69, - 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, - 0x01, 0x52, 0x0b, 0x70, 0x72, 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x73, 0x3a, 0x39, - 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x8a, 0xe7, - 0xb0, 0x2a, 0x26, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x6d, 0x2f, 0x78, 0x2f, - 0x76, 0x6d, 0x2f, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x50, 0x72, - 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x73, 0x22, 0x20, 0x0a, 0x1e, 0x4d, 0x73, 0x67, + 0x61, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, + 0x68, 0x12, 0x27, 0x0a, 0x0f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0e, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, + 0x22, 0xba, 0x01, 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x12, 0x36, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x3b, 0x0a, 0x06, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, + 0x01, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x3a, 0x32, 0x82, 0xe7, 0xb0, 0x2a, 0x09, + 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x8a, 0xe7, 0xb0, 0x2a, 0x1f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x6d, 0x2f, 0x78, 0x2f, 0x76, 0x6d, 0x2f, 0x4d, 0x73, + 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x19, 0x0a, + 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xd6, 0x01, 0x0a, 0x16, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x50, 0x72, 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, - 0x6c, 0x6c, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xdc, 0x02, 0x0a, 0x03, - 0x4d, 0x73, 0x67, 0x12, 0x7d, 0x0a, 0x0a, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x54, - 0x78, 0x12, 0x1f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, - 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, - 0x54, 0x78, 0x1a, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, - 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, - 0x6d, 0x54, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x25, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x1f, 0x22, 0x1d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x6d, - 0x2f, 0x76, 0x6d, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5f, - 0x74, 0x78, 0x12, 0x5c, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x12, 0x21, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, - 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x29, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, - 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x71, 0x0a, 0x13, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x50, 0x72, 0x65, 0x69, - 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x73, 0x12, 0x28, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, + 0x6c, 0x6c, 0x73, 0x12, 0x36, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, + 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x49, 0x0a, 0x0b, 0x70, + 0x72, 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, + 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x42, 0x09, + 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0b, 0x70, 0x72, 0x65, 0x69, 0x6e, + 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x73, 0x3a, 0x39, 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, + 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x8a, 0xe7, 0xb0, 0x2a, 0x26, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2f, 0x65, 0x76, 0x6d, 0x2f, 0x78, 0x2f, 0x76, 0x6d, 0x2f, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x50, 0x72, 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, - 0x73, 0x1a, 0x30, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, - 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x73, 0x22, 0x20, 0x0a, 0x1e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x50, 0x72, 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xaa, 0x01, 0x0a, 0x14, 0x63, - 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, - 0x2e, 0x76, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x26, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x6d, 0x2f, 0x76, 0x6d, 0x2f, 0x76, - 0x31, 0x3b, 0x76, 0x6d, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x45, 0x56, 0xaa, 0x02, 0x10, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x45, 0x76, 0x6d, 0x2e, 0x56, 0x6d, 0x2e, 0x56, 0x31, 0xca, - 0x02, 0x10, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x45, 0x76, 0x6d, 0x5c, 0x56, 0x6d, 0x5c, - 0x56, 0x31, 0xe2, 0x02, 0x1c, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x45, 0x76, 0x6d, 0x5c, - 0x56, 0x6d, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0xea, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x45, 0x76, 0x6d, 0x3a, - 0x3a, 0x56, 0x6d, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x73, 0x65, 0x32, 0xdc, 0x02, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x7d, 0x0a, 0x0a, 0x45, + 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x54, 0x78, 0x12, 0x1f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, + 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x54, 0x78, 0x1a, 0x27, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, + 0x67, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x54, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x25, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1f, 0x22, 0x1d, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x6d, 0x2f, 0x76, 0x6d, 0x2f, 0x76, 0x31, 0x2f, 0x65, + 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5f, 0x74, 0x78, 0x12, 0x5c, 0x0a, 0x0c, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x21, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, + 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x29, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, + 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x71, 0x0a, 0x13, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x65, 0x72, 0x50, 0x72, 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x73, 0x12, + 0x28, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, + 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x50, 0x72, + 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x73, 0x1a, 0x30, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x50, 0x72, 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6c, 0x6c, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, + 0x2a, 0x01, 0x42, 0xaa, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x26, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, + 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, + 0x65, 0x76, 0x6d, 0x2f, 0x76, 0x6d, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x6d, 0x76, 0x31, 0xa2, 0x02, + 0x03, 0x43, 0x45, 0x56, 0xaa, 0x02, 0x10, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x45, 0x76, + 0x6d, 0x2e, 0x56, 0x6d, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x10, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x5c, 0x45, 0x76, 0x6d, 0x5c, 0x56, 0x6d, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1c, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x5c, 0x45, 0x76, 0x6d, 0x5c, 0x56, 0x6d, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x3a, 0x3a, 0x45, 0x76, 0x6d, 0x3a, 0x3a, 0x56, 0x6d, 0x3a, 0x3a, 0x56, 0x31, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/cosmos/evm/vm/v1/tx.proto b/proto/cosmos/evm/vm/v1/tx.proto index 3d953e9e0..7ac870f9a 100644 --- a/proto/cosmos/evm/vm/v1/tx.proto +++ b/proto/cosmos/evm/vm/v1/tx.proto @@ -73,6 +73,10 @@ message MsgEthereumTxResponse { uint64 gas_used = 5; // max_used_gas specifies the gas consumed by the transaction, not including refunds uint64 max_used_gas = 6; + // include the block hash for json-rpc to use + bytes block_hash = 7; + // include the block timestamp for json-rpc to use + uint64 block_timestamp = 8; } // MsgUpdateParams defines a Msg for updating the x/vm module parameters. diff --git a/tests/integration/x/vm/test_statedb.go b/tests/integration/x/vm/test_statedb.go index b78480b90..5ac2ac861 100644 --- a/tests/integration/x/vm/test_statedb.go +++ b/tests/integration/x/vm/test_statedb.go @@ -729,7 +729,6 @@ func (s *KeeperTestSuite) TestAddLog() { }, ðtypes.Log{ Address: addr, - TxHash: txHash, Topics: make([]common.Hash, 0), }, func(vm.StateDB) {}, @@ -743,7 +742,6 @@ func (s *KeeperTestSuite) TestAddLog() { }, ðtypes.Log{ Address: addr, - TxHash: txHash3, Topics: make([]common.Hash, 0), }, func(vm.StateDB) {}, diff --git a/x/vm/keeper/state_transition.go b/x/vm/keeper/state_transition.go index 2188b13f4..fafa49463 100644 --- a/x/vm/keeper/state_transition.go +++ b/x/vm/keeper/state_transition.go @@ -506,15 +506,15 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, msg core.Message, trace if vmError == vm.ErrExecutionReverted.Error() { ret = evm.Interpreter().ReturnData() } - - logs := stateDB.GetLogs(uint64(ctx.BlockHeight()), common.BytesToHash(ctx.HeaderHash()), evm.Context.Time) //#nosec G115 -- int overflow is not a concern here return &types.MsgEthereumTxResponse{ - GasUsed: gasUsed.TruncateInt().Uint64(), - MaxUsedGas: maxUsedGas, - VmError: vmError, - Ret: ret, - Logs: types.NewLogsFromEth(logs), - Hash: txConfig.TxHash.Hex(), + GasUsed: gasUsed.TruncateInt().Uint64(), + MaxUsedGas: maxUsedGas, + VmError: vmError, + Ret: ret, + Logs: types.NewLogsFromEth(stateDB.Logs()), + Hash: txConfig.TxHash.Hex(), + BlockHash: ctx.HeaderHash(), + BlockTimestamp: evm.Context.Time, }, nil } diff --git a/x/vm/statedb/statedb.go b/x/vm/statedb/statedb.go index b86963230..1c4a7395d 100644 --- a/x/vm/statedb/statedb.go +++ b/x/vm/statedb/statedb.go @@ -218,23 +218,11 @@ func (s *StateDB) cache() error { func (s *StateDB) AddLog(log *ethtypes.Log) { s.journal.append(addLogChange{}) - log.TxHash = s.txConfig.TxHash log.TxIndex = s.txConfig.TxIndex log.Index = s.txConfig.LogIndex + uint(len(s.logs)) s.logs = append(s.logs, log) } -// GetLogs returns the logs matching the specified transaction hash, and annotates -// them with the given blockNumber and blockHash. -func (s *StateDB) GetLogs(blockNumber uint64, blockHash common.Hash, blockTime uint64) []*ethtypes.Log { - for _, l := range s.logs { - l.BlockNumber = blockNumber - l.BlockHash = blockHash - l.BlockTimestamp = blockTime - } - return s.logs -} - // Logs returns the logs of current transaction. func (s *StateDB) Logs() []*ethtypes.Log { return s.logs diff --git a/x/vm/statedb/statedb_test.go b/x/vm/statedb/statedb_test.go index 45497c270..cb75eb25a 100644 --- a/x/vm/statedb/statedb_test.go +++ b/x/vm/statedb/statedb_test.go @@ -24,7 +24,6 @@ var ( address common.Address = common.BigToAddress(big.NewInt(101)) address2 common.Address = common.BigToAddress(big.NewInt(102)) address3 common.Address = common.BigToAddress(big.NewInt(103)) - blockHash common.Hash = common.BigToHash(big.NewInt(9999)) emptyTxConfig statedb.TxConfig = statedb.NewEmptyTxConfig() ) @@ -600,17 +599,14 @@ func (suite *StateDBTestSuite) TestLog() { }) suite.Require().Equal(1, len(db.Logs())) expecedLog := ðtypes.Log{ - Address: address, - Topics: []common.Hash{}, - Data: data, - BlockNumber: 1, - BlockHash: blockHash, - BlockTimestamp: 1, - TxHash: txHash, - TxIndex: 1, - Index: 1, + Address: address, + Topics: []common.Hash{}, + Data: data, + BlockNumber: 1, + TxIndex: 1, + Index: 1, } - suite.Require().Equal(expecedLog, db.GetLogs(1, blockHash, 1)[0]) + suite.Require().Equal(expecedLog, db.Logs()[0]) db.AddLog(ðtypes.Log{ Address: address, @@ -620,7 +616,7 @@ func (suite *StateDBTestSuite) TestLog() { }) suite.Require().Equal(2, len(db.Logs())) expecedLog.Index++ - suite.Require().Equal(expecedLog, db.GetLogs(1, blockHash, 1)[1]) + suite.Require().Equal(expecedLog, db.Logs()[1]) } func (suite *StateDBTestSuite) TestRefund() { diff --git a/x/vm/types/tx.pb.go b/x/vm/types/tx.pb.go index dc6c10831..096775978 100644 --- a/x/vm/types/tx.pb.go +++ b/x/vm/types/tx.pb.go @@ -130,6 +130,10 @@ type MsgEthereumTxResponse struct { GasUsed uint64 `protobuf:"varint,5,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` // max_used_gas specifies the gas consumed by the transaction, not including refunds MaxUsedGas uint64 `protobuf:"varint,6,opt,name=max_used_gas,json=maxUsedGas,proto3" json:"max_used_gas,omitempty"` + // include the block hash for json-rpc to use + BlockHash []byte `protobuf:"bytes,7,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` + // include the block timestamp for json-rpc to use + BlockTimestamp uint64 `protobuf:"varint,8,opt,name=block_timestamp,json=blockTimestamp,proto3" json:"block_timestamp,omitempty"` } func (m *MsgEthereumTxResponse) Reset() { *m = MsgEthereumTxResponse{} } @@ -365,51 +369,53 @@ func init() { func init() { proto.RegisterFile("cosmos/evm/vm/v1/tx.proto", fileDescriptor_77a8ac5e8c9c4850) } var fileDescriptor_77a8ac5e8c9c4850 = []byte{ - // 699 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x4f, 0x6b, 0x13, 0x4f, - 0x18, 0xce, 0x26, 0xdb, 0x36, 0x9d, 0xf6, 0xc7, 0x2f, 0x8e, 0xad, 0xdd, 0x2e, 0x35, 0x49, 0x17, - 0xff, 0xa4, 0x05, 0xb3, 0x36, 0x82, 0x60, 0x3c, 0x19, 0x28, 0x62, 0x30, 0x58, 0x56, 0x7b, 0x11, - 0x21, 0x4c, 0x9b, 0x71, 0xb2, 0x90, 0xd9, 0x59, 0x67, 0x26, 0x31, 0x3d, 0x08, 0x52, 0x3c, 0x88, - 0x27, 0xc1, 0x2f, 0xe0, 0xd1, 0x63, 0x0f, 0x9e, 0xfc, 0x00, 0x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 0x74, 0x5d, 0xcf, 0xa6, 0x73, 0x99, 0xba, 0x9e, 0xcd, 0xe4, 0xf4, 0xba, 0x9e, 0xd5, - 0x73, 0x63, 0x96, 0x05, 0xcc, 0xd5, 0xbe, 0xc4, 0x9e, 0x70, 0x99, 0xf7, 0xc0, 0x0f, 0x06, 0x1c, - 0x54, 0x55, 0x75, 0x25, 0x6c, 0x7d, 0xd6, 0xc0, 0xec, 0x90, 0x9a, 0x83, 0x85, 0xcf, 0x3c, 0x81, - 0xd5, 0xc8, 0x6d, 0x24, 0xda, 0x86, 0x56, 0xd4, 0x4a, 0x93, 0x4e, 0xb0, 0x86, 0x4b, 0x40, 0xef, - 0x30, 0x22, 0x8c, 0x74, 0x31, 0x53, 0x9a, 0xaa, 0xcc, 0x96, 0x4f, 0x07, 0x52, 0xbe, 0xcf, 0x88, - 0x13, 0x50, 0x60, 0x0e, 0x64, 0x38, 0x96, 0x46, 0x26, 0x30, 0xac, 0x96, 0x70, 0x1e, 0x64, 0x7b, - 0xb4, 0x89, 0x39, 0x67, 0xdc, 0xd0, 0x03, 0xd1, 0x89, 0x1e, 0x5d, 0x55, 0x8f, 0x0a, 0x22, 0x48, - 0x34, 0xbb, 0x02, 0xb7, 0x82, 0x23, 0xd2, 0x9d, 0x09, 0x82, 0xc4, 0xba, 0xc0, 0x2d, 0x58, 0x04, - 0xd3, 0x14, 0xf5, 0x03, 0xa8, 0x49, 0x90, 0x08, 0x8e, 0x4b, 0x77, 0x00, 0x45, 0x7d, 0x05, 0xdf, - 0x45, 0x22, 0x32, 0xf2, 0x49, 0x03, 0xff, 0x37, 0x04, 0x59, 0xf7, 0x5b, 0x48, 0xe2, 0x35, 0xc4, - 0x11, 0x15, 0xf0, 0x26, 0x98, 0x44, 0x5d, 0xd9, 0x66, 0xdc, 0x95, 0x5b, 0xa1, 0x8f, 0x9a, 0xf1, - 0xe5, 0xe3, 0xb5, 0x99, 0x68, 0xec, 0x3b, 0xad, 0x16, 0xc7, 0x42, 0x3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x48, 0x60, 0x9a, 0xd7, 0xff, 0x96, 0x79, 0xdc, 0xd2, 0x1c, 0x7b, 0xa9, 0x82, 0xac, 0x55, - 0x77, 0x0f, 0xf2, 0xda, 0xde, 0x41, 0x5e, 0xfb, 0x75, 0x90, 0xd7, 0xde, 0x1e, 0xe6, 0x53, 0x7b, - 0x87, 0xf9, 0xd4, 0xf7, 0xc3, 0x7c, 0xea, 0x71, 0x91, 0xb8, 0xb2, 0xdd, 0xdd, 0x28, 0x6f, 0x32, - 0x6a, 0x9f, 0x4e, 0x53, 0x6e, 0xf9, 0x58, 0x6c, 0x8c, 0x07, 0x3f, 0xba, 0x1b, 0x7f, 0x02, 0x00, - 0x00, 0xff, 0xff, 0xf9, 0x21, 0xde, 0xc0, 0xae, 0x05, 0x00, 0x00, + // 736 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x4d, 0x6b, 0x13, 0x41, + 0x18, 0xce, 0x26, 0xdb, 0x36, 0x99, 0x56, 0x1b, 0xd7, 0xd6, 0x6e, 0x97, 0x36, 0x49, 0x17, 0xb5, + 0x69, 0xc1, 0xac, 0x8d, 0x20, 0x18, 0x4f, 0x06, 0x8a, 0x1a, 0x0c, 0x96, 0xb5, 0xbd, 0x88, 0x10, + 0xa6, 0xcd, 0x38, 0x59, 0xcc, 0xec, 0xac, 0x3b, 0x93, 0x98, 0x1e, 0x04, 0x29, 0x1e, 0xc4, 0x83, + 0x08, 0xfe, 0x01, 0x8f, 0x1e, 0x7b, 0xf0, 0xe4, 0x2f, 0xe8, 0xb1, 0x28, 0x88, 0x88, 0x14, 0x69, + 0x85, 0xfe, 0x0d, 0x99, 0xd9, 0x4d, 0x93, 0x34, 0x0b, 0x15, 0x61, 0x59, 0x66, 0xdf, 0xe7, 0x79, + 0x9f, 0xf7, 0x73, 0x16, 0xcc, 0x6e, 0x51, 0x46, 0x28, 0xb3, 0x50, 0x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0x1c, + 0x5c, 0x8c, 0x9a, 0x6d, 0x3e, 0x52, 0x21, 0x82, 0x69, 0x5c, 0xff, 0x57, 0x66, 0x37, 0xa4, 0x31, + 0xf2, 0x4a, 0x0c, 0xb2, 0x5c, 0xda, 0x3b, 0xcc, 0x28, 0xfb, 0x87, 0x19, 0xe5, 0xf7, 0x61, 0x46, + 0x79, 0x7f, 0x94, 0x89, 0xed, 0x1f, 0x65, 0x62, 0x3f, 0x8e, 0x32, 0xb1, 0xc7, 0x39, 0xec, 0xf0, + 0x46, 0x6b, 0xb3, 0xb0, 0x45, 0x89, 0x75, 0x7a, 0x9a, 0x7c, 0xdb, 0x43, 0x6c, 0x73, 0x54, 0xfe, + 0x30, 0x6f, 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x5b, 0xb8, 0x53, 0x9d, 0xf6, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -661,6 +667,18 @@ func (m *MsgEthereumTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.BlockTimestamp != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.BlockTimestamp)) + i-- + dAtA[i] = 0x40 + } + if len(m.BlockHash) > 0 { + i -= len(m.BlockHash) + copy(dAtA[i:], m.BlockHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.BlockHash))) + i-- + dAtA[i] = 0x3a + } if m.MaxUsedGas != 0 { i = encodeVarintTx(dAtA, i, uint64(m.MaxUsedGas)) i-- @@ -904,6 +922,13 @@ func (m *MsgEthereumTxResponse) Size() (n int) { if m.MaxUsedGas != 0 { n += 1 + sovTx(uint64(m.MaxUsedGas)) } + l = len(m.BlockHash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.BlockTimestamp != 0 { + n += 1 + sovTx(uint64(m.BlockTimestamp)) + } return n } @@ -1331,6 +1356,59 @@ func (m *MsgEthereumTxResponse) Unmarshal(dAtA []byte) error { break } } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BlockHash = append(m.BlockHash[:0], dAtA[iNdEx:postIndex]...) + if m.BlockHash == nil { + m.BlockHash = []byte{} + } + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockTimestamp", wireType) + } + m.BlockTimestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockTimestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/vm/types/utils.go b/x/vm/types/utils.go index 9d58f233b..07cbefb26 100644 --- a/x/vm/types/utils.go +++ b/x/vm/types/utils.go @@ -82,6 +82,12 @@ func logsFromTxResponse(dst []*ethtypes.Log, rsp *MsgEthereumTxResponse, blockNu l := log.ToEthereum() l.TxHash = txHash l.BlockNumber = blockNumber + if len(rsp.BlockHash) > 0 { + l.BlockHash = common.BytesToHash(rsp.BlockHash) + } + if rsp.BlockTimestamp > 0 { + l.BlockTimestamp = rsp.BlockTimestamp + } dst = append(dst, l) } return dst