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

manifest: support interface checking #1373

Merged
merged 3 commits into from
Nov 26, 2020
Merged

manifest: support interface checking #1373

merged 3 commits into from
Nov 26, 2020

Conversation

fyrchik
Copy link
Contributor

@fyrchik fyrchik commented Aug 28, 2020

There are some standards (NEP5, etc.) which impose
some restrictions on what methods and events a contract
must contain and their signatures. This commit supports
checking if arbitrary manifest complies with the standard.

@roman-khimov
Copy link
Member

Let's move compiler part out of this PR. We can't really change manifest checks now because neo-project/neo#1883 is not (yet) accepted (we can make it an extension, but it's not critical for us).

@roman-khimov
Copy link
Member

OK, I see you're not changing contract deployment checks now, so this makes more sense as it is now.

Copy link
Member

@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.

Please fix the linter also.

@@ -104,3 +104,55 @@ func TestComlileAndInvokeFunction(t *testing.T) {
require.Equal(t, []byte("on update|sub update"), res.Stack[0].Value())
})
}

func TestCompileExamples(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

But we already have something like that in the compiler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is here mainly to cover compiler options settings. Maybe we can cut this test to just 3 examples (both tokens and contract with invalid events).

There are some standards (NEP5, etc.) which impose
some restrictions on what methods and events a contract
must contain and their signatures. This commit supports
checking if arbitrary manifest complies with the standard.
Check that emitted manifest complies with supported standards.
This can be made a separate flag.
Check that all `Notify` invocations in source correspond to some event
in manifest.
Helpful for typos such as `transfer` instead of `Transfer`.
@codecov
Copy link

codecov bot commented Nov 26, 2020

Codecov Report

Merging #1373 (75a9a42) into master (882c214) will increase coverage by 0.10%.
The diff coverage is 95.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1373      +/-   ##
==========================================
+ Coverage   77.51%   77.62%   +0.10%     
==========================================
  Files         233      235       +2     
  Lines       18647    18711      +64     
==========================================
+ Hits        14455    14524      +69     
+ Misses       3167     3162       -5     
  Partials     1025     1025              
Impacted Files Coverage Δ
pkg/smartcontract/manifest/standard/nep17.go 0.00% <0.00%> (ø)
pkg/compiler/compiler.go 58.71% <86.66%> (+4.46%) ⬆️
cli/smartcontract/smart_contract.go 72.09% <100.00%> (+0.83%) ⬆️
pkg/compiler/codegen.go 90.42% <100.00%> (+0.05%) ⬆️
pkg/compiler/debug.go 83.84% <100.00%> (+0.94%) ⬆️
pkg/smartcontract/manifest/manifest.go 82.92% <100.00%> (+1.34%) ⬆️
pkg/smartcontract/manifest/standard/comply.go 100.00% <100.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 882c214...75a9a42. Read the comment docs.

tv := c.typeAndValueOf(n.Args[0])
params := make([]string, 0, len(n.Args[1:]))
for _, p := range n.Args[1:] {
params = append(params, c.scTypeFromExpr(p))
Copy link
Member

Choose a reason for hiding this comment

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

It's a little risky, but let's try doing that.

@roman-khimov roman-khimov merged commit badb1d6 into master Nov 26, 2020
@roman-khimov roman-khimov deleted the feature/standard branch November 26, 2020 11:46
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.

2 participants