-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add tx fee event #9860
Merged
Merged
feat: add tx fee event #9860
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1cdf9ab
add tx fee event
colin-axner be0ac49
add cli test
colin-axner f72d97f
add changelog
colin-axner c103d79
update tests
colin-axner 798a163
Merge branch 'master' into colin/9857-fee-event
colin-axner 7394c51
apply review suggestions
colin-axner c47a49f
Merge branch 'colin/9857-fee-event' of github.com:cosmos/cosmos-sdk i…
colin-axner cc782cb
Merge branch 'master' into colin/9857-fee-event
colin-axner 4ba3df2
Merge branch 'master' into colin/9857-fee-event
colin-axner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -428,6 +428,76 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByEvents() { | |
} | ||
} | ||
|
||
func (s *IntegrationTestSuite) TestCLIQueryTxsCmdByEvents() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Took this from the |
||
val := s.network.Validators[0] | ||
|
||
account2, err := val.ClientCtx.Keyring.Key("newAccount2") | ||
s.Require().NoError(err) | ||
|
||
sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 10) | ||
|
||
// Send coins. | ||
out, err := s.createBankMsg( | ||
val, account2.GetAddress(), | ||
sdk.NewCoins(sendTokens), | ||
) | ||
s.Require().NoError(err) | ||
var txRes sdk.TxResponse | ||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes)) | ||
s.Require().NoError(s.network.WaitForNextBlock()) | ||
|
||
// Query the tx by hash to get the inner tx. | ||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, authcli.QueryTxCmd(), []string{txRes.TxHash, fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) | ||
s.Require().NoError(err) | ||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes)) | ||
|
||
testCases := []struct { | ||
name string | ||
args []string | ||
expectEmpty bool | ||
}{ | ||
{ | ||
"fee event happy case", | ||
[]string{ | ||
fmt.Sprintf("--events=tx.fee=%s", | ||
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), | ||
fmt.Sprintf("--%s=json", tmcli.OutputFlag), | ||
}, | ||
false, | ||
}, | ||
{ | ||
"no matching fee event", | ||
[]string{ | ||
fmt.Sprintf("--events=tx.fee=%s", | ||
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(0))).String()), | ||
fmt.Sprintf("--%s=json", tmcli.OutputFlag), | ||
}, | ||
true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
s.Run(tc.name, func() { | ||
cmd := authcli.QueryTxsByEventsCmd() | ||
clientCtx := val.ClientCtx | ||
|
||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) | ||
s.Require().NoError(err) | ||
|
||
var result sdk.SearchTxsResult | ||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) | ||
|
||
if tc.expectEmpty { | ||
s.Require().Equal(0, len(result.Txs)) | ||
} else { | ||
s.Require().NotEqual(0, len(result.Txs)) | ||
s.Require().NotNil(result.Txs[0]) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() { | ||
val1 := s.network.Validators[0] | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR Colin!
This is the total fee payed by the tx, represented as a coin/denom?
I'm trying to test this with Hermes and will provide feedback on how easy is it for the relayer to use the fee info.
As a side-note, I'm trying to rebuild my local gaiad using this branch, and was wondering if there any instructions for doing that. I'm patching my gaia
go.mod
but not sure that's the right approach.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is the total fee, but the fee may be multiple coins. Each coin would be represented by denom/amount. An empty coin set returns an empty string
Using the SDK's
simd
binary is another alternative togaiad
. You can runmake build
ormake install
depending on your usageEdit: I realize SDK's simd doesn't have IBC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is the entire fee. In the case of the Hub, it would be
Nuatom
, but could be multiple coins as @colin-axner pointed out, e.g.Nuatom,Yphoton