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

Replace NEP-5 with NEP-17 #1558

Merged
merged 6 commits into from
Nov 24, 2020
Merged

Replace NEP-5 with NEP-17 #1558

merged 6 commits into from
Nov 24, 2020

Conversation

fyrchik
Copy link
Contributor

@fyrchik fyrchik commented Nov 20, 2020

  1. Add Name field to manifest.
  2. Fix calling from native contracts (need to discuss with NEO).
  3. NEP-17.

TODO

  • update transfer costs

pkg/compiler/debug.go Outdated Show resolved Hide resolved
pkg/core/native/native_nep17.go Outdated Show resolved Hide resolved
pkg/core/native/native_nep17.go Outdated Show resolved Hide resolved
pkg/core/native/native_nep17.go Show resolved Hide resolved
@roman-khimov
Copy link
Member

And take a look at RPC client also, NEP5Name is no longer relevant, for example.

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

There's also a binary file added (cli/testdata/verify.nef ), do we need it?

pkg/smartcontract/manifest/manifest.go Show resolved Hide resolved
@@ -402,6 +409,10 @@ func (o *Oracle) verify(ic *interop.Context, _ []stackitem.Item) stackitem.Item
return stackitem.NewBool(ic.Tx.HasAttribute(transaction.OracleResponseT))
}

func (o *Oracle) onPayment(_ *interop.Context, _ []stackitem.Item) stackitem.Item {
return stackitem.Null{}
Copy link
Member

Choose a reason for hiding this comment

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

Just a question, don't we need to check that calling script hash is GAS and panic if not? Otherwise, Oracle contract will accept any other token.

Copy link
Member

@roman-khimov roman-khimov Nov 23, 2020

Choose a reason for hiding this comment

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

I think this needs to be discussed with core devs. I mean, it's correct and expected behavior, but at the same time we need to be compatible.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, allow GAS only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a problem with this: when invoking native methods directly, calling script hash is not updated. And when invoking them via contract.Call, GAS is spent.

Copy link
Member

Choose a reason for hiding this comment

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

Same problem in neo-project/neo#2094.

pkg/smartcontract/manifest/manifest.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Nov 23, 2020

Codecov Report

Merging #1558 (31eca34) into master (5f21178) will increase coverage by 0.04%.
The diff coverage is 84.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1558      +/-   ##
==========================================
+ Coverage   77.54%   77.58%   +0.04%     
==========================================
  Files         233      233              
  Lines       18413    18438      +25     
==========================================
+ Hits        14278    14306      +28     
+ Misses       3120     3116       -4     
- Partials     1015     1016       +1     
Impacted Files Coverage Δ
pkg/core/interop_system.go 63.20% <0.00%> (+1.72%) ⬆️
pkg/core/storage/store.go 75.00% <ø> (ø)
pkg/rpc/client/nep17.go 49.05% <58.33%> (ø)
pkg/core/dao/dao.go 69.40% <66.66%> (ø)
pkg/core/dao/cacheddao.go 76.66% <81.81%> (ø)
pkg/core/native/native_gas.go 66.66% <81.81%> (ø)
pkg/core/native/native_neo.go 71.59% <81.81%> (ø)
pkg/core/native/oracle.go 81.14% <81.81%> (-0.06%) ⬇️
pkg/rpc/server/server.go 77.45% <85.71%> (-0.08%) ⬇️
pkg/core/blockchain.go 74.10% <86.66%> (ø)
... and 15 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 5f21178...31eca34. Read the comment docs.

// InvocationState contains return convention and callback to be executed on context unload.
type InvocationState struct {
// Callback is executed on context unload.
Callback func(ctx *Context)
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need it now, though it exists in C# code.
If we remove it, some tests for native contract will also be removed. I am ok with both variants, as we have it covered with tests.

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 we better not introduce things not need for the protocol to work. I'd say it's an internal C# thingie (that's not really used even there), so we can not complicate our code with it.

pkg/vm/emit/emit.go Show resolved Hide resolved
@@ -402,6 +409,10 @@ func (o *Oracle) verify(ic *interop.Context, _ []stackitem.Item) stackitem.Item
return stackitem.NewBool(ic.Tx.HasAttribute(transaction.OracleResponseT))
}

func (o *Oracle) onPayment(_ *interop.Context, _ []stackitem.Item) stackitem.Item {
return stackitem.Null{}
Copy link
Member

Choose a reason for hiding this comment

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

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.

supportedstandards in YAML files were not updated to nep-17.

pkg/rpc/server/server.go Show resolved Hide resolved
pkg/rpc/server/testdata/test_contract.go Show resolved Hide resolved
pkg/rpc/server/testdata/test_contract.go Show resolved Hide resolved
When native method calls other contract result should be put
on the stack of current context. With oracles this problem wasn't
noticed because of void return type.
Sometimes amount of GAS consumed depends on block height.
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.

@AnnaShaleva: take a look and you can use data in onPayment now.

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.

3 participants