Skip to content

Commit

Permalink
Merge branch 'main' into steve/geth
Browse files Browse the repository at this point in the history
  • Loading branch information
misko9 committed Aug 23, 2024
2 parents 84bd7d6 + c3e1187 commit 77cad5d
Show file tree
Hide file tree
Showing 20 changed files with 716 additions and 92 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/local-interchain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,40 @@ jobs:
name: local-ic
path: ~/go/bin/local-ic

bash-e2e:
name: bash
needs: build
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./local-interchain
strategy:
fail-fast: false

steps:
- name: checkout chain
uses: actions/checkout@v4

- name: Download Tarball Artifact
uses: actions/download-artifact@v3
with:
name: local-ic
path: /tmp

- name: Make local-ic executable
run: chmod +x /tmp/local-ic

- name: Start background ibc local-interchain
run: /tmp/local-ic start juno_ibc --api-port 8080 &

- name: Run Bash Script
run: |
cd bash
bash ./test.bash
- name: Cleanup
run: killall local-ic && exit 0

rust-e2e:
name: rust
needs: build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
# run tests
- name: run unit tests
# -short flag purposefully omitted because there are some longer unit tests
run: go test -race -timeout 10m -failfast -p 2 $(go list ./... | grep -v /cmd | grep -v /examples)
run: go test -race -timeout 30m -failfast -p 2 $(go list ./... | grep -v /cmd | grep -v /examples)
2 changes: 1 addition & 1 deletion chain/cosmos/chain_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (tn *ChainNode) NewClient(addr string) error {

tn.Client = rpcClient

grpcConn, err := grpc.Dial(
grpcConn, err := grpc.NewClient(
tn.hostGRPCPort, grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
Expand Down
15 changes: 12 additions & 3 deletions chain/cosmos/module_slashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,28 @@ func (tn *ChainNode) SlashingUnJail(ctx context.Context, keyName string) error {
func (c *CosmosChain) SlashingQueryParams(ctx context.Context) (*slashingtypes.Params, error) {
res, err := slashingtypes.NewQueryClient(c.GetNode().GrpcConn).
Params(ctx, &slashingtypes.QueryParamsRequest{})
return &res.Params, err
if err != nil {
return nil, err
}
return &res.Params, nil
}

// SlashingSigningInfo returns signing info for a validator
func (c *CosmosChain) SlashingQuerySigningInfo(ctx context.Context, consAddress string) (*slashingtypes.ValidatorSigningInfo, error) {
res, err := slashingtypes.NewQueryClient(c.GetNode().GrpcConn).
SigningInfo(ctx, &slashingtypes.QuerySigningInfoRequest{ConsAddress: consAddress})
return &res.ValSigningInfo, err
if err != nil {
return nil, err
}
return &res.ValSigningInfo, nil
}

// SlashingSigningInfos returns all signing infos
func (c *CosmosChain) SlashingQuerySigningInfos(ctx context.Context) ([]slashingtypes.ValidatorSigningInfo, error) {
res, err := slashingtypes.NewQueryClient(c.GetNode().GrpcConn).
SigningInfos(ctx, &slashingtypes.QuerySigningInfosRequest{})
return res.Info, err
if err != nil {
return nil, err
}
return res.Info, nil
}
70 changes: 56 additions & 14 deletions chain/cosmos/module_staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,103 +84,145 @@ func (tn *ChainNode) StakingCreateValidatorFile(
func (c *CosmosChain) StakingQueryDelegation(ctx context.Context, valAddr string, delegator string) (*stakingtypes.DelegationResponse, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).
Delegation(ctx, &stakingtypes.QueryDelegationRequest{DelegatorAddr: delegator, ValidatorAddr: valAddr})
return res.DelegationResponse, err
if err != nil {
return nil, err
}
return res.DelegationResponse, nil
}

// StakingQueryDelegations returns all delegations for a delegator.
func (c *CosmosChain) StakingQueryDelegations(ctx context.Context, delegator string) ([]stakingtypes.DelegationResponse, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).
DelegatorDelegations(ctx, &stakingtypes.QueryDelegatorDelegationsRequest{DelegatorAddr: delegator, Pagination: nil})
return res.DelegationResponses, err
if err != nil {
return nil, err
}
return res.DelegationResponses, nil
}

// StakingQueryDelegationsTo returns all delegations to a validator.
func (c *CosmosChain) StakingQueryDelegationsTo(ctx context.Context, validator string) ([]*stakingtypes.DelegationResponse, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).
ValidatorDelegations(ctx, &stakingtypes.QueryValidatorDelegationsRequest{ValidatorAddr: validator})
if err != nil {
return nil, err
}

var delegations []*stakingtypes.DelegationResponse
for _, d := range res.DelegationResponses {
delegations = append(delegations, &d)
}

return delegations, err
return delegations, nil
}

// StakingQueryDelegatorValidator returns a validator for a delegator.
func (c *CosmosChain) StakingQueryDelegatorValidator(ctx context.Context, delegator string, validator string) (*stakingtypes.Validator, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).
DelegatorValidator(ctx, &stakingtypes.QueryDelegatorValidatorRequest{DelegatorAddr: delegator, ValidatorAddr: validator})
return &res.Validator, err
if err != nil {
return nil, err
}
return &res.Validator, nil
}

// StakingQueryDelegatorValidators returns all validators for a delegator.
func (c *CosmosChain) StakingQueryDelegatorValidators(ctx context.Context, delegator string) ([]stakingtypes.Validator, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).
DelegatorValidators(ctx, &stakingtypes.QueryDelegatorValidatorsRequest{DelegatorAddr: delegator})
return res.Validators, err
if err != nil {
return nil, err
}
return res.Validators, nil
}

