Skip to content

Implement NotaryAssisted transaction attribute#3175

Merged
NGDAdmin merged 37 commits intoneo-project:masterfrom
AnnaShaleva:notary-assisted
Mar 4, 2025
Merged

Implement NotaryAssisted transaction attribute#3175
NGDAdmin merged 37 commits intoneo-project:masterfrom
AnnaShaleva:notary-assisted

Conversation

@AnnaShaleva
Copy link
Member

@AnnaShaleva AnnaShaleva commented Mar 6, 2024

Description

Close #2896. Use a stub for native Notary contract hash since this contract is not implemented yet. Thus, technically, NotaryAssisted attribute verification will always fail on real network until native Notary is implemented.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • A group of unit tests for NotaryAssisted attribute.

Checklist:

Close neo-project#2896. Use a stub for native Notary contract hash since this
contract is not implemented yet. Thus, technically, NotaryAssisted
attribute verification will always fail on real network until native
Notary is implemented.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit to AnnaShaleva/neo-devpack-dotnet that referenced this pull request Mar 6, 2024
Port neo-project/neo#3175.
Ref. neo-project/neo#2896.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit to AnnaShaleva/neo-modules that referenced this pull request Mar 6, 2024
Port neo-project/neo#3175.
Ref. neo-project/neo#2896.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
@AnnaShaleva
Copy link
Member Author

I'm not allowed to request review, set labels or resolve conversations. Maybe someone from neo-project with access rights can allow me at least to request review?

@shargon
Copy link
Member

shargon commented Mar 6, 2024

I'm not allowed to request review, set labels or resolve conversations. Maybe someone from neo-project with access rights can allow me at least to request review?

You didn't accept your role xD, I sent you an invitation time ago... Time to review your email? 😄

@Jim8y
Copy link
Contributor

Jim8y commented Mar 6, 2024

Hi @AnnaShaleva , we are trying to add as much comments in the core as possible, may you please add comments to explain CalculateNetworkFee.

…ribute

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
@AnnaShaleva
Copy link
Member Author

may you please add comments to explain CalculateNetworkFee.

Sure, fixed.

@AnnaShaleva AnnaShaleva requested review from Jim8y and shargon March 6, 2024 15:12
Copy link
Contributor

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GAS.OnPersist change is missing for the attribute.

Transactions network fee should be split between Primary node and Notary
nodes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Once Notary contract is implemented, this hash will be replaced by a
proper Notary contract hash. The exact value won't be changed since
Notary contract has constant hash as any other native contract.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
@AnnaShaleva
Copy link
Member Author

GAS.OnPersist change is missing for the attribute.

Completely forgot about it, fixed.

@AnnaShaleva AnnaShaleva requested a review from roman-khimov March 7, 2024 09:41
@vncoelho
Copy link
Member

vncoelho commented Mar 7, 2024

Maybe this PR we merge after next release.

@AnnaShaleva
Copy link
Member Author

Maybe this PR we merge after next release.

This PR doesn't hurt because currently in real network NotaryAssisted attribute is always invalid since transaction must have Notary contract as a signer, and Notary contract is not implemented yet.

Thus, I vote to merge it before 3.7. What do you think?

@roman-khimov
Copy link
Contributor

It goes step by step, @vncoelho. What this delay would buy us? The attribute logic is rather simple on its own.

roman-khimov
roman-khimov previously approved these changes Mar 7, 2024
Copy link
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need more time to review the notary proposal, honestly, I didn't expect it to be merged in 3.7 and it is already beginning to produce changes in the core

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
@AnnaShaleva AnnaShaleva dismissed stale reviews from roman-khimov and shargon via 803d872 March 4, 2025 07:50
@AnnaShaleva
Copy link
Member Author

You have errors that need fixing 1st.

Thanks for pointing that out, it was due to recent testing framework upgrade happened on master. Unit-test is fixed (see the latest commit), nothing is changed in the core logic, but we need to collect approvals from @shargon @nan01ab and @roman-khimov one more time.

@NGDAdmin NGDAdmin merged commit 4c7bae4 into neo-project:master Mar 4, 2025
7 checks passed
AnnaShaleva added a commit that referenced this pull request Mar 31, 2025
Problem:

`getAttributeFee` method of native Policy contract has two
implementations: pre-Echidna and post-Echidna (ref. #3175). The problem
is that two implementaitons of this method have reversed
ActiveIn/ActiveTill meaning.

Solution:

GetAttributeFeeV0 implementaiton of Policy's `getAttributeFee` method
should be enabled *till* Echidna, whereas GetAttributeFee should be
enabled *starting from* Echidna.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this pull request Mar 31, 2025
Problem:

`[get/set]AttributeFee` method of native Policy contract has two
implementations: pre-Echidna and post-Echidna (ref. #3175). The problem
is that two implementaitons of this method have reversed
ActiveIn/ActiveTill meaning.

Solution:

GetAttributeFeeV0 implementaiton of Policy's `getAttributeFee` method
should be enabled *till* Echidna, whereas GetAttributeFee should be
enabled *starting from* Echidna. The same is relevant for
SetAttributeFeeV0 and SetAttributeFeeV1 implementations.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit to nspcc-dev/neo-go that referenced this pull request Apr 1, 2025
Move it under Echidna hardfork. Port
neo-project/neo#3175.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit to nspcc-dev/neo-go that referenced this pull request Apr 1, 2025
Move it under Echidna hardfork. Port
neo-project/neo#3175.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit to nspcc-dev/neo-go that referenced this pull request Apr 1, 2025
Move it under Echidna hardfork. Port
neo-project/neo#3175.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
NGDAdmin added a commit that referenced this pull request Apr 2, 2025
* Native: swap Policy's `[get/set]AttributeFee` implementations

Problem:

`[get/set]AttributeFee` method of native Policy contract has two
implementations: pre-Echidna and post-Echidna (ref. #3175). The problem
is that two implementaitons of this method have reversed
ActiveIn/ActiveTill meaning.

Solution:

GetAttributeFeeV0 implementaiton of Policy's `getAttributeFee` method
should be enabled *till* Echidna, whereas GetAttributeFee should be
enabled *starting from* Echidna. The same is relevant for
SetAttributeFeeV0 and SetAttributeFeeV1 implementations.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Native: rename Policy's GetAttributeFee to GetAttributeFeeV1

This renaming allows to avoid bugs and collisions with
ActiveIn/ActiveTill. Also, this renaming follows the setters style (for
setters we have `SetAttributeFeeV0` and `SetAttributeFeeV1`.

No functional changes, just a refactoring. Contract manifest is not affected.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

---------

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com>
AnnaShaleva added a commit to nspcc-dev/neo-go that referenced this pull request Apr 21, 2025
Move it under Echidna hardfork. Port
neo-project/neo#3175.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
NGDAdmin added a commit that referenced this pull request Apr 29, 2025
* Implement NotaryAssisted transaction attribute

Close #2896. Use a stub for native Notary contract hash since this
contract is not implemented yet. Thus, technically, NotaryAssisted
attribute verification will always fail on real network until native
Notary is implemented.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Payloads: add doc to CalculateNetworkFee method of NotaryAssisted attribute

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Native: add NotaryAssisted attributes handler to Gas OnPersist

Transactions network fee should be split between Primary node and Notary
nodes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Payloads: adjust comment to NotaryAssisted attribute

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Payloads: temporary use hard-coded Notary contract hash

Once Notary contract is implemented, this hash will be replaced by a
proper Notary contract hash. The exact value won't be changed since
Notary contract has constant hash as any other native contract.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Payloads: replace hard-coded Notary hash value with calculated one

No functional changes, just a refactoring for better code readability.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Native: implement native Notary contract

Close #2897. Depends on #3175.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Native: fix typo in the exception message

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Native: use more syntactic sugar

No functional changes, just a refactoring.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: add unit tests for OnNEP17Payment and ExpirationOf methods

Also, mark improper code of Withdraw method with TODO, it should be
reworked.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Fix transfer

* Update tests/Neo.UnitTests/SmartContract/Native/UT_Notary.cs

* Update UT_Notary.cs

* fix

* Fix notary

* Fix notary

* Notary: add unit tests for LockDepositUntil and BalanceOf methods

Also, format code.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: test GAS distribution with FeePerKey update

Test the situation described in
https://github.com/neo-project/neo/pull/3175/files/00b54ff6d20cc84b435beaa790fe72a9d8f78bec#r1530493475.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: add test for Withdraw

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: remove unused code

No functional changes, I just finally made my code analizer work
properly.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Attributtes: fix NotaryAssisted attribute documentation format

Co-authored-by: Shargon <shargon@gmail.com>

* Native: update to the fresh master

Fetch changes from the fresh master and fix build errors.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: sync up with master changes

No functional changes, just adopt latest changes in syntax from master
to make the code buildable and make unit tests pass.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: make the contract active starting from Echidna.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: add NEP-27 to the list of supported standards

Port nspcc-dev/neo-go#3792.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: adjust deposit expiration rule

Follow nspcc-dev/neo-go#3211.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* clean usings

* Update tests/Neo.UnitTests/Extensions/Nep17NativeContractExtensions.cs

Co-authored-by: Will <201105916+Wi1l-B0t@users.noreply.github.com>

* Notary: improve long line format

No functional changes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: prettify exception thrown on unexpected OnNEP17Payment data

Throw FormatException instead of InvalidCastException on invalid data
passed to OnNEP17Payment.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: don't FAULT execution in case of non-tx verification container

Return `false` in case if execution container for `verify` is not a
transaction.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: unify deposit lock validity check

No functional changes, just a refactoring.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: extend `verify` with signature argument validation

Ref.
https://github.com/neo-project/neo/pull/3178/files/56acd97e4b2e93601b7e3d4b15b5ccafc9455fcd#r2010316964.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: add a note about Deposit serialization

No functional changes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* UnitTests: remove NotaryAssisted fees unit test

This test requires Notary nodes to be properly designated via native
RoleManagement contract, it's hard to mock this behaviour during test,
I wasn't able to properly do it.

This test may be restored once we have better testing system.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: replace exceptions with false return for `withdraw`

Ref.
#3178 (comment).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: refactor variable definition

No functional changes, ref.
#3178 (comment).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: migrate to Policy.GetAttributeFeeV1 usage

No functional changes, just adopt the #3859.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Review Notary (#3870)

* Update Notary.cs

* Update Notary.cs

* Update Notary.cs

* fix

* clean

* Clean

* Update src/Neo/SmartContract/Native/Notary.cs

* Update tests/Neo.UnitTests/TestUtils.Transaction.cs

Co-authored-by: Christopher Schuchardt <cschuchardt88@gmail.com>

* Update tests/Neo.UnitTests/TestUtils.Transaction.cs

Co-authored-by: Christopher Schuchardt <cschuchardt88@gmail.com>

* Update tests/Neo.UnitTests/TestUtils.Transaction.cs

* Update tests/Neo.UnitTests/TestUtils.Transaction.cs

* Notary: adapt Policy-based MaxValidUntilBlockIncrement

Fetch recent update from #3861.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: rename manifest parameters to follow the native style

Unify parameters naming to follow the style of other native contracts.
No functional changes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: adjust required callflags for some methods

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: fix Notary node scripthash construction

Notary node account is always a standard single signature script.

This commit fixes state difference between Go and C# nodes at block 9762 of
NeoFS Testnet:
```
go run scripts/compare-dumps/compare-dumps.go ./godump-echidna-neofs-testnet/ ../../neo-project/neo/neo-cli-notary-testnet/Storage_2bdb2b5f/
Processing directory BlockStorage_0
Processing directory BlockStorage_100000
file BlockStorage_100000/dump-block-10000.json: block 9762, changes length mismatch: 13 vs 20
compare-dumps dumpDirA dumpDirB
exit status 1
```

The reason is in improper construction of Notary node address which
leads to the fact that notary GAS reward goes to wrong addresses. Here's
a part of OnPersist application log for this block generated by C# node
that contains wrong GAS receiver addresses:
```
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "Z0B9UyyyUsDlW4OgICWJ+nwLyZc="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "5Sk5i/oPh7IBb7VvlHfiUjX2LHU="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "HcOwwNv9mwY1i3SF4d5qX8jDdJs="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "8a2TEhIZFJ/lZDklkMs+d6i7OWI="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "Oke4DvOe+XZ+3mQnZ5nE1Ilm3jY="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "7frkdtIbPRN2ijaHnw+tfUxMzA8="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "YjI6lI1pOy/OxH1PjcG/yIXwD/4="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    }
                ],
                "stack": [
                ],
                "trigger": "OnPersist",
                "vmstate": "HALT"
            }
```

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

---------

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Co-authored-by: Jimmy <jinghui@wayne.edu>
Co-authored-by: Fernando Diaz Toledano <shargon@gmail.com>
Co-authored-by: Christopher Schuchardt <cschuchardt88@gmail.com>
Co-authored-by: Will <201105916+Wi1l-B0t@users.noreply.github.com>
Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com>
Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com>
AnnaShaleva added a commit to nspcc-dev/neo-go that referenced this pull request Apr 29, 2025
Move it under Echidna hardfork. Port
neo-project/neo#3175.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit to nspcc-dev/neo-go that referenced this pull request Apr 29, 2025
Move it under Echidna hardfork. Port
neo-project/neo#3175.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
cschuchardt88 added a commit to cschuchardt88/neo that referenced this pull request Jun 8, 2025
* Implement NotaryAssisted transaction attribute

Close neo-project#2896. Use a stub for native Notary contract hash since this
contract is not implemented yet. Thus, technically, NotaryAssisted
attribute verification will always fail on real network until native
Notary is implemented.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Payloads: add doc to CalculateNetworkFee method of NotaryAssisted attribute

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Native: add NotaryAssisted attributes handler to Gas OnPersist

Transactions network fee should be split between Primary node and Notary
nodes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Payloads: adjust comment to NotaryAssisted attribute

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Payloads: temporary use hard-coded Notary contract hash

Once Notary contract is implemented, this hash will be replaced by a
proper Notary contract hash. The exact value won't be changed since
Notary contract has constant hash as any other native contract.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Payloads: replace hard-coded Notary hash value with calculated one

No functional changes, just a refactoring for better code readability.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* NeoModules: integrate NotaryAssisted attribute

Port the neo-project/neo-modules#884.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Payloads: fix XML comment formatting

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* P2P: move NotaryAssisted transaction attribute under D hardfork

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* P2P: move NotaryAssisted transaction attribute under E hardfork

D hardfork was occupied by 3.7.5, thus use the next available one.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* tests: fix build errors

No functional changes, just build fixes required by updated master
branch.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* NotaryAssisted: update copyright date

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* SmartContract: refactor obsolete code

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Persistance: fix UT

Related to additional storage entries added by the previous changes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Clean comments

* Native: improve exception message for Policy's getFee/setFee

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* EC Recover (neo-project#3696)

* EC Recover

* Clean code

* Fix ut

* Fix ut

* Unify hashing

* Allow HashAlgorithm.None

* Clean comment

* Update src/Neo/Cryptography/Crypto.cs

* Fix merge

* Add None check

* Fix GetHash

* fix unit testing issues

* Clean code

* Update src/Neo/SmartContract/Native/CryptoLib.cs

---------

Co-authored-by: Jimmy <jinghui@wayne.edu>

* Improve MaxNestingDepth of WitnessCondition (neo-project#3761)

* tests: add UT for nested WitnessCondition

This just works as the code works.

Signed-off-by: Roman Khimov <roman@nspcc.ru>

* WitnessCondition: unify nesting checks, fix MaxNestingDepth

1. We have some duplication around "maxNestDepth <= 0" checks.
2. If we're to fix them by moving to DeserializeFrom() and thereby affecting
   all types of conditions we can discover a simple truth about conditions
   that was hidden previously: our real supported MaxNestingDepth is 3, not 2.
3. Test_WitnessCondition_Nesting works as before, check it there, we have
   And->And->Boolean and other nesting cases, 3-4 elements in the chain,
   not 2.

Signed-off-by: Roman Khimov <roman@nspcc.ru>

* WitnessCondition: unify JSON parsing as well

Signed-off-by: Roman Khimov <roman@nspcc.ru>

* tests: s/WitnessContition/WitnessCondition/

Fix typo.

Signed-off-by: Roman Khimov <roman@nspcc.ru>

* Format header

* Format arrays in UT_WitnessCondition.cs

---------

Signed-off-by: Roman Khimov <roman@nspcc.ru>
Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: Christopher Schuchardt <cschuchardt88@gmail.com>
Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com>

* Add Support for Plugin Loading by Assembly (neo-project#3755)

* Add Support for plugin loading

* Added @shargon request of changes

---------

Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com>

* Optimize `StorageKey` creation (neo-project#3756)

* Optimize key builder

* Optimize with GetSpan

* Use Span

* Clean

* Rename

* Update src/Neo/SmartContract/KeyBuilder.cs

Co-authored-by: nan01ab <yjcc201374@outlook.com>

* Update KeyBuilder.cs

* @cschuchardt88 feedback

* Avoid ToArray in StorageKey constructor

* Use sizeof

* Optimize ECPoint

* Optimize ECPoint

* Add ISerializableSpan

* Move to StorageKey

* Use ReadOnlySpan

---------

Co-authored-by: nan01ab <yjcc201374@outlook.com>
Co-authored-by: Christopher Schuchardt <cschuchardt88@gmail.com>

* [`Fix`] Linux File Access (neo-project#3769)

* Add some stuff to hope once and for all fix the linux workflows

* update workflow

* update nuget.yml

* Change dig to detailed, log too big

* Fix targets

* revert main.yml

* Update .github/workflows/main.yml

* disable BuildInParallel

---------

Co-authored-by: Jimmy <jinghui@wayne.edu>
Co-authored-by: Shargon <shargon@gmail.com>

* Update src/Neo/SmartContract/Native/PolicyContract.cs

* UnitTests: migrate NotaryAssisted test from MSTestV1 to MSTestV2

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

---------

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Co-authored-by: Jimmy <jinghui@wayne.edu>
Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: Christopher Schuchardt <cschuchardt88@gmail.com>
Co-authored-by: Roman Khimov <roman@nspcc.ru>
Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com>
Co-authored-by: nan01ab <yjcc201374@outlook.com>
cschuchardt88 pushed a commit to cschuchardt88/neo that referenced this pull request Jun 8, 2025
…oject#3859)

* Native: swap Policy's `[get/set]AttributeFee` implementations

Problem:

`[get/set]AttributeFee` method of native Policy contract has two
implementations: pre-Echidna and post-Echidna (ref. neo-project#3175). The problem
is that two implementaitons of this method have reversed
ActiveIn/ActiveTill meaning.

Solution:

GetAttributeFeeV0 implementaiton of Policy's `getAttributeFee` method
should be enabled *till* Echidna, whereas GetAttributeFee should be
enabled *starting from* Echidna. The same is relevant for
SetAttributeFeeV0 and SetAttributeFeeV1 implementations.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Native: rename Policy's GetAttributeFee to GetAttributeFeeV1

This renaming allows to avoid bugs and collisions with
ActiveIn/ActiveTill. Also, this renaming follows the setters style (for
setters we have `SetAttributeFeeV0` and `SetAttributeFeeV1`.

No functional changes, just a refactoring. Contract manifest is not affected.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

---------

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com>
cschuchardt88 added a commit to cschuchardt88/neo that referenced this pull request Jun 8, 2025
* Implement NotaryAssisted transaction attribute

Close neo-project#2896. Use a stub for native Notary contract hash since this
contract is not implemented yet. Thus, technically, NotaryAssisted
attribute verification will always fail on real network until native
Notary is implemented.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Payloads: add doc to CalculateNetworkFee method of NotaryAssisted attribute

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Native: add NotaryAssisted attributes handler to Gas OnPersist

Transactions network fee should be split between Primary node and Notary
nodes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Payloads: adjust comment to NotaryAssisted attribute

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Payloads: temporary use hard-coded Notary contract hash

Once Notary contract is implemented, this hash will be replaced by a
proper Notary contract hash. The exact value won't be changed since
Notary contract has constant hash as any other native contract.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Payloads: replace hard-coded Notary hash value with calculated one

No functional changes, just a refactoring for better code readability.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Native: implement native Notary contract

Close neo-project#2897. Depends on neo-project#3175.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Native: fix typo in the exception message

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Native: use more syntactic sugar

No functional changes, just a refactoring.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: add unit tests for OnNEP17Payment and ExpirationOf methods

Also, mark improper code of Withdraw method with TODO, it should be
reworked.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Fix transfer

* Update tests/Neo.UnitTests/SmartContract/Native/UT_Notary.cs

* Update UT_Notary.cs

* fix

* Fix notary

* Fix notary

* Notary: add unit tests for LockDepositUntil and BalanceOf methods

Also, format code.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: test GAS distribution with FeePerKey update

Test the situation described in
https://github.com/neo-project/neo/pull/3175/files/00b54ff6d20cc84b435beaa790fe72a9d8f78bec#r1530493475.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: add test for Withdraw

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: remove unused code

No functional changes, I just finally made my code analizer work
properly.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Attributtes: fix NotaryAssisted attribute documentation format

Co-authored-by: Shargon <shargon@gmail.com>

* Native: update to the fresh master

Fetch changes from the fresh master and fix build errors.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: sync up with master changes

No functional changes, just adopt latest changes in syntax from master
to make the code buildable and make unit tests pass.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: make the contract active starting from Echidna.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: add NEP-27 to the list of supported standards

Port nspcc-dev/neo-go#3792.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: adjust deposit expiration rule

Follow nspcc-dev/neo-go#3211.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* clean usings

* Update tests/Neo.UnitTests/Extensions/Nep17NativeContractExtensions.cs

Co-authored-by: Will <201105916+Wi1l-B0t@users.noreply.github.com>

* Notary: improve long line format

No functional changes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: prettify exception thrown on unexpected OnNEP17Payment data

Throw FormatException instead of InvalidCastException on invalid data
passed to OnNEP17Payment.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: don't FAULT execution in case of non-tx verification container

Return `false` in case if execution container for `verify` is not a
transaction.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: unify deposit lock validity check

No functional changes, just a refactoring.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: extend `verify` with signature argument validation

Ref.
https://github.com/neo-project/neo/pull/3178/files/56acd97e4b2e93601b7e3d4b15b5ccafc9455fcd#r2010316964.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: add a note about Deposit serialization

No functional changes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* UnitTests: remove NotaryAssisted fees unit test

This test requires Notary nodes to be properly designated via native
RoleManagement contract, it's hard to mock this behaviour during test,
I wasn't able to properly do it.

This test may be restored once we have better testing system.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: replace exceptions with false return for `withdraw`

Ref.
neo-project#3178 (comment).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: refactor variable definition

No functional changes, ref.
neo-project#3178 (comment).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: migrate to Policy.GetAttributeFeeV1 usage

No functional changes, just adopt the neo-project#3859.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Review Notary (neo-project#3870)

* Update Notary.cs

* Update Notary.cs

* Update Notary.cs

* fix

* clean

* Clean

* Update src/Neo/SmartContract/Native/Notary.cs

* Update tests/Neo.UnitTests/TestUtils.Transaction.cs

Co-authored-by: Christopher Schuchardt <cschuchardt88@gmail.com>

* Update tests/Neo.UnitTests/TestUtils.Transaction.cs

Co-authored-by: Christopher Schuchardt <cschuchardt88@gmail.com>

* Update tests/Neo.UnitTests/TestUtils.Transaction.cs

* Update tests/Neo.UnitTests/TestUtils.Transaction.cs

* Notary: adapt Policy-based MaxValidUntilBlockIncrement

Fetch recent update from neo-project#3861.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: rename manifest parameters to follow the native style

Unify parameters naming to follow the style of other native contracts.
No functional changes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: adjust required callflags for some methods

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

* Notary: fix Notary node scripthash construction

Notary node account is always a standard single signature script.

This commit fixes state difference between Go and C# nodes at block 9762 of
NeoFS Testnet:
```
go run scripts/compare-dumps/compare-dumps.go ./godump-echidna-neofs-testnet/ ../../neo-project/neo/neo-cli-notary-testnet/Storage_2bdb2b5f/
Processing directory BlockStorage_0
Processing directory BlockStorage_100000
file BlockStorage_100000/dump-block-10000.json: block 9762, changes length mismatch: 13 vs 20
compare-dumps dumpDirA dumpDirB
exit status 1
```

The reason is in improper construction of Notary node address which
leads to the fact that notary GAS reward goes to wrong addresses. Here's
a part of OnPersist application log for this block generated by C# node
that contains wrong GAS receiver addresses:
```
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "Z0B9UyyyUsDlW4OgICWJ+nwLyZc="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "5Sk5i/oPh7IBb7VvlHfiUjX2LHU="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "HcOwwNv9mwY1i3SF4d5qX8jDdJs="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "8a2TEhIZFJ/lZDklkMs+d6i7OWI="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "Oke4DvOe+XZ+3mQnZ5nE1Ilm3jY="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "7frkdtIbPRN2ijaHnw+tfUxMzA8="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "YjI6lI1pOy/OxH1PjcG/yIXwD/4="
                                },
                                {
                                    "type": "Integer",
                                    "value": "11428571"
                                }
                            ]
                        }
                    }
                ],
                "stack": [
                ],
                "trigger": "OnPersist",
                "vmstate": "HALT"
            }
```

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>

---------

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Co-authored-by: Jimmy <jinghui@wayne.edu>
Co-authored-by: Fernando Diaz Toledano <shargon@gmail.com>
Co-authored-by: Christopher Schuchardt <cschuchardt88@gmail.com>
Co-authored-by: Will <201105916+Wi1l-B0t@users.noreply.github.com>
Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com>
Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com>
Jim8y pushed a commit to neo-project/neo-devpack-dotnet that referenced this pull request Aug 3, 2025
Port neo-project/neo#3175.
Ref. neo-project/neo#2896.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Co-authored-by: Shargon <shargon@gmail.com>
Jim8y pushed a commit to neo-project/neo-devpack-dotnet that referenced this pull request Aug 18, 2025
Port neo-project/neo#3175.
Ref. neo-project/neo#2896.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Co-authored-by: Shargon <shargon@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a NotaryAssisted transaction attribute

9 participants