merge
This commit is contained in:
commit
22d29a6d52
@ -309,13 +309,13 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
|
||||
|
||||
var (
|
||||
ptx = xeth.NewJSTx(tx, pipe.World().State())
|
||||
send = nameReg.Storage(tx.Sender())
|
||||
rec = nameReg.Storage(tx.Recipient)
|
||||
send = nameReg.Storage(tx.From())
|
||||
rec = nameReg.Storage(tx.To())
|
||||
s, r string
|
||||
)
|
||||
|
||||
if tx.CreatesContract() {
|
||||
rec = nameReg.Storage(tx.CreationAddress(pipe.World().State()))
|
||||
if core.MessageCreatesContract(tx) {
|
||||
rec = nameReg.Storage(core.AddressFromMessage(tx))
|
||||
}
|
||||
|
||||
if send.Len() != 0 {
|
||||
@ -326,10 +326,10 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
|
||||
if rec.Len() != 0 {
|
||||
r = strings.Trim(rec.Str(), "\x00")
|
||||
} else {
|
||||
if tx.CreatesContract() {
|
||||
r = ethutil.Bytes2Hex(tx.CreationAddress(pipe.World().State()))
|
||||
if core.MessageCreatesContract(tx) {
|
||||
r = ethutil.Bytes2Hex(core.AddressFromMessage(tx))
|
||||
} else {
|
||||
r = ethutil.Bytes2Hex(tx.Recipient)
|
||||
r = ethutil.Bytes2Hex(tx.To())
|
||||
}
|
||||
}
|
||||
ptx.Sender = s
|
||||
@ -454,11 +454,11 @@ func (gui *Gui) update() {
|
||||
object := state.GetAccount(gui.address())
|
||||
|
||||
if bytes.Compare(tx.Sender(), gui.address()) == 0 {
|
||||
object.SubAmount(tx.Value)
|
||||
object.SubAmount(tx.Value())
|
||||
|
||||
gui.txDb.Put(tx.Hash(), tx.RlpEncode())
|
||||
} else if bytes.Compare(tx.Recipient, gui.address()) == 0 {
|
||||
object.AddAmount(tx.Value)
|
||||
} else if bytes.Compare(tx.To(), gui.address()) == 0 {
|
||||
object.AddAmount(tx.Value())
|
||||
|
||||
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
|
||||
state.EmptyLogs()
|
||||
|
||||
txGas := new(big.Int).Set(tx.Gas)
|
||||
txGas := new(big.Int).Set(tx.Gas())
|
||||
|
||||
cb := state.GetStateObject(coinbase.Address())
|
||||
st := NewStateTransition(cb, tx, state, block)
|
||||
err = st.TransitionState()
|
||||
_, err = st.TransitionState()
|
||||
if err != nil {
|
||||
switch {
|
||||
case IsNonceErr(err):
|
||||
@ -132,7 +132,7 @@ done:
|
||||
}
|
||||
|
||||
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
|
||||
state.Update(txGas)
|
||||
|
@ -5,6 +5,8 @@ import (
|
||||
"math/big"
|
||||
|
||||
"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/vm"
|
||||
)
|
||||
@ -27,48 +29,69 @@ import (
|
||||
*/
|
||||
type StateTransition struct {
|
||||
coinbase, receiver []byte
|
||||
tx *types.Transaction
|
||||
msg Message
|
||||
gas, gasPrice *big.Int
|
||||
initialGas *big.Int
|
||||
value *big.Int
|
||||
data []byte
|
||||
state *state.StateDB
|
||||
block *types.Block
|
||||
|
||||
cb, rec, sen *state.StateObject
|
||||
|
||||
Env vm.Environment
|
||||
}
|
||||
|
||||
func NewStateTransition(coinbase *state.StateObject, tx *types.Transaction, state *state.StateDB, block *types.Block) *StateTransition {
|
||||
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}
|
||||
type Message interface {
|
||||
Hash() []byte
|
||||
|
||||
From() []byte
|
||||
To() []byte
|
||||
|
||||
GasPrice() *big.Int
|
||||
Gas() *big.Int
|
||||
Value() *big.Int
|
||||
|
||||
Nonce() uint64
|
||||
Data() []byte
|
||||
}
|
||||
|
||||
func AddressFromMessage(msg Message) []byte {
|
||||
// Generate a new address
|
||||
return crypto.Sha3(ethutil.NewValue([]interface{}{msg.From(), msg.Nonce()}).Encode())[12:]
|
||||
}
|
||||
|
||||
func MessageCreatesContract(msg Message) bool {
|
||||
return len(msg.To()) == 0
|
||||
}
|
||||
|
||||
func MessageGasValue(msg Message) *big.Int {
|
||||
return new(big.Int).Mul(msg.Gas(), msg.GasPrice())
|
||||
}
|
||||
|
||||
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) VmEnv() vm.Environment {
|
||||
if self.Env == nil {
|
||||
self.Env = NewEnv(self.state, self.msg, self.block)
|
||||
}
|
||||
|
||||
return self.Env
|
||||
}
|
||||
|
||||
func (self *StateTransition) Coinbase() *state.StateObject {
|
||||
if self.cb != nil {
|
||||
return self.cb
|
||||
return self.state.GetOrNewStateObject(self.coinbase)
|
||||
}
|
||||
|
||||
self.cb = self.state.GetOrNewStateObject(self.coinbase)
|
||||
return self.cb
|
||||
func (self *StateTransition) From() *state.StateObject {
|
||||
return self.state.GetOrNewStateObject(self.msg.From())
|
||||
}
|
||||
func (self *StateTransition) Sender() *state.StateObject {
|
||||
if self.sen != nil {
|
||||
return self.sen
|
||||
}
|
||||
|
||||
self.sen = self.state.GetOrNewStateObject(self.tx.Sender())
|
||||
|
||||
return self.sen
|
||||
}
|
||||
func (self *StateTransition) Receiver() *state.StateObject {
|
||||
if self.tx != nil && self.tx.CreatesContract() {
|
||||
func (self *StateTransition) To() *state.StateObject {
|
||||
if self.msg != nil && MessageCreatesContract(self.msg) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if self.rec != nil {
|
||||
return self.rec
|
||||
}
|
||||
|
||||
self.rec = self.state.GetOrNewStateObject(self.tx.Recipient)
|
||||
return self.rec
|
||||
return self.state.GetOrNewStateObject(self.msg.To())
|
||||
}
|
||||
|
||||
func (self *StateTransition) UseGas(amount *big.Int) error {
|
||||
@ -87,41 +110,33 @@ func (self *StateTransition) AddGas(amount *big.Int) {
|
||||
func (self *StateTransition) BuyGas() error {
|
||||
var err error
|
||||
|
||||
sender := self.Sender()
|
||||
if sender.Balance().Cmp(self.tx.GasValue()) < 0 {
|
||||
return fmt.Errorf("Insufficient funds to pre-pay gas. Req %v, has %v", self.tx.GasValue(), sender.Balance())
|
||||
sender := self.From()
|
||||
if sender.Balance().Cmp(MessageGasValue(self.msg)) < 0 {
|
||||
return fmt.Errorf("Insufficient funds to pre-pay gas. Req %v, has %v", MessageGasValue(self.msg), sender.Balance())
|
||||
}
|
||||
|
||||
coinbase := self.Coinbase()
|
||||
err = coinbase.BuyGas(self.tx.Gas, self.tx.GasPrice)
|
||||
err = coinbase.BuyGas(self.msg.Gas(), self.msg.GasPrice())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
self.AddGas(self.tx.Gas)
|
||||
sender.SubAmount(self.tx.GasValue())
|
||||
self.AddGas(self.msg.Gas())
|
||||
self.initialGas.Set(self.msg.Gas())
|
||||
sender.SubAmount(MessageGasValue(self.msg))
|
||||
|
||||
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) {
|
||||
var (
|
||||
tx = self.tx
|
||||
sender = self.Sender()
|
||||
msg = self.msg
|
||||
sender = self.From()
|
||||
)
|
||||
|
||||
// Make sure this transaction's nonce is correct
|
||||
if sender.Nonce != tx.Nonce {
|
||||
return NonceError(tx.Nonce, sender.Nonce)
|
||||
if sender.Nonce != msg.Nonce() {
|
||||
return NonceError(msg.Nonce(), sender.Nonce)
|
||||
}
|
||||
|
||||
// Pre-pay gas / Buy gas of the coinbase account
|
||||
@ -132,8 +147,8 @@ func (self *StateTransition) preCheck() (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *StateTransition) TransitionState() (err error) {
|
||||
statelogger.Debugf("(~) %x\n", self.tx.Hash())
|
||||
func (self *StateTransition) TransitionState() (ret []byte, err error) {
|
||||
statelogger.Debugf("(~) %x\n", self.msg.Hash())
|
||||
|
||||
// XXX Transactions after this point are considered valid.
|
||||
if err = self.preCheck(); err != nil {
|
||||
@ -141,8 +156,8 @@ func (self *StateTransition) TransitionState() (err error) {
|
||||
}
|
||||
|
||||
var (
|
||||
tx = self.tx
|
||||
sender = self.Sender()
|
||||
msg = self.msg
|
||||
sender = self.From()
|
||||
)
|
||||
|
||||
defer self.RefundGas()
|
||||
@ -168,16 +183,15 @@ func (self *StateTransition) TransitionState() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
var ret []byte
|
||||
vmenv := NewEnv(self.state, self.tx, self.block)
|
||||
vmenv := self.VmEnv()
|
||||
var ref vm.ClosureRef
|
||||
if tx.CreatesContract() {
|
||||
self.rec = MakeContract(tx, self.state)
|
||||
if MessageCreatesContract(msg) {
|
||||
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)
|
||||
} 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 {
|
||||
statelogger.Debugln(err)
|
||||
@ -187,11 +201,32 @@ func (self *StateTransition) TransitionState() (err error) {
|
||||
}
|
||||
|
||||
// Converts an transaction in to a state object
|
||||
func MakeContract(tx *types.Transaction, state *state.StateDB) *state.StateObject {
|
||||
addr := tx.CreationAddress(state)
|
||||
func MakeContract(msg Message, state *state.StateDB) *state.StateObject {
|
||||
addr := AddressFromMessage(msg)
|
||||
|
||||
contract := state.GetOrNewStateObject(addr)
|
||||
contract.InitCode = tx.Data
|
||||
contract.InitCode = msg.Data()
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
if len(tx.Recipient) != 0 && len(tx.Recipient) != 20 {
|
||||
return fmt.Errorf("Invalid recipient. len = %d", len(tx.Recipient))
|
||||
if len(tx.To()) != 0 && len(tx.To()) != 20 {
|
||||
return fmt.Errorf("Invalid recipient. len = %d", len(tx.To()))
|
||||
}
|
||||
|
||||
v, _, _ := tx.Curve()
|
||||
@ -118,17 +118,11 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
|
||||
// Get the 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
|
||||
// funds won't invalidate this transaction but simple ignores it.
|
||||
if sender.Balance().Cmp(totAmount) < 0 {
|
||||
return fmt.Errorf("Insufficient amount in sender's (%x) account", tx.Sender())
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
return fmt.Errorf("Insufficient amount in sender's (%x) account", tx.From())
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
||||
tmp := make([]byte, 4)
|
||||
copy(tmp, tx.Recipient)
|
||||
|
||||
txplogger.Debugf("(t) %x => %x (%v) %x\n", tx.Sender()[:4], tmp, tx.Value, tx.Hash())
|
||||
txplogger.Debugf("(t) %x => %x (%v) %x\n", tx.From()[:4], tx.To()[:4], tx.Value, tx.Hash())
|
||||
|
||||
// Notify the subscribers
|
||||
go self.eventMux.Post(TxPreEvent{tx})
|
||||
@ -204,7 +195,7 @@ func (pool *TxPool) RemoveInvalid(state *state.StateDB) {
|
||||
tx := e.Value.(*types.Transaction)
|
||||
sender := state.GetAccount(tx.Sender())
|
||||
err := pool.ValidateTransaction(tx)
|
||||
if err != nil || sender.Nonce >= tx.Nonce {
|
||||
if err != nil || sender.Nonce >= tx.Nonce() {
|
||||
pool.pool.Remove(e)
|
||||
}
|
||||
}
|
||||
|
@ -6,37 +6,30 @@ import (
|
||||
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/ethutil"
|
||||
"github.com/ethereum/go-ethereum/state"
|
||||
"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 {
|
||||
return len(addr) == 0
|
||||
//return bytes.Compare(addr, ContractAddr) == 0
|
||||
}
|
||||
|
||||
type Transaction struct {
|
||||
Nonce uint64
|
||||
Recipient []byte
|
||||
Value *big.Int
|
||||
Gas *big.Int
|
||||
GasPrice *big.Int
|
||||
Data []byte
|
||||
nonce uint64
|
||||
recipient []byte
|
||||
value *big.Int
|
||||
gas *big.Int
|
||||
gasPrice *big.Int
|
||||
data []byte
|
||||
v 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 {
|
||||
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 {
|
||||
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 {
|
||||
@ -53,33 +46,42 @@ func NewTransactionFromValue(val *ethutil.Value) *Transaction {
|
||||
return tx
|
||||
}
|
||||
|
||||
func (self *Transaction) GasValue() *big.Int {
|
||||
return new(big.Int).Mul(self.Gas, self.GasPrice)
|
||||
}
|
||||
|
||||
func (self *Transaction) TotalValue() *big.Int {
|
||||
v := self.GasValue()
|
||||
return v.Add(v, self.Value)
|
||||
}
|
||||
|
||||
func (tx *Transaction) Hash() []byte {
|
||||
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}
|
||||
|
||||
return crypto.Sha3(ethutil.NewValue(data).Encode())
|
||||
}
|
||||
|
||||
func (tx *Transaction) CreatesContract() bool {
|
||||
return tx.contractCreation
|
||||
func (self *Transaction) Data() []byte {
|
||||
return self.data
|
||||
}
|
||||
|
||||
/* Deprecated */
|
||||
func (tx *Transaction) IsContract() bool {
|
||||
return tx.CreatesContract()
|
||||
func (self *Transaction) Gas() *big.Int {
|
||||
return self.gas
|
||||
}
|
||||
|
||||
func (tx *Transaction) CreationAddress(state *state.StateDB) []byte {
|
||||
// Generate a new address
|
||||
return crypto.Sha3(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce}).Encode())[12:]
|
||||
func (self *Transaction) GasPrice() *big.Int {
|
||||
return self.gasPrice
|
||||
}
|
||||
|
||||
func (self *Transaction) Value() *big.Int {
|
||||
return self.value
|
||||
}
|
||||
|
||||
func (self *Transaction) Nonce() uint64 {
|
||||
return self.nonce
|
||||
}
|
||||
|
||||
func (self *Transaction) SetNonce(nonce uint64) {
|
||||
self.nonce = nonce
|
||||
}
|
||||
|
||||
func (self *Transaction) From() []byte {
|
||||
return self.Sender()
|
||||
}
|
||||
|
||||
func (self *Transaction) To() []byte {
|
||||
return self.recipient
|
||||
}
|
||||
|
||||
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{} {
|
||||
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
|
||||
|
||||
@ -156,20 +158,16 @@ func (tx *Transaction) RlpDecode(data []byte) {
|
||||
}
|
||||
|
||||
func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value) {
|
||||
tx.Nonce = decoder.Get(0).Uint()
|
||||
tx.GasPrice = decoder.Get(1).BigInt()
|
||||
tx.Gas = decoder.Get(2).BigInt()
|
||||
tx.Recipient = decoder.Get(3).Bytes()
|
||||
tx.Value = decoder.Get(4).BigInt()
|
||||
tx.Data = decoder.Get(5).Bytes()
|
||||
tx.nonce = decoder.Get(0).Uint()
|
||||
tx.gasPrice = decoder.Get(1).BigInt()
|
||||
tx.gas = decoder.Get(2).BigInt()
|
||||
tx.recipient = decoder.Get(3).Bytes()
|
||||
tx.value = decoder.Get(4).BigInt()
|
||||
tx.data = decoder.Get(5).Bytes()
|
||||
tx.v = byte(decoder.Get(6).Uint())
|
||||
|
||||
tx.r = decoder.Get(7).Bytes()
|
||||
tx.s = decoder.Get(8).Bytes()
|
||||
|
||||
if IsContractAddr(tx.Recipient) {
|
||||
tx.contractCreation = true
|
||||
}
|
||||
}
|
||||
|
||||
func (tx *Transaction) String() string {
|
||||
@ -188,12 +186,12 @@ func (tx *Transaction) String() string {
|
||||
S: 0x%x
|
||||
`,
|
||||
tx.Hash(),
|
||||
len(tx.Recipient) == 0,
|
||||
len(tx.recipient) == 0,
|
||||
tx.Sender(),
|
||||
tx.Recipient,
|
||||
tx.Nonce,
|
||||
tx.GasPrice,
|
||||
tx.Gas,
|
||||
tx.recipient,
|
||||
tx.nonce,
|
||||
tx.gasPrice,
|
||||
tx.gas,
|
||||
tx.Value,
|
||||
tx.Data,
|
||||
tx.v,
|
||||
@ -221,5 +219,5 @@ func (s Transactions) GetRlp(i int) []byte { return ethutil.Rlp(s[i]) }
|
||||
type TxByNonce struct{ Transactions }
|
||||
|
||||
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 {
|
||||
state *state.StateDB
|
||||
block *types.Block
|
||||
tx *types.Transaction
|
||||
msg Message
|
||||
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{
|
||||
state: state,
|
||||
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) PrevHash() []byte { return self.block.PrevHash }
|
||||
func (self *VMEnv) Coinbase() []byte { return self.block.Coinbase }
|
||||
func (self *VMEnv) Time() int64 { return self.block.Time }
|
||||
func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty }
|
||||
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) GasLimit() *big.Int { return self.block.GasLimit }
|
||||
func (self *VMEnv) Depth() int { return self.depth }
|
||||
|
@ -236,8 +236,8 @@ func (self *Miner) finiliseTxs() types.Transactions {
|
||||
key := self.eth.KeyManager()
|
||||
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.Nonce = state.GetNonce(self.Coinbase)
|
||||
state.SetNonce(self.Coinbase, tx.Nonce+1)
|
||||
tx.SetNonce(state.GetNonce(self.Coinbase))
|
||||
state.SetNonce(self.Coinbase, tx.Nonce()+1)
|
||||
|
||||
tx.Sign(key.PrivateKey())
|
||||
|
||||
@ -246,7 +246,7 @@ func (self *Miner) finiliseTxs() types.Transactions {
|
||||
|
||||
// Faster than append
|
||||
for _, tx := range self.eth.TxPool().GetTransactions() {
|
||||
if tx.GasPrice.Cmp(self.MinAcceptedGasPrice) >= 0 {
|
||||
if tx.GasPrice().Cmp(self.MinAcceptedGasPrice) >= 0 {
|
||||
txs[actualSize] = tx
|
||||
actualSize++
|
||||
}
|
||||
|
@ -23,14 +23,14 @@ type StateDB struct {
|
||||
|
||||
manifest *Manifest
|
||||
|
||||
refund map[string][]refund
|
||||
refund map[string]*big.Int
|
||||
|
||||
logs Logs
|
||||
}
|
||||
|
||||
// Create a new state from a given trie
|
||||
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() {
|
||||
@ -55,12 +55,11 @@ func (self *StateDB) GetBalance(addr []byte) *big.Int {
|
||||
return ethutil.Big0
|
||||
}
|
||||
|
||||
type refund struct {
|
||||
gas, price *big.Int
|
||||
func (self *StateDB) Refund(addr []byte, gas *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)] = append(self.refund[string(addr)], refund{gas, price})
|
||||
self.refund[string(addr)].Add(self.refund[string(addr)], gas)
|
||||
}
|
||||
|
||||
func (self *StateDB) AddBalance(addr []byte, amount *big.Int) {
|
||||
@ -211,7 +210,7 @@ func (self *StateDB) Copy() *StateDB {
|
||||
}
|
||||
|
||||
for addr, refund := range self.refund {
|
||||
state.refund[addr] = refund
|
||||
state.refund[addr] = new(big.Int).Set(refund)
|
||||
}
|
||||
|
||||
logs := make(Logs, len(self.logs))
|
||||
@ -273,23 +272,17 @@ func (s *StateDB) Sync() {
|
||||
|
||||
func (self *StateDB) Empty() {
|
||||
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) {
|
||||
var deleted bool
|
||||
|
||||
// Refund any gas that's left
|
||||
// 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)
|
||||
self.refund = make(map[string]*big.Int)
|
||||
|
||||
for _, stateObject := range self.stateObjects {
|
||||
if stateObject.remove {
|
||||
|
870
tests/files/StateTests/stInitCodeTest.json
Normal file
870
tests/files/StateTests/stInitCodeTest.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
523
tests/files/StateTests/stRefundTest.json
Normal file
523
tests/files/StateTests/stRefundTest.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
277
tests/files/StateTests/stTransactionTest.json
Normal file
277
tests/files/StateTests/stTransactionTest.json
Normal file
@ -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'),
|
||||
txtest: require('./BasicTests/txtest'),
|
||||
StateTests: {
|
||||
stExample: require('./StateTests/stExample.json'),
|
||||
stInitCodeTest: require('./StateTests/stInitCodeTest.json'),
|
||||
stLogTests: require('./StateTests/stLogTests.json'),
|
||||
stPreCompiledContracts: require('./StateTests/stPreCompiledContracts'),
|
||||
stRecursiveCreate: require('./StateTests/stRecursiveCreate'),
|
||||
stSpecial: require('./StateTests/stSpecialTest'),
|
||||
stSystemOperationsTest: require('./StateTests/stSystemOperationsTest'),
|
||||
stTransactionTest: require('./StateTests/stTransactionTest')
|
||||
},
|
||||
VMTests: {
|
||||
vmRandom: require('./VMTests/RandomTests/randomTest'),
|
||||
vmArithmeticTest: require('./VMTests/vmArithmeticTest'),
|
||||
vmBitwiseLogicOperationTest: require('./VMTests/vmBitwiseLogicOperationTest'),
|
||||
vmBlockInfoTest: require('./VMTests/vmBlockInfoTest'),
|
||||
@ -22,6 +27,6 @@ module.exports = {
|
||||
vmLogTest: require('./VMTests/vmLogTest'),
|
||||
vmPushDupSwapTest: require('./VMTests/vmPushDupSwapTest'),
|
||||
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.difficulty = ethutil.Big(envValues["currentDifficulty"])
|
||||
env.gasLimit = ethutil.Big(envValues["currentGasLimit"])
|
||||
env.Gas = new(big.Int)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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 (
|
||||
keyPair, _ = crypto.NewKeyPairFromSec([]byte(ethutil.Hex2Bytes(tx["secretKey"])))
|
||||
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"])
|
||||
price = ethutil.Big(tx["gasPrice"])
|
||||
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)
|
||||
vmenv.origin = caller.Address()
|
||||
ret, err := vmenv.Call(caller, to, data, gas, price, value)
|
||||
message := NewMessage(keyPair.Address(), to, data, value, gas, price)
|
||||
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)
|
||||
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
|
||||
}
|
||||
|
||||
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/ethutil"
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/state"
|
||||
"github.com/ethereum/go-ethereum/tests/helper"
|
||||
)
|
||||
@ -81,6 +82,9 @@ func RunVmTest(p string, t *testing.T) {
|
||||
for addr, account := range test.Pre {
|
||||
obj := StateObjectFromAccount(addr, account)
|
||||
statedb.SetStateObject(obj)
|
||||
for a, v := range account.Storage {
|
||||
obj.SetState(helper.FromHex(a), ethutil.NewValue(helper.FromHex(v)))
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Yeah, yeah...
|
||||
@ -129,6 +133,16 @@ func RunVmTest(p string, t *testing.T) {
|
||||
|
||||
for addr, account := range test.Post {
|
||||
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 {
|
||||
v := obj.GetState(helper.FromHex(addr)).Bytes()
|
||||
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.
|
||||
@ -212,7 +227,12 @@ func TestStateRecursiveCreate(t *testing.T) {
|
||||
RunVmTest(fn, t)
|
||||
}
|
||||
|
||||
func TestStateSpecialTest(t *testing.T) {
|
||||
func TestStateSpecial(t *testing.T) {
|
||||
const fn = "../files/StateTests/stSpecialTest.json"
|
||||
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)
|
||||
GasSha256 = big.NewInt(50)
|
||||
GasRipemd = big.NewInt(50)
|
||||
GasEcrecover = big.NewInt(100)
|
||||
GasEcrecover = big.NewInt(500)
|
||||
|
||||
Pow256 = ethutil.BigPow(2, 256)
|
||||
|
||||
|
@ -2,6 +2,7 @@ package vm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
|
||||
"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
|
||||
}
|
||||
|
||||
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 {
|
||||
prevStep = step
|
||||
@ -180,16 +181,17 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
|
||||
|
||||
var mult *big.Int
|
||||
y, x := stack.Peekn()
|
||||
val := closure.GetStorage(x)
|
||||
if val.BigInt().Cmp(ethutil.Big0) == 0 && len(y.Bytes()) > 0 {
|
||||
//val := closure.GetStorage(x)
|
||||
val := statedb.GetState(closure.Address(), x.Bytes())
|
||||
if len(val) == 0 && len(y.Bytes()) > 0 {
|
||||
// 0 => non 0
|
||||
mult = ethutil.Big3
|
||||
} else if val.BigInt().Cmp(ethutil.Big0) != 0 && len(y.Bytes()) == 0 {
|
||||
statedb.Refund(closure.caller.Address(), GasSStoreRefund, closure.Price)
|
||||
} else if len(val) > 0 && len(y.Bytes()) == 0 {
|
||||
statedb.Refund(caller.Address(), GasSStoreRefund)
|
||||
|
||||
mult = ethutil.Big0
|
||||
} else {
|
||||
// non 0 => non 0
|
||||
// non 0 => non 0 (or 0 => 0)
|
||||
mult = ethutil.Big1
|
||||
}
|
||||
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
|
||||
l = 0
|
||||
} else if cOff+l > size {
|
||||
l = 0
|
||||
l = uint64(math.Min(float64(cOff+l), float64(size)))
|
||||
}
|
||||
|
||||
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()
|
||||
statedb.SetState(closure.Address(), loc.Bytes(), val)
|
||||
|
||||
// Debug sessions are allowed to run without message
|
||||
if closure.message != nil {
|
||||
closure.message.AddStorageChange(loc.Bytes())
|
||||
}
|
||||
|
||||
self.Printf(" {0x%x : 0x%x}", loc.Bytes(), val.Bytes())
|
||||
case JUMP:
|
||||
@ -898,10 +897,12 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
|
||||
|
||||
return closure.Return(ret), nil
|
||||
case SUICIDE:
|
||||
|
||||
receiver := statedb.GetOrNewStateObject(stack.Pop().Bytes())
|
||||
balance := statedb.GetBalance(closure.Address())
|
||||
|
||||
receiver.AddAmount(statedb.GetBalance(closure.Address()))
|
||||
self.Printf(" => (%x) %v", receiver.Address()[:4], balance)
|
||||
|
||||
receiver.AddAmount(balance)
|
||||
statedb.Delete(closure.Address())
|
||||
|
||||
fallthrough
|
||||
|
@ -211,7 +211,7 @@ func (self *JSXEth) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr
|
||||
return "", err
|
||||
}
|
||||
if types.IsContractAddr(to) {
|
||||
return ethutil.Bytes2Hex(tx.CreationAddress(nil)), nil
|
||||
return ethutil.Bytes2Hex(core.AddressFromMessage(tx)), nil
|
||||
}
|
||||
|
||||
return ethutil.Bytes2Hex(tx.Hash()), nil
|
||||
@ -224,7 +224,7 @@ func (self *JSXEth) PushTx(txStr string) (*JSReceipt, error) {
|
||||
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 {
|
||||
|
@ -96,21 +96,21 @@ type JSTransaction struct {
|
||||
|
||||
func NewJSTx(tx *types.Transaction, state *state.StateDB) *JSTransaction {
|
||||
hash := ethutil.Bytes2Hex(tx.Hash())
|
||||
receiver := ethutil.Bytes2Hex(tx.Recipient)
|
||||
receiver := ethutil.Bytes2Hex(tx.To())
|
||||
if receiver == "0000000000000000000000000000000000000000" {
|
||||
receiver = ethutil.Bytes2Hex(tx.CreationAddress(state))
|
||||
receiver = ethutil.Bytes2Hex(core.AddressFromMessage(tx))
|
||||
}
|
||||
sender := ethutil.Bytes2Hex(tx.Sender())
|
||||
createsContract := tx.CreatesContract()
|
||||
createsContract := core.MessageCreatesContract(tx)
|
||||
|
||||
var data string
|
||||
if tx.CreatesContract() {
|
||||
data = strings.Join(core.Disassemble(tx.Data), "\n")
|
||||
if createsContract {
|
||||
data = strings.Join(core.Disassemble(tx.Data()), "\n")
|
||||
} 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 {
|
||||
|
@ -134,7 +134,7 @@ func (self *XEth) Transact(key *crypto.KeyPair, to []byte, value, gas, price *et
|
||||
state := self.chainManager.TransState()
|
||||
nonce := state.GetNonce(key.Address())
|
||||
|
||||
tx.Nonce = nonce
|
||||
tx.SetNonce(nonce)
|
||||
tx.Sign(key.PrivateKey)
|
||||
|
||||
// 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)
|
||||
|
||||
if contractCreation {
|
||||
addr := tx.CreationAddress(self.World().State())
|
||||
addr := core.AddressFromMessage(tx)
|
||||
pipelogger.Infof("Contract addr %x\n", addr)
|
||||
}
|
||||
|
||||
@ -163,8 +163,8 @@ func (self *XEth) PushTx(tx *types.Transaction) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if tx.Recipient == nil {
|
||||
addr := tx.CreationAddress(self.World().State())
|
||||
if tx.To() == nil {
|
||||
addr := core.AddressFromMessage(tx)
|
||||
pipelogger.Infof("Contract addr %x\n", addr)
|
||||
return addr, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user