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

[Dynamic Protocol State] Read-only interfaces of protocol state #4579

Merged
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
6eff830
Renamed state -> chain_state. Introduced prootocol_state.go
durkmurder Jul 17, 2023
9f4a0a7
Added interfaces for accessing protocol state
durkmurder Jul 17, 2023
fa4a17f
Extracted inmem DKG conversions into public function
durkmurder Jul 17, 2023
c43200b
Updated interfaces for protocol state
durkmurder Jul 17, 2023
d550c92
Added partial implementation of dynamic protocol state adapter and pr…
durkmurder Jul 17, 2023
bf5d3ed
Small renaming. Cleanup and tidy
durkmurder Jul 17, 2023
62c14b5
Implementing additional functionality for dynamic protocol state adapter
durkmurder Jul 17, 2023
6106dc1
Split dynamic protocol state adapter into initial and dynamic
durkmurder Jul 18, 2023
2062efb
Added tests and documentation for adapters
durkmurder Jul 18, 2023
8e270b5
Updated mocks
durkmurder Jul 18, 2023
ec2b92b
Added tests for protocol state reader
durkmurder Jul 18, 2023
6b997ea
Updated godoc
durkmurder Jul 18, 2023
b42124b
Updated protocol state adapters to return data in lazy way
durkmurder Jul 19, 2023
6b3fa6b
Cleanup of existing code
durkmurder Jul 19, 2023
2ee7d87
Extracted GlobalParams from Params. Injected GlobalParams into Protoc…
durkmurder Jul 19, 2023
3ca81bb
Added tests to make sure that global params are correctly injected in…
durkmurder Jul 19, 2023
fdbb3cd
Merge branch 'yurii/5529-dynamic-protocol-state-storage-layer' of htt…
durkmurder Jul 20, 2023
71da068
Updated godoc for protocol state
durkmurder Jul 20, 2023
7605d99
Updated protocol.GlobalParams to stop returning errors as values are …
durkmurder Jul 20, 2023
9152753
Linted
durkmurder Jul 24, 2023
a44ec8f
Merge branch 'yurii/5529-dynamic-protocol-state-storage-layer' of htt…
durkmurder Jul 24, 2023
c59c26a
Added interface for state updater
durkmurder Jul 25, 2023
dfcab24
Updated ProtocolStateEntry to support deep copy functionality
durkmurder Jul 25, 2023
6b47488
Implemented processing of epoch setup and commit events. Implemented …
durkmurder Jul 25, 2023
ef964a4
Added some tests for updater
durkmurder Jul 26, 2023
3192722
Added test for setting invalid state transition
durkmurder Jul 26, 2023
a216da5
Added tests for processing epoch commit
durkmurder Jul 27, 2023
5c4c332
More updates to updater tests
durkmurder Jul 27, 2023
cdcd456
Added test for processing epoch setup event
durkmurder Jul 31, 2023
61f53c1
Added implementation and small test for UpdateIdentity
durkmurder Jul 31, 2023
7f844e2
Added more test cases for protocol state updater
durkmurder Jul 31, 2023
c7471d8
Added test for updating identity before processing epoch setup
durkmurder Jul 31, 2023
8126acd
Work in progress on updater tests
durkmurder Jul 31, 2023
c9480b2
Merge branch 'yurii/5529-dynamic-protocol-state-storage-layer' of htt…
durkmurder Jul 31, 2023
8ba0775
Merge branch 'yurii/5513-read-only-identity-table' of https://github.…
durkmurder Jul 31, 2023
f6952be
Merge branch 'yurii/5529-dynamic-protocol-state-storage-layer' of htt…
durkmurder Jul 31, 2023
c8144c8
Merge branch 'yurii/5513-read-only-identity-table' of https://github.…
durkmurder Jul 31, 2023
e0f0f1b
Updated godoc
durkmurder Aug 1, 2023
b909d20
Merge branch 'yurii/5529-dynamic-protocol-state-storage-layer' of htt…
durkmurder Aug 1, 2023
5881242
Merge branch 'yurii/5513-read-only-identity-table' of https://github.…
durkmurder Aug 1, 2023
dacf332
Changed how epoch setup events are processed. Changed how participant…
durkmurder Aug 1, 2023
18696f6
Updated tests to handle different edge cases when processing epoch setup
durkmurder Aug 1, 2023
07e449e
Updated godocs for multiple structures. Code cleanup and small refact…
durkmurder Aug 1, 2023
6e3f587
Linted
durkmurder Aug 1, 2023
9290985
Added a function to StateUpdater to retrieve candidate block
durkmurder Aug 2, 2023
4edcb11
Updated protocol state to return epoch status
durkmurder Aug 3, 2023
cf509f9
Updated mocks
durkmurder Aug 3, 2023
4fd8696
Merge branch 'yurii/5513-read-only-identity-table' of https://github.…
durkmurder Aug 3, 2023
16aa94d
Made protocol state updater to return parent state. Implemented Epoch…
durkmurder Aug 3, 2023
4423875
Updated protocol state to return low-level entry for bootstraping pur…
durkmurder Aug 7, 2023
325b7c9
Merge branch 'yurii/5529-dynamic-protocol-state-storage-layer' of htt…
durkmurder Aug 7, 2023
5dc0d20
Refactored implementation and tests of inmemory adapters. Moved to in…
durkmurder Aug 7, 2023
3163e93
Merge branch 'yurii/5513-read-only-identity-table' of https://github.…
durkmurder Aug 7, 2023
79c45c1
Merge branch 'yurii/5529-dynamic-protocol-state-storage-layer' of htt…
durkmurder Aug 7, 2023
5e8982e
Merge branch 'yurii/5513-read-only-identity-table' of https://github.…
durkmurder Aug 7, 2023
c95a9b7
Fixed tests after merge
durkmurder Aug 7, 2023
0d19d0a
Merge branch 'yurii/5529-dynamic-protocol-state-storage-layer' of htt…
durkmurder Aug 7, 2023
0953256
Merge branch 'yurii/5513-read-only-identity-table' of https://github.…
durkmurder Aug 7, 2023
3a9a86e
Linted
durkmurder Aug 7, 2023
d982854
Merge branch 'yurii/5529-dynamic-protocol-state-storage-layer' of htt…
durkmurder Aug 8, 2023
9570336
Merge branch 'yurii/6801-protocol-state-updater' of https://github.co…
durkmurder Aug 8, 2023
cfc1eec
Removed automatic transition to new epoch in state updater
durkmurder Aug 9, 2023
0be0711
Updated how epoch transition is performed for protocol state updater.…
durkmurder Aug 9, 2023
1fe92c7
Updated how state transition happens
durkmurder Aug 9, 2023
63cd2f4
Updated mocks. Updated InitialProtocolStateAdaptor to return rich entry
durkmurder Aug 11, 2023
a678791
Merge branch 'yurii/5529-dynamic-protocol-state-storage-layer' into y…
jordanschalm Aug 24, 2023
21c621f
removed error checks, whose APIs we refactored and that don't return …
Sep 4, 2023
8b16dad
Apply Jodan's suggested goDoc revisions
Sep 4, 2023
0a1bf67
micro code consolidation
Sep 5, 2023
30f6d52
extended GoDoc of `IdentityList.Copy`
Sep 5, 2023
0fa6e01
doc: req for StateUpdate inputs to be validated
jordanschalm Sep 7, 2023
0d961bc
add todo
jordanschalm Sep 7, 2023
f72f260
Merge branch 'yurii/5529-dynamic-protocol-state-storage-layer' into y…
jordanschalm Sep 7, 2023
a0041b8
Merge branch 'feature/dynamic-protocol-state' of https://github.com/o…
durkmurder Sep 8, 2023
7d91701
Apply suggestions from code review
durkmurder Sep 8, 2023
792715e
Apply suggestions from code review
durkmurder Sep 8, 2023
d222fd0
Applied suggestions from PR review. Updated tests
durkmurder Sep 8, 2023
0ccdb11
Linted
durkmurder Sep 8, 2023
4d3e92f
Fixed test
durkmurder Sep 8, 2023
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
10 changes: 2 additions & 8 deletions cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,10 +729,7 @@ func (fnb *FlowNodeBuilder) initMetrics() error {
// metrics enabled, report node info metrics as post init event
fnb.PostInit(func(nodeConfig *NodeConfig) error {
nodeInfoMetrics := metrics.NewNodeInfoCollector()
protocolVersion, err := fnb.RootSnapshot.Params().ProtocolVersion()
if err != nil {
return fmt.Errorf("could not query root snapshoot protocol version: %w", err)
}
protocolVersion := fnb.RootSnapshot.Params().ProtocolVersion()
nodeInfoMetrics.NodeInfo(build.Semver(), build.Commit(), nodeConfig.SporkID.String(), protocolVersion)
return nil
})
Expand Down Expand Up @@ -1204,10 +1201,7 @@ func (fnb *FlowNodeBuilder) setRootSnapshot(rootSnapshot protocol.Snapshot) erro
}

fnb.RootChainID = fnb.FinalizedRootBlock.Header.ChainID
fnb.SporkID, err = fnb.RootSnapshot.Params().SporkID()
if err != nil {
return fmt.Errorf("failed to read spork ID: %w", err)
}
fnb.SporkID = fnb.RootSnapshot.Params().SporkID()

return nil
}
Expand Down
15 changes: 3 additions & 12 deletions engine/access/rpc/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import (
"strconv"
"time"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

lru "github.com/hashicorp/golang-lru"
"github.com/rs/zerolog"

Expand Down Expand Up @@ -291,17 +288,11 @@ func (b *Backend) Ping(ctx context.Context) error {
}

// GetNodeVersionInfo returns node version information such as semver, commit, sporkID, protocolVersion, etc
func (b *Backend) GetNodeVersionInfo(ctx context.Context) (*access.NodeVersionInfo, error) {
func (b *Backend) GetNodeVersionInfo(_ context.Context) (*access.NodeVersionInfo, error) {
stateParams := b.state.Params()
sporkId, err := stateParams.SporkID()
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to read spork ID: %v", err)
}
sporkId := stateParams.SporkID()

protocolVersion, err := stateParams.ProtocolVersion()
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to read protocol version: %v", err)
}
protocolVersion := stateParams.ProtocolVersion()

return &access.NodeVersionInfo{
Semver: build.Semver(),
Expand Down
13 changes: 3 additions & 10 deletions engine/access/rpc/backend/backend_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,10 @@ func (b *backendNetwork) GetNetworkParameters(_ context.Context) access.NetworkP
}
}

