mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-14 13:51:21 +00:00
state: fireEvents flag on ExecTx and fixes for GetAccount
This commit is contained in:
@ -53,7 +53,9 @@ func (cache *BlockCache) GetAccount(addr []byte) *ac.Account {
|
|||||||
return acc
|
return acc
|
||||||
} else {
|
} else {
|
||||||
acc = cache.backend.GetAccount(addr)
|
acc = cache.backend.GetAccount(addr)
|
||||||
cache.accounts[string(addr)] = accountInfo{acc, nil, false, false}
|
if acc != nil {
|
||||||
|
cache.accounts[string(addr)] = accountInfo{acc, nil, false, false}
|
||||||
|
}
|
||||||
return acc
|
return acc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,7 +189,7 @@ func (cache *BlockCache) Sync() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if acc == nil {
|
if acc == nil {
|
||||||
panic(Fmt("Account should not be nil for addr: %X", acc.Address))
|
panic(Fmt("Account should not be nil for addr: %x", addrStr))
|
||||||
}
|
}
|
||||||
if storage != nil {
|
if storage != nil {
|
||||||
newStorageRoot := storage.Save()
|
newStorageRoot := storage.Save()
|
||||||
|
@ -296,6 +296,8 @@ func ExecTx(blockCache *BlockCache, tx_ types.Tx, runCall, fireEvents bool) erro
|
|||||||
// TODO: do something with fees
|
// TODO: do something with fees
|
||||||
fees := uint64(0)
|
fees := uint64(0)
|
||||||
_s := blockCache.State() // hack to access validators and event switch.
|
_s := blockCache.State() // hack to access validators and event switch.
|
||||||
|
nilSwitch := _s.evsw == nil
|
||||||
|
fireEvents = fireEvents && !nilSwitch
|
||||||
|
|
||||||
// Exec tx
|
// Exec tx
|
||||||
switch tx := tx_.(type) {
|
switch tx := tx_.(type) {
|
||||||
@ -424,7 +426,8 @@ func ExecTx(blockCache *BlockCache, tx_ types.Tx, runCall, fireEvents bool) erro
|
|||||||
|
|
||||||
txCache.UpdateAccount(caller) // because we adjusted by input above, and bumped nonce maybe.
|
txCache.UpdateAccount(caller) // because we adjusted by input above, and bumped nonce maybe.
|
||||||
txCache.UpdateAccount(callee) // because we adjusted by input above.
|
txCache.UpdateAccount(callee) // because we adjusted by input above.
|
||||||
vmach := vm.NewVM(txCache, params, caller.Address)
|
vmach := vm.NewVM(txCache, params, caller.Address, account.SignBytes(tx))
|
||||||
|
vmach.SetEventSwitch(_s.evsw)
|
||||||
// NOTE: Call() transfers the value from caller to callee iff call succeeds.
|
// NOTE: Call() transfers the value from caller to callee iff call succeeds.
|
||||||
|
|
||||||
ret, err := vmach.Call(caller, callee, code, tx.Data, value, &gas)
|
ret, err := vmach.Call(caller, callee, code, tx.Data, value, &gas)
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
func execTxWithState(state *State, tx types.Tx, runCall bool) error {
|
func execTxWithState(state *State, tx types.Tx, runCall bool) error {
|
||||||
cache := NewBlockCache(state)
|
cache := NewBlockCache(state)
|
||||||
err := ExecTx(cache, tx, runCall)
|
err := ExecTx(cache, tx, runCall, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
|
@ -30,9 +30,13 @@ func (cache *TxCache) GetAccount(addr Word256) *vm.Account {
|
|||||||
acc, removed := vmUnpack(cache.accounts[addr])
|
acc, removed := vmUnpack(cache.accounts[addr])
|
||||||
if removed {
|
if removed {
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else if acc == nil {
|
||||||
return acc
|
acc2 := cache.backend.GetAccount(addr.Prefix(20))
|
||||||
|
if acc2 != nil {
|
||||||
|
return toVMAccount(acc2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return acc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cache *TxCache) UpdateAccount(acc *vm.Account) {
|
func (cache *TxCache) UpdateAccount(acc *vm.Account) {
|
||||||
|
Reference in New Issue
Block a user