From c9da1f69ed4e92e8cc40a933c5f65f8ab388414a Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Tue, 10 Sep 2024 14:57:54 -0500 Subject: [PATCH] fixes --- chain/cosmos/chain_node.go | 25 ++++++++++--------------- examples/cosmos/chain_gordian_test.go | 6 +++--- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/chain/cosmos/chain_node.go b/chain/cosmos/chain_node.go index b7c429330..0ca1c4add 100644 --- a/chain/cosmos/chain_node.go +++ b/chain/cosmos/chain_node.go @@ -434,18 +434,16 @@ func (tn *ChainNode) SetPeers(ctx context.Context, peers string) error { } func (tn *ChainNode) Height(ctx context.Context) (int64, error) { - - type GordianBlockWatermark struct { - VotingHeight int64 `json:"VotingHeight"` - VotingRound int64 `json:"VotingRound"` - CommittingHeight int64 `json:"CommittingHeight"` - CommittingRound int64 `json:"CommittingRound"` + type GordianCurrentBlockResponse struct { + VotingHeight *uint64 `protobuf:"varint,1,opt,name=voting_height,json=votingHeight,proto3,oneof" json:"voting_height,omitempty"` + VotingRound *uint32 `protobuf:"varint,2,opt,name=voting_round,json=votingRound,proto3,oneof" json:"voting_round,omitempty"` + CommittingHeight *uint64 `protobuf:"varint,3,opt,name=committing_height,json=committingHeight,proto3,oneof" json:"committing_height,omitempty"` + CommittingRound *uint32 `protobuf:"varint,4,opt,name=committing_round,json=committingRound,proto3,oneof" json:"committing_round,omitempty"` } // TODO: cleanup / cache this on first call. gRPC here instead of HTTP. if tn.IsCometBFT(ctx) { - fmt.Println("Height CometBFT chain consensus") res, err := tn.Client.Status(ctx) if err != nil { return 0, fmt.Errorf("tendermint rpc client status: %w", err) @@ -455,9 +453,6 @@ func (tn *ChainNode) Height(ctx context.Context) (int64, error) { } if tn.IsGordian(ctx) { - fmt.Println("Height Gordian chain consensus") - // http query http://127.0.0.1:26657/blocks/watermark and save to GordianBlockWatermark - ports, err := tn.containerLifecycle.GetHostPorts(ctx, rpcPort) if err != nil { return 0, fmt.Errorf("getting host ports: %w", err) @@ -486,14 +481,13 @@ func (tn *ChainNode) Height(ctx context.Context) (int64, error) { } defer resp.Body.Close() - var watermark GordianBlockWatermark + var watermark GordianCurrentBlockResponse if err := json.NewDecoder(resp.Body).Decode(&watermark); err != nil { log.Print(err) os.Exit(1) } - fmt.Println("watermark VotingHeight: ", watermark.VotingHeight) - return watermark.VotingHeight, nil + return int64(*watermark.VotingHeight), nil } return 0, fmt.Errorf("unsupported chain consensus") @@ -621,6 +615,7 @@ func (tn *ChainNode) ExecTx(ctx context.Context, keyName string, command ...stri if err != nil { return "", err } + fmt.Println("ExecTx-stdout", string(stdout)) output := CosmosTx{} err = json.Unmarshal([]byte(stdout), &output) if err != nil { @@ -836,9 +831,9 @@ func (tn *ChainNode) IsCometBFT(ctx context.Context) bool { return tn.Cache[key].(bool) } - fmt.Println("IsCometBFT call check") isComet := tn.HasCommand(ctx, "cometbft") tn.Cache[key] = isComet + fmt.Println("IsCometBFT call check", isComet) return isComet } @@ -849,9 +844,9 @@ func (tn *ChainNode) IsGordian(ctx context.Context) bool { return tn.Cache[key].(bool) } - fmt.Println("IsGordian call check") isGordian := tn.HasCommand(ctx, "gordian") tn.Cache[key] = isGordian + fmt.Println("IsGordian call check", isGordian) return isGordian } diff --git a/examples/cosmos/chain_gordian_test.go b/examples/cosmos/chain_gordian_test.go index f9d37d9aa..39c4e3ce4 100644 --- a/examples/cosmos/chain_gordian_test.go +++ b/examples/cosmos/chain_gordian_test.go @@ -53,7 +53,7 @@ func TestChainGordian(t *testing.T) { TrustingPeriod: "330h", AdditionalStartArgs: []string{ "--g-http-addr", ":26657", - "--g-grpc-addr", ":9092", + "--g-grpc-addr", ":9092", // gRPC 9090 is already used? }, Denom: denomMetadata.Base, // ExposeAdditionalPorts: , @@ -88,10 +88,10 @@ func TestChainGordian(t *testing.T) { _ = ic.Close() }) + // TODO: gordian does not yet accept standard tx commands, it requires a manual broadcast of a generate only. Need to submit the raw bytes properly users := interchaintest.GetAndFundTestUsers(t, ctx, "default", genesisAmt, chain, chain) user1 := users[1].FormattedAddress() - - fmt.Println("user1", user1) + fmt.Println("user1", user1, "yuh") // b2, err := chain.BankQueryBalance(ctx, user1, chain.Config().Denom) // require.NoError(t, err)