mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 13:44:31 +00:00
Merge pull request #291 from gzliudan/fix-issue-288
Increase gas price from 250000000 to 12500000000
This commit is contained in:
commit
1718a5b66b
19 changed files with 98 additions and 73 deletions
|
|
@ -128,7 +128,7 @@ func (c *BoundContract) Call(opts *CallOpts, result interface{}, method string,
|
|||
return err
|
||||
}
|
||||
var (
|
||||
msg = XDPoSChain.CallMsg{From: opts.From, To: &c.address, Data: input, GasPrice: common.MinGasPrice, Gas: uint64(4200000)}
|
||||
msg = XDPoSChain.CallMsg{From: opts.From, To: &c.address, Data: input, GasPrice: common.MinGasPrice50x, Gas: uint64(4200000)}
|
||||
ctx = ensureContext(opts.Context)
|
||||
code []byte
|
||||
output []byte
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
|
|||
common.MinGasPrice = big.NewInt(gasPrice)
|
||||
}
|
||||
}
|
||||
common.MinGasPrice50x = common.MinGasPrice50x.Mul(common.MinGasPrice, big.NewInt(50))
|
||||
|
||||
// read passwords from environment
|
||||
passwords := []string{}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ var BaseTopUp = big.NewInt(100)
|
|||
var BaseRecall = big.NewInt(100)
|
||||
var TIPTRC21Fee = big.NewInt(38383838)
|
||||
var TIPTRC21FeeTestnet = big.NewInt(38383838)
|
||||
var BlockNumberGas50x = big.NewInt(TIPTRC21Fee.Int64() + 30000000)
|
||||
var LimitTimeFinality = uint64(30) // limit in 30 block
|
||||
|
||||
var IgnoreSignerCheckBlockArray = map[uint64]bool{
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ var BaseTopUp = big.NewInt(100)
|
|||
var BaseRecall = big.NewInt(100)
|
||||
var TIPTRC21Fee = big.NewInt(13523400)
|
||||
var TIPTRC21FeeTestnet = big.NewInt(225000)
|
||||
var BlockNumberGas50x = big.NewInt(11818181)
|
||||
var LimitTimeFinality = uint64(30) // limit in 30 block
|
||||
|
||||
var IgnoreSignerCheckBlockArray = map[uint64]bool{
|
||||
|
|
|
|||
34
common/gas.go
Normal file
34
common/gas.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package common
|
||||
|
||||
import "math/big"
|
||||
|
||||
var MinGasPrice50x = big.NewInt(12500000000)
|
||||
var GasPrice50x = big.NewInt(12500000000)
|
||||
|
||||
func GetGasFee(blockNumber, gas uint64) *big.Int {
|
||||
fee := new(big.Int).SetUint64(gas)
|
||||
|
||||
if blockNumber >= BlockNumberGas50x.Uint64() {
|
||||
fee = fee.Mul(fee, GasPrice50x)
|
||||
} else if blockNumber > TIPTRC21Fee.Uint64() {
|
||||
fee = fee.Mul(fee, TRC21GasPrice)
|
||||
}
|
||||
|
||||
return fee
|
||||
}
|
||||
|
||||
func GetGasPrice(number *big.Int) *big.Int {
|
||||
if number == nil || number.Cmp(BlockNumberGas50x) < 0 {
|
||||
return new(big.Int).Set(TRC21GasPrice)
|
||||
} else {
|
||||
return new(big.Int).Set(GasPrice50x)
|
||||
}
|
||||
}
|
||||
|
||||
func GetMinGasPrice(number *big.Int) *big.Int {
|
||||
if number == nil || number.Cmp(BlockNumberGas50x) < 0 {
|
||||
return new(big.Int).Set(MinGasPrice)
|
||||
} else {
|
||||
return new(big.Int).Set(MinGasPrice50x)
|
||||
}
|
||||
}
|
||||
|
|
@ -4,15 +4,16 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind"
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/common/hexutil"
|
||||
"github.com/XinFinOrg/XDPoSChain/contracts/trc21issuer"
|
||||
"github.com/XinFinOrg/XDPoSChain/contracts/trc21issuer/simulation"
|
||||
"github.com/XinFinOrg/XDPoSChain/ethclient"
|
||||
"log"
|
||||
"math/big"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -48,11 +49,10 @@ func airDropTokenToAccountNoXDC() {
|
|||
if err != nil {
|
||||
log.Fatal("can't transaction's receipt ", err, "hash", tx.Hash().Hex())
|
||||
}
|
||||
fee := big.NewInt(0).SetUint64(hexutil.MustDecodeUint64(receipt["gasUsed"].(string)))
|
||||
if hexutil.MustDecodeUint64(receipt["blockNumber"].(string)) > common.TIPTRC21Fee.Uint64() {
|
||||
fee = fee.Mul(fee, common.TRC21GasPrice)
|
||||
}
|
||||
fmt.Println("fee", fee.Uint64(), "number", hexutil.MustDecodeUint64(receipt["blockNumber"].(string)))
|
||||
gasUsed := hexutil.MustDecodeUint64(receipt["gasUsed"].(string))
|
||||
blockNumber := hexutil.MustDecodeUint64(receipt["blockNumber"].(string))
|
||||
fee := common.GetGasFee(blockNumber, gasUsed)
|
||||
fmt.Println("fee", fee.Uint64(), "number", blockNumber)
|
||||
remainFee = big.NewInt(0).Sub(remainFee, fee)
|
||||
//check balance fee
|
||||
balanceIssuerFee, err := trc21IssuerInstance.GetTokenCapacity(trc21TokenAddr)
|
||||
|
|
@ -111,11 +111,10 @@ func testTransferTRC21TokenWithAccountNoXDC() {
|
|||
if err != nil {
|
||||
log.Fatal("can't transaction's receipt ", err, "hash", tx.Hash().Hex())
|
||||
}
|
||||
fee := big.NewInt(0).SetUint64(hexutil.MustDecodeUint64(receipt["gasUsed"].(string)))
|
||||
if hexutil.MustDecodeUint64(receipt["blockNumber"].(string)) > common.TIPTRC21Fee.Uint64() {
|
||||
fee = fee.Mul(fee, common.TRC21GasPrice)
|
||||
}
|
||||
fmt.Println("fee", fee.Uint64(), "number", hexutil.MustDecodeUint64(receipt["blockNumber"].(string)))
|
||||
gasUsed := hexutil.MustDecodeUint64(receipt["gasUsed"].(string))
|
||||
blockNumber := hexutil.MustDecodeUint64(receipt["blockNumber"].(string))
|
||||
fee := common.GetGasFee(blockNumber, gasUsed)
|
||||
fmt.Println("fee", fee.Uint64(), "number", blockNumber)
|
||||
remainFee = big.NewInt(0).Sub(remainFee, fee)
|
||||
//check balance fee
|
||||
balanceIssuerFee, err := trc21IssuerInstance.GetTokenCapacity(trc21TokenAddr)
|
||||
|
|
@ -178,11 +177,10 @@ func testTransferTrc21Fail() {
|
|||
if err != nil {
|
||||
log.Fatal("can't transaction's receipt ", err, "hash", tx.Hash().Hex())
|
||||
}
|
||||
fee := big.NewInt(0).SetUint64(hexutil.MustDecodeUint64(receipt["gasUsed"].(string)))
|
||||
if hexutil.MustDecodeUint64(receipt["blockNumber"].(string)) > common.TIPTRC21Fee.Uint64() {
|
||||
fee = fee.Mul(fee, common.TRC21GasPrice)
|
||||
}
|
||||
fmt.Println("fee", fee.Uint64(), "number", hexutil.MustDecodeUint64(receipt["blockNumber"].(string)))
|
||||
gasUsed := hexutil.MustDecodeUint64(receipt["gasUsed"].(string))
|
||||
blockNumber := hexutil.MustDecodeUint64(receipt["blockNumber"].(string))
|
||||
fee := common.GetGasFee(blockNumber, gasUsed)
|
||||
fmt.Println("fee", fee.Uint64(), "number", blockNumber)
|
||||
remainFee = big.NewInt(0).Sub(remainFee, fee)
|
||||
//check balance fee
|
||||
balanceIssuerFee, err = trc21IssuerInstance.GetTokenCapacity(trc21TokenAddr)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
package trc21issuer
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind"
|
||||
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends"
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/core"
|
||||
"github.com/XinFinOrg/XDPoSChain/crypto"
|
||||
"math/big"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -81,10 +82,7 @@ func TestFeeTxWithTRC21Token(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal("can't transaction's receipt ", err, "hash", tx.Hash())
|
||||
}
|
||||
fee := big.NewInt(0).SetUint64(receipt.GasUsed)
|
||||
if receipt.Logs[0].BlockNumber > common.TIPTRC21Fee.Uint64() {
|
||||
fee = fee.Mul(fee, common.TRC21GasPrice)
|
||||
}
|
||||
fee := common.GetGasFee(receipt.Logs[0].BlockNumber, receipt.GasUsed)
|
||||
remainFee := big.NewInt(0).Sub(minApply, fee)
|
||||
|
||||
// check balance trc21 again
|
||||
|
|
@ -133,10 +131,7 @@ func TestFeeTxWithTRC21Token(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal("can't transaction's receipt ", err, "hash", tx.Hash())
|
||||
}
|
||||
fee = big.NewInt(0).SetUint64(receipt.GasUsed)
|
||||
if receipt.Logs[0].BlockNumber > common.TIPTRC21Fee.Uint64() {
|
||||
fee = fee.Mul(fee, common.TRC21GasPrice)
|
||||
}
|
||||
fee = common.GetGasFee(receipt.Logs[0].BlockNumber, receipt.GasUsed)
|
||||
remainFee = big.NewInt(0).Sub(remainFee, fee)
|
||||
//check balance fee
|
||||
balanceIssuerFee, err = trc21Issuer.GetTokenCapacity(trc21TokenAddr)
|
||||
|
|
|
|||
|
|
@ -108,10 +108,7 @@ func (b *BlockGen) AddTxWithChain(bc *BlockChain, tx *types.Transaction) {
|
|||
b.txs = append(b.txs, tx)
|
||||
b.receipts = append(b.receipts, receipt)
|
||||
if tokenFeeUsed {
|
||||
fee := new(big.Int).SetUint64(gas)
|
||||
if b.header.Number.Cmp(common.TIPTRC21Fee) > 0 {
|
||||
fee = fee.Mul(fee, common.TRC21GasPrice)
|
||||
}
|
||||
fee := common.GetGasFee(b.header.Number.Uint64(), gas)
|
||||
state.UpdateTRC21Fee(b.statedb, map[common.Address]*big.Int{*tx.To(): new(big.Int).Sub(feeCapacity[*tx.To()], new(big.Int).SetUint64(gas))}, fee)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,10 +120,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, tra
|
|||
receipts = append(receipts, receipt)
|
||||
allLogs = append(allLogs, receipt.Logs...)
|
||||
if tokenFeeUsed {
|
||||
fee := new(big.Int).SetUint64(gas)
|
||||
if block.Header().Number.Cmp(common.TIPTRC21Fee) > 0 {
|
||||
fee = fee.Mul(fee, common.TRC21GasPrice)
|
||||
}
|
||||
fee := common.GetGasFee(block.Header().Number.Uint64(), gas)
|
||||
balanceFee[*tx.To()] = new(big.Int).Sub(balanceFee[*tx.To()], fee)
|
||||
balanceUpdated[*tx.To()] = balanceFee[*tx.To()]
|
||||
totalFeeUsed = totalFeeUsed.Add(totalFeeUsed, fee)
|
||||
|
|
@ -201,10 +198,7 @@ func (p *StateProcessor) ProcessBlockNoValidator(cBlock *CalculatedBlock, stated
|
|||
receipts[i] = receipt
|
||||
allLogs = append(allLogs, receipt.Logs...)
|
||||
if tokenFeeUsed {
|
||||
fee := new(big.Int).SetUint64(gas)
|
||||
if block.Header().Number.Cmp(common.TIPTRC21Fee) > 0 {
|
||||
fee = fee.Mul(fee, common.TRC21GasPrice)
|
||||
}
|
||||
fee := common.GetGasFee(block.Header().Number.Uint64(), gas)
|
||||
balanceFee[*tx.To()] = new(big.Int).Sub(balanceFee[*tx.To()], fee)
|
||||
balanceUpdated[*tx.To()] = balanceFee[*tx.To()]
|
||||
totalFeeUsed = totalFeeUsed.Add(totalFeeUsed, fee)
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ func (l *txList) Forward(threshold uint64) types.Transactions {
|
|||
// a point in calculating all the costs or if the balance covers all. If the threshold
|
||||
// is lower than the costgas cap, the caps will be reset to a new high after removing
|
||||
// the newly invalidated transactions.
|
||||
func (l *txList) Filter(costLimit *big.Int, gasLimit uint64, trc21Issuers map[common.Address]*big.Int) (types.Transactions, types.Transactions) {
|
||||
func (l *txList) Filter(costLimit *big.Int, gasLimit uint64, trc21Issuers map[common.Address]*big.Int, number *big.Int) (types.Transactions, types.Transactions) {
|
||||
// If all transactions are below the threshold, short circuit
|
||||
if l.costcap.Cmp(costLimit) <= 0 && l.gascap <= gasLimit {
|
||||
return nil, nil
|
||||
|
|
@ -303,7 +303,7 @@ func (l *txList) Filter(costLimit *big.Int, gasLimit uint64, trc21Issuers map[co
|
|||
maximum := costLimit
|
||||
if tx.To() != nil {
|
||||
if feeCapacity, ok := trc21Issuers[*tx.To()]; ok {
|
||||
return new(big.Int).Add(costLimit, feeCapacity).Cmp(tx.TRC21Cost()) < 0 || tx.Gas() > gasLimit
|
||||
return new(big.Int).Add(costLimit, feeCapacity).Cmp(tx.TxCost(number)) < 0 || tx.Gas() > gasLimit
|
||||
}
|
||||
}
|
||||
return tx.Cost().Cmp(maximum) > 0 || tx.Gas() > gasLimit
|
||||
|
|
|
|||
|
|
@ -632,7 +632,11 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
|||
// cost == V + GP * GL
|
||||
balance := pool.currentState.GetBalance(from)
|
||||
cost := tx.Cost()
|
||||
minGasPrice := common.MinGasPrice
|
||||
var number *big.Int = nil
|
||||
if pool.chain.CurrentHeader() != nil {
|
||||
number = pool.chain.CurrentHeader().Number
|
||||
}
|
||||
minGasPrice := common.GetMinGasPrice(number)
|
||||
feeCapacity := big.NewInt(0)
|
||||
|
||||
if tx.To() != nil {
|
||||
|
|
@ -641,8 +645,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
|||
if !state.ValidateTRC21Tx(pool.pendingState.StateDB, from, *tx.To(), tx.Data()) {
|
||||
return ErrInsufficientFunds
|
||||
}
|
||||
cost = tx.TRC21Cost()
|
||||
minGasPrice = common.TRC21GasPrice
|
||||
cost = tx.TxCost(number)
|
||||
}
|
||||
}
|
||||
if new(big.Int).Add(balance, feeCapacity).Cmp(cost) < 0 {
|
||||
|
|
@ -1066,7 +1069,11 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) {
|
|||
pool.priced.Removed()
|
||||
}
|
||||
// Drop all transactions that are too costly (low balance or out of gas)
|
||||
drops, _ := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas, pool.trc21FeeCapacity)
|
||||
var number *big.Int = nil
|
||||
if pool.chain.CurrentHeader() != nil {
|
||||
number = pool.chain.CurrentHeader().Number
|
||||
}
|
||||
drops, _ := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas, pool.trc21FeeCapacity, number)
|
||||
for _, tx := range drops {
|
||||
hash := tx.Hash()
|
||||
log.Trace("Removed unpayable queued transaction", "hash", hash)
|
||||
|
|
@ -1224,7 +1231,11 @@ func (pool *TxPool) demoteUnexecutables() {
|
|||
pool.priced.Removed()
|
||||
}
|
||||
// Drop all transactions that are too costly (low balance or out of gas), and queue any invalids back for later
|
||||
drops, invalids := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas, pool.trc21FeeCapacity)
|
||||
var number *big.Int = nil
|
||||
if pool.chain.CurrentHeader() != nil {
|
||||
number = pool.chain.CurrentHeader().Number
|
||||
}
|
||||
drops, invalids := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas, pool.trc21FeeCapacity, number)
|
||||
for _, tx := range drops {
|
||||
hash := tx.Hash()
|
||||
log.Trace("Removed unpayable pending transaction", "hash", hash)
|
||||
|
|
|
|||
|
|
@ -262,7 +262,9 @@ func (tx *Transaction) AsMessage(s Signer, balanceFee *big.Int, number *big.Int)
|
|||
var err error
|
||||
msg.from, err = Sender(s, tx)
|
||||
if balanceFee != nil {
|
||||
if number.Cmp(common.TIPTRC21Fee) > 0 {
|
||||
if number.Cmp(common.BlockNumberGas50x) >= 0 {
|
||||
msg.gasPrice = common.GasPrice50x
|
||||
} else if number.Cmp(common.TIPTRC21Fee) > 0 {
|
||||
msg.gasPrice = common.TRC21GasPrice
|
||||
} else {
|
||||
msg.gasPrice = common.TRC21GasPriceBefore
|
||||
|
|
@ -291,8 +293,8 @@ func (tx *Transaction) Cost() *big.Int {
|
|||
}
|
||||
|
||||
// Cost returns amount + gasprice * gaslimit.
|
||||
func (tx *Transaction) TRC21Cost() *big.Int {
|
||||
total := new(big.Int).Mul(common.TRC21GasPrice, new(big.Int).SetUint64(tx.data.GasLimit))
|
||||
func (tx *Transaction) TxCost(number *big.Int) *big.Int {
|
||||
total := new(big.Int).Mul(common.GetGasPrice(number), new(big.Int).SetUint64(tx.data.GasLimit))
|
||||
total.Add(total, tx.data.Amount)
|
||||
return total
|
||||
}
|
||||
|
|
@ -700,9 +702,9 @@ type Message struct {
|
|||
balanceTokenFee *big.Int
|
||||
}
|
||||
|
||||
func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, checkNonce bool, balanceTokenFee *big.Int) Message {
|
||||
func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, checkNonce bool, balanceTokenFee *big.Int, number *big.Int) Message {
|
||||
if balanceTokenFee != nil {
|
||||
gasPrice = common.TRC21GasPrice
|
||||
gasPrice = common.GetGasPrice(number)
|
||||
}
|
||||
return Message{
|
||||
from: from,
|
||||
|
|
|
|||
|
|
@ -706,10 +706,7 @@ func (api *PrivateDebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, ree
|
|||
}
|
||||
|
||||
if tokenFeeUsed {
|
||||
fee := new(big.Int).SetUint64(gas)
|
||||
if block.Header().Number.Cmp(common.TIPTRC21Fee) > 0 {
|
||||
fee = fee.Mul(fee, common.TRC21GasPrice)
|
||||
}
|
||||
fee := common.GetGasFee(block.Header().Number.Uint64(), gas)
|
||||
feeCapacity[*tx.To()] = new(big.Int).Sub(feeCapacity[*tx.To()], fee)
|
||||
balanceUpdated[*tx.To()] = feeCapacity[*tx.To()]
|
||||
totalFeeUsed = totalFeeUsed.Add(totalFeeUsed, fee)
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
|
|||
}
|
||||
|
||||
// Check gas price min.
|
||||
minGasPrice := common.MinGasPrice
|
||||
minGasPrice := common.GetMinGasPrice(head.Number)
|
||||
if price.Cmp(minGasPrice) < 0 {
|
||||
price = new(big.Int).Set(minGasPrice)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1066,7 +1066,7 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr
|
|||
balanceTokenFee := big.NewInt(0).SetUint64(gas)
|
||||
balanceTokenFee = balanceTokenFee.Mul(balanceTokenFee, gasPrice)
|
||||
// Create new call message
|
||||
msg := types.NewMessage(addr, args.To, 0, args.Value.ToInt(), gas, gasPrice, args.Data, false, balanceTokenFee)
|
||||
msg := types.NewMessage(addr, args.To, 0, args.Value.ToInt(), gas, gasPrice, args.Data, false, balanceTokenFee, header.Number)
|
||||
|
||||
// Setup context so it may be cancelled the call has completed
|
||||
// or, in case of unmetered gas, setup a context with a timeout.
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
|
|||
if value, ok := feeCapacity[testContractAddr]; ok {
|
||||
balanceTokenFee = value
|
||||
}
|
||||
msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false, balanceTokenFee)}
|
||||
msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false, balanceTokenFee, header.Number)}
|
||||
|
||||
context := core.NewEVMContext(msg, header, bc, nil)
|
||||
vmenv := vm.NewEVM(context, statedb, nil, config, vm.Config{})
|
||||
|
|
@ -153,7 +153,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
|
|||
if value, ok := feeCapacity[testContractAddr]; ok {
|
||||
balanceTokenFee = value
|
||||
}
|
||||
msg := callmsg{types.NewMessage(testBankAddress, &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false, balanceTokenFee)}
|
||||
msg := callmsg{types.NewMessage(testBankAddress, &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false, balanceTokenFee, header.Number)}
|
||||
context := core.NewEVMContext(msg, header, lc, nil)
|
||||
vmenv := vm.NewEVM(context, statedb, nil, config, vm.Config{})
|
||||
gp := new(core.GasPool).AddGas(math.MaxUint64)
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, bc *core.BlockChain
|
|||
if value, ok := feeCapacity[testContractAddr]; ok {
|
||||
balanceTokenFee = value
|
||||
}
|
||||
msg := callmsg{types.NewMessage(testBankAddress, &testContractAddr, 0, new(big.Int), 1000000, new(big.Int), data, false, balanceTokenFee)}
|
||||
msg := callmsg{types.NewMessage(testBankAddress, &testContractAddr, 0, new(big.Int), 1000000, new(big.Int), data, false, balanceTokenFee, header.Number)}
|
||||
context := core.NewEVMContext(msg, header, chain, nil)
|
||||
vmenv := vm.NewEVM(context, st, nil, config, vm.Config{})
|
||||
gp := new(core.GasPool).AddGas(math.MaxUint64)
|
||||
|
|
|
|||
|
|
@ -931,10 +931,7 @@ func (env *Work) commitTransactions(mux *event.TypeMux, balanceFee map[common.Ad
|
|||
log.Debug("Add Special Transaction failed, account skipped", "hash", tx.Hash(), "sender", from, "nonce", tx.Nonce(), "to", tx.To(), "err", err)
|
||||
}
|
||||
if tokenFeeUsed {
|
||||
fee := new(big.Int).SetUint64(gas)
|
||||
if env.header.Number.Cmp(common.TIPTRC21Fee) > 0 {
|
||||
fee = fee.Mul(fee, common.TRC21GasPrice)
|
||||
}
|
||||
fee := common.GetGasFee(env.header.Number.Uint64(), gas)
|
||||
balanceFee[*tx.To()] = new(big.Int).Sub(balanceFee[*tx.To()], fee)
|
||||
balanceUpdated[*tx.To()] = balanceFee[*tx.To()]
|
||||
totalFeeUsed = totalFeeUsed.Add(totalFeeUsed, fee)
|
||||
|
|
@ -1049,10 +1046,7 @@ func (env *Work) commitTransactions(mux *event.TypeMux, balanceFee map[common.Ad
|
|||
txs.Shift()
|
||||
}
|
||||
if tokenFeeUsed {
|
||||
fee := new(big.Int).SetUint64(gas)
|
||||
if env.header.Number.Cmp(common.TIPTRC21Fee) > 0 {
|
||||
fee = fee.Mul(fee, common.TRC21GasPrice)
|
||||
}
|
||||
fee := common.GetGasFee(env.header.Number.Uint64(), gas)
|
||||
balanceFee[*tx.To()] = new(big.Int).Sub(balanceFee[*tx.To()], fee)
|
||||
balanceUpdated[*tx.To()] = balanceFee[*tx.To()]
|
||||
totalFeeUsed = totalFeeUsed.Add(totalFeeUsed, fee)
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateD
|
|||
statedb := MakePreState(db, t.json.Pre)
|
||||
|
||||
post := t.json.Post[subtest.Fork][subtest.Index]
|
||||
msg, err := t.json.Tx.toMessage(post)
|
||||
msg, err := t.json.Tx.toMessage(post, block.Number())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ func (t *StateTest) genesis(config *params.ChainConfig) *core.Genesis {
|
|||
}
|
||||
}
|
||||
|
||||
func (tx *stTransaction) toMessage(ps stPostState) (core.Message, error) {
|
||||
func (tx *stTransaction) toMessage(ps stPostState, number *big.Int) (core.Message, error) {
|
||||
// Derive sender from private key if present.
|
||||
var from common.Address
|
||||
if len(tx.PrivateKey) > 0 {
|
||||
|
|
@ -235,7 +235,7 @@ func (tx *stTransaction) toMessage(ps stPostState) (core.Message, error) {
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid tx data %q", dataHex)
|
||||
}
|
||||
msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, data, true, nil)
|
||||
msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, data, true, nil, number)
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue