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

hashTreeRoot for slice field #23

Open
fearlessfe opened this issue Nov 9, 2024 · 0 comments
Open

hashTreeRoot for slice field #23

fearlessfe opened this issue Nov 9, 2024 · 0 comments

Comments

@fearlessfe
Copy link
Contributor

In ssz spec, the list type must have a limit to calculate the merkle tree root. So we define a method to get the limit of the slice.

eg IndexedAttestation, the field attesting_indices is a slice, so it must have a method ${fieldName}_limit

pub const IndexedAttestation = struct {
    // # [Modified in Electra:EIP7549] size: MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT
    attesting_indices: []primitives.ValidatorIndex,
    data: AttestationData,
    signature: primitives.BLSSignature,

    // limit for slice type from spec, the method name must be field name + "_limit"
    pub fn attesting_indices_limit() u64 {
        return preset.ActivePreset.get().MAX_VALIDATORS_PER_COMMITTEE;
    }
};

There is a side efffect, Because call the method through reflection is comptime, so we have to add method for all Slice type field, even it's not a ssz type.

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

No branches or pull requests

1 participant