obscuren 10 years ago
commit 22d29a6d52
  1. 20
      cmd/mist/gui.go
  2. 6
      core/block_manager.go
  3. 145
      core/state_transition.go
  4. 21
      core/transaction_pool.go
  5. 94
      core/types/transaction.go
  6. 10
      core/vm_env.go
  7. 6
      miner/miner.go
  8. 35
      state/state.go
  9. 870
      tests/files/StateTests/stInitCodeTest.json
  10. 523
      tests/files/StateTests/stRefundTest.json
  11. 2
      tests/files/StateTests/stSystemOperationsTest.json
  12. 277
      tests/files/StateTests/stTransactionTest.json
  13. 294
      tests/files/VMTests/vmArithmeticTest.json
  14. 7
      tests/files/index.js
  15. 37
      tests/helper/vm.go
  16. 22
      tests/vm/gh_test.go
  17. 2
      vm/common.go
  18. 27
      vm/vm_debug.go
  19. 4
      xeth/hexface.go
  20. 14
      xeth/js_types.go
  21. 8
      xeth/pipe.go

@ -309,13 +309,13 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
var ( var (
ptx = xeth.NewJSTx(tx, pipe.World().State()) ptx = xeth.NewJSTx(tx, pipe.World().State())
send = nameReg.Storage(tx.Sender()) send = nameReg.Storage(tx.From())
rec = nameReg.Storage(tx.Recipient) rec = nameReg.Storage(tx.To())
s, r string s, r string
) )
if tx.CreatesContract() { if core.MessageCreatesContract(tx) {
rec = nameReg.Storage(tx.CreationAddress(pipe.World().State())) rec = nameReg.Storage(core.AddressFromMessage(tx))
} }
if send.Len() != 0 { if send.Len() != 0 {
@ -326,10 +326,10 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
if rec.Len() != 0 { if rec.Len() != 0 {
r = strings.Trim(rec.Str(), "\x00") r = strings.Trim(rec.Str(), "\x00")
} else { } else {
if tx.CreatesContract() { if core.MessageCreatesContract(tx) {
r = ethutil.Bytes2Hex(tx.CreationAddress(pipe.World().State())) r = ethutil.Bytes2Hex(core.AddressFromMessage(tx))
} else { } else {
r = ethutil.Bytes2Hex(tx.Recipient) r = ethutil.Bytes2Hex(tx.To())
} }
} }
ptx.Sender = s ptx.Sender = s
@ -454,11 +454,11 @@ func (gui *Gui) update() {
object := state.GetAccount(gui.address()) object := state.GetAccount(gui.address())
if bytes.Compare(tx.Sender(), gui.address()) == 0 { if bytes.Compare(tx.Sender(), gui.address()) == 0 {
object.SubAmount(tx.Value) object.SubAmount(tx.Value())
gui.txDb.Put(tx.Hash(), tx.RlpEncode()) gui.txDb.Put(tx.Hash(), tx.RlpEncode())
} else if bytes.Compare(tx.Recipient, gui.address()) == 0 { } else if bytes.Compare(tx.To(), gui.address()) == 0 {
object.AddAmount(tx.Value) object.AddAmount(tx.Value())
gui.txDb.Put(tx.Hash(), tx.RlpEncode()) gui.txDb.Put(tx.Hash(), tx.RlpEncode())
} }

@ -109,11 +109,11 @@ done:
// If we are mining this block and validating we want to set the logs back to 0 // If we are mining this block and validating we want to set the logs back to 0
state.EmptyLogs() state.EmptyLogs()
txGas := new(big.Int).Set(tx.Gas) txGas := new(big.Int).Set(tx.Gas())
cb := state.GetStateObject(coinbase.Address()) cb := state.GetStateObject(coinbase.Address())
st := NewStateTransition(cb, tx, state, block) st := NewStateTransition(cb, tx, state, block)
err = st.TransitionState() _, err = st.TransitionState()
if err != nil { if err != nil {
switch { switch {
case IsNonceErr(err): case IsNonceErr(err):
@ -132,7 +132,7 @@ done:
} }
txGas.Sub(txGas, st.gas) txGas.Sub(txGas, st.gas)
cumulativeSum.Add(cumulativeSum, new(big.Int).Mul(txGas, tx.GasPrice)) cumulativeSum.Add(cumulativeSum, new(big.Int).Mul(txGas, tx.GasPrice()))
// Update the state with pending changes // Update the state with pending changes
state.Update(txGas) state.Update(txGas)

@ -5,6 +5,8 @@ import (
"math/big" "math/big"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm" "github.com/ethereum/go-ethereum/vm"
) )
@ -27,48 +29,69 @@ import (
*/ */
type StateTransition struct { type StateTransition struct {
coinbase, receiver []byte coinbase, receiver []byte
tx *types.Transaction msg Message
gas, gasPrice *big.Int gas, gasPrice *big.Int
initialGas *big.Int
value *big.Int value *big.Int
data []byte data []byte
state *state.StateDB state *state.StateDB
block *types.Block block *types.Block
cb, rec, sen *state.StateObject cb, rec, sen *state.StateObject
Env vm.Environment
} }
func NewStateTransition(coinbase *state.StateObject, tx *types.Transaction, state *state.StateDB, block *types.Block) *StateTransition { type Message interface {
return &StateTransition{coinbase.Address(), tx.Recipient, tx, new(big.Int), new(big.Int).Set(tx.GasPrice), tx.Value, tx.Data, state, block, coinbase, nil, nil} Hash() []byte
From() []byte
To() []byte
GasPrice() *big.Int
Gas() *big.Int
Value() *big.Int
Nonce() uint64
Data() []byte
} }
func (self *StateTransition) Coinbase() *state.StateObject { func AddressFromMessage(msg Message) []byte {
if self.cb != nil { // Generate a new address
return self.cb return crypto.Sha3(ethutil.NewValue([]interface{}{msg.From(), msg.Nonce()}).Encode())[12:]
} }
self.cb = self.state.GetOrNewStateObject(self.coinbase) func MessageCreatesContract(msg Message) bool {
return self.cb return len(msg.To()) == 0
} }
func (self *StateTransition) Sender() *state.StateObject {
if self.sen != nil {
return self.sen
}
self.sen = self.state.GetOrNewStateObject(self.tx.Sender()) func MessageGasValue(msg Message) *big.Int {
return new(big.Int).Mul(msg.Gas(), msg.GasPrice())
}
return self.sen func NewStateTransition(coinbase *state.StateObject, msg Message, state *state.StateDB, block *types.Block) *StateTransition {
return &StateTransition{coinbase.Address(), msg.To(), msg, new(big.Int), new(big.Int).Set(msg.GasPrice()), new(big.Int), msg.Value(), msg.Data(), state, block, coinbase, nil, nil, nil}
} }
func (self *StateTransition) Receiver() *state.StateObject {
if self.tx != nil && self.tx.CreatesContract() {
return nil
}
if self.rec != nil { func (self *StateTransition) VmEnv() vm.Environment {
return self.rec if self.Env == nil {
self.Env = NewEnv(self.state, self.msg, self.block)
} }
self.rec = self.state.GetOrNewStateObject(self.tx.Recipient) return self.Env
return self.rec }
func (self *StateTransition) Coinbase() *state.StateObject {
return self.state.GetOrNewStateObject(self.coinbase)
}
func (self *StateTransition) From() *state.StateObject {
return self.state.GetOrNewStateObject(self.msg.From())
}
func (self *StateTransition) To() *state.StateObject {
if self.msg != nil && MessageCreatesContract(self.msg) {
return nil
}
return self.state.GetOrNewStateObject(self.msg.To())
} }
func (self *StateTransition) UseGas(amount *big.Int) error { func (self *StateTransition) UseGas(amount *big.Int) error {
@ -87,41 +110,33 @@ func (self *StateTransition) AddGas(amount *big.Int) {
func (self *StateTransition) BuyGas() error { func (self *StateTransition) BuyGas() error {
var err error var err error
sender := self.Sender() sender := self.From()
if sender.Balance().Cmp(self.tx.GasValue()) < 0 { if sender.Balance().Cmp(MessageGasValue(self.msg)) < 0 {
return fmt.Errorf("Insufficient funds to pre-pay gas. Req %v, has %v", self.tx.GasValue(), sender.Balance()) return fmt.Errorf("Insufficient funds to pre-pay gas. Req %v, has %v", MessageGasValue(self.msg), sender.Balance())
} }
coinbase := self.Coinbase() coinbase := self.Coinbase()
err = coinbase.BuyGas(self.tx.Gas, self.tx.GasPrice) err = coinbase.BuyGas(self.msg.Gas(), self.msg.GasPrice())
if err != nil { if err != nil {
return err return err
} }
self.AddGas(self.tx.Gas) self.AddGas(self.msg.Gas())
sender.SubAmount(self.tx.GasValue()) self.initialGas.Set(self.msg.Gas())
sender.SubAmount(MessageGasValue(self.msg))
return nil return nil
} }
func (self *StateTransition) RefundGas() {
coinbase, sender := self.Coinbase(), self.Sender()
coinbase.RefundGas(self.gas, self.tx.GasPrice)
// Return remaining gas
remaining := new(big.Int).Mul(self.gas, self.tx.GasPrice)
sender.AddAmount(remaining)
}
func (self *StateTransition) preCheck() (err error) { func (self *StateTransition) preCheck() (err error) {
var ( var (
tx = self.tx msg = self.msg
sender = self.Sender() sender = self.From()
) )
// Make sure this transaction's nonce is correct // Make sure this transaction's nonce is correct
if sender.Nonce != tx.Nonce { if sender.Nonce != msg.Nonce() {
return NonceError(tx.Nonce, sender.Nonce) return NonceError(msg.Nonce(), sender.Nonce)
} }
// Pre-pay gas / Buy gas of the coinbase account // Pre-pay gas / Buy gas of the coinbase account
@ -132,8 +147,8 @@ func (self *StateTransition) preCheck() (err error) {
return nil return nil
} }
func (self *StateTransition) TransitionState() (err error) { func (self *StateTransition) TransitionState() (ret []byte, err error) {
statelogger.Debugf("(~) %x\n", self.tx.Hash()) statelogger.Debugf("(~) %x\n", self.msg.Hash())
// XXX Transactions after this point are considered valid. // XXX Transactions after this point are considered valid.
if err = self.preCheck(); err != nil { if err = self.preCheck(); err != nil {
@ -141,8 +156,8 @@ func (self *StateTransition) TransitionState() (err error) {
} }
var ( var (
tx = self.tx msg = self.msg
sender = self.Sender() sender = self.From()
) )
defer self.RefundGas() defer self.RefundGas()
@ -168,16 +183,15 @@ func (self *StateTransition) TransitionState() (err error) {
return return
} }
var ret []byte vmenv := self.VmEnv()
vmenv := NewEnv(self.state, self.tx, self.block)
var ref vm.ClosureRef var ref vm.ClosureRef
if tx.CreatesContract() { if MessageCreatesContract(msg) {
self.rec = MakeContract(tx, self.state) self.rec = MakeContract(msg, self.state)
ret, err, ref = vmenv.Create(sender, self.rec.Address(), self.tx.Data, self.gas, self.gasPrice, self.value) ret, err, ref = vmenv.Create(sender, self.rec.Address(), self.msg.Data(), self.gas, self.gasPrice, self.value)
ref.SetCode(ret) ref.SetCode(ret)
} else { } else {
ret, err = vmenv.Call(self.Sender(), self.Receiver().Address(), self.tx.Data, self.gas, self.gasPrice, self.value) ret, err = vmenv.Call(self.From(), self.To().Address(), self.msg.Data(), self.gas, self.gasPrice, self.value)
} }
if err != nil { if err != nil {
statelogger.Debugln(err) statelogger.Debugln(err)
@ -187,11 +201,32 @@ func (self *StateTransition) TransitionState() (err error) {
} }
// Converts an transaction in to a state object // Converts an transaction in to a state object
func MakeContract(tx *types.Transaction, state *state.StateDB) *state.StateObject { func MakeContract(msg Message, state *state.StateDB) *state.StateObject {
addr := tx.CreationAddress(state) addr := AddressFromMessage(msg)
contract := state.GetOrNewStateObject(addr) contract := state.GetOrNewStateObject(addr)
contract.InitCode = tx.Data contract.InitCode = msg.Data()
return contract return contract
} }
func (self *StateTransition) RefundGas() {
coinbaseSub := new(big.Int).Set(self.gas)
uhalf := new(big.Int).Div(self.GasUsed(), ethutil.Big2)
for addr, ref := range self.state.Refunds() {
refund := ethutil.BigMin(uhalf, ref)
coinbaseSub.Add(self.gas, refund)
self.state.AddBalance([]byte(addr), refund.Mul(refund, self.msg.GasPrice()))
}
coinbase, sender := self.Coinbase(), self.From()
coinbase.RefundGas(coinbaseSub, self.msg.GasPrice())
// Return remaining gas
remaining := new(big.Int).Mul(self.gas, self.msg.GasPrice())
sender.AddAmount(remaining)
}
func (self *StateTransition) GasUsed() *big.Int {
return new(big.Int).Sub(self.initialGas, self.gas)
}

@ -106,8 +106,8 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
return fmt.Errorf("No last block on the block chain") return fmt.Errorf("No last block on the block chain")
} }
if len(tx.Recipient) != 0 && len(tx.Recipient) != 20 { if len(tx.To()) != 0 && len(tx.To()) != 20 {
return fmt.Errorf("Invalid recipient. len = %d", len(tx.Recipient)) return fmt.Errorf("Invalid recipient. len = %d", len(tx.To()))
} }
v, _, _ := tx.Curve() v, _, _ := tx.Curve()
@ -118,17 +118,11 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
// Get the sender // Get the sender
sender := pool.chainManager.State().GetAccount(tx.Sender()) sender := pool.chainManager.State().GetAccount(tx.Sender())
totAmount := new(big.Int).Set(tx.Value) totAmount := new(big.Int).Set(tx.Value())
// Make sure there's enough in the sender's account. Having insufficient // Make sure there's enough in the sender's account. Having insufficient
// funds won't invalidate this transaction but simple ignores it. // funds won't invalidate this transaction but simple ignores it.
if sender.Balance().Cmp(totAmount) < 0 { if sender.Balance().Cmp(totAmount) < 0 {
return fmt.Errorf("Insufficient amount in sender's (%x) account", tx.Sender()) return fmt.Errorf("Insufficient amount in sender's (%x) account", tx.From())
}
if tx.IsContract() {
if tx.GasPrice.Cmp(big.NewInt(minGasPrice)) < 0 {
return fmt.Errorf("Gasprice too low, %s given should be at least %d.", tx.GasPrice, minGasPrice)
}
} }
// Increment the nonce making each tx valid only once to prevent replay // Increment the nonce making each tx valid only once to prevent replay
@ -154,10 +148,7 @@ func (self *TxPool) Add(tx *types.Transaction) error {
self.addTransaction(tx) self.addTransaction(tx)
tmp := make([]byte, 4) txplogger.Debugf("(t) %x => %x (%v) %x\n", tx.From()[:4], tx.To()[:4], tx.Value, tx.Hash())
copy(tmp, tx.Recipient)
txplogger.Debugf("(t) %x => %x (%v) %x\n", tx.Sender()[:4], tmp, tx.Value, tx.Hash())
// Notify the subscribers // Notify the subscribers
go self.eventMux.Post(TxPreEvent{tx}) go self.eventMux.Post(TxPreEvent{tx})
@ -204,7 +195,7 @@ func (pool *TxPool) RemoveInvalid(state *state.StateDB) {
tx := e.Value.(*types.Transaction) tx := e.Value.(*types.Transaction)
sender := state.GetAccount(tx.Sender()) sender := state.GetAccount(tx.Sender())
err := pool.ValidateTransaction(tx) err := pool.ValidateTransaction(tx)
if err != nil || sender.Nonce >= tx.Nonce { if err != nil || sender.Nonce >= tx.Nonce() {
pool.pool.Remove(e) pool.pool.Remove(e)
} }
} }

@ -6,37 +6,30 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state"
"github.com/obscuren/secp256k1-go" "github.com/obscuren/secp256k1-go"
) )
var ContractAddr = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
func IsContractAddr(addr []byte) bool { func IsContractAddr(addr []byte) bool {
return len(addr) == 0 return len(addr) == 0
//return bytes.Compare(addr, ContractAddr) == 0
} }
type Transaction struct { type Transaction struct {
Nonce uint64 nonce uint64
Recipient []byte recipient []byte
Value *big.Int value *big.Int
Gas *big.Int gas *big.Int
GasPrice *big.Int gasPrice *big.Int
Data []byte data []byte
v byte v byte
r, s []byte r, s []byte
// Indicates whether this tx is a contract creation transaction
contractCreation bool
} }
func NewContractCreationTx(value, gas, gasPrice *big.Int, script []byte) *Transaction { func NewContractCreationTx(value, gas, gasPrice *big.Int, script []byte) *Transaction {
return &Transaction{Recipient: nil, Value: value, Gas: gas, GasPrice: gasPrice, Data: script, contractCreation: true} return &Transaction{recipient: nil, value: value, gas: gas, gasPrice: gasPrice, data: script}
} }
func NewTransactionMessage(to []byte, value, gas, gasPrice *big.Int, data []byte) *Transaction { func NewTransactionMessage(to []byte, value, gas, gasPrice *big.Int, data []byte) *Transaction {
return &Transaction{Recipient: to, Value: value, GasPrice: gasPrice, Gas: gas, Data: data, contractCreation: IsContractAddr(to)} return &Transaction{recipient: to, value: value, gasPrice: gasPrice, gas: gas, data: data}
} }
func NewTransactionFromBytes(data []byte) *Transaction { func NewTransactionFromBytes(data []byte) *Transaction {
@ -53,33 +46,42 @@ func NewTransactionFromValue(val *ethutil.Value) *Transaction {
return tx return tx
} }
func (self *Transaction) GasValue() *big.Int { func (tx *Transaction) Hash() []byte {
return new(big.Int).Mul(self.Gas, self.GasPrice) data := []interface{}{tx.Nonce, tx.gasPrice, tx.gas, tx.recipient, tx.Value, tx.Data}
return crypto.Sha3(ethutil.NewValue(data).Encode())
} }
func (self *Transaction) TotalValue() *big.Int { func (self *Transaction) Data() []byte {
v := self.GasValue() return self.data
return v.Add(v, self.Value)
} }
func (tx *Transaction) Hash() []byte { func (self *Transaction) Gas() *big.Int {
data := []interface{}{tx.Nonce, tx.GasPrice, tx.Gas, tx.Recipient, tx.Value, tx.Data} return self.gas
}
return crypto.Sha3(ethutil.NewValue(data).Encode()) func (self *Transaction) GasPrice() *big.Int {
return self.gasPrice
}
func (self *Transaction) Value() *big.Int {
return self.value
} }
func (tx *Transaction) CreatesContract() bool { func (self *Transaction) Nonce() uint64 {
return tx.contractCreation return self.nonce
} }
/* Deprecated */ func (self *Transaction) SetNonce(nonce uint64) {
func (tx *Transaction) IsContract() bool { self.nonce = nonce
return tx.CreatesContract()
} }
func (tx *Transaction) CreationAddress(state *state.StateDB) []byte { func (self *Transaction) From() []byte {
// Generate a new address return self.Sender()
return crypto.Sha3(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce}).Encode())[12:] }
func (self *Transaction) To() []byte {
return self.recipient
} }
func (tx *Transaction) Curve() (v byte, r []byte, s []byte) { func (tx *Transaction) Curve() (v byte, r []byte, s []byte) {
@ -136,7 +138,7 @@ func (tx *Transaction) Sign(privk []byte) error {
} }
func (tx *Transaction) RlpData() interface{} { func (tx *Transaction) RlpData() interface{} {
data := []interface{}{tx.Nonce, tx.GasPrice, tx.Gas, tx.Recipient, tx.Value, tx.Data} data := []interface{}{tx.Nonce, tx.GasPrice, tx.Gas, tx.recipient, tx.Value, tx.Data}
// TODO Remove prefixing zero's // TODO Remove prefixing zero's
@ -156,20 +158,16 @@ func (tx *Transaction) RlpDecode(data []byte) {
} }
func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value) { func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value) {
tx.Nonce = decoder.Get(0).Uint() tx.nonce = decoder.Get(0).Uint()
tx.GasPrice = decoder.Get(1).BigInt() tx.gasPrice = decoder.Get(1).BigInt()
tx.Gas = decoder.Get(2).BigInt() tx.gas = decoder.Get(2).BigInt()
tx.Recipient = decoder.Get(3).Bytes() tx.recipient = decoder.Get(3).Bytes()
tx.Value = decoder.Get(4).BigInt() tx.value = decoder.Get(4).BigInt()
tx.Data = decoder.Get(5).Bytes() tx.data = decoder.Get(5).Bytes()
tx.v = byte(decoder.Get(6).Uint()) tx.v = byte(decoder.Get(6).Uint())
tx.r = decoder.Get(7).Bytes() tx.r = decoder.Get(7).Bytes()
tx.s = decoder.Get(8).Bytes() tx.s = decoder.Get(8).Bytes()
if IsContractAddr(tx.Recipient) {
tx.contractCreation = true
}
} }
func (tx *Transaction) String() string { func (tx *Transaction) String() string {
@ -188,12 +186,12 @@ func (tx *Transaction) String() string {
S: 0x%x S: 0x%x
`, `,
tx.Hash(), tx.Hash(),
len(tx.Recipient) == 0, len(tx.recipient) == 0,
tx.Sender(), tx.Sender(),
tx.Recipient, tx.recipient,
tx.Nonce, tx.nonce,
tx.GasPrice, tx.gasPrice,
tx.Gas, tx.gas,
tx.Value, tx.Value,
tx.Data, tx.Data,
tx.v, tx.v,
@ -221,5 +219,5 @@ func (s Transactions) GetRlp(i int) []byte { return ethutil.Rlp(s[i]) }
type TxByNonce struct{ Transactions } type TxByNonce struct{ Transactions }
func (s TxByNonce) Less(i, j int) bool { func (s TxByNonce) Less(i, j int) bool {
return s.Transactions[i].Nonce < s.Transactions[j].Nonce return s.Transactions[i].nonce < s.Transactions[j].nonce
} }

@ -11,26 +11,26 @@ import (
type VMEnv struct { type VMEnv struct {
state *state.StateDB state *state.StateDB
block *types.Block block *types.Block
tx *types.Transaction msg Message
depth int depth int
} }
func NewEnv(state *state.StateDB, tx *types.Transaction, block *types.Block) *VMEnv { func NewEnv(state *state.StateDB, msg Message, block *types.Block) *VMEnv {
return &VMEnv{ return &VMEnv{
state: state, state: state,
block: block, block: block,
tx: tx, msg: msg,
} }
} }
func (self *VMEnv) Origin() []byte { return self.tx.Sender() } func (self *VMEnv) Origin() []byte { return self.msg.From() }
func (self *VMEnv) BlockNumber() *big.Int { return self.block.Number } func (self *VMEnv) BlockNumber() *big.Int { return self.block.Number }
func (self *VMEnv) PrevHash() []byte { return self.block.PrevHash } func (self *VMEnv) PrevHash() []byte { return self.block.PrevHash }
func (self *VMEnv) Coinbase() []byte { return self.block.Coinbase } func (self *VMEnv) Coinbase() []byte { return self.block.Coinbase }
func (self *VMEnv) Time() int64 { return self.block.Time } func (self *VMEnv) Time() int64 { return self.block.Time }
func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty } func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty }
func (self *VMEnv) BlockHash() []byte { return self.block.Hash() } func (self *VMEnv) BlockHash() []byte { return self.block.Hash() }
func (self *VMEnv) Value() *big.Int { return self.tx.Value } func (self *VMEnv) Value() *big.Int { return self.msg.Value() }
func (self *VMEnv) State() *state.StateDB { return self.state } func (self *VMEnv) State() *state.StateDB { return self.state }
func (self *VMEnv) GasLimit() *big.Int { return self.block.GasLimit } func (self *VMEnv) GasLimit() *big.Int { return self.block.GasLimit }
func (self *VMEnv) Depth() int { return self.depth } func (self *VMEnv) Depth() int { return self.depth }

@ -236,8 +236,8 @@ func (self *Miner) finiliseTxs() types.Transactions {
key := self.eth.KeyManager() key := self.eth.KeyManager()
for i, ltx := range self.localTxs { for i, ltx := range self.localTxs {
tx := types.NewTransactionMessage(ltx.To, ethutil.Big(ltx.Value), ethutil.Big(ltx.Gas), ethutil.Big(ltx.GasPrice), ltx.Data) tx := types.NewTransactionMessage(ltx.To, ethutil.Big(ltx.Value), ethutil.Big(ltx.Gas), ethutil.Big(ltx.GasPrice), ltx.Data)
tx.Nonce = state.GetNonce(self.Coinbase) tx.SetNonce(state.GetNonce(self.Coinbase))
state.SetNonce(self.Coinbase, tx.Nonce+1) state.SetNonce(self.Coinbase, tx.Nonce()+1)
tx.Sign(key.PrivateKey()) tx.Sign(key.PrivateKey())
@ -246,7 +246,7 @@ func (self *Miner) finiliseTxs() types.Transactions {
// Faster than append // Faster than append
for _, tx := range self.eth.TxPool().GetTransactions() { for _, tx := range self.eth.TxPool().GetTransactions() {
if tx.GasPrice.Cmp(self.MinAcceptedGasPrice) >= 0 { if tx.GasPrice().Cmp(self.MinAcceptedGasPrice) >= 0 {
txs[actualSize] = tx txs[actualSize] = tx
actualSize++ actualSize++
} }

@ -23,14 +23,14 @@ type StateDB struct {
manifest *Manifest manifest *Manifest
refund map[string][]refund refund map[string]*big.Int
logs Logs logs Logs
} }
// Create a new state from a given trie // Create a new state from a given trie
func New(trie *trie.Trie) *StateDB { func New(trie *trie.Trie) *StateDB {
return &StateDB{Trie: trie, stateObjects: make(map[string]*StateObject), manifest: NewManifest(), refund: make(map[string][]refund)} return &StateDB{Trie: trie, stateObjects: make(map[string]*StateObject), manifest: NewManifest(), refund: make(map[string]*big.Int)}
} }
func (self *StateDB) EmptyLogs() { func (self *StateDB) EmptyLogs() {
@ -55,12 +55,11 @@ func (self *StateDB) GetBalance(addr []byte) *big.Int {
return ethutil.Big0 return ethutil.Big0
} }
type refund struct { func (self *StateDB) Refund(addr []byte, gas *big.Int) {
gas, price *big.Int if self.refund[string(addr)] == nil {
} self.refund[string(addr)] = new(big.Int)
}
func (self *StateDB) Refund(addr []byte, gas, price *big.Int) { self.refund[string(addr)].Add(self.refund[string(addr)], gas)
self.refund[string(addr)] = append(self.refund[string(addr)], refund{gas, price})
} }
func (self *StateDB) AddBalance(addr []byte, amount *big.Int) { func (self *StateDB) AddBalance(addr []byte, amount *big.Int) {
@ -211,7 +210,7 @@ func (self *StateDB) Copy() *StateDB {
} }
for addr, refund := range self.refund { for addr, refund := range self.refund {
state.refund[addr] = refund state.refund[addr] = new(big.Int).Set(refund)
} }
logs := make(Logs, len(self.logs)) logs := make(Logs, len(self.logs))
@ -273,23 +272,17 @@ func (s *StateDB) Sync() {
func (self *StateDB) Empty() { func (self *StateDB) Empty() {
self.stateObjects = make(map[string]*StateObject) self.stateObjects = make(map[string]*StateObject)
self.refund = make(map[string][]refund) self.refund = make(map[string]*big.Int)
}
func (self *StateDB) Refunds() map[string]*big.Int {
return self.refund
} }
func (self *StateDB) Update(gasUsed *big.Int) { func (self *StateDB) Update(gasUsed *big.Int) {
var deleted bool var deleted bool
// Refund any gas that's left self.refund = make(map[string]*big.Int)
// XXX THIS WILL CHANGE IN POC8
uhalf := new(big.Int).Div(gasUsed, ethutil.Big2)
for addr, refs := range self.refund {
for _, ref := range refs {
refund := ethutil.BigMin(uhalf, ref.gas)
self.GetStateObject([]byte(addr)).AddBalance(refund.Mul(refund, ref.price))
}
}
self.refund = make(map[string][]refund)
for _, stateObject := range self.stateObjects { for _, stateObject := range self.stateObjects {
if stateObject.remove { if stateObject.remove {

@ -0,0 +1,870 @@
{
"CallRecursiveContract" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"04110d816c380812a427968ece99b1c963dfbce6" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x04110d816c380812a427968ece99b1c963dfbce6"
}
},
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1",
"code" : "0x3060025560206000600039602060006000f0",
"nonce" : "1",
"storage" : {
"0x02" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87"
}
},
"0a517d755cebbf66312b30fff713666a9cb917e0" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x0a517d755cebbf66312b30fff713666a9cb917e0"
}
},
"24dd378f51adc67a50e339e8031fe9bd4aafab36" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x24dd378f51adc67a50e339e8031fe9bd4aafab36"
}
},
"293f982d000532a7861ab122bdc4bbfd26bf9030" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x293f982d000532a7861ab122bdc4bbfd26bf9030"
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "10000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"2cf5732f017b0cf1b1f13a1478e10239716bf6b5" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x2cf5732f017b0cf1b1f13a1478e10239716bf6b5"
}
},
"31c640b92c21a1f1465c91070b4b3b4d6854195f" : {
"balance" : "0",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"37f998764813b136ddf5a754f34063fd03065e36" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x37f998764813b136ddf5a754f34063fd03065e36"
}
},
"37fa399a749c121f8a15ce77e3d9f9bec8020d7a" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x37fa399a749c121f8a15ce77e3d9f9bec8020d7a"
}
},
"4f36659fa632310b6ec438dea4085b522a2dd077" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x4f36659fa632310b6ec438dea4085b522a2dd077"
}
},
"62c01474f089b07dae603491675dc5b5748f7049" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x62c01474f089b07dae603491675dc5b5748f7049"
}
},
"729af7294be595a0efd7d891c9e51f89c07950c7" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x729af7294be595a0efd7d891c9e51f89c07950c7"
}
},
"83e3e5a16d3b696a0314b30b2534804dd5e11197" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x83e3e5a16d3b696a0314b30b2534804dd5e11197"
}
},
"8703df2417e0d7c59d063caa9583cb10a4d20532" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x8703df2417e0d7c59d063caa9583cb10a4d20532"
}
},
"8dffcd74e5b5923512916c6a64b502689cfa65e1" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x8dffcd74e5b5923512916c6a64b502689cfa65e1"
}
},
"95a4d7cccb5204733874fa87285a176fe1e9e240" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x95a4d7cccb5204733874fa87285a176fe1e9e240"
}
},
"99b2fcba8120bedd048fe79f5262a6690ed38c39" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x99b2fcba8120bedd048fe79f5262a6690ed38c39"
}
},
"a4202b8b8afd5354e3e40a219bdc17f6001bf2cf" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xa4202b8b8afd5354e3e40a219bdc17f6001bf2cf"
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "89999",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
},
"a9647f4a0a14042d91dc33c0328030a7157c93ae" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xa9647f4a0a14042d91dc33c0328030a7157c93ae"
}
},
"aa6cffe5185732689c18f37a7f86170cb7304c2a" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xaa6cffe5185732689c18f37a7f86170cb7304c2a"
}
},
"aae4a2e3c51c04606dcb3723456e58f3ed214f45" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xaae4a2e3c51c04606dcb3723456e58f3ed214f45"
}
},
"c37a43e940dfb5baf581a0b82b351d48305fc885" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xc37a43e940dfb5baf581a0b82b351d48305fc885"
}
},
"d2571607e241ecf590ed94b12d87c94babe36db6" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xd2571607e241ecf590ed94b12d87c94babe36db6"
}
},
"f735071cbee190d76b704ce68384fc21e389fbe7" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xf735071cbee190d76b704ce68384fc21e389fbe7"
}
}
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0",
"code" : "0x3060025560206000600039602060006000f0",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x00",
"gasLimit" : "10000",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "1"
}
},
"CallTheContractToCreateContractWithInitCode" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"04110d816c380812a427968ece99b1c963dfbce6" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x04110d816c380812a427968ece99b1c963dfbce6"
}
},
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "10001",
"code" : "0x3060025560206000600039602060006000f0",
"nonce" : "1",
"storage" : {
"0x02" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87"
}
},
"0a517d755cebbf66312b30fff713666a9cb917e0" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x0a517d755cebbf66312b30fff713666a9cb917e0"
}
},
"24dd378f51adc67a50e339e8031fe9bd4aafab36" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x24dd378f51adc67a50e339e8031fe9bd4aafab36"
}
},
"293f982d000532a7861ab122bdc4bbfd26bf9030" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x293f982d000532a7861ab122bdc4bbfd26bf9030"
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "10000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"2cf5732f017b0cf1b1f13a1478e10239716bf6b5" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x2cf5732f017b0cf1b1f13a1478e10239716bf6b5"
}
},
"31c640b92c21a1f1465c91070b4b3b4d6854195f" : {
"balance" : "0",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"37f998764813b136ddf5a754f34063fd03065e36" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x37f998764813b136ddf5a754f34063fd03065e36"
}
},
"37fa399a749c121f8a15ce77e3d9f9bec8020d7a" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x37fa399a749c121f8a15ce77e3d9f9bec8020d7a"
}
},
"4f36659fa632310b6ec438dea4085b522a2dd077" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x4f36659fa632310b6ec438dea4085b522a2dd077"
}
},
"62c01474f089b07dae603491675dc5b5748f7049" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x62c01474f089b07dae603491675dc5b5748f7049"
}
},
"729af7294be595a0efd7d891c9e51f89c07950c7" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x729af7294be595a0efd7d891c9e51f89c07950c7"
}
},
"83e3e5a16d3b696a0314b30b2534804dd5e11197" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x83e3e5a16d3b696a0314b30b2534804dd5e11197"
}
},
"8703df2417e0d7c59d063caa9583cb10a4d20532" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x8703df2417e0d7c59d063caa9583cb10a4d20532"
}
},
"8dffcd74e5b5923512916c6a64b502689cfa65e1" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x8dffcd74e5b5923512916c6a64b502689cfa65e1"
}
},
"95a4d7cccb5204733874fa87285a176fe1e9e240" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x95a4d7cccb5204733874fa87285a176fe1e9e240"
}
},
"99b2fcba8120bedd048fe79f5262a6690ed38c39" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0x99b2fcba8120bedd048fe79f5262a6690ed38c39"
}
},
"a4202b8b8afd5354e3e40a219bdc17f6001bf2cf" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xa4202b8b8afd5354e3e40a219bdc17f6001bf2cf"
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "89999",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
},
"a9647f4a0a14042d91dc33c0328030a7157c93ae" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xa9647f4a0a14042d91dc33c0328030a7157c93ae"
}
},
"aa6cffe5185732689c18f37a7f86170cb7304c2a" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xaa6cffe5185732689c18f37a7f86170cb7304c2a"
}
},
"aae4a2e3c51c04606dcb3723456e58f3ed214f45" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xaae4a2e3c51c04606dcb3723456e58f3ed214f45"
}
},
"c37a43e940dfb5baf581a0b82b351d48305fc885" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xc37a43e940dfb5baf581a0b82b351d48305fc885"
}
},
"d2571607e241ecf590ed94b12d87c94babe36db6" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xd2571607e241ecf590ed94b12d87c94babe36db6"
}
},
"f735071cbee190d76b704ce68384fc21e389fbe7" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
"0x02" : "0xf735071cbee190d76b704ce68384fc21e389fbe7"
}
}
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "10000",
"code" : "0x3060025560206000600039602060006000f0",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x00",
"gasLimit" : "10000",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "1"
}
},
"CallTheContractToCreateEmptyContract" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1",
"code" : "0x602060006000f0",
"nonce" : "1",
"storage" : {
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "605",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "99394",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
},
"d2571607e241ecf590ed94b12d87c94babe36db6" : {
"balance" : "0",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0",
"code" : "0x602060006000f0",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x00",
"gasLimit" : "10000",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "1"
}
},
"NotEnoughCashContractCreation" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "2",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "2",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x600a80600c6000396000f200600160008035811a8100",
"gasLimit" : "599",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "",
"value" : "1"
}
},
"OutOfGasContractCreation" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "1770",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"6295ee1b4f6dd65047762f924ecd367c17eabf8f" : {
"balance" : "1",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "8229",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x600a80600c6000396000f200600160008035811a8100",
"gasLimit" : "590",
"gasPrice" : "3",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "",
"value" : "1"
}
},
"TransactionContractCreation" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "599",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"6295ee1b4f6dd65047762f924ecd367c17eabf8f" : {
"balance" : "1",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "99400",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x600a80600c6000396000f200600160008035811a8100",
"gasLimit" : "599",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "",
"value" : "1"
}
},
"TransactionCreateSuicideContract" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "1000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"6295ee1b4f6dd65047762f924ecd367c17eabf8f" : {
"balance" : "1",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "8999",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x600a80600c6000396000f200ff600160008035811a81",
"gasLimit" : "1000",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "",
"value" : "1"
}
},
"TransactionStopInitCode" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "599",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"6295ee1b4f6dd65047762f924ecd367c17eabf8f" : {
"balance" : "1",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "9400",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x600a80600c600039600000f20000600160008035811a81",
"gasLimit" : "1000",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "",
"value" : "1"
}
},
"TransactionSuicideInitCode" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"0000000000000000000000000000000000000000" : {
"balance" : "1",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "611",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "9388",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x600a80600c6000396000fff2ffff600160008035811a81",
"gasLimit" : "1000",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "",
"value" : "1"
}
}
}