// StakingQueryHistoricalInfo returns the historical info at the given height.
func (c *CosmosChain) StakingQueryHistoricalInfo(ctx context.Context, height int64) (*stakingtypes.HistoricalInfo, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).
HistoricalInfo(ctx, &stakingtypes.QueryHistoricalInfoRequest{Height: height})
return res.Hist, err
if err != nil {
return nil, err
}
return res.Hist, nil
}

// StakingQueryParams returns the staking parameters.
func (c *CosmosChain) StakingQueryParams(ctx context.Context) (*stakingtypes.Params, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).
Params(ctx, &stakingtypes.QueryParamsRequest{})
return &res.Params, err
if err != nil {
return nil, err
}
return &res.Params, nil
}

// StakingQueryPool returns the current staking pool values.
func (c *CosmosChain) StakingQueryPool(ctx context.Context) (*stakingtypes.Pool, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).
Pool(ctx, &stakingtypes.QueryPoolRequest{})
return &res.Pool, err
if err != nil {
return nil, err
}
return &res.Pool, nil
}

// StakingQueryRedelegation returns a redelegation.
func (c *CosmosChain) StakingQueryRedelegation(ctx context.Context, delegator string, srcValAddr string, dstValAddr string) ([]stakingtypes.RedelegationResponse, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).
Redelegations(ctx, &stakingtypes.QueryRedelegationsRequest{DelegatorAddr: delegator, SrcValidatorAddr: srcValAddr, DstValidatorAddr: dstValAddr})
return res.RedelegationResponses, err
if err != nil {
return nil, err
}
return res.RedelegationResponses, nil
}

// StakingQueryUnbondingDelegation returns an unbonding delegation.
func (c *CosmosChain) StakingQueryUnbondingDelegation(ctx context.Context, delegator string, validator string) (*stakingtypes.UnbondingDelegation, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).
UnbondingDelegation(ctx, &stakingtypes.QueryUnbondingDelegationRequest{DelegatorAddr: delegator, ValidatorAddr: validator})
return &res.Unbond, err
if err != nil {
return nil, err
}
return &res.Unbond, nil
}

// StakingQueryUnbondingDelegations returns all unbonding delegations for a delegator.
func (c *CosmosChain) StakingQueryUnbondingDelegations(ctx context.Context, delegator string) ([]stakingtypes.UnbondingDelegation, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).
DelegatorUnbondingDelegations(ctx, &stakingtypes.QueryDelegatorUnbondingDelegationsRequest{DelegatorAddr: delegator})
return res.UnbondingResponses, err
if err != nil {
return nil, err
}
return res.UnbondingResponses, nil
}

// StakingQueryUnbondingDelegationsFrom returns all unbonding delegations from a validator.
func (c *CosmosChain) StakingQueryUnbondingDelegationsFrom(ctx context.Context, validator string) ([]stakingtypes.UnbondingDelegation, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).
ValidatorUnbondingDelegations(ctx, &stakingtypes.QueryValidatorUnbondingDelegationsRequest{ValidatorAddr: validator})
return res.UnbondingResponses, err
if err != nil {
return nil, err
}
return res.UnbondingResponses, nil
}

// StakingQueryValidator returns a validator.
func (c *CosmosChain) StakingQueryValidator(ctx context.Context, validator string) (*stakingtypes.Validator, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).
Validator(ctx, &stakingtypes.QueryValidatorRequest{ValidatorAddr: validator})
return &res.Validator, err
if err != nil {
return nil, err
}
return &res.Validator, nil
}

// StakingQueryValidators returns all validators.
func (c *CosmosChain) StakingQueryValidators(ctx context.Context, status string) ([]stakingtypes.Validator, error) {
res, err := stakingtypes.NewQueryClient(c.GetNode().GrpcConn).Validators(ctx, &stakingtypes.QueryValidatorsRequest{
Status: status,
})
return res.Validators, err
if err != nil {
return nil, err
}
return res.Validators, nil
}
2 changes: 1 addition & 1 deletion chain/penumbra/penumbra_client_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ func (p *PenumbraClientNode) StartContainer(ctx context.Context) error {

p.hostGRPCPort = hostPorts[0]

p.GRPCConn, err = grpc.Dial(p.hostGRPCPort, grpc.WithTransportCredentials(insecure.NewCredentials()))
p.GRPCConn, err = grpc.NewClient(p.hostGRPCPort, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return err
}
Expand Down
61 changes: 48 additions & 13 deletions chain/thorchain/module_bank.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,68 +25,103 @@ func (c *Thorchain) GetBalance(ctx context.Context, address string, denom string
// BankGetBalance is an alias for GetBalance
func (c *Thorchain) BankQueryBalance(ctx context.Context, address string, denom string) (sdkmath.Int, error) {
res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).Balance(ctx, &banktypes.QueryBalanceRequest{Address: address, Denom: denom})
return res.Balance.Amount, err
if err != nil {
return sdkmath.ZeroInt(), err
}
return res.Balance.Amount, nil
}

// AllBalances fetches an account address's balance for all denoms it holds
func (c *Thorchain) BankQueryAllBalances(ctx context.Context, address string) (types.Coins, error) {
res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).AllBalances(ctx, &banktypes.QueryAllBalancesRequest{Address: address})
return res.GetBalances(), err
if err != nil {
return nil, err
}
return res.GetBalances(), nil
}

// BankDenomMetadata fetches the metadata of a specific coin denomination
func (c *Thorchain) BankQueryDenomMetadata(ctx context.Context, denom string) (*banktypes.Metadata, error) {
res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).DenomMetadata(ctx, &banktypes.QueryDenomMetadataRequest{Denom: denom})
return &res.Metadata, err
if err != nil {
return nil, err
}
return &res.Metadata, nil
}

func (c *Thorchain) BankQueryDenomMetadataByQueryString(ctx context.Context, denom string) (*banktypes.Metadata, error) {
res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).DenomMetadataByQueryString(ctx, &banktypes.QueryDenomMetadataByQueryStringRequest{Denom: denom})
return &res.Metadata, err
if err != nil {
return nil, err
}
return &res.Metadata, nil
}

func (c *Thorchain) BankQueryDenomOwners(ctx context.Context, denom string) ([]*banktypes.DenomOwner, error) {
res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).DenomOwners(ctx, &banktypes.QueryDenomOwnersRequest{Denom: denom})
return res.DenomOwners, err
if err != nil {
return nil, err
}
return res.DenomOwners, nil
}

func (c *Thorchain) BankQueryDenomsMetadata(ctx context.Context) ([]banktypes.Metadata, error) {
res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).DenomsMetadata(ctx, &banktypes.QueryDenomsMetadataRequest{})
return res.Metadatas, err
if err != nil {
return nil, err
}
return res.Metadatas, nil
}

func (c *Thorchain) BankQueryParams(ctx context.Context) (*banktypes.Params, error) {
res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).Params(ctx, &banktypes.QueryParamsRequest{})
return &res.Params, err
if err != nil {
return nil, err
}
return &res.Params, nil
}

func (c *Thorchain) BankQuerySendEnabled(ctx context.Context, denoms []string) ([]*banktypes.SendEnabled, error) {
res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).SendEnabled(ctx, &banktypes.QuerySendEnabledRequest{
Denoms: denoms,
})
return res.SendEnabled, err
if err != nil {
return nil, err
}
return res.SendEnabled, nil
}

func (c *Thorchain) BankQuerySpendableBalance(ctx context.Context, address, denom string) (*types.Coin, error) {
res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).SpendableBalanceByDenom(ctx, &banktypes.QuerySpendableBalanceByDenomRequest{
Address: address,
Denom: denom,
})
return res.Balance, err
if err != nil {
return nil, err
}
return res.Balance, nil
}

func (c *Thorchain) BankQuerySpendableBalances(ctx context.Context, address string) (*types.Coins, error) {
res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).SpendableBalances(ctx, &banktypes.QuerySpendableBalancesRequest{Address: address})
return &res.Balances, err
if err != nil {
return nil, err
}
return &res.Balances, nil
}

func (c *Thorchain) BankQueryTotalSupply(ctx context.Context) (*types.Coins, error) {
res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).TotalSupply(ctx, &banktypes.QueryTotalSupplyRequest{})
return &res.Supply, err
if err != nil {
return nil, err
}
return &res.Supply, nil
}

func (c *Thorchain) BankQueryTotalSupplyOf(ctx context.Context, address string) (*types.Coin, error) {
res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).SupplyOf(ctx, &banktypes.QuerySupplyOfRequest{Denom: address})

return &res.Amount, err
if err != nil {
return nil, err
}
return &res.Amount, nil
}
2 changes: 1 addition & 1 deletion chain/thorchain/thornode.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (tn *ChainNode) NewClient(addr string) error {

tn.Client = rpcClient

grpcConn, err := grpc.Dial(
grpcConn, err := grpc.NewClient(
tn.hostGRPCPort, grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion examples/thorchain/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"regexp"
"strings"

"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
)
Expand Down
Loading

0 comments on commit 77cad5d

Please sign in to comment.