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 syscall for current tx signers #2827

Merged
merged 16 commits into from
Sep 13, 2023
Merged

Interop syscall for current tx signers #2827

merged 16 commits into from
Sep 13, 2023

Conversation

shargon
Copy link
Member

@shargon shargon commented Oct 27, 2022

Close #2825

@shargon shargon requested a review from erikzhang October 27, 2022 08:52
@shargon
Copy link
Member Author

shargon commented Oct 27, 2022

@roman-khimov please take a look to this version

@erikzhang
Copy link
Member

I prefer to add a new syscall.

@shargon
Copy link
Member Author

shargon commented Oct 30, 2022

I prefer to add a new syscall.

GetTransactionSigners was extended, create a new one only for the current tx, seems weird to me :S

@shargon
Copy link
Member Author

shargon commented Jul 5, 2023

@neo-project/core what do you think about this change? now is not possible to check the signers of the current transaction, and this could be important for certain cases

@Jim8y
Copy link
Contributor

Jim8y commented Jul 5, 2023

@neo-project/core what do you think about this change? now is not possible to check the signers of the current transaction, and this could be important for certain cases

I am with @erikzhang on this. Maybe we should give it another syscall, cause current transaction may not actually be a part of the ledger.

@vncoelho
Copy link
Member

vncoelho commented Jul 5, 2023

Maybe one advantage of a new syscall is also to avoid problems during resync. @shargon , is this 100% compatible? Maybe state could change,no?

@Jim8y
Copy link
Contributor

Jim8y commented Jul 5, 2023

Maybe one advantage of a new syscall is also to avoid problems during resync. @shargon , is this 100% compatible? Maybe state could change,no?

A good question, if they called this on current tx before, this will change the state.

@superboyiii
Copy link
Member

@shargon I think add a new one is better to avoid data incompatible.

@AnnaShaleva
Copy link
Member

AnnaShaleva commented Jul 6, 2023

Just FYI, I've checked the compatibility with current mainnet up to 3722380 height using this patch applied to 0.101.2 (latest 3.5.0-compatible release) with NeoGo node, it doesn't produce a fork:

diff --git a/pkg/core/native/ledger.go b/pkg/core/native/ledger.go
index 51734c226..9b1f9bddc 100644
--- a/pkg/core/native/ledger.go
+++ b/pkg/core/native/ledger.go
@@ -154,6 +154,13 @@ func (l *Ledger) getTransactionFromBlock(ic *interop.Context, params []stackitem
 
 // getTransactionSigners returns transaction signers to the SC.
 func (l *Ledger) getTransactionSigners(ic *interop.Context, params []stackitem.Item) stackitem.Item {
+       hash, err := getUint256FromItem(params[0])
+       if err != nil {
+               panic(err)
+       }
+       if tx, ok := ic.Container.(*transaction.Transaction); ok && tx.Hash().Equals(hash) {
+               return SignersToStackItem(tx.Signers)
+       }
        tx, h, err := getTransactionAndHeight(ic.DAO, params[0])
        if err != nil || !isTraceableBlock(ic, h) {
                return stackitem.Null{}

Synced NeoGo node log:

...
2023-07-06T13:14:41.522+0300	INFO	node reached synchronized state, starting services
2023-07-06T13:14:41.522+0300	INFO	starting state validation service
2023-07-06T13:14:41.522+0300	INFO	RPC server already started
2023-07-06T13:14:43.654+0300	INFO	persisted to disk	{"blocks": 0, "keys": 2, "headerHeight": 3722380, "blockHeight": 3722380, "took": "2.419533ms"}
2023-07-06T13:14:55.668+0300	INFO	persisted to disk	{"blocks": 1, "keys": 24, "headerHeight": 3722381, "blockHeight": 3722381, "took": "9.178084ms"}
2023-07-06T13:14:59.665+0300	INFO	persisted to disk	{"blocks": 0, "keys": 2, "headerHeight": 3722381, "blockHeight": 3722381, "took": "4.620791ms"}
...

States check result:

anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ go run scripts/compare-states/compare-states.go http://localhost:10332 http://seed1.neo.org:10332
at 0: bb2bd2dfee742024b966cdf757c6235044cb9e0ce43497ad0eb27c49b8bdf4fe vs bb2bd2dfee742024b966cdf757c6235044cb9e0ce43497ad0eb27c49b8bdf4fe
at 3722380: ec321406a353f5906a049ebb034b72b8aeaeb7e07658d1bf6a8e84c0a7ba20ad vs ec321406a353f5906a049ebb034b72b8aeaeb7e07658d1bf6a8e84c0a7ba20ad

Although I'm not sure about T5 testnet.

@AnnaShaleva
Copy link
Member

I've checked compatibility of this patch with T5 testnet as far, it's compatible up to 2306990:

...
2023-07-06T13:44:37.606+0300	INFO	node reached synchronized state, starting services
2023-07-06T13:44:37.606+0300	INFO	RPC server already started
2023-07-06T13:44:37.606+0300	INFO	starting state validation service
2023-07-06T13:44:53.741+0300	WARN	peer disconnected	{"addr": "65.108.90.74:21333", "error": "handling CMDExtensible message: invalid height", "peerCount": 12}
2023-07-06T13:45:18.242+0300	INFO	persisted to disk	{"blocks": 1, "keys": 23, "headerHeight": 2297514, "blockHeight": 2297514, "took": "1m31.495449456s"}
2023-07-06T13:45:24.609+0300	INFO	persisted to disk	{"blocks": 9474, "keys": 246120, "headerHeight": 2306988, "blockHeight": 2306988, "took": "6.366979915s"}
2023-07-06T13:45:25.617+0300	INFO	persisted to disk	{"blocks": 1, "keys": 23, "headerHeight": 2306989, "blockHeight": 2306989, "took": "5.461234ms"}
2023-07-06T13:45:26.619+0300	INFO	persisted to disk	{"blocks": 0, "keys": 2, "headerHeight": 2306989, "blockHeight": 2306989, "took": "7.163001ms"}
2023-07-06T13:45:38.647+0300	INFO	persisted to disk	{"blocks": 1, "keys": 23, "headerHeight": 2306990, "blockHeight": 2306990, "took": "27.762326ms"}
2023-07-06T13:45:43.625+0300	INFO	persisted to disk	{"blocks": 0, "keys": 2, "headerHeight": 2306990, "blockHeight": 2306990, "took": "2.693429ms"}
2023-07-06T13:45:53.633+0300	INFO	persisted to disk	{"blocks": 1, "keys": 23, "headerHeight": 2306991, "blockHeight": 2306991, "took": "5.431817ms"}
...

The states comparison result:

anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ go run scripts/compare-states/compare-states.go http://localhost:20332 http://seed1t5.neo.org:20332
at 0: 9c1361fbbe2a0ce31910f992cbdfb8afee6f178e5d1aabdd1c6f2af90440e239 vs 9c1361fbbe2a0ce31910f992cbdfb8afee6f178e5d1aabdd1c6f2af90440e239
at 2306990: f40800cc2da50ce3934795711d07d1bedf01ea91ab6de487cfad155a7f09cc89 vs f40800cc2da50ce3934795711d07d1bedf01ea91ab6de487cfad155a7f09cc89

So technically if nothinig breaking happens after the checked heights, this PR can be merged as is (without new interop).

However, we have #2873 that makes 3.6 incompatible with T5.

@shargon shargon requested review from Jim8y and roman-khimov July 6, 2023 14:21
Jim8y
Jim8y previously approved these changes Jul 6, 2023
AnnaShaleva added a commit to nspcc-dev/neo-go that referenced this pull request Jul 8, 2023
@superboyiii
Copy link
Member

@vncoelho Could you have a review?

@vncoelho
Copy link
Member

Sure, I will review asap

Jim8y
Jim8y previously approved these changes Jul 12, 2023
@vncoelho vncoelho changed the title Allow current tx signers Interop syscall for current tx signers Jul 12, 2023
vncoelho
vncoelho previously approved these changes Jul 12, 2023
@superboyiii
Copy link
Member

@shargon We need modify signer.cs
1689237654002
Otherwise will throw null exception

@shargon shargon dismissed stale reviews from vncoelho and Jim8y via 5d2e482 August 24, 2023 08:06
@shargon
Copy link
Member Author

shargon commented Aug 24, 2023

@shargon We need modify signer.cs 1689237654002 Otherwise will throw null exception

Could you send me the error?

@Jim8y
Copy link
Contributor

Jim8y commented Aug 29, 2023

@superboyiii @shargon Lets move on to finish this

@shargon
Copy link
Member Author

shargon commented Aug 31, 2023

@superboyiii @shargon Lets move on to finish this

I'm waiting for @superboyiii , I didn't have this error

@ProDog
Copy link
Contributor

ProDog commented Sep 11, 2023

When make the transaction, we need to calculate GasConsumed with InvokeScript in RpcClient, and AllowedContracts/AllowedGroups/Rules is null in RpcServer, so it will throw null exception.

https://github.com/neo-project/neo-modules/blob/09c2879958a916e0867fc78c64a04edfabe6935f/src/RpcServer/RpcServer.SmartContract.cs#L172-L174

Need to fix the RpcServer!

image

Copy link
Member

@superboyiii superboyiii left a comment

Choose a reason for hiding this comment

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

Good to merge.

@shargon shargon reopened this Sep 13, 2023
@shargon shargon merged commit 5bccb94 into master Sep 13, 2023
1 check passed
@shargon shargon deleted the current-signers branch September 13, 2023 10:41
AnnaShaleva added a commit to nspcc-dev/neo-go that referenced this pull request Nov 20, 2023
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.

Cannot get signers of current transaction
8 participants