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: tx hash may be incorrect in event parsing #595

Merged
merged 1 commit into from
Jul 25, 2022

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Jul 19, 2022

Solution:

👮🏻👮🏻👮🏻 !!!! 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 July 19, 2022 02:52
@yihuang yihuang requested review from devashishdxt and leejw51crypto and removed request for a team July 19, 2022 02:52
CHANGELOG.md Outdated Show resolved Hide resolved
go.mod Show resolved Hide resolved
Solution:
- Due to bug evmos/ethermint#1175, the first `ethereum_tx` event emitted in ante handler may be incorrect,
  Althrough the root casue is fixed, but to avoid resync we can do a workaround in event parsing to override with the second one.
@yihuang yihuang enabled auto-merge (squash) July 20, 2022 06:51
@yihuang yihuang requested a review from adu-crypto July 20, 2022 06:51
@yihuang
Copy link
Collaborator Author

yihuang commented Jul 20, 2022

Verified in production.

@yihuang yihuang requested a review from thomas-nguy July 25, 2022 03:15
@adu-crypto
Copy link
Contributor

we don't validate other fields like Hash/Size_ in MsgEthereumTx.
is this intended to avoid consensus problems?

@yihuang
Copy link
Collaborator Author

yihuang commented Jul 25, 2022

we don't validate other fields like Hash/Size_ in MsgEthereumTx. is this intended to avoid consensus problems?

do you mean this PR #584,
it's a non-breaking backport to v0.7, in main branch, it's in the ValidateBasic.

@adu-crypto
Copy link
Contributor

I mean in vbd.Antehandle only From is checked:

	for _, msg := range protoTx.GetMsgs() {
		msgEthTx, ok := msg.(*evmtypes.MsgEthereumTx)
		if !ok {
			return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "invalid message type %T, expected %T", msg, (*evmtypes.MsgEthereumTx)(nil))
		}

		// Validate `From` field
		if msgEthTx.From != "" {
			return ctx, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid From %s, expect empty string", msgEthTx.From)
		}

		txGasLimit += msgEthTx.GetGas()
...

https://github.com/evmos/ethermint/blob/main/app/ante/eth.go#L436-L438

@yihuang
Copy link
Collaborator Author

yihuang commented Jul 25, 2022

I mean in vbd.Antehandle only From is checked:

	for _, msg := range protoTx.GetMsgs() {
		msgEthTx, ok := msg.(*evmtypes.MsgEthereumTx)
		if !ok {
			return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "invalid message type %T, expected %T", msg, (*evmtypes.MsgEthereumTx)(nil))
		}

		// Validate `From` field
		if msgEthTx.From != "" {
			return ctx, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid From %s, expect empty string", msgEthTx.From)
		}

		txGasLimit += msgEthTx.GetGas()
...

https://github.com/evmos/ethermint/blob/main/app/ante/eth.go#L436-L438

Hash and Size_ is checked in ValidateBasic

@yihuang yihuang merged commit e30cc05 into crypto-org-chain:release/v0.7.x Jul 25, 2022
@yihuang yihuang deleted the release/v0.7.x branch July 25, 2022 16:09
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.

2 participants