Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration test for querying malleated transactions #188

Merged
merged 8 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ PACKAGES=$(shell go list ./... | grep -v '/simulation')
COMMIT := $(shell git log -1 --format='%H')
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
IMAGE := ghcr.io/tendermint/docker-build-proto:latest
DOCKER_PROTO_BUILDER := docker run -v $(shell pwd):/workspace --workdir /workspace $(IMAGE)

all: install

Expand Down Expand Up @@ -37,6 +39,11 @@ proto-gen:
proto-lint:
@$(DOCKER_BUF) lint --error-format=json

proto-format:
@echo "Formatting Protobuf files"
@$(DOCKER_PROTO_BUILDER) find . -name '*.proto' -path "./proto/*" -exec clang-format -i {} \;
.PHONY: proto-format

build-docker:
$(DOCKER) build -t celestiaorg/celestia-app -f docker/Dockerfile .

Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func New(

dec := encodingConfig.TxConfig.TxDecoder()

bApp := baseapp.NewBaseApp(Name, logger, db, ChildTxDecoder(dec), baseAppOptions...)
bApp := baseapp.NewBaseApp(Name, logger, db, MalleatedTxDecoder(dec), baseAppOptions...)
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetVersion(version.Version)
bApp.SetInterfaceRegistry(interfaceRegistry)
Expand Down
2 changes: 1 addition & 1 deletion app/child_tx_decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
coretypes "github.com/tendermint/tendermint/types"
)

