diff --git a/consensus/satoshi/satoshi.go b/consensus/satoshi/satoshi.go index 6abfd7147..ff4f75f16 100644 --- a/consensus/satoshi/satoshi.go +++ b/consensus/satoshi/satoshi.go @@ -269,7 +269,6 @@ func New( candidateHubABI: cABI, signer: types.NewEIP155Signer(chainConfig.ChainID), } - return c } diff --git a/core/types/transaction.go b/core/types/transaction.go index 38a01b643..080ec3770 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -28,7 +28,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/eth/gasprice/locaFeeMarket" + "github.com/ethereum/go-ethereum/eth/gasprice/lfm" "github.com/ethereum/go-ethereum/rlp" ) @@ -170,7 +170,7 @@ func (tx *Transaction) UnmarshalBinary(b []byte) error { //@lfm RPC invocation route: adjust tx gas price if data.OrigGasPrice == nil { data.OrigGasPrice = data.GasPrice - data.GasPrice = locaFeeMarket.AdjustGasPrice(data.Gas, data.Value, data.To, data.Data, data.OrigGasPrice) + data.GasPrice = lfm.AdjustGasPrice(data.Gas, data.Value, data.To, data.Data, data.OrigGasPrice) } tx.setDecoded(&data, len(b)) return nil diff --git a/eth/gasprice/locaFeeMarket/nativediscount.go b/eth/gasprice/lfm/nativediscount.go similarity index 78% rename from eth/gasprice/locaFeeMarket/nativediscount.go rename to eth/gasprice/lfm/nativediscount.go index f00894b7e..895ab902e 100644 --- a/eth/gasprice/locaFeeMarket/nativediscount.go +++ b/eth/gasprice/lfm/nativediscount.go @@ -1,4 +1,4 @@ -package locaFeeMarket +package lfm import ( "bytes" @@ -49,8 +49,10 @@ var ( debugDiscountedGasPrice = new(big.Int).SetUint64(18_000_000_000) errNotFunctionInvocation = errors.New("tx is not a function invocation") +) - //------- +// white-listed erc20 map +var ( btcLstContract = common.HexToAddress("0xTBD") internalErc20Whitelist = map[common.Address]bool{ @@ -109,66 +111,6 @@ func calcCoreTransferDiscountedGasPrice(networkGasPrice *big.Int) *big.Int { return internalCalcDiscountedGasPrice(networkGasPrice) } -func obsolete__internalCalcDiscountedGasPrice(networkGasPrice *big.Int) *big.Int { - networkPrice := networkGasPrice.Uint64() - const MEAN = historicalMeanGasPrice - const LOW_WATERMARK = (700*MEAN)/1000 - var discounted uint64 - - switch { - case networkPrice <= LOW_WATERMARK: - discounted = networkPrice // no discount - case networkPrice <= MEAN: - discounted = LOW_WATERMARK - case networkPrice <= MEAN+789473684: - discounted = MEAN + 220850187 - case networkPrice <= MEAN+1578947368: - discounted = MEAN + 229206660 - case networkPrice <= MEAN+2368421053: - discounted = MEAN + 237511346 - case networkPrice <= MEAN+3157894737: - discounted = MEAN + 245739149 - case networkPrice <= MEAN+3947368421: - discounted = MEAN + 253865910 - case networkPrice <= MEAN+4736842105: - discounted = MEAN + 261868680 - case networkPrice <= MEAN+5526315789: - discounted = MEAN + 269725961 - case networkPrice <= MEAN+6315789474: - discounted = MEAN + 277417917 - case networkPrice <= MEAN+7105263158: - discounted = MEAN + 284926545 - case networkPrice <= MEAN+7894736842: - discounted = MEAN + 292235799 - case networkPrice <= MEAN+8684210526: - discounted = MEAN + 299331682 - case networkPrice <= MEAN+9473684211: - discounted = MEAN + 306202288 - case networkPrice <= MEAN+10263157895: - discounted = MEAN + 312837812 - case networkPrice <= MEAN+11052631579: - discounted = MEAN + 319230518 - case networkPrice <= MEAN+11842105263: - discounted = MEAN + 325374683 - case networkPrice <= MEAN+12631578947: - discounted = MEAN + 331266505 - case networkPrice <= MEAN+13421052632: - discounted = MEAN + 336903992 - case networkPrice <= MEAN+14210526316: - discounted = MEAN + 342286837 - default: - discounted = maxDiscountedGasPrice - } - - if discounted != networkPrice { - discounted = min(discounted, networkPrice) // sanity check: discounted gas-price cannot exceed networkPrice - discounted = min(discounted, maxDiscountedGasPrice) // sanity check: discounted gas-price cannot exceed maxDiscountedGasPrice value - discounted = max(discounted, networkPrice/2) // sanity check: discounted gas-price cannot go below half of the networkPrice price - } - return new(big.Int).SetUint64(discounted) -} - - /** discrete steps for the sigmoid function sig(x) = 1 / (1 + e^(-3 * (x - 0.8))) where x denotes the historical mean, slightly modified for simplicity @@ -302,17 +244,3 @@ func validApproveData(functionSelector []byte, dataLen int) bool { func eq(a []byte, b []byte) bool { return bytes.Equal(a, b) } - -func min(a, b uint64) uint64 { - if a < b { - return a - } - return b -} - -func max(a, b uint64) uint64 { - if a > b { - return a - } - return b -} \ No newline at end of file diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index d10ee460a..1c6944af4 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -43,7 +43,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/eth/gasprice/locaFeeMarket" + "github.com/ethereum/go-ethereum/eth/gasprice/lfm" "github.com/ethereum/go-ethereum/eth/tracers/logger" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/p2p" @@ -1006,7 +1006,7 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr hi uint64 cap uint64 ) - args.GasPrice = locaFeeMarket.AdjustGasPriceForEstimation(args.GasPrice, args.Gas, args.Value, args.To, args.data()) //@lfm + args.GasPrice = lfm.AdjustGasPriceForEstimation(args.GasPrice, args.Gas, args.Value, args.To, args.data()) //@lfm // Use zero address if sender unspecified. if args.From == nil { args.From = new(common.Address)