func (b *backendNetwork) GetNodeVersionInfo(ctx context.Context) (*access.NodeVersionInfo, error) {
func (b *backendNetwork) GetNodeVersionInfo(_ context.Context) (*access.NodeVersionInfo, error) {
stateParams := b.state.Params()
sporkId, err := stateParams.SporkID()
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to read spork ID: %v", err)
}

protocolVersion, err := stateParams.ProtocolVersion()
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to read protocol version: %v", err)
}
sporkId := stateParams.SporkID()
protocolVersion := stateParams.ProtocolVersion()

return &access.NodeVersionInfo{
Semver: build.Semver(),
Expand Down
6 changes: 1 addition & 5 deletions engine/access/rpc/backend/backend_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,7 @@ func (b *backendTransactions) GetTransactionResultsByBlockID(
// after iterating through all transactions in each collection, i equals the total number of
// user transactions in the block
txCount := i

sporkRootBlockHeight, err := b.state.Params().SporkRootBlockHeight()
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to retrieve root block: %v", err)
}
sporkRootBlockHeight := b.state.Params().SporkRootBlockHeight()

// root block has no system transaction result
if block.Header.Height > sporkRootBlockHeight {
Expand Down
5 changes: 1 addition & 4 deletions engine/collection/epochmgr/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,7 @@ func (e *Engine) activeClusterIDs() (flow.ChainIDList, error) {
defer e.mu.RUnlock()
clusterIDs := make(flow.ChainIDList, 0)
for _, epoch := range e.epochs {
chainID, err := epoch.state.Params().ChainID() // cached, does not hit database
if err != nil {
return nil, fmt.Errorf("failed to get active cluster ids: %w", err)
}
chainID := epoch.state.Params().ChainID() // cached, does not hit database
clusterIDs = append(clusterIDs, chainID)
}
return clusterIDs, nil
Expand Down
5 changes: 1 addition & 4 deletions engine/collection/message_hub/message_hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ func NewMessageHub(log zerolog.Logger,
}

// register network conduit
chainID, err := clusterState.Params().ChainID()
if err != nil {
return nil, fmt.Errorf("could not get chain ID: %w", err)
}
chainID := clusterState.Params().ChainID()
conduit, err := net.Register(channels.ConsensusCluster(chainID), hub)
if err != nil {
return nil, fmt.Errorf("could not register engine: %w", err)
Expand Down
6 changes: 1 addition & 5 deletions engine/collection/synchronization/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,7 @@ func New(
if err != nil {
return nil, fmt.Errorf("could not setup message handler")
}

chainID, err := state.Params().ChainID()
if err != nil {
return nil, fmt.Errorf("could not get chain ID: %w", err)
}
chainID := state.Params().ChainID()

// register the engine with the network layer and store the conduit
con, err := net.Register(channels.SyncCluster(chainID), e)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
Expand Down Expand Up @@ -1141,6 +1142,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/montanaflynn/stats v0.6.6 h1:Duep6KMIDpY4Yo11iFsvyqJDyfzLF9+sndUKT+v64GQ=
github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
Expand Down
89 changes: 88 additions & 1 deletion model/flow/protocol_state.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package flow

import "fmt"
import (
"fmt"
"sort"
)

// DynamicIdentityEntry encapsulates nodeID and dynamic portion of identity.
type DynamicIdentityEntry struct {
Expand Down Expand Up @@ -154,6 +157,59 @@ func (e *ProtocolStateEntry) ID() Identifier {
return MakeID(body)
}

// Copy returns a full copy of the entry.
durkmurder marked this conversation as resolved.
Show resolved Hide resolved
func (e *ProtocolStateEntry) Copy() *ProtocolStateEntry {
if e == nil {
return nil
}
return &ProtocolStateEntry{
CurrentEpochEventIDs: e.CurrentEpochEventIDs,
PreviousEpochEventIDs: e.PreviousEpochEventIDs,
Identities: e.Identities.Copy(),
InvalidStateTransitionAttempted: e.InvalidStateTransitionAttempted,
NextEpochProtocolState: e.NextEpochProtocolState.Copy(),
}
}

// Copy returns a full copy of rich protocol state entry.
AlexHentschel marked this conversation as resolved.
Show resolved Hide resolved
// Embedded service events are copied by reference (not deep-copied).
durkmurder marked this conversation as resolved.
Show resolved Hide resolved
func (e *RichProtocolStateEntry) Copy() *RichProtocolStateEntry {
if e == nil {
return nil
}
return &RichProtocolStateEntry{
ProtocolStateEntry: e.ProtocolStateEntry.Copy(),
CurrentEpochSetup: e.CurrentEpochSetup,
CurrentEpochCommit: e.CurrentEpochCommit,
PreviousEpochSetup: e.PreviousEpochSetup,
PreviousEpochCommit: e.PreviousEpochCommit,
Identities: e.Identities.Copy(),
NextEpochProtocolState: e.NextEpochProtocolState.Copy(),
}
}

// EpochStatus returns epoch status for the current protocol state.
func (e *ProtocolStateEntry) EpochStatus() *EpochStatus {
var nextEpoch EventIDs
if e.NextEpochProtocolState != nil {
nextEpoch = e.NextEpochProtocolState.CurrentEpochEventIDs
}
return &EpochStatus{
PreviousEpoch: e.PreviousEpochEventIDs,
CurrentEpoch: e.CurrentEpochEventIDs,
NextEpoch: nextEpoch,
InvalidServiceEventIncorporated: e.InvalidStateTransitionAttempted,
}
}

func (ll DynamicIdentityEntryList) Lookup() map[Identifier]*DynamicIdentityEntry {
result := make(map[Identifier]*DynamicIdentityEntry, len(ll))
for _, entry := range ll {
result[entry.NodeID] = entry
}
return result
}

// Sorted returns whether the list is sorted by the input ordering.
func (ll DynamicIdentityEntryList) Sorted(less IdentifierOrder) bool {
for i := 0; i < len(ll)-1; i++ {
Expand All @@ -166,6 +222,37 @@ func (ll DynamicIdentityEntryList) Sorted(less IdentifierOrder) bool {
return true
}

// ByNodeID gets a node from the list by node ID.
func (ll DynamicIdentityEntryList) ByNodeID(nodeID Identifier) (*DynamicIdentityEntry, bool) {
for _, identity := range ll {
if identity.NodeID == nodeID {
return identity, true
}
}
return nil, false
}

func (ll DynamicIdentityEntryList) Copy() DynamicIdentityEntryList {
durkmurder marked this conversation as resolved.
Show resolved Hide resolved
dup := make(DynamicIdentityEntryList, 0, len(ll))

lenList := len(ll)
for i := 0; i < lenList; i++ {
// copy the object
next := *(ll[i])
dup = append(dup, &next)
}
return dup
}

// Sort sorts the list by the input ordering. Returns a new, sorted list without modifying the input.
durkmurder marked this conversation as resolved.
Show resolved Hide resolved
func (ll DynamicIdentityEntryList) Sort(less IdentifierOrder) DynamicIdentityEntryList {
dup := ll.Copy()
sort.Slice(dup, func(i int, j int) bool {
return less(dup[i].NodeID, dup[j].NodeID)
})
return dup
}

// buildIdentityTable builds identity table for current epoch combining data from previous, current epoch setups and dynamic identities
// that are stored in protocol state. It also performs sanity checks to make sure that data is consistent.
// No errors are expected during normal operation.
Expand Down
26 changes: 26 additions & 0 deletions model/flow/protocol_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,29 @@ func TestNewRichProtocolStateEntry(t *testing.T) {
assert.Equal(t, expectedIdentities, richEntry.NextEpochProtocolState.Identities, "should be equal to next epoch setup participants + current epoch setup participants")
})
}

// TestProtocolStateEntry_Copy tests if the copy method returns a deep copy of the entry. All changes to cpy shouldn't affect the original entry.
durkmurder marked this conversation as resolved.
Show resolved Hide resolved
func TestProtocolStateEntry_Copy(t *testing.T) {
entry := unittest.ProtocolStateFixture(unittest.WithNextEpochProtocolState()).ProtocolStateEntry
cpy := entry.Copy()
assert.Equal(t, entry, cpy)
assert.NotSame(t, entry.NextEpochProtocolState, cpy.NextEpochProtocolState)
assert.NotSame(t, entry.PreviousEpochEventIDs, cpy.PreviousEpochEventIDs)
assert.NotSame(t, entry.CurrentEpochEventIDs, cpy.CurrentEpochEventIDs)

cpy.InvalidStateTransitionAttempted = !entry.InvalidStateTransitionAttempted
assert.NotEqual(t, entry, cpy)

assert.Equal(t, entry.Identities[0], cpy.Identities[0])
cpy.Identities[0].Dynamic.Weight = 123
assert.NotEqual(t, entry.Identities[0], cpy.Identities[0])

cpy.Identities = append(cpy.Identities, &flow.DynamicIdentityEntry{
NodeID: unittest.IdentifierFixture(),
Dynamic: flow.DynamicIdentity{
Weight: 100,
Ejected: false,
},
})
assert.NotEqual(t, entry.Identities, cpy.Identities)
}
4 changes: 2 additions & 2 deletions state/cluster/badger/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ type Params struct {
state *State
}

func (p *Params) ChainID() (flow.ChainID, error) {
return p.state.clusterID, nil
func (p *Params) ChainID() flow.ChainID {
return p.state.clusterID
}
4 changes: 1 addition & 3 deletions state/cluster/badger/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,6 @@ func (suite *SnapshotSuite) TestPending_Grandchildren() {
}

func (suite *SnapshotSuite) TestParams_ChainID() {

chainID, err := suite.state.Params().ChainID()
suite.Require().Nil(err)
chainID := suite.state.Params().ChainID()
suite.Assert().Equal(suite.genesis.Header.ChainID, chainID)
}
14 changes: 2 additions & 12 deletions state/cluster/mock/params.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions state/cluster/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (

// Params contains constant information about this cluster state.
type Params interface {

// ChainID returns the chain ID for this cluster.
// No errors are expected during normal operation.
ChainID() (flow.ChainID, error)
ChainID() flow.ChainID
}
5 changes: 1 addition & 4 deletions state/protocol/badger/mutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,10 +812,7 @@ func (m *FollowerState) epochFallbackTriggeredByFinalizedBlock(block *flow.Heade
}

// 2.(a) determine whether block B is past the epoch commitment deadline
safetyThreshold, err := m.Params().EpochCommitSafetyThreshold()
if err != nil {
return false, fmt.Errorf("could not get epoch commit safety threshold: %w", err)
}
safetyThreshold := m.Params().EpochCommitSafetyThreshold()
blockExceedsDeadline := block.View+safetyThreshold >= currentEpochSetup.FinalView

// 2.(b) determine whether the next epoch is committed w.r.t. block B
Expand Down
4 changes: 2 additions & 2 deletions state/protocol/badger/mutator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@ func TestEmergencyEpochFallback(t *testing.T) {
require.NoError(t, err)
result, _, err := rootSnapshot.SealedResult()
require.NoError(t, err)
safetyThreshold, err := rootSnapshot.Params().EpochCommitSafetyThreshold()
safetyThreshold := rootSnapshot.Params().EpochCommitSafetyThreshold()
require.NoError(t, err)

epoch1Setup := result.ServiceEvents[0].Event.(*flow.EpochSetup)
Expand Down Expand Up @@ -1744,7 +1744,7 @@ func TestEmergencyEpochFallback(t *testing.T) {
require.NoError(t, err)
result, _, err := rootSnapshot.SealedResult()
require.NoError(t, err)
safetyThreshold, err := rootSnapshot.Params().EpochCommitSafetyThreshold()
safetyThreshold := rootSnapshot.Params().EpochCommitSafetyThreshold()
require.NoError(t, err)

// add a block for the first seal to reference
Expand Down
Loading