Skip to content

Sync neo changes#391

Merged
shargon merged 55 commits intoneo-project:masterfrom
shargon:sync-nep17
Dec 10, 2020
Merged

Sync neo changes#391
shargon merged 55 commits intoneo-project:masterfrom
shargon:sync-nep17

Conversation

@shargon
Copy link
Member

@shargon shargon commented Nov 12, 2020

@Tommo-L
Copy link
Contributor

Tommo-L commented Nov 13, 2020

call onPayment in Transfer method?

@shargon
Copy link
Member Author

shargon commented Nov 13, 2020

call onPayment in Transfer method?

In the template right?

@Tommo-L
Copy link
Contributor

Tommo-L commented Nov 13, 2020

call onPayment in Transfer method?

In the template right?

Yes

@Tommo-L
Copy link
Contributor

Tommo-L commented Nov 13, 2020

UT failed

@shargon
Copy link
Member Author

shargon commented Nov 13, 2020

UT failed

It will need the neo nuget

addrConvTable ??= ImmutableDictionary<int, int>.Empty;

var outjson = new JObject();
outjson["hash"] = FuncExport.ComputeHash(script);
Copy link
Member Author

Choose a reason for hiding this comment

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

@devhawk do you need the name in debugExport?

Copy link
Contributor

Choose a reason for hiding this comment

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

I need whatever unique identifier is used to identify the contract.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a design document describing how contract deploy and invoke is supposed to work now? I am all for having a stable contract identifier other than the script hash, though it's not clear what the new design is?

One question - Have we considered the impact on dynamic contract invocations scenarios. Using script hash to invoke a contract means that any calling contracts break when a dependent contract is updated. That is, I was calling a specific contract by script hash it will be obvious something has changed if that script hash is no longer valid. With a stable identifier, will it still be obvious if a dependent contract has made a backwards incompatible change?

Copy link
Member

@vncoelho vncoelho Nov 19, 2020

Choose a reason for hiding this comment

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

Hi @devhawk, thinking in this perspective you mentioned, it may be important to create a flag that says that the contract trust any update on the dynamic invoked contract.
For instance, most of the DeFi projects are relying on external dynamic invoked contracts. In this sense, consider the need of mutual update is something plausible.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would expect that dynamic invoke scenarios always require "mutual update" as you called it @vncoelho. I'm not sure it's a good idea to make the change less obvious. Right now, if you update your contract it breaks anyone who calls it since the hash changes. If we keep the hash, will that allow a developer to publish a malicious contract update w/o their users noticing?

@superboyiii superboyiii mentioned this pull request Nov 16, 2020
44 tasks
//hash
outjson["hash"] = ComputeHash(script);
//name
outjson["name"] = module.attributes
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the https://github.com/neo-project/neo/pull/2024/files#diff-6a8fe6159fb062d52f619635b6c0e2123632e3a61acdc5f86b867da878af2e02R166, name is on first level in manifest, but here the name is inside the abi.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now I am not sure, maybe it's more appropriate to put the Name in the abi 🤔. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think name and supportedstandards should be on the same level, maybe it shouldn't be added here?

@Tommo-L
Copy link
Contributor

Tommo-L commented Nov 20, 2020

UT failed

@shargon
Copy link
Member Author

shargon commented Nov 20, 2020

UT failed

It require neo-project/neo#2044

@cloud8little
Copy link
Contributor

#391 (comment)
use neo to mint only success for the first time. Refs:

4b72a1db3f1b604df88f7098427d409

@erikzhang
Copy link
Member

@cloud8little Fixed.

@Tommo-L
Copy link
Contributor

Tommo-L commented Dec 9, 2020

When transfer NEO, it'll trigger twice OnPayment.
One is for auto-clamied
https://github.com/neo-project/neo/blob/beac9a9432ea3b6d423f570ab535a257e750bab8/src/neo/SmartContract/Native/Tokens/NeoToken.cs#L68

Another is NEO transfer:
https://github.com/neo-project/neo/blob/beac9a9432ea3b6d423f570ab535a257e750bab8/src/neo/SmartContract/Native/Tokens/Nep17Token.cs#L146

There are two OnPayment context in stack, after NEO transfered.

@superboyiii
Copy link
Member

superboyiii commented Dec 9, 2020

@cloud8little Fixed.

It still get the wrong CallingScriptHash. I found the first received CallingScriptHash is the Nep17 contract itself's if mint twice.
When this transaction make contract address auto claim gas, the CallingScriptHash can be contract address itself and it also call onPayment?
image
image

