aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/state_manager.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-12 03:56:59 +0800
committerobscuren <geffobscura@gmail.com>2014-06-12 03:56:59 +0800
commit8a2e50ab2a6c903a6ab3ab10a74c37e1f3b8f3f1 (patch)
tree3cf67a559ef450500ddfd7df9d457f3e1a994caf /ethchain/state_manager.go
parent9ee6295c752a518603de01e4feaec787c61a5dcf (diff)
parent1938bfcddfd2722880a692c59cad344b611711c8 (diff)
downloadgo-tangerine-8a2e50ab2a6c903a6ab3ab10a74c37e1f3b8f3f1.tar
go-tangerine-8a2e50ab2a6c903a6ab3ab10a74c37e1f3b8f3f1.tar.gz
go-tangerine-8a2e50ab2a6c903a6ab3ab10a74c37e1f3b8f3f1.tar.bz2
go-tangerine-8a2e50ab2a6c903a6ab3ab10a74c37e1f3b8f3f1.tar.lz
go-tangerine-8a2e50ab2a6c903a6ab3ab10a74c37e1f3b8f3f1.tar.xz
go-tangerine-8a2e50ab2a6c903a6ab3ab10a74c37e1f3b8f3f1.tar.zst
go-tangerine-8a2e50ab2a6c903a6ab3ab10a74c37e1f3b8f3f1.zip
Merge branch 'develop' into interop
Conflicts: peer.go
Diffstat (limited to 'ethchain/state_manager.go')
-rw-r--r--ethchain/state_manager.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index e783ffdd8..9631b55fe 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -188,6 +188,8 @@ func (sm *StateManager) ApplyTransactions(coinbase []byte, state *State, block *
// Process each transaction/contract
var receipts []*Receipt
var validTxs []*Transaction
+ var ignoredTxs []*Transaction // Transactions which go over the gasLimit
+
totalUsedGas := big.NewInt(0)
for _, tx := range txs {
@@ -196,6 +198,12 @@ func (sm *StateManager) ApplyTransactions(coinbase []byte, state *State, block *
if IsNonceErr(err) {
continue
}
+ if IsGasLimitErr(err) {
+ ignoredTxs = append(ignoredTxs, tx)
+ // We need to figure out if we want to do something with thse txes
+ ethutil.Config.Log.Debugln("Gastlimit:", err)
+ continue
+ }
ethutil.Config.Log.Infoln(err)
}
@@ -207,6 +215,9 @@ func (sm *StateManager) ApplyTransactions(coinbase []byte, state *State, block *
validTxs = append(validTxs, tx)
}
+ // Update the total gas used for the block (to be mined)
+ block.GasUsed = totalUsedGas
+
return receipts, validTxs
}
@@ -226,6 +237,7 @@ func (sm *StateManager) ApplyTransaction(coinbase []byte, state *State, block *B
script []byte
)
totalGasUsed = big.NewInt(0)
+ snapshot := state.Snapshot()
ca := state.GetAccount(coinbase)
// Apply the transaction to the current state
@@ -266,6 +278,14 @@ func (sm *StateManager) ApplyTransaction(coinbase []byte, state *State, block *B
}
}
+ parent := sm.bc.GetBlock(block.PrevHash)
+ total := new(big.Int).Add(block.GasUsed, totalGasUsed)
+ limit := block.CalcGasLimit(parent)
+ if total.Cmp(limit) > 0 {
+ state.Revert(snapshot)
+ err = GasLimitError(total, limit)
+ }
+
return
}