-
Notifications
You must be signed in to change notification settings - Fork 240
Patch Unlucky Tx
There's a known issue in 0.6.x
that when a transaction's execution exceeds the block gas limit, the execution side-effects are committed successfully, but the tx can't be found by the JSON-RPC APIs. The bug is fixed after the v0.7.0
upgrade, and a CLI command cronosd fix-unlucky-tx
is provided in the v0.6.10 release to fix the historical block data for RPC nodes.
Note: The recent v0.6.x release branch contains a patch that improve the performance significantly, it's recommended to build a custom binary from there.
WARNING: Don't run the fix-unlucky-tx
command on blocks generated after the v0.7.0
upgrade.
If you want to fully patch the historical block data, can follow such procedure:
- Update
cronosd
binary tov0.6.10
. - Prepare a temporary node, and sync to block height
2693800
(v0.7.0
upgrade point). - Make sure the
cronosd
process is stopped. - Download the file of block numbers to patch, which is generated by command:
cronosd fix-unlucky-tx --end-block 2693799 --print-block-numbers | cut -d ' ' -f 1 > /tmp/blocks
. - Run
cronosd fix-unlucky-tx --blocks-file /tmp/blocks
.
After the full patch, that unlucky txs will be returned in JSON-RPC responses.
But a full patch could take days to finish, you can share the patched DB snapshot to other nodes to avoid repeating this on multiple nodes.
The command also provides several flags to support flexible usage:
-
Patch a range of blocks (the range is inclusive):
cronosd fix-unlucky-tx --start-block $START_BLOCK_NUMBER --end-block $END_BLOCK_NUMBER
-
Print the block numbers and tx indexes which need to be patched without actual patching, it's significantly faster than doing patching:
cronosd fix-unlucky-tx --start-block $START_BLOCK_NUMBER --end-block $END_BLOCK_NUMBER --print-block-numbers
-
Read the block numbers to patch from a file (one block number per line):
cronosd fix-unlucky-tx --blocks-file /path/to/file
We also provide an archive node with patched data directory (it also synced to a recent block after the v0.7.0 upgrade, but didn't include the post v0.7.0 patch).
Please note that they are post-upgrade snapshots.
Since the update of v0.7.0, the missing transaction in the case of the “overflowing” block should stop happening. However, after v0.7.0, there is still an edge case regarding the tx that exceeds the block gas limit - although the tx is reverted in such case, the tx fee is deducted from the sender, and the sender’s nonce is also increased. However, the tx is not shown in JSON-RPC response.
To obtain the most completed database, we suggest you run it with v0.7.0 (https://github.com/crypto-org-chain/cronos/releases/tag/v0.7.0) with your choice of OS/DB with the patched data snapshot:
-
goleveldb
-
rocksdb
After v0.7.0
upgrade and before v0.7.1
release, there's still a minor issue regarding the tx that exceeds the block gas limit, although the tx is reverted in such case, but the tx fee is deducted from sender, and sender's nonce is also increased, but the tx is not shown in JSON-RPC response. The v0.7.1
has fixed the issue to show the tx, and for the blocks generated by v0.7.0
, either do a resync with v0.7.1
, or do a simple patch as described below.
Upgrade the node to v0.7.1
and restart, and run:
$ cat > /tmp/find-unlucky-txs.py << EOF
import json
import sys
result = json.load(sys.stdin)["result"]
for tx in result["txs_results"] or []:
if (
tx["code"] == 11
and "out of gas in location: block gas meter; gasWanted:" in tx["log"]
and not any(evt["type"] == "ethereum_tx" for evt in tx["events"])
):
print(result["height"])
break
EOF
$ LATEST_HEIGHT=$(curl -s http://localhost:26657/status | jq -r ".result.sync_info.latest_block_height")
$ seq 2693800 $LATEST_HEIGHT | xargs -I{} sh -c "curl -s http://localhost:26657/block_results\?height\={} | python3 /tmp/find-unlucky-txs.py" | tee /tmp/unlucky-blocks
Stop the node, and run:
$ cronosd fix-unlucky-tx /tmp/unlucky-blocks