From c37c82e259a3d08c58d34aa60652b63b5796a5be Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 19:47:10 +0200 Subject: [PATCH] core: HARD FORK. GU_b is no longer reduces by refunds. --- core/state_transition.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index aacf537996..feeb4316d3 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -255,10 +255,18 @@ func (self *StateTransition) refundGas() { uhalf := remaining.Div(self.gasUsed(), common.Big2) refund := common.BigMin(uhalf, self.state.Refunds()) - self.gas.Add(self.gas, refund) - self.state.AddBalance(sender.Address(), refund.Mul(refund, self.gasPrice)) - coinbase.AddGas(self.gas, self.gasPrice) + gas := new(big.Int).Set(self.gas) + gas.Add(gas, refund) + self.state.AddBalance(sender.Address(), refund.Mul(refund, self.gasPrice)) + coinbase.AddGas(gas, self.gasPrice) + // XXX !!HARD FORK!! XXX + // Above 830.000 receipts should no longer have have reduced gas used + // from refunds. This prevents clever tricks to add 2x more used gas in + // a block. + if self.env.BlockNumber().Cmp(big.NewInt(830000)) < 0 { + self.gas.Set(gas) + } } func (self *StateTransition) gasUsed() *big.Int {