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

Implement the ability to partially validate messages without knowing the ec chain #813

Closed
Tracked by #792
masih opened this issue Jan 7, 2025 · 0 comments · Fixed by #829
Closed
Tracked by #792

Implement the ability to partially validate messages without knowing the ec chain #813

masih opened this issue Jan 7, 2025 · 0 comments · Fixed by #829
Assignees

Comments

@masih
Copy link
Member

masih commented Jan 7, 2025

As part of #792 the ec chain (or Vote Value) may arrive in a different time than the message that references it. We will need to buffer such messages until the chain they reference is known. But we want to avoid buffering invalid messages for security reasons. For example, we can validate:

  • the message signature, because signature uses Merkle root of the chain, and the same key is used as the reference (i.e. provided as part of the partial message).
  • basic GPBFT validation rules that are independent of chain, e.g. validity of phase relative to round, etc.
  • relevance of the message relative to current progress (See ErrValidationNotRelevant, ErrValidationTooOld)

To make this possible, the current validation logic needs to be refactored to allow partial validation. We need to dig out the validation rules and apply them in a more pluggable way. An alternative is to duplicate the validation logic and harden it by tests to avoid divergence. The latter approach is probably faster but is a tech debt.

@github-project-automation github-project-automation bot moved this to Todo in F3 Jan 7, 2025
@masih masih self-assigned this Jan 7, 2025
@BigLep BigLep added this to the M2: Mainnet Passive Testing milestone Jan 8, 2025
@masih masih moved this from Todo to In progress in F3 Jan 14, 2025
masih added a commit that referenced this issue Jan 16, 2025
When messages arrive with yet to be discovered EC chain we want to do as
much validation as possible before buffering the message for future use.

Because the key of the EC chain is included in the partial messages we
are able to validate basically everything about the message except the
chain itself. The changes here implement this ability.

The implementation introduces a new validator implementation
specifically written to handle partial messages. The validation rules
are similar to the full GMesssage validator but then are adopted to
infer the state of a message from chain key instead. A separate issue
is captured to reduce duplicate rules across the two validators. This
refactor is postponed on purpose as it touches a lot of the core
implementations. Instead, the implementation here aims to provide a
correct partial validation mechanism to progress efforts.

The new validation makes a final validation attempt once the chain is
discovered to check the validity of chain, its consistency with key and
justification.

The partial validator maintains its own cache, similar to the full
validator, where messages are evicted as soon as GPBFT progresses. The
caches between full and partial validators are independent and do not
have an overlap: a message that can immediately be completed is never
cached by the partial validator and vise versa. This should keep the
total memory footprint across the both validators basically the same as
before.

Fixes #813
masih added a commit that referenced this issue Jan 16, 2025
When messages arrive with yet to be discovered EC chain we want to do as
much validation as possible before buffering the message for future use.

Because the key of the EC chain is included in the partial messages we
are able to validate basically everything about the message except the
chain itself. The changes here implement this ability.

The implementation introduces a new validator implementation
specifically written to handle partial messages. The validation rules
are similar to the full GMesssage validator but then are adopted to
infer the state of a message from chain key instead. A separate issue
is captured to reduce duplicate rules across the two validators. This
refactor is postponed on purpose as it touches a lot of the core
implementations. Instead, the implementation here aims to provide a
correct partial validation mechanism to progress efforts.

The new validation makes a final validation attempt once the chain is
discovered to check the validity of chain, its consistency with key and
justification.

The partial validator maintains its own cache, similar to the full
validator, where messages are evicted as soon as GPBFT progresses. The
caches between full and partial validators are independent and do not
have an overlap: a message that can immediately be completed is never
cached by the partial validator and vise versa. This should keep the
total memory footprint across the both validators basically the same as
before.

Fixes #813
@masih masih moved this from In progress to In review in F3 Jan 16, 2025
github-merge-queue bot pushed a commit that referenced this issue Jan 16, 2025
When messages arrive with yet to be discovered EC chain we want to do as
much validation as possible before buffering the message for future use.

Because the key of the EC chain is included in the partial messages we
are able to validate basically everything about the message except the
chain itself. The changes here implement this ability.

The implementation introduces a new validator implementation
specifically written to handle partial messages. The validation rules
are similar to the full GMesssage validator but then are adopted to
infer the state of a message from chain key instead. A separate issue
is captured to reduce duplicate rules across the two validators. This
refactor is postponed on purpose as it touches a lot of the core
implementations. Instead, the implementation here aims to provide a
correct partial validation mechanism to progress efforts.

The new validation makes a final validation attempt once the chain is
discovered to check the validity of chain, its consistency with key and
justification.

The partial validator maintains its own cache, similar to the full
validator, where messages are evicted as soon as GPBFT progresses. The
caches between full and partial validators are independent and do not
have an overlap: a message that can immediately be completed is never
cached by the partial validator and vise versa. This should keep the
total memory footprint across the both validators basically the same as
before.

Fixes #813
@github-project-automation github-project-automation bot moved this from In review to Done in F3 Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants