Skip to content

Commit

Permalink
chore: Unify bitmap length (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitferry authored Dec 8, 2022
1 parent fb7a231 commit 2ca49f0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions testutil/datagen/raw_checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func GenRandomRawCheckpoint() *types.RawCheckpoint {
return &types.RawCheckpoint{
EpochNum: GenRandomEpochNum(),
LastCommitHash: &randomHashBytes,
Bitmap: bitmap.New(13),
Bitmap: bitmap.New(types.BitmapBits),
BlsMultiSig: &randomBLSSig,
}
}
Expand Down Expand Up @@ -108,7 +108,7 @@ func GenerateLegitimateRawCheckpoint(privKeys []bls12381.PrivateKey) *types.RawC
msgBytes := append(sdk.Uint64ToBigEndian(epochNum), lch.MustMarshal()...)
sigs := GenerateBLSSigs(privKeys[:signerNum], msgBytes)
multiSig, _ := bls12381.AggrSigList(sigs)
bm := bitmap.New(13)
bm := bitmap.New(types.BitmapBits)
for i := 0; i < signerNum; i++ {
bm.Set(i, true)
}
Expand Down
2 changes: 1 addition & 1 deletion x/checkpointing/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func FuzzKeeperCheckpointEpoch(f *testing.F) {
}

// add local checkpoint, signed by the first validator
bm := bitmap.New(104)
bm := bitmap.New(types.BitmapBits)
bm.Set(0, true)
localCkptWithMeta := datagen.GenRandomRawCheckpointWithMeta()
localCkptWithMeta.Status = types.Sealed
Expand Down
5 changes: 3 additions & 2 deletions x/checkpointing/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import (

const (
// HashSize is the size in bytes of a hash
HashSize = sha256.Size
HashSize = sha256.Size
BitmapBits = 104 // 104 bits for 104 validators at top
)

type LastCommitHash []byte
Expand All @@ -27,7 +28,7 @@ func NewCheckpoint(epochNum uint64, lch LastCommitHash) *RawCheckpoint {
return &RawCheckpoint{
EpochNum: epochNum,
LastCommitHash: &lch,
Bitmap: bitmap.New(104), // 13 bytes, holding 100 validators
Bitmap: bitmap.New(BitmapBits), // 13 bytes, holding 100 validators
BlsMultiSig: nil,
}
}
Expand Down

0 comments on commit 2ca49f0

Please sign in to comment.