test: enable spec tests related to eip-7549 - #6741
Conversation
| } | ||
| const attestationElectra = attestation as electra.Attestation; | ||
| const committeeBitsLength = attestationElectra.committeeBits.bitLen; | ||
| const committeeBitsLength = attestationElectra.committeeBits.getTrueBitIndexes().length; |
There was a problem hiding this comment.
The committeeBits is a bit vector so the bitLen will always remain fixed which is MAX_COMMITTEES_PER_SLOT. Hence if a chain is starting with initial validators less than MAX_COMMITTEES_PER_SLOT the attestation check will never pass.
So we actually need to get how many comittees actually participatd using getTrueBitIndexes.
There was a problem hiding this comment.
The if(committeeBitsLength > committeeCount) check in electra-fork branch is wrong.
The check is supposedly to be identical to this line of the spec. The reason is although committeeBits has a set length of 64, actual number of committees might be less than that. If the 60th bit is set, but there is only 40 committees, then this check needs to throw error
Here we actually want the position of the last set bit in attestationElectra.committeeBits. If lastCommitteeIndex is greater than committeeCount, then we throw error.
There was a problem hiding this comment.
So something like this:
const committeeIndices = attestationElectra.committeeBits.getTrueBitIndexes();
if (committeeIndices.length === 0) {
throw Error("Should have at least one committee bit set");
} else {
const lastCommitteeIndex = committeeIndices[committeeIndices.length - 1];
if (lastCommitteeIndex >= committeeCount) {
throw new Error("Committee index exceeds committee count");
}
}
This is beyond the scope of this PR, happy to fix this in another PR. Maybe add a todo here for now. Thanks for catching it @nazarhussain @wemeetagain
02b5f1c to
7c7bdeb
Compare
84d0950 to
28ae804
Compare
28ae804 to
0ff25d9
Compare
* feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com>
0ff25d9 to
8be57b1
Compare
| } | ||
| const attestationElectra = attestation as electra.Attestation; | ||
| const committeeBitsLength = attestationElectra.committeeBits.bitLen; | ||
| const committeeBitsLength = attestationElectra.committeeBits.getTrueBitIndexes().length; |
There was a problem hiding this comment.
The if(committeeBitsLength > committeeCount) check in electra-fork branch is wrong.
The check is supposedly to be identical to this line of the spec. The reason is although committeeBits has a set length of 64, actual number of committees might be less than that. If the 60th bit is set, but there is only 40 committees, then this check needs to throw error
Here we actually want the position of the last set bit in attestationElectra.committeeBits. If lastCommitteeIndex is greater than committeeCount, then we throw error.
| } | ||
| const attestationElectra = attestation as electra.Attestation; | ||
| const committeeBitsLength = attestationElectra.committeeBits.bitLen; | ||
| const committeeBitsLength = attestationElectra.committeeBits.getTrueBitIndexes().length; |
There was a problem hiding this comment.
So something like this:
const committeeIndices = attestationElectra.committeeBits.getTrueBitIndexes();
if (committeeIndices.length === 0) {
throw Error("Should have at least one committee bit set");
} else {
const lastCommitteeIndex = committeeIndices[committeeIndices.length - 1];
if (lastCommitteeIndex >= committeeCount) {
throw new Error("Committee index exceeds committee count");
}
}
This is beyond the scope of this PR, happy to fix this in another PR. Maybe add a todo here for now. Thanks for catching it @nazarhussain @wemeetagain
|
@ensi321 As this PR is enabling the spec tests for |
ensi321
left a comment
There was a problem hiding this comment.
looks good overall minor comment
| if (opts?.skippedForks?.includes(forkStr)) { | ||
| if ( | ||
| opts?.skippedForks?.includes(forkStr) || | ||
| (process.env.SPEC_FILTER_FORK && forkStr !== process.env.SPEC_FILTER_FORK) |
There was a problem hiding this comment.
Curious why we would want to specify fork that we want to skip in a env variable SPEC_FILTER_FORK. What's the use case for this? I think defaultSkipOpts is serving quite well
There was a problem hiding this comment.
Quickly run the spec tests for some forks. Whilde debugging, if we run for all forks it take too much time.
SPEC_FILTER_FORK=electra yarn test:spec:minimal* initial commit * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * clean up * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments * Fix the build erros * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * Fix rebase issue * Update committee index count check --------- Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: Navie Chan <naviechan@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * clean up * Misc * Fix the build erros * feat: get attestations for electra block (ChainSafe#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments * Fix the build erros * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * Fix rebase issue * Update committee index count check --------- Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: Navie Chan <naviechan@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * clean up * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments * Fix the build erros * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * Fix rebase issue * Update committee index count check --------- Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: Navie Chan <naviechan@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * clean up * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments * Fix the build erros * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * Fix rebase issue * Update committee index count check --------- Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: Navie Chan <naviechan@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * clean up * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments * Fix the build erros * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * Fix rebase issue * Update committee index count check --------- Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: Navie Chan <naviechan@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * clean up * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments * Fix the build erros * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * Fix rebase issue * Update committee index count check --------- Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: Navie Chan <naviechan@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * clean up * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments * Fix the build erros * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * Fix rebase issue * Update committee index count check --------- Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: Navie Chan <naviechan@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * clean up * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments * Fix the build erros * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * Fix rebase issue * Update committee index count check --------- Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: Navie Chan <naviechan@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * clean up * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments * Fix the build erros * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * Fix rebase issue * Update committee index count check --------- Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: Navie Chan <naviechan@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * clean up * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments * Fix the build erros * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * Fix rebase issue * Update committee index count check --------- Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: Navie Chan <naviechan@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * clean up * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments * Fix the build erros * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * Fix rebase issue * Update committee index count check --------- Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: Navie Chan <naviechan@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * clean up * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments * Fix the build erros * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * Fix rebase issue * Update committee index count check --------- Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: Navie Chan <naviechan@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * clean up * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments * Fix the build erros * Extend spec runner to be more flexible * Add missing state attributes for electra * Fix ss data types for electra spec * Make the spec runner more flexible * Fix the bug in process attestation * Update the sepc test version * Fix rebase issue * Update committee index count check --------- Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: Navie Chan <naviechan@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
|
🎉 This PR is included in v1.22.0 🎉 |
Motivation
Increase spec test coverage for Electra.
Description
SPEC_FILTER_FORKandSPEC_FILTER_FORKenvironmental variable which will be read in during spec testprocessAttestation()Steps to test or reproduce