From 373fce54e6986881fc7d0acf2abd4cede3f450f7 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 8 Feb 2022 21:47:17 +0300 Subject: [PATCH] config: conflict P2PStateExchangeExtensions/KeepOnlyLatestState They don't make sense together, for P2P state exchange to be possible we need a set of MPTs. --- docs/node-configuration.md | 4 ++-- pkg/config/protocol_config.go | 3 +++ pkg/config/protocol_config_test.go | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/node-configuration.md b/docs/node-configuration.md index b4e04a2c2..9591981ba 100644 --- a/docs/node-configuration.md +++ b/docs/node-configuration.md @@ -200,7 +200,7 @@ protocol-related settings described in the table below. | CommitteeHistory | map[uint32]int | none | Number of committee members after given height, for example `{0: 1, 20: 4}` sets up a chain with one committee member since the genesis and then changes the setting to 4 committee members at the height of 20. `StandbyCommittee` committee setting must have the number of keys equal or exceeding the highest value in this option. Blocks numbers where the change happens must be divisble by the old and by the new values simultaneously. If not set, committee size is derived from the `StandbyCommittee` setting and never changes. | | GarbageCollectionPeriod | `uint32` | 10000 | Controls MPT garbage collection interval (in blocks) for configurations with `RemoveUntraceableBlocks` enabled and `KeepOnlyLatestState` disabled. In this mode the node stores a number of MPT trees (corresponding to `MaxTraceableBlocks` and `StateSyncInterval`), but the DB needs to be clean from old entries from time to time. Doing it too often will cause too much processing overhead, doing it too rarely will leave more useless data in the DB. | | KeepOnlyLatestState | `bool` | `false` | Specifies if MPT should only store latest state. If true, DB size will be smaller, but older roots won't be accessible. This value should remain th -e same for the same database. | +e same for the same database. | Conflicts with `P2PStateExchangeExtensions`. | | Magic | `uint32` | `0` | Magic number which uniquely identifies NEO network. | | MaxBlockSize | `uint32` | `262144` | Maximum block size in bytes. | | MaxBlockSystemFee | `int64` | `900000000000` | Maximum overall transactions system fee per block. | @@ -210,7 +210,7 @@ e same for the same database. | | 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. | +| 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. Conflicts with `KeepOnlyLatestState`. | | 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. Old MPT data is also deleted in accordance with `GarbageCollectionPeriod` setting. | | 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. | diff --git a/pkg/config/protocol_config.go b/pkg/config/protocol_config.go index 007602d0c..c2f5dff01 100644 --- a/pkg/config/protocol_config.go +++ b/pkg/config/protocol_config.go @@ -86,6 +86,9 @@ type heightNumber struct { func (p *ProtocolConfiguration) Validate() error { var err error + if p.KeepOnlyLatestState && p.P2PStateExchangeExtensions { + return errors.New("can't have both KeepOnlyLatestState and P2PStateExchangeExtensions") + } for name := range p.NativeUpdateHistories { if !nativenames.IsValid(name) { return fmt.Errorf("NativeActivations configuration section contains unexpected native contract name: %s", name) diff --git a/pkg/config/protocol_config_test.go b/pkg/config/protocol_config_test.go index b2c978279..2d3c2d811 100644 --- a/pkg/config/protocol_config_test.go +++ b/pkg/config/protocol_config_test.go @@ -8,6 +8,15 @@ import ( func TestProtocolConfigurationValidation(t *testing.T) { p := &ProtocolConfiguration{ + StandbyCommittee: []string{ + "02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2", + }, + ValidatorsCount: 1, + KeepOnlyLatestState: true, + P2PStateExchangeExtensions: true, + } + require.Error(t, p.Validate()) + p = &ProtocolConfiguration{ ValidatorsCount: 1, } require.Error(t, p.Validate())