Skip to content

Native: move MaxValidUntilBlockIncrement to native Policy#3861

Merged
NGDAdmin merged 11 commits intomasterfrom
policy-maxvub
Apr 10, 2025
Merged

Native: move MaxValidUntilBlockIncrement to native Policy#3861
NGDAdmin merged 11 commits intomasterfrom
policy-maxvub

Conversation

@AnnaShaleva
Copy link
Member

@AnnaShaleva AnnaShaleva commented Mar 31, 2025

Description

The problem is described in nspcc-dev/neo-go#3841. In short words, the chain's state is dependent on MaxValidUntilBlockIncrement setting, whereas this setting depends on the block time. Since block generation time is a part of native Policy (#3622), MaxValidUntilBlockIncrement should follow, we need the same value to be applied at all CNs simultaneously.

Port nspcc-dev/neo-go#3849.

This PR has a common part that intersects with #3622 (Neo/Etensions/NeoSystemExtensions.cs), so I'll rebase PR if #3622 is merged first.

Type of change

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

How Has This Been Tested?

  • Check_SetMaxValidUntilBlockIncrement

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

The problem is described in
nspcc-dev/neo-go#3841. In short words,
the chain's state is dependent on MaxValidUntilBlockIncrement setting,
whereas this setting depends on the block time. Since block generation
time is a part of native Policy (#3622), MaxValidUntilBlockIncrement
should follow, we need the same value to be applied at all CNs
simultaneously.

Port nspcc-dev/neo-go#3849.

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

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
@AnnaShaleva AnnaShaleva requested a review from Wi1l-B0t April 1, 2025 13:36
@shargon
Copy link
Member

shargon commented Apr 1, 2025

we need the same value to be applied at all CNs simultaneously.

It's big enough to fail, isn't it? In my opinion seems weird, it's more a user defined variable than a global policy

@AnnaShaleva
Copy link
Member Author

AnnaShaleva commented Apr 2, 2025

It's big enough to fail, isn't it?

On N3 networks right now - yes. But we use a different value in NeoFS networks and after #3622 we'll likely would like to change this value on N3 networks as far, so we need this change to be synchronized across all nodes.

it's more a user defined variable than a global policy

I'd say it's a global policy because nodes use this value to verify transactions, hence this value should be synchronized at least across consensus nodes, otherwise it will lead to view changes due to transaction verification failure:

if (ValidUntilBlock <= height || ValidUntilBlock > height + settings.MaxValidUntilBlockIncrement)
return VerifyResult.Expired;

Moreover, native Notary contract uses this value as a constraint for setMaxNotValidBeforeDelta method, which means that this value should be a part of the node's state so that chain processing result won't dependent on the non-constant config parameter (MaxValidUntilBlockIncrement can be changed within the network lifetime):

if (value > engine.ProtocolSettings.MaxValidUntilBlockIncrement / 2 || value < ProtocolSettings.Default.ValidatorsCount)
throw new FormatException(string.Format("MaxNotValidBeforeDelta cannot be more than {0} or less than {1}",

@shargon
Copy link
Member

shargon commented Apr 3, 2025

Moreover, native Notary contract uses this value as a constraint for setMaxNotValidBeforeDelta method

Then is related no notary, not to policy, users can use any number

@roman-khimov
Copy link
Contributor

roman-khimov commented Apr 3, 2025

users can use any number

No, they can't. See code links @AnnaShaleva provided above. Nodes do reject transactions that have invalid VUB wrt MVUBI already and it's an important property. If nodes are not synchronized on MVUBI value we can have random errors occuring here and there (transactions rejected by RPC or not accepted by CN).

See "block transactions" in https://neospcc.medium.com/cutting-blockchain-tail-with-neogo-5256a120f6bb as well.

It's set to be a day of 1-second blocks, that should be enough, ref.
#3861 (comment).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
@AnnaShaleva AnnaShaleva requested a review from shargon April 3, 2025 14:48
Copy link
Contributor

@Wi1l-B0t Wi1l-B0t left a comment

Choose a reason for hiding this comment

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

LGTM

@NGDAdmin NGDAdmin merged commit 3be10f7 into master Apr 10, 2025
7 checks passed
@NGDAdmin NGDAdmin deleted the policy-maxvub branch April 10, 2025 02:44
AnnaShaleva added a commit that referenced this pull request Apr 17, 2025
Fetch recent update from #3861.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
@AnnaShaleva AnnaShaleva mentioned this pull request Apr 17, 2025
12 tasks
AnnaShaleva added a commit that referenced this pull request Apr 17, 2025
Fetch recent update from #3861.

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>
cschuchardt88 added a commit to cschuchardt88/neo that referenced this pull request Jun 8, 2025
…ect#3861)

* Native: move MaxValidUntilBlockIncrement to native Policy

The problem is described in
nspcc-dev/neo-go#3841. In short words,
the chain's state is dependent on MaxValidUntilBlockIncrement setting,
whereas this setting depends on the block time. Since block generation
time is a part of native Policy (neo-project#3622), MaxValidUntilBlockIncrement
should follow, we need the same value to be applied at all CNs
simultaneously.

Port nspcc-dev/neo-go#3849.

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

* Extensions: improve formatting

No functional changes.

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

* Native: set maximum constraint for MaxValidUntilBlockIncrement

It's set to be a day of 1-second blocks, that should be enough, ref.
neo-project#3861 (comment).

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: Will <201105916+Wi1l-B0t@users.noreply.github.com>
Co-authored-by: Christopher Schuchardt <cschuchardt88@gmail.com>
Co-authored-by: Jimmy <jinghui@wayne.edu>
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>
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.

7 participants