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

VoteOnObservedInboundTx: separate cctx state transition logic from the message into new functions #1800

Closed
Tracked by #1799
lumtis opened this issue Feb 23, 2024 · 0 comments · Fixed by #1853
Closed
Tracked by #1799

Comments

@lumtis
Copy link
Member

lumtis commented Feb 23, 2024

We currently have an open PR to move voting logic out of the message: #1511
In this PR we simplify the message logic by moving the voting logic into a separate function. The idea of this issue is to do the same for the CCTX state transition.
Basically, all the logic after

	// ******************************************************************************
	// below only happens when ballot is finalized: exactly when threshold vote is in
	// ******************************************************************************

We have in the docs a graph representing the control flow of the message: https://www.zetachain.com/docs/architecture/modules/crosschain/messages/#msgvoteonobservedinboundtx
This control is very hard to visualizing by looking at the message body, while it shouldn't be the case.

The idea of this issues is to separate the components into smaller functions so the high level logic can be easy to visualize.

The vision of this task is to end up in a message logic looking like:

func VoteOnObservedInboundTx(msg) {
  isFinalized := VoteOnInboundBallot(msg) // implying PR above is merged

  if isFinalized {
    inbound := getInboundFromMsg(msg)
    cctx := ProcessInbound(inbound, msg.receiver)

    // Post processing we currently have in defer (we should remove as defer with extensive logic are bug vector)
    SaveCCTX(cctx)
  }
}

func ProcessInbound(inbound, receiver) {
  if receiver == zetachain {
    return ProcessInboundZetaChain(inbound)
  } else {
    return ProcessInboundExternalChain(inbound)
  }
}

Adding this task in the epic #1799 as the idea is to get a future proof design simplifying adding new logic in the CCTX control flow

Tests should be added for the new methods. Therefore #1316 might be completed in this task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants