Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interop: use executing contract state for permissions checks #3472

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

AnnaShaleva
Copy link
Member

@AnnaShaleva AnnaShaleva commented Jun 1, 2024

Do not use the updated contract state from native Management to perform permissions checks. We need to use the currently executing state instead got from the currently executing VM context until context is unloaded.

Close #3471.

Mainnet check is in progress.

Copy link

codecov bot commented Jun 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.15%. Comparing base (0b136c1) to head (4945145).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3472      +/-   ##
==========================================
- Coverage   86.19%   86.15%   -0.05%     
==========================================
  Files         331      331              
  Lines       38470    38473       +3     
==========================================
- Hits        33159    33145      -14     
- Misses       3778     3801      +23     
+ Partials     1533     1527       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AnnaShaleva
Copy link
Member Author

Finally got the state, had to process it twice due to invalid dump file. States match:

anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ go run ./scripts/compare-states/compare-states.go http://seed1.neo.org:10332 http://localhost:10332
at 0: 58a5157b7e99eeabf631291f1747ec8eb12ab89461cda888492b17a301de81e8 vs 58a5157b7e99eeabf631291f1747ec8eb12ab89461cda888492b17a301de81e8
at 5471905: 2d215258b07fd550f861d8e362f673887d32b4243d38206521f2519055174041 vs 2d215258b07fd550f861d8e362f673887d32b4243d38206521f2519055174041

Do not use the updated contract state from native Management to perform
permissions checks. We need to use the currently executing state
instead got from the currently executing VM context until context is
unloaded.

Close #3471.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
@ixje
Copy link
Contributor

ixje commented Jun 3, 2024

what is the ETA for a release with this?

@AnnaShaleva
Copy link
Member Author

We’re releasing 0.106.1 right now, it’ll be ready in a few hours.

@AnnaShaleva
Copy link
Member Author

AnnaShaleva commented Jun 3, 2024

Finally got my T5 state, it's match:

anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ go run scripts/compare-states/compare-states.go http://seed1t5.neo.org:20332 http://localhost:20332
at 0: 62fd8ff9b0543aea352257db5b00bbb01d1bc0d2cc665e1f24cf5de0d16ebc7b vs 62fd8ff9b0543aea352257db5b00bbb01d1bc0d2cc665e1f24cf5de0d16ebc7b
at 4087361: 510a86a594dfa138815d7456a83458c160bd59131f3bdd8236bbd2a948207298 vs 510a86a594dfa138815d7456a83458c160bd59131f3bdd8236bbd2a948207298

NeoFS chains check is in progress, but I doubt this change affects them, I'm almost sure we don't have such use-cases in NeoFS.

@AnnaShaleva
Copy link
Member Author

NeoFS mainnet OK:

anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ go run scripts/compare-states/compare-states.go http://localhost:40332 https://rpc1.morph.fs.neo.org:40341
at 0: 437e6b95ac529ede8685071a29471f096ea8d6824b916c0e7ca6d8017b2a23ed vs 437e6b95ac529ede8685071a29471f096ea8d6824b916c0e7ca6d8017b2a23ed
at 5793708: db965a52fd765ef579ddbb4ded2ec964b41c7622041c83edf017187302f104c4 vs db965a52fd765ef579ddbb4ded2ec964b41c7622041c83edf017187302f104c4

Testnet is also OK:

anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ go run scripts/compare-states/compare-states.go http://localhost:50332 https://rpc1.morph.t5.fs.neo.org:51331
at 0: a0be47491a114eb0cb8684dd5d17ee79e1c6ab2dc10ff73de33ff3c385512288 vs a0be47491a114eb0cb8684dd5d17ee79e1c6ab2dc10ff73de33ff3c385512288
at 3674593: adb36738c62b02a63337002812e1a59967bea059d6af883030659260fac7e111 vs adb36738c62b02a63337002812e1a59967bea059d6af883030659260fac7e111

@AnnaShaleva AnnaShaleva merged commit 45b8af3 into master Jun 3, 2024
20 of 21 checks passed
@AnnaShaleva AnnaShaleva deleted the pick-proper-exe-context branch June 3, 2024 13:10
AnnaShaleva added a commit to neo-project/neo that referenced this pull request Jun 3, 2024
It's not correct to use an updated contract state got from native
Management to check for the allowed method call. We need to use
manifest from the currently executing context for that. It may be
critical for cases when executing contract is being updated firstly,
and after that it calls another contract. So we need an old (executing)
contract manifest for this check.

This change likely does not affect the mainnet's state since it's
hard to meet the trigger criteria, thus we suggest not to use a hardfok.

A port of nspcc-dev/neo-go#3473. This bug was
discovered during the similar problem fix in
nspcc-dev/neo-go#3472. I've checked all other
similar usages and the rest of them use proper contract state (executing
one, not the Management's one).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit to neo-project/neo that referenced this pull request Jun 3, 2024
It's not correct to use an updated contract state got from native
Management to check for the allowed method call. We need to use
manifest from the currently executing context for that. It may be
critical for cases when executing contract is being updated firstly,
and after that it calls another contract. So we need an old (executing)
contract manifest for this check.

This change likely does not affect the mainnet's state since it's
hard to meet the trigger criteria, thus we suggest not to use a hardfok.

A port of nspcc-dev/neo-go#3473. This bug was
discovered during the similar problem fix in
nspcc-dev/neo-go#3471 and
nspcc-dev/neo-go#3472. I've checked all other
similar usages and the rest of them use proper contract state (executing
one, not the Management's one).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit to neo-project/neo that referenced this pull request Jun 4, 2024
It's not correct to use an updated contract state got from native
Management to check for the allowed method call. We need to use
manifest from the currently executing context for that. It may be
critical for cases when executing contract is being updated firstly,
and after that it calls another contract. So we need an old (executing)
contract manifest for this check.

This change likely does not affect the mainnet's state since it's
hard to meet the trigger criteria, thus we suggest not to use a hardfok.

A port of nspcc-dev/neo-go#3473. This bug was
discovered during the similar problem described in
nspcc-dev/neo-go#3471 and fixed in
nspcc-dev/neo-go#3472. I've checked all other
similar usages and the rest of them use proper contract state (executing
one, not the Management's one).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit to neo-project/neo that referenced this pull request Jun 4, 2024
It's not correct to use an updated contract state got from native
Management to check for the allowed method call. We need to use
manifest from the currently executing context for that. It may be
critical for cases when executing contract is being updated firstly,
and after that it calls another contract. So we need an old (executing)
contract manifest for this check.

This change is moved under D hardfork to avoid state diff issues on
nodes update. Although it should be noted that it's hard to meet the
trigger criteria.

A port of nspcc-dev/neo-go#3473. This bug was
discovered during the similar problem described in
nspcc-dev/neo-go#3471 and fixed in
nspcc-dev/neo-go#3472. I've checked all other
similar usages and the rest of them use proper contract state (executing
one, not the Management's one).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
NGDAdmin pushed a commit to neo-project/neo that referenced this pull request Jun 11, 2024
It's not correct to use an updated contract state got from native
Management to check for the allowed method call. We need to use
manifest from the currently executing context for that. It may be
critical for cases when executing contract is being updated firstly,
and after that it calls another contract. So we need an old (executing)
contract manifest for this check.

This change is moved under D hardfork to avoid state diff issues on
nodes update. Although it should be noted that it's hard to meet the
trigger criteria.

A port of nspcc-dev/neo-go#3473. This bug was
discovered during the similar problem described in
nspcc-dev/neo-go#3471 and fixed in
nspcc-dev/neo-go#3472. I've checked all other
similar usages and the rest of them use proper contract state (executing
one, not the Management's one).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: Jimmy <jinghui@wayne.edu>
Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com>
NGDAdmin added a commit to neo-project/neo that referenced this pull request Jun 12, 2024
* [Neo Core Bug]fix 3300 (#3301)

* fix 3300

* update format

* add state subitems to ref counter, with suggestion from DuSmart

* apply hardfork

* format

* my mistake

* fix hardfork

* remove negative check

* add unit test

* apply anna's suggestion

---------

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

* SmartContract: use executing contract state to check permissions (#3290)

It's not correct to use an updated contract state got from native
Management to check for the allowed method call. We need to use
manifest from the currently executing context for that. It may be
critical for cases when executing contract is being updated firstly,
and after that it calls another contract. So we need an old (executing)
contract manifest for this check.

This change is moved under D hardfork to avoid state diff issues on
nodes update. Although it should be noted that it's hard to meet the
trigger criteria.

A port of nspcc-dev/neo-go#3473. This bug was
discovered during the similar problem described in
nspcc-dev/neo-go#3471 and fixed in
nspcc-dev/neo-go#3472. I've checked all other
similar usages and the rest of them use proper contract state (executing
one, not the Management's one).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: Jimmy <jinghui@wayne.edu>
Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com>

* v3.7.5

* Neo.CLI: enable hardforks for NeoFS mainnet (#3240)

Otherwise this configuration file is broken. Port changes from
nspcc-dev/neo-go#3446.

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

* fix workflow & FS config

* remove hardfork for fs testnet

---------

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Co-authored-by: Jimmy <jinghui@wayne.edu>
Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com>
Co-authored-by: Anna Shaleva <shaleva.ann@nspcc.ru>
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mainnet stop blocks processing at 5468658
3 participants