Skip to content

Comments

Use the correct role and encoding for sync committee contributions#395

Merged
mergify[bot] merged 5 commits intosigp:unstablefrom
dknopik:role-sync-aggregations
Jul 7, 2025
Merged

Use the correct role and encoding for sync committee contributions#395
mergify[bot] merged 5 commits intosigp:unstablefrom
dknopik:role-sync-aggregations

Conversation

@dknopik
Copy link
Member

@dknopik dknopik commented Jun 27, 2025

Issue Addressed

Proposed Changes

Use the correct Role for sync committee aggregations. I think I got confused here during implementation.

Additionally, I realized Go-SSV does not encode the data correctly, so I introduced a wrapper that treats the contribution as variable length to fix the encoding

@dknopik dknopik linked an issue Jun 27, 2025 that may be closed by this pull request
@diegomrsantos diegomrsantos requested a review from Copilot July 1, 2025 11:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the role used when collecting sync committee contributions by updating the role from Aggregator to SyncCommittee and adjusts related error handling and serialization. Key changes include:

  • Replacing VariableList with a Contributions alias based on ContributionWrapper.
  • Updating error mapping to include DecodeError details.
  • Changing the signature version from ForkName::Base to ForkName::Altair and updating the role to SyncCommittee.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
anchor/validator_store/src/lib.rs Updated sync committee role usage, contributed signature error mapping, and version change.
anchor/common/ssv_types/src/consensus.rs Introduced ContributionWrapper with custom SSZ (de)serialization and Contributions alias.
Comments suppressed due to low confidence (1)

anchor/validator_store/src/lib.rs:1402

  • Please confirm that using ForkName::Altair here is intentional, ensuring that the sync committee contributions are aligned with the correct protocol version.
                        version: ForkName::Altair.into(),

@dknopik dknopik changed the title Use the correct role for sync committee contributions Use the correct role and encoding for sync committee contributions Jul 1, 2025
@dknopik dknopik added ready-for-review This PR is ready to be reviewed and removed do-not-merge waiting-on-author labels Jul 1, 2025
@dknopik dknopik marked this pull request as ready for review July 1, 2025 16:17
@mergify
Copy link

mergify bot commented Jul 1, 2025

Some required checks have failed. Could you please take a look @dknopik? 🙏

@mergify mergify bot added waiting-on-author ready-for-review This PR is ready to be reviewed and removed ready-for-review This PR is ready to be reviewed waiting-on-author labels Jul 1, 2025
@dknopik dknopik requested a review from diegomrsantos July 4, 2025 06:35
/// macro impls of `Encode and `Decode` on `Contribution` for the actual serialization and
/// deserialization.
#[derive(Clone, Debug, Into, From)]
pub struct ContributionWrapper<E: EthSpec> {
Copy link
Member

Choose a reason for hiding this comment

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

Could you also explain why, from a technical perspective, this is necessary? Wasn't the previous code working correctly?

Copy link
Member Author

Choose a reason for hiding this comment

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

@diegomrsantos The encoding mismatched. First, let me explain some background info.

Basically, the way SSZ encoding works, is by having a "fixed" part of an encoded container, and a "variable" part. In the fixed part, all values (for example integers, or nested containers) with a fixed size are contained, as well as offsets pointing to the starts of all variable length values (such as a byte string of variable length).

So, if we have a list of variable length items, we have a bunch of offsets, followed by the actual items. Basically, for a list with two variable length items, it looks like this:

offset1 |offset2 |data1   |data2
08000000|0b000000|abcdef00|12323434

Here, offset1 is the little endian encoding of 8, so it is pointing to the start of data1, and offset2 is 12, pointing to the start of data2.

For a list of fixed sized values, no offsets are necessary: as the values are of fixed size, we can just divide the length of the message by the length of a single value to determine the number of items.

So much for the background. This is hard to explain well in a nutshell here, for more info ping me or take a look at the spec. Now to our issue here:

Contribution<E> has a fixed lengh. So a VariableList<Contribution<E>, U13> needs no offsets.

I noticed that Go-SSV incorrectly sends lists with offsets - basically encoding the list as if Contribution<E> had a variable length. The wrapper with the custom impls simply sets the length of a Contribution<E> to be variable, in order to have VariableList add the offsets. Note that the encoding of a single Contribution<E> is not affected by this.

Unfortunately this is needed, as we can't simply fix this on SSV side, as such a fix would be a breaking protocol change.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the explanation. But how was the code behaving before this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

It could not decode the message, causing sync committee aggregations to fail

@dknopik dknopik requested a review from jking-aus July 4, 2025 21:04
mergify bot added a commit that referenced this pull request Jul 7, 2025
@mergify mergify bot merged commit 5f4b4bc into sigp:unstable Jul 7, 2025
21 of 28 checks passed
@dknopik dknopik deleted the role-sync-aggregations branch July 18, 2025 08:59
diegomrsantos pushed a commit to diegomrsantos/anchor that referenced this pull request Sep 17, 2025
…igp#395)

- closes sigp#263


  Use the correct Role for sync committee aggregations. I think I got confused here during implementation.

Additionally, I realized Go-SSV does not encode the data correctly, so I introduced a wrapper that treats the contribution as variable length to fix the encoding
jking-aus pushed a commit to jking-aus/anchor that referenced this pull request Oct 8, 2025
…igp#395)

- closes sigp#263


  Use the correct Role for sync committee aggregations. I think I got confused here during implementation.

Additionally, I realized Go-SSV does not encode the data correctly, so I introduced a wrapper that treats the contribution as variable length to fix the encoding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-merge ready-for-review This PR is ready to be reviewed v0.2.0 Second testnet release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sync committee aggregations

3 participants