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

Check script and abi when deploying contracts #2263

Merged
merged 6 commits into from
Jan 27, 2021
Merged

Conversation

erikzhang
Copy link
Member

Close #733
Close #2030
Close neo-project/neo-vm#376

@erikzhang erikzhang added this to the NEO 3.0 milestone Jan 26, 2021
@erikzhang
Copy link
Member Author

@roman-khimov

shargon
shargon previously approved these changes Jan 26, 2021
roman-khimov
roman-khimov previously approved these changes Jan 26, 2021
@roman-khimov
Copy link
Contributor

The only I'd probably add is name != "" check for #2229.

@erikzhang erikzhang dismissed stale reviews from roman-khimov and shargon via abcbe4c January 26, 2021 13:43
@erikzhang
Copy link
Member Author

@shargon @roman-khimov I added more checks. Please review again.

instructions.Add(ip, instruction);
ip += instruction.Size;
}
foreach (var (ip, instruction) in instructions)
Copy link
Member

Choose a reason for hiding this comment

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

In the past, I need to check if it's happens now, we used a RET and dummy data in order to randomize a transaction, with this, we will need to do it with a right opcodes.

Copy link
Member Author

Choose a reason for hiding this comment

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

RET + PUSHx

Copy link
Contributor

Choose a reason for hiding this comment

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

We have proper nonce in every transaction now, so I don't think it's needed. And these checks currently only affect deployed contracts, transactions can still have some garbage in their script (which is not good, but much less of an issue anyway).

Copy link
Member Author

Choose a reason for hiding this comment

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

@roman-khimov Do you think we should check all the transactions and the witnesses?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a tough question. Ideally, yes, but this can affect performance (unlike this PR which is almost free, contract deployments/updates are rare). At the same time scripts in transactions are usually short and we already parse witness verification scripts (IsStandardContract in VerifyWitness) without any noticeable issues. And this check is state-independent, which also is good (can be done concurrently).

So maybe it's possible. But if we're to do that I'd go with a bit more efficient checker.

Copy link
Member Author

@erikzhang erikzhang Jan 26, 2021

Choose a reason for hiding this comment

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

I've made a new PR to check all the transactions and witnesses. Please check #2266. @roman-khimov

Copy link
Member

Choose a reason for hiding this comment

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

I think that it will be slower, we should trust in the vm

Copy link
Member Author

Choose a reason for hiding this comment

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

For most transactions, only a few instructions need to be checked, so the speed will not be affected.

roman-khimov
roman-khimov previously approved these changes Jan 26, 2021
@erikzhang
Copy link
Member Author

I will merge this first. And please check #2266.

@erikzhang erikzhang merged commit 5c88a99 into master Jan 27, 2021
@erikzhang erikzhang deleted the check-script branch January 27, 2021 09:29
Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

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

Good checks.

roman-khimov added a commit to nspcc-dev/neo-go that referenced this pull request Feb 9, 2021
Some methods must be defined in a valid ABI. Refs. neo-project/neo#2263.
ixje added a commit to CityOfZion/neo-mamba that referenced this pull request Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants