From adbdaad29c12a2a86d435ae72048aa4a406b4e3e Mon Sep 17 00:00:00 2001 From: Anusha Date: Thu, 20 Jul 2023 10:08:54 -0700 Subject: [PATCH] remove --- core/state_processor_test.go | 111 ----------------------------------- 1 file changed, 111 deletions(-) diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 74d96fc2bf..3367544a0c 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -27,7 +27,6 @@ package core import ( - "fmt" "math/big" "testing" @@ -426,113 +425,3 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr // Assemble and return the final block for sealing return types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil), nil, true) } - -func CostOfUsingGasLimitEachBlock(gspec *Genesis) { - genesis := gspec.ToBlock() - totalPaid := big.NewInt(0) - parent := genesis.Header() - gasLimit := new(big.Int).SetUint64(gspec.GasLimit) - totalGasUsed := big.NewInt(0) - - for i := 1; i < 20; i++ { - header := nextBlock(gspec.Config, parent, gspec.GasLimit) - baseFee := header.BaseFee - gasCost := new(big.Int).Mul(baseFee, gasLimit) - totalGasUsed = new(big.Int).Add(totalGasUsed, gasLimit) - totalPaid = new(big.Int).Add(totalPaid, gasCost) - parent = header - - avg := new(big.Int).Div(totalPaid, totalGasUsed) - fmt.Printf( - "Number: %d, BaseFee: %vGWei, TotalGasUsed: %d, TotalPaid (Ether): %d, AvgGasPrice: %dGWei\n", - header.Number, - new(big.Int).Div(baseFee, big.NewInt(params.GWei)), // baseFee in GWei - totalGasUsed, - new(big.Int).Div(totalPaid, big.NewInt(params.Ether)), // totalPaid in Ether - new(big.Int).Div(avg, big.NewInt(params.GWei)), // avgGasPrice in GWei - ) - } -} - -func ExampleCostOfUsingGasLimitEachBlock() { - banff := &Genesis{ - Config: params.TestBanffChainConfig, - Alloc: GenesisAlloc{ - common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): GenesisAccount{ - Balance: big.NewInt(4000000000000000000), // 4 ether - Nonce: 0, - }, - }, - BaseFee: big.NewInt(225 * params.GWei), - GasLimit: params.ApricotPhase1GasLimit, - } - cortina := &Genesis{ - Config: params.TestCortinaChainConfig, - Alloc: GenesisAlloc{ - common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): GenesisAccount{ - Balance: big.NewInt(4000000000000000000), // 4 ether - Nonce: 0, - }, - }, - BaseFee: big.NewInt(225 * params.GWei), - GasLimit: params.CortinaGasLimit, - } - fmt.Println("----- banff ----") - CostOfUsingGasLimitEachBlock(banff) - fmt.Println("----- cortina ----") - CostOfUsingGasLimitEachBlock(cortina) - // Output: - // ----- banff ---- - // Number: 1, BaseFee: 225GWei, TotalGasUsed: 8000000, TotalPaid (Ether): 1, AvgGasPrice: 225GWei - // Number: 2, BaseFee: 222GWei, TotalGasUsed: 16000000, TotalPaid (Ether): 3, AvgGasPrice: 223GWei - // Number: 3, BaseFee: 222GWei, TotalGasUsed: 24000000, TotalPaid (Ether): 5, AvgGasPrice: 223GWei - // Number: 4, BaseFee: 226GWei, TotalGasUsed: 32000000, TotalPaid (Ether): 7, AvgGasPrice: 223GWei - // Number: 5, BaseFee: 233GWei, TotalGasUsed: 40000000, TotalPaid (Ether): 9, AvgGasPrice: 225GWei - // Number: 6, BaseFee: 240GWei, TotalGasUsed: 48000000, TotalPaid (Ether): 10, AvgGasPrice: 228GWei - // Number: 7, BaseFee: 248GWei, TotalGasUsed: 56000000, TotalPaid (Ether): 12, AvgGasPrice: 231GWei - // Number: 8, BaseFee: 256GWei, TotalGasUsed: 64000000, TotalPaid (Ether): 14, AvgGasPrice: 234GWei - // Number: 9, BaseFee: 264GWei, TotalGasUsed: 72000000, TotalPaid (Ether): 17, AvgGasPrice: 237GWei - // Number: 10, BaseFee: 272GWei, TotalGasUsed: 80000000, TotalPaid (Ether): 19, AvgGasPrice: 241GWei - // Number: 11, BaseFee: 281GWei, TotalGasUsed: 88000000, TotalPaid (Ether): 21, AvgGasPrice: 244GWei - // Number: 12, BaseFee: 289GWei, TotalGasUsed: 96000000, TotalPaid (Ether): 23, AvgGasPrice: 248GWei - // Number: 13, BaseFee: 298GWei, TotalGasUsed: 104000000, TotalPaid (Ether): 26, AvgGasPrice: 252GWei - // Number: 14, BaseFee: 308GWei, TotalGasUsed: 112000000, TotalPaid (Ether): 28, AvgGasPrice: 256GWei - // Number: 15, BaseFee: 318GWei, TotalGasUsed: 120000000, TotalPaid (Ether): 31, AvgGasPrice: 260GWei - // Number: 16, BaseFee: 328GWei, TotalGasUsed: 128000000, TotalPaid (Ether): 33, AvgGasPrice: 264GWei - // Number: 17, BaseFee: 338GWei, TotalGasUsed: 136000000, TotalPaid (Ether): 36, AvgGasPrice: 269GWei - // Number: 18, BaseFee: 349GWei, TotalGasUsed: 144000000, TotalPaid (Ether): 39, AvgGasPrice: 273GWei - // Number: 19, BaseFee: 360GWei, TotalGasUsed: 152000000, TotalPaid (Ether): 42, AvgGasPrice: 278GWei - // ----- cortina ---- - // Number: 1, BaseFee: 225GWei, TotalGasUsed: 15000000, TotalPaid (Ether): 3, AvgGasPrice: 225GWei - // Number: 2, BaseFee: 225GWei, TotalGasUsed: 30000000, TotalPaid (Ether): 6, AvgGasPrice: 225GWei - // Number: 3, BaseFee: 231GWei, TotalGasUsed: 45000000, TotalPaid (Ether): 10, AvgGasPrice: 227GWei - // Number: 4, BaseFee: 244GWei, TotalGasUsed: 60000000, TotalPaid (Ether): 13, AvgGasPrice: 231GWei - // Number: 5, BaseFee: 264GWei, TotalGasUsed: 75000000, TotalPaid (Ether): 17, AvgGasPrice: 237GWei - // Number: 6, BaseFee: 286GWei, TotalGasUsed: 90000000, TotalPaid (Ether): 22, AvgGasPrice: 246GWei - // Number: 7, BaseFee: 310GWei, TotalGasUsed: 105000000, TotalPaid (Ether): 26, AvgGasPrice: 255GWei - // Number: 8, BaseFee: 336GWei, TotalGasUsed: 120000000, TotalPaid (Ether): 31, AvgGasPrice: 265GWei - // Number: 9, BaseFee: 364GWei, TotalGasUsed: 135000000, TotalPaid (Ether): 37, AvgGasPrice: 276GWei - // Number: 10, BaseFee: 394GWei, TotalGasUsed: 150000000, TotalPaid (Ether): 43, AvgGasPrice: 288GWei - // Number: 11, BaseFee: 427GWei, TotalGasUsed: 165000000, TotalPaid (Ether): 49, AvgGasPrice: 300GWei - // Number: 12, BaseFee: 463GWei, TotalGasUsed: 180000000, TotalPaid (Ether): 56, AvgGasPrice: 314GWei - // Number: 13, BaseFee: 501GWei, TotalGasUsed: 195000000, TotalPaid (Ether): 64, AvgGasPrice: 328GWei - // Number: 14, BaseFee: 543GWei, TotalGasUsed: 210000000, TotalPaid (Ether): 72, AvgGasPrice: 344GWei - // Number: 15, BaseFee: 588GWei, TotalGasUsed: 225000000, TotalPaid (Ether): 81, AvgGasPrice: 360GWei - // Number: 16, BaseFee: 637GWei, TotalGasUsed: 240000000, TotalPaid (Ether): 90, AvgGasPrice: 377GWei - // Number: 17, BaseFee: 690GWei, TotalGasUsed: 255000000, TotalPaid (Ether): 101, AvgGasPrice: 396GWei - // Number: 18, BaseFee: 748GWei, TotalGasUsed: 270000000, TotalPaid (Ether): 112, AvgGasPrice: 415GWei - // Number: 19, BaseFee: 810GWei, TotalGasUsed: 285000000, TotalPaid (Ether): 124, AvgGasPrice: 436GWei -} - -func nextBlock(config *params.ChainConfig, parent *types.Header, gasUsed uint64) *types.Header { - header := &types.Header{ - ParentHash: parent.Hash(), - Number: new(big.Int).Add(parent.Number, common.Big1), - Time: parent.Time + 2, - } - if config.IsApricotPhase3(header.Time) { - header.Extra, header.BaseFee, _ = dummy.CalcBaseFee(config, parent, header.Time) - } - header.GasUsed = gasUsed - return header -}