mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
config: drop deprecated Protocol configurations
Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
parent
9f7b19f886
commit
460362ab2e
7 changed files with 6 additions and 75 deletions
12
ROADMAP.md
12
ROADMAP.md
|
@ -26,18 +26,6 @@ APIs/commands/configurations will be removed and here is a list of scheduled
|
|||
breaking changes. Consider changing your code/scripts/configurations if you're
|
||||
using anything mentioned here.
|
||||
|
||||
## Node-specific configuration moved from Protocol to Application
|
||||
|
||||
GarbageCollectionPeriod, KeepOnlyLatestState, RemoveUntraceableBlocks,
|
||||
SaveStorageBatch and VerifyBlocks settings were moved from
|
||||
ProtocolConfiguration to ApplicationConfiguration in version 0.100.0. Old
|
||||
configurations are still supported, except for VerifyBlocks which is replaced
|
||||
by SkipBlockVerification with inverted meaning (and hence an inverted default)
|
||||
for security reasons.
|
||||
|
||||
Removal of these options from ProtocolConfiguration is scheduled for May-June
|
||||
2023 (~0.103.0 release).
|
||||
|
||||
## GetPeers RPC server response type changes and RPC client support
|
||||
|
||||
GetPeers RPC command returns a list of Peers where the port type has changed from
|
||||
|
|
|
@ -325,9 +325,7 @@ protocol-related settings described in the table below.
|
|||
| Section | Type | Default value | Description | Notes |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| CommitteeHistory | map[uint32]uint32 | none | Number of committee members after the 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 divisible 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. This setting is deprecated in favor of the same setting in the ApplicationConfiguration and will be removed in future node versions. If both settings are used, ApplicationConfiguration is prioritized over this one. |
|
||||
| Hardforks | `map[string]uint32` | [] | The set of incompatible changes that affect node behaviour starting from the specified height. The default value is an empty set which should be interpreted as "each known hard-fork is applied from the zero blockchain height". The list of valid hard-fork names:<br>• `Aspidochelone` represents hard-fork introduced in [#2469](https://github.com/nspcc-dev/neo-go/pull/2469) (ported from the [reference](https://github.com/neo-project/neo/pull/2712)). It adjusts the prices of `System.Contract.CreateStandardAccount` and `System.Contract.CreateMultisigAccount` interops so that the resulting prices are in accordance with `sha256` method of native `CryptoLib` contract. It also includes [#2519](https://github.com/nspcc-dev/neo-go/pull/2519) (ported from the [reference](https://github.com/neo-project/neo/pull/2749)) that adjusts the price of `System.Runtime.GetRandom` interop and fixes its vulnerability. A special NeoGo-specific change is included as well for ContractManagement's update/deploy call flags behaviour to be compatible with pre-0.99.0 behaviour that was changed because of the [3.2.0 protocol change](https://github.com/neo-project/neo/pull/2653).<br>• `Basilisk` represents hard-fork introduced in [#3056](https://github.com/nspcc-dev/neo-go/pull/3056) (ported from the [reference](https://github.com/neo-project/neo/pull/2881)). It enables strict smart contract script check against a set of JMP instructions and against method boundaries enabled on contract deploy or update. It also includes [#3080](https://github.com/nspcc-dev/neo-go/pull/3080) (ported from the [reference](https://github.com/neo-project/neo/pull/2883)) that increases `stackitem.Integer` JSON parsing precision up to the maximum value supported by the NeoVM. It also includes [#3085](https://github.com/nspcc-dev/neo-go/pull/3085) (ported from the [reference](https://github.com/neo-project/neo/pull/2810)) that enables strict check for notifications emitted by a contract to precisely match the events specified in the contract manifest. |
|
||||
| KeepOnlyLatestState | `bool` | `false` | Specifies if MPT should only store the latest state (or a set of latest states, see `P2PStateExcangeExtensions` section for details). If true, DB size will be smaller, but older roots won't be accessible. This value should remain the same for the same database. | This setting is deprecated in favor of the same setting in the ApplicationConfiguration and will be removed in future node versions. If both settings are used, setting any of them to true enables the function. |
|
||||
| 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. |
|
||||
|
@ -339,9 +337,7 @@ protocol-related settings described in the table below.
|
|||
| 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.<br>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:<br>• Transaction attribute `NotaryAssisted`<br>• Network payload of the `P2PNotaryRequest` type<br>• Native `Notary` contract<br>• Notary node module | Not supported by the C# node, thus may affect heterogeneous networks functionality. |
|
||||
| P2PStateExchangeExtensions | `bool` | `false` | Enables the following P2P MPT state data exchange logic: <br>• `StateSyncInterval` protocol setting <br>• P2P commands `GetMPTDataCMD` and `MPTDataCMD` | Not supported by the C# node, thus may affect heterogeneous networks functionality. Can be supported either on MPT-complete node (`KeepOnlyLatestState`=`false`) or on light GC-enabled node (`RemoveUntraceableBlocks=true`) in which case `KeepOnlyLatestState` setting doesn't change the behavior, an appropriate set of MPTs is always stored (see `RemoveUntraceableBlocks`). |
|
||||
| RemoveUntraceableBlocks | `bool`| `false` | Denotes whether old blocks should be removed from cache and database. If enabled, then only the last `MaxTraceableBlocks` are stored and accessible to smart contracts. Old MPT data is also deleted in accordance with `GarbageCollectionPeriod` setting. If enabled along with `P2PStateExchangeExtensions`, then old blocks and MPT states will be removed up to the second latest state synchronisation point (see `StateSyncInterval`). | This setting is deprecated in favor of the same setting in the ApplicationConfiguration and will be removed in future node versions. If both settings are used, setting any of them to true enables the function. |
|
||||
| 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. | This setting is deprecated in favor of the same setting in the ApplicationConfiguration and will be removed in future node versions. If both settings are used, setting any of them to true enables the function. |
|
||||
| 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! |
|
||||
|
@ -349,5 +345,4 @@ protocol-related settings described in the table below.
|
|||
| TimePerBlock | `Duration` | `15s` | Minimal (and targeted for) time interval between blocks. Must be an integer number of milliseconds. |
|
||||
| ValidatorsCount | `uint32` | `0` | Number of validators set for the whole network lifetime, can't be set if `ValidatorsHistory` setting is used. |
|
||||
| ValidatorsHistory | map[uint32]uint32 | none | Number of consensus nodes to use after given height (see `CommitteeHistory` also). Heights where the change occurs must be divisible by the number of committee members at that height. Can't be used with `ValidatorsCount` not equal to zero. |
|
||||
| VerifyBlocks | `bool` | `false` | This setting is deprecated and no longer works, please use `SkipBlockVerification` in the `ApplicationConfiguration`, it will be removed in future node versions. |
|
||||
| VerifyTransactions | `bool` | `false` | Denotes whether to verify transactions in the received blocks. |
|
||||
|
|
|
@ -16,12 +16,6 @@ type (
|
|||
ProtocolConfiguration struct {
|
||||
// CommitteeHistory stores committee size change history (height: size).
|
||||
CommitteeHistory map[uint32]uint32 `yaml:"CommitteeHistory"`
|
||||
// GarbageCollectionPeriod sets the number of blocks to wait before
|
||||
// starting the next MPT garbage collection cycle when RemoveUntraceableBlocks
|
||||
// option is used.
|
||||
//
|
||||
// Deprecated: please use the same setting in the ApplicationConfiguration, this field will be removed in future versions.
|
||||
GarbageCollectionPeriod uint32 `yaml:"GarbageCollectionPeriod"`
|
||||
|
||||
Magic netmode.Magic `yaml:"Magic"`
|
||||
MemPoolSize int `yaml:"MemPoolSize"`
|
||||
|
@ -34,16 +28,6 @@ type (
|
|||
// P2PNotaryRequestPayloadPoolSize specifies the memory pool size for P2PNotaryRequestPayloads.
|
||||
// It is valid only if P2PSigExtensions are enabled.
|
||||
P2PNotaryRequestPayloadPoolSize int `yaml:"P2PNotaryRequestPayloadPoolSize"`
|
||||
// KeepOnlyLatestState specifies if MPT should only store the latest state.
|
||||
// If true, DB size will be smaller, but older roots won't be accessible.
|
||||
// This value should remain the same for the same database.
|
||||
//
|
||||
// Deprecated: please use the same setting in the ApplicationConfiguration, this field will be removed in future versions.
|
||||
KeepOnlyLatestState bool `yaml:"KeepOnlyLatestState"`
|
||||
// RemoveUntraceableBlocks specifies if old data should be removed.
|
||||
//
|
||||
// Deprecated: please use the same setting in the ApplicationConfiguration, this field will be removed in future versions.
|
||||
RemoveUntraceableBlocks bool `yaml:"RemoveUntraceableBlocks"`
|
||||
// MaxBlockSize is the maximum block size in bytes.
|
||||
MaxBlockSize uint32 `yaml:"MaxBlockSize"`
|
||||
// MaxBlockSystemFee is the maximum overall system fee per block.
|
||||
|
@ -64,10 +48,7 @@ type (
|
|||
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.
|
||||
//
|
||||
// Deprecated: please use the same setting in the ApplicationConfiguration, this field will be removed in future versions.
|
||||
SaveStorageBatch bool `yaml:"SaveStorageBatch"`
|
||||
|
||||
SeedList []string `yaml:"SeedList"`
|
||||
StandbyCommittee []string `yaml:"StandbyCommittee"`
|
||||
// StateRooInHeader enables storing state root in block header.
|
||||
|
@ -81,10 +62,6 @@ type (
|
|||
ValidatorsCount uint32 `yaml:"ValidatorsCount"`
|
||||
// Validators stores history of changes to consensus node number (height: number).
|
||||
ValidatorsHistory map[uint32]uint32 `yaml:"ValidatorsHistory"`
|
||||
// Whether to verify received blocks.
|
||||
//
|
||||
// Deprecated: please use the same setting in the ApplicationConfiguration, this field will be removed in future versions.
|
||||
VerifyBlocks bool `yaml:"VerifyBlocks"`
|
||||
// Whether to verify transactions in the received blocks.
|
||||
VerifyTransactions bool `yaml:"VerifyTransactions"`
|
||||
}
|
||||
|
@ -102,9 +79,6 @@ type heightNumber struct {
|
|||
func (p *ProtocolConfiguration) Validate() error {
|
||||
var err error
|
||||
|
||||
if p.P2PStateExchangeExtensions && p.KeepOnlyLatestState && !p.RemoveUntraceableBlocks {
|
||||
return fmt.Errorf("P2PStateExchangeExtensions can be enabled either on MPT-complete node (KeepOnlyLatestState=false) or on light GC-enabled node (RemoveUntraceableBlocks=true)")
|
||||
}
|
||||
if p.TimePerBlock%time.Millisecond != 0 {
|
||||
return errors.New("TimePerBlock must be an integer number of milliseconds")
|
||||
}
|
||||
|
@ -240,9 +214,7 @@ func (p *ProtocolConfiguration) ShouldUpdateCommitteeAt(height uint32) bool {
|
|||
// Equals allows to compare two ProtocolConfiguration instances, returns true if
|
||||
// they're equal.
|
||||
func (p *ProtocolConfiguration) Equals(o *ProtocolConfiguration) bool {
|
||||
if p.GarbageCollectionPeriod != o.GarbageCollectionPeriod ||
|
||||
p.InitialGASSupply != o.InitialGASSupply ||
|
||||
p.KeepOnlyLatestState != o.KeepOnlyLatestState ||
|
||||
if p.InitialGASSupply != o.InitialGASSupply ||
|
||||
p.Magic != o.Magic ||
|
||||
p.MaxBlockSize != o.MaxBlockSize ||
|
||||
p.MaxBlockSystemFee != o.MaxBlockSystemFee ||
|
||||
|
@ -253,14 +225,11 @@ func (p *ProtocolConfiguration) Equals(o *ProtocolConfiguration) bool {
|
|||
p.P2PNotaryRequestPayloadPoolSize != o.P2PNotaryRequestPayloadPoolSize ||
|
||||
p.P2PSigExtensions != o.P2PSigExtensions ||
|
||||
p.P2PStateExchangeExtensions != o.P2PStateExchangeExtensions ||
|
||||
p.RemoveUntraceableBlocks != o.RemoveUntraceableBlocks ||
|
||||
p.ReservedAttributes != o.ReservedAttributes ||
|
||||
p.SaveStorageBatch != o.SaveStorageBatch ||
|
||||
p.StateRootInHeader != o.StateRootInHeader ||
|
||||
p.StateSyncInterval != o.StateSyncInterval ||
|
||||
p.TimePerBlock != o.TimePerBlock ||
|
||||
p.ValidatorsCount != o.ValidatorsCount ||
|
||||
p.VerifyBlocks != o.VerifyBlocks ||
|
||||
p.VerifyTransactions != o.VerifyTransactions ||
|
||||
len(p.CommitteeHistory) != len(o.CommitteeHistory) ||
|
||||
len(p.Hardforks) != len(o.Hardforks) ||
|
||||
|
|
|
@ -10,15 +10,6 @@ import (
|
|||
|
||||
func TestProtocolConfigurationValidation(t *testing.T) {
|
||||
p := &ProtocolConfiguration{
|
||||
StandbyCommittee: []string{
|
||||
"02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2",
|
||||
},
|
||||
ValidatorsCount: 1,
|
||||
KeepOnlyLatestState: true,
|
||||
P2PStateExchangeExtensions: true,
|
||||
}
|
||||
require.Error(t, p.Validate())
|
||||
p = &ProtocolConfiguration{
|
||||
StandbyCommittee: []string{
|
||||
"02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2",
|
||||
},
|
||||
|
|
|
@ -272,6 +272,9 @@ func NewBlockchain(s storage.Store, cfg config.Blockchain, log *zap.Logger) (*Bl
|
|||
if !cfg.StateRootInHeader {
|
||||
return nil, errors.New("P2PStatesExchangeExtensions are enabled, but StateRootInHeader is off")
|
||||
}
|
||||
if cfg.KeepOnlyLatestState && !cfg.RemoveUntraceableBlocks {
|
||||
return nil, errors.New("P2PStateExchangeExtensions can be enabled either on MPT-complete node (KeepOnlyLatestState=false) or on light GC-enabled node (RemoveUntraceableBlocks=true)")
|
||||
}
|
||||
if cfg.StateSyncInterval <= 0 {
|
||||
cfg.StateSyncInterval = defaultStateSyncInterval
|
||||
log.Info("StateSyncInterval is not set or wrong, using default value",
|
||||
|
@ -299,13 +302,6 @@ func NewBlockchain(s storage.Store, cfg config.Blockchain, log *zap.Logger) (*Bl
|
|||
break
|
||||
}
|
||||
}
|
||||
// Compatibility with the old ProtocolConfiguration.
|
||||
if cfg.ProtocolConfiguration.GarbageCollectionPeriod > 0 && cfg.Ledger.GarbageCollectionPeriod == 0 { //nolint:staticcheck // SA1019: cfg.ProtocolConfiguration.GarbageCollectionPeriod is deprecated
|
||||
cfg.Ledger.GarbageCollectionPeriod = cfg.ProtocolConfiguration.GarbageCollectionPeriod //nolint:staticcheck // SA1019: cfg.ProtocolConfiguration.GarbageCollectionPeriod is deprecated
|
||||
}
|
||||
cfg.Ledger.KeepOnlyLatestState = cfg.Ledger.KeepOnlyLatestState || cfg.ProtocolConfiguration.KeepOnlyLatestState //nolint:staticcheck // SA1019: cfg.ProtocolConfiguration.KeepOnlyLatestState is deprecated
|
||||
cfg.Ledger.RemoveUntraceableBlocks = cfg.Ledger.RemoveUntraceableBlocks || cfg.ProtocolConfiguration.RemoveUntraceableBlocks //nolint:staticcheck // SA1019: cfg.ProtocolConfiguration.RemoveUntraceableBlocks is deprecated
|
||||
cfg.Ledger.SaveStorageBatch = cfg.Ledger.SaveStorageBatch || cfg.ProtocolConfiguration.SaveStorageBatch //nolint:staticcheck // SA1019: cfg.ProtocolConfiguration.SaveStorageBatch is deprecated
|
||||
|
||||
// Local config consistency checks.
|
||||
if cfg.Ledger.RemoveUntraceableBlocks && cfg.Ledger.GarbageCollectionPeriod == 0 {
|
||||
|
|
|
@ -219,7 +219,7 @@ func TestBlockchain_InitWithIncompleteStateJump(t *testing.T) {
|
|||
checkNewBlockchainErr(t, func(c *config.Config) {
|
||||
boltCfg(c)
|
||||
c.ApplicationConfiguration.RemoveUntraceableBlocks = false
|
||||
}, bcSpout.dao.Store, "state jump was not completed, but P2PStateExchangeExtensions are disabled or archival node capability is on")
|
||||
}, bcSpout.dao.Store, "P2PStateExchangeExtensions can be enabled either on MPT-complete node")
|
||||
})
|
||||
t.Run("invalid state sync point", func(t *testing.T) {
|
||||
bcSpout.dao.Store.Put(bPrefix, []byte{byte(stateJumpStarted)})
|
||||
|
|
|
@ -37,14 +37,6 @@ func TestStateSyncModule_Init(t *testing.T) {
|
|||
c.Ledger.KeepOnlyLatestState = true
|
||||
c.Ledger.RemoveUntraceableBlocks = true
|
||||
}
|
||||
t.Run("error: module disabled by config", func(t *testing.T) {
|
||||
bcBolt, _, _ := chain.NewMultiWithCustomConfig(t, func(c *config.Blockchain) {
|
||||
boltCfg(c)
|
||||
c.Ledger.RemoveUntraceableBlocks = false
|
||||
})
|
||||
module := bcBolt.GetStateSyncModule()
|
||||
require.Error(t, module.Init(bcSpout.BlockHeight())) // module inactive (non-archival node)
|
||||
})
|
||||
|
||||
t.Run("inactive: spout chain is too low to start state sync process", func(t *testing.T) {
|
||||
bcBolt, _, _ := chain.NewMultiWithCustomConfig(t, boltCfg)
|
||||
|
|
Loading…
Reference in a new issue