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

Sync neo changes #391

Merged
merged 55 commits into from
Dec 10, 2020
Merged

Sync neo changes #391

merged 55 commits into from
Dec 10, 2020

Conversation

@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

{
var docMap = GetDocumentMap(module);
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

Test passed with commit 882a721

  1. send neo to the contract.
neo> send neo 0xc77487f73dfde3f76f690f5df96c39af72bc1667 100 NfkPM5juAxBETYXNMZpp1zzxVCwJpAqQRh
password: *
TXID: 0x3be7f74736b3544b389ce1a5319da4a138ee97009c08f52f7a11b74d58e198e7
neo> invoke 0xc77487f73dfde3f76f690f5df96c39af72bc1667 totalSupply []
Invoking script with: 'EMAMC3RvdGFsU3VwcGx5DBRnFrxyrzls+V0PaW/34/0994d0x0FifVtS'
VM State: HALT
Gas Consumed: 0.0374394
Result Stack: [{"type":"Integer","value":"2000100000000000"}]
Relay tx(no|yes): no
  1. send gas to the contract
neo> send gas 0xc77487f73dfde3f76f690f5df96c39af72bc1667 5 NfkPM5juAxBETYXNMZpp1zzxVCwJpAqQRh
password: *
TXID: 0x7735e0947eddff53049d39807c38f872380c78879b8f8776f316789a23ff6d63
neo> invoke 0xc77487f73dfde3f76f690f5df96c39af72bc1667 totalSupply []
Invoking script with: 'EMAMC3RvdGFsU3VwcGx5DBRnFrxyrzls+V0PaW/34/0994d0x0FifVtS'
VM State: HALT
Gas Consumed: 0.0374394
Result Stack: [{"type":"Integer","value":"2000100500000000"}]
Relay tx(no|yes): no
  1. send the asset to other account.
neo> invoke 0xc77487f73dfde3f76f690f5df96c39af72bc1667 balanceOf [{"type":"Hash160","value":"0xeaf0dd7a6b7b4248b22c2b5f7f0f4b5a448692d9"}] NfkPM5juAxBETYXNMZpp1zzxVCwJpAqQRh NfkPM5juAxBETYXNMZpp1zzxVCwJpAqQRh
Invoking script with: 'DBTZkoZEWksPf18rLLJIQntret3w6hHADAliYWxhbmNlT2YMFGcWvHKvOWz5XQ9pb/fj/T33h3THQWJ9W1I='
VM State: HALT
Gas Consumed: 0.0377198
Result Stack: [{"type":"Integer","value":"2000100500000000"}]
Relay tx(no|yes): no
neo> create address 1
[■■■■■■■■■■] (100.0%)
Export addresses to address.txt
neo> list address
   Address: NfkPM5juAxBETYXNMZpp1zzxVCwJpAqQRh  Standard
ScriptHash: 0xeaf0dd7a6b7b4248b22c2b5f7f0f4b5a448692d9

   Address: NfjpZ2RJ1JHozNqiHLXRd2wr4qNVSnzsLk  MultiSignature
ScriptHash: 0x0b0920a82bfabf01e87d17d91b32d9f23b2677d9

   Address: NMZZos2yCEM9G2zdkMjd89MFSjjqn7xaVL  WatchOnly
ScriptHash: 0xf8e5270ffc3a50ccc611c3842d7643d8f56a1412

   Address: NSjjFysocrQhNmF26c5njBWgT4QFPttCRD  WatchOnly
ScriptHash: 0xb4e2fed09cf4968fea4885c5677866a15618d94a

   Address: NMbRM6VGEqNHSeFvwHrsDqpPi5cxtM9MEe  Standard
ScriptHash: 0x581d1eded06bbac72e3a6f14aab62114b92f6e12

neo> send 0xc77487f73dfde3f76f690f5df96c39af72bc1667  NMbRM6VGEqNHSeFvwHrsDqpPi5cxtM9MEe 160
password: *
TXID: 0xe169673f3a69faa6bfc27a0045dcf57c240ce4b592d1de2ce28a42b2f03755ac
neo> invoke 0xc77487f73dfde3f76f690f5df96c39af72bc1667 balanceOf [{"type":"Hash160","value":"0xeaf0dd7a6b7b4248b22c2b5f7f0f4b5a448692d9"}] NfkPM5juAxBETYXNMZpp1zzxVCwJpAqQRh NfkPM5juAxBETYXNMZpp1zzxVCwJpAqQRh
Invoking script with: 'DBTZkoZEWksPf18rLLJIQntret3w6hHADAliYWxhbmNlT2YMFGcWvHKvOWz5XQ9pb/fj/T33h3THQWJ9W1I='
VM State: HALT
Gas Consumed: 0.0377198
Result Stack: [{"type":"Integer","value":"2000084500000000"}]
Relay tx(no|yes): no

@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

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