-
Notifications
You must be signed in to change notification settings - Fork 757
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
ExecResult simplification #551
Conversation
This pull request fixes 1 alert when merging 80d1293 into a990a3a - view on LGTM.com fixed alerts:
|
Some questions:
|
This pull request fixes 1 alert when merging e78de1c into a990a3a - view on LGTM.com fixed alerts:
|
This pull request fixes 1 alert when merging d50bb32 into a990a3a - view on LGTM.com fixed alerts:
|
Re 1.:
Something I was thinking about a bit in this direction was whether it makes sense to have separate objects for the results at each step ( |
Thanks for starting to work on this! I like the changes you've made. Some other points that I was considering for simplification, which I'd be curious to hear your take on:
|
I have a feeling that this may be useful for some use-cases, but I don't know of one.
This is interesting. How do you imagine this being implemented? Returning a tuple form |
Haven't noticed this before. I'll try and unify them.
Good point. I'm also a little confused about
TBH I have no idea. Maybe it's useful on failures.
Is there a way to know the gas limit apart from adding them? |
This pull request fixes 1 alert when merging 370526e into a990a3a - view on LGTM.com fixed alerts:
|
I think I find a bug or documentation error related to this.
But this internal function of I guess is a documentation error. Any idea @s1na ? |
This |
Ok let's leave those options we're not sure of for now.
I don't have a strong opinion on this. I just think nesting data structures like we're doing now results in returning extra unnecessary data. On
Gas limit is usually provided by the calling code. But let's leave this |
To help our thought process it might be good to have every result interface and their relationship in one glance (from the lowest level of bytecode execution, to highest level of block execution): Running a bytecode via export interface InterpreterResult {
runState?: RunState
exception: IsException
exceptionError?: VmError | ERROR
} It further produces these side-effects which are stored in export interface RunResult {
logs: any // TODO: define type for Log (each log: [Buffer(address), [Buffer(topic0), ...]])
returnValue?: Buffer
gasRefund: BN
/**
* A map from the accounts that have self-destructed to the addresses to send their funds to
*/
selfdestruct: { [k: string]: Buffer }
} After executing a single call, export interface ExecResult {
runState?: RunState
/**
* `0` if the contract encountered an exception, `1` otherwise
*/
exception: IsException
/**
* Description of the exception, if any occured
*/
exceptionError?: VmError | ERROR
/**
* Amount of gas left
*/
gas?: BN
/**
* Amount of gas the code used to run
*/
gasUsed: BN
/**
* Return value from the contract
*/
return: Buffer
/**
* Array of logs that the contract emitted
*/
logs?: any[]
/**
* Value returned by the contract
*/
returnValue?: Buffer
/**
* Amount of gas to refund from deleting storage values
*/
gasRefund?: BN
/**
* A map from the accounts that have self-destructed to the addresses to send their funds to
*/
selfdestruct?: { [k: string]: Buffer }
}
export interface EVMResult {
/**
* Amount of gas used by the transaction
*/
gasUsed: BN
/**
* Address of created account durint transaction, if any
*/
createdAddress?: Buffer
/**
* Contains the results from running the code, if any, as described in [[runCode]]
*/
vm: ExecResult
} After /**
* Execution result of a transaction
*/
export interface RunTxResult extends EVMResult {
/**
* Bloom filter resulted from transaction
*/
bloom: Bloom
/**
* The amount of ether used by this transaction
*/
amountSpent: BN
/**
* The amount of gas as that was refunded during the transaction (i.e. `gasUsed = totalGasConsumed - gasRefund`)
*/
gasRefund?: BN
}
/**
* Result of [[runBlock]]
*/
export interface RunBlockResult {
/**
* Receipts generated for transactions in the block
*/
receipts: TxReceipt[]
/**
* Results of executing the transactions in the block
*/
results: RunTxResult[]
} |
Ah yes, it's incorrect. I think it makes sense to keep the
Sounds reasonable. I'll pay more attention to these types and think about it.
This is a very good point.
Thanks! This is super useful! I'll take a deeper look at this later today/tomorrow. |
Yeah sorry for the confusion, I didn't suggest we drop By the way, we don't have to do all the simplification in this PR. This can be a longer process. Let me know whenever you're happy with the PR yourself and I'll review. |
After working for a few days with the beta of v4, I came to appreciate this simplification a lot. I will update this PR today so it can be reviewed. Should we release a new beta with this change @holgerd77? |
@alcuadrado Yes, maybe another |
370526e
to
d5d7484
Compare
This pull request fixes 1 alert when merging d5d7484 into 4bbb6e3 - view on LGTM.com fixed alerts:
|
I unified the I think I encountered a bug in the EEI implementation. Can you take a look at this @s1na? d5d7484#diff-73c9d0f1a5deec3528a056f5d9e78b3aR575 Apart from that, I think this is ready to review. Things discussed but not included in this PR:
|
I missed this @holgerd77. What about a beta when this gets merged, and another one if we migrate block to ts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very good thanks @alcuadrado. Just for documentation purposes, it introduces 3 breaking changes:
- The result
vm
field being renamed toexecResult
(wondering if this is worth a breaking change. Thoughts @holgerd77?) exception
is droppedreturnValue
in one of the result interfaces is dropped in favor ofreturn
(I do favorreturnValue
slightly more though, because it's not a reserved keyword)
I think I encountered a bug in the EEI implementation. Can you take a look at this @s1na? d5d7484#diff-73c9d0f1a5deec3528a056f5d9e78b3aR575
This is consensus logic, I assume the current implementation is correct, otherwise tests would have caught it. (We're not fully compatible with the Ewasm EEI and have already other differences.)
This is a good point, I'll rename it.
Yes, I initially implemented the logic described in the spec and lots of tests failed. Should I leave the comment there? |
This pull request fixes 1 alert when merging 5263ea6 into 4bbb6e3 - view on LGTM.com fixed alerts:
|
@s1na I think I like the Just had a rough look, there is this @s1na Would be good if you then just finish the review and eventually merge, not yet so deep into this PR respectively the code changes and would like to avoid digging deeper if possible. @alcuadrado @s1na Yes, we can also do another |
I think this kind of change only makes sense in the context of a bigger release, like this one.
I forgot about that. It's already renamed.
Sounds good. |
This pull request fixes 1 alert when merging f3bd72a into 4bbb6e3 - view on LGTM.com fixed alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
This is a WIP that simplifies the
ExecResult
type.The changes I made so far are:
ERROR
.ExecResult
andPrecompileResult
.OOGResult
toevm.ts
EVMResult#vm
toEVMResult#execResult
Each of them is implemented in separate commits, so we can pick/discard whatever we want.