Skip to content

Commit f986f8f

Browse files
authored
Merge pull request #28 from datachainlab/fix-committee-size-check
Fix to check if the committee size matches expected value Signed-off-by: Jun Kimura <[email protected]>
2 parents 020b462 + 5be7e3e commit f986f8f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

relay/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const (
1616
Sepolia = "sepolia"
1717
)
1818

19+
const (
20+
MAINNET_PRESET_SYNC_COMMITTEE_SIZE = 512
21+
MINIMAL_PRESET_SYNC_COMMITTEE_SIZE = 32
22+
)
23+
1924
var (
2025
AltairSpec = lctypes.ForkSpec{
2126
FinalizedRootGindex: 105,

relay/prover.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,16 @@ func (pr *Prover) CreateInitialLightClientState(height ibcexported.Height) (ibce
8383
return nil, nil, err
8484
}
8585
pr.GetLogger().Debug("InitialState", "initial_state", initialState)
86-
86+
committeeSize := len(initialState.CurrentSyncCommittee.Pubkeys)
87+
if pr.config.IsMainnetPreset() {
88+
if committeeSize != MAINNET_PRESET_SYNC_COMMITTEE_SIZE {
89+
return nil, nil, fmt.Errorf("the size of current sync committee is not %v: actual=%v", MAINNET_PRESET_SYNC_COMMITTEE_SIZE, committeeSize)
90+
}
91+
} else {
92+
if committeeSize != MINIMAL_PRESET_SYNC_COMMITTEE_SIZE {
93+
return nil, nil, fmt.Errorf("the size of current sync committee is not %v: actual=%v", MINIMAL_PRESET_SYNC_COMMITTEE_SIZE, committeeSize)
94+
}
95+
}
8796
clientState := pr.buildClientState(
8897
initialState.Genesis.GenesisValidatorsRoot[:],
8998
initialState.Genesis.GenesisTimeSeconds,

0 commit comments

Comments
 (0)