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

Simplify Message Containers #455

Open
GalRogozinski opened this issue Jul 4, 2024 · 4 comments
Open

Simplify Message Containers #455

GalRogozinski opened this issue Jul 4, 2024 · 4 comments
Labels
refactor ssv ssv related issues

Comments

@GalRogozinski
Copy link
Contributor

Description

For spec it makes better sense to have simpler message containers with inefficient logic, rather than hard to decipher nested map structure.

@GalRogozinski GalRogozinski added ssv ssv related issues refactor labels Jul 4, 2024
@GalRogozinski
Copy link
Contributor Author

See:

type PartialSigContainer struct {
// Signature map: validator index -> signing root -> operator id (signer) -> signature (from the signer for the validator's signing root)
Signatures map[phase0.ValidatorIndex]map[SigningRoot]map[types.OperatorID]types.Signature
// Quorum is the number of min signatures needed for quorum
Quorum uint64
}

@alan-ssvlabs
Copy link

alan-ssvlabs commented Nov 30, 2024

Looking at this code for a while, I think although it it not good looking, it is a reasonable implementation. If we want to get rid of the nested map we can use a list of PartialSignatureMessage, but it makes the GetSignature and GetSignatures function less elegant. What is the solution in your mind?

type PartialSignatureMessage struct {
	PartialSignature Signature `ssz-size:"96"` // The Beacon chain partial Signature for a duty
	SigningRoot      [32]byte  `ssz-size:"32"` // the root signed in PartialSignature
	Signer           OperatorID
	ValidatorIndex   phase0.ValidatorIndex
}

@GalRogozinski
Copy link
Contributor Author

GalRogozinski commented Dec 1, 2024

@alan-ssvlabs
I think this is good actually
The implementation will be something like this (no IDE was use so may have errors):

func GetSignature(ps PartialSigContainer, validatorIndex phase0.ValidatorIndex, signer types.OperatorID, signingRoot [32]byte) (types.Signature, error) {
	for _, psm := range ps.GetSignatureMessages {
              if psm.ValidatorIndex == validatorIndex && psm.Signer == signer && psm.Root == signingRoot {
                    return psm.Signature, nil
              }
        }
        return nil, error.new("Signature is not found")
}

I think this is simpler and more readable.
But before you continue with this let's hear what @moshe-blox , @y0sher and the sigP guys think

@AgeManning
Copy link

I spoke with the team. We don't have strong opinions either way.

We typically like simpler things that are easy to read, so this change sounds good to us.

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

No branches or pull requests

3 participants