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

InitialProtocolState refactor and epoch protocol sub-state rename #5968

Merged
merged 27 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f8fffbb
move InitialProtocolState into DynProtoState
jordanschalm May 22, 2024
e348c38
rm InitialProtocolState
jordanschalm May 22, 2024
7930a65
rename DynamicProtocolState to EpochProtocolState
jordanschalm May 22, 2024
788e885
remove commented ByEpoch method
jordanschalm May 22, 2024
7edd829
rename test suite, adapter
jordanschalm May 22, 2024
cb6001d
rename dynamic_protocol_state files
jordanschalm May 22, 2024
9b79f69
renaming adapter references, vars
jordanschalm May 22, 2024
33d4945
rename epoch protocol state typed vars
jordanschalm May 22, 2024
d8d2b9f
remove initial protocol state files
jordanschalm May 22, 2024
287fd54
rename (Rich)ProtocolStateEntry
jordanschalm May 22, 2024
b4bd80a
rename storage.ProtocolState
jordanschalm May 22, 2024
b0c5ba4
rename ProtocolState.ByBlockID
jordanschalm May 22, 2024
f23b53e
update mocks
jordanschalm May 22, 2024
763a663
fix mock names in tests
jordanschalm May 22, 2024
0dd09d6
add missing godoc
jordanschalm May 22, 2024
ceb3d66
Merge branch 'master' into jord/initial-proto-state-refactor
jordanschalm May 28, 2024
a36e111
Apply suggestions from code review
jordanschalm May 28, 2024
007927b
rename RichEpochProtocolStateEntry comments, constructor, etc.
jordanschalm May 28, 2024
ff0831c
EpochProtocolState interface updates
jordanschalm May 28, 2024
a360767
rename EpochProtocolStateFromServiceEvents
jordanschalm May 28, 2024
8cdfb26
rename RootEpochProtocolStateFixture
jordanschalm May 28, 2024
4600168
update epoch protocol state naming in storage layer
jordanschalm May 28, 2024
59bef12
EpochProtocolStateEntries godoc
jordanschalm May 28, 2024
242f699
rename EpochProtocolStateEntries in all.go
jordanschalm May 28, 2024
0af615c
update mocks
jordanschalm May 28, 2024
e3a9664
Update storage/badger/epoch_protocol_state.go
jordanschalm May 28, 2024
3cc4dde
Update state/protocol/inmem/epoch_protocol_state.go
jordanschalm May 29, 2024
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
2 changes: 1 addition & 1 deletion cmd/bootstrap/cmd/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func constructRootBlock(rootHeader *flow.Header, setup *flow.EpochSetup, commit
Receipts: nil,
Results: nil,
// TODO: shortcut in bootstrapping; we will probably have to start with a non-empty KV store in the future
ProtocolStateID: kvstore.NewDefaultKVStore(inmem.ProtocolStateFromEpochServiceEvents(setup, commit).ID()).ID(),
ProtocolStateID: kvstore.NewDefaultKVStore(inmem.EpochProtocolStateFromServiceEvents(setup, commit).ID()).ID(),
})
return block
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/consensus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ func main() {
}).
Component("consensus participant", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
mutableProtocolState := protocol_state.NewMutableProtocolState(
node.Storage.EpochProtocolState,
node.Storage.EpochProtocolStateEntries,
node.Storage.ProtocolKVStore,
node.State.Params(),
node.Storage.Headers,
Expand Down
42 changes: 21 additions & 21 deletions cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -1181,30 +1181,30 @@ func (fnb *FlowNodeBuilder) initStorage() error {
setups := bstorage.NewEpochSetups(fnb.Metrics.Cache, fnb.DB)
epochCommits := bstorage.NewEpochCommits(fnb.Metrics.Cache, fnb.DB)
commits := bstorage.NewCommits(fnb.Metrics.Cache, fnb.DB)
protocolState := bstorage.NewProtocolState(fnb.Metrics.Cache, setups, epochCommits, fnb.DB,
bstorage.DefaultProtocolStateCacheSize, bstorage.DefaultProtocolStateByBlockIDCacheSize)
protocolState := bstorage.NewEpochProtocolStateEntries(fnb.Metrics.Cache, setups, epochCommits, fnb.DB,
bstorage.DefaultEpochProtocolStateCacheSize, bstorage.DefaultProtocolStateIndexCacheSize)
protocolKVStores := bstorage.NewProtocolKVStore(fnb.Metrics.Cache, fnb.DB,
bstorage.DefaultProtocolKVStoreCacheSize, bstorage.DefaultProtocolKVStoreByBlockIDCacheSize)
versionBeacons := bstorage.NewVersionBeacons(fnb.DB)

fnb.Storage = Storage{
Headers: headers,
Guarantees: guarantees,
Receipts: receipts,
Results: results,
Seals: seals,
Index: index,
Payloads: payloads,
Blocks: blocks,
QuorumCertificates: qcs,
Transactions: transactions,
Collections: collections,
Setups: setups,
EpochCommits: epochCommits,
VersionBeacons: versionBeacons,
EpochProtocolState: protocolState,
ProtocolKVStore: protocolKVStores,
Commits: commits,
Headers: headers,
Guarantees: guarantees,
Receipts: receipts,
Results: results,
Seals: seals,
Index: index,
Payloads: payloads,
Blocks: blocks,
QuorumCertificates: qcs,
Transactions: transactions,
Collections: collections,
Setups: setups,
EpochCommits: epochCommits,
VersionBeacons: versionBeacons,
EpochProtocolStateEntries: protocolState,
ProtocolKVStore: protocolKVStores,
Commits: commits,
}

return nil
Expand Down Expand Up @@ -1293,7 +1293,7 @@ func (fnb *FlowNodeBuilder) initState() error {
fnb.Storage.QuorumCertificates,
fnb.Storage.Setups,
fnb.Storage.EpochCommits,
fnb.Storage.EpochProtocolState,
fnb.Storage.EpochProtocolStateEntries,
fnb.Storage.ProtocolKVStore,
fnb.Storage.VersionBeacons,
)
Expand Down Expand Up @@ -1342,7 +1342,7 @@ func (fnb *FlowNodeBuilder) initState() error {
fnb.Storage.QuorumCertificates,
fnb.Storage.Setups,
fnb.Storage.EpochCommits,
fnb.Storage.EpochProtocolState,
fnb.Storage.EpochProtocolStateEntries,
fnb.Storage.ProtocolKVStore,
fnb.Storage.VersionBeacons,
fnb.RootSnapshot,
Expand Down
2 changes: 1 addition & 1 deletion cmd/util/cmd/common/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func InitProtocolState(db *badger.DB, storages *storage.All) (protocol.State, er
storages.QuorumCertificates,
storages.Setups,
storages.EpochCommits,
storages.EpochProtocolState,
storages.EpochProtocolStateEntries,
storages.ProtocolKVStore,
storages.VersionBeacons,
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/util/cmd/read-badger/cmd/epoch_protocol_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var epochProtocolStateCmd = &cobra.Command{
}

log.Info().Msgf("getting protocol state by block id: %v", blockID)
protocolState, err := storages.EpochProtocolState.ByBlockID(blockID)
protocolState, err := storages.EpochProtocolStateEntries.ByBlockID(blockID)
if err != nil {
log.Error().Err(err).Msgf("could not get protocol state for block id: %v", blockID)
return
Expand Down
4 changes: 2 additions & 2 deletions consensus/integration/epoch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ func withNextEpoch(
ActiveIdentities: flow.DynamicIdentityEntryListFromIdentities(nextEpochIdentities),
}
// Re-construct epoch protocol state with modified events (constructs ActiveIdentity fields)
epochProtocolState, err = flow.NewRichProtocolStateEntry(
epochProtocolState.ProtocolStateEntry,
epochProtocolState, err = flow.NewRichEpochProtocolStateEntry(
epochProtocolState.EpochProtocolStateEntry,
epochProtocolState.PreviousEpochSetup, epochProtocolState.PreviousEpochCommit,
currEpochSetup, currEpochCommit,
nextEpochSetup, nextEpochCommit)
Expand Down
6 changes: 3 additions & 3 deletions consensus/integration/nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func createRootBlockData(participantData *run.ParticipantData) (*flow.Block, *fl
},
)

epochProtocolStateID := inmem.ProtocolStateFromEpochServiceEvents(setup, commit).ID()
epochProtocolStateID := inmem.EpochProtocolStateFromServiceEvents(setup, commit).ID()
root.SetPayload(flow.Payload{ProtocolStateID: kvstore.NewDefaultKVStore(epochProtocolStateID).ID()})
result := unittest.BootstrapExecutionResultFixture(root, unittest.GenesisStateCommitment)
result.ServiceEvents = []flow.ServiceEvent{setup.ServiceEvent(), commit.ServiceEvent()}
Expand Down Expand Up @@ -378,8 +378,8 @@ func createNode(
qcsDB := storage.NewQuorumCertificates(metricsCollector, db, storage.DefaultCacheSize)
setupsDB := storage.NewEpochSetups(metricsCollector, db)
commitsDB := storage.NewEpochCommits(metricsCollector, db)
protocolStateDB := storage.NewProtocolState(metricsCollector, setupsDB, commitsDB, db,
storage.DefaultProtocolStateCacheSize, storage.DefaultProtocolStateByBlockIDCacheSize)
protocolStateDB := storage.NewEpochProtocolStateEntries(metricsCollector, setupsDB, commitsDB, db,
storage.DefaultEpochProtocolStateCacheSize, storage.DefaultProtocolStateIndexCacheSize)
protocokKVStoreDB := storage.NewProtocolKVStore(metricsCollector, db,
storage.DefaultProtocolKVStoreCacheSize, storage.DefaultProtocolKVStoreByBlockIDCacheSize)
versionBeaconDB := storage.NewVersionBeacons(db)
Expand Down
2 changes: 1 addition & 1 deletion engine/collection/test/cluster_switchover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func NewClusterSwitchoverTestCase(t *testing.T, conf ClusterSwitchoverTestConf)

seal.ResultID = result.ID()
root.Payload.ProtocolStateID = kvstore.NewDefaultKVStore(
inmem.ProtocolStateFromEpochServiceEvents(setup, commit).ID()).ID()
inmem.EpochProtocolStateFromServiceEvents(setup, commit).ID()).ID()
tc.root, err = inmem.SnapshotFromBootstrapState(root, result, seal, qc)
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion engine/common/follower/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestFollowerHappyPath(t *testing.T) {
all.QuorumCertificates,
all.Setups,
all.EpochCommits,
all.EpochProtocolState,
all.EpochProtocolStateEntries,
all.ProtocolKVStore,
all.VersionBeacons,
rootSnapshot,
Expand Down
2 changes: 1 addition & 1 deletion engine/testutil/mock/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type GenericNode struct {
Results storage.ExecutionResults
Setups storage.EpochSetups
EpochCommits storage.EpochCommits
EpochProtocolState storage.ProtocolState
EpochProtocolState storage.EpochProtocolStateEntries
ProtocolKVStore storage.ProtocolKVStore
State protocol.ParticipantState
Index storage.Index
Expand Down
4 changes: 2 additions & 2 deletions engine/testutil/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func GenericNodeWithStateFixture(t testing.TB,
Results: stateFixture.Storage.Results,
Setups: stateFixture.Storage.Setups,
EpochCommits: stateFixture.Storage.EpochCommits,
EpochProtocolState: stateFixture.Storage.EpochProtocolState,
EpochProtocolState: stateFixture.Storage.EpochProtocolStateEntries,
ProtocolKVStore: stateFixture.Storage.ProtocolKVStore,
State: stateFixture.State,
Index: stateFixture.Storage.Index,
Expand Down Expand Up @@ -245,7 +245,7 @@ func CompleteStateFixture(
s.QuorumCertificates,
s.Setups,
s.EpochCommits,
s.EpochProtocolState,
s.EpochProtocolStateEntries,
s.ProtocolKVStore,
s.VersionBeacons,
rootSnapshot,
Expand Down
2 changes: 1 addition & 1 deletion engine/verification/utils/unittest/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ func bootstrapSystem(
identities = append(identities, verID.Identity())

mutableProtocolState := protocol_state.NewMutableProtocolState(
stateFixture.Storage.EpochProtocolState,
stateFixture.Storage.EpochProtocolStateEntries,
stateFixture.Storage.ProtocolKVStore,
stateFixture.State.Params(),
stateFixture.Storage.Headers,
Expand Down
4 changes: 2 additions & 2 deletions integration/testnet/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ func (c *Container) OpenState() (*state.State, error) {
qcs := storage.NewQuorumCertificates(metrics, db, storage.DefaultCacheSize)
setups := storage.NewEpochSetups(metrics, db)
commits := storage.NewEpochCommits(metrics, db)
protocolState := storage.NewProtocolState(metrics, setups, commits, db,
storage.DefaultProtocolStateCacheSize, storage.DefaultProtocolStateByBlockIDCacheSize)
protocolState := storage.NewEpochProtocolStateEntries(metrics, setups, commits, db,
storage.DefaultEpochProtocolStateCacheSize, storage.DefaultProtocolStateIndexCacheSize)
protocolKVStates := storage.NewProtocolKVStore(metrics, db,
storage.DefaultProtocolKVStoreCacheSize, storage.DefaultProtocolKVStoreByBlockIDCacheSize)
versionBeacons := storage.NewVersionBeacons(db)
Expand Down
2 changes: 1 addition & 1 deletion integration/testnet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ func BootstrapNetwork(networkConf NetworkConfig, bootstrapDir string, chainID fl
}
root.SetPayload(unittest.PayloadFixture(unittest.WithProtocolStateID(
networkConf.KVStoreFactory(
inmem.ProtocolStateFromEpochServiceEvents(epochSetup, epochCommit).ID(),
inmem.EpochProtocolStateFromServiceEvents(epochSetup, epochCommit).ID(),
).ID(),
)))

Expand Down
Loading
Loading