Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,10 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
}
if ctx.GlobalIsSet(GasPriceFlag.Name) {
cfg.GasPrice = GlobalBig(ctx, GasPriceFlag.Name)
if len(cfg.GasPrice.Bits()) == 0 { //IsUint64() && cfg.GasPrice.Uint64() == 0 {
common.Gasless = true
log.Info("Gasless enabled. You can run transactions with zero gas fee.")
}
}
if ctx.GlobalIsSet(VMEnableDebugFlag.Name) {
// TODO(fjl): force-enable this in --dev mode
Expand Down
13 changes: 12 additions & 1 deletion common/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import (
var MinGasPrice50x = big.NewInt(12500000000)
var GasPrice50x = big.NewInt(12500000000)

var Gasless = false

func GetGasFee(blockNumber, gas uint64) *big.Int {
if Gasless {
return big.NewInt(0)
}
fee := new(big.Int).SetUint64(gas)
if blockNumber >= uint64(10) { //temp fix trc21issuer test fail
fee = fee.Mul(fee, GasPrice50x)
Expand All @@ -16,15 +21,21 @@ func GetGasFee(blockNumber, gas uint64) *big.Int {
}

func GetGasPrice(number *big.Int) *big.Int {
if Gasless {
return big.NewInt(0)
}
if number == nil {
return new(big.Int).Set(TRC21GasPrice)
}
return new(big.Int).Set(GasPrice50x)
}

func GetMinGasPrice(number *big.Int) *big.Int {
if Gasless {
return big.NewInt(0)
}
if number == nil {
return new(big.Int).Set(MinGasPrice)
}
return new(big.Int).Set(MinGasPrice50x)
}
}
4 changes: 3 additions & 1 deletion core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,9 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {

// Check zero gas price.
if tx.GasPrice().Cmp(new(big.Int).SetInt64(0)) == 0 {
return ErrZeroGasPrice
if !common.Gasless {
return ErrZeroGasPrice
}
}

// under min gas price
Expand Down
3 changes: 3 additions & 0 deletions eth/gasprice/gasprice.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func NewOracle(backend ethapi.Backend, params Config) *Oracle {

// SuggestPrice returns the recommended gas price.
func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
if common.Gasless {
return big.NewInt(0), nil
}
gpo.cacheLock.RLock()
lastHead := gpo.lastHead
lastPrice := gpo.lastPrice
Expand Down
Loading