Skip to content

Commit b545f51

Browse files
authored
Merge pull request ethereum#4 from bas-vk/zero-gasprice
cmd,eth enforce gas price of 0
2 parents 7044872 + 9bb4635 commit b545f51

File tree

22 files changed

+108
-786
lines changed

22 files changed

+108
-786
lines changed

accounts/abi/bind/auth.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"io"
2323
"io/ioutil"
2424

25+
"math/big"
26+
2527
"github.com/ethereum/go-ethereum/accounts"
2628
"github.com/ethereum/go-ethereum/common"
2729
"github.com/ethereum/go-ethereum/core/types"
@@ -58,5 +60,6 @@ func NewKeyedTransactor(key *ecdsa.PrivateKey) *TransactOpts {
5860
}
5961
return tx.WithSignature(signature)
6062
},
63+
GasPrice: new(big.Int),
6164
}
6265
}

accounts/abi/bind/base.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
207207
// Create the transaction, sign it and schedule it for execution
208208
var rawTx *types.Transaction
209209
if contract == nil {
210-
rawTx = types.NewContractCreation(nonce, value, gasLimit, gasPrice, input)
210+
rawTx = types.NewContractCreation(nonce, value, gasLimit, nil, input)
211211
} else {
212-
rawTx = types.NewTransaction(nonce, c.address, value, gasLimit, gasPrice, input)
212+
rawTx = types.NewTransaction(nonce, c.address, value, gasLimit, nil, input)
213213
}
214214
if opts.Signer == nil {
215215
return nil, errors.New("no signer to authorize the transaction with")

accounts/abi/bind/util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestWaitDeployed(t *testing.T) {
5959
})
6060

6161
// Create the transaction.
62-
tx := types.NewContractCreation(0, big.NewInt(0), test.gas, big.NewInt(1), common.FromHex(test.code))
62+
tx := types.NewContractCreation(0, big.NewInt(0), test.gas, big.NewInt(0), common.FromHex(test.code))
6363
tx, _ = tx.SignECDSA(testKey)
6464

6565
// Wait for it to get mined in the background.

cmd/geth/main.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ participating.
116116
utils.MaxPeersFlag,
117117
utils.MaxPendingPeersFlag,
118118
utils.EtherbaseFlag,
119-
utils.GasPriceFlag,
120119
utils.AutoDAGFlag,
121120
utils.TargetGasLimitFlag,
122121
utils.NATFlag,
@@ -149,12 +148,6 @@ participating.
149148
utils.MetricsEnabledFlag,
150149
utils.FakePoWFlag,
151150
utils.SolcPathFlag,
152-
utils.GpoMinGasPriceFlag,
153-
utils.GpoMaxGasPriceFlag,
154-
utils.GpoFullBlockRatioFlag,
155-
utils.GpobaseStepDownFlag,
156-
utils.GpobaseStepUpFlag,
157-
utils.GpobaseCorrectionFactorFlag,
158151
utils.ExtraDataFlag,
159152
utils.VoteAccountFlag,
160153
utils.VoteAccountPasswordFlag,

