parent
0651af9dfd
commit
1c85d8c66b
|
@ -34,12 +34,12 @@ func (s *State) Reset() {
|
||||||
|
|
||||||
// Syncs the trie and all siblings
|
// Syncs the trie and all siblings
|
||||||
func (s *State) Sync() {
|
func (s *State) Sync() {
|
||||||
s.trie.Sync()
|
|
||||||
|
|
||||||
// Sync all nested states
|
// Sync all nested states
|
||||||
for _, state := range s.states {
|
for _, state := range s.states {
|
||||||
state.Sync()
|
state.Sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.trie.Sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Purges the current trie.
|
// Purges the current trie.
|
||||||
|
|
|
@ -117,6 +117,7 @@ func (sm *StateManager) ApplyTransactions(block *Block, txs []*Transaction) {
|
||||||
contract := sm.MakeContract(tx)
|
contract := sm.MakeContract(tx)
|
||||||
if contract != nil {
|
if contract != nil {
|
||||||
sm.EvalScript(contract.Init(), contract, tx, block)
|
sm.EvalScript(contract.Init(), contract, tx, block)
|
||||||
|
fmt.Printf("state root of contract %x\n", contract.State().Root())
|
||||||
} else {
|
} else {
|
||||||
ethutil.Config.Log.Infoln("[STATE] Unable to create contract")
|
ethutil.Config.Log.Infoln("[STATE] Unable to create contract")
|
||||||
}
|
}
|
||||||
|
@ -332,4 +333,5 @@ func (sm *StateManager) EvalScript(script []byte, object *StateObject, tx *Trans
|
||||||
|
|
||||||
// Update the account (refunds)
|
// Update the account (refunds)
|
||||||
sm.procState.UpdateStateObject(caller)
|
sm.procState.UpdateStateObject(caller)
|
||||||
|
sm.procState.UpdateStateObject(object)
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,10 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract
|
||||||
// Get the sender
|
// Get the sender
|
||||||
sender := block.state.GetAccount(tx.Sender())
|
sender := block.state.GetAccount(tx.Sender())
|
||||||
|
|
||||||
|
if sender.Nonce != tx.Nonce {
|
||||||
|
return fmt.Errorf("[TXPL] Invalid account nonce, state nonce is %d transaction nonce is %d instead", sender.Nonce, tx.Nonce)
|
||||||
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
totAmount := new(big.Int).Add(tx.Value, new(big.Int).Mul(TxFee, TxFeeRat))
|
totAmount := new(big.Int).Add(tx.Value, new(big.Int).Mul(TxFee, TxFeeRat))
|
||||||
|
@ -107,10 +111,6 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract
|
||||||
return fmt.Errorf("[TXPL] Insufficient amount in sender's (%x) account", tx.Sender())
|
return fmt.Errorf("[TXPL] Insufficient amount in sender's (%x) account", tx.Sender())
|
||||||
}
|
}
|
||||||
|
|
||||||
if sender.Nonce != tx.Nonce {
|
|
||||||
return fmt.Errorf("[TXPL] Invalid account nonce, state nonce is %d transaction nonce is %d instead", sender.Nonce, tx.Nonce)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the receiver
|
// Get the receiver
|
||||||
receiver := block.state.GetAccount(tx.Recipient)
|
receiver := block.state.GetAccount(tx.Recipient)
|
||||||
sender.Nonce += 1
|
sender.Nonce += 1
|
||||||
|
|
|
@ -82,14 +82,15 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
|
||||||
pc := big.NewInt(0)
|
pc := big.NewInt(0)
|
||||||
// Current step count
|
// Current step count
|
||||||
step := 0
|
step := 0
|
||||||
// The base for all big integer arithmetic
|
|
||||||
base := new(big.Int)
|
|
||||||
|
|
||||||
if ethutil.Config.Debug {
|
if ethutil.Config.Debug {
|
||||||
ethutil.Config.Log.Debugf("# op\n")
|
ethutil.Config.Log.Debugf("# op\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
// The base for all big integer arithmetic
|
||||||
|
base := new(big.Int)
|
||||||
|
|
||||||
step++
|
step++
|
||||||
// Get the memory location of pc
|
// Get the memory location of pc
|
||||||
val := closure.Get(pc)
|
val := closure.Get(pc)
|
||||||
|
@ -390,6 +391,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
|
||||||
require(1)
|
require(1)
|
||||||
loc := stack.Pop()
|
loc := stack.Pop()
|
||||||
val := closure.GetMem(loc)
|
val := closure.GetMem(loc)
|
||||||
|
fmt.Printf("load %x = %v\n", loc.Bytes(), val.BigInt())
|
||||||
stack.Push(val.BigInt())
|
stack.Push(val.BigInt())
|
||||||
case oSSTORE:
|
case oSSTORE:
|
||||||
require(2)
|
require(2)
|
||||||
|
|
Loading…
Reference in New Issue