Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Implement tx counter for transaction info #621

Merged
merged 3 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

[Full Changelog](https://github.com/CosmWasm/wasmd/compare/v0.19.0...HEAD)

**Implemented Enhancements:**

- Add transaction index implemented as counter [\#601](https://github.com/CosmWasm/wasmd/issues/601)


## [v0.19.0](https://github.com/CosmWasm/wasmd/tree/v0.19.0) (2021-09-15)

[Full Changelog](https://github.com/CosmWasm/wasmd/compare/v0.19.0...v0.18.0)
Expand Down
4 changes: 4 additions & 0 deletions INTEGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ from the Cosmos SDK, and enabled them in `app.go`. If so, you can just look
at [`wasmd/app/app.go`](https://github.com/CosmWasm/wasmd/blob/master/app/app.go#)
for how to do so (just search there for lines with `wasm`).

`wasmd` also comes with a custom `ante handler` that adds the TX position in the block into the context
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

and passes it to the contracts. In order to support this feature you would need to add our custom
ante handler into the `ante handler chain` as in: [`app/ante.go`](https://github.com/CosmWasm/wasmd/blob/master/app/ante.go)

### Copied into your app

Sometimes, however, you will need to copy `x/wasm` into your app. This should
Expand Down
2 changes: 1 addition & 1 deletion app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func NewAnteHandler(
// copied sdk https://github.com/cosmos/cosmos-sdk/blob/v0.42.9/x/auth/ante/ante.go
return sdk.ChainAnteDecorators(
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
wasmkeeper.NewCountTXDecorator(txCounterStoreKey),
ante.NewRejectExtensionOptionsDecorator(),
ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
Expand All @@ -33,6 +34,5 @@ func NewAnteHandler(
ante.NewSigGasConsumeDecorator(ak, sigGasConsumer),
ante.NewSigVerificationDecorator(ak, signModeHandler),
ante.NewIncrementSequenceDecorator(ak),
wasmkeeper.NewCountTXDecorator(txCounterStoreKey),
)
}
4 changes: 2 additions & 2 deletions contrib/local/02-contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo "## Add new CosmWasm contract"
RESP=$(wasmd tx wasm store "$DIR/../../x/wasm/keeper/testdata/hackatom.wasm" \
--from validator --gas 1500000 -y --chain-id=testing --node=http://localhost:26657 -b block)

CODE_ID=$(echo "$RESP" | jq -r '.logs[0].events[0].attributes[-1].value')
CODE_ID=$(echo "$RESP" | jq -r '.logs[0].events[1].attributes[-1].value')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ante handler added an event?
Or this is just an older bug you just found?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a 🐛 that I found with manual tests. Not related to the ante handler.

echo "* Code id: $CODE_ID"
echo "* Download code"
TMPDIR=$(mktemp -t wasmdXXXXXX)
Expand Down Expand Up @@ -57,7 +57,7 @@ echo "### Upload new code"
RESP=$(wasmd tx wasm store "$DIR/../../x/wasm/keeper/testdata/burner.wasm" \
--from validator --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b block)

BURNER_CODE_ID=$(echo "$RESP" | jq -r '.logs[0].events[0].attributes[-1].value')
BURNER_CODE_ID=$(echo "$RESP" | jq -r '.logs[0].events[1].attributes[-1].value')
echo "### Migrate to code id: $BURNER_CODE_ID"

DEST_ACCOUNT=$(wasmd keys show fred -a)
Expand Down