Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public record PooledAttestationWithData(AttestationData data, PooledAttestation

public Attestation toAttestation(final AttestationSchema<Attestation> attestationSchema) {
return attestationSchema.create(
pooledAttestation.bits().getAggregationBits(),
pooledAttestation.bits().getAggregationSszBits(),
data,
pooledAttestation.aggregatedSignature(),
pooledAttestation.bits()::getCommitteeBits);
pooledAttestation.bits()::getCommitteeSszBits);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ static AttestationBits of(

boolean isSuperSetOf(AttestationBits other);

SszBitlist getAggregationBits();
SszBitlist getAggregationSszBits();

SszBitvector getCommitteeBits();
SszBitvector getCommitteeSszBits();

Int2IntMap getCommitteesSize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class AttestationBitsElectra implements AttestationBits {
private Int2ObjectMap<BitSet> committeeAggregationBitsMap;
private BitSet committeeBits;

private SszBitlist cachedAggregationBits = null;
private SszBitvector cachedCommitteeBits = null;
private SszBitlist cachedAggregationSszBits = null;
private SszBitvector cachedCommitteeSszBits = null;

AttestationBitsElectra(
final SszBitlist initialAggregationBits,
Expand Down Expand Up @@ -249,9 +249,9 @@ private boolean isSuperSetOf(
}

@Override
public SszBitlist getAggregationBits() {
if (cachedAggregationBits != null) {
return cachedAggregationBits;
public SszBitlist getAggregationSszBits() {
if (cachedAggregationSszBits != null) {
return cachedAggregationSszBits;
}
final List<Integer> committeeIndicesInOrder = new ArrayList<>();
for (int i = committeeBits.nextSetBit(0); i >= 0; i = committeeBits.nextSetBit(i + 1)) {
Expand Down Expand Up @@ -279,24 +279,24 @@ public SszBitlist getAggregationBits() {
}
currentOffset += committeeSize;
}
cachedAggregationBits =
cachedAggregationSszBits =
aggregationBitsSchema.wrapBitSet(totalBitlistSize, combinedAggregationBits);
return cachedAggregationBits;
return cachedAggregationSszBits;
}

@Override
public SszBitvector getCommitteeBits() {
if (cachedCommitteeBits == null) {
cachedCommitteeBits =
public SszBitvector getCommitteeSszBits() {
if (cachedCommitteeSszBits == null) {
cachedCommitteeSszBits =
committeeBitsSchema.wrapBitSet(
committeeBitsSchema.getLength(), (BitSet) this.committeeBits.clone());
}
return cachedCommitteeBits;
return cachedCommitteeSszBits;
}

private void invalidateCache() {
this.cachedAggregationBits = null;
this.cachedCommitteeBits = null;
this.cachedAggregationSszBits = null;
this.cachedCommitteeSszBits = null;
}

@Override
Expand Down Expand Up @@ -359,7 +359,7 @@ public String toString() {
.add("committeeBits", committeeBits.cardinality())
.add("committeeAggregationBitsMap", totalSetBits)
.add("committeesSize", committeesSize.size())
.add("cached", cachedAggregationBits != null || cachedCommitteeBits != null)
.add("sszBitsCached", cachedAggregationSszBits != null || cachedCommitteeSszBits != null)
.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public boolean isSuperSetOf(final AttestationBits other) {
}

@Override
public SszBitlist getAggregationBits() {
public SszBitlist getAggregationSszBits() {
return aggregationBits;
}

@Override
public SszBitvector getCommitteeBits() {
public SszBitvector getCommitteeSszBits() {
throw new IllegalStateException("Committee bits not available in phase0");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@ private PooledAttestation createPooledAttestation(

private Attestation toAttestation(final PooledAttestation pooledAttestation) {
return attestationSchema.create(
pooledAttestation.bits().getAggregationBits(),
pooledAttestation.bits().getAggregationSszBits(),
attestationData,
pooledAttestation.aggregatedSignature(),
pooledAttestation.bits()::getCommitteeBits);
pooledAttestation.bits()::getCommitteeSszBits);
}

private PooledAttestationWithData toPooledAttestationWithData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,12 +770,13 @@ private List<UInt64> validatorBitToValidatorIndex(final int... validatorBits) {

private List<UInt64> validatorBitToValidatorIndex(final AttestationBits bits) {
if (!bits.requiresCommitteeBits()) {
return validatorBitToValidatorIndex(bits.getAggregationBits().getAllSetBits().toIntArray());
return validatorBitToValidatorIndex(
bits.getAggregationSszBits().getAllSetBits().toIntArray());
}

// only 2 committees are supported
assertThat(committeeSizes.keySet()).isEqualTo(Set.of(0, 1));
final IntList committeeBits = bits.getCommitteeBits().getAllSetBits();
final IntList committeeBits = bits.getCommitteeSszBits().getAllSetBits();
assertThat(committeeBits.size()).isLessThanOrEqualTo(2);

final List<UInt64> result = new ArrayList<>();
Expand All @@ -784,14 +785,18 @@ private List<UInt64> validatorBitToValidatorIndex(final AttestationBits bits) {
result.addAll(
validatorBitToValidatorIndex(
Optional.of(0),
bits.getAggregationBits().getAsBitSet(0, committeeSizes.get(0)).stream().toArray()));
bits.getAggregationSszBits().getAsBitSet(0, committeeSizes.get(0)).stream()
.toArray()));
offset = committeeSizes.get(0);
}
if (committeeBits.contains(1)) {
result.addAll(
validatorBitToValidatorIndex(
Optional.of(1),
bits.getAggregationBits().getAsBitSet(offset, committeeSizes.get(1) + offset).stream()
bits
.getAggregationSszBits()
.getAsBitSet(offset, committeeSizes.get(1) + offset)
.stream()
.toArray()));
}

Expand All @@ -800,10 +805,10 @@ private List<UInt64> validatorBitToValidatorIndex(final AttestationBits bits) {

private Attestation toAttestation(final PooledAttestation pooledAttestation) {
return attestationSchema.create(
pooledAttestation.bits().getAggregationBits(),
pooledAttestation.bits().getAggregationSszBits(),
attestationData,
pooledAttestation.aggregatedSignature(),
pooledAttestation.bits()::getCommitteeBits); // Supplier for committee bits
pooledAttestation.bits()::getCommitteeSszBits); // Supplier for committee bits
}

private PooledAttestationWithData toPooledAttestationWithData(
Expand Down
Loading