Skip to content

Centralize _initialize call#2052

Merged
shargon merged 26 commits intoneo-project:masterfrom
shargon:verification-create
Nov 24, 2020
Merged

Centralize _initialize call#2052
shargon merged 26 commits intoneo-project:masterfrom
shargon:verification-create

Conversation

@shargon
Copy link
Member

@shargon shargon commented Nov 5, 2020

Close #2047

@shargon
Copy link
Member Author

shargon commented Nov 5, 2020

@chenzhitong please take a look to this solution, I think that verification it's quite important to replicate the logic around modules.

@roman-khimov
Copy link
Contributor

We've played a little with neo-project/neo-modules#378 and I think this is really needed to do it right.

@chenzhitong
Copy link
Contributor

@chenzhitong please take a look to this solution, I think that verification it's quite important to replicate the logic around modules.

image
Brother, have a cold Coke.

@erikzhang
Copy link
Member

Can it be solved by creating mocked IVerifiable?

@roman-khimov
Copy link
Contributor

Can it be solved by creating mocked IVerifiable?

Take a look at neo-project/neo-modules#378 (comment), I don't think we can make anything useful without real Transaction. Signature check is something expected to be used in verification context and it needs real data.

@erikzhang
Copy link
Member

Can you provide some code on how you plan to call it? I want to see if there are other ways.

@Tommo-L
Copy link
Contributor

Tommo-L commented Nov 16, 2020

Can you provide some code on how you plan to call it? I want to see if there are other ways.

https://github.com/neo-project/neo-modules/pull/378/files#diff-b7c84ee5f6c8ef2d64f5942c80e7cf30024bc0ebfe006f02cc2a2b9c0842ba65R88

@erikzhang
Copy link
Member

I didn't find where it calls TryCreateVerifyEngine. @Tommo-L

@Tommo-L
Copy link
Contributor

Tommo-L commented Nov 17, 2020

We want to add a InvokeContractVerify method in rpc server.

var tx = new Transaction{ Witnesses =[new Witness ]}
var witnessIndex = 0
if (Helper.TryCreateVerifyEngine(tx, snapshot.clone(), scriptHash, witnessIndex, MaxVerificationGas), out ApplicationEngine engine)
{
      JObject json = new JObject();
      json["script"] = Convert.ToBase64String(contract.Script);
      json["state"] = engine.Execute();
      json["gasconsumed"] = new BigDecimal(engine.GasConsumed, NativeContract.GAS.Decimals).ToString();
      json["exception"] = GetExceptionMessage(engine.FaultException);
}

@erikzhang
Copy link
Member

erikzhang commented Nov 17, 2020

Maybe add a method LoadContractMethod() in ApplicationEngine? And it automatically load _initialize if it exists.

LoadContractMethod() can be used in both Verification and Application triggers.

@Tommo-L
Copy link
Contributor

Tommo-L commented Nov 17, 2020

Maybe add a method LoadContractMethod() in ApplicationEngine? And it automatically load _initialize if it exists.

LoadContractMethod() can be used in both Verification and Application triggers.

@shargon what do you think?

@shargon
Copy link
Member Author

shargon commented Nov 18, 2020

@shargon what do you think?

I will do it

@shargon
Copy link
Member Author

shargon commented Nov 18, 2020

@erikzhang @Tommo-L please take a look

Co-authored-by: Erik Zhang <erik@neo.org>
erikzhang
erikzhang previously approved these changes Nov 22, 2020
@erikzhang
Copy link
Member

Maybe we should modify CallContractInternal() to use LoadContract() too.

@shargon
Copy link
Member Author

shargon commented Nov 22, 2020

Maybe we should modify CallContractInternal() to use LoadContract() too.

I think that it's ok like this because CallContractInternal is more complex.

@shargon
Copy link
Member Author

shargon commented Nov 23, 2020

@superboyiii tested?

@superboyiii
Copy link
Member

superboyiii commented Nov 24, 2020

@superboyiii tested?

Tested on my local within Native contract's methods. It works well.

@shargon shargon merged commit 7a36f80 into neo-project:master Nov 24, 2020
@shargon shargon deleted the verification-create branch November 24, 2020 08:54
ShawnYun pushed a commit to ShawnYun/neo that referenced this pull request Jan 8, 2021
* Allow to get Verification Result outside core

* Use index

* Return IEnumerable

* Clean code

* Revert "Return IEnumerable"

This reverts commit 7dd3717.

* LoadContract solution

* Remove constant

* Reuse call

* Refactor

* Move to LoadContract

* Remove double check

* Update src/neo/SmartContract/ApplicationEngine.cs

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

* Move to else

* Fix LoadContract

* Update Helper.cs

* Remove empty line

* Add packParameters

* Use LoadContract in CallContractInternal

Co-authored-by: Erik Zhang <erik@neo.org>
cloud8little pushed a commit to cloud8little/neo that referenced this pull request Jan 24, 2021
* Allow to get Verification Result outside core

* Use index

* Return IEnumerable

* Clean code

* Revert "Return IEnumerable"

This reverts commit 7dd3717.

* LoadContract solution

* Remove constant

* Reuse call

* Refactor

* Move to LoadContract

* Remove double check

* Update src/neo/SmartContract/ApplicationEngine.cs

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

* Move to else

* Fix LoadContract

* Update Helper.cs

* Remove empty line

* Add packParameters

* Use LoadContract in CallContractInternal

Co-authored-by: Erik Zhang <erik@neo.org>
ixje added a commit to CityOfZion/neo-mamba that referenced this pull request Feb 2, 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

Development

Successfully merging this pull request may close these issues.

6 participants