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

Problem: The unlucky transactions are not shown in json rpc #455

Closed
yihuang opened this issue May 5, 2022 · 4 comments
Closed

Problem: The unlucky transactions are not shown in json rpc #455

yihuang opened this issue May 5, 2022 · 4 comments
Assignees

Comments

@yihuang
Copy link
Collaborator

yihuang commented May 5, 2022

What is Unlucky Tx

The transactions whose execution happens to exceed block gas limit are not shown in json-rpc response, there's at most one in each block when it includes more tx than capacity.

Before v0.7.0, these transactions are executed successfully but return error in deliver tx response, after v0.7.0, the executions are reverted, and return the same error in response as before. In both cases, the tx can't be found in json-rpc response.

How To Identify The Unlucky Tx

for tx_result in reqeusts.get('/block_results', params={'height': block_number}).json()['result']['txs_results']:
  if tx_result['Code'] == 11 and 'out of gas in location: block gas meter; gasWanted:' in tx_result['Log']:
    # this is an unlucky tx

How To Patch Tendermint DB

Tx Hash Index

Currently json-rpc using /tx_search to find tx info by eth tx hash, so we need to have those eth tx hashes indexed.
For the legacy blocks before upgrade, we need to patch the tx indexer db to add the missing txs.
For new blocks, we should change the code to emit a eth tx hash event in ante handler, so the failed tx can be indexed.

Alternatively we can design a new way to index the eth tx hash.

Tx Result

Need to patch the tx result of the unlucky txs before v0.7.0 upgrade

  • replay the block to get the correct tx result of the unlucky tx
  • update the tx result in the db

DB Keys To Patch

  • Indexer DB: Key: ethereum_tx.ethereumTxHash/{ETH_HASH}/{res.Height}/{res.Index}, Value: tm hash.
  • Indexer DB: Key: tm hash, Value: abci.TxResult.
  • State DB: Key: abciResponsesKey:{height}, Value: tmstate.ABCIResponses.

How To Replay A Block

@tomtau
Copy link
Contributor

tomtau commented May 5, 2022

is also one solution if the tm tx indexer isn't used: #451 (comment) ?

@yihuang
Copy link
Collaborator Author

yihuang commented May 5, 2022

is also one solution if the tm tx indexer isn't used: #451 (comment) ?

yes, I've added that to the comment, the other thing to patch is the tx result, need to replay the block to get it.

@romeroandalusia
Copy link

@yihuang Does the nonce of the unlucky reverted transaction count?

If I send a tx with nonce 10, with V0.7.0 it is reverted if it is the unlucky tx. Does the next tx from this address need to have a nonce of 10 or 11? It should be 11 like a normal reverted tx.

@yihuang
Copy link
Collaborator Author

yihuang commented May 5, 2022

@yihuang Does the nonce of the unlucky reverted transaction count?

If I send a tx with nonce 10, with V0.7.0 it is reverted if it is the unlucky tx. Does the next tx from this address need to have a nonce of 10 or 11? It should be 11 like a normal reverted tx.

nonce is increased too, it should be 11 like a normal reverted tx.

@yihuang yihuang self-assigned this May 6, 2022
yihuang added a commit to yihuang/cronos that referenced this issue May 6, 2022
Closes: crypto-org-chain#455
- add patch-tx-result command
- test in integration test
yihuang added a commit to yihuang/cronos that referenced this issue May 6, 2022
Closes: crypto-org-chain#455
- add patch-tx-result command
- test in integration test
yihuang added a commit to yihuang/cronos that referenced this issue May 6, 2022
Closes: crypto-org-chain#455
- add patch-tx-result command
- test in integration test
yihuang added a commit to yihuang/cronos that referenced this issue May 6, 2022
Closes: crypto-org-chain#455
- add patch-tx-result command
- test in integration test
yihuang added a commit that referenced this issue May 10, 2022
* Problem: The unlucky transactions are not shown in json rpc

Closes: #455
- add patch-tx-result command
- test in integration test

* support psql indexer

* fix integration test

* tag dependency

* Update cmd/cronosd/cmd/fix-unlucky-tx.go

* Apply suggestions from code review

* create a refresh app to replay tx

* enable lazy loading

* add dry-run flag

* fix lint

* more convinient flags

* Update cmd/cronosd/cmd/fix-unlucky-tx.go

Co-authored-by: Thomas Nguy <81727899+thomas-nguy@users.noreply.github.com>

* fix integration test

* fix lint

* Apply suggestions from code review

* add a warning in help text

Co-authored-by: Thomas Nguy <81727899+thomas-nguy@users.noreply.github.com>
@yihuang yihuang closed this as completed May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants