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

wormchain: only latest guardian set is exempt from expiry #3714

Merged
merged 1 commit into from
Jan 17, 2024
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
4 changes: 3 additions & 1 deletion wormchain/x/wormhole/keeper/vaa.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ func (k Keeper) CalculateQuorum(ctx sdk.Context, guardianSetIndex uint32) (int,
return 0, nil, types.ErrGuardianSetNotFound
}

if 0 < guardianSet.ExpirationTime && guardianSet.ExpirationTime < uint64(ctx.BlockTime().Unix()) {
latestGuardianSetIndex := k.GetLatestGuardianSetIndex(ctx)

if guardianSet.Index != latestGuardianSetIndex && guardianSet.ExpirationTime < uint64(ctx.BlockTime().Unix()) {
return 0, nil, types.ErrGuardianSetExpired
}

Expand Down
15 changes: 10 additions & 5 deletions wormchain/x/wormhole/keeper/vaa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,28 @@ func TestKeeperCalculateQuorum(t *testing.T) {

tests := []struct {
label string
guardianSet types.GuardianSet
guardianSets []types.GuardianSet
guardianSetIndex uint32
quorum int
willError bool
err error
}{

{label: "HappyPath",
guardianSet: types.GuardianSet{Index: 0, Keys: addrsBytes, ExpirationTime: 0},
guardianSets: []types.GuardianSet{{Index: 0, Keys: addrsBytes, ExpirationTime: 0}},
guardianSetIndex: 0,
quorum: 1,
willError: false},
{label: "GuardianSetNotFound",
guardianSet: types.GuardianSet{Index: 0, Keys: addrsBytes, ExpirationTime: 0},
guardianSets: []types.GuardianSet{{Index: 0, Keys: addrsBytes, ExpirationTime: 0}},
guardianSetIndex: 1,
willError: true,
err: types.ErrGuardianSetNotFound},
{label: "GuardianSetExpired",
guardianSet: types.GuardianSet{Index: 0, Keys: addrsBytes, ExpirationTime: 100},
guardianSets: []types.GuardianSet{
{Index: 0, Keys: addrsBytes, ExpirationTime: 0},
{Index: 1, Keys: addrsBytes, ExpirationTime: 0},
},
guardianSetIndex: 0,
willError: true,
err: types.ErrGuardianSetExpired},
Expand All @@ -83,7 +86,9 @@ func TestKeeperCalculateQuorum(t *testing.T) {
for _, tc := range tests {
t.Run(tc.label, func(t *testing.T) {
keeper, ctx := keepertest.WormholeKeeper(t)
keeper.AppendGuardianSet(ctx, tc.guardianSet)
for _, gs := range tc.guardianSets {
keeper.AppendGuardianSet(ctx, gs)
}
quorum, _, err := keeper.CalculateQuorum(ctx, tc.guardianSetIndex)

if tc.willError == true {
Expand Down
Loading