Skip to content

Commit

Permalink
native: add callflag.AllowNotify to some methods to HFEchidna
Browse files Browse the repository at this point in the history
Close #3702

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
  • Loading branch information
AliceInHunterland committed Dec 23, 2024
1 parent b096e68 commit 80e1822
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/node-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ in development and can change in an incompatible way.
| `Basilisk` | Enables strict smart contract script check against a set of JMP instructions and against method boundaries enabled on contract deploy or update. Increases `stackitem.Integer` JSON parsing precision up to the maximum value supported by the NeoVM. Enables strict check for notifications emitted by a contract to precisely match the events specified in the contract manifest. | https://github.com/nspcc-dev/neo-go/pull/3056 <br> https://github.com/neo-project/neo/pull/2881 <br> https://github.com/nspcc-dev/neo-go/pull/3080 <br> https://github.com/neo-project/neo/pull/2883 <br> https://github.com/nspcc-dev/neo-go/pull/3085 <br> https://github.com/neo-project/neo/pull/2810 |
| `Cockatrice` | Introduces the ability to update native contracts. Includes a couple of new native smart contract APIs: `keccak256` of native CryptoLib contract and `getCommitteeAddress` of native NeoToken contract. | https://github.com/nspcc-dev/neo-go/pull/3402 <br> https://github.com/neo-project/neo/pull/2942 <br> https://github.com/nspcc-dev/neo-go/pull/3301 <br> https://github.com/neo-project/neo/pull/2925 <br> https://github.com/nspcc-dev/neo-go/pull/3362 <br> https://github.com/neo-project/neo/pull/3154 |
| `Domovoi` | Makes node use executing contract state for the contract call permissions check instead of the state stored in the native Management contract. In C# also makes System.Runtime.GetNotifications interop properly count stack references of notification parameters which prevents users from creating objects that exceed MaxStackSize constraint, but NeoGo has never had this bug, thus proper behaviour is preserved even before HFDomovoi. It results in the fact that some T5 testnet transactions have different ApplicationLogs compared to the C# node, but the node states match. | https://github.com/nspcc-dev/neo-go/pull/3476 <br> https://github.com/neo-project/neo/pull/3290 <br> https://github.com/nspcc-dev/neo-go/pull/3473 <br> https://github.com/neo-project/neo/pull/3290 <br> https://github.com/neo-project/neo/pull/3301 <br> https://github.com/nspcc-dev/neo-go/pull/3485 |
| `Echidna` | Introduces `Designation` event extension with `Old` and `New` roles data to native RoleManagement contract. Adds support for `base64UrlEncode` and `base64UrlDecode` methods to native StdLib contract. | https://github.com/nspcc-dev/neo-go/pull/3554 <br> https://github.com/nspcc-dev/neo-go/pull/3761 |
| `Echidna` | Introduces `Designation` event extension with `Old` and `New` roles data to native RoleManagement contract. Adds support for `base64UrlEncode` and `base64UrlDecode` methods to native StdLib contract. Extends the list of required call flags for `registerCandidate`, `unregisterCandidate`and `vote` methods of native NeoToken contract with AllowNotify flag. | https://github.com/nspcc-dev/neo-go/pull/3554 <br> https://github.com/nspcc-dev/neo-go/pull/3761 |


## DB compatibility
Expand Down
15 changes: 12 additions & 3 deletions pkg/core/native/native_neo.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,27 @@ func newNEO(cfg config.ProtocolConfiguration) *NEO {

desc = newDescriptor("registerCandidate", smartcontract.BoolType,
manifest.NewParameter("pubkey", smartcontract.PublicKeyType))
md = newMethodAndPrice(n.registerCandidate, 0, callflag.States)
md = newMethodAndPrice(n.registerCandidate, 0, callflag.States, config.HFDefault, config.HFEchidna)
n.AddMethod(md, desc)

md = newMethodAndPrice(n.registerCandidate, 0, callflag.States|callflag.AllowNotify, config.HFEchidna)
n.AddMethod(md, desc)

desc = newDescriptor("unregisterCandidate", smartcontract.BoolType,
manifest.NewParameter("pubkey", smartcontract.PublicKeyType))
md = newMethodAndPrice(n.unregisterCandidate, 1<<16, callflag.States)
md = newMethodAndPrice(n.unregisterCandidate, 1<<16, callflag.States, config.HFDefault, config.HFEchidna)
n.AddMethod(md, desc)

md = newMethodAndPrice(n.unregisterCandidate, 1<<16, callflag.States|callflag.AllowNotify, config.HFEchidna)
n.AddMethod(md, desc)

desc = newDescriptor("vote", smartcontract.BoolType,
manifest.NewParameter("account", smartcontract.Hash160Type),
manifest.NewParameter("voteTo", smartcontract.PublicKeyType))
md = newMethodAndPrice(n.vote, 1<<16, callflag.States)
md = newMethodAndPrice(n.vote, 1<<16, callflag.States, config.HFDefault, config.HFEchidna)
n.AddMethod(md, desc)

md = newMethodAndPrice(n.vote, 1<<16, callflag.States|callflag.AllowNotify, config.HFEchidna)
n.AddMethod(md, desc)

desc = newDescriptor("getCandidates", smartcontract.ArrayType)
Expand Down
6 changes: 3 additions & 3 deletions pkg/interop/native/neo/neo.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ func SetRegisterPrice(amount int) {

// RegisterCandidate represents `registerCandidate` method of NEO native contract.
func RegisterCandidate(pub interop.PublicKey) bool {
return neogointernal.CallWithToken(Hash, "registerCandidate", int(contract.States), pub).(bool)
return neogointernal.CallWithToken(Hash, "registerCandidate", int(contract.States|contract.AllowNotify), pub).(bool)
}

// UnregisterCandidate represents `unregisterCandidate` method of NEO native contract.
func UnregisterCandidate(pub interop.PublicKey) bool {
return neogointernal.CallWithToken(Hash, "unregisterCandidate", int(contract.States), pub).(bool)
return neogointernal.CallWithToken(Hash, "unregisterCandidate", int(contract.States|contract.AllowNotify), pub).(bool)
}

// Vote represents `vote` method of NEO native contract.
func Vote(addr interop.Hash160, pub interop.PublicKey) bool {
return neogointernal.CallWithToken(Hash, "vote", int(contract.States), addr, pub).(bool)
return neogointernal.CallWithToken(Hash, "vote", int(contract.States|contract.AllowNotify), addr, pub).(bool)
}

// UnclaimedGAS represents `unclaimedGas` method of NEO native contract.
Expand Down

0 comments on commit 80e1822

Please sign in to comment.