mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-04 19:19:44 +00:00
*: specify first state root index in config
This commit is contained in:
parent
d128b55dbf
commit
b5fb63d091
3 changed files with 21 additions and 6 deletions
|
@ -2,6 +2,8 @@ ProtocolConfiguration:
|
|||
Magic: 1953787457
|
||||
AddressVersion: 23
|
||||
SecondsPerBlock: 15
|
||||
EnableStateRoot: true
|
||||
StateRootEnableIndex: 4380100
|
||||
LowPriorityThreshold: 0.000
|
||||
MemPoolSize: 50000
|
||||
StandbyValidators:
|
||||
|
|
|
@ -36,11 +36,13 @@ type (
|
|||
MaxFreeTransactionsPerBlock int `yaml:"MaxFreeTransactionsPerBlock"`
|
||||
MemPoolSize int `yaml:"MemPoolSize"`
|
||||
// SaveStorageBatch enables storage batch saving before every persist.
|
||||
SaveStorageBatch bool `yaml:"SaveStorageBatch"`
|
||||
SecondsPerBlock int `yaml:"SecondsPerBlock"`
|
||||
SeedList []string `yaml:"SeedList"`
|
||||
StandbyValidators []string `yaml:"StandbyValidators"`
|
||||
SystemFee SystemFee `yaml:"SystemFee"`
|
||||
SaveStorageBatch bool `yaml:"SaveStorageBatch"`
|
||||
SecondsPerBlock int `yaml:"SecondsPerBlock"`
|
||||
SeedList []string `yaml:"SeedList"`
|
||||
StandbyValidators []string `yaml:"StandbyValidators"`
|
||||
// StateRootEnableIndex specifies starting height for state root calculations and exchange.
|
||||
StateRootEnableIndex uint32 `yaml:"StateRootEnableIndex"`
|
||||
SystemFee SystemFee `yaml:"SystemFee"`
|
||||
// Whether to verify received blocks.
|
||||
VerifyBlocks bool `yaml:"VerifyBlocks"`
|
||||
// Whether to verify transactions in received blocks.
|
||||
|
|
|
@ -602,7 +602,8 @@ func (s *Server) handleGetHeadersCmd(p Peer, gh *payload.GetBlocks) error {
|
|||
|
||||
// handleGetRootsCmd processees `getroots` request.
|
||||
func (s *Server) handleGetRootsCmd(p Peer, gr *payload.GetStateRoots) error {
|
||||
if !s.chain.GetConfig().EnableStateRoot {
|
||||
cfg := s.chain.GetConfig()
|
||||
if !cfg.EnableStateRoot || gr.Start < cfg.StateRootEnableIndex {
|
||||
return nil
|
||||
}
|
||||
count := gr.Count
|
||||
|
@ -628,6 +629,9 @@ func (s *Server) handleRootsCmd(p Peer, rs *payload.StateRoots) error {
|
|||
return nil
|
||||
}
|
||||
h := s.chain.StateHeight()
|
||||
if h < s.chain.GetConfig().StateRootEnableIndex {
|
||||
h = s.chain.GetConfig().StateRootEnableIndex
|
||||
}
|
||||
for i := range rs.Roots {
|
||||
if rs.Roots[i].Index <= h {
|
||||
continue
|
||||
|
@ -642,6 +646,13 @@ func (s *Server) handleRootsCmd(p Peer, rs *payload.StateRoots) error {
|
|||
func (s *Server) requestStateRoot(p Peer) error {
|
||||
stateHeight := s.chain.StateHeight()
|
||||
hdrHeight := s.chain.BlockHeight()
|
||||
enableIndex := s.chain.GetConfig().StateRootEnableIndex
|
||||
if hdrHeight < enableIndex {
|
||||
return nil
|
||||
}
|
||||
if stateHeight < enableIndex {
|
||||
stateHeight = enableIndex - 1
|
||||
}
|
||||
count := uint32(payload.MaxStateRootsAllowed)
|
||||
if diff := hdrHeight - stateHeight; diff < count {
|
||||
count = diff
|
||||
|
|
Loading…
Reference in a new issue