aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-17 20:24:12 +0800
committerobscuren <geffobscura@gmail.com>2015-03-17 20:24:25 +0800
commit0fa7859b94ddb0a35a6fbdb2c29139b0baaa2bfa (patch)
tree9d4b05ed91f007c0831033c35f80dff691a4c7e7 /core
parentff55c6f5badda7ef11c38ef5d94b71420b14817c (diff)
downloadgo-tangerine-0fa7859b94ddb0a35a6fbdb2c29139b0baaa2bfa.tar.gz
go-tangerine-0fa7859b94ddb0a35a6fbdb2c29139b0baaa2bfa.tar.zst
go-tangerine-0fa7859b94ddb0a35a6fbdb2c29139b0baaa2bfa.zip
Fixed VM & Tests w/ conversion
Diffstat (limited to 'core')
-rw-r--r--core/state_transition.go19
-rw-r--r--core/vm_env.go4
2 files changed, 11 insertions, 12 deletions
diff --git a/core/state_transition.go b/core/state_transition.go
index 72999de7e..1509a5258 100644
--- a/core/state_transition.go
+++ b/core/state_transition.go
@@ -5,6 +5,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm"
)
@@ -195,9 +196,9 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
vmenv := self.env
var ref vm.ContextRef
if MessageCreatesContract(msg) {
- //contract := makeContract(msg, self.state)
- //addr := contract.Address()
- ret, err, ref = vmenv.Create(sender, self.msg.Data(), self.gas, self.gasPrice, self.value)
+ contract := makeContract(msg, self.state)
+ addr := contract.Address()
+ ret, err, ref = vmenv.Create(sender, &addr, self.msg.Data(), self.gas, self.gasPrice, self.value)
if err == nil {
dataGas := big.NewInt(int64(len(ret)))
dataGas.Mul(dataGas, vm.GasCreateByte)
@@ -243,13 +244,11 @@ func (self *StateTransition) gasUsed() *big.Int {
// Converts an message in to a state object
func makeContract(msg Message, state *state.StateDB) *state.StateObject {
- /*
- addr := AddressFromMessage(msg)
+ faddr, _ := msg.From()
+ addr := crypto.CreateAddress(faddr, msg.Nonce())
- contract := state.GetOrNewStateObject(addr)
- contract.SetInitCode(msg.Data())
+ contract := state.GetOrNewStateObject(addr)
+ contract.SetInitCode(msg.Data())
- return contract
- */
- return nil
+ return contract
}
diff --git a/core/vm_env.go b/core/vm_env.go
index 1ddbd5e5e..7845d1cd9 100644
--- a/core/vm_env.go
+++ b/core/vm_env.go
@@ -68,7 +68,7 @@ func (self *VMEnv) CallCode(me vm.ContextRef, addr common.Address, data []byte,
return exe.Call(addr, me)
}
-func (self *VMEnv) Create(me vm.ContextRef, data []byte, gas, price, value *big.Int) ([]byte, error, vm.ContextRef) {
- exe := self.vm(nil, data, gas, price, value)
+func (self *VMEnv) Create(me vm.ContextRef, addr *common.Address, data []byte, gas, price, value *big.Int) ([]byte, error, vm.ContextRef) {
+ exe := self.vm(addr, data, gas, price, value)
return exe.Create(me)
}