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

core: add status as a consensus field in receipt #15014

Merged
merged 3 commits into from Aug 23, 2017

Conversation

Projects
None yet
5 participants
@rjl493456442
Member

rjl493456442 commented Aug 21, 2017

Implements Ethereum EIP #658

Motivation:

Current receipt doesn't include a field to indicate the transaction execution status. User can only get execution result by replay transaction. While this method is only useful in a full node, fast nodes can only do this for nodes after their pivot point, and light nodes cannot do this at all. So the field in receipt is helpful.

So a new field Failed is added to receipt, if this field be set with false, means the state revert happened in the outermost call(any internal state revert can be discarded).

While in consensus recepit, failed is converted to a field named status, 0x01 means transaction been executed successfully, while 0x00 means failure occurred.

Whatsmore, the Failed can help to estimate gas cost more accurately, and expose more information in evm runner

@rjl493456442 rjl493456442 changed the title from [WIP]core/types: add status as a consensus field in receipt to core: add status as a consensus field in receipt Aug 21, 2017

@rjl493456442

This comment has been minimized.

Show comment
Hide comment
@rjl493456442

rjl493456442 Aug 21, 2017

Member

@karalabe Could you please review the changes?

Member

rjl493456442 commented Aug 21, 2017

@karalabe Could you please review the changes?

@karalabe karalabe added this to the 1.7.0 milestone Aug 21, 2017

@karalabe karalabe added the metropolis label Aug 21, 2017

Show outdated Hide outdated core/vm/evm.go
Show outdated Hide outdated core/vm/evm.go
Show outdated Hide outdated core/vm/evm.go
Show outdated Hide outdated core/vm/evm.go
Show outdated Hide outdated core/vm/evm.go
@karalabe

Thanks for the PR! It's almost good, but can be simplified a bit.

@karalabe

This comment has been minimized.

Show comment
Hide comment
@karalabe

karalabe Aug 21, 2017

Member

Note, an internal reversion doesn't mean the receipt's state should be set to failed. Only the outermost revertal/failure should impact the receipt's new field.

Member

karalabe commented Aug 21, 2017

Note, an internal reversion doesn't mean the receipt's state should be set to failed. Only the outermost revertal/failure should impact the receipt's new field.

@rjl493456442

This comment has been minimized.

Show comment
Hide comment
@rjl493456442

rjl493456442 Aug 21, 2017

Member

Thanks for your time! If only the outermost failure should take care, it can be more simplified. It will fix these tomorrow.

Member

rjl493456442 commented Aug 21, 2017

Thanks for your time! If only the outermost failure should take care, it can be more simplified. It will fix these tomorrow.

@rjl493456442 rjl493456442 changed the title from core: add status as a consensus field in receipt to [WIP]core: add status as a consensus field in receipt Aug 22, 2017

@rjl493456442 rjl493456442 changed the title from [WIP]core: add status as a consensus field in receipt to core: add status as a consensus field in receipt Aug 22, 2017

@karalabe

This comment has been minimized.

Show comment
Hide comment
@karalabe

karalabe Aug 22, 2017

Member

One tiny error, otherwise it works

 diff --git a/common/bytes.go b/common/bytes.go
index c445968..66577bb 100644
--- a/common/bytes.go
+++ b/common/bytes.go
@@ -47,6 +47,9 @@ func FromHex(s string) []byte {
 //
 // Returns an exact copy of the provided bytes
 func CopyBytes(b []byte) (copiedBytes []byte) {
+       if b == nil {
+               return nil
+       }
        copiedBytes = make([]byte, len(b))
        copy(copiedBytes, b)

Without this, the PostState of a receipt is always set to []byte{} on Metropolis, which causes it to encode as Homestead (since PostState != nil).

Member

karalabe commented Aug 22, 2017

One tiny error, otherwise it works

 diff --git a/common/bytes.go b/common/bytes.go
index c445968..66577bb 100644
--- a/common/bytes.go
+++ b/common/bytes.go
@@ -47,6 +47,9 @@ func FromHex(s string) []byte {
 //
 // Returns an exact copy of the provided bytes
 func CopyBytes(b []byte) (copiedBytes []byte) {
+       if b == nil {
+               return nil
+       }
        copiedBytes = make([]byte, len(b))
        copy(copiedBytes, b)

Without this, the PostState of a receipt is always set to []byte{} on Metropolis, which causes it to encode as Homestead (since PostState != nil).

rjl493456442 and others added some commits Aug 21, 2017

@karalabe

LGTM (I've squashed it and pulled in a test suite update)

Show outdated Hide outdated core/types/receipt.go
@karalabe

This comment has been minimized.

Show comment
Hide comment
@karalabe

karalabe Aug 23, 2017

Member

@holiman Fixed, PTAL.

Member

karalabe commented Aug 23, 2017

@holiman Fixed, PTAL.

@holiman

This comment has been minimized.

Show comment
Hide comment
@holiman

holiman Aug 23, 2017

Contributor

LGTM

Contributor

holiman commented Aug 23, 2017

LGTM

@karalabe karalabe merged commit 3c48a25 into ethereum:master Aug 23, 2017

1 of 3 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
commit-message-check/gitcop All commit messages are valid
Details
@@ -158,7 +158,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
evm.Transfer(evm.StateDB, caller.Address(), to.Address(), value)
// initialise a new contract and set the code that is to be used by the
// E The contract is a scoped evmironment for this execution context

This comment has been minimized.

@ligi

ligi Aug 24, 2017

Member

what a great typo - love this word!-)

@ligi

ligi Aug 24, 2017

Member

what a great typo - love this word!-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment