Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Extend ExecutionContext with states #193

Merged
merged 5 commits into from
Aug 20, 2019

Conversation

erikzhang
Copy link
Member

Closes #191

@codecov-io
Copy link

codecov-io commented Aug 16, 2019

Codecov Report

Merging #193 into master will increase coverage by 0.23%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #193      +/-   ##
==========================================
+ Coverage   79.07%   79.31%   +0.23%     
==========================================
  Files          16       16              
  Lines        1405     1421      +16     
==========================================
+ Hits         1111     1127      +16     
  Misses        294      294
Impacted Files Coverage Δ
src/neo-vm/ExecutionContext.cs 100% <100%> (ø) ⬆️
src/neo-vm/ExecutionEngine.cs 70.75% <100%> (+0.04%) ⬆️

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 98805df...e338202. Read the comment docs.

igormcoelho
igormcoelho previously approved these changes Aug 16, 2019
Copy link
Contributor

@igormcoelho igormcoelho left a comment

Choose a reason for hiding this comment

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

I like these changes. Don't know how GetState compiles into library (being a template function), but still, looking good (an implicit cast is made).
I hope this function doesn't break my C++ portable vm of C# 😂

Advice is the same here @shargon, I think we should test and use it on ApplicationEngine before we merge this... so we are sure this is useful.

@igormcoelho
Copy link
Contributor

@erikzhang If I'm following your reasoning here, perhaps we should declare Context as sealed, and end future inheritance tries. This expresses more clearly the intend of not extending this.

@@ -1074,12 +1071,11 @@ private bool ExecuteInstruction()
return true;
}

private void LoadContext(ExecutionContext context)
protected virtual void LoadContext(ExecutionContext context)
Copy link
Contributor

Choose a reason for hiding this comment

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

Will we still inherit from this?

Copy link
Member

Choose a reason for hiding this comment

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

Is the unique way to set the states

Copy link
Contributor

Choose a reason for hiding this comment

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

So event based may be better than this, if we can seal the class and use event to manage internals...

Copy link
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

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

It could work, i will test it and approve it

Co-Authored-By: Igor Machado Coelho <igor.machado@gmail.com>
Copy link
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

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

My review at #194

@shargon
Copy link
Member

shargon commented Aug 18, 2019

How can I share the script Hash on ContextLoader? Also I want to cache this in this states, but i only can check if it is the same as the calling Context

@erikzhang
Copy link
Member Author

What is ContextLoader?

@shargon
Copy link
Member

shargon commented Aug 19, 2019

sorry, LoadContext xD

@erikzhang
Copy link
Member Author

You can override LoadContext().

@shargon
Copy link
Member

shargon commented Aug 19, 2019

We should decide if is better with events or with override.
I think that events should have more presence in neo. But we can have both, are compatible

@erikzhang
Copy link
Member Author

There are currently no other places where these events are used. And the event can be listened to by multiple listeners, and you can't control the order of execution, which is very unfavorable for the method that can modify the parameters.

@shargon
Copy link
Member

shargon commented Aug 20, 2019

Is ready to me, i am not sure if this could help with the script hash cache, because is related to the script hash, but this is not the priority now, just focus on neo-project/neo#927

Copy link
Contributor

@igormcoelho igormcoelho left a comment

Choose a reason for hiding this comment

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

Lets try it, looks good.

@igormcoelho
Copy link
Contributor

@erikzhang we can still overide a method on sealed class? learning things every day...
I agree with you that execution order is fundamental, without that guarantee, its hard to use events 👍

@shargon shargon merged commit 1663f61 into master Aug 20, 2019
@shargon shargon deleted the features/extend-execution-context branch August 20, 2019 16:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants