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

fix: inbound index #1536

Merged
merged 24 commits into from
Jan 11, 2024
Merged

fix: inbound index #1536

merged 24 commits into from
Jan 11, 2024

Conversation

kingpinXD
Copy link
Contributor

@kingpinXD kingpinXD commented Jan 8, 2024

Description

  • Adds an index to keep track of finalized inbounds
  • Adds a new field to the CCTX struct to track the finalization state of a tx

Closes: (https://github.com/zeta-chain/security/issues/44)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Include instructions and any relevant details so others can reproduce.

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Checklist:

  • I have added unit tests that prove my fix feature works

@kingpinXD kingpinXD changed the title Fix inbound index fix: inbound index Jan 8, 2024
Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

It looks good to me.
I'm thinking in anticipation of #1515 if we could consider instead of having a boolean IsFinalized introduce a inboundStatus
So we can have:

  • nonFinalized: vote still ongoing
  • finalizing: vote finished but not executed yet
  • finalized: voted and executed

We could introduce the status value and just keep nonFinalized and finalized for now

x/crosschain/keeper/finalized_inbounds.go Outdated Show resolved Hide resolved
@kingpinXD
Copy link
Contributor Author

It looks good to me. I'm thinking in anticipation of #1515 if we could consider instead of having a boolean IsFinalized introduce a inboundStatus So we can have:

  • nonFinalized: vote still ongoing
  • finalizing: vote finished but not executed yet
  • finalized: voted and executed

We could introduce the status value and just keep nonFinalized and finalized for now

It makes sense to do that,however we can consider the following situations

  • if 1515 is going to be part of v12 or the first mainnet release , it would be cleaner to add that as part of the implementation PR
  • if 1515 is going to be implemented post mainnet, we can modify the cross-chain struct now and avoid migrating cctxs on mainnet

@kingpinXD kingpinXD requested a review from lumtis January 8, 2024 21:27
@kingpinXD kingpinXD marked this pull request as draft January 9, 2024 00:24
Copy link

github-actions bot commented Jan 9, 2024

!!!WARNING!!!
nosec detected in the following files: x/crosschain/client/integrationtests/cli_helpers.go, x/crosschain/keeper/msg_server_vote_inbound_tx.go, x/crosschain/keeper/msg_server_vote_outbound_tx.go

Be very careful about using #nosec in code. It can be a quick way to suppress security warnings and move forward with development, it should be employed with caution. Suppressing warnings with #nosec can hide potentially serious vulnerabilities. Only use #nosec when you're absolutely certain that the security issue is either a false positive or has been mitigated in another way.

Only suppress a single rule (or a specific set of rules) within a section of code, while continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within the #nosec annotation, e.g: /* #nosec G401 */ or //#nosec G201 G202 G203
Broad #nosec annotations should be avoided, as they can hide other vulnerabilities. The CI will block you from merging this PR until you remove #nosec annotations that do not target specific rules.

Pay extra attention to the way #nosec is being used in the files listed above.

@github-actions github-actions bot added the nosec label Jan 9, 2024
@kingpinXD kingpinXD marked this pull request as ready for review January 9, 2024 18:55
@brewmaster012
Copy link
Collaborator

zeta-chain/security#44

What's the relationship to this issue?

@kingpinXD
Copy link
Contributor Author

zeta-chain/security#44

What's the relationship to this issue?

it adds a check for the inbound which have been finalized
https://github.com/zeta-chain/zeta-node/blob/0a41cccbd0ae2c72afe350fe4b7ac060f1d9a1eb/x/crosschain/keeper/msg_server_vote_inbound_tx.go#L108-L111

@brewmaster012
Copy link
Collaborator

zeta-chain/security#44

What's the relationship to this issue?

it adds a check for the inbound which have been finalized https://github.com/zeta-chain/zeta-node/blob/0a41cccbd0ae2c72afe350fe4b7ac060f1d9a1eb/x/crosschain/keeper/msg_server_vote_inbound_tx.go#L108-L111

so it's basically using the txhash+chainid+eventid as a stable "index" for deduplicating observation?

@lumtis
Copy link
Member

lumtis commented Jan 10, 2024

To me it seems a correct way to handle it. We can highlight the fix with TrailOfBits in our next call.

x/crosschain/keeper/msg_server_vote_inbound_tx.go Outdated Show resolved Hide resolved
x/crosschain/keeper/finalized_inbounds.go Outdated Show resolved Hide resolved
x/crosschain/keeper/finalized_inbounds.go Outdated Show resolved Hide resolved
@lumtis lumtis added this to the v12 milestone Jan 11, 2024
@lumtis lumtis merged commit 736d616 into develop Jan 11, 2024
15 checks passed
@lumtis lumtis deleted the fix-inbound-index branch January 11, 2024 23:43
This was referenced Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants