Skip to content

Remove isNew condition in FinalizedInbound check #4108

@lumtis

Description

@lumtis

In this line:

This condition removes the check as a condition for double spend if similar inbounds producing difference digests are observed in a short timeframe. The first inbound will not be finalized before the second one get observed.

All votes for new inbounds should be blocked as soon as a inbound with the same data is finalized.

The condition has originally been left to ensure all observers can cast their vote for an inbounds, even if they do it after the inbound get the 2/3 votes need to finalize.
We should investigate an alternative to make the check stricter:
Example: still allowing vote if the associated ballot was already finalized before vote, this means the inbound has been observed, casting more votes has no implication.

VoteOnInboundBallot currently return if the vote is finalized at all. This doesn't tell if it just got finalized in the current vote.

finalized, isNew, err := k.zetaObserverKeeper.VoteOnInboundBallot

The function could return the information if the inbound just got finalized or was already finalized:

justFinalized, wasFinalized, isNew, err := k.zetaObserverKeeper.VoteOnInboundBallot

If the inbound was already finalized, we can skip the check to ensure last vote can be cast

if !wasFinalized {
		if k.IsFinalizedInbound(tmpCtx, msg.InboundHash, msg.SenderChainId, msg.EventIndex) {
			return nil, sdkerrors.Wrapf(
				types.ErrObservedTxAlreadyFinalized,
				"%s, InboundHash:%s, SenderChainID:%d, EventIndex:%d",
				voteInboundID,
				msg.InboundHash,
				msg.SenderChainId,
				msg.EventIndex,
			)
		}
	}

Alternative

Since VoteOnInboundBallot start returning more and more value, we could also return a vote state in the returned values instead

VOTE_STATE = NEW | PENDING | FINALIZING | FINALIZED

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions