-
Notifications
You must be signed in to change notification settings - Fork 0
BlockMaker BlockVoting StateProcessor StateTransition changes
Now some of these changes are more specific to Quorum, like the blockmaker and blockvoting, but the StateProcessor and StateTransition changes are pretty much the standard geth code.
Like I said quorum did a pretty good job of separating out blockmakers, so the changes that need to made here are pretty minor.
First off, it is simply adding the math/big go library for use in the gasPrice variable in applyTransactions
...
+ "math/big"
...
So now in our function applyTransactions we can basically we are setting a gasPrice here for use.
...
+ gasPrice = new(big.Int).Mul(big.NewInt(20), common.Shannon)
...
We do this because we simply want a gasPrice we can compare to our transaction gasPrice we want to make sure we are not accepting transactions with too low of a gas price. Like this:
...
+ //Ignore any transactions (and accounts) with low gas limits --andrew
+ if tx.GasPrice().Cmp(gasPrice) < 0 && !ps.ownedAccounts.Has(from) {
+ glog.V(logger.Info).Infof("Transaction (%x) below gas price (tx=%v ask=%v). All sequential txs from this address(%x) will be ignored\n", tx.Hash().Bytes()[:4], common.CurrencyToString(tx.GasPrice()), common.CurrencyToString(gasPrice), from[:4])
+ lowGasTxs = append(lowGasTxs, tx)
+ txs.Pop()
+ continue
+ }
...
Now all the changes in blockMaker are done. Now on to blockVoting here we are just making sure to ensure our block votes have a gasPrice
...
+ gasPrice: new(big.Int).Mul(big.NewInt(10), common.Shannon),
...
We also need to make sure our nodes can make sense of the state of the blockchain with gasPrice being a thing, so we also need to account for that, and so we delete the following line in the ApplyTransaction function.
...
- if tx.GasPrice() != nil && tx.GasPrice().Cmp(common.Big0) > 0 {
- return nil, nil, nil, ErrInvalidGasPrice
- }
...
In state_transition things are a bit trickier. I need to take a closer a look at the changes here to account for private transactions because I think it might break them, but for now we just make sure our transactions are not private when updating with gasPrice
...
- self.refundGas()
- publicState.AddBalance(self.env.Coinbase(), new(big.Int).Mul(self.gasUsed(), self.gasPrice))
+ if !isPrivate{
+ self.refundGas()
+ publicState.AddBalance(self.env.Coinbase(), new(big.Int).Mul(self.gasUsed(), self.gasPrice))
+ }
...