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: no command to patch missing transactions between v0.7.0 and v0.7.1 #513

Merged
merged 10 commits into from
May 31, 2022

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented May 26, 2022

Solution:

  • add fix-unlucky-tx command to patch txs post v0.7.0 upgrade.

How To Use

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

@yihuang yihuang requested a review from a team as a code owner May 26, 2022 08:13
@yihuang yihuang requested review from calvinaco and leejw51crypto and removed request for a team May 26, 2022 08:13
…v0.7.1

Solution:
- add fix-unlucky-tx command to patch txs post v0.7.0 upgrade.
cmd := &cobra.Command{
Use: "fix-unlucky-tx [blocks-file]",
Short: "Fix tx execution result of false-failed tx after v0.7.0 upgrade, \"-\" means stdin.",
Long: "Fix tx execution result of false-failed tx after v0.7.0 upgrade.\nWARNING: don't use this command to patch blocks generated before v0.7.0 upgrade",
Copy link
Collaborator

@thomas-nguy thomas-nguy May 27, 2022

Choose a reason for hiding this comment

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

as a safe guard, would it be better to hardcode the upgrade height number and skip the command if the height is below this number? (or have two number, one for testnet-x, one for mainnet)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that would complicate the code a little bit though.
To do conditional compile with network build tag, we must create separate modules right?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe just one for mainnet + have a --force flag to skip the safe guard?

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm since we specify the chainId, maybe a simple map chainId -> number would be enough?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm, maybe a default value for mainnet, but user can supply a different value?

Copy link
Collaborator

Choose a reason for hiding this comment

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

what would happen if someone try to patch a tx before v0.7.0 upgrade? can it leads to possible state corruption?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added a --min-block-height as safty guard, with default value of 2693800.

Copy link
Collaborator

Choose a reason for hiding this comment

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

from your comment below, I understand that doing it on block before v0.7.0 could lead to state corruption because of the event format?

in that case, having the ability to override --min-block-height could be dangerous if bad interpreted, unless there is a reason for node operator to use it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe at least, strongly enforce the min-block-height when chain-id cronosmainnet_25-1 is specified

Copy link
Collaborator Author

@yihuang yihuang May 31, 2022

Choose a reason for hiding this comment

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

we'll provide an external doc to the user: https://github.com/crypto-org-chain/cronos/wiki/Patch-Unlucky-Tx#post-v070-upgrade, the users should simply follow the procedures in the doc.

# wait for tm-rpc port
wait_for_port(ports.rpc_port(custom_cronos.base_port(0)))
# check the tx indexer
assert len(cli.txs(f"ethereum_tx.ethereumTxHash={txhashes[1].hex()}")["txs"]) == 1
Copy link
Collaborator Author

@yihuang yihuang May 31, 2022

Choose a reason for hiding this comment

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

This integration test only works before the root cause is fixed: #503, after that, there's nothing to patch.

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

Successfully merging this pull request may close these issues.

3 participants