Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
Merge branch 'feature/tx-status'
Browse files Browse the repository at this point in the history
  • Loading branch information
tzdybal committed Jul 19, 2018
2 parents 01ce9b3 + b65d29e commit 382aa8f
Show file tree
Hide file tree
Showing 17 changed files with 295 additions and 94 deletions.
11 changes: 5 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ sputnik_vm_steps: &sputnik_vm_steps
command: |
export GOPATH=$HOME/go
export PATH=$PATH:$HOME/.cargo/bin:$HOME/janusbin
git clone https://github.com/ethereumproject/sputnikvm-ffi $GOPATH/src/github.com/ethereumproject/sputnikvm-ffi
cd $GOPATH/src/github.com/ethereumproject/sputnikvm-ffi/c/ffi && cargo build --release
cp $GOPATH/src/github.com/ethereumproject/sputnikvm-ffi/c/ffi/target/release/libsputnikvm_ffi.a $GOPATH/src/github.com/ethereumproject/sputnikvm-ffi/c/libsputnikvm.a
cd $GOPATH/src/github.com/ethereumproject/go-ethereum
make -C vendor/github.com/ethereumproject/sputnikvm-ffi/c
- persist_to_workspace:
root: ~/
paths:
- go/src/github.com/ethereumproject/sputnikvm-ffi/c/libsputnikvm.a
- go/src/github.com/ethereumproject/go-ethereum/vendor/github.com/ethereumproject/sputnikvm-ffi/c/libsputnikvm.a

deploy_steps: &deploy_steps
steps:
Expand Down Expand Up @@ -48,7 +47,7 @@ unit_tests_steps: &unit_tests_steps
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN
export CGO_LDFLAGS="$GOPATH/src/github.com/ethereumproject/sputnikvm-ffi/c/libsputnikvm.a -ldl"
export CGO_LDFLAGS="$GOPATH/src/github.com/ethereumproject/go-ethereum/vendor/github.com/ethereumproject/sputnikvm-ffi/c/libsputnikvm.a -ldl"
if [ "$(uname)" == "Darwin" ]; then
export CGO_LDFLAGS="$CGO_LDFLAGS -lresolv"
fi
Expand All @@ -68,7 +67,7 @@ bats_tests_steps: &bats_tests_steps
name: Run bats tests
command: |
export GOPATH=$HOME/go
export CGO_LDFLAGS="$GOPATH/src/github.com/ethereumproject/sputnikvm-ffi/c/libsputnikvm.a -ldl"
export CGO_LDFLAGS="$GOPATH/src/github.com/ethereumproject/go-ethereum/vendor/github.com/ethereumproject/sputnikvm-ffi/c/libsputnikvm.a -ldl"
if [ "$(uname)" == "Darwin" ]; then
export CGO_LDFLAGS="$CGO_LDFLAGS -lresolv"
else
Expand Down
128 changes: 113 additions & 15 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ ${GOPATH}/bin/resources:
clean: ## Remove local snapshot binary directory
if [ -d ${BINARY} ] ; then rm -rf ${BINARY} ; fi
go clean -i ./...
rm -rf vendor/github.com/ethereumproject/sputnikvm-ffi/c/ffi/target
rm -f vendor/github.com/ethereumproject/sputnikvm-ffi/c/libsputnikvm.*

# Absolutely awesome: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (b *SimulatedBackend) ContractCall(contract common.Address, data []byte, pe
vmenv := core.NewEnv(statedb, core.DefaultConfigMorden.ChainConfig, b.blockchain, msg, block.Header())
gaspool := new(core.GasPool).AddGas(common.MaxBig)

out, _, err := core.ApplyMessage(vmenv, msg, gaspool)
out, _, _, err := core.ApplyMessage(vmenv, msg, gaspool)
return out, err
}

Expand Down
2 changes: 1 addition & 1 deletion common/registrar/ethreg/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (be *registryAPIBackend) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr
header := be.bc.CurrentBlock().Header()
vmenv := core.NewEnv(statedb, be.config, be.bc, msg, header)
gp := new(core.GasPool).AddGas(common.MaxBig)
res, gas, err := core.ApplyMessage(vmenv, msg, gp)
res, gas, _, err := core.ApplyMessage(vmenv, msg, gp)

return common.ToHex(res), gas.String(), err
}
Expand Down
5 changes: 5 additions & 0 deletions core/multivm_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ Loop:
receipt := types.NewReceipt(statedb.IntermediateRoot(false).Bytes(), totalUsedGas)
receipt.TxHash = tx.Hash()
receipt.GasUsed = new(big.Int).Set(totalUsedGas)
if vm.Failed() {
receipt.Status = types.TxFailure
} else {
receipt.Status = types.TxSuccess
}
if MessageCreatesContract(tx) {
receipt.ContractAddress = crypto.CreateAddress(from, tx.Nonce())
}
Expand Down
10 changes: 7 additions & 3 deletions core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
package core

import (
"math/big"

"errors"
"fmt"
"math/big"

"github.com/ethereumproject/go-ethereum/core/state"
"github.com/ethereumproject/go-ethereum/core/types"
Expand Down Expand Up @@ -114,7 +113,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB) (ty
func ApplyTransaction(config *ChainConfig, bc *BlockChain, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *big.Int) (*types.Receipt, vm.Logs, *big.Int, error) {
tx.SetSigner(config.GetSigner(header.Number))

_, gas, err := ApplyMessage(NewEnv(statedb, config, bc, tx, header), tx, gp)
_, gas, failed, err := ApplyMessage(NewEnv(statedb, config, bc, tx, header), tx, gp)
if err != nil {
return nil, nil, nil, err
}
Expand All @@ -132,6 +131,11 @@ func ApplyTransaction(config *ChainConfig, bc *BlockChain, gp *GasPool, statedb
logs := statedb.GetLogs(tx.Hash())
receipt.Logs = logs
receipt.Bloom = types.CreateBloom(types.Receipts{receipt})
if failed {
receipt.Status = types.TxFailure
} else {
receipt.Status = types.TxSuccess
}

glog.V(logger.Debug).Infoln(receipt)

Expand Down
Loading

0 comments on commit 382aa8f

Please sign in to comment.