@erikzhang
Copy link
Member

It should be fixed by neo-project/neo#2130

@shargon
Copy link
Member Author

shargon commented Dec 9, 2020

Because the problem it's in core and not in the template, we can merge it?

@superboyiii
Copy link
Member

I think template is OK, we can merge it first because #402 is waiting for this.

@shargon shargon mentioned this pull request Dec 9, 2020
@shargon
Copy link
Member Author

shargon commented Dec 9, 2020

Merge? 🚀

@erikzhang
Copy link
Member

@shargon We need to fix #391 (comment)

@shargon
Copy link
Member Author

shargon commented Dec 10, 2020

Null should return false or throw?

@shargon shargon merged commit 64db190 into neo-project:master Dec 10, 2020
@shargon shargon deleted the sync-nep17 branch December 10, 2020 09:05
Jim8y pushed a commit that referenced this pull request Aug 3, 2025
* Initial commit
* Remove hash from ABI
* Clean lines
* Fixes
* Fix some UT
* Change name to manifest
* Update nuget
* Update NEP17.cs
* Fix more UT
* Some fixes
* Fix Contract
* Update NEP17.Owner.cs
* Update NEP17.Methods.cs
* Add data to Transfer
* add data to onPayment
* Remove name
* Update src/Neo.Compiler.MSIL/Neo.Compiler.MSIL.csproj
Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com>
* Fix NEF Version
* Fix UT
* Fix test
* Add OnPayment() for Mint()
* Fix
* Fix
* Format
* Format
* Format
* Update NEP17.Owner.cs
* Update templates/Template.NEP17.CSharp/NEP17.cs
* Update templates/Template.NEP17.CSharp/NEP17.Methods.cs
* Update AssetStorage.cs
* Update AssetStorage.cs
* Update AssetStorage.cs
* Update templates/Template.NEP17.CSharp/NEP17.cs
Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com>
* Update templates/Template.NEP17.CSharp/NEP17.Methods.cs
Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com>
* Rename to ContractNameAttribute & fix invocation counter
* Change mint
* Rename to IsDeployed
* Use DisplayName
* Fix mint
* Fix
* Optimize Mint
* Remove GetTransactionAmount
* Fix claim gas
* Add IsValid
* Update NEP17.Crowdsale.cs
* Update src/Neo.SmartContract.Framework/UInt160.cs
Co-authored-by: Erik Zhang <erik@neo.org>
* Remove Size from UInt160 and UInt256
* Update UInt256.cs
* Fix UT
Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com>
Co-authored-by: superboyiii <573504781@qq.com>
Co-authored-by: Erik Zhang <erik@neo.org>
Jim8y pushed a commit that referenced this pull request Aug 18, 2025
* Initial commit

* Remove hash from ABI

* Clean lines

* Fixes

* Fix some UT

* Change name to manifest

* Update nuget

* Update NEP17.cs

* Fix more UT

* Some fixes

* Fix Contract

* Update NEP17.Owner.cs

* Update NEP17.Methods.cs

* Add data to Transfer

* add data to onPayment

* Remove name

* Update src/Neo.Compiler.MSIL/Neo.Compiler.MSIL.csproj

Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com>

* Fix NEF Version

* Fix UT

* Fix test

* Add OnPayment() for Mint()

* Fix

* Fix

* Format

* Format

* Format

* Update NEP17.Owner.cs

* Update templates/Template.NEP17.CSharp/NEP17.cs

* Update templates/Template.NEP17.CSharp/NEP17.Methods.cs

* Update AssetStorage.cs

* Update AssetStorage.cs

* Update AssetStorage.cs

* Update templates/Template.NEP17.CSharp/NEP17.cs

Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com>

* Update templates/Template.NEP17.CSharp/NEP17.Methods.cs

Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com>

* Rename to ContractNameAttribute & fix invocation counter

* Change mint

* Rename to IsDeployed

* Use DisplayName

* Fix mint

* Fix

* Optimize Mint

* Remove GetTransactionAmount

* Fix claim gas

* Add IsValid

* Update NEP17.Crowdsale.cs

* Update src/Neo.SmartContract.Framework/UInt160.cs

Co-authored-by: Erik Zhang <erik@neo.org>

* Remove Size from UInt160 and UInt256

* Update UInt256.cs

* Fix UT

Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com>
Co-authored-by: superboyiii <573504781@qq.com>
Co-authored-by: Erik Zhang <erik@neo.org>
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.

Neo.Compiler.MSIL no longer compiles against neo master branch

10 participants