From ed84d5256ab520e24857d85566208263f57f9b1d Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Tue, 7 Nov 2023 13:08:44 +0100 Subject: [PATCH 01/14] WIP: CalculateGas integration tests --- integration-tests/modules/bank_test.go | 3 +- integration-tests/pkg/client_test.go | 84 ++++++++++++++++++++++++++ pkg/client/tx.go | 5 +- x/deterministicgas/spec/README.tmpl.md | 4 +- 4 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 integration-tests/pkg/client_test.go diff --git a/integration-tests/modules/bank_test.go b/integration-tests/modules/bank_test.go index 98c7197bb..4ccad8c74 100644 --- a/integration-tests/modules/bank_test.go +++ b/integration-tests/modules/bank_test.go @@ -380,11 +380,10 @@ func TestBankSendGasEstimation(t *testing.T) { Amount: sdk.NewCoins(chain.NewCoin(amountToSend)), } - clientCtx := chain.ClientContext.WithFromAddress(sender) bankSendGas := chain.GasLimitByMsgs(&banktypes.MsgSend{}) _, estimatedGas, err := client.CalculateGas( ctx, - clientCtx, + chain.ClientContext.WithFromAddress(sender), chain.TxFactory(). WithGas(bankSendGas), msg) diff --git a/integration-tests/pkg/client_test.go b/integration-tests/pkg/client_test.go new file mode 100644 index 000000000..86ff39eb7 --- /dev/null +++ b/integration-tests/pkg/client_test.go @@ -0,0 +1,84 @@ +//go:build integrationtests + +package pkg + +import ( + "fmt" + "testing" + + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/stretchr/testify/require" + + integrationtests "github.com/CoreumFoundation/coreum/v3/integration-tests" + "github.com/CoreumFoundation/coreum/v3/pkg/client" + "github.com/CoreumFoundation/coreum/v3/testutil/integration" +) + +func TestCalculateGas(t *testing.T) { + t.Parallel() + + ctx, chain := integrationtests.NewCoreumTestingContext(t) + + sender := chain.GenAccount() + + multisigPublicKey, keyNamesSet, err := chain.GenMultisigAccount(4, 3) + require.NoError(t, err) + + multisigAddress := sdk.AccAddress(multisigPublicKey.Address()) + _ = keyNamesSet + //signer1KeyName := keyNamesSet[0] + //signer2KeyName := keyNamesSet[1] + + chain.FundAccountWithOptions(ctx, t, sender, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) + chain.FundAccountWithOptions(ctx, t, multisigAddress, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) + + tests := []struct { + name string + fromAddress sdk.AccAddress + msgs []sdk.Msg + expectedGas int + }{ + { + name: "single address send", + fromAddress: sender, + msgs: []sdk.Msg{ + &banktypes.MsgSend{ + FromAddress: sender.String(), + ToAddress: sender.String(), + Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), + }, + }, + expectedGas: 65_000 + 1*50_000 + 0*10 + (1-1)*1000, + }, + { + name: "multisig bank send", + fromAddress: multisigAddress, + msgs: []sdk.Msg{ + &banktypes.MsgSend{ + FromAddress: multisigAddress.String(), + ToAddress: multisigAddress.String(), + Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), + }, + }, + expectedGas: 65_000 + 1*50_000 + 0*10 + (3-1)*1000, // extra 2 signatures + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + _, estimatedGas, err := client.CalculateGas( + ctx, + chain.ClientContext.WithFromAddress(test.fromAddress), + chain.TxFactory(), + test.msgs..., + ) + chainEstimatedGas := chain.GasLimitByMsgs(test.msgs...) + + fmt.Printf("estimatedGas: %v\n", estimatedGas) + fmt.Printf("chainEstimatedGas: %v\n", chainEstimatedGas) + require.NoError(t, err) + require.EqualValues(t, test.expectedGas, int(estimatedGas)) + }) + } +} diff --git a/pkg/client/tx.go b/pkg/client/tx.go index 1097790ec..9c4f60cb6 100644 --- a/pkg/client/tx.go +++ b/pkg/client/tx.go @@ -104,8 +104,9 @@ func BroadcastTx(ctx context.Context, clientCtx Context, txf Factory, msgs ...sd // CalculateGas simulates the execution of a transaction and returns the // simulation response obtained by the query and the adjusted gas amount. -// -// FIXME(v47-multisig-calculate-gas-test) add test to calculate +// The main differences between our version and the one from cosmos-sdk are: +// - we respect context.Context +// - it correctly works when estimating for multisig accounts func CalculateGas(ctx context.Context, clientCtx Context, txf Factory, msgs ...sdk.Msg) (*sdktx.SimulateResponse, uint64, error) { txf, err := prepareFactory(ctx, clientCtx, txf) if err != nil { diff --git a/x/deterministicgas/spec/README.tmpl.md b/x/deterministicgas/spec/README.tmpl.md index 9cd79dd93..b91c67f76 100644 --- a/x/deterministicgas/spec/README.tmpl.md +++ b/x/deterministicgas/spec/README.tmpl.md @@ -49,7 +49,7 @@ Let's say we have a transaction with 1 messages of type signatures and the tx size is 1000 bytes, total will be: ` -TotalGas = {{ .FixedGas }} + 1 * {{ .BankSendPerCoinGas }} + 1 * {{ .SigVerifyCost }} + max(0, 1000-{{ .FreeBytes }}) * {{ .TxSizeCostPerByte }} +TotalGas = {{ .FixedGas }} + 1 * {{ .BankSendPerCoinGas }} + (1 - 1) * {{ .SigVerifyCost }} + max(0, 1000-{{ .FreeBytes }}) * {{ .TxSizeCostPerByte }} ` #### Example 2 @@ -58,7 +58,7 @@ Let's say we have a transaction with 2 messages of type signatures and the tx size is 2050 bytes, total will be: ` -TotalGas = {{ .FixedGas }} + 2 * {{ .MsgIssueGasPrice }} + 2 * {{ .SigVerifyCost }} + max(0, 2050-{{ .FreeBytes }}) * {{ .TxSizeCostPerByte }} +TotalGas = {{ .FixedGas }} + 2 * {{ .MsgIssueGasPrice }} + (2 - 1) * {{ .SigVerifyCost }} + max(0, 2050-{{ .FreeBytes }}) * {{ .TxSizeCostPerByte }} ` ## Gas Tables From 2cc07678c4ed41d9e2ef513c8f2fa3063ba7d70b Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Tue, 7 Nov 2023 16:56:59 +0100 Subject: [PATCH 02/14] wip --- integration-tests/pkg/client_test.go | 33 ++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/integration-tests/pkg/client_test.go b/integration-tests/pkg/client_test.go index 86ff39eb7..0e3bceed3 100644 --- a/integration-tests/pkg/client_test.go +++ b/integration-tests/pkg/client_test.go @@ -23,16 +23,19 @@ func TestCalculateGas(t *testing.T) { sender := chain.GenAccount() - multisigPublicKey, keyNamesSet, err := chain.GenMultisigAccount(4, 3) + multisigPublicKey1, keyNamesSet, err := chain.GenMultisigAccount(4, 3) require.NoError(t, err) + multisigAddress1 := sdk.AccAddress(multisigPublicKey1.Address()) + _ = keyNamesSet - multisigAddress := sdk.AccAddress(multisigPublicKey.Address()) + multisigPublicKey2, keyNamesSet, err := chain.GenMultisigAccount(5, 4) + require.NoError(t, err) + multisigAddress2 := sdk.AccAddress(multisigPublicKey2.Address()) _ = keyNamesSet - //signer1KeyName := keyNamesSet[0] - //signer2KeyName := keyNamesSet[1] chain.FundAccountWithOptions(ctx, t, sender, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) - chain.FundAccountWithOptions(ctx, t, multisigAddress, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) + chain.FundAccountWithOptions(ctx, t, multisigAddress1, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) + chain.FundAccountWithOptions(ctx, t, multisigAddress2, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) tests := []struct { name string @@ -53,12 +56,24 @@ func TestCalculateGas(t *testing.T) { expectedGas: 65_000 + 1*50_000 + 0*10 + (1-1)*1000, }, { - name: "multisig bank send", - fromAddress: multisigAddress, + name: "multisig 3/4 bank send", + fromAddress: multisigAddress1, + msgs: []sdk.Msg{ + &banktypes.MsgSend{ + FromAddress: multisigAddress1.String(), + ToAddress: multisigAddress1.String(), + Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), + }, + }, + expectedGas: 65_000 + 1*50_000 + 0*10 + (3-1)*1000, // extra 2 signatures + }, + { + name: "multisig 4/5 bank send", + fromAddress: multisigAddress1, msgs: []sdk.Msg{ &banktypes.MsgSend{ - FromAddress: multisigAddress.String(), - ToAddress: multisigAddress.String(), + FromAddress: multisigAddress1.String(), + ToAddress: multisigAddress1.String(), Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), }, }, From aa05082789687de20e31cf1502a74414938b0aa4 Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Tue, 7 Nov 2023 19:39:44 +0100 Subject: [PATCH 03/14] Add tests --- integration-tests/modules/auth_test.go | 152 ++++++++++++++++++++++++- integration-tests/pkg/client_test.go | 99 ---------------- pkg/client/tx.go | 14 +++ 3 files changed, 160 insertions(+), 105 deletions(-) delete mode 100644 integration-tests/pkg/client_test.go diff --git a/integration-tests/modules/auth_test.go b/integration-tests/modules/auth_test.go index e39fd93d8..725ac208e 100644 --- a/integration-tests/modules/auth_test.go +++ b/integration-tests/modules/auth_test.go @@ -8,13 +8,16 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" cosmoserrors "github.com/cosmos/cosmos-sdk/types/errors" + authztypes "github.com/cosmos/cosmos-sdk/x/authz" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/samber/lo" "github.com/stretchr/testify/require" integrationtests "github.com/CoreumFoundation/coreum/v3/integration-tests" "github.com/CoreumFoundation/coreum/v3/pkg/client" "github.com/CoreumFoundation/coreum/v3/testutil/integration" assetfttypes "github.com/CoreumFoundation/coreum/v3/x/asset/ft/types" + "github.com/CoreumFoundation/coreum/v3/x/deterministicgas" ) // TestAuthFeeLimits verifies that invalid message gas won't be accepted. @@ -128,11 +131,11 @@ func TestAuthMultisig(t *testing.T) { recipient := chain.GenAccount() amountToSendFromMultisigAccount := int64(1000) - multisigPublicKey, keyNamesSet, err := chain.GenMultisigAccount(3, 2) + signersCount := 7 + multisigTreshold := 6 + multisigPublicKey, keyNamesSet, err := chain.GenMultisigAccount(signersCount, multisigTreshold) requireT.NoError(err) multisigAddress := sdk.AccAddress(multisigPublicKey.Address()) - signer1KeyName := keyNamesSet[0] - signer2KeyName := keyNamesSet[1] bankClient := banktypes.NewQueryClient(chain.ClientContext) @@ -158,19 +161,31 @@ func TestAuthMultisig(t *testing.T) { // We do it to test simulation for multisig account. chain.TxFactory().WithSimulateAndExecute(true), bankSendMsg, - signer1KeyName) + keyNamesSet[0]) requireT.ErrorIs(err, cosmoserrors.ErrUnauthorized) t.Log("Partially signed tx executed with expected error") + _, estimatedGas, err := client.CalculateGas( + ctx, + chain.ClientContext.WithFromAddress(multisigAddress), + chain.TxFactory().WithGasAdjustment(1.0), + bankSendMsg, + ) + requireT.NoError(err) + // sign and submit with the min threshold txRes, err := chain.SignAndBroadcastMultisigTx( ctx, chain.ClientContext.WithFromAddress(multisigAddress), chain.TxFactory().WithGas(chain.GasLimitByMsgs(bankSendMsg)), bankSendMsg, - signer1KeyName, signer2KeyName) + keyNamesSet[:multisigTreshold]...) requireT.NoError(err) - t.Logf("Fully signed tx executed, txHash:%s", txRes.TxHash) + t.Logf("Fully signed tx executed, txHash:%s, gas:%d", txRes.TxHash, txRes.GasUsed) + + //requireT.Equal(txRes.GasUsed, txRes.GasWanted) // another option to reproduce is to use chain.TxFactory().WithSimulateAndExecute(true) & this assertion. + + requireT.Equal(txRes.GasUsed, int64(estimatedGas)) // this shouldn't fail. recipientBalances, err := bankClient.AllBalances(ctx, &banktypes.QueryAllBalancesRequest{ Address: recipientAddr, @@ -212,3 +227,128 @@ func TestAuthUnexpectedSequenceNumber(t *testing.T) { msg) require.True(t, cosmoserrors.ErrWrongSequence.Is(err)) } + +func TestGasEstimation(t *testing.T) { + t.Parallel() + + ctx, chain := integrationtests.NewCoreumTestingContext(t) + + sender := chain.GenAccount() + + multisigPublicKey1, _, err := chain.GenMultisigAccount(3, 2) + require.NoError(t, err) + multisigAddress1 := sdk.AccAddress(multisigPublicKey1.Address()) + + multisigPublicKey2, _, err := chain.GenMultisigAccount(7, 6) + require.NoError(t, err) + multisigAddress2 := sdk.AccAddress(multisigPublicKey2.Address()) + + dgc := deterministicgas.DefaultConfig() + + // For accounts to exist on chain we need to fund them at least with min amount (1ucore). + chain.FundAccountWithOptions(ctx, t, sender, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) + chain.FundAccountWithOptions(ctx, t, multisigAddress1, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) + chain.FundAccountWithOptions(ctx, t, multisigAddress2, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) + + //initialPayload, err := json.Marshal(moduleswasm.SimpleState{ + // Count: 1337, + //}) + //requireT.NoError(err) + //contractAddr, codeID, err := chain.Wasm.DeployAndInstantiateWASMContract( + // ctx, + // chain.TxFactory().WithSimulateAndExecute(true), + // admin, + // moduleswasm.SimpleStateWASM, + // integration.InstantiateConfig{ + // AccessType: wasmtypes.AccessTypeUnspecified, + // Payload: initialPayload, + // Label: "simple_state", + // }, + //) + //requireT.NoError(err) + //chain.Wasm.ExecuteWASMContract() + + tests := []struct { + name string + fromAddress sdk.AccAddress + msgs []sdk.Msg + expectedGas uint64 + }{ + { + name: "singlesig_bank_send", + fromAddress: sender, + msgs: []sdk.Msg{ + &banktypes.MsgSend{ + FromAddress: sender.String(), + ToAddress: sender.String(), + Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), + }, + }, + // single signature no extra bytes. + expectedGas: dgc.FixedGas + 1*deterministicgas.BankSendPerCoinGas, + }, + { + name: "multisig_2_3_bank_send", + fromAddress: multisigAddress1, + msgs: []sdk.Msg{ + &banktypes.MsgSend{ + FromAddress: multisigAddress1.String(), + ToAddress: multisigAddress1.String(), + Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), + }, + }, + // single signature no extra bytes. + // Note that multisig account and multiple signatures in a single tx are different. + // Multisig tx still has single signature which is combination of multiple signatures so gas is charged for single sig. + // Tx containing multiple signatures is a different case and gas is charged for each standalone signature. + expectedGas: dgc.FixedGas + 1*deterministicgas.BankSendPerCoinGas, + }, + // FIXME: This test fails. Probably because of bug. + //{ + // name: "multisig_6_7_bank_send", + // fromAddress: multisigAddress2, + // msgs: []sdk.Msg{ + // &banktypes.MsgSend{ + // FromAddress: multisigAddress2.String(), + // ToAddress: multisigAddress2.String(), + // Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), + // }, + // }, + // expectedGas: dgc.FixedGas + 1*deterministicgas.BankSendPerCoinGas, + // expectedGasAllowedDelta: 0, + //}, + { + name: "singlesig_auth_exec_and_bank_send", + fromAddress: sender, + msgs: []sdk.Msg{ + lo.ToPtr( + authztypes.NewMsgExec(sender, []sdk.Msg{ + &banktypes.MsgSend{ + FromAddress: sender.String(), + ToAddress: sender.String(), + Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), + }, + })), + &banktypes.MsgSend{ + FromAddress: sender.String(), + ToAddress: sender.String(), + Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), + }, + }, + // single signature no extra bytes. + expectedGas: dgc.FixedGas + 1*deterministicgas.BankSendPerCoinGas + (1*deterministicgas.AuthzExecOverhead + 1*deterministicgas.BankSendPerCoinGas), + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + _, estimatedGas, err := client.CalculateGas( + ctx, + chain.ClientContext.WithFromAddress(test.fromAddress), + chain.TxFactory(), + test.msgs..., + ) + require.NoError(t, err) + require.Equal(t, test.expectedGas, estimatedGas) + }) + } +} diff --git a/integration-tests/pkg/client_test.go b/integration-tests/pkg/client_test.go deleted file mode 100644 index 0e3bceed3..000000000 --- a/integration-tests/pkg/client_test.go +++ /dev/null @@ -1,99 +0,0 @@ -//go:build integrationtests - -package pkg - -import ( - "fmt" - "testing" - - sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/stretchr/testify/require" - - integrationtests "github.com/CoreumFoundation/coreum/v3/integration-tests" - "github.com/CoreumFoundation/coreum/v3/pkg/client" - "github.com/CoreumFoundation/coreum/v3/testutil/integration" -) - -func TestCalculateGas(t *testing.T) { - t.Parallel() - - ctx, chain := integrationtests.NewCoreumTestingContext(t) - - sender := chain.GenAccount() - - multisigPublicKey1, keyNamesSet, err := chain.GenMultisigAccount(4, 3) - require.NoError(t, err) - multisigAddress1 := sdk.AccAddress(multisigPublicKey1.Address()) - _ = keyNamesSet - - multisigPublicKey2, keyNamesSet, err := chain.GenMultisigAccount(5, 4) - require.NoError(t, err) - multisigAddress2 := sdk.AccAddress(multisigPublicKey2.Address()) - _ = keyNamesSet - - chain.FundAccountWithOptions(ctx, t, sender, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) - chain.FundAccountWithOptions(ctx, t, multisigAddress1, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) - chain.FundAccountWithOptions(ctx, t, multisigAddress2, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) - - tests := []struct { - name string - fromAddress sdk.AccAddress - msgs []sdk.Msg - expectedGas int - }{ - { - name: "single address send", - fromAddress: sender, - msgs: []sdk.Msg{ - &banktypes.MsgSend{ - FromAddress: sender.String(), - ToAddress: sender.String(), - Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), - }, - }, - expectedGas: 65_000 + 1*50_000 + 0*10 + (1-1)*1000, - }, - { - name: "multisig 3/4 bank send", - fromAddress: multisigAddress1, - msgs: []sdk.Msg{ - &banktypes.MsgSend{ - FromAddress: multisigAddress1.String(), - ToAddress: multisigAddress1.String(), - Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), - }, - }, - expectedGas: 65_000 + 1*50_000 + 0*10 + (3-1)*1000, // extra 2 signatures - }, - { - name: "multisig 4/5 bank send", - fromAddress: multisigAddress1, - msgs: []sdk.Msg{ - &banktypes.MsgSend{ - FromAddress: multisigAddress1.String(), - ToAddress: multisigAddress1.String(), - Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), - }, - }, - expectedGas: 65_000 + 1*50_000 + 0*10 + (3-1)*1000, // extra 2 signatures - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - _, estimatedGas, err := client.CalculateGas( - ctx, - chain.ClientContext.WithFromAddress(test.fromAddress), - chain.TxFactory(), - test.msgs..., - ) - chainEstimatedGas := chain.GasLimitByMsgs(test.msgs...) - - fmt.Printf("estimatedGas: %v\n", estimatedGas) - fmt.Printf("chainEstimatedGas: %v\n", chainEstimatedGas) - require.NoError(t, err) - require.EqualValues(t, test.expectedGas, int(estimatedGas)) - }) - } -} diff --git a/pkg/client/tx.go b/pkg/client/tx.go index 9c4f60cb6..f2aba4859 100644 --- a/pkg/client/tx.go +++ b/pkg/client/tx.go @@ -182,10 +182,24 @@ func CalculateGas(ctx context.Context, clientCtx Context, txf Factory, msgs ...s signature, }, }) + fmt.Printf("tx bytes len: %v\n", len(txBytes)) if err != nil { return nil, 0, errors.WithStack(err) } + txTx, err := clientCtx.TxConfig().TxDecoder()(txBytes) + if err != nil { + fmt.Printf("err: %v\n", err) + } + + txJSON, err := clientCtx.TxConfig().TxJSONEncoder()(txTx) + if err != nil { + fmt.Printf("err: %v\n", err) + } else { + _ = txJSON + fmt.Printf("txJSON: %s\n", txJSON) + } + txSvcClient := sdktx.NewServiceClient(clientCtx) simRes, err := txSvcClient.Simulate(ctx, &sdktx.SimulateRequest{ TxBytes: txBytes, From bdaf64df7556762af6495c49ed1f92dcffbf4d98 Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Wed, 8 Nov 2023 18:41:28 +0100 Subject: [PATCH 04/14] Finalize tests --- integration-tests/modules/auth_test.go | 170 ++++++++++++++++--------- x/deterministicgas/ante/ante.go | 27 +++- 2 files changed, 130 insertions(+), 67 deletions(-) diff --git a/integration-tests/modules/auth_test.go b/integration-tests/modules/auth_test.go index 725ac208e..0b9de2859 100644 --- a/integration-tests/modules/auth_test.go +++ b/integration-tests/modules/auth_test.go @@ -3,9 +3,11 @@ package modules import ( + "encoding/json" "testing" sdkmath "cosmossdk.io/math" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" sdk "github.com/cosmos/cosmos-sdk/types" cosmoserrors "github.com/cosmos/cosmos-sdk/types/errors" authztypes "github.com/cosmos/cosmos-sdk/x/authz" @@ -14,6 +16,7 @@ import ( "github.com/stretchr/testify/require" integrationtests "github.com/CoreumFoundation/coreum/v3/integration-tests" + moduleswasm "github.com/CoreumFoundation/coreum/v3/integration-tests/contracts/modules" "github.com/CoreumFoundation/coreum/v3/pkg/client" "github.com/CoreumFoundation/coreum/v3/testutil/integration" assetfttypes "github.com/CoreumFoundation/coreum/v3/x/asset/ft/types" @@ -165,27 +168,20 @@ func TestAuthMultisig(t *testing.T) { requireT.ErrorIs(err, cosmoserrors.ErrUnauthorized) t.Log("Partially signed tx executed with expected error") - _, estimatedGas, err := client.CalculateGas( - ctx, - chain.ClientContext.WithFromAddress(multisigAddress), - chain.TxFactory().WithGasAdjustment(1.0), - bankSendMsg, - ) - requireT.NoError(err) - // sign and submit with the min threshold txRes, err := chain.SignAndBroadcastMultisigTx( ctx, chain.ClientContext.WithFromAddress(multisigAddress), - chain.TxFactory().WithGas(chain.GasLimitByMsgs(bankSendMsg)), + chain.TxFactory().WithSimulateAndExecute(true), bankSendMsg, keyNamesSet[:multisigTreshold]...) requireT.NoError(err) - t.Logf("Fully signed tx executed, txHash:%s, gas:%d", txRes.TxHash, txRes.GasUsed) + t.Logf("Fully signed tx executed, txHash:%s, gasUsed:%d, gasWanted:%d", txRes.TxHash, txRes.GasUsed, txRes.GasWanted) - //requireT.Equal(txRes.GasUsed, txRes.GasWanted) // another option to reproduce is to use chain.TxFactory().WithSimulateAndExecute(true) & this assertion. - - requireT.Equal(txRes.GasUsed, int64(estimatedGas)) // this shouldn't fail. + // Real gas used might be less that estimation for multisig account because (especially when there are many signers) + // because in ConsumeTxSizeGasDecorator (cosmos-sdk@v0.47.5/x/auth/ante/basic.go:99) bytes are estimated for the worst + // case. + requireT.LessOrEqual(txRes.GasUsed, txRes.GasWanted) recipientBalances, err := bankClient.AllBalances(ctx, &banktypes.QueryAllBalancesRequest{ Address: recipientAddr, @@ -233,7 +229,7 @@ func TestGasEstimation(t *testing.T) { ctx, chain := integrationtests.NewCoreumTestingContext(t) - sender := chain.GenAccount() + singlesigAddress := chain.GenAccount() multisigPublicKey1, _, err := chain.GenMultisigAccount(3, 2) require.NoError(t, err) @@ -246,29 +242,12 @@ func TestGasEstimation(t *testing.T) { dgc := deterministicgas.DefaultConfig() // For accounts to exist on chain we need to fund them at least with min amount (1ucore). - chain.FundAccountWithOptions(ctx, t, sender, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) + chain.FundAccountWithOptions(ctx, t, singlesigAddress, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) chain.FundAccountWithOptions(ctx, t, multisigAddress1, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) chain.FundAccountWithOptions(ctx, t, multisigAddress2, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) - //initialPayload, err := json.Marshal(moduleswasm.SimpleState{ - // Count: 1337, - //}) - //requireT.NoError(err) - //contractAddr, codeID, err := chain.Wasm.DeployAndInstantiateWASMContract( - // ctx, - // chain.TxFactory().WithSimulateAndExecute(true), - // admin, - // moduleswasm.SimpleStateWASM, - // integration.InstantiateConfig{ - // AccessType: wasmtypes.AccessTypeUnspecified, - // Payload: initialPayload, - // Label: "simple_state", - // }, - //) - //requireT.NoError(err) - //chain.Wasm.ExecuteWASMContract() - - tests := []struct { + // For deterministic messages we are able to assert that gas estimation is equal to exact number. + testsDeterm := []struct { name string fromAddress sdk.AccAddress msgs []sdk.Msg @@ -276,11 +255,11 @@ func TestGasEstimation(t *testing.T) { }{ { name: "singlesig_bank_send", - fromAddress: sender, + fromAddress: singlesigAddress, msgs: []sdk.Msg{ &banktypes.MsgSend{ - FromAddress: sender.String(), - ToAddress: sender.String(), + FromAddress: singlesigAddress.String(), + ToAddress: singlesigAddress.String(), Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), }, }, @@ -298,40 +277,37 @@ func TestGasEstimation(t *testing.T) { }, }, // single signature no extra bytes. - // Note that multisig account and multiple signatures in a single tx are different. - // Multisig tx still has single signature which is combination of multiple signatures so gas is charged for single sig. - // Tx containing multiple signatures is a different case and gas is charged for each standalone signature. expectedGas: dgc.FixedGas + 1*deterministicgas.BankSendPerCoinGas, }, - // FIXME: This test fails. Probably because of bug. - //{ - // name: "multisig_6_7_bank_send", - // fromAddress: multisigAddress2, - // msgs: []sdk.Msg{ - // &banktypes.MsgSend{ - // FromAddress: multisigAddress2.String(), - // ToAddress: multisigAddress2.String(), - // Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), - // }, - // }, - // expectedGas: dgc.FixedGas + 1*deterministicgas.BankSendPerCoinGas, - // expectedGasAllowedDelta: 0, - //}, + { + name: "multisig_6_7_bank_send", + fromAddress: multisigAddress2, + msgs: []sdk.Msg{ + &banktypes.MsgSend{ + FromAddress: multisigAddress2.String(), + ToAddress: multisigAddress2.String(), + Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), + }, + }, + // estimation uses worst case to estimate number of bytes in tx which causes possible overflow of free bytes. + // 10 is price for each extra byte over FreeBytes. + expectedGas: dgc.FixedGas + 1*deterministicgas.BankSendPerCoinGas + 1133*10, + }, { name: "singlesig_auth_exec_and_bank_send", - fromAddress: sender, + fromAddress: singlesigAddress, msgs: []sdk.Msg{ lo.ToPtr( - authztypes.NewMsgExec(sender, []sdk.Msg{ + authztypes.NewMsgExec(singlesigAddress, []sdk.Msg{ &banktypes.MsgSend{ - FromAddress: sender.String(), - ToAddress: sender.String(), + FromAddress: singlesigAddress.String(), + ToAddress: singlesigAddress.String(), Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), }, })), &banktypes.MsgSend{ - FromAddress: sender.String(), - ToAddress: sender.String(), + FromAddress: singlesigAddress.String(), + ToAddress: singlesigAddress.String(), Amount: sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(1))), }, }, @@ -339,7 +315,7 @@ func TestGasEstimation(t *testing.T) { expectedGas: dgc.FixedGas + 1*deterministicgas.BankSendPerCoinGas + (1*deterministicgas.AuthzExecOverhead + 1*deterministicgas.BankSendPerCoinGas), }, } - for _, test := range tests { + for _, test := range testsDeterm { t.Run(test.name, func(t *testing.T) { _, estimatedGas, err := client.CalculateGas( ctx, @@ -348,7 +324,77 @@ func TestGasEstimation(t *testing.T) { test.msgs..., ) require.NoError(t, err) - require.Equal(t, test.expectedGas, estimatedGas) + require.Equal(t, int(test.expectedGas), int(estimatedGas)) }) } + + // For non-deterministic messages we need to deploy a contract. + // Any address could be admin since we are not going to execute it but just estimate. + admin := chain.GenAccount() + chain.FundAccountWithOptions(ctx, t, admin, integration.BalancesOptions{Amount: sdkmath.NewInt(1_000_000)}) + + initialPayload, err := json.Marshal(moduleswasm.SimpleState{ + Count: 1337, + }) + require.NoError(t, err) + contractAddr, _, err := chain.Wasm.DeployAndInstantiateWASMContract( + ctx, + chain.TxFactory().WithSimulateAndExecute(true), + admin, + moduleswasm.SimpleStateWASM, + integration.InstantiateConfig{ + AccessType: wasmtypes.AccessTypeUnspecified, + Payload: initialPayload, + Label: "simple_state", + }, + ) + require.NoError(t, err) + + wasmPayload, err := moduleswasm.MethodToEmptyBodyPayload(moduleswasm.SimpleIncrement) + require.NoError(t, err) + + // For non-deterministic messages we are unable to know exact number, so we do just basic assertion. + testsNonDeterm := []struct { + name string + fromAddress sdk.AccAddress + msgs []sdk.Msg + }{ + { + name: "singlesig_wasm_execute_contract", + fromAddress: singlesigAddress, + msgs: []sdk.Msg{ + &wasmtypes.MsgExecuteContract{ + Sender: singlesigAddress.String(), + Contract: contractAddr, + Msg: wasmtypes.RawContractMessage(wasmPayload), + Funds: sdk.Coins{}, + }, + }, + }, + { + name: "multisig_2_3_wasm_execute_contract", + fromAddress: multisigAddress1, + msgs: []sdk.Msg{ + &wasmtypes.MsgExecuteContract{ + Sender: multisigAddress1.String(), + Contract: contractAddr, + Msg: wasmtypes.RawContractMessage(wasmPayload), + Funds: sdk.Coins{}, + }, + }, + }, + } + for _, test := range testsNonDeterm { + t.Run(test.name, func(t *testing.T) { + _, estimatedGas, err := client.CalculateGas( + ctx, + chain.ClientContext.WithFromAddress(test.fromAddress), + chain.TxFactory(), + test.msgs..., + ) + require.NoError(t, err) + require.Greater(t, int(estimatedGas), 0) + }) + } + } diff --git a/x/deterministicgas/ante/ante.go b/x/deterministicgas/ante/ante.go index ccbd6be1c..dd4227613 100644 --- a/x/deterministicgas/ante/ante.go +++ b/x/deterministicgas/ante/ante.go @@ -1,12 +1,27 @@ package ante import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/CoreumFoundation/coreum/v3/x/deterministicgas" ) +type debuggingGasMeter struct { + sdk.GasMeter +} + +func newDGM(g sdk.GasMeter) debuggingGasMeter { + return debuggingGasMeter{g} +} + +func (d debuggingGasMeter) ConsumeGas(amount sdk.Gas, descriptor string) { + fmt.Printf("Consumig gas descriptor: %q, amount: %d\n", descriptor, amount) + d.GasMeter.ConsumeGas(amount, descriptor) +} + // SetInfiniteGasMeterDecorator sets the infinite gas limit for ante handler // CONTRACT: Must be the first decorator in the chain. // CONTRACT: Tx must implement GasTx interface. @@ -28,7 +43,7 @@ func (sigmd SetInfiniteGasMeterDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, ctx.GasMeter().ConsumeGas(sigmd.deterministicGasConfig.FixedGas, "Fixed") // Set infinite gas meter for ante handler - return next(ctx.WithGasMeter(sdk.NewInfiniteGasMeter()), tx, simulate) + return next(ctx.WithGasMeter(newDGM(sdk.NewInfiniteGasMeter())), tx, simulate) } // AddBaseGasDecorator adds free gas to gas meter. @@ -52,14 +67,14 @@ func (abgd AddBaseGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate if simulate || ctx.BlockHeight() == 0 { // During simulation and genesis initialization infinite gas meter is set inside context by `SetUpContextDecorator`. // Here, we reset it to initial state with 0 gas consumed. - gasMeter = sdk.NewInfiniteGasMeter() + gasMeter = newDGM(sdk.NewInfiniteGasMeter()) } else { params := abgd.ak.GetParams(ctx) // It is not needed to verify that tx really implements `GasTx` interface because it has been already done by // `SetUpContextDecorator` gasTx := tx.(authante.GasTx) - gasMeter = sdk.NewGasMeter(gasTx.GetGas() + abgd.deterministicGasConfig.TxBaseGas(params)) + gasMeter = newDGM(sdk.NewGasMeter(gasTx.GetGas() + abgd.deterministicGasConfig.TxBaseGas(params))) } return next(ctx.WithGasMeter(gasMeter), tx, simulate) } @@ -91,9 +106,9 @@ func (cfgd ChargeFixedGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul if simulate || ctx.BlockHeight() == 0 { // During simulation and genesis initialization infinite gas meter is set inside context by `SetUpContextDecorator`. // We reset it to initial state with 0 gas consumed. - gasMeter = sdk.NewInfiniteGasMeter() + gasMeter = newDGM(sdk.NewInfiniteGasMeter()) } else { - gasMeter = sdk.NewGasMeter(gasTx.GetGas()) + gasMeter = newDGM(sdk.NewGasMeter(gasTx.GetGas())) } gasConsumed := ctx.GasMeter().GasConsumed() @@ -103,5 +118,7 @@ func (cfgd ChargeFixedGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul } gasMeter.ConsumeGas(cfgd.deterministicGasConfig.FixedGas, "Fixed") + fmt.Printf("ChargeFixedGasDecorator: simulate: %v\n. gasMeter: %v\n", simulate, gasMeter.String()) + return next(ctx.WithGasMeter(gasMeter), tx, simulate) } From 5bd6bcd372e0972f76138eb9648fdbc52a58ae04 Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Wed, 8 Nov 2023 18:43:43 +0100 Subject: [PATCH 05/14] reset debug code --- pkg/client/tx.go | 16 +--------------- x/deterministicgas/ante/ante.go | 27 +++++---------------------- 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/pkg/client/tx.go b/pkg/client/tx.go index f2aba4859..74d45ae90 100644 --- a/pkg/client/tx.go +++ b/pkg/client/tx.go @@ -182,24 +182,10 @@ func CalculateGas(ctx context.Context, clientCtx Context, txf Factory, msgs ...s signature, }, }) - fmt.Printf("tx bytes len: %v\n", len(txBytes)) if err != nil { return nil, 0, errors.WithStack(err) } - txTx, err := clientCtx.TxConfig().TxDecoder()(txBytes) - if err != nil { - fmt.Printf("err: %v\n", err) - } - - txJSON, err := clientCtx.TxConfig().TxJSONEncoder()(txTx) - if err != nil { - fmt.Printf("err: %v\n", err) - } else { - _ = txJSON - fmt.Printf("txJSON: %s\n", txJSON) - } - txSvcClient := sdktx.NewServiceClient(clientCtx) simRes, err := txSvcClient.Simulate(ctx, &sdktx.SimulateRequest{ TxBytes: txBytes, @@ -327,7 +313,7 @@ func AwaitNextBlocks( if res.SdkBlock != nil { currentHeight = res.SdkBlock.Header.Height } else { - // TODO: Remove this in v4 version of cored. Now it is needed because we might still use it in integration tests together with v2 cored binary. + // TODO(v4): Remove this in v4 version of cored. Now it is needed because we might still use it in integration tests together with v2 cored binary. currentHeight = res.Block.Header.Height //nolint:staticcheck // Yes, we know that this is deprecated } diff --git a/x/deterministicgas/ante/ante.go b/x/deterministicgas/ante/ante.go index dd4227613..ccbd6be1c 100644 --- a/x/deterministicgas/ante/ante.go +++ b/x/deterministicgas/ante/ante.go @@ -1,27 +1,12 @@ package ante import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/CoreumFoundation/coreum/v3/x/deterministicgas" ) -type debuggingGasMeter struct { - sdk.GasMeter -} - -func newDGM(g sdk.GasMeter) debuggingGasMeter { - return debuggingGasMeter{g} -} - -func (d debuggingGasMeter) ConsumeGas(amount sdk.Gas, descriptor string) { - fmt.Printf("Consumig gas descriptor: %q, amount: %d\n", descriptor, amount) - d.GasMeter.ConsumeGas(amount, descriptor) -} - // SetInfiniteGasMeterDecorator sets the infinite gas limit for ante handler // CONTRACT: Must be the first decorator in the chain. // CONTRACT: Tx must implement GasTx interface. @@ -43,7 +28,7 @@ func (sigmd SetInfiniteGasMeterDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, ctx.GasMeter().ConsumeGas(sigmd.deterministicGasConfig.FixedGas, "Fixed") // Set infinite gas meter for ante handler - return next(ctx.WithGasMeter(newDGM(sdk.NewInfiniteGasMeter())), tx, simulate) + return next(ctx.WithGasMeter(sdk.NewInfiniteGasMeter()), tx, simulate) } // AddBaseGasDecorator adds free gas to gas meter. @@ -67,14 +52,14 @@ func (abgd AddBaseGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate if simulate || ctx.BlockHeight() == 0 { // During simulation and genesis initialization infinite gas meter is set inside context by `SetUpContextDecorator`. // Here, we reset it to initial state with 0 gas consumed. - gasMeter = newDGM(sdk.NewInfiniteGasMeter()) + gasMeter = sdk.NewInfiniteGasMeter() } else { params := abgd.ak.GetParams(ctx) // It is not needed to verify that tx really implements `GasTx` interface because it has been already done by // `SetUpContextDecorator` gasTx := tx.(authante.GasTx) - gasMeter = newDGM(sdk.NewGasMeter(gasTx.GetGas() + abgd.deterministicGasConfig.TxBaseGas(params))) + gasMeter = sdk.NewGasMeter(gasTx.GetGas() + abgd.deterministicGasConfig.TxBaseGas(params)) } return next(ctx.WithGasMeter(gasMeter), tx, simulate) } @@ -106,9 +91,9 @@ func (cfgd ChargeFixedGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul if simulate || ctx.BlockHeight() == 0 { // During simulation and genesis initialization infinite gas meter is set inside context by `SetUpContextDecorator`. // We reset it to initial state with 0 gas consumed. - gasMeter = newDGM(sdk.NewInfiniteGasMeter()) + gasMeter = sdk.NewInfiniteGasMeter() } else { - gasMeter = newDGM(sdk.NewGasMeter(gasTx.GetGas())) + gasMeter = sdk.NewGasMeter(gasTx.GetGas()) } gasConsumed := ctx.GasMeter().GasConsumed() @@ -118,7 +103,5 @@ func (cfgd ChargeFixedGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul } gasMeter.ConsumeGas(cfgd.deterministicGasConfig.FixedGas, "Fixed") - fmt.Printf("ChargeFixedGasDecorator: simulate: %v\n. gasMeter: %v\n", simulate, gasMeter.String()) - return next(ctx.WithGasMeter(gasMeter), tx, simulate) } From 8f6a8908f0637da92c351d76cea62b11b3c9afb8 Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Wed, 8 Nov 2023 18:45:56 +0100 Subject: [PATCH 06/14] regen --- x/deterministicgas/spec/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/deterministicgas/spec/README.md b/x/deterministicgas/spec/README.md index c93a4f769..4d1823dc4 100644 --- a/x/deterministicgas/spec/README.md +++ b/x/deterministicgas/spec/README.md @@ -50,7 +50,7 @@ Let's say we have a transaction with 1 messages of type signatures and the tx size is 1000 bytes, total will be: ` -TotalGas = 65000 + 1 * 50000 + 1 * 1000 + max(0, 1000-2048) * 10 +TotalGas = 65000 + 1 * 50000 + (1 - 1) * 1000 + max(0, 1000-2048) * 10 ` #### Example 2 @@ -59,7 +59,7 @@ Let's say we have a transaction with 2 messages of type signatures and the tx size is 2050 bytes, total will be: ` -TotalGas = 65000 + 2 * 70000 + 2 * 1000 + max(0, 2050-2048) * 10 +TotalGas = 65000 + 2 * 70000 + (2 - 1) * 1000 + max(0, 2050-2048) * 10 ` ## Gas Tables From a43de1c33b0ee4b916b1beea3d36259a2b92efab Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Thu, 9 Nov 2023 11:25:44 +0100 Subject: [PATCH 07/14] Improve test --- integration-tests/modules/auth_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/integration-tests/modules/auth_test.go b/integration-tests/modules/auth_test.go index 0b9de2859..8a1e66c56 100644 --- a/integration-tests/modules/auth_test.go +++ b/integration-tests/modules/auth_test.go @@ -10,6 +10,7 @@ import ( wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" sdk "github.com/cosmos/cosmos-sdk/types" cosmoserrors "github.com/cosmos/cosmos-sdk/types/errors" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authztypes "github.com/cosmos/cosmos-sdk/x/authz" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/samber/lo" @@ -240,6 +241,8 @@ func TestGasEstimation(t *testing.T) { multisigAddress2 := sdk.AccAddress(multisigPublicKey2.Address()) dgc := deterministicgas.DefaultConfig() + authParams, err := authtypes.NewQueryClient(chain.ClientContext).Params(ctx, &authtypes.QueryParamsRequest{}) + require.NoError(t, err) // For accounts to exist on chain we need to fund them at least with min amount (1ucore). chain.FundAccountWithOptions(ctx, t, singlesigAddress, integration.BalancesOptions{Amount: sdkmath.NewInt(1)}) @@ -291,7 +294,7 @@ func TestGasEstimation(t *testing.T) { }, // estimation uses worst case to estimate number of bytes in tx which causes possible overflow of free bytes. // 10 is price for each extra byte over FreeBytes. - expectedGas: dgc.FixedGas + 1*deterministicgas.BankSendPerCoinGas + 1133*10, + expectedGas: dgc.FixedGas + 1*deterministicgas.BankSendPerCoinGas + 1133*authParams.Params.TxSizeCostPerByte, }, { name: "singlesig_auth_exec_and_bank_send", From 88ad4d570a0a67bbad5bd3a902d0a5087249a9a7 Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Thu, 9 Nov 2023 11:54:21 +0100 Subject: [PATCH 08/14] fix --- integration-tests/modules/auth_test.go | 32 ++++++++++++++++++-------- pkg/client/tx.go | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/integration-tests/modules/auth_test.go b/integration-tests/modules/auth_test.go index 8a1e66c56..3ef20688b 100644 --- a/integration-tests/modules/auth_test.go +++ b/integration-tests/modules/auth_test.go @@ -133,7 +133,7 @@ func TestAuthMultisig(t *testing.T) { ctx, chain := integrationtests.NewCoreumTestingContext(t) requireT := require.New(t) recipient := chain.GenAccount() - amountToSendFromMultisigAccount := int64(1000) + amountToSendFromMultisigAccount := int64(1_000_000) signersCount := 7 multisigTreshold := 6 @@ -141,14 +141,12 @@ func TestAuthMultisig(t *testing.T) { requireT.NoError(err) multisigAddress := sdk.AccAddress(multisigPublicKey.Address()) - bankClient := banktypes.NewQueryClient(chain.ClientContext) - - // fund the multisig account chain.FundAccountWithOptions(ctx, t, multisigAddress, integration.BalancesOptions{ - Messages: []sdk.Msg{&banktypes.MsgSend{}}, - Amount: sdkmath.NewInt(amountToSendFromMultisigAccount), + Amount: sdkmath.NewInt(amountToSendFromMultisigAccount), // for gas estimation to work wee need account to exist on chain so we fund it with to be sent amount. }) + bankClient := banktypes.NewQueryClient(chain.ClientContext) + // prepare account to be funded from the multisig recipientAddr := recipient.String() coinsToSendToRecipient := sdk.NewCoins(chain.NewCoin(sdkmath.NewInt(amountToSendFromMultisigAccount))) @@ -158,6 +156,20 @@ func TestAuthMultisig(t *testing.T) { ToAddress: recipientAddr, Amount: coinsToSendToRecipient, } + + _, gasEstimation, err := client.CalculateGas( + ctx, + chain.ClientContext.WithFromAddress(multisigAddress), + chain.TxFactory(), + bankSendMsg, + ) + requireT.NoError(err) + + // fund the multisig account + chain.FundAccountWithOptions(ctx, t, multisigAddress, integration.BalancesOptions{ + Amount: sdkmath.NewInt(int64(gasEstimation)), // because of 6/7 multisig gas exceeds FixedGas, and we need to fund it to pay fees. + }) + _, err = chain.SignAndBroadcastMultisigTx( ctx, chain.ClientContext.WithFromAddress(multisigAddress), @@ -179,10 +191,10 @@ func TestAuthMultisig(t *testing.T) { requireT.NoError(err) t.Logf("Fully signed tx executed, txHash:%s, gasUsed:%d, gasWanted:%d", txRes.TxHash, txRes.GasUsed, txRes.GasWanted) - // Real gas used might be less that estimation for multisig account because (especially when there are many signers) - // because in ConsumeTxSizeGasDecorator (cosmos-sdk@v0.47.5/x/auth/ante/basic.go:99) bytes are estimated for the worst - // case. - requireT.LessOrEqual(txRes.GasUsed, txRes.GasWanted) + // Real gas used might be less that estimation for multisig account (especially when there are many signers) + // because in ConsumeTxSizeGasDecorator (cosmos-sdk@v0.47.5/x/auth/ante/basic.go:99) amount of bytes is estimated + // for the worst case. + requireT.LessOrEqual(txRes.GasUsed, int64(gasEstimation)) recipientBalances, err := bankClient.AllBalances(ctx, &banktypes.QueryAllBalancesRequest{ Address: recipientAddr, diff --git a/pkg/client/tx.go b/pkg/client/tx.go index 74d45ae90..419957d48 100644 --- a/pkg/client/tx.go +++ b/pkg/client/tx.go @@ -106,7 +106,7 @@ func BroadcastTx(ctx context.Context, clientCtx Context, txf Factory, msgs ...sd // simulation response obtained by the query and the adjusted gas amount. // The main differences between our version and the one from cosmos-sdk are: // - we respect context.Context -// - it correctly works when estimating for multisig accounts +// - it works when estimating for multisig accounts. func CalculateGas(ctx context.Context, clientCtx Context, txf Factory, msgs ...sdk.Msg) (*sdktx.SimulateResponse, uint64, error) { txf, err := prepareFactory(ctx, clientCtx, txf) if err != nil { From 4432869f2767536f33cd4d1af3b44e37650e9ace Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Fri, 10 Nov 2023 13:32:14 +0100 Subject: [PATCH 09/14] finalize --- x/deterministicgas/ante/ante.go | 25 ++++++++++++++++++++----- x/deterministicgas/spec/README.md | 21 +++++++++++++-------- x/deterministicgas/spec/README.tmpl.md | 21 +++++++++++++-------- x/deterministicgas/spec/generate.go | 7 +++++-- 4 files changed, 51 insertions(+), 23 deletions(-) diff --git a/x/deterministicgas/ante/ante.go b/x/deterministicgas/ante/ante.go index ccbd6be1c..eef32a302 100644 --- a/x/deterministicgas/ante/ante.go +++ b/x/deterministicgas/ante/ante.go @@ -1,12 +1,27 @@ package ante import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/CoreumFoundation/coreum/v3/x/deterministicgas" ) +type debugGasMeter struct { + sdk.GasMeter +} + +func newDBG(g sdk.GasMeter) debugGasMeter { + return debugGasMeter{g} +} + +func (dbg debugGasMeter) ConsumeGas(amount sdk.Gas, descriptor string) { + fmt.Printf("dbg gas: %v descriptor: %v\n", amount, descriptor) + dbg.GasMeter.ConsumeGas(amount, descriptor) +} + // SetInfiniteGasMeterDecorator sets the infinite gas limit for ante handler // CONTRACT: Must be the first decorator in the chain. // CONTRACT: Tx must implement GasTx interface. @@ -28,7 +43,7 @@ func (sigmd SetInfiniteGasMeterDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, ctx.GasMeter().ConsumeGas(sigmd.deterministicGasConfig.FixedGas, "Fixed") // Set infinite gas meter for ante handler - return next(ctx.WithGasMeter(sdk.NewInfiniteGasMeter()), tx, simulate) + return next(ctx.WithGasMeter(newDBG(sdk.NewInfiniteGasMeter())), tx, simulate) } // AddBaseGasDecorator adds free gas to gas meter. @@ -52,14 +67,14 @@ func (abgd AddBaseGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate if simulate || ctx.BlockHeight() == 0 { // During simulation and genesis initialization infinite gas meter is set inside context by `SetUpContextDecorator`. // Here, we reset it to initial state with 0 gas consumed. - gasMeter = sdk.NewInfiniteGasMeter() + gasMeter = newDBG(sdk.NewInfiniteGasMeter()) } else { params := abgd.ak.GetParams(ctx) // It is not needed to verify that tx really implements `GasTx` interface because it has been already done by // `SetUpContextDecorator` gasTx := tx.(authante.GasTx) - gasMeter = sdk.NewGasMeter(gasTx.GetGas() + abgd.deterministicGasConfig.TxBaseGas(params)) + gasMeter = newDBG(sdk.NewGasMeter(gasTx.GetGas() + abgd.deterministicGasConfig.TxBaseGas(params))) } return next(ctx.WithGasMeter(gasMeter), tx, simulate) } @@ -91,9 +106,9 @@ func (cfgd ChargeFixedGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul if simulate || ctx.BlockHeight() == 0 { // During simulation and genesis initialization infinite gas meter is set inside context by `SetUpContextDecorator`. // We reset it to initial state with 0 gas consumed. - gasMeter = sdk.NewInfiniteGasMeter() + gasMeter = newDBG(sdk.NewInfiniteGasMeter()) } else { - gasMeter = sdk.NewGasMeter(gasTx.GetGas()) + gasMeter = newDBG(sdk.NewGasMeter(gasTx.GetGas())) } gasConsumed := ctx.GasMeter().GasConsumed() diff --git a/x/deterministicgas/spec/README.md b/x/deterministicgas/spec/README.md index 4d1823dc4..fc9a439db 100644 --- a/x/deterministicgas/spec/README.md +++ b/x/deterministicgas/spec/README.md @@ -16,31 +16,36 @@ complicated, nondeterministic execution path (e.g `/cosmwasm.wasm.v1.MsgExecuteC Here is formula for the transaction ` -Gas = FixedGas + Sum(Gas for each message) + GasForExtraBytes + GasForExtraSignatures +Gas = FixedGas + max((GasForBytes + GasForSignatures - TxBaseGas), 0) + Sum(Gas for each message) ` If message type is deterministic, then the value is looked up from the table, if it is non-deterministic, then the required gas is determined after the execution. ` -GasForExtraBytes = max(0, TxByteSize-FreeBytes) * TxSizeCostPerByte +GasForBytes = TxByteSize * TxSizeCostPerByte ` ` -GasForExtraSignatures = max(0, NumOfSigs-FreeSigs) * SigVerifyCost +GasForSignatures = NumOfSigs * SigVerifyCost ` Currently, we have values for the above variables as follows: - `FixedGas`: 65000 +- `TxBaseGas`: 21480 - `SigVerifyCost`: 1000 - `TxSizeCostPerByte`: 10 - `FreeSignatures`: 1 - `FreeBytes`: 2048 -As an example if the transaction has 1 signature on it and is below -2048 bytes, the user will not pay anything extra, and if one of those values exceed those limits, the user will pay for -the extra resources. + +To summarize user pays FixedGas as long as `GasForBytes + GasForSignatures <= TxBaseGas`. +If `GasForBytes + GasForSignatures > TxBaseGas` user will have to pay anything above `TxBaseGas` on top of `FixedGas`. + +As an example if the transaction has 1 signature on it and size is below +2048 bytes, the user will not pay anything extra. Or user can have multiple signatures but fewer bytes then nothing extra should be paid. + ### Full examples @@ -50,7 +55,7 @@ Let's say we have a transaction with 1 messages of type signatures and the tx size is 1000 bytes, total will be: ` -TotalGas = 65000 + 1 * 50000 + (1 - 1) * 1000 + max(0, 1000-2048) * 10 +TotalGas = 65000 + max(0, (21480 - 1 * 1000 + 1000 * 10)) + 1 * 50000 ` #### Example 2 @@ -59,7 +64,7 @@ Let's say we have a transaction with 2 messages of type signatures and the tx size is 2050 bytes, total will be: ` -TotalGas = 65000 + 2 * 70000 + (2 - 1) * 1000 + max(0, 2050-2048) * 10 +TotalGas = 65000 + max(0, (21480 - 2 * 1000 + 2050 * 10)) + 2 * 70000 ` ## Gas Tables diff --git a/x/deterministicgas/spec/README.tmpl.md b/x/deterministicgas/spec/README.tmpl.md index b91c67f76..ff6767282 100644 --- a/x/deterministicgas/spec/README.tmpl.md +++ b/x/deterministicgas/spec/README.tmpl.md @@ -15,31 +15,36 @@ complicated, nondeterministic execution path (e.g `/cosmwasm.wasm.v1.MsgExecuteC Here is formula for the transaction ` -Gas = FixedGas + Sum(Gas for each message) + GasForExtraBytes + GasForExtraSignatures +Gas = FixedGas + max((GasForBytes + GasForSignatures - TxBaseGas), 0) + Sum(Gas for each message) ` If message type is deterministic, then the value is looked up from the table, if it is non-deterministic, then the required gas is determined after the execution. ` -GasForExtraBytes = max(0, TxByteSize-FreeBytes) * TxSizeCostPerByte +GasForBytes = TxByteSize * TxSizeCostPerByte ` ` -GasForExtraSignatures = max(0, NumOfSigs-FreeSigs) * SigVerifyCost +GasForSignatures = NumOfSigs * SigVerifyCost ` Currently, we have values for the above variables as follows: - `FixedGas`: {{ .FixedGas }} +- `TxBaseGas`: {{ .TxBaseGas }} - `SigVerifyCost`: {{ .SigVerifyCost }} - `TxSizeCostPerByte`: {{ .TxSizeCostPerByte }} - `FreeSignatures`: {{ .FreeSignatures }} - `FreeBytes`: {{ .FreeBytes }} -As an example if the transaction has 1 signature on it and is below -2048 bytes, the user will not pay anything extra, and if one of those values exceed those limits, the user will pay for -the extra resources. + +To summarize user pays FixedGas as long as `GasForBytes + GasForSignatures <= TxBaseGas`. +If `GasForBytes + GasForSignatures > TxBaseGas` user will have to pay anything above `TxBaseGas` on top of `FixedGas`. + +As an example if the transaction has 1 signature on it and size is below +2048 bytes, the user will not pay anything extra. Or user can have multiple signatures but fewer bytes then nothing extra should be paid. + ### Full examples @@ -49,7 +54,7 @@ Let's say we have a transaction with 1 messages of type signatures and the tx size is 1000 bytes, total will be: ` -TotalGas = {{ .FixedGas }} + 1 * {{ .BankSendPerCoinGas }} + (1 - 1) * {{ .SigVerifyCost }} + max(0, 1000-{{ .FreeBytes }}) * {{ .TxSizeCostPerByte }} +TotalGas = {{ .FixedGas }} + max(0, ({{ .TxBaseGas }} - 1 * {{ .SigVerifyCost }} + 1000 * {{ .TxSizeCostPerByte }})) + 1 * {{ .BankSendPerCoinGas }} ` #### Example 2 @@ -58,7 +63,7 @@ Let's say we have a transaction with 2 messages of type signatures and the tx size is 2050 bytes, total will be: ` -TotalGas = {{ .FixedGas }} + 2 * {{ .MsgIssueGasPrice }} + (2 - 1) * {{ .SigVerifyCost }} + max(0, 2050-{{ .FreeBytes }}) * {{ .TxSizeCostPerByte }} +TotalGas = {{ .FixedGas }} + max(0, ({{ .TxBaseGas }} - 2 * {{ .SigVerifyCost }} + 2050 * {{ .TxSizeCostPerByte }})) + 2 * {{ .MsgIssueGasPrice }} ` ## Gas Tables diff --git a/x/deterministicgas/spec/generate.go b/x/deterministicgas/spec/generate.go index ac1257b81..c17e6462e 100644 --- a/x/deterministicgas/spec/generate.go +++ b/x/deterministicgas/spec/generate.go @@ -73,11 +73,13 @@ func main() { panic(err) } + authParams := auth.DefaultParams() err = template.Must(template.New("README.md").Parse(readmeTmpl)).Execute(file, struct { GeneratorComment string SigVerifyCost uint64 TxSizeCostPerByte uint64 FixedGas uint64 + TxBaseGas uint64 FreeBytes uint64 FreeSignatures uint64 @@ -95,8 +97,9 @@ func main() { }{ GeneratorComment: generatorComment, FixedGas: cfg.FixedGas, - SigVerifyCost: auth.DefaultSigVerifyCostSecp256k1, - TxSizeCostPerByte: auth.DefaultTxSizeCostPerByte, + TxBaseGas: cfg.TxBaseGas(authParams), + SigVerifyCost: authParams.SigVerifyCostSecp256k1, + TxSizeCostPerByte: authParams.TxSizeCostPerByte, FreeBytes: cfg.FreeBytes, FreeSignatures: cfg.FreeSignatures, From e78d0c46898ec026aed620e216519a7e47e2573c Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Fri, 10 Nov 2023 13:33:24 +0100 Subject: [PATCH 10/14] Add ante with DGB & replace cosmos-sdk --- go.mod | 2 ++ go.sum | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 0a6249f6f..5c2077ed9 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,8 @@ go 1.20 replace ( // cosmos keyring github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 + + github.com/cosmos/cosmos-sdk => ../misc/cosmos-sdk // dgrijalva/jwt-go is deprecated and doesn't receive security updates. // TODO(v4): remove it: https://github.com/cosmos/cosmos-sdk/issues/13134 github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 diff --git a/go.sum b/go.sum index a678c5799..fb62745c7 100644 --- a/go.sum +++ b/go.sum @@ -399,8 +399,6 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.47.5 h1:n1+WjP/VM/gAEOx3TqU2/Ny734rj/MX1kpUnn7zVJP8= -github.com/cosmos/cosmos-sdk v0.47.5/go.mod h1:EHwCeN9IXonsjKcjpS12MqeStdZvIdxt3VYXhus3G3c= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= From 59c0820adbd4c8ccfea0a64f6fe21b4884b2cc82 Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Fri, 10 Nov 2023 13:34:35 +0100 Subject: [PATCH 11/14] Reset --- x/deterministicgas/ante/ante.go | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/x/deterministicgas/ante/ante.go b/x/deterministicgas/ante/ante.go index eef32a302..ccbd6be1c 100644 --- a/x/deterministicgas/ante/ante.go +++ b/x/deterministicgas/ante/ante.go @@ -1,27 +1,12 @@ package ante import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/CoreumFoundation/coreum/v3/x/deterministicgas" ) -type debugGasMeter struct { - sdk.GasMeter -} - -func newDBG(g sdk.GasMeter) debugGasMeter { - return debugGasMeter{g} -} - -func (dbg debugGasMeter) ConsumeGas(amount sdk.Gas, descriptor string) { - fmt.Printf("dbg gas: %v descriptor: %v\n", amount, descriptor) - dbg.GasMeter.ConsumeGas(amount, descriptor) -} - // SetInfiniteGasMeterDecorator sets the infinite gas limit for ante handler // CONTRACT: Must be the first decorator in the chain. // CONTRACT: Tx must implement GasTx interface. @@ -43,7 +28,7 @@ func (sigmd SetInfiniteGasMeterDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, ctx.GasMeter().ConsumeGas(sigmd.deterministicGasConfig.FixedGas, "Fixed") // Set infinite gas meter for ante handler - return next(ctx.WithGasMeter(newDBG(sdk.NewInfiniteGasMeter())), tx, simulate) + return next(ctx.WithGasMeter(sdk.NewInfiniteGasMeter()), tx, simulate) } // AddBaseGasDecorator adds free gas to gas meter. @@ -67,14 +52,14 @@ func (abgd AddBaseGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate if simulate || ctx.BlockHeight() == 0 { // During simulation and genesis initialization infinite gas meter is set inside context by `SetUpContextDecorator`. // Here, we reset it to initial state with 0 gas consumed. - gasMeter = newDBG(sdk.NewInfiniteGasMeter()) + gasMeter = sdk.NewInfiniteGasMeter() } else { params := abgd.ak.GetParams(ctx) // It is not needed to verify that tx really implements `GasTx` interface because it has been already done by // `SetUpContextDecorator` gasTx := tx.(authante.GasTx) - gasMeter = newDBG(sdk.NewGasMeter(gasTx.GetGas() + abgd.deterministicGasConfig.TxBaseGas(params))) + gasMeter = sdk.NewGasMeter(gasTx.GetGas() + abgd.deterministicGasConfig.TxBaseGas(params)) } return next(ctx.WithGasMeter(gasMeter), tx, simulate) } @@ -106,9 +91,9 @@ func (cfgd ChargeFixedGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul if simulate || ctx.BlockHeight() == 0 { // During simulation and genesis initialization infinite gas meter is set inside context by `SetUpContextDecorator`. // We reset it to initial state with 0 gas consumed. - gasMeter = newDBG(sdk.NewInfiniteGasMeter()) + gasMeter = sdk.NewInfiniteGasMeter() } else { - gasMeter = newDBG(sdk.NewGasMeter(gasTx.GetGas())) + gasMeter = sdk.NewGasMeter(gasTx.GetGas()) } gasConsumed := ctx.GasMeter().GasConsumed() From 15e55682eb7c33880a991485d63b86010103461c Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Fri, 10 Nov 2023 13:35:42 +0100 Subject: [PATCH 12/14] reset go.mod --- go.mod | 46 +++++++++++++++--------------- go.sum | 89 +++++++++++++++++++++++++++++----------------------------- 2 files changed, 67 insertions(+), 68 deletions(-) diff --git a/go.mod b/go.mod index 5c2077ed9..2967705e1 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,6 @@ go 1.20 replace ( // cosmos keyring github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 - - github.com/cosmos/cosmos-sdk => ../misc/cosmos-sdk // dgrijalva/jwt-go is deprecated and doesn't receive security updates. // TODO(v4): remove it: https://github.com/cosmos/cosmos-sdk/issues/13134 github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 @@ -38,8 +36,8 @@ require ( github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.8.4 - google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a - google.golang.org/grpc v1.59.0 + google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e + google.golang.org/grpc v1.57.0 ) require ( @@ -53,10 +51,10 @@ require ( ) require ( - cloud.google.com/go v0.110.8 // indirect - cloud.google.com/go/compute v1.23.1 // indirect + cloud.google.com/go v0.110.4 // indirect + cloud.google.com/go/compute v1.20.1 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v1.1.3 // indirect + cloud.google.com/go/iam v1.1.0 // indirect cloud.google.com/go/storage v1.30.1 // indirect cosmossdk.io/core v0.6.1 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect @@ -85,7 +83,7 @@ require ( github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v0.20.0 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect - github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect + github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect github.com/creachadair/taskgroup v0.4.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect @@ -106,7 +104,7 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.1.2 // indirect + github.com/golang/glog v1.1.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/snappy v0.0.4 // indirect @@ -115,9 +113,9 @@ require ( github.com/google/gofuzz v1.2.0 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/google/s2a-go v0.1.4 // indirect - github.com/google/uuid v1.3.1 - github.com/googleapis/enterprise-certificate-proxy v0.2.4 // indirect - github.com/googleapis/gax-go/v2 v2.12.0 // indirect + github.com/google/uuid v1.3.0 + github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect + github.com/googleapis/gax-go/v2 v2.11.0 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect @@ -175,24 +173,24 @@ require ( github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.6.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect - github.com/zondax/hid v0.9.2 // indirect - github.com/zondax/ledger-go v0.14.3 // indirect + github.com/zondax/hid v0.9.1 // indirect + github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect - golang.org/x/crypto v0.14.0 // indirect + golang.org/x/crypto v0.11.0 // indirect golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/oauth2 v0.11.0 // indirect - golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/net v0.12.0 // indirect + golang.org/x/oauth2 v0.10.0 // indirect + golang.org/x/sync v0.2.0 // indirect + golang.org/x/sys v0.11.0 // indirect + golang.org/x/term v0.10.0 // indirect + golang.org/x/text v0.12.0 // indirect golang.org/x/tools v0.7.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/api v0.128.0 // indirect + google.golang.org/api v0.126.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect + google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e // indirect google.golang.org/protobuf v1.31.0 gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index fb62745c7..c34dbf107 100644 --- a/go.sum +++ b/go.sum @@ -34,8 +34,8 @@ cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w9 cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= -cloud.google.com/go v0.110.8 h1:tyNdfIxjzaWctIiLYOTalaLKZ17SI44SKFW26QbOhME= -cloud.google.com/go v0.110.8/go.mod h1:Iz8AkXJf1qmxC3Oxoep8R1T36w8B92yU29PcBhHO5fk= +cloud.google.com/go v0.110.4 h1:1JYyxKMN9hd5dR2MYTPWkGUgcoxVVhg0LKNKEo0qvmk= +cloud.google.com/go v0.110.4/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= @@ -73,8 +73,8 @@ cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= -cloud.google.com/go/compute v1.23.1 h1:V97tBoDaZHb6leicZ1G6DLK2BAaZLJ/7+9BB/En3hR0= -cloud.google.com/go/compute v1.23.1/go.mod h1:CqB3xpmPKKt3OJpW2ndFIXnA9A4xAy/F3Xp1ixncW78= +cloud.google.com/go/compute v1.20.1 h1:6aKEtlUiwEpJzM001l0yFkpXmUVXaN8W+fbkb2AZNbg= +cloud.google.com/go/compute v1.20.1/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= @@ -114,8 +114,8 @@ cloud.google.com/go/gkehub v0.10.0/go.mod h1:UIPwxI0DsrpsVoWpLB0stwKCP+WFVG9+y97 cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc= cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= cloud.google.com/go/iam v0.5.0/go.mod h1:wPU9Vt0P4UmCux7mqtRu6jcpPAb74cP1fh50J3QpkUc= -cloud.google.com/go/iam v1.1.3 h1:18tKG7DzydKWUnLjonWcJO6wjSCAtzh4GcRKlH/Hrzc= -cloud.google.com/go/iam v1.1.3/go.mod h1:3khUlaBXfPKKe7huYgEpDn6FtgRyMEqbkvBxrQyY5SE= +cloud.google.com/go/iam v1.1.0 h1:67gSqaPukx7O8WLLHMa0PNs3EBGd2eE4d+psbO/CO94= +cloud.google.com/go/iam v1.1.0/go.mod h1:nxdHjaKfCr7fNYx/HJMM8LgiMugmveWlkatear5gVyk= cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic= cloud.google.com/go/language v1.6.0/go.mod h1:6dJ8t3B+lUYfStgls25GusK04NLh3eDLQnWM3mdEbhI= cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8= @@ -399,6 +399,8 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= +github.com/cosmos/cosmos-sdk v0.47.5 h1:n1+WjP/VM/gAEOx3TqU2/Ny734rj/MX1kpUnn7zVJP8= +github.com/cosmos/cosmos-sdk v0.47.5/go.mod h1:EHwCeN9IXonsjKcjpS12MqeStdZvIdxt3VYXhus3G3c= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -415,8 +417,8 @@ github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZD github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= -github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw= -github.com/cosmos/ledger-cosmos-go v0.12.4/go.mod h1:fjfVWRf++Xkygt9wzCsjEBdjcf7wiiY35fv3ctT+k4M= +github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA= +github.com/cosmos/ledger-cosmos-go v0.12.2/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI= github.com/cosmos/rosetta-sdk-go v0.10.0 h1:E5RhTruuoA7KTIXUcMicL76cffyeoyvNybzUGSKFTcM= github.com/cosmos/rosetta-sdk-go v0.10.0/go.mod h1:SImAZkb96YbwvoRkzSMQB6noNJXFgWl/ENIznEoYQI4= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= @@ -578,8 +580,8 @@ github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= -github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= +github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= +github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -677,14 +679,13 @@ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= -github.com/googleapis/enterprise-certificate-proxy v0.2.4 h1:uGy6JWR/uMIILU8wbf+OkstIrNiMjGpEIyhx8f6W7s4= -github.com/googleapis/enterprise-certificate-proxy v0.2.4/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= +github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= +github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= @@ -694,8 +695,8 @@ github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99 github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqEF02fYlzkUCyo= github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY= -github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas= -github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU= +github.com/googleapis/gax-go/v2 v2.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cUUI8Ki4= +github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI= github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -1204,10 +1205,10 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= -github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= -github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= -github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= +github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= +github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +github.com/zondax/ledger-go v0.14.1 h1:Pip65OOl4iJ84WTpA4BKChvOufMhhbxED3BaihoZN4c= +github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2feOQv8K320= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= @@ -1266,8 +1267,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1380,8 +1381,8 @@ golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfS golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1407,8 +1408,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.11.0 h1:vPL4xzxBM4niKCW6g9whtaWVXTJf1U5e4aZxxFx/gbU= -golang.org/x/oauth2 v0.11.0/go.mod h1:LdF7O/8bLR/qWK9DrpXmbHLTouvRHK0SgJl0GmDBchk= +golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= +golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1423,8 +1424,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1540,16 +1541,16 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= +golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1563,8 +1564,8 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1702,8 +1703,8 @@ google.golang.org/api v0.96.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ google.golang.org/api v0.97.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= google.golang.org/api v0.98.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= google.golang.org/api v0.100.0/go.mod h1:ZE3Z2+ZOr87Rx7dqFsdRQkRBk36kDtp/h+QpHbB7a70= -google.golang.org/api v0.128.0 h1:RjPESny5CnQRn9V6siglged+DZCgfu9l6mO9dkX9VOg= -google.golang.org/api v0.128.0/go.mod h1:Y611qgqaE92On/7g65MQgxYul3c0rEB894kniWLY750= +google.golang.org/api v0.126.0 h1:q4GJq+cAdMAC7XP7njvQ4tvohGLiSlytuL4BQxbIZ+o= +google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1823,12 +1824,12 @@ google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqw google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b h1:+YaDE2r2OG8t/z5qmsh7Y+XXwCbvadxxZ0YY6mTdrVA= -google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:CgAqfJo+Xmu0GwA0411Ht3OU3OntXwsGmrmjI8ioGXI= -google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a h1:myvhA4is3vrit1a6NZCWBIwN0kNEnX21DJOJX/NvIfI= -google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:SUBoKXbI1Efip18FClrQVGjWcyd0QZd8KkvdP34t7ww= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 h1:AB/lmRny7e2pLhFEYIbl5qkDAUt2h0ZRO4wGPhZf+ik= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405/go.mod h1:67X1fPuzjcrkymZzZV1vvkFeTn2Rvc6lYF9MYFGCcwE= +google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 h1:Au6te5hbKUV8pIYWHqOUZ1pva5qK/rwbIhoXEUB9Lu8= +google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:O9kGHb51iE/nOGvQaDUuadVYqovW56s5emA88lQnj6Y= +google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e h1:z3vDksarJxsAKM5dmEGv0GHwE2hKJ096wZra71Vs4sw= +google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e h1:S83+ibolgyZ0bqz7KEsUOPErxcv4VzlszxY+31OfB/E= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1870,8 +1871,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= -google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= From 6c303869326a6c38bd28a8aa5fb7bf70fbc7ba36 Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Fri, 10 Nov 2023 13:40:41 +0100 Subject: [PATCH 13/14] Finalize --- integration-tests/modules/auth_test.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/integration-tests/modules/auth_test.go b/integration-tests/modules/auth_test.go index 3ef20688b..e243af938 100644 --- a/integration-tests/modules/auth_test.go +++ b/integration-tests/modules/auth_test.go @@ -239,7 +239,6 @@ func TestAuthUnexpectedSequenceNumber(t *testing.T) { func TestGasEstimation(t *testing.T) { t.Parallel() - ctx, chain := integrationtests.NewCoreumTestingContext(t) singlesigAddress := chain.GenAccount() @@ -330,16 +329,18 @@ func TestGasEstimation(t *testing.T) { expectedGas: dgc.FixedGas + 1*deterministicgas.BankSendPerCoinGas + (1*deterministicgas.AuthzExecOverhead + 1*deterministicgas.BankSendPerCoinGas), }, } - for _, test := range testsDeterm { - t.Run(test.name, func(t *testing.T) { + for _, tt := range testsDeterm { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() _, estimatedGas, err := client.CalculateGas( ctx, - chain.ClientContext.WithFromAddress(test.fromAddress), + chain.ClientContext.WithFromAddress(tt.fromAddress), chain.TxFactory(), - test.msgs..., + tt.msgs..., ) require.NoError(t, err) - require.Equal(t, int(test.expectedGas), int(estimatedGas)) + require.Equal(t, int(tt.expectedGas), int(estimatedGas)) }) } @@ -399,17 +400,17 @@ func TestGasEstimation(t *testing.T) { }, }, } - for _, test := range testsNonDeterm { - t.Run(test.name, func(t *testing.T) { + for _, tt := range testsNonDeterm { + tt := tt + t.Run(tt.name, func(t *testing.T) { _, estimatedGas, err := client.CalculateGas( ctx, - chain.ClientContext.WithFromAddress(test.fromAddress), + chain.ClientContext.WithFromAddress(tt.fromAddress), chain.TxFactory(), - test.msgs..., + tt.msgs..., ) require.NoError(t, err) require.Greater(t, int(estimatedGas), 0) }) } - } From c0250325e6f66aecb940e9a21b3989d932b5b789 Mon Sep 17 00:00:00 2001 From: Yaroslav Savchuk Date: Fri, 10 Nov 2023 16:43:09 +0100 Subject: [PATCH 14/14] Fix --- integration-tests/modules/auth_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/integration-tests/modules/auth_test.go b/integration-tests/modules/auth_test.go index e243af938..a8953ac15 100644 --- a/integration-tests/modules/auth_test.go +++ b/integration-tests/modules/auth_test.go @@ -403,6 +403,7 @@ func TestGasEstimation(t *testing.T) { for _, tt := range testsNonDeterm { tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() _, estimatedGas, err := client.CalculateGas( ctx, chain.ClientContext.WithFromAddress(tt.fromAddress),