diff --git a/docs/cli.md b/docs/cli.md index 7dc4a9e02..6ca7e521a 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -234,6 +234,7 @@ protocol-related settings described in the table below. | NativeActivations | `map[string][]uint32` | ContractManagement: [0]
StdLib: [0]
CryptoLib: [0]
LedgerContract: [0]
NeoToken: [0]
GasToken: [0]
PolicyContract: [0]
RoleManagement: [0]
OracleContract: [0] | The list of histories of native contracts updates. Each list item shod be presented as a known native contract name with the corresponding list of chain's heights. The contract is not active until chain reaches the first height value specified in the list. | `Notary` is supported. | | P2PNotaryRequestPayloadPoolSize | `int` | `1000` | Size of the node's P2P Notary request payloads memory pool where P2P Notary requests are stored before main or fallback transaction is completed and added to the chain.
This option is valid only if `P2PSigExtensions` are enabled. | Not supported by the C# node, thus may affect heterogeneous networks functionality. | | P2PSigExtensions | `bool` | `false` | Enables following additional Notary service related logic:
• Transaction attributes `NotValidBefore`, `Conflicts` and `NotaryAssisted`
• Network payload of the `P2PNotaryRequest` type
• Native `Notary` contract
• Notary node module | Not supported by the C# node, thus may affect heterogeneous networks functionality. | +| P2PStateExchangeExtensions | `bool` | `false` | Enables following P2P MPT state data exchange logic:
• `StateSyncInterval` protocol setting
• P2P commands `GetMPTDataCMD` and `MPTDataCMD` | Not supported by the C# node, thus may affect heterogeneous networks functionality. | | RemoveUntraceableBlocks | `bool`| `false` | Denotes whether old blocks should be removed from cache and database. If enabled, then only last `MaxTraceableBlocks` are stored and accessible to smart contracts. | | ReservedAttributes | `bool` | `false` | Allows to have reserved attributes range for experimental or private purposes. | | SaveStorageBatch | `bool` | `false` | Enables storage batch saving before every persist. It is similar to StorageDump plugin for C# node. | @@ -241,6 +242,7 @@ protocol-related settings described in the table below. | SeedList | `[]string` | [] | List of initial nodes addresses used to establish connectivity. | | StandbyCommittee | `[]string` | [] | List of public keys of standby committee validators are chosen from. | | StateRootInHeader | `bool` | `false` | Enables storing state root in block header. | Experimental protocol extension! | +| StateSyncInterval | `int` | `40000` | The number of blocks between state heights available for MPT state data synchronization. | `P2PStateExchangeExtensions` should be enabled to use this setting. | | ValidatorsCount | `int` | `0` | Number of validators. | | VerifyBlocks | `bool` | `false` | Denotes whether to verify received blocks. | | VerifyTransactions | `bool` | `false` | Denotes whether to verify transactions in received blocks. | diff --git a/pkg/config/protocol_config.go b/pkg/config/protocol_config.go index 9c3482933..656af153f 100644 --- a/pkg/config/protocol_config.go +++ b/pkg/config/protocol_config.go @@ -38,6 +38,8 @@ type ( NativeUpdateHistories map[string][]uint32 `yaml:"NativeActivations"` // P2PSigExtensions enables additional signature-related logic. P2PSigExtensions bool `yaml:"P2PSigExtensions"` + // P2PStateExchangeExtensions enables additional P2P MPT state data exchange logic. + P2PStateExchangeExtensions bool `yaml:"P2PStateExchangeExtensions"` // ReservedAttributes allows to have reserved attributes range for experimental or private purposes. ReservedAttributes bool `yaml:"ReservedAttributes"` // SaveStorageBatch enables storage batch saving before every persist. @@ -47,7 +49,10 @@ type ( StandbyCommittee []string `yaml:"StandbyCommittee"` // StateRooInHeader enables storing state root in block header. StateRootInHeader bool `yaml:"StateRootInHeader"` - ValidatorsCount int `yaml:"ValidatorsCount"` + // StateSyncInterval is the number of blocks between state heights available for MPT state data synchronization. + // It is valid only if P2PStateExchangeExtensions are enabled. + StateSyncInterval int `yaml:"StateSyncInterval"` + ValidatorsCount int `yaml:"ValidatorsCount"` // Whether to verify received blocks. VerifyBlocks bool `yaml:"VerifyBlocks"` // Whether to verify transactions in received blocks. diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index f9e9f3072..16edf08dd 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -54,6 +54,7 @@ const ( defaultMaxTransactionsPerBlock = 512 // HeaderVerificationGasLimit is the maximum amount of GAS for block header verification. HeaderVerificationGasLimit = 3_00000000 // 3 GAS + defaultStateSyncInterval = 40000 ) var ( @@ -208,6 +209,16 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L log.Info("MaxValidUntilBlockIncrement is not set or wrong, using default value", zap.Uint32("MaxValidUntilBlockIncrement", cfg.MaxValidUntilBlockIncrement)) } + if cfg.P2PStateExchangeExtensions { + if !cfg.StateRootInHeader { + return nil, errors.New("P2PStatesExchangeExtensions are enabled, but StateRootInHeader is off") + } + if cfg.StateSyncInterval <= 0 { + cfg.StateSyncInterval = defaultStateSyncInterval + log.Info("StateSyncInterval is not set or wrong, using default value", + zap.Int("StateSyncInterval", cfg.StateSyncInterval)) + } + } committee, err := committeeFromConfig(cfg) if err != nil { return nil, err