all: rename internal 1559 gas fields, add support for graphql (#23010)

* all: rename internal 1559 gas fields, add support for graphql

* cmd/evm/testdata, core: use public 1559 gas names on API surfaces
This commit is contained in:
Péter Szilágyi
2021-06-08 13:05:41 +03:00
committed by GitHub
parent 248572ee54
commit c503f98f6d
27 changed files with 329 additions and 262 deletions

View File

@ -155,7 +155,7 @@ func makeTransaction(nonce uint64, privKey *ecdsa.PrivateKey, signer types.Signe
// larger buffer for creating both valid and invalid transactions.
var buf = make([]byte, 32+5)
rand.Read(buf)
tip := new(big.Int).SetBytes(buf)
gasTipCap := new(big.Int).SetBytes(buf)
// If the given base fee is nil(the 1559 is still not available),
// generate a fake base fee in order to create 1559 tx forcibly.
@ -163,18 +163,18 @@ func makeTransaction(nonce uint64, privKey *ecdsa.PrivateKey, signer types.Signe
baseFee = new(big.Int).SetInt64(int64(rand.Int31()))
}
// Generate the feecap, 75% valid feecap and 25% unguaranted.
var feeCap *big.Int
var gasFeeCap *big.Int
if rand.Intn(4) == 0 {
rand.Read(buf)
feeCap = new(big.Int).SetBytes(buf)
gasFeeCap = new(big.Int).SetBytes(buf)
} else {
feeCap = new(big.Int).Add(baseFee, tip)
gasFeeCap = new(big.Int).Add(baseFee, gasTipCap)
}
return types.MustSignNewTx(privKey, signer, &types.DynamicFeeTx{
ChainID: signer.ChainID(),
Nonce: nonce,
Tip: tip,
FeeCap: feeCap,
GasTipCap: gasTipCap,
GasFeeCap: gasFeeCap,
Gas: 21000,
To: &recipient,
Value: big.NewInt(100),

View File

@ -1052,7 +1052,7 @@ func (w *worker) postSideBlock(event core.ChainSideEvent) {
func totalFees(block *types.Block, receipts []*types.Receipt) *big.Float {
feesWei := new(big.Int)
for i, tx := range block.Transactions() {
minerFee, _ := tx.EffectiveTip(block.BaseFee())
minerFee, _ := tx.EffectiveGasTip(block.BaseFee())
feesWei.Add(feesWei, new(big.Int).Mul(new(big.Int).SetUint64(receipts[i].GasUsed), minerFee))
}
return new(big.Float).Quo(new(big.Float).SetInt(feesWei), new(big.Float).SetInt(big.NewInt(params.Ether)))