cmd/geth/usage.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,6 @@ var AppHelpFlagGroups = []flagGroup{
134134
utils.NodeKeyHexFlag,
135135
},
136136
},
137-
{
138-
Name: "GAS PRICE ORACLE",
139-
Flags: []cli.Flag{
140-
utils.GpoMinGasPriceFlag,
141-
utils.GpoMaxGasPriceFlag,
142-
utils.GpoFullBlockRatioFlag,
143-
utils.GpobaseStepDownFlag,
144-
utils.GpobaseStepUpFlag,
145-
utils.GpobaseCorrectionFactorFlag,
146-
},
147-
},
148137
{
149138
Name: "VIRTUAL MACHINE",
150139
Flags: []cli.Flag{

cmd/utils/flags.go

Lines changed: 14 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@ var (
169169
Usage: "Public address for block mining rewards (default = first account created)",
170170
Value: "0",
171171
}
172-
GasPriceFlag = cli.StringFlag{
173-
Name: "gasprice",
174-
Usage: "Minimal gas price to accept for mining a transactions",
175-
Value: common.Big0.String(),
176-
}
177172
ExtraDataFlag = cli.StringFlag{
178173
Name: "extradata",
179174
Usage: "Block extra data set by the miner (default = client version)",
@@ -339,38 +334,6 @@ var (
339334
Usage: "Solidity compiler command to be used",
340335
Value: "solc",
341336
}
342-
343-
// Gas price oracle settings
344-
GpoMinGasPriceFlag = cli.StringFlag{
345-
Name: "gpomin",
346-
Usage: "Minimum suggested gas price",
347-
Value: new(big.Int).Mul(big.NewInt(20), common.Shannon).String(),
348-
}
349-
GpoMaxGasPriceFlag = cli.StringFlag{
350-
Name: "gpomax",
351-
Usage: "Maximum suggested gas price",
352-
Value: new(big.Int).Mul(big.NewInt(500), common.Shannon).String(),
353-
}
354-
GpoFullBlockRatioFlag = cli.IntFlag{
355-
Name: "gpofull",
356-
Usage: "Full block threshold for gas price calculation (%)",
357-
Value: 80,
358-
}
359-
GpobaseStepDownFlag = cli.IntFlag{
360-
Name: "gpobasedown",
361-
Usage: "Suggested gas price base step down ratio (1/1000)",
362-
Value: 10,
363-
}
364-
GpobaseStepUpFlag = cli.IntFlag{
365-
Name: "gpobaseup",
366-
Usage: "Suggested gas price base step up ratio (1/1000)",
367-
Value: 100,
368-
}
369-
GpobaseCorrectionFactorFlag = cli.IntFlag{
370-
Name: "gpobasecf",
371-
Usage: "Suggested gas price base correction factor (%)",
372-
Value: 110,
373-
}
374337
// Quorum flags
375338
VoteAccountFlag = cli.StringFlag{
376339
Name: "voteaccount",
@@ -688,27 +651,20 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
688651
}
689652

690653
ethConf := &eth.Config{
691-
Etherbase: MakeEtherbase(stack.AccountManager(), ctx),
692-
ChainConfig: MakeChainConfig(ctx, stack),
693-
SingleBlockMaker: ctx.GlobalBool(SingleBlockMakerFlag.Name),
694-
DatabaseCache: ctx.GlobalInt(CacheFlag.Name),
695-
DatabaseHandles: MakeDatabaseHandles(),
696-
NetworkId: ctx.GlobalInt(NetworkIdFlag.Name),
697-
ExtraData: MakeMinerExtra(extra, ctx),
698-
NatSpec: ctx.GlobalBool(NatspecEnabledFlag.Name),
699-
DocRoot: ctx.GlobalString(DocRootFlag.Name),
700-
EnableJit: jitEnabled,
701-
ForceJit: ctx.GlobalBool(VMForceJitFlag.Name),
702-
GasPrice: common.String2Big(ctx.GlobalString(GasPriceFlag.Name)),
703-
GpoMinGasPrice: common.String2Big(ctx.GlobalString(GpoMinGasPriceFlag.Name)),
704-
GpoMaxGasPrice: common.String2Big(ctx.GlobalString(GpoMaxGasPriceFlag.Name)),
705-
GpoFullBlockRatio: ctx.GlobalInt(GpoFullBlockRatioFlag.Name),
706-
GpobaseStepDown: ctx.GlobalInt(GpobaseStepDownFlag.Name),
707-
GpobaseStepUp: ctx.GlobalInt(GpobaseStepUpFlag.Name),
708-
GpobaseCorrectionFactor: ctx.GlobalInt(GpobaseCorrectionFactorFlag.Name),
709-
SolcPath: ctx.GlobalString(SolcPathFlag.Name),
710-
VoteMinBlockTime: uint(ctx.GlobalInt(VoteMinBlockTimeFlag.Name)),
711-
VoteMaxBlockTime: uint(ctx.GlobalInt(VoteMaxBlockTimeFlag.Name)),
654+
Etherbase: MakeEtherbase(stack.AccountManager(), ctx),
655+
ChainConfig: MakeChainConfig(ctx, stack),
656+
SingleBlockMaker: ctx.GlobalBool(SingleBlockMakerFlag.Name),
657+
DatabaseCache: ctx.GlobalInt(CacheFlag.Name),
658+
DatabaseHandles: MakeDatabaseHandles(),
659+
NetworkId: ctx.GlobalInt(NetworkIdFlag.Name),
660+
ExtraData: MakeMinerExtra(extra, ctx),
661+
NatSpec: ctx.GlobalBool(NatspecEnabledFlag.Name),
662+
DocRoot: ctx.GlobalString(DocRootFlag.Name),
663+
EnableJit: jitEnabled,
664+
ForceJit: ctx.GlobalBool(VMForceJitFlag.Name),
665+
SolcPath: ctx.GlobalString(SolcPathFlag.Name),
666+
VoteMinBlockTime: uint(ctx.GlobalInt(VoteMinBlockTimeFlag.Name)),
667+
VoteMaxBlockTime: uint(ctx.GlobalInt(VoteMaxBlockTimeFlag.Name)),
712668
}
713669

714670
// Override any default configs in dev mode or the test net
@@ -728,9 +684,6 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
728684

729685
case ctx.GlobalBool(DevModeFlag.Name):
730686
ethConf.Genesis = core.OlympicGenesisBlock()
731-
if !ctx.GlobalIsSet(GasPriceFlag.Name) {
732-
ethConf.GasPrice = new(big.Int)
733-
}
734687
ethConf.PowTest = true
735688
}
736689
// Override any global options pertaining to the Ethereum protocol

common/registrar/ethreg/api.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ func (be *registryAPIBackend) Transact(fromStr, toStr, nonceStr, valueStr, gasSt
223223
to = common.HexToAddress(toStr)
224224
value = common.Big(valueStr)
225225
gas *big.Int
226-
price *big.Int
227226
data []byte
228227
contractCreation bool
229228
)
@@ -234,12 +233,6 @@ func (be *registryAPIBackend) Transact(fromStr, toStr, nonceStr, valueStr, gasSt
234233
gas = common.Big(gasStr)
235234
}
236235

237-
if len(gasPriceStr) == 0 {
238-
price = big.NewInt(10000000000000)
239-
} else {
240-
price = common.Big(gasPriceStr)
241-
}
242-
243236
data = common.FromHex(codeStr)
244237
if len(toStr) == 0 {
245238
contractCreation = true
@@ -252,9 +245,9 @@ func (be *registryAPIBackend) Transact(fromStr, toStr, nonceStr, valueStr, gasSt
252245

253246
var tx *types.Transaction
254247
if contractCreation {
255-
tx = types.NewContractCreation(nonce, value, gas, price, data)
248+
tx = types.NewContractCreation(nonce, value, gas, nil, data)
256249
} else {
257-
tx = types.NewTransaction(nonce, to, value, gas, price, data)
250+
tx = types.NewTransaction(nonce, to, value, gas, nil, data)
258251
}
259252

260253
signature, err := be.am.SignEthereum(from, tx.SigHash().Bytes())

core/quorum/block_maker.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package quorum
33
import (
44
"time"
55

6-
"math/big"
7-
86
"github.com/ethereum/go-ethereum/common"
97
"github.com/ethereum/go-ethereum/core"
108
"github.com/ethereum/go-ethereum/core/state"
@@ -64,7 +62,6 @@ func (ps *pendingState) applyTransactions(txs *types.TransactionsByPriorityAndNo
6462
var (
6563
lowGasTxs types.Transactions
6664
failedTxs types.Transactions
67-
gasPrice = new(big.Int).Mul(big.NewInt(20), common.Shannon)
6865
)
6966

7067
var coalescedLogs vm.Logs
@@ -78,14 +75,6 @@ func (ps *pendingState) applyTransactions(txs *types.TransactionsByPriorityAndNo
7875
// during transaction acceptance is the transaction pool.
7976
from, _ := tx.From()
8077

81-
// Ignore any transactions (and accounts subsequently) with low gas limits
82-
if tx.GasPrice().Cmp(gasPrice) < 0 && !ps.ownedAccounts.Has(from) {
83-
// Pop the current low-priced transaction without shifting in the next from the account
84-
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])
85-
lowGasTxs = append(lowGasTxs, tx)
86-
txs.Pop()
87-
continue
88-
}
8978
// Start executing the transaction
9079
ps.state.StartRecord(tx.Hash(), common.Hash{}, 0)
9180

core/quorum/block_voting.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,13 @@ type CreateBlock struct {
8585
// Note, don't forget to call Start.
8686
func NewBlockVoting(bc *core.BlockChain, chainConfig *core.ChainConfig, txpool *core.TxPool, mux *event.TypeMux, db ethdb.Database, accountMgr *accounts.Manager, isSynchronised bool) *BlockVoting {
8787
bv := &BlockVoting{
88-
bc: bc,
89-
cc: chainConfig,
90-
txpool: txpool,
91-
mux: mux,
92-
db: db,
93-
am: accountMgr,
94-
synced: isSynchronised,
95-
gasPrice: new(big.Int).Mul(big.NewInt(10), common.Shannon),
88+
bc: bc,
89+
cc: chainConfig,
90+
txpool: txpool,
91+
mux: mux,
92+
db: db,
93+
am: accountMgr,
94+
synced: isSynchronised,
9695
}
9796

9897
return bv

core/state_processor.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package core
1919
import (
2020
"math/big"
2121

22+
"github.com/ethereum/go-ethereum/common"
2223
"github.com/ethereum/go-ethereum/core/state"
2324
"github.com/ethereum/go-ethereum/core/types"
2425
"github.com/ethereum/go-ethereum/core/vm"
@@ -87,6 +88,11 @@ func ApplyTransaction(config *ChainConfig, bc *BlockChain, gp *GasPool, publicSt
8788
if !tx.IsPrivate() {
8889
privateState = publicState
8990
}
91+
92+
if tx.GasPrice() != nil && tx.GasPrice().Cmp(common.Big0) > 0 {
93+
return nil, nil, nil, ErrInvalidGasPrice
94+
}
95+
9096
_, gas, err := ApplyMessage(NewEnv(publicState, privateState, config, bc, tx, header, cfg), tx, gp)
9197
if err != nil {
9298
return nil, nil, nil, err

core/tx_list_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestStrictTxListAdd(t *testing.T) {
3333

3434
txs := make(types.Transactions, 1024)
3535
for i := 0; i < len(txs); i++ {
36-
txs[i] = transaction(uint64(i), new(big.Int), key)
36+
txs[i] = transaction(uint64(i), new(big.Int), new(big.Int), key)
3737
}
3838
// Insert the transactions in a random order
3939
list := newTxList(true)

core/tx_pool.go

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ var (
3737
// Transaction Pool Errors
3838
ErrInvalidSender = errors.New("Invalid sender")
3939
ErrNonce = errors.New("Nonce too low")
40-
ErrCheap = errors.New("Gas price too low for acceptance")
41-
ErrBalance = errors.New("Insufficient balance")
42-
ErrNonExistentAccount = errors.New("Account does not exist or account balance too low")
40+
ErrInvalidGasPrice = errors.New("Gas price not 0")
4341
ErrInsufficientFunds = errors.New("Insufficient funds for gas * price + value")
4442
ErrIntrinsicGas = errors.New("Intrinsic gas too low")
4543
ErrGasLimit = errors.New("Exceeds block gas limit")
4644
ErrNegativeValue = errors.New("Negative value")
45+
ErrNonExistentAccount = errors.New("Account doesn't exist")
4746
)
4847

4948
var (
@@ -69,7 +68,6 @@ type TxPool struct {
6968
currentState stateFn // The state function which will allow us to do some pre checks
7069
pendingState *state.ManagedState
7170
gasLimit func() *big.Int // The current gas limit function callback
72-
minGasPrice *big.Int
7371
eventMux *event.TypeMux
7472
events event.Subscription
7573
localTx *txSet
@@ -96,10 +94,9 @@ func NewTxPool(config *ChainConfig, eventMux *event.TypeMux, currentStateFn stat
9694
eventMux: eventMux,
9795
currentState: currentStateFn,
9896
gasLimit: gasLimitFn,
99-
minGasPrice: new(big.Int),
10097
pendingState: nil,
10198
localTx: newTxSet(),
102-
events: eventMux.Subscribe(ChainHeadEvent{}, GasPriceChanged{}, RemovedTransactionEvent{}),
99+
events: eventMux.Subscribe(ChainHeadEvent{}, RemovedTransactionEvent{}),
103100
quit: make(chan struct{}),
104101
}
105102

@@ -126,10 +123,6 @@ func (pool *TxPool) eventLoop() {
126123

127124
pool.resetState()
128125
pool.mu.Unlock()
129-
case GasPriceChanged:
130-
pool.mu.Lock()
131-
pool.minGasPrice = ev.Price
132-
pool.mu.Unlock()
133126
case RemovedTransactionEvent:
134127
pool.AddBatch(ev.Txs)
135128
}
@@ -151,8 +144,7 @@ func (pool *TxPool) resetState() {
151144

152145
// validate the pool of pending transactions, this will remove
153146
// any transactions that have been included in the block or
154-
// have been invalidated because of another transaction (e.g.
155-
// higher gas price)
147+
// have been invalidated because of another transaction.
156148
pool.demoteUnexecutables()
157149

158150
// Update all accounts to the latest known pending nonce
@@ -231,8 +223,7 @@ func (pool *TxPool) Pending() map[common.Address]types.Transactions {
231223
return pending
232224
}
233225

234-
// SetLocal marks a transaction as local, skipping gas price
235-
// check against local miner minimum in the future
226+
// SetLocal marks a transaction as local.
236227
func (pool *TxPool) SetLocal(tx *types.Transaction) {
237228
pool.mu.Lock()
238229
defer pool.mu.Unlock()
@@ -242,10 +233,10 @@ func (pool *TxPool) SetLocal(tx *types.Transaction) {
242233
// validateTx checks whether a transaction is valid according
243234
// to the consensus rules.
244235
func (pool *TxPool) validateTx(tx *types.Transaction) error {
245-
local := pool.localTx.contains(tx.Hash())
246-
// Drop transactions under our own minimal accepted gas price
247-
if !local && pool.minGasPrice.Cmp(tx.GasPrice()) > 0 {
248-
return ErrCheap
236+
// due to dual state balances of private accounts cannot be determined.
237+
// only accept transactions with a gas price of 0
238+
if tx.GasPrice().Cmp(common.Big0) != 0 {
239+
return ErrInvalidGasPrice
249240
}
250241

251242
currentState, _, err := pool.currentState()

0 commit comments

Comments
 (0)