Skip to content

Commit

Permalink
node: init blockchain state on startup
Browse files Browse the repository at this point in the history
Fixes #3066 on cold starts.

Signed-off-by: Pavel Karpy <[email protected]>
  • Loading branch information
carpawell committed Dec 24, 2024
1 parent 3a10bc1 commit 2b27bff
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/neofs-node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,9 @@ func initBasics(c *cfg, key *keys.PrivateKey, stateStorage *state.PersistentStor
lookupScriptHashesInNNS(cli, c.applicationConfiguration, &b)

nState := newNetworkState()
currBlock, err := cli.BlockCount()
fatalOnErr(err)
nState.block.Store(currBlock)

Check warning on line 730 in cmd/neofs-node/config.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/config.go#L728-L730

Added lines #L728 - L730 were not covered by tests

cnrWrap, err := cntClient.NewFromMorph(cli, b.containerSH, 0)
fatalOnErr(err)
Expand All @@ -738,6 +741,10 @@ func initBasics(c *cfg, key *keys.PrivateKey, stateStorage *state.PersistentStor
nmWrap, err := nmClient.NewFromMorph(cli, b.netmapSH, 0)
fatalOnErr(err)

eDuration, err := nmWrap.EpochDuration()
fatalOnErr(err)
nState.epochDuration.Store(eDuration)

Check warning on line 747 in cmd/neofs-node/config.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/config.go#L744-L747

Added lines #L744 - L747 were not covered by tests
ttl := c.applicationConfiguration.fsChain.cacheTTL
if ttl == 0 {
msPerBlock, err := cli.MsPerBlock()
Expand Down

0 comments on commit 2b27bff

Please sign in to comment.