Skip to content

Commit

Permalink
(feat) height to slots, stop instance after 2 epochs. (ssvlabs#1063)
Browse files Browse the repository at this point in the history
* take spec changes into ssv

* deploy to all stage nodes, use new db path

* use my spec

* update gosum

* new db path

* latest update from spec branch

* try a new db

* update spectest and fix tests

* replace to new db and restart

* spec alignment

spec alignment

* Update integration/qbft/tests/regular_test.go

Co-authored-by: Nikita Kryuchkov <[email protected]>

* change db_path and revert gitlab

* take spec from fixed ver by gal

* set genesis epochs for jato-v2 and mainnet

---------

Co-authored-by: Nikita Kryuchkov <[email protected]>
Co-authored-by: moshe-blox <[email protected]>
  • Loading branch information
3 people authored Jul 19, 2023
1 parent 137f6e6 commit 6ee6f4b
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 76 deletions.
9 changes: 6 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/aquasecurity/table v1.8.0
github.com/attestantio/go-eth2-client v0.16.3
github.com/bloxapp/eth2-key-manager v1.3.1
github.com/bloxapp/ssv-spec v0.3.1-0.20230528103541-820f72b858bc
github.com/bloxapp/ssv-spec v0.3.1
github.com/btcsuite/btcd/btcec/v2 v2.3.2
github.com/cespare/xxhash/v2 v2.2.0
github.com/cornelk/hashmap v1.0.8
Expand All @@ -22,7 +22,6 @@ require (
github.com/hashicorp/golang-lru/v2 v2.0.2
github.com/herumi/bls-eth-go-binary v1.29.1
github.com/ilyakaznacheev/cleanenv v1.4.2
github.com/ipfs/go-log/v2 v2.5.1
github.com/jellydator/ttlcache/v3 v3.0.1
github.com/libp2p/go-libp2p v0.28.1
github.com/libp2p/go-libp2p-kad-dht v0.23.0
Expand Down Expand Up @@ -70,7 +69,7 @@ require (
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/goccy/go-yaml v1.9.5 // indirect
github.com/goccy/go-yaml v1.11.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
Expand All @@ -79,6 +78,7 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/flatbuffers v1.12.1 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand All @@ -92,6 +92,7 @@ require (
github.com/ipfs/go-datastore v0.6.0 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
github.com/ipfs/go-log v1.0.5 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/ipld/go-ipld-prime v0.20.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
Expand Down Expand Up @@ -185,3 +186,5 @@ require (
replace github.com/google/flatbuffers => github.com/google/flatbuffers v1.11.0

replace github.com/dgraph-io/ristretto => github.com/dgraph-io/ristretto v0.1.1-0.20211108053508-297c39e6640f

replace github.com/bloxapp/ssv-spec => github.com/GalRogozinski/ssv-spec v0.0.0-20230717135936-591075aff542
17 changes: 5 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8=
github.com/GalRogozinski/ssv-spec v0.0.0-20230717135936-591075aff542 h1:G/+s1jq23EYvpWpXSsym3c6jBgj6i+80Dfkh+zdzxc0=
github.com/GalRogozinski/ssv-spec v0.0.0-20230717135936-591075aff542/go.mod h1:zPJR7YnG5iZ6I0h6EzfVly8bTBXaZwcx4TyJ8pzYVd8=
github.com/Shopify/sarama v1.26.1/go.mod h1:NbSGBSSndYaIhRcBtY9V0U7AyH+x71bG668AuWys/yU=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/VictoriaMetrics/fastcache v1.12.0 h1:vnVi/y9yKDcD9akmc4NqAoqgQhJrOwUF+j9LTgn4QDE=
Expand Down Expand Up @@ -43,10 +45,7 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bloxapp/eth2-key-manager v1.3.1 h1:1olQcOHRY2TN1o8JX9AN1siEIJXWnlM+BlknfBbXoo4=
github.com/bloxapp/eth2-key-manager v1.3.1/go.mod h1:cT+qAJfnAzNz9StFoHQ8xAkyU2eyEukd6xfxvcBWuZA=
github.com/bloxapp/ssv-spec v0.3.1-0.20230528103541-820f72b858bc h1:JK0z+GAUqkvUTi7Ziqh+CEG0itRR2dV7fUapUJtbe4k=
github.com/bloxapp/ssv-spec v0.3.1-0.20230528103541-820f72b858bc/go.mod h1:8OAYKYxifYZ0ahWb4X+KZ6Rb49L2R3bm8lpqXt8u/2k=
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c=
github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U=
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
Expand Down Expand Up @@ -112,7 +111,6 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum/go-ethereum v1.12.0 h1:bdnhLPtqETd4m3mS8BGMNvBTf36bO5bx/hxE2zljOa0=
github.com/ethereum/go-ethereum v1.12.0/go.mod h1:/oo2X/dZLJjf2mJ6YT9wcWxa4nNJDBKDBU6sFIpx1Gs=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/ferranbt/fastssz v0.1.3 h1:ZI+z3JH05h4kgmFXdHuR1aWYsgrg7o+Fw7/NCzM16Mo=
Expand Down Expand Up @@ -151,12 +149,8 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
Expand All @@ -165,8 +159,8 @@ github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg78
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0=
github.com/goccy/go-yaml v1.9.5 h1:Eh/+3uk9kLxG4koCX6lRMAPS1OaMSAi+FJcya0INdB0=
github.com/goccy/go-yaml v1.9.5/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
github.com/goccy/go-yaml v1.11.0 h1:n7Z+zx8S9f9KgzG6KtQKf+kwqXZlLNR2F6018Dgau54=
github.com/goccy/go-yaml v1.11.0/go.mod h1:H+mJrWtjPTJAHvRbV09MCK9xYwODM+wRTVFFTWckfng=
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
Expand Down Expand Up @@ -220,6 +214,7 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
Expand Down Expand Up @@ -332,7 +327,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
Expand Down Expand Up @@ -369,7 +363,6 @@ github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8u83wA0rVZ8ttrq5CpaPZdvrK0LP2lOk=
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd/go.mod h1:QuCEs1Nt24+FYQEqAAncTDPJIuGs+LxK1MCiFL25pMU=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
Expand Down
2 changes: 1 addition & 1 deletion integration/qbft/tests/regular_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestRegular10CommitteeScenario(t *testing.T) {

func regularValidator() func(t *testing.T, committee int, actual *protocolstorage.StoredInstance) {
return func(t *testing.T, committee int, actual *protocolstorage.StoredInstance) {
require.Equal(t, int(qbft.FirstHeight), int(actual.State.Height), "height not matching") //int conversion needs to show correct output from require
require.EqualValues(t, DefaultSlot, actual.State.Height, "height not matching")
require.Equal(t, int(qbft.FirstRound), int(actual.State.Round), "round not matching")

require.NotNil(t, actual.DecidedMessage, "no decided message")
Expand Down
2 changes: 1 addition & 1 deletion networkconfig/jato-v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var JatoV2 = NetworkConfig{
Name: "jato-v2",
Beacon: beacon.NewNetwork(spectypes.PraterNetwork),
Domain: spectypes.DomainType{0x0, 0x0, 0x4, 0x1},
GenesisEpoch: 183993,
GenesisEpoch: 192100,
ETH1SyncOffset: new(big.Int).SetInt64(9203578),
RegistryContractAddr: "0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D",
Bootnodes: []string{
Expand Down
2 changes: 1 addition & 1 deletion networkconfig/mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var Mainnet = NetworkConfig{
Name: "mainnet",
Beacon: beacon.NewNetwork(spectypes.MainNetwork),
Domain: spectypes.GenesisMainnet,
GenesisEpoch: 1,
GenesisEpoch: 218450,
ETH1SyncOffset: new(big.Int).SetInt64(17507487),
RegistryContractAddr: "0xDD9BC35aE942eF0cFa76930954a156B3fF30a4E1",
Bootnodes: []string{
Expand Down
57 changes: 22 additions & 35 deletions protocol/v2/qbft/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,36 @@ func NewController(
}

// StartNewInstance will start a new QBFT instance, if can't will return error
func (c *Controller) StartNewInstance(logger *zap.Logger, value []byte) error {
if err := c.canStartInstanceForValue(value); err != nil {
return errors.Wrap(err, "can't start new QBFT instance")
func (c *Controller) StartNewInstance(logger *zap.Logger, height specqbft.Height, value []byte) error {

if err := c.GetConfig().GetValueCheckF()(value); err != nil {
return errors.Wrap(err, "value invalid")
}

// only if current height's instance exists (and decided since passed can start instance) bump
if c.StoredInstances.FindInstance(c.Height) != nil {
c.bumpHeight()
if height < c.Height {
return errors.New("attempting to start an instance with a past height")
}

newInstance := c.addAndStoreNewInstance()
newInstance.Start(logger, value, c.Height)
if c.StoredInstances.FindInstance(height) != nil {
return errors.New("instance already running")
}

c.Height = height

newInstance := c.addAndStoreNewInstance()
newInstance.Start(logger, value, height)
c.forceStopAllInstanceExceptCurrent()
return nil
}

func (c *Controller) forceStopAllInstanceExceptCurrent() {
for _, i := range c.StoredInstances {
if i.State.Height != c.Height {
i.ForceStop()
}
}
}

// ProcessMsg processes a new msg, returns decided message or error
func (c *Controller) ProcessMsg(logger *zap.Logger, msg *specqbft.SignedMessage) (*specqbft.SignedMessage, error) {
if err := c.BaseMsgValidation(msg); err != nil {
Expand Down Expand Up @@ -164,10 +178,6 @@ func (c *Controller) InstanceForHeight(logger *zap.Logger, height specqbft.Heigh
return inst
}

func (c *Controller) bumpHeight() {
c.Height++
}

// GetIdentifier returns QBFT Identifier, used to identify messages
func (c *Controller) GetIdentifier() []byte {
return c.Identifier
Expand All @@ -189,29 +199,6 @@ func (c *Controller) addAndStoreNewInstance() *instance.Instance {
return i
}

func (c *Controller) canStartInstanceForValue(value []byte) error {
// check value
if err := c.GetConfig().GetValueCheckF()(value); err != nil {
return errors.Wrap(err, "value invalid")
}

return c.CanStartInstance()
}

// CanStartInstance returns nil if controller can start a new instance
func (c *Controller) CanStartInstance() error {
// check prev instance if prev instance is not the first instance
inst := c.StoredInstances.FindInstance(c.Height)
if inst == nil {
return nil
}
if decided, _ := inst.IsDecided(); !decided {
return errors.New("previous instance hasn't Decided")
}

return nil
}

// GetRoot returns the state's deterministic root
func (c *Controller) GetRoot() ([32]byte, error) {
marshaledRoot, err := json.Marshal(c)
Expand Down
17 changes: 16 additions & 1 deletion protocol/v2/qbft/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ type Instance struct {

processMsgF *spectypes.ThreadSafeF
startOnce sync.Once
StartValue []byte

forceStop bool
StartValue []byte

metrics *metrics
}
Expand Down Expand Up @@ -52,6 +54,10 @@ func NewInstance(
}
}

func (i *Instance) ForceStop() {
i.forceStop = true
}

// Start is an interface implementation
func (i *Instance) Start(logger *zap.Logger, value []byte, height specqbft.Height) {
i.startOnce.Do(func() {
Expand Down Expand Up @@ -122,6 +128,10 @@ func allSigners(all []*specqbft.SignedMessage) []spectypes.OperatorID {

// ProcessMsg processes a new QBFT msg, returns non nil error on msg processing error
func (i *Instance) ProcessMsg(logger *zap.Logger, msg *specqbft.SignedMessage) (decided bool, decidedValue []byte, aggregatedCommit *specqbft.SignedMessage, err error) {
if !i.CanProcessMessages() {
return false, nil, nil, errors.New("instance stopped processing messages")
}

if err := i.BaseMsgValidation(msg); err != nil {
return false, nil, nil, errors.Wrap(err, "invalid signed message")
}
Expand Down Expand Up @@ -245,3 +255,8 @@ func (i *Instance) bumpToRound(round specqbft.Round) {
i.State.Round = round
i.metrics.SetRound(round)
}

// CanProcessMessages will return true if instance can process messages
func (i *Instance) CanProcessMessages() bool {
return !i.forceStop && int(i.State.Round) < CutoffRound
}
6 changes: 6 additions & 0 deletions protocol/v2/qbft/instance/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import (
"go.uber.org/zap"
)

var CutoffRound = 15 // stop processing instances after 8*2+120*6 = 14.2 min (~ 2 epochs)

func (i *Instance) UponRoundTimeout(logger *zap.Logger) error {
if !i.CanProcessMessages() {
return errors.New("instance stopped processing timeouts")
}

newRound := i.State.Round + 1
logger.Debug("⌛ round timed out", fields.Round(newRound))

Expand Down
2 changes: 1 addition & 1 deletion protocol/v2/qbft/spectest/controller_sync_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func RunControllerSync(t *testing.T, test *futuremsg.ControllerSyncSpecTest) {
false,
)

err := contr.StartNewInstance(logger, []byte{1, 2, 3, 4})
err := contr.StartNewInstance(logger, 0, []byte{1, 2, 3, 4})
if err != nil {
t.Fatalf(err.Error())
}
Expand Down
12 changes: 6 additions & 6 deletions protocol/v2/qbft/spectest/controller_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func RunControllerSpecTest(t *testing.T, test *spectests.ControllerSpecTest) {
)

var lastErr error
for _, runData := range test.RunInstanceData {
if err := runInstanceWithData(t, logger, contr, config, identifier, runData); err != nil {
for i, runData := range test.RunInstanceData {
if err := runInstanceWithData(t, logger, specqbft.Height(i), contr, config, identifier, runData); err != nil {
lastErr = err
}
}
Expand Down Expand Up @@ -64,7 +64,7 @@ func testProcessMsg(
config *qbft.Config,
runData *spectests.RunInstanceData,
) error {
decidedCnt := 0
decidedCnt := uint(0)
var lastErr error
for _, msg := range runData.InputMessages {
decided, err := contr.ProcessMsg(logger, msg)
Expand All @@ -77,7 +77,7 @@ func testProcessMsg(
require.EqualValues(t, runData.ExpectedDecidedState.DecidedVal, decided.FullData)
}
}
require.EqualValues(t, runData.ExpectedDecidedState.DecidedCnt, decidedCnt)
require.EqualValues(t, runData.ExpectedDecidedState.DecidedCnt, decidedCnt, lastErr)

// verify sync decided by range calls
if runData.ExpectedDecidedState.CalledSyncDecidedByRange {
Expand Down Expand Up @@ -129,8 +129,8 @@ func testBroadcastedDecided(
}
}

func runInstanceWithData(t *testing.T, logger *zap.Logger, contr *controller.Controller, config *qbft.Config, identifier []byte, runData *spectests.RunInstanceData) error {
err := contr.StartNewInstance(logger, runData.InputValue)
func runInstanceWithData(t *testing.T, logger *zap.Logger, height specqbft.Height, contr *controller.Controller, config *qbft.Config, identifier []byte, runData *spectests.RunInstanceData) error {
err := contr.StartNewInstance(logger, height, runData.InputValue)
var lastErr error
if err != nil {
lastErr = err
Expand Down
18 changes: 4 additions & 14 deletions protocol/v2/ssv/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,10 @@ func NewBaseRunner(

// baseStartNewDuty is a base func that all runner implementation can call to start a duty
func (b *BaseRunner) baseStartNewDuty(logger *zap.Logger, runner Runner, duty *spectypes.Duty) error {
if err := b.canStartNewDuty(); err != nil {
return err
}

b.baseSetupForNewDuty(duty)
return runner.executeDuty(logger, duty)
}

// canStartNewDuty is a base func that all runner implementation can call to decide if a new duty can start
func (b *BaseRunner) canStartNewDuty() error {
if b.State == nil {
return nil
}

return b.QBFTController.CanStartInstance()
}

// basePreConsensusMsgProcessing is a base func that all runner implementation can call for processing a pre-consensus msg
func (b *BaseRunner) basePreConsensusMsgProcessing(runner Runner, signedMsg *spectypes.SignedPartialSignatureMessage) (bool, [][32]byte, error) {
if err := b.ValidatePreConsensusMsg(runner, signedMsg); err != nil {
Expand Down Expand Up @@ -250,7 +237,10 @@ func (b *BaseRunner) decide(logger *zap.Logger, runner Runner, input *spectypes.

}

if err := runner.GetBaseRunner().QBFTController.StartNewInstance(logger, byts); err != nil {
if err := runner.GetBaseRunner().QBFTController.StartNewInstance(logger,
specqbft.Height(input.Duty.Slot),
byts,
); err != nil {
return errors.Wrap(err, "could not start new QBFT instance")
}
newInstance := runner.GetBaseRunner().QBFTController.InstanceForHeight(logger, runner.GetBaseRunner().QBFTController.Height)
Expand Down
Binary file added scripts/differ/differ
Binary file not shown.
2 changes: 1 addition & 1 deletion scripts/spec-alignment/differ.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ApprovedChanges: ["256a3dc0f1eb7abf","22b66e9a63ba145b","12c1c3a1622fb7cc","1c44
"db32f358b6e8e2bb","f372e174e1f34c3b","bc47b3d202e8cd0d","86a6abca1a1c16d6","1655d21d5a4cad4","ac4e427097fc5533","6b4d5a114f8066ff",
"9482fb9b6a953c48","5778a05e0976a6eb","24e2c7f54d5dd1d","2a8937e50d20faa9","587c629a67ef07ed","9d06d8e0ee4e1113","e624ec802068e711",
"943be3ce709a99d3", "5b3bb2d2262fe8be", "5b3bb2d2262fe8be","e12b17f3910be26b","17cf3119ac6879f2","b10c6fc7dd9eee7","7aa380d0261f7286",
"c20c4c7ed8d1711d",
"c20c4c7ed8d1711d", "c121cdaab6c1c698","3f31546191c9e6b2","e47bf52e962c90af","e8292a58d2eb08ab",
# Temporary approval, pending merge of PR on ssv-spec: https://github.com/bloxapp/ssv-spec/pull/267
"90b8a0c8d2c30e95"]
IgnoredIdentifiers:
Expand Down

0 comments on commit 6ee6f4b

Please sign in to comment.