diff --git a/app/grpc/tx/server.go b/app/grpc/tx/server.go index 9526ec99e3..c6e8229a0b 100644 --- a/app/grpc/tx/server.go +++ b/app/grpc/tx/server.go @@ -84,5 +84,9 @@ func (s *txServer) TxStatus(ctx context.Context, req *TxStatusRequest) (*TxStatu ExecutionCode: resTx.ExecutionCode, Error: resTx.Error, Status: resTx.Status, + GasWanted: resTx.GasWanted, + GasUsed: resTx.GasUsed, + Codespace: resTx.Codespace, + Signers: resTx.Signers, }, nil } diff --git a/app/grpc/tx/tx.pb.go b/app/grpc/tx/tx.pb.go index f0252713bf..542cef60b3 100644 --- a/app/grpc/tx/tx.pb.go +++ b/app/grpc/tx/tx.pb.go @@ -86,6 +86,13 @@ type TxStatusResponse struct { Error string `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"` // status is the status of the transaction. Status string `protobuf:"bytes,5,opt,name=status,proto3" json:"status,omitempty"` + // the error namespace/module + Codespace string `protobuf:"bytes,6,opt,name=codespace,proto3" json:"codespace,omitempty"` + // requested gas limit + GasWanted int64 `protobuf:"varint,7,opt,name=gas_wanted,json=gasWanted,proto3" json:"gas_wanted,omitempty"` + // actual gas consumed + GasUsed int64 `protobuf:"varint,8,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` + Signers []string `protobuf:"bytes,9,rep,name=signers,proto3" json:"signers,omitempty"` } func (m *TxStatusResponse) Reset() { *m = TxStatusResponse{} } @@ -156,6 +163,34 @@ func (m *TxStatusResponse) GetStatus() string { return "" } +func (m *TxStatusResponse) GetCodespace() string { + if m != nil { + return m.Codespace + } + return "" +} + +func (m *TxStatusResponse) GetGasWanted() int64 { + if m != nil { + return m.GasWanted + } + return 0 +} + +func (m *TxStatusResponse) GetGasUsed() int64 { + if m != nil { + return m.GasUsed + } + return 0 +} + +func (m *TxStatusResponse) GetSigners() []string { + if m != nil { + return m.Signers + } + return nil +} + func init() { proto.RegisterType((*TxStatusRequest)(nil), "celestia.core.v1.tx.TxStatusRequest") proto.RegisterType((*TxStatusResponse)(nil), "celestia.core.v1.tx.TxStatusResponse") @@ -164,29 +199,33 @@ func init() { func init() { proto.RegisterFile("celestia/core/v1/tx/tx.proto", fileDescriptor_7d8b070565b0dcb6) } var fileDescriptor_7d8b070565b0dcb6 = []byte{ - // 337 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x51, 0xcd, 0x4a, 0x33, 0x31, - 0x14, 0x6d, 0xfa, 0xc7, 0xf7, 0x05, 0xfa, 0x7d, 0x92, 0x8a, 0x0c, 0xa5, 0x0c, 0xa5, 0xb4, 0xd2, - 0x8d, 0x13, 0xaa, 0x6f, 0xa0, 0xab, 0x6e, 0xc7, 0xae, 0xdc, 0x94, 0xe9, 0xcc, 0x65, 0x1a, 0xa8, - 0x93, 0x31, 0xb9, 0x53, 0x02, 0xd2, 0x8d, 0xbe, 0x80, 0x20, 0xbe, 0x93, 0xcb, 0x82, 0x1b, 0x97, - 0xd2, 0xfa, 0x20, 0x32, 0x99, 0xb6, 0x82, 0x14, 0x5c, 0x04, 0x72, 0xee, 0x39, 0x37, 0x27, 0xf7, - 0x5c, 0xda, 0x0e, 0x61, 0x0e, 0x1a, 0x45, 0xc0, 0x43, 0xa9, 0x80, 0x2f, 0x86, 0x1c, 0x0d, 0x47, - 0xe3, 0xa5, 0x4a, 0xa2, 0x64, 0xcd, 0x1d, 0xeb, 0xe5, 0xac, 0xb7, 0x18, 0x7a, 0x68, 0x5a, 0xed, - 0x58, 0xca, 0x78, 0x0e, 0x3c, 0x48, 0x05, 0x0f, 0x92, 0x44, 0x62, 0x80, 0x42, 0x26, 0xba, 0x68, - 0xe9, 0x9e, 0xd2, 0xff, 0x63, 0x73, 0x8d, 0x01, 0x66, 0xda, 0x87, 0xbb, 0x0c, 0x34, 0xb2, 0x26, - 0xad, 0xa1, 0x99, 0x88, 0xc8, 0x21, 0x1d, 0x32, 0xf8, 0xeb, 0x57, 0xd1, 0x8c, 0xa2, 0xee, 0x0b, - 0xa1, 0x47, 0xdf, 0x42, 0x9d, 0xca, 0x44, 0x03, 0x3b, 0xa1, 0xf5, 0x19, 0x88, 0x78, 0x86, 0x56, - 0x5a, 0xf1, 0xb7, 0x88, 0x1d, 0xd3, 0x9a, 0x48, 0x22, 0x30, 0x4e, 0xb9, 0x43, 0x06, 0x0d, 0xbf, - 0x00, 0xac, 0x4f, 0xff, 0x81, 0x81, 0x30, 0xcb, 0xed, 0x27, 0xa1, 0x8c, 0xc0, 0xa9, 0x58, 0xba, - 0xb1, 0xaf, 0x5e, 0xc9, 0x08, 0xf2, 0x66, 0x50, 0x4a, 0x2a, 0xa7, 0x6a, 0xed, 0x0b, 0x90, 0x5b, - 0x69, 0x6b, 0xee, 0xd4, 0x6c, 0x79, 0x8b, 0xce, 0x1f, 0x09, 0x2d, 0x8f, 0x0d, 0x5b, 0xd2, 0x3f, - 0xbb, 0xdf, 0xb1, 0x9e, 0x77, 0x20, 0x06, 0xef, 0xc7, 0x94, 0xad, 0xfe, 0x2f, 0xaa, 0x62, 0xc4, - 0x6e, 0xef, 0xe1, 0xed, 0xf3, 0xb9, 0xec, 0xb2, 0x36, 0x3f, 0x94, 0xfc, 0xbd, 0x0d, 0x6a, 0x79, - 0x39, 0x7a, 0x5d, 0xbb, 0x64, 0xb5, 0x76, 0xc9, 0xc7, 0xda, 0x25, 0x4f, 0x1b, 0xb7, 0xb4, 0xda, - 0xb8, 0xa5, 0xf7, 0x8d, 0x5b, 0xba, 0xe1, 0xb1, 0xc0, 0x59, 0x36, 0xf5, 0x42, 0x79, 0xbb, 0x7f, - 0x41, 0xaa, 0x78, 0x7f, 0x3f, 0x0b, 0xd2, 0x94, 0xe7, 0x27, 0x56, 0x69, 0xc8, 0xd1, 0x4c, 0xeb, - 0x76, 0x2f, 0x17, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x5a, 0x2f, 0x1b, 0xd1, 0xea, 0x01, 0x00, - 0x00, + // 404 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0x4d, 0x8b, 0x14, 0x31, + 0x10, 0x9d, 0xee, 0xd9, 0xf9, 0xe8, 0xc0, 0xaa, 0x64, 0x45, 0xe2, 0xd2, 0x36, 0xc3, 0xb0, 0x2b, + 0x73, 0xb1, 0xc3, 0xea, 0x3f, 0xd0, 0xd3, 0x5e, 0xdb, 0x15, 0xc1, 0xcb, 0x90, 0xed, 0x14, 0x99, + 0xc0, 0xda, 0x69, 0x93, 0xea, 0x35, 0x20, 0x7b, 0xd1, 0x83, 0x57, 0xc1, 0x3f, 0xe5, 0x71, 0xc0, + 0x8b, 0x47, 0x99, 0xf1, 0x87, 0x48, 0xa7, 0xe7, 0x03, 0x64, 0xc0, 0x43, 0x20, 0xef, 0xbd, 0xaa, + 0x7a, 0xe1, 0x55, 0x48, 0x5a, 0xc2, 0x0d, 0x38, 0xd4, 0x82, 0x97, 0xc6, 0x02, 0xbf, 0xbd, 0xe0, + 0xe8, 0x39, 0xfa, 0xbc, 0xb6, 0x06, 0x0d, 0x3d, 0xd9, 0xaa, 0x79, 0xab, 0xe6, 0xb7, 0x17, 0x39, + 0xfa, 0xd3, 0x54, 0x19, 0xa3, 0x6e, 0x80, 0x8b, 0x5a, 0x73, 0x51, 0x55, 0x06, 0x05, 0x6a, 0x53, + 0xb9, 0xae, 0x65, 0xfa, 0x94, 0xdc, 0xbf, 0xf2, 0xaf, 0x51, 0x60, 0xe3, 0x0a, 0xf8, 0xd0, 0x80, + 0x43, 0x7a, 0x42, 0x06, 0xe8, 0xe7, 0x5a, 0xb2, 0x68, 0x12, 0xcd, 0x92, 0xe2, 0x08, 0xfd, 0xa5, + 0x9c, 0x7e, 0x8d, 0xc9, 0x83, 0x7d, 0xa1, 0xab, 0x4d, 0xe5, 0x80, 0x3e, 0x22, 0xc3, 0x05, 0x68, + 0xb5, 0xc0, 0x50, 0xda, 0x2f, 0x36, 0x88, 0x3e, 0x24, 0x03, 0x5d, 0x49, 0xf0, 0x2c, 0x9e, 0x44, + 0xb3, 0xe3, 0xa2, 0x03, 0xf4, 0x9c, 0xdc, 0x03, 0x0f, 0x65, 0xd3, 0xda, 0xcf, 0x4b, 0x23, 0x81, + 0xf5, 0x83, 0x7c, 0xbc, 0x63, 0x5f, 0x19, 0x09, 0x6d, 0x33, 0x58, 0x6b, 0x2c, 0x3b, 0x0a, 0xf6, + 0x1d, 0x68, 0xad, 0x5c, 0x30, 0x67, 0x83, 0x40, 0x6f, 0x10, 0x4d, 0x49, 0xd2, 0x8e, 0x72, 0xb5, + 0x28, 0x81, 0x0d, 0x83, 0xb4, 0x27, 0xe8, 0x13, 0x42, 0x94, 0x70, 0xf3, 0x8f, 0xa2, 0x42, 0x90, + 0x6c, 0x14, 0x1e, 0x99, 0x28, 0xe1, 0xde, 0x06, 0x82, 0x3e, 0x26, 0xe3, 0x56, 0x6e, 0x1c, 0x48, + 0x36, 0x0e, 0xe2, 0x48, 0x09, 0xf7, 0xc6, 0x81, 0xa4, 0x8c, 0x8c, 0x9c, 0x56, 0x15, 0x58, 0xc7, + 0x92, 0x49, 0x7f, 0x96, 0x14, 0x5b, 0xf8, 0xfc, 0x4b, 0x44, 0xe2, 0x2b, 0x4f, 0xef, 0xc8, 0x78, + 0x9b, 0x07, 0x3d, 0xcb, 0x0f, 0x04, 0x9f, 0xff, 0x93, 0xeb, 0xe9, 0xf9, 0x7f, 0xaa, 0xba, 0x50, + 0xa7, 0x67, 0x9f, 0x7f, 0xfe, 0xf9, 0x1e, 0x67, 0x34, 0xe5, 0x87, 0x76, 0xfd, 0x29, 0xac, 0xe6, + 0xee, 0xe5, 0xe5, 0x8f, 0x55, 0x16, 0x2d, 0x57, 0x59, 0xf4, 0x7b, 0x95, 0x45, 0xdf, 0xd6, 0x59, + 0x6f, 0xb9, 0xce, 0x7a, 0xbf, 0xd6, 0x59, 0xef, 0x1d, 0x57, 0x1a, 0x17, 0xcd, 0x75, 0x5e, 0x9a, + 0xf7, 0xbb, 0x09, 0xc6, 0xaa, 0xdd, 0xfd, 0x99, 0xa8, 0x6b, 0xde, 0x1e, 0x65, 0xeb, 0x92, 0xa3, + 0xbf, 0x1e, 0x86, 0x9f, 0xf0, 0xe2, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x71, 0xcb, 0xde, 0x23, + 0x5c, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -332,6 +371,32 @@ func (m *TxStatusResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Signers) > 0 { + for iNdEx := len(m.Signers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Signers[iNdEx]) + copy(dAtA[i:], m.Signers[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signers[iNdEx]))) + i-- + dAtA[i] = 0x4a + } + } + if m.GasUsed != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GasUsed)) + i-- + dAtA[i] = 0x40 + } + if m.GasWanted != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GasWanted)) + i-- + dAtA[i] = 0x38 + } + if len(m.Codespace) > 0 { + i -= len(m.Codespace) + copy(dAtA[i:], m.Codespace) + i = encodeVarintTx(dAtA, i, uint64(len(m.Codespace))) + i-- + dAtA[i] = 0x32 + } if len(m.Status) > 0 { i -= len(m.Status) copy(dAtA[i:], m.Status) @@ -411,6 +476,22 @@ func (m *TxStatusResponse) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.Codespace) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.GasWanted != 0 { + n += 1 + sovTx(uint64(m.GasWanted)) + } + if m.GasUsed != 0 { + n += 1 + sovTx(uint64(m.GasUsed)) + } + if len(m.Signers) > 0 { + for _, s := range m.Signers { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } return n } @@ -652,6 +733,108 @@ func (m *TxStatusResponse) Unmarshal(dAtA []byte) error { } m.Status = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Codespace", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Codespace = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasWanted", wireType) + } + m.GasWanted = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasWanted |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasUsed", wireType) + } + m.GasUsed = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasUsed |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signers", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signers = append(m.Signers, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/app/test/square_size_test.go b/app/test/square_size_test.go index 50d0e86489..ea20f975c4 100644 --- a/app/test/square_size_test.go +++ b/app/test/square_size_test.go @@ -179,9 +179,6 @@ func (s *SquareSizeIntegrationTest) SetupBlockSizeParams(t *testing.T, squareSiz res, err := txClient.SubmitTx(s.cctx.GoContext(), []sdk.Msg{msgSubmitProp}, opt) require.NoError(t, err) - - res, err = txClient.ConfirmTx(s.cctx.GoContext(), res.TxHash) - require.NoError(t, err) require.Equal(t, uint32(0), res.Code) txService := sdktx.NewServiceClient(s.cctx.GRPCClient) diff --git a/cmd/celestia-appd/cmd/override_p2p_config_test.go b/cmd/celestia-appd/cmd/override_p2p_config_test.go index c04395350d..32f8275bfd 100644 --- a/cmd/celestia-appd/cmd/override_p2p_config_test.go +++ b/cmd/celestia-appd/cmd/override_p2p_config_test.go @@ -183,7 +183,7 @@ func TestOverrideP2PConfig_Integration(t *testing.T) { configPath := filepath.Join(configDir, "config.toml") tmcfg.WriteConfigFile(configPath, cfg) - // Create a mock cobra command with server context + // Create a mock cobra command with server context cmd := &cobra.Command{ Use: "test", } diff --git a/go.mod b/go.mod index 9f23d570fa..9be3e49498 100644 --- a/go.mod +++ b/go.mod @@ -278,7 +278,7 @@ replace ( cosmossdk.io/api => github.com/celestiaorg/cosmos-sdk/api v0.7.6 cosmossdk.io/x/upgrade => github.com/celestiaorg/cosmos-sdk/x/upgrade v0.2.0 github.com/cometbft/cometbft => github.com/celestiaorg/celestia-core v0.39.12 - github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v0.51.4 + github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v0.51.6 github.com/cosmos/ibc-go/v8 => github.com/celestiaorg/ibc-go/v8 v8.7.2 // Use ledger-cosmos-go v0.16.0 because v0.15.0 causes "hidapi: unknown failure" // See https://github.com/celestiaorg/celestia-app/issues/5453 diff --git a/go.sum b/go.sum index ab1e7a9b94..7226030353 100644 --- a/go.sum +++ b/go.sum @@ -785,8 +785,8 @@ github.com/celestiaorg/celestia-core v0.39.12 h1:SvlGmZr6XmsSeruFDSyz2rQmCdAJT+6 github.com/celestiaorg/celestia-core v0.39.12/go.mod h1:GxCnrVUUJZ3dtpNlKfHw3otb5TqyOdwjXef1/pNqSzA= github.com/celestiaorg/celestia-core v1.55.0-tm-v0.34.35 h1:FREwqZwPvYsodr1AqqEIyW+VsBnwTzJNtC6NFdZX8rs= github.com/celestiaorg/celestia-core v1.55.0-tm-v0.34.35/go.mod h1:SI38xqZZ4ccoAxszUJqsJ/a5rOkzQRijzHQQlLKkyUc= -github.com/celestiaorg/cosmos-sdk v0.51.4 h1:4yQQ+3NqvfcrO3Im1dbzSPF7Ujvw8P0IIisRWVXjWLg= -github.com/celestiaorg/cosmos-sdk v0.51.4/go.mod h1:YRNOXtC4vo5FG1SSoj57yEUiidU8Pn3ofjqYlFdu8qg= +github.com/celestiaorg/cosmos-sdk v0.51.6 h1:sUDSbbg6SjPjWHW7mow4j6i+I8X8nHDmpojnPOeAwYI= +github.com/celestiaorg/cosmos-sdk v0.51.6/go.mod h1:z5sV0ONMM7Qww3FuLZ2xmqjFblbivkb/jmwQfnHAxrE= github.com/celestiaorg/cosmos-sdk/api v0.7.6 h1:81in9Zk+noz0ko+hZFSSK8L1aawFN8/CmdcQAUhbiUU= github.com/celestiaorg/cosmos-sdk/api v0.7.6/go.mod h1:1BgQSufu6ZQkst3YBIHDCo/TPUrhfU4fV7tOI0ftql8= github.com/celestiaorg/cosmos-sdk/x/upgrade v0.2.0 h1:GyDYfK8dLETlUI7F+w+3QYQgAszUegMXgB6cTbDm7CA= diff --git a/pkg/user/mock_tx_server_test.go b/pkg/user/mock_tx_server_test.go index f9d5269813..5729d66b49 100644 --- a/pkg/user/mock_tx_server_test.go +++ b/pkg/user/mock_tx_server_test.go @@ -7,6 +7,7 @@ import ( "github.com/celestiaorg/celestia-app/v6/app/grpc/tx" "github.com/celestiaorg/celestia-app/v6/pkg/user" + "github.com/celestiaorg/celestia-app/v6/pkg/user/utils" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/rpc/core" sdk "github.com/cosmos/cosmos-sdk/types" @@ -163,7 +164,7 @@ func setupTxClientWithMockServers(t *testing.T, broadcastHandlers []BroadcastHan } // Create TxClient with mock connection - encCfg, txClient, _ := setupTxClientWithDefaultParams(t) + encCfg, txClient, _ := utils.SetupTxClientWithDefaultParams(t) // Build options list clientOpts := opts diff --git a/pkg/user/tx_client.go b/pkg/user/tx_client.go index 0c6e22979e..577529eb30 100644 --- a/pkg/user/tx_client.go +++ b/pkg/user/tx_client.go @@ -71,9 +71,13 @@ type txInfo struct { // a transaction has been submitted. type TxResponse struct { // Height is the block height at which the transaction was included on-chain. - Height int64 - TxHash string - Code uint32 + Height int64 + TxHash string + Code uint32 + Codespace string + GasWanted int64 + GasUsed int64 + Signers []string } // BroadcastTxError is an error that occurs when broadcasting a transaction. @@ -93,13 +97,41 @@ type ExecutionError struct { TxHash string Code uint32 // ErrorLog is the error output of the app's logger - ErrorLog string + ErrorLog string + Codespace string + GasWanted int64 + GasUsed int64 } func (e *ExecutionError) Error() string { return fmt.Sprintf("tx execution failed with code %d: %s", e.Code, e.ErrorLog) } +// buildTxResponse populates the TxResponse from the TxStatus response +func (client *TxClient) buildTxResponse(txHash string, statusResp *tx.TxStatusResponse) *TxResponse { + return &TxResponse{ + Height: statusResp.Height, + TxHash: txHash, + Code: statusResp.ExecutionCode, + Codespace: statusResp.Codespace, + GasWanted: statusResp.GasWanted, + GasUsed: statusResp.GasUsed, + Signers: statusResp.Signers, + } +} + +// buildExecutionError populates the ExecutionError from the TxStatus response +func (client *TxClient) buildExecutionError(txHash string, statusResp *tx.TxStatusResponse) *ExecutionError { + return &ExecutionError{ + TxHash: txHash, + ErrorLog: statusResp.Error, + Codespace: statusResp.Codespace, + Code: statusResp.ExecutionCode, + GasWanted: statusResp.GasWanted, + GasUsed: statusResp.GasUsed, + } +} + // WithPollTime sets a custom polling interval with which to check if a transaction has been submitted func WithPollTime(time time.Duration) Option { return func(c *TxClient) { @@ -746,26 +778,17 @@ func (client *TxClient) ConfirmTx(ctx context.Context, txHash string) (*TxRespon span.AddEvent("txclient/ConfirmTx: transaction committed", trace.WithAttributes( attribute.Int("resp_code", int(resp.ExecutionCode)), )) - txResponse := &TxResponse{ - Height: resp.Height, - TxHash: txHash, - Code: resp.ExecutionCode, - } if resp.ExecutionCode != abci.CodeTypeOK { - executionErr := &ExecutionError{ - TxHash: txHash, - Code: resp.ExecutionCode, - ErrorLog: resp.Error, - } span.RecordError(fmt.Errorf("txclient/ConfirmTx: execution error: %s", resp.Error)) client.deleteFromTxTracker(txHash) - return nil, executionErr + return nil, client.buildExecutionError(txHash, resp) } + span.AddEvent("txclient/ConfirmTx: transaction confirmed successfully") client.deleteFromTxTracker(txHash) - return txResponse, nil + return client.buildTxResponse(txHash, resp), nil case core.TxStatusEvicted: - _, _, exists := client.GetTxFromTxTracker(txHash) + _, _, txBytes, exists := client.GetTxFromTxTracker(txHash) if !exists { return nil, fmt.Errorf("tx: %s not found in txTracker; likely failed during broadcast", txHash) } @@ -781,7 +804,7 @@ func (client *TxClient) ConfirmTx(ctx context.Context, txHash string) (*TxRespon )) // If we're not already tracking eviction timeout, try to resubmit - _, err := client.sendTxToConnection(ctx, client.conns[0], client.txTracker[txHash].txBytes) + _, err := client.sendTxToConnection(ctx, client.conns[0], txBytes) if err != nil { // Check if the error is a broadcast tx error _, ok := err.(*BroadcastTxError) @@ -796,7 +819,7 @@ func (client *TxClient) ConfirmTx(ctx context.Context, txHash string) (*TxRespon span.AddEvent("txclient/ConfirmTx: transaction resubmitted successfully after eviction") case core.TxStatusRejected: span.RecordError(fmt.Errorf("txclient/ConfirmTx: transaction rejected: %s", resp.Error)) - sequence, signer, exists := client.GetTxFromTxTracker(txHash) + sequence, signer, _, exists := client.GetTxFromTxTracker(txHash) if !exists { return nil, fmt.Errorf("tx: %s not found in tx client txTracker; likely failed during broadcast", txHash) } @@ -806,7 +829,7 @@ func (client *TxClient) ConfirmTx(ctx context.Context, txHash string) (*TxRespon return nil, fmt.Errorf("setting sequence: %w", err) } client.deleteFromTxTracker(txHash) - return nil, fmt.Errorf("tx with hash %s was rejected by the node with execution code %d", txHash, resp.ExecutionCode) + return nil, fmt.Errorf("tx with hash %s was rejected by the node with execution code: %d and log: %s", txHash, resp.ExecutionCode, resp.Error) default: span.RecordError(fmt.Errorf("txclient/ConfirmTx: unknown tx status for tx: %s", txHash)) client.deleteFromTxTracker(txHash) @@ -1035,11 +1058,11 @@ func (client *TxClient) trackTransaction(signer, txHash string, txBytes []byte) } // GetTxFromTxTracker gets transaction info from the tx client's local tx tracker by its hash -func (client *TxClient) GetTxFromTxTracker(hash string) (sequence uint64, signer string, exists bool) { +func (client *TxClient) GetTxFromTxTracker(hash string) (sequence uint64, signer string, txBytes []byte, exists bool) { client.mtx.Lock() defer client.mtx.Unlock() txInfo, exists := client.txTracker[hash] - return txInfo.sequence, txInfo.signer, exists + return txInfo.sequence, txInfo.signer, txInfo.txBytes, exists } // Signer exposes the tx clients underlying signer diff --git a/pkg/user/tx_client_test.go b/pkg/user/tx_client_test.go index 76112a51d1..192cb221eb 100644 --- a/pkg/user/tx_client_test.go +++ b/pkg/user/tx_client_test.go @@ -11,19 +11,16 @@ import ( "time" sdkmath "cosmossdk.io/math" - "github.com/celestiaorg/celestia-app/v6/app" "github.com/celestiaorg/celestia-app/v6/app/encoding" "github.com/celestiaorg/celestia-app/v6/app/grpc/gasestimation" "github.com/celestiaorg/celestia-app/v6/app/grpc/tx" "github.com/celestiaorg/celestia-app/v6/app/params" "github.com/celestiaorg/celestia-app/v6/pkg/appconsts" "github.com/celestiaorg/celestia-app/v6/pkg/user" + "github.com/celestiaorg/celestia-app/v6/pkg/user/utils" "github.com/celestiaorg/celestia-app/v6/test/util/blobfactory" - "github.com/celestiaorg/celestia-app/v6/test/util/genesis" "github.com/celestiaorg/celestia-app/v6/test/util/random" - "github.com/celestiaorg/celestia-app/v6/test/util/testfactory" "github.com/celestiaorg/celestia-app/v6/test/util/testnode" - blobtypes "github.com/celestiaorg/celestia-app/v6/x/blob/types" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/rpc/core" sdk "github.com/cosmos/cosmos-sdk/types" @@ -55,7 +52,7 @@ type TxClientTestSuite struct { } func (suite *TxClientTestSuite) SetupSuite() { - suite.encCfg, suite.txClient, suite.ctx = setupTxClientWithDefaultParams(suite.T()) + suite.encCfg, suite.txClient, suite.ctx = utils.SetupTxClientWithDefaultParams(suite.T()) suite.serviceClient = sdktx.NewServiceClient(suite.ctx.GRPCClient) } @@ -272,6 +269,12 @@ func (suite *TxClientTestSuite) TestConfirmTx() { confirmTxResp, err := suite.txClient.ConfirmTx(ctx, resp.TxHash) require.NoError(t, err) require.Equal(t, abci.CodeTypeOK, confirmTxResp.Code) + + // Verify the response against the getTx response + utils.VerifyTxResponse(t, suite.ctx.GoContext(), suite.serviceClient, confirmTxResp) + require.Equal(t, len(confirmTxResp.Signers), 1) + require.Equal(t, confirmTxResp.Signers[0], suite.txClient.DefaultAddress().String()) + require.True(t, wasRemovedFromTxTracker(resp.TxHash, suite.txClient)) }) @@ -288,16 +291,27 @@ func (suite *TxClientTestSuite) TestConfirmTx() { confirmTxResp, err := suite.txClient.ConfirmTx(suite.ctx.GoContext(), resp.TxHash) require.Error(t, err) + // During errors response does not get populated require.Nil(t, confirmTxResp) code := err.(*user.ExecutionError).Code require.NotEqual(t, abci.CodeTypeOK, code) + require.Equal(t, resp.TxHash, err.(*user.ExecutionError).TxHash) + + // Compare it to the getTx response + getTxResp, getTxErr := suite.serviceClient.GetTx(suite.ctx.GoContext(), &sdktx.GetTxRequest{Hash: resp.TxHash}) + require.NoError(t, getTxErr) + // This is a workaround because they are different types + require.Contains(t, err.(*user.ExecutionError).ErrorLog, getTxResp.TxResponse.RawLog) + require.Equal(t, getTxResp.TxResponse.Codespace, err.(*user.ExecutionError).Codespace) + require.Equal(t, getTxResp.TxResponse.GasWanted, err.(*user.ExecutionError).GasWanted) + require.Equal(t, getTxResp.TxResponse.GasUsed, err.(*user.ExecutionError).GasUsed) require.True(t, wasRemovedFromTxTracker(resp.TxHash, suite.txClient)) }) } func TestRejections(t *testing.T) { ttlNumBlocks := int64(5) - _, txClient, ctx := setupTxClient(t, ttlNumBlocks, appconsts.DefaultGovMaxSquareSize, appconsts.DefaultMaxBytes) + _, txClient, ctx := utils.SetupTxClient(t, ttlNumBlocks, appconsts.DefaultGovMaxSquareSize, appconsts.DefaultMaxBytes) fee := user.SetFee(1e6) gas := user.SetGasLimit(1e6) @@ -316,7 +330,7 @@ func TestRejections(t *testing.T) { _, err = txClient.ConfirmTx(ctx.GoContext(), resp.TxHash) require.Error(t, err) - require.Contains(t, err.Error(), "was rejected by the node") + require.Contains(t, err.Error(), "was rejected by the node with execution code: 30 and log:") seqAfterRejection := sender.Sequence() require.Equal(t, seqBeforeSubmission, seqAfterRejection) @@ -328,7 +342,7 @@ func TestRejections(t *testing.T) { seqAfterConfirmation := sender.Sequence() require.Equal(t, seqBeforeSubmission+1, seqAfterConfirmation) // Was removed from the tx tracker - _, _, exists := txClient.GetTxFromTxTracker(resp.TxHash) + _, _, _, exists := txClient.GetTxFromTxTracker(resp.TxHash) require.False(t, exists) } @@ -338,7 +352,7 @@ func TestEvictions(t *testing.T) { } blocksize := int64(1024 * 1024 * 2) // 2 MiB - _, txClient, ctx := setupTxClient(t, 1, 64, blocksize) + _, txClient, ctx := utils.SetupTxClient(t, 1, 64, blocksize) grpcTxClient := tx.NewTxClient(ctx.GRPCClient) fee := user.SetFee(1e6) @@ -379,7 +393,7 @@ func TestEvictions(t *testing.T) { require.NoError(t, err) require.Equal(t, res.Code, abci.CodeTypeOK) // They should be removed from the tx tracker after confirmation - _, _, exists := txClient.GetTxFromTxTracker(resp.TxHash) + _, _, _, exists := txClient.GetTxFromTxTracker(resp.TxHash) require.False(t, exists) } @@ -461,7 +475,7 @@ func TestEvictions(t *testing.T) { // used to estimate gas price and usage instead of the default connection. func TestWithEstimatorService(t *testing.T) { mockEstimator := setupEstimatorService(t) - _, txClient, ctx := setupTxClientWithDefaultParams(t, user.WithEstimatorService(mockEstimator.conn)) + _, txClient, ctx := utils.SetupTxClientWithDefaultParams(t, user.WithEstimatorService(mockEstimator.conn)) msg := bank.NewMsgSend(txClient.DefaultAddress(), testnode.RandomAddress().(sdk.AccAddress), sdk.NewCoins(sdk.NewInt64Coin(params.BondDenom, 10))) @@ -551,13 +565,13 @@ func (suite *TxClientTestSuite) queryCurrentBalance(t *testing.T) int64 { } func wasRemovedFromTxTracker(txHash string, txClient *user.TxClient) bool { - seq, signer, exists := txClient.GetTxFromTxTracker(txHash) - return !exists && seq == 0 && signer == "" + seq, signer, txBytes, exists := txClient.GetTxFromTxTracker(txHash) + return !exists && seq == 0 && signer == "" && len(txBytes) == 0 } // assertTxInTxTracker verifies that a tx was indexed in the tx tracker and that the sequence increases by one after broadcast. func assertTxInTxTracker(t *testing.T, txClient *user.TxClient, txHash, expectedSigner string, seqBeforeBroadcast uint64) { - seqFromTxTracker, signer, exists := txClient.GetTxFromTxTracker(txHash) + seqFromTxTracker, signer, txBytes, exists := txClient.GetTxFromTxTracker(txHash) require.True(t, exists) require.Equal(t, expectedSigner, signer) seqAfterBroadcast := txClient.Signer().Account(expectedSigner).Sequence() @@ -565,44 +579,7 @@ func assertTxInTxTracker(t *testing.T, txClient *user.TxClient, txHash, expected require.Equal(t, seqBeforeBroadcast, seqFromTxTracker) // Successfully broadcast transaction increases the sequence require.Equal(t, seqAfterBroadcast, seqBeforeBroadcast+1) -} - -func setupTxClient( - t *testing.T, - ttlNumBlocks int64, - squareSize uint64, - blocksize int64, - opts ...user.Option, -) (encoding.Config, *user.TxClient, testnode.Context) { - enc := encoding.MakeConfig(app.ModuleEncodingRegisters...) - defaultTmConfig := testnode.DefaultTendermintConfig() - defaultTmConfig.Mempool.TTLNumBlocks = ttlNumBlocks - accounts := testfactory.GenerateAccounts(3) - - defaultBlobParams := blobtypes.DefaultParams() - defaultBlobParams.GovMaxSquareSize = squareSize - - testnodeConfig := testnode.DefaultConfig(). - WithTendermintConfig(defaultTmConfig). - WithFundedAccounts(accounts...). - WithDelayedPrecommitTimeout(300 * time.Millisecond). - WithModifiers(genesis.SetBlobParams(enc.Codec, defaultBlobParams)) - // WithSuppressLogs(false) - - testnodeConfig.Genesis.ConsensusParams.Block.MaxBytes = blocksize - - ctx, _, _ := testnode.NewNetwork(t, testnodeConfig) - _, err := ctx.WaitForHeight(1) - require.NoError(t, err) - - txClient, err := user.SetupTxClient(ctx.GoContext(), ctx.Keyring, ctx.GRPCClient, enc, opts...) - require.NoError(t, err) - - return enc, txClient, ctx -} - -func setupTxClientWithDefaultParams(t *testing.T, opts ...user.Option) (encoding.Config, *user.TxClient, testnode.Context) { - return setupTxClient(t, 0, 128, 8388608, opts...) // no ttl and 8MiB block size + require.NotEmpty(t, txBytes) } type mockEstimatorServer struct { @@ -850,7 +827,7 @@ func (suite *TxClientTestSuite) TestSequenceIncrementOnlyOnceInMultiConnBroadcas require.Equal(t, seqBefore+1, seqAfter, "Sequence should be incremented by exactly 1, not by number of connections") // Verify the transaction is tracked - trackedSeq, trackedSigner, exists := multiConnClient.GetTxFromTxTracker(resp.TxHash) + trackedSeq, trackedSigner, _, exists := multiConnClient.GetTxFromTxTracker(resp.TxHash) require.True(t, exists, "Transaction should be in tracker") require.Equal(t, seqBefore, trackedSeq, "Tracked sequence should be the sequence before increment") require.Equal(t, multiConnClient.DefaultAccountName(), trackedSigner, "Tracked signer should match") diff --git a/pkg/user/utils/txclient_utils.go b/pkg/user/utils/txclient_utils.go new file mode 100644 index 0000000000..6ea0907537 --- /dev/null +++ b/pkg/user/utils/txclient_utils.go @@ -0,0 +1,91 @@ +package utils + +import ( + "context" + "testing" + "time" + + "github.com/celestiaorg/celestia-app/v6/app" + "github.com/celestiaorg/celestia-app/v6/app/encoding" + "github.com/celestiaorg/celestia-app/v6/pkg/user" + "github.com/celestiaorg/celestia-app/v6/test/util/genesis" + "github.com/celestiaorg/celestia-app/v6/test/util/testfactory" + "github.com/celestiaorg/celestia-app/v6/test/util/testnode" + blobtypes "github.com/celestiaorg/celestia-app/v6/x/blob/types" + sdktypes "github.com/cosmos/cosmos-sdk/types" + sdktx "github.com/cosmos/cosmos-sdk/types/tx" + "github.com/stretchr/testify/require" +) + +func SetupTxClient( + t *testing.T, + ttlNumBlocks int64, + squareSize uint64, + blocksize int64, + opts ...user.Option, +) (encoding.Config, *user.TxClient, testnode.Context) { + enc := encoding.MakeConfig(app.ModuleEncodingRegisters...) + tmConfig := testnode.DefaultTendermintConfig() + tmConfig.Mempool.TTLNumBlocks = ttlNumBlocks + accounts := testfactory.GenerateAccounts(3) + + blobParams := blobtypes.DefaultParams() + blobParams.GovMaxSquareSize = squareSize + + testnodeConfig := testnode.DefaultConfig(). + WithTendermintConfig(tmConfig). + WithFundedAccounts(accounts...). + WithDelayedPrecommitTimeout(300 * time.Millisecond). + WithModifiers(genesis.SetBlobParams(enc.Codec, blobParams)). + WithMaxBytes(blocksize) + + ctx, _, _ := testnode.NewNetwork(t, testnodeConfig) + _, err := ctx.WaitForHeight(1) + require.NoError(t, err) + + txClient, err := user.SetupTxClient(ctx.GoContext(), ctx.Keyring, ctx.GRPCClient, enc, opts...) + require.NoError(t, err) + + return enc, txClient, ctx +} + +func SetupTxClientWithDefaultParams(t *testing.T, opts ...user.Option) (encoding.Config, *user.TxClient, testnode.Context) { + return SetupTxClient(t, 0, 128, 8388608, opts...) // no ttl and 8MiB block size +} + +func VerifyTxResponse( + t *testing.T, + ctx context.Context, + serviceClient sdktx.ServiceClient, + confirmTxResp any, +) { + var ( + expTxHash string + expCode uint32 + expCodespace string + expGasWanted int64 + expGasUsed int64 + expHeight int64 + ) + + switch v := confirmTxResp.(type) { + case *user.TxResponse: + expTxHash, expCode, expCodespace, expGasWanted, expGasUsed, expHeight = v.TxHash, v.Code, v.Codespace, v.GasWanted, v.GasUsed, v.Height + case *sdktypes.TxResponse: + expTxHash, expCode, expCodespace, expGasWanted, expGasUsed, expHeight = v.TxHash, v.Code, v.Codespace, v.GasWanted, v.GasUsed, v.Height + default: + require.FailNowf(t, "unexpected type", "unsupported confirmTxResp type: %T", confirmTxResp) + } + + getTxResp, err := serviceClient.GetTx(ctx, &sdktx.GetTxRequest{Hash: expTxHash}) + require.NoError(t, err) + + txResp := getTxResp.TxResponse + require.NotNil(t, txResp) + require.Empty(t, txResp.RawLog) + require.Equal(t, expCode, txResp.Code) + require.Equal(t, expCodespace, txResp.Codespace) + require.Equal(t, expGasWanted, txResp.GasWanted) + require.Equal(t, expGasUsed, txResp.GasUsed) + require.Equal(t, expHeight, txResp.Height) +} diff --git a/pkg/user/v2/tx_client.go b/pkg/user/v2/tx_client.go new file mode 100644 index 0000000000..4cca1021bc --- /dev/null +++ b/pkg/user/v2/tx_client.go @@ -0,0 +1,122 @@ +package v2 + +import ( + "context" + + "github.com/celestiaorg/celestia-app/v6/app/encoding" + "github.com/celestiaorg/celestia-app/v6/pkg/user" + "github.com/celestiaorg/go-square/v3/share" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdktypes "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc" +) + +// TxClient is a v2 wrapper around the original TxClient that +// converts all user.TxResponse to sdktypes.TxResponse including the signer info. +type TxClient struct { + // Embed the underlying client to automatically delegate all methods + *user.TxClient +} + +// NewTxClient creates a new v2 TxClient by wrapping the original NewTxClient function. +func NewTxClient( + cdc codec.Codec, + signer *user.Signer, + conn *grpc.ClientConn, + registry codectypes.InterfaceRegistry, + options ...user.Option, +) (*TxClient, error) { + v1Client, err := user.NewTxClient(cdc, signer, conn, registry, options...) + if err != nil { + return nil, err + } + + return &TxClient{TxClient: v1Client}, nil +} + +// SetupTxClient creates and initializes a new v2 TxClient by wrapping the original setupTxClient method. +func SetupTxClient( + ctx context.Context, + keys keyring.Keyring, + conn *grpc.ClientConn, + encCfg encoding.Config, + options ...user.Option, +) (*TxClient, error) { + v1Client, err := user.SetupTxClient(ctx, keys, conn, encCfg, options...) + if err != nil { + return nil, err + } + + return &TxClient{TxClient: v1Client}, nil +} + +// Wrapv1TxClient wraps a v1 TxClient and returns a v2 TxClient. +func Wrapv1TxClient(v1Client *user.TxClient) *TxClient { + return &TxClient{TxClient: v1Client} +} + +func (c *TxClient) buildSDKTxResponse(legacyResp *user.TxResponse) *sdktypes.TxResponse { + return &sdktypes.TxResponse{ + Height: legacyResp.Height, + TxHash: legacyResp.TxHash, + Code: legacyResp.Code, + Codespace: legacyResp.Codespace, + GasWanted: legacyResp.GasWanted, + GasUsed: legacyResp.GasUsed, + Signers: legacyResp.Signers, + } +} + +// Override only the methods that have breaking changes from the original TxClient. + +// SubmitPayForBlob calls the original SubmitPayForBlob method and returns a v2 sdk.TxResponse. +func (c *TxClient) SubmitPayForBlob(ctx context.Context, blobs []*share.Blob, opts ...user.TxOption) (*sdktypes.TxResponse, error) { + legacyResp, err := c.TxClient.SubmitPayForBlob(ctx, blobs, opts...) + if err != nil { + return nil, err + } + + return c.buildSDKTxResponse(legacyResp), nil +} + +// SubmitPayForBlobWithAccount calls the original SubmitPayForBlobWithAccount method and returns a v2 sdk.TxResponse. +func (c *TxClient) SubmitPayForBlobWithAccount(ctx context.Context, accountName string, blobs []*share.Blob, opts ...user.TxOption) (*sdktypes.TxResponse, error) { + legacyResp, err := c.TxClient.SubmitPayForBlobWithAccount(ctx, accountName, blobs, opts...) + if err != nil { + return nil, err + } + + return c.buildSDKTxResponse(legacyResp), nil +} + +// SubmitTx calls the original SubmitTx method and returns a v2 sdk.TxResponse. +func (c *TxClient) SubmitTx(ctx context.Context, msgs []sdktypes.Msg, opts ...user.TxOption) (*sdktypes.TxResponse, error) { + legacyResp, err := c.TxClient.SubmitTx(ctx, msgs, opts...) + if err != nil { + return nil, err + } + + return c.buildSDKTxResponse(legacyResp), nil +} + +// SubmitPayForBlobToQueue calls the original SubmitPayForBlobToQueue method and returns a v2 sdk.TxResponse. +func (c *TxClient) SubmitPayForBlobToQueue(ctx context.Context, blobs []*share.Blob, opts ...user.TxOption) (*sdktypes.TxResponse, error) { + legacyResp, err := c.TxClient.SubmitPayForBlobToQueue(ctx, blobs, opts...) + if err != nil { + return nil, err + } + + return c.buildSDKTxResponse(legacyResp), nil +} + +// ConfirmTx calls the original ConfirmTx method and returns a v2 sdk.TxResponse. +func (c *TxClient) ConfirmTx(ctx context.Context, txHash string) (*sdktypes.TxResponse, error) { + legacyResp, err := c.TxClient.ConfirmTx(ctx, txHash) + if err != nil { + return nil, err + } + + return c.buildSDKTxResponse(legacyResp), nil +} diff --git a/pkg/user/v2/tx_client_test.go b/pkg/user/v2/tx_client_test.go new file mode 100644 index 0000000000..073cc1a202 --- /dev/null +++ b/pkg/user/v2/tx_client_test.go @@ -0,0 +1,91 @@ +package v2 + +import ( + "context" + "testing" + "time" + + "github.com/celestiaorg/celestia-app/v6/app/params" + "github.com/celestiaorg/celestia-app/v6/pkg/user/utils" + "github.com/celestiaorg/celestia-app/v6/test/util/blobfactory" + "github.com/celestiaorg/celestia-app/v6/test/util/random" + "github.com/celestiaorg/celestia-app/v6/test/util/testnode" + sdktypes "github.com/cosmos/cosmos-sdk/types" + sdktx "github.com/cosmos/cosmos-sdk/types/tx" + bank "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/stretchr/testify/require" +) + +func TestV2SubmitMethods(t *testing.T) { + if testing.Short() { + t.Skip("skipping in short mode") + } + + // setup test client + _, txClient, ctx := utils.SetupTxClientWithDefaultParams(t) + v2Client := Wrapv1TxClient(txClient) + serviceClient := sdktx.NewServiceClient(ctx.GRPCClient) + testCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + + blobs := blobfactory.ManyRandBlobs(random.New(), 1e3, 1e4) + addr := txClient.DefaultAddress() + msg := bank.NewMsgSend(addr, testnode.RandomAddress().(sdktypes.AccAddress), sdktypes.NewCoins(sdktypes.NewInt64Coin(params.BondDenom, 10))) + expectedSigner := txClient.DefaultAddress().String() + + testCases := []struct { + name string + submitFunc func() (*sdktypes.TxResponse, error) + expectedSigner string + }{ + { + name: "SubmitPayForBlob processes tx and populates sdk response", + submitFunc: func() (*sdktypes.TxResponse, error) { + return v2Client.SubmitPayForBlob(testCtx, blobs) + }, + expectedSigner: expectedSigner, + }, + { + name: "SubmitPayForBlobWithAccount processes tx and populates sdk response", + submitFunc: func() (*sdktypes.TxResponse, error) { + return v2Client.SubmitPayForBlobWithAccount(testCtx, txClient.DefaultAccountName(), blobs) + }, + expectedSigner: expectedSigner, + }, + { + name: "SubmitPayForBlobToQueue processes tx and populates sdk response", + submitFunc: func() (*sdktypes.TxResponse, error) { + return v2Client.SubmitPayForBlobToQueue(testCtx, blobs) + }, + expectedSigner: expectedSigner, + }, + { + name: "SubmitTx processes tx and populates sdk response", + submitFunc: func() (*sdktypes.TxResponse, error) { + return v2Client.SubmitTx(testCtx, []sdktypes.Msg{msg}) + }, + expectedSigner: expectedSigner, + }, + { + name: "ConfirmTx processes tx and populates sdk response", + submitFunc: func() (*sdktypes.TxResponse, error) { + resp, err := v2Client.BroadcastPayForBlob(testCtx, blobs) + require.NoError(t, err) + return v2Client.ConfirmTx(testCtx, resp.TxHash) + }, + expectedSigner: expectedSigner, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + submitResp, err := tc.submitFunc() + require.NoError(t, err) + utils.VerifyTxResponse(t, context.Background(), serviceClient, submitResp) + + // verify signers + require.Equal(t, len(submitResp.Signers), 1) + require.Equal(t, submitResp.Signers[0], txClient.DefaultAddress().String()) + }) + } +} diff --git a/proto/celestia/core/v1/tx/tx.proto b/proto/celestia/core/v1/tx/tx.proto index 79751075d0..72c22e6d71 100644 --- a/proto/celestia/core/v1/tx/tx.proto +++ b/proto/celestia/core/v1/tx/tx.proto @@ -38,4 +38,12 @@ message TxStatusResponse { string error = 4; // status is the status of the transaction. string status = 5; + // the error namespace/module. + string codespace = 6; + // requested gas limit. + int64 gas_wanted = 7; + // actual gas consumed. + int64 gas_used = 8; + // signers of the transaction. + repeated string signers = 9; } diff --git a/specs/src/tx_client.md b/specs/src/tx_client.md index 21af793171..ca565336fe 100644 --- a/specs/src/tx_client.md +++ b/specs/src/tx_client.md @@ -1,4 +1,4 @@ -## Transaction Client +# Transaction Client ## Abstract diff --git a/test/docker-e2e/go.mod b/test/docker-e2e/go.mod index f62b899faf..f593ec8d35 100644 --- a/test/docker-e2e/go.mod +++ b/test/docker-e2e/go.mod @@ -276,7 +276,7 @@ replace ( cosmossdk.io/x/upgrade => github.com/celestiaorg/cosmos-sdk/x/upgrade v0.2.0 github.com/celestiaorg/celestia-app/v6 => ../.. github.com/cometbft/cometbft => github.com/celestiaorg/celestia-core v0.39.12 - github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v0.51.4 + github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v0.51.6 github.com/cosmos/ibc-go/v8 => github.com/celestiaorg/ibc-go/v8 v8.7.2 // Use ledger-cosmos-go v0.16.0 because v0.15.0 causes "hidapi: unknown failure" // See https://github.com/celestiaorg/celestia-app/issues/5453 diff --git a/test/docker-e2e/go.sum b/test/docker-e2e/go.sum index 0fc07216a0..7f95185660 100644 --- a/test/docker-e2e/go.sum +++ b/test/docker-e2e/go.sum @@ -776,8 +776,8 @@ github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFos github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/celestiaorg/celestia-core v0.39.12 h1:SvlGmZr6XmsSeruFDSyz2rQmCdAJT+6JoPZwNDPpOhU= github.com/celestiaorg/celestia-core v0.39.12/go.mod h1:GxCnrVUUJZ3dtpNlKfHw3otb5TqyOdwjXef1/pNqSzA= -github.com/celestiaorg/cosmos-sdk v0.51.4 h1:4yQQ+3NqvfcrO3Im1dbzSPF7Ujvw8P0IIisRWVXjWLg= -github.com/celestiaorg/cosmos-sdk v0.51.4/go.mod h1:YRNOXtC4vo5FG1SSoj57yEUiidU8Pn3ofjqYlFdu8qg= +github.com/celestiaorg/cosmos-sdk v0.51.6 h1:sUDSbbg6SjPjWHW7mow4j6i+I8X8nHDmpojnPOeAwYI= +github.com/celestiaorg/cosmos-sdk v0.51.6/go.mod h1:z5sV0ONMM7Qww3FuLZ2xmqjFblbivkb/jmwQfnHAxrE= github.com/celestiaorg/cosmos-sdk/api v0.7.6 h1:81in9Zk+noz0ko+hZFSSK8L1aawFN8/CmdcQAUhbiUU= github.com/celestiaorg/cosmos-sdk/api v0.7.6/go.mod h1:1BgQSufu6ZQkst3YBIHDCo/TPUrhfU4fV7tOI0ftql8= github.com/celestiaorg/cosmos-sdk/x/upgrade v0.2.0 h1:GyDYfK8dLETlUI7F+w+3QYQgAszUegMXgB6cTbDm7CA= diff --git a/test/txsim/account.go b/test/txsim/account.go index 0f52f42d53..72f4b1ce2c 100644 --- a/test/txsim/account.go +++ b/test/txsim/account.go @@ -14,6 +14,7 @@ import ( "github.com/celestiaorg/celestia-app/v6/app/encoding" "github.com/celestiaorg/celestia-app/v6/pkg/appconsts" "github.com/celestiaorg/celestia-app/v6/pkg/user" + txclientv2 "github.com/celestiaorg/celestia-app/v6/pkg/user/v2" "github.com/celestiaorg/go-square/v3/share" tmservice "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" "github.com/cosmos/cosmos-sdk/crypto/hd" @@ -36,7 +37,7 @@ type AccountManager struct { // to protect from concurrent writes to the map mtx sync.Mutex - txClient *user.TxClient + txClient *txclientv2.TxClient balance uint64 latestHeight uint64 lastUpdated time.Time @@ -147,7 +148,7 @@ func (am *AccountManager) setupMasterAccount(ctx context.Context, masterAccName return fmt.Errorf("error getting master account %s balance: %w", masterAccName, err) } - am.txClient, err = user.SetupTxClient(ctx, am.keys, am.conn, am.encCfg, user.WithDefaultAccount(masterAccName), user.WithPollTime(am.pollTime)) + am.txClient, err = txclientv2.SetupTxClient(ctx, am.keys, am.conn, am.encCfg, user.WithDefaultAccount(masterAccName), user.WithPollTime(am.pollTime)) if err != nil { return err } @@ -275,7 +276,7 @@ func (am *AccountManager) Submit(ctx context.Context, op Operation) error { } var ( - res *user.TxResponse + res *types.TxResponse err error ) if len(op.Blobs) > 0 { diff --git a/test/util/testnode/config.go b/test/util/testnode/config.go index be9e6bf44e..92ea1bb39f 100644 --- a/test/util/testnode/config.go +++ b/test/util/testnode/config.go @@ -135,6 +135,11 @@ func (c *Config) WithConsensusParams(params *tmproto.ConsensusParams) *Config { return c } +func (c *Config) WithMaxBytes(maxBytes int64) *Config { + c.Genesis.ConsensusParams.Block.MaxBytes = maxBytes + return c +} + // DefaultConfig returns the default configuration of a test node. func DefaultConfig() *Config { cfg := &Config{}