aboutsummaryrefslogtreecommitdiffstats
path: root/chain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-11-12 08:36:36 +0800
committerobscuren <geffobscura@gmail.com>2014-11-12 08:36:36 +0800
commit60cdb1148c404218846fd39331690658168f4e04 (patch)
tree229e68d7dfdaccb12e0b6b9ff19c5c14b9f9c603 /chain
parent9bb1ac7564ff0588f33a1eb43e76f40664d9e527 (diff)
downloadgo-tangerine-60cdb1148c404218846fd39331690658168f4e04.tar.gz
go-tangerine-60cdb1148c404218846fd39331690658168f4e04.tar.zst
go-tangerine-60cdb1148c404218846fd39331690658168f4e04.zip
Transaction execution fixes
Diffstat (limited to 'chain')
-rw-r--r--chain/block.go8
-rw-r--r--chain/block_manager.go16
-rw-r--r--chain/chain_manager.go2
-rw-r--r--chain/state_transition.go2
4 files changed, 14 insertions, 14 deletions
diff --git a/chain/block.go b/chain/block.go
index 16975a2fe..23a7c63a2 100644
--- a/chain/block.go
+++ b/chain/block.go
@@ -319,8 +319,8 @@ func (block *Block) Trie() *trie.Trie {
return block.state.Trie
}
-func (block *Block) GetRoot() interface{} {
- return block.state.Trie.Root
+func (block *Block) Root() interface{} {
+ return block.state.Root()
}
func (block *Block) Diff() *big.Int {
@@ -340,7 +340,7 @@ func (block *Block) miningHeader() []interface{} {
// Coinbase address
block.Coinbase,
// root state
- block.state.Trie.Root,
+ block.Root(),
// tx root
block.TxSha,
// Sha of tx
@@ -393,7 +393,7 @@ func (block *Block) String() string {
block.PrevHash,
block.UncleSha,
block.Coinbase,
- block.state.Trie.Root,
+ block.Root(),
block.TxSha,
block.ReceiptSha,
block.LogsBloom,
diff --git a/chain/block_manager.go b/chain/block_manager.go
index 4431e3ba9..a1c75fd93 100644
--- a/chain/block_manager.go
+++ b/chain/block_manager.go
@@ -161,7 +161,7 @@ done:
cumulative := new(big.Int).Set(totalUsedGas.Add(totalUsedGas, txGas))
bloom := ethutil.LeftPadBytes(LogsBloom(state.Logs()).Bytes(), 64)
receipt := &Receipt{ethutil.CopyBytes(state.Root()), cumulative, bloom, state.Logs()}
- //fmt.Println(receipt)
+ fmt.Println(receipt)
// Notify all subscribers
go self.eth.EventMux().Post(TxPostEvent{tx})
@@ -217,13 +217,11 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
}
//block.SetReceipts(receipts)
- /*
- txSha := DeriveSha(block.transactions)
- if bytes.Compare(txSha, block.TxSha) != 0 {
- err = fmt.Errorf("Error validating transaction sha. Received %x, got %x", block.TxSha, txSha)
- return
- }
- */
+ txSha := DeriveSha(block.transactions)
+ if bytes.Compare(txSha, block.TxSha) != 0 {
+ err = fmt.Errorf("Error validating transaction sha. Received %x, got %x", block.TxSha, txSha)
+ return
+ }
receiptSha := DeriveSha(receipts)
if bytes.Compare(receiptSha, block.ReceiptSha) != 0 {
@@ -250,7 +248,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
state.Update()
if !block.State().Cmp(state) {
- err = fmt.Errorf("Invalid merkle root.\nrec: %x\nis: %x", block.State().Trie.Root, state.Trie.Root)
+ err = fmt.Errorf("Invalid merkle root.\nrec: %x\nis: %x", block.State().Root(), state.Root())
return
}
diff --git a/chain/chain_manager.go b/chain/chain_manager.go
index 077db649f..710d96bef 100644
--- a/chain/chain_manager.go
+++ b/chain/chain_manager.go
@@ -47,7 +47,7 @@ func (bc *ChainManager) NewBlock(coinbase []byte) *Block {
hash := ZeroHash256
if bc.CurrentBlock != nil {
- root = bc.CurrentBlock.state.Trie.Root
+ root = bc.CurrentBlock.Root()
hash = bc.LastBlockHash
}
diff --git a/chain/state_transition.go b/chain/state_transition.go
index be117cf29..c208a9188 100644
--- a/chain/state_transition.go
+++ b/chain/state_transition.go
@@ -247,6 +247,8 @@ func (self *StateTransition) Eval(msg *state.Message, script []byte, context *st
)
evm := vm.New(env, vm.DebugVmTy)
+ // TMP this will change in the refactor
+ callerClosure.SetExecution(vm.NewExecution(evm, nil, nil, nil, nil, self.tx.Value))
ret, _, err = callerClosure.Call(evm, self.tx.Data)
return