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

Fix max fee per gas less than block base fee #289

Merged
merged 13 commits into from
Oct 11, 2024
Merged

Fix max fee per gas less than block base fee #289

merged 13 commits into from
Oct 11, 2024

Conversation

syntrust
Copy link
Collaborator

@syntrust syntrust commented May 28, 2024

Addressing #284

Solution

Compute the gas price from the minimum profit and use it as the gas fee cap.

Tests been done

integration_tests/node_mine_test.go#TestMining() and node tests on L1 and L2 networks shows mining can be successfully done:

  • using the minimum profitable gas price as gasFeeCap
# on Sepolia L1

INFO [10-08|14:51:18.449] Query baseFee done                       baseFee=3,304,814,517
INFO [10-08|14:51:18.852] Query gas tip cap done                   gasTipGap=1,216,647
INFO [10-08|14:51:18.852] Suggested gas fee cap                    gasFeeCap=3,306,031,164
INFO [10-08|14:51:19.257] Estimated gas done                       gas=401,601
INFO [10-08|14:51:19.620] Minimum profitable gas fee cap           gasFeeCap=7,470,186,602
INFO [10-08|14:51:19.620] Using profitable gas fee cap             gasFeeCap=7,470,186,602
INFO [10-08|14:51:20.443] Submit mined result done                 shard=0 block=6,836,741 nonce=330,091 txSigner=0x471977571aD818379E2b6CC37792a5EaC85FdE22 hash=0x1105769998ebeb7198f254cdb115492ff73ad993e545159887302e7b58024ab4
INFO [10-08|14:51:25.796] Mining transaction confirmed             txHash=110576..024ab4
INFO [10-08|14:51:26.896] "Mining transaction success!      √"     miner=0x471977571aD818379E2b6CC37792a5EaC85FdE22
INFO [10-08|14:51:26.896] Mining transaction details               txHash=110576..024ab4 gasUsed=393,068 effectiveGasPrice=3,203,772,189
INFO [10-08|14:51:26.896] Mining transaction accounting (in ether) reward=0.000000034 cost=0.001259300 profit=-0.001259266

# on L2 where gas prices are stable and baseFee is far less than tip

t=2024-09-29T15:31:37+0800 lvl=info msg="Query baseFee done"                  baseFee=252
t=2024-09-29T15:31:41+0800 lvl=dbug msg="Got latest block number by Randao querier" number=6,780,060
t=2024-09-29T15:31:41+0800 lvl=dbug msg="Fetching header by number by Randao querier" number=6,780,060
t=2024-09-29T15:31:41+0800 lvl=info msg="Query gas tip cap done"              gasTipGap=1,000,000
t=2024-09-29T15:31:41+0800 lvl=info msg="Suggested gas fee cap"               gasFeeCap=1,000,252
t=2024-09-29T15:31:45+0800 lvl=info msg="Estimated gas done"                  gas=394,411
t=2024-09-29T15:31:47+0800 lvl=info msg="Minimum profitable gas fee cap"      gasFeeCap=1,270,049
t=2024-09-29T15:31:47+0800 lvl=info msg="Using profitable gas fee cap"        gasFeeCap=1,270,049
t=2024-09-29T15:31:50+0800 lvl=dbug msg="Query nonce done"                    nonce=3215
t=2024-09-29T15:32:14+0800 lvl=info msg="Submit mined result done"            shard=59 block=6,780,053 nonce=146,956 txSigner=0x2F43878FAb122D9A7596949e4985cc284feCD4B8 hash=0xf340469b69b20682a505621c03669a039d659b1ffe9aee8556cf32cfb766ab30
t=2024-09-29T15:32:22+0800 lvl=info msg="Mining transaction confirmed"        txHash=0xf340469b69b20682a505621c03669a039d659b1ffe9aee8556cf32cfb766ab30
t=2024-09-29T15:32:24+0800 lvl=info msg="Mining transaction success!      √"  miner=0x534632D6d7aD1fe5f832951c97FDe73E4eFD9a77
t=2024-09-29T15:32:24+0800 lvl=info msg="Mining transaction details"          txHash=0xf340469b69b20682a505621c03669a039d659b1ffe9aee8556cf32cfb766ab30 gasUsed=385,949 effectiveGasPrice=1,000,252
t=2024-09-29T15:32:24+0800 lvl=info msg="Mining transaction accounting (in ether)" reward=0.000000001 cost=0.000000386 profit=-0.000000385

  • drop the tx as baseFee + tip will not meet the minimum profit
# on Sepolia L1

NFO [10-08|13:45:59.239] Query baseFee done                       baseFee=1,441,982
INFO [10-08|13:45:59.543] Query gas tip cap done                   gasTipGap=1,374,798
INFO [10-08|13:45:59.543] Suggested gas fee cap                    gasFeeCap=2,816,780
INFO [10-08|13:45:59.868] Estimated gas done                       gas=401,042
INFO [10-08|13:46:00.172] Minimum profitable gas fee cap           gasFeeCap=47988
WARN [10-08|13:46:00.175] Mining tx dropped: the profit will not meet expectation estimatedProfit=-1,110,401,633,427 minimumProfit=0.000000000


# on L2

t=2024-09-29T15:26:46+0800 lvl=info msg="Query baseFee done"                  baseFee=252
t=2024-09-29T15:26:48+0800 lvl=info msg="Query gas tip cap done"              gasTipGap=1,000,000
t=2024-09-29T15:26:48+0800 lvl=info msg="Suggested gas fee cap"               gasFeeCap=1,000,252
t=2024-09-29T15:26:52+0800 lvl=info msg="Estimated gas done"                  gas=533,292
t=2024-09-29T15:28:32+0800 lvl=info msg="Minimum profitable gas fee cap"      gasFeeCap=991,580
t=2024-09-29T15:28:32+0800 lvl=warn msg="Mining tx dropped: the profit will not meet expectation" estimatedProfit=-0.000000505 minimumProfit=-0.000000500

@syntrust syntrust changed the base branch from miner_opt to main September 9, 2024 02:35
@syntrust syntrust requested review from qzhodl and ping-ke September 9, 2024 03:46
@syntrust syntrust marked this pull request as ready for review September 9, 2024 03:49
ethstorage/miner/l1_mining_api.go Outdated Show resolved Hide resolved
ethstorage/miner/l1_mining_api.go Outdated Show resolved Hide resolved
@syntrust syntrust merged commit 1cec4d6 into main Oct 11, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants