mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-25 12:57:17 +00:00
Minor improvements and bug fixes
* Fixed VM base bug
This commit is contained in:
parent
0651af9dfd
commit
1c85d8c66b
@ -34,12 +34,12 @@ func (s *State) Reset() {
|
||||
|
||||
// Syncs the trie and all siblings
|
||||
func (s *State) Sync() {
|
||||
s.trie.Sync()
|
||||
|
||||
// Sync all nested states
|
||||
for _, state := range s.states {
|
||||
state.Sync()
|
||||
}
|
||||
|
||||
s.trie.Sync()
|
||||
}
|
||||
|
||||
// Purges the current trie.
|
||||
|
@ -117,6 +117,7 @@ func (sm *StateManager) ApplyTransactions(block *Block, txs []*Transaction) {
|
||||
contract := sm.MakeContract(tx)
|
||||
if contract != nil {
|
||||
sm.EvalScript(contract.Init(), contract, tx, block)
|
||||
fmt.Printf("state root of contract %x\n", contract.State().Root())
|
||||
} else {
|
||||
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)
|
||||
sm.procState.UpdateStateObject(caller)
|
||||
sm.procState.UpdateStateObject(object)
|
||||
}
|
||||
|
@ -100,6 +100,10 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract
|
||||
// Get the 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
|
||||
// funds won't invalidate this transaction but simple ignores it.
|
||||
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())
|
||||
}
|
||||
|
||||
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
|
||||
receiver := block.state.GetAccount(tx.Recipient)
|
||||
sender.Nonce += 1
|
||||
|
@ -82,14 +82,15 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
|
||||
pc := big.NewInt(0)
|
||||
// Current step count
|
||||
step := 0
|
||||
// The base for all big integer arithmetic
|
||||
base := new(big.Int)
|
||||
|
||||
if ethutil.Config.Debug {
|
||||
ethutil.Config.Log.Debugf("# op\n")
|
||||
}
|
||||
|
||||
for {
|
||||
// The base for all big integer arithmetic
|
||||
base := new(big.Int)
|
||||
|
||||
step++
|
||||
// Get the memory location of pc
|
||||
val := closure.Get(pc)
|
||||
@ -390,6 +391,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
|
||||
require(1)
|
||||
loc := stack.Pop()
|
||||
val := closure.GetMem(loc)
|
||||
fmt.Printf("load %x = %v\n", loc.Bytes(), val.BigInt())
|
||||
stack.Push(val.BigInt())
|
||||
case oSSTORE:
|
||||
require(2)
|
||||
|
Loading…
Reference in New Issue
Block a user