@ -0,0 +1,523 @@
{
"refund500" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x600154506002545060ff60020a600a553031600b55600060015560006002556000600355600060045560006005556000600655",
"nonce" : "0",
"storage" : {
"0x0a" : "0x8000000000000000000000000000000000000000000000000000000000000000",
"0x0b" : "0x0de0b6b3a7640000"
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "592",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "9408",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x600154506002545060ff60020a600a553031600b55600060015560006002556000600355600060045560006005556000600655",
"nonce" : "0",
"storage" : {
"0x01" : "0x01",
"0x02" : "0x01",
"0x03" : "0x01",
"0x04" : "0x01",
"0x05" : "0x01",
"0x06" : "0x01"
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "10000",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "0"
}
},
"refund50_1" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x60006001556000600255600060035560006004556000600555",
"nonce" : "0",
"storage" : {
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "255",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "9745",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x60006001556000600255600060035560006004556000600555",
"nonce" : "0",
"storage" : {
"0x01" : "0x01",
"0x02" : "0x01",
"0x03" : "0x01",
"0x04" : "0x01",
"0x05" : "0x01"
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "10000",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "0"
}
},
"refund50_2" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x6001600a556001600b5560006001556000600255600060035560006004556000600555",
"nonce" : "0",
"storage" : {
"0x0a" : "0x01",
"0x0b" : "0x01"
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "614",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "9386",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x6001600a556001600b5560006001556000600255600060035560006004556000600555",
"nonce" : "0",
"storage" : {
"0x01" : "0x01",
"0x02" : "0x01",
"0x03" : "0x01",
"0x04" : "0x01",
"0x05" : "0x01"
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "10000",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "0"
}
},
"refund600" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x600154506002545061ffff60020a600a553031600b55600060015560006002556000600355600060045560006005556000600655",
"nonce" : "0",
"storage" : {
"0x0b" : "0x0de0b6b3a7640000"
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "492",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "9508",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x600154506002545061ffff60020a600a553031600b55600060015560006002556000600355600060045560006005556000600655",
"nonce" : "0",
"storage" : {
"0x01" : "0x01",
"0x02" : "0x01",
"0x03" : "0x01",
"0x04" : "0x01",
"0x05" : "0x01",
"0x06" : "0x01"
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "10000",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "0"
}
},
"refund_NoOOG_1" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x6000600155",
"nonce" : "0",
"storage" : {
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "402",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x6000600155",
"nonce" : "0",
"storage" : {
"0x01" : "0x01"
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "502",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "502",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "0"
}
},
"refund_OOG" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x6000600155",
"nonce" : "0",
"storage" : {
"0x01" : "0x01"
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "500",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x6000600155",
"nonce" : "0",
"storage" : {
"0x01" : "0x01"
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "500",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "500",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "0"
}
},
"refund_changeNonZeroStorage" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000010",
"code" : "0x6017600155",
"nonce" : "0",
"storage" : {
"0x01" : "0x17"
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "602",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "388",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x6017600155",
"nonce" : "0",
"storage" : {
"0x01" : "0x01"
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "850",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "10"
}
},
"refund_getEtherBack" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000010",
"code" : "0x6000600155",
"nonce" : "0",
"storage" : {
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "402",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "588",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"code" : "0x6000600155",
"nonce" : "0",
"storage" : {
"0x01" : "0x01"
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "850",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "10"
}
}
}

@ -5827,4 +5827,4 @@
"value" : "100000" "value" : "100000"
} }
} }
} }

@ -0,0 +1,277 @@
{
"EmptyTransaction" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "",
"gasPrice" : "",
"nonce" : "",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "",
"value" : ""
}
},
"TransactionFromCoinbaseNotEnoughFounds" : {
"env" : {
"currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1100",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"pre" : {
"b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "600",
"gasPrice" : "1",
"nonce" : "",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"value" : "502"
}
},
"TransactionSendingToEmpty" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "500",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"6295ee1b4f6dd65047762f924ecd367c17eabf8f" : {
"balance" : "0",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "99500",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "500",
"gasPrice" : "1",
"nonce" : "",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "",
"value" : ""
}
},
"TransactionSendingToZero" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"0000000000000000000000000000000000000000" : {
"balance" : "1",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "500",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "99499",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "5000",
"gasPrice" : "1",
"nonce" : "",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "0000000000000000000000000000000000000000",
"value" : "1"
}
},
"TransactionToItself" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "500",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "99500",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "5000",
"gasPrice" : "1",
"nonce" : "",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"value" : "1"
}
},
"TransactionToItselfNotEnoughFounds" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "45678256",
"currentGasLimit" : "1000000",
"currentNumber" : "0",
"currentTimestamp" : 1,
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1101",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1101",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "600",
"gasPrice" : "1",
"nonce" : "",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"value" : "502"
}
}
}

File diff suppressed because it is too large Load Diff

@ -8,12 +8,17 @@ module.exports = {
trietestnextprev: require('./TrieTests/trietestnextprev'), trietestnextprev: require('./TrieTests/trietestnextprev'),
txtest: require('./BasicTests/txtest'), txtest: require('./BasicTests/txtest'),
StateTests: { StateTests: {
stExample: require('./StateTests/stExample.json'),
stInitCodeTest: require('./StateTests/stInitCodeTest.json'),
stLogTests: require('./StateTests/stLogTests.json'),
stPreCompiledContracts: require('./StateTests/stPreCompiledContracts'), stPreCompiledContracts: require('./StateTests/stPreCompiledContracts'),
stRecursiveCreate: require('./StateTests/stRecursiveCreate'), stRecursiveCreate: require('./StateTests/stRecursiveCreate'),
stSpecial: require('./StateTests/stSpecialTest'), stSpecial: require('./StateTests/stSpecialTest'),
stSystemOperationsTest: require('./StateTests/stSystemOperationsTest'), stSystemOperationsTest: require('./StateTests/stSystemOperationsTest'),
stTransactionTest: require('./StateTests/stTransactionTest')
}, },
VMTests: { VMTests: {
vmRandom: require('./VMTests/RandomTests/randomTest'),
vmArithmeticTest: require('./VMTests/vmArithmeticTest'), vmArithmeticTest: require('./VMTests/vmArithmeticTest'),
vmBitwiseLogicOperationTest: require('./VMTests/vmBitwiseLogicOperationTest'), vmBitwiseLogicOperationTest: require('./VMTests/vmBitwiseLogicOperationTest'),
vmBlockInfoTest: require('./VMTests/vmBlockInfoTest'), vmBlockInfoTest: require('./VMTests/vmBlockInfoTest'),
@ -22,6 +27,6 @@ module.exports = {
vmLogTest: require('./VMTests/vmLogTest'), vmLogTest: require('./VMTests/vmLogTest'),
vmPushDupSwapTest: require('./VMTests/vmPushDupSwapTest'), vmPushDupSwapTest: require('./VMTests/vmPushDupSwapTest'),
vmSha3Test: require('./VMTests/vmSha3Test'), vmSha3Test: require('./VMTests/vmSha3Test'),
vmtests: require('./VMTests/vmtests'), vmtests: require('./VMTests/vmtests')
} }
}; };

@ -44,6 +44,7 @@ func NewEnvFromMap(state *state.StateDB, envValues map[string]string, exeValues
env.time = ethutil.Big(envValues["currentTimestamp"]).Int64() env.time = ethutil.Big(envValues["currentTimestamp"]).Int64()
env.difficulty = ethutil.Big(envValues["currentDifficulty"]) env.difficulty = ethutil.Big(envValues["currentDifficulty"])
env.gasLimit = ethutil.Big(envValues["currentGasLimit"]) env.gasLimit = ethutil.Big(envValues["currentGasLimit"])
env.Gas = new(big.Int)
return env return env
} }
@ -110,7 +111,7 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log
return ret, vmenv.logs, vmenv.Gas, err return ret, vmenv.logs, vmenv.Gas, err
} }
func RunState(state *state.StateDB, env, tx map[string]string) ([]byte, state.Logs, *big.Int, error) { func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state.Logs, *big.Int, error) {
var ( var (
keyPair, _ = crypto.NewKeyPairFromSec([]byte(ethutil.Hex2Bytes(tx["secretKey"]))) keyPair, _ = crypto.NewKeyPairFromSec([]byte(ethutil.Hex2Bytes(tx["secretKey"])))
to = FromHex(tx["to"]) to = FromHex(tx["to"])
@ -118,13 +119,39 @@ func RunState(state *state.StateDB, env, tx map[string]string) ([]byte, state.Lo
gas = ethutil.Big(tx["gasLimit"]) gas = ethutil.Big(tx["gasLimit"])
price = ethutil.Big(tx["gasPrice"]) price = ethutil.Big(tx["gasPrice"])
value = ethutil.Big(tx["value"]) value = ethutil.Big(tx["value"])
caddr = FromHex(env["currentCoinbase"])
) )
caller := state.GetOrNewStateObject(keyPair.Address()) coinbase := statedb.GetOrNewStateObject(caddr)
coinbase.SetGasPool(ethutil.Big(env["currentGasLimit"]))
vmenv := NewEnvFromMap(state, env, tx) message := NewMessage(keyPair.Address(), to, data, value, gas, price)
vmenv.origin = caller.Address() Log.DebugDetailf("message{ to: %x, from %x, value: %v, gas: %v, price: %v }\n", message.to[:4], message.from[:4], message.value, message.gas, message.price)
ret, err := vmenv.Call(caller, to, data, gas, price, value) st := core.NewStateTransition(coinbase, message, statedb, nil)
vmenv := NewEnvFromMap(statedb, env, tx)
vmenv.origin = keyPair.Address()
st.Env = vmenv
ret, err := st.TransitionState()
statedb.Update(vmenv.Gas)
return ret, vmenv.logs, vmenv.Gas, err return ret, vmenv.logs, vmenv.Gas, err
} }
type Message struct {
from, to []byte
value, gas, price *big.Int
data []byte
}
func NewMessage(from, to, data []byte, value, gas, price *big.Int) Message {
return Message{from, to, value, gas, price, data}
}
func (self Message) Hash() []byte { return nil }
func (self Message) From() []byte { return self.from }
func (self Message) To() []byte { return self.to }
func (self Message) GasPrice() *big.Int { return self.price }
func (self Message) Gas() *big.Int { return self.gas }
func (self Message) Value() *big.Int { return self.value }
func (self Message) Nonce() uint64 { return 0 }
func (self Message) Data() []byte { return self.data }

@ -8,6 +8,7 @@ import (
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/tests/helper" "github.com/ethereum/go-ethereum/tests/helper"
) )
@ -81,6 +82,9 @@ func RunVmTest(p string, t *testing.T) {
for addr, account := range test.Pre { for addr, account := range test.Pre {
obj := StateObjectFromAccount(addr, account) obj := StateObjectFromAccount(addr, account)
statedb.SetStateObject(obj) statedb.SetStateObject(obj)
for a, v := range account.Storage {
obj.SetState(helper.FromHex(a), ethutil.NewValue(helper.FromHex(v)))
}
} }
// XXX Yeah, yeah... // XXX Yeah, yeah...
@ -129,6 +133,16 @@ func RunVmTest(p string, t *testing.T) {
for addr, account := range test.Post { for addr, account := range test.Post {
obj := statedb.GetStateObject(helper.FromHex(addr)) obj := statedb.GetStateObject(helper.FromHex(addr))
if obj == nil {
continue
}
if len(test.Exec) == 0 {
if obj.Balance().Cmp(ethutil.Big(account.Balance)) != 0 {
t.Errorf("%s's : (%x) balance failed. Expected %v, got %v => %v\n", name, obj.Address()[:4], account.Balance, obj.Balance(), new(big.Int).Sub(ethutil.Big(account.Balance), obj.Balance()))
}
}
for addr, value := range account.Storage { for addr, value := range account.Storage {
v := obj.GetState(helper.FromHex(addr)).Bytes() v := obj.GetState(helper.FromHex(addr)).Bytes()
vexp := helper.FromHex(value) vexp := helper.FromHex(value)
@ -149,6 +163,7 @@ func RunVmTest(p string, t *testing.T) {
} }
} }
} }
logger.Flush()
} }
// I've created a new function for each tests so it's easier to identify where the problem lies if any of them fail. // I've created a new function for each tests so it's easier to identify where the problem lies if any of them fail.
@ -212,7 +227,12 @@ func TestStateRecursiveCreate(t *testing.T) {
RunVmTest(fn, t) RunVmTest(fn, t)
} }
func TestStateSpecialTest(t *testing.T) { func TestStateSpecial(t *testing.T) {
const fn = "../files/StateTests/stSpecialTest.json" const fn = "../files/StateTests/stSpecialTest.json"
RunVmTest(fn, t) RunVmTest(fn, t)
} }
func TestStateRefund(t *testing.T) {
const fn = "../files/StateTests/stRefundTest.json"
RunVmTest(fn, t)
}

@ -37,7 +37,7 @@ var (
GasLog = big.NewInt(32) GasLog = big.NewInt(32)
GasSha256 = big.NewInt(50) GasSha256 = big.NewInt(50)
GasRipemd = big.NewInt(50) GasRipemd = big.NewInt(50)
GasEcrecover = big.NewInt(100) GasEcrecover = big.NewInt(500)
Pow256 = ethutil.BigPow(2, 256) Pow256 = ethutil.BigPow(2, 256)

@ -2,6 +2,7 @@ package vm
import ( import (
"fmt" "fmt"
"math"
"math/big" "math/big"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
@ -112,7 +113,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
return closure.Return(nil), nil return closure.Return(nil), nil
} }
vmlogger.Debugf("(%d) %x gas: %v (d) %x\n", self.env.Depth(), closure.Address(), closure.Gas, callData) vmlogger.Debugf("(%d) (%x) %x gas: %v (d) %x\n", self.env.Depth(), caller.Address()[:4], closure.Address(), closure.Gas, callData)
for { for {
prevStep = step prevStep = step
@ -180,16 +181,17 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
var mult *big.Int var mult *big.Int
y, x := stack.Peekn() y, x := stack.Peekn()
val := closure.GetStorage(x) //val := closure.GetStorage(x)
if val.BigInt().Cmp(ethutil.Big0) == 0 && len(y.Bytes()) > 0 { val := statedb.GetState(closure.Address(), x.Bytes())
if len(val) == 0 && len(y.Bytes()) > 0 {
// 0 => non 0 // 0 => non 0
mult = ethutil.Big3 mult = ethutil.Big3
} else if val.BigInt().Cmp(ethutil.Big0) != 0 && len(y.Bytes()) == 0 { } else if len(val) > 0 && len(y.Bytes()) == 0 {
statedb.Refund(closure.caller.Address(), GasSStoreRefund, closure.Price) statedb.Refund(caller.Address(), GasSStoreRefund)
mult = ethutil.Big0 mult = ethutil.Big0
} else { } else {
// non 0 => non 0 // non 0 => non 0 (or 0 => 0)
mult = ethutil.Big1 mult = ethutil.Big1
} }
gas.Set(new(big.Int).Mul(mult, GasSStore)) gas.Set(new(big.Int).Mul(mult, GasSStore))
@ -660,7 +662,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
cOff = 0 cOff = 0
l = 0 l = 0
} else if cOff+l > size { } else if cOff+l > size {
l = 0 l = uint64(math.Min(float64(cOff+l), float64(size)))
} }
codeCopy := code[cOff : cOff+l] codeCopy := code[cOff : cOff+l]
@ -776,10 +778,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
val, loc := stack.Popn() val, loc := stack.Popn()
statedb.SetState(closure.Address(), loc.Bytes(), val) statedb.SetState(closure.Address(), loc.Bytes(), val)
// Debug sessions are allowed to run without message closure.message.AddStorageChange(loc.Bytes())
if closure.message != nil {
closure.message.AddStorageChange(loc.Bytes())
}
self.Printf(" {0x%x : 0x%x}", loc.Bytes(), val.Bytes()) self.Printf(" {0x%x : 0x%x}", loc.Bytes(), val.Bytes())
case JUMP: case JUMP:
@ -898,10 +897,12 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
return closure.Return(ret), nil return closure.Return(ret), nil
case SUICIDE: case SUICIDE:
receiver := statedb.GetOrNewStateObject(stack.Pop().Bytes()) receiver := statedb.GetOrNewStateObject(stack.Pop().Bytes())
balance := statedb.GetBalance(closure.Address())
self.Printf(" => (%x) %v", receiver.Address()[:4], balance)
receiver.AddAmount(statedb.GetBalance(closure.Address())) receiver.AddAmount(balance)
statedb.Delete(closure.Address()) statedb.Delete(closure.Address())
fallthrough fallthrough

@ -211,7 +211,7 @@ func (self *JSXEth) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr
return "", err return "", err
} }
if types.IsContractAddr(to) { if types.IsContractAddr(to) {
return ethutil.Bytes2Hex(tx.CreationAddress(nil)), nil return ethutil.Bytes2Hex(core.AddressFromMessage(tx)), nil
} }
return ethutil.Bytes2Hex(tx.Hash()), nil return ethutil.Bytes2Hex(tx.Hash()), nil
@ -224,7 +224,7 @@ func (self *JSXEth) PushTx(txStr string) (*JSReceipt, error) {
return nil, err return nil, err
} }
return NewJSReciept(tx.CreatesContract(), tx.CreationAddress(self.World().State()), tx.Hash(), tx.Sender()), nil return NewJSReciept(core.MessageCreatesContract(tx), core.AddressFromMessage(tx), tx.Hash(), tx.From()), nil
} }
func (self *JSXEth) CompileMutan(code string) string { func (self *JSXEth) CompileMutan(code string) string {

@ -96,21 +96,21 @@ type JSTransaction struct {
func NewJSTx(tx *types.Transaction, state *state.StateDB) *JSTransaction { func NewJSTx(tx *types.Transaction, state *state.StateDB) *JSTransaction {
hash := ethutil.Bytes2Hex(tx.Hash()) hash := ethutil.Bytes2Hex(tx.Hash())
receiver := ethutil.Bytes2Hex(tx.Recipient) receiver := ethutil.Bytes2Hex(tx.To())
if receiver == "0000000000000000000000000000000000000000" { if receiver == "0000000000000000000000000000000000000000" {
receiver = ethutil.Bytes2Hex(tx.CreationAddress(state)) receiver = ethutil.Bytes2Hex(core.AddressFromMessage(tx))
} }
sender := ethutil.Bytes2Hex(tx.Sender()) sender := ethutil.Bytes2Hex(tx.Sender())
createsContract := tx.CreatesContract() createsContract := core.MessageCreatesContract(tx)
var data string var data string
if tx.CreatesContract() { if createsContract {
data = strings.Join(core.Disassemble(tx.Data), "\n") data = strings.Join(core.Disassemble(tx.Data()), "\n")
} else { } else {
data = ethutil.Bytes2Hex(tx.Data) data = ethutil.Bytes2Hex(tx.Data())
} }
return &JSTransaction{ref: tx, Hash: hash, Value: ethutil.CurrencyToString(tx.Value), Address: receiver, Contract: tx.CreatesContract(), Gas: tx.Gas.String(), GasPrice: tx.GasPrice.String(), Data: data, Sender: sender, CreatesContract: createsContract, RawData: ethutil.Bytes2Hex(tx.Data)} return &JSTransaction{ref: tx, Hash: hash, Value: ethutil.CurrencyToString(tx.Value()), Address: receiver, Contract: createsContract, Gas: tx.Gas().String(), GasPrice: tx.GasPrice().String(), Data: data, Sender: sender, CreatesContract: createsContract, RawData: ethutil.Bytes2Hex(tx.Data())}
} }
func (self *JSTransaction) ToString() string { func (self *JSTransaction) ToString() string {

@ -134,7 +134,7 @@ func (self *XEth) Transact(key *crypto.KeyPair, to []byte, value, gas, price *et
state := self.chainManager.TransState() state := self.chainManager.TransState()
nonce := state.GetNonce(key.Address()) nonce := state.GetNonce(key.Address())
tx.Nonce = nonce tx.SetNonce(nonce)
tx.Sign(key.PrivateKey) tx.Sign(key.PrivateKey)
// Do some pre processing for our "pre" events and hooks // Do some pre processing for our "pre" events and hooks
@ -150,7 +150,7 @@ func (self *XEth) Transact(key *crypto.KeyPair, to []byte, value, gas, price *et
state.SetNonce(key.Address(), nonce+1) state.SetNonce(key.Address(), nonce+1)
if contractCreation { if contractCreation {
addr := tx.CreationAddress(self.World().State()) addr := core.AddressFromMessage(tx)
pipelogger.Infof("Contract addr %x\n", addr) pipelogger.Infof("Contract addr %x\n", addr)
} }
@ -163,8 +163,8 @@ func (self *XEth) PushTx(tx *types.Transaction) ([]byte, error) {
return nil, err return nil, err
} }
if tx.Recipient == nil { if tx.To() == nil {
addr := tx.CreationAddress(self.World().State()) addr := core.AddressFromMessage(tx)
pipelogger.Infof("Contract addr %x\n", addr) pipelogger.Infof("Contract addr %x\n", addr)
return addr, nil return addr, nil
} }

Loading…
Cancel
Save