Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

temp pr for cicd #189

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ else
echo "No RPC API is enabled. If you wanna enable any API calls, provide values to RPC_API. Available options are admin,db,eth,debug,miner,net,shh,txpool,personal,web3,XDPoS"
fi

# Subnet gasprice config
if [[ ! -z $GASPRICE ]]; then
echo "Set Gasprice ${GASPRICE}"
params="$params --gasprice ${GASPRICE}"
else
params="$params --gasprice 1"
echo "Set Gasprice default"
fi

if [ ! -d $DATA_DIR/XDC/chaindata ]
then
if test -z "$PRIVATE_KEY"
Expand Down Expand Up @@ -142,7 +151,6 @@ XDC $params \
--rpcaddr 0.0.0.0 \
--rpcvhosts "*" \
--password /work/.pwd \
--gasprice "1" \
--targetgaslimit "420000000" \
--ws --wsaddr=0.0.0.0 \
--mine \
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