func ChildTxDecoder(dec sdk.TxDecoder) sdk.TxDecoder {
func MalleatedTxDecoder(dec sdk.TxDecoder) sdk.TxDecoder {
return func(txBytes []byte) (sdk.Tx, error) {
if _, childTx, has := coretypes.UnwrapMalleatedTx(txBytes); has {
return dec(childTx)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v0.44.1-celestia
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/tendermint/tendermint v0.34.13 => github.com/celestiaorg/celestia-core v0.34.14-celestia.0.20220110174237-266919cced26
github.com/tendermint/tendermint v0.34.13 => github.com/celestiaorg/celestia-core v0.34.14-celestia.0.20220119223021-e54097114e14
google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/celestiaorg/celestia-core v0.34.14-celestia.0.20220110174237-266919cced26 h1:rjRRkLQhqs/sVnYiDBRo3ndPaAKKKH0YuG+kl9lfD40=
github.com/celestiaorg/celestia-core v0.34.14-celestia.0.20220110174237-266919cced26/go.mod h1:3n9kP3esPVYeAXMW/QSLALhMtraZInoTD5rcjteFpVQ=
github.com/celestiaorg/celestia-core v0.34.14-celestia.0.20220119223021-e54097114e14 h1:PiiLrn/eNV++ByjxRo6o8M62aNvVc786AL4Bl3vCpd0=
github.com/celestiaorg/celestia-core v0.34.14-celestia.0.20220119223021-e54097114e14/go.mod h1:3n9kP3esPVYeAXMW/QSLALhMtraZInoTD5rcjteFpVQ=
github.com/celestiaorg/cosmos-sdk v0.44.1-celestia h1:WbNV1I4L7oudA38lZ+7ILnWElfDIbdZdNp3jHBvIXgU=
github.com/celestiaorg/cosmos-sdk v0.44.1-celestia/go.mod h1:YVeOYCHyYj6Ig58sB9wxpu2hxzdI+apUtQ+hrp308kg=
github.com/celestiaorg/go-leopard v0.1.0 h1:28z2EkvKJIez5J9CEaiiUEC+OxalRLtTGJJ1oScfE1g=
Expand Down
9 changes: 5 additions & 4 deletions proto/cosmos/base/query/v1beta1/pagination.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ message PageRequest {
uint64 limit = 3;

// count_total is set to true to indicate that the result set should include
// a count of the total number of items available for pagination in UIs. count_total
// is only respected when offset is used. It is ignored when key is set.
// a count of the total number of items available for pagination in UIs.
// count_total is only respected when offset is used. It is ignored when key
// is set.
bool count_total = 4;
}

// PageResponse is to be embedded in gRPC response messages where the corresponding
// request message has used PageRequest.
// PageResponse is to be embedded in gRPC response messages where the
// corresponding request message has used PageRequest.
//
// message SomeResponse {
// repeated Bar results = 1;
Expand Down
4 changes: 1 addition & 3 deletions proto/payment/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ package payment;
option go_package = "github.com/celestiaorg/celestia-app/x/payment/types";

// GenesisState defines the capability module's genesis state.
message GenesisState {
}

message GenesisState {}
2 changes: 1 addition & 1 deletion proto/payment/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option go_package = "github.com/celestiaorg/celestia-app/x/payment/types";

// Query defines the gRPC querier service.
service Query {
// this line is used by starport scaffolding # 2
// this line is used by starport scaffolding # 2
}

// this line is used by starport scaffolding # 3
39 changes: 21 additions & 18 deletions proto/payment/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,48 @@ import "google/api/annotations.proto";

option go_package = "github.com/celestiaorg/celestia-app/x/payment/types";


// Msg defines the payment Msg service.
service Msg {
// PayForMessage allows the user to pay for the inclusion of a message
rpc PayForMessage(MsgPayForMessage) returns (MsgPayForMessageResponse) {
option (google.api.http).get = "/celestia/payment/payformessage";
}
// PayForMessage allows the user to pay for the inclusion of a message
rpc PayForMessage(MsgPayForMessage) returns (MsgPayForMessageResponse) {
option (google.api.http).get = "/celestia/payment/payformessage";
}
}

// MsgWirePayForMessage describes the format of data that is sent over the wire for
// each PayForMessage
// MsgWirePayForMessage describes the format of data that is sent over the wire
// for each PayForMessage
message MsgWirePayForMessage {
string signer = 1;
bytes message_name_space_id = 2; // assume this is 8 bytes!
uint64 message_size = 3;
bytes message = 4;
repeated ShareCommitAndSignature message_share_commitment = 6 [(gogoproto.nullable) = false];
repeated ShareCommitAndSignature message_share_commitment = 6
[ (gogoproto.nullable) = false ];
}

// MsgWirePayForMessageResponse describes the response returned after the submission of a WirePayForMessage
// MsgWirePayForMessageResponse describes the response returned after the
// submission of a WirePayForMessage
message MsgWirePayForMessageResponse {}

// ShareCommitAndSignature defines the
// ShareCommitAndSignature defines the
message ShareCommitAndSignature {
uint64 k = 1;
bytes share_commitment = 2;
bytes signature = 3; // signature on one SignedTransactionPayForMessage
}

// MsgPayForMessage is what gets signed by users when creating ShareCommitSignatures.
// Multiple versions are signed and included, each version creates a commitment for a
// MsgPayForMessage is what gets signed by users when creating
// ShareCommitSignatures.
// Multiple versions are signed and included, each version creates a commitment
// for a
// specific square size.
message MsgPayForMessage {
string signer = 1;
bytes message_namespace_id = 2;
uint64 message_size = 3;
bytes message_share_commitment = 4;
string signer = 1;
bytes message_namespace_id = 2;
uint64 message_size = 3;
bytes message_share_commitment = 4;
}

// MsgPayForMessageResponse describes the response returned after the submission of a PayForMessage
// MsgPayForMessageResponse describes the response returned after the submission
// of a PayForMessage
message MsgPayForMessageResponse {}

9 changes: 5 additions & 4 deletions third_party/proto/tendermint/abci/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,11 @@ message EventAttribute {
//
// One usage is indexing transaction results.
message TxResult {
int64 height = 1;
uint32 index = 2;
bytes tx = 3;
ResponseDeliverTx result = 4 [(gogoproto.nullable) = false];
int64 height = 1;
uint32 index = 2;
bytes tx = 3;
ResponseDeliverTx result = 4 [(gogoproto.nullable) = false];
bytes original_hash = 5;
}

//----------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions x/payment/client/testutil/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package testutil
import (
"fmt"
"testing"
"time"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
Expand All @@ -15,6 +16,7 @@ import (

"github.com/celestiaorg/celestia-app/testutil/network"
paycli "github.com/celestiaorg/celestia-app/x/payment/client/cli"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
)

// username is used to create a funded genesis account under this name
Expand Down Expand Up @@ -105,6 +107,17 @@ func (s *IntegrationTestSuite) TestSubmitWirePayForMessage() {
for i := 0; i < len(events); i++ {
s.Equal("/payment.MsgPayForMessage", events[i].GetAttributes()[0].Value)
}

// wait for the tx to be indexed
time.Sleep(time.Second * 3)
adlerjohn marked this conversation as resolved.
Show resolved Hide resolved

// attempt to query for the malleated transaction using the original tx's hash
qTxCmd := authcmd.QueryTxCmd()
out, err := clitestutil.ExecTestCLICmd(clientCtx, qTxCmd, []string{txResp.TxHash, "--output=json"})
require.NoError(err)

var result sdk.TxResponse
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &result))
}
})
}
Expand Down