diff --git a/pkg/rpcclient/actor/maker.go b/pkg/rpcclient/actor/maker.go index 57ce83adb..392a84391 100644 --- a/pkg/rpcclient/actor/maker.go +++ b/pkg/rpcclient/actor/maker.go @@ -191,5 +191,14 @@ func (a *Actor) CalculateValidUntilBlock() (uint32, error) { if err != nil { return 0, fmt.Errorf("can't get block count: %w", err) } - return blockCount + uint32(a.version.Protocol.ValidatorsCount) + 1, nil + var vc = int(a.version.Protocol.ValidatorsCount) + var bestH = uint32(0) + for h, n := range a.version.Protocol.ValidatorsHistory { // In case it's enabled. + if h >= bestH && h <= blockCount { + vc = n + bestH = h + } + } + + return blockCount + uint32(vc+1), nil } diff --git a/pkg/rpcclient/actor/maker_test.go b/pkg/rpcclient/actor/maker_test.go index 0e741b7cd..116baf46b 100644 --- a/pkg/rpcclient/actor/maker_test.go +++ b/pkg/rpcclient/actor/maker_test.go @@ -24,6 +24,23 @@ func TestCalculateValidUntilBlock(t *testing.T) { vub, err := a.CalculateValidUntilBlock() require.NoError(t, err) require.Equal(t, uint32(42+7+1), vub) + + client.version.Protocol.ValidatorsHistory = map[uint32]int{ + 0: 7, + 40: 4, + 80: 10, + } + a, err = NewSimple(client, acc) + require.NoError(t, err) + + vub, err = a.CalculateValidUntilBlock() + require.NoError(t, err) + require.Equal(t, uint32(42+4+1), vub) + + client.bCount = 101 + vub, err = a.CalculateValidUntilBlock() + require.NoError(t, err) + require.Equal(t, uint32(101+10+1), vub) } func TestMakeUnsigned(t *testing.T) {