Skip to content

Commit f9c91f0

Browse files
committedApr 9, 2024
config, native: introduce Cockatrice hard-fork
With all associated native API changes ported from neo-project/neo#2925 and neo-project/neo#3154. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
1 parent 7e4b22f commit f9c91f0

File tree

8 files changed

+25
-8
lines changed

8 files changed

+25
-8
lines changed
 

‎cli/vm/cli_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ func newTestVMClIWithState(t *testing.T) *executor {
134134
}
135135
bc, validators, committee, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, customConfig, store)
136136
require.NoError(t, err)
137+
138+
// Save config for future usage.
139+
protoCfg := bc.GetConfig()
140+
137141
go bc.Run()
138142
e := neotest.NewExecutor(t, bc, validators, committee)
139143
basicchain.InitSimple(t, "../../", e)
@@ -145,7 +149,9 @@ func newTestVMClIWithState(t *testing.T) *executor {
145149
require.NoError(t, err)
146150
cfg.ApplicationConfiguration.DBConfiguration.Type = dbconfig.LevelDB
147151
cfg.ApplicationConfiguration.DBConfiguration.LevelDBOptions = opts
148-
cfg.ProtocolConfiguration.StateRootInHeader = true
152+
cfg.ProtocolConfiguration.StateRootInHeader = protoCfg.StateRootInHeader
153+
cfg.ProtocolConfiguration.P2PStateExchangeExtensions = protoCfg.P2PStateExchangeExtensions
154+
cfg.ProtocolConfiguration.Hardforks = protoCfg.Hardforks
149155
return newTestVMCLIWithLogoAndCustomConfig(t, false, &cfg)
150156
}
151157

‎docs/node-configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ protocol-related settings described in the table below.
332332
| --- | --- | --- | --- | --- |
333333
| 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. |
334334
| Genesis | [Genesis](#Genesis-Configuration) | none | The set of genesis block settings including NeoGo-specific protocol extensions that should be enabled at the genesis block or during native contracts initialisation. |
335-
| 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. |
335+
| 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. <br>• `Cockatrice` represents hard-fork introduced in [#3402](https://github.com/nspcc-dev/neo-go/pull/3402) (ported from the [reference](https://github.com/neo-project/neo/pull/2942)). Initially it is introduced along with the ability to update native contracts. This hard-fork also includes a couple of new native smart contract APIs: `keccaak256` of native CryptoLib contract introduced in [#3301](https://github.com/nspcc-dev/neo-go/pull/3301) (ported from the [reference](https://github.com/neo-project/neo/pull/2925)) and `getCommitteeAddress` of native NeoToken contract inctroduced in [#3362](https://github.com/nspcc-dev/neo-go/pull/3362) (ported from the [reference](https://github.com/neo-project/neo/pull/3154)). |
336336
| Magic | `uint32` | `0` | Magic number which uniquely identifies Neo network. |
337337
| MaxBlockSize | `uint32` | `262144` | Maximum block size in bytes. |
338338
| MaxBlockSystemFee | `int64` | `900000000000` | Maximum overall transactions system fee per block. |

‎pkg/config/hardfork.go

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ const (
2222
// https://github.com/neo-project/neo/pull/2883) and #3085 (ported from
2323
// https://github.com/neo-project/neo/pull/2810).
2424
HFBasilisk // Basilisk
25+
// HFCockatrice represents hard-fork introduced in #3402 (ported from
26+
// https://github.com/neo-project/neo/pull/2942), #3301 (ported from
27+
// https://github.com/neo-project/neo/pull/2925) and #3362 (ported from
28+
// https://github.com/neo-project/neo/pull/3154).
29+
HFCockatrice // Cockatrice
2530
// hfLast denotes the end of hardforks enum. Consider adding new hardforks
2631
// before hfLast.
2732
hfLast

‎pkg/config/hardfork_string.go

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pkg/core/blockchain_core_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ func TestNewBlockchain_InitHardforks(t *testing.T) {
369369
require.Equal(t, map[string]uint32{
370370
config.HFAspidochelone.String(): 0,
371371
config.HFBasilisk.String(): 0,
372+
config.HFCockatrice.String(): 0,
372373
}, bc.GetConfig().Hardforks)
373374
})
374375
t.Run("missing old", func(t *testing.T) {
@@ -392,12 +393,13 @@ func TestNewBlockchain_InitHardforks(t *testing.T) {
392393
})
393394
t.Run("all present", func(t *testing.T) {
394395
bc := newTestChainWithCustomCfg(t, func(c *config.Config) {
395-
c.ProtocolConfiguration.Hardforks = map[string]uint32{config.HFAspidochelone.String(): 5, config.HFBasilisk.String(): 10}
396+
c.ProtocolConfiguration.Hardforks = map[string]uint32{config.HFAspidochelone.String(): 5, config.HFBasilisk.String(): 10, config.HFCockatrice.String(): 15}
396397
require.NoError(t, c.ProtocolConfiguration.Validate())
397398
})
398399
require.Equal(t, map[string]uint32{
399400
config.HFAspidochelone.String(): 5,
400401
config.HFBasilisk.String(): 10,
402+
config.HFCockatrice.String(): 15,
401403
}, bc.GetConfig().Hardforks)
402404
})
403405
}

‎pkg/core/native/crypto.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func newCrypto() *Crypto {
104104

105105
desc = newDescriptor("keccak256", smartcontract.ByteArrayType,
106106
manifest.NewParameter("data", smartcontract.ByteArrayType))
107-
md = newMethodAndPrice(c.keccak256, 1<<15, callflag.NoneFlag)
107+
md = newMethodAndPrice(c.keccak256, 1<<15, callflag.NoneFlag, config.HFCockatrice)
108108
c.AddMethod(md, desc)
109109
return c
110110
}

‎pkg/core/native/native_neo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func newNEO(cfg config.ProtocolConfiguration) *NEO {
233233
n.AddMethod(md, desc)
234234

235235
desc = newDescriptor("getCommitteeAddress", smartcontract.Hash160Type)
236-
md = newMethodAndPrice(n.getCommitteeAddress, 1<<16, callflag.ReadStates)
236+
md = newMethodAndPrice(n.getCommitteeAddress, 1<<16, callflag.ReadStates, config.HFCockatrice)
237237
n.AddMethod(md, desc)
238238

239239
desc = newDescriptor("getNextBlockValidators", smartcontract.ArrayType)

‎pkg/services/rpcsrv/server_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const (
8989
faultedTxHashLE = "82279bfe9bada282ca0f8cb8e0bb124b921af36f00c69a518320322c6f4fef60"
9090
faultedTxBlock uint32 = 23
9191
invokescriptContractAVM = "VwIADBQBDAMOBQYMDQIODw0DDgcJAAAAAErZMCQE2zBwaEH4J+yMqiYEEUAMFA0PAwIJAAIBAwcDBAUCAQAOBgwJStkwJATbMHFpQfgn7IyqJgQSQBNA"
92-
block20StateRootLE = "637aac452ef781dee7ac5e898a1edf4d3c5b6420288ea5232dad620f39d2152a"
92+
block20StateRootLE = "397c69adbc0201d59623fa913bfff4a2da25c792c484d1d278c061709f2c21cf"
9393
)
9494

9595
var (

0 commit comments

Comments
 (0)