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

feat(ethash): flashbots_getWork RPC with profit #106

Merged
merged 1 commit into from
Dec 28, 2021

Conversation

shekhirin
Copy link

@shekhirin shekhirin commented Dec 22, 2021

#103

Adds new RPC method flashbots_getWork which adds a new block reward including MEV to eth_getWork RPC result.

Block reward matches the profit number used in the mining worker

profit *big.Int


Not sure how I can test it, but running on Sepolia with (mainnet in the log is a bug, see ethereum#24147)

mev-geth git:(feat/flashbots-get-work) ./build/bin/geth --sepolia --mine
INFO [12-22|09:45:39.458] Starting Geth on Ethereum mainnet... 

successfully returns both eth_getWork and flashbots_getWork RPCs

> web3.currentProvider.send({method: 'eth_getWork'})
{
  id: 0,
  jsonrpc: "2.0",
  result: ["0x61459bbdf3c56b8e7d281fca4210e440daf95526e59f7068ec61681980ac9da2", "0x9b2baad7528ecec612c5751a6bd525905892d7892e155c3b05e61363154a940b", "0x0000000a9f8ed07e7747b5db09228583fe0410d0c823bd414157935370bbe9fe", "0x50357"]
}
> web3.currentProvider.send({method: 'flashbots_getWork'})
{
  id: 0,
  jsonrpc: "2.0",
  result: ["0x61459bbdf3c56b8e7d281fca4210e440daf95526e59f7068ec61681980ac9da2", "0x9b2baad7528ecec612c5751a6bd525905892d7892e155c3b05e61363154a940b", "0x0000000a9f8ed07e7747b5db09228583fe0410d0c823bd414157935370bbe9fe", "0x50357", "0x0"]
}

Guess I could try syncing Ropsten and trying to mine it watching for profit value in flashbots_getWork response.

@shekhirin shekhirin marked this pull request as ready for review December 22, 2021 06:49
@libevm
Copy link

libevm commented Dec 22, 2021

I'm curious to how you would test this feature, but in my mind, I'm thinking something like

./build/bin/geth --dev --dev.period 100

And then send some test transactions around then calling flashbots_getWork

@shekhirin
Copy link
Author

--dev is PoA network with Clique consensus engine, so you can't really use ethash-based endpoints with it

> web3.currentProvider.send({method: 'eth_getWork'})
{
  error: {
    code: -32601,
    message: "the method eth_getWork does not exist/is not available"
  },
  id: 0,
  jsonrpc: "2.0"
}
> web3.currentProvider.send({method: 'flashbots_getWork'})
{
  error: {
    code: -32601,
    message: "the method flashbots_getWork does not exist/is not available"
  },
  id: 0,
  jsonrpc: "2.0"
}

@shekhirin
Copy link
Author

Set up a local PoW net, everything seems to be working fine with simple transaction, will test with sendBundle a bit later

> function getWork() { for (let i = 0; i < 10; i++) { setTimeout(() => console.log(JSON.stringify(web3.currentProvider.send({method: 'flashbots_getWork'}).result)), i*1000) } }
undefined

> eth.sendTransaction({from: '0xe394dd7832d8a26c5b4c6205649f85df25617a45', to: '0xe394dd7832d8a26c5b4c6205649f85df25617a45'}); getWork()
undefined

["0x7521d7254c597ed37a6fa67c3eb879a952582c7599ce853046da99b7324d1b40","0x0000000000000000000000000000000000000000000000000000000000000000","0x00006246fe64d8fdb818328ad2c48d383bb531be34f4e5407374e75cf9ec1206","0x227","0x0"]
["0xfd6d5a1180060b6bc0eb8f02b01f39c6fb7bb71ad6b81d1ccc2938c21f08d223","0x0000000000000000000000000000000000000000000000000000000000000000","0x00006246fe64d8fdb818328ad2c48d383bb531be34f4e5407374e75cf9ec1206","0x227","0x1319718a5000"]
["0xfd6d5a1180060b6bc0eb8f02b01f39c6fb7bb71ad6b81d1ccc2938c21f08d223","0x0000000000000000000000000000000000000000000000000000000000000000","0x00006246fe64d8fdb818328ad2c48d383bb531be34f4e5407374e75cf9ec1206","0x227","0x1319718a5000"]
["0xf079d4a29cf2d1e272fc7aa91559cae370d7300051f44ba64d374f5a75f218e5","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000622259be21c99badfa5a0dddb286296e288b391bb16d8f358ce29ca28bf5","0x22a","0x0"]
...

@metachris
Copy link
Collaborator

metachris commented Dec 22, 2021

The mev-callbundle changes have been squashed and picked into the master branch, which messed up this PR. I think best would be to cherry-pick your original commit(s) onto the latest master state, and pointing the PR towards the master branch.

@shekhirin shekhirin changed the base branch from mev-callbundle to master December 23, 2021 04:45
@shekhirin
Copy link
Author

@metachris oh that's nice that master is relevant now. Cherry-picked my commit and pointed branch towards the master.

@shekhirin
Copy link
Author

I tested it with https://github.com/flashbots/mev-geth-demo and demo-simple-old script, everything seems to be working.

> print = () => { console.log(JSON.stringify(web3.currentProvider.send({method: 'flashbots_getWork'}).result.slice(3)) + '\n' + JSON.stringify(web3.currentProvider.send({method: 'eth_getWork'}).result.slice(3)) + '\n\n'); setTimeout(print, 1000) }
() =>
> print()

["0xcd","0x0"]
["0xcd"]
...
mev-geth-demo git:(main) ✗ yarn demo-simple-old
...

["0xcd","0x0"]
["0xcd"]


["0xcd","0xecd8fae8c0fc20"]
["0xcd"]

...

@jparyani jparyani merged commit 7723be7 into flashbots:master Dec 28, 2021
@jparyani
Copy link

This looks great, thanks! Sorry for the delay getting it reviewed, I was distracted over the holidays

Ruteri pushed a commit that referenced this pull request Feb 18, 2022
* fix issue with geth not shutting down (#97)
* Add eth_callBundle rpc method (#14)
* flashbots: add eth_estimateGasBundle (#102)
* feat(ethash): flashbots_getWork RPC with profit (#106)
* Calculate megabundle as soon as it's received (#112)
* Add v0.5 specification link (#118)
Ruteri added a commit that referenced this pull request Feb 21, 2022
* fix issue with geth not shutting down (#97)
* Add eth_callBundle rpc method (#14)
* flashbots: add eth_estimateGasBundle (#102)
* feat(ethash): flashbots_getWork RPC with profit (#106)
* Calculate megabundle as soon as it's received (#112)
* Add v0.5 specification link (#118)
Ruteri added a commit that referenced this pull request Feb 21, 2022
* fix issue with geth not shutting down (#97)
* Add eth_callBundle rpc method (#14)
* flashbots: add eth_estimateGasBundle (#102)
* feat(ethash): flashbots_getWork RPC with profit (#106)
* Calculate megabundle as soon as it's received (#112)
* Add v0.5 specification link (#118)
Ruteri added a commit that referenced this pull request Apr 4, 2022
* fix issue with geth not shutting down (#97)
* Add eth_callBundle rpc method (#14)
* flashbots: add eth_estimateGasBundle (#102)
* feat(ethash): flashbots_getWork RPC with profit (#106)
* Calculate megabundle as soon as it's received (#112)
* Add v0.5 specification link (#118)
Ruteri added a commit that referenced this pull request Jun 7, 2022
* fix issue with geth not shutting down (#97)
* Add eth_callBundle rpc method (#14)
* flashbots: add eth_estimateGasBundle (#102)
* feat(ethash): flashbots_getWork RPC with profit (#106)
* Calculate megabundle as soon as it's received (#112)
* Add v0.5 specification link (#118)
Ruteri added a commit that referenced this pull request Jun 15, 2022
* fix issue with geth not shutting down (#97)
* Add eth_callBundle rpc method (#14)
* flashbots: add eth_estimateGasBundle (#102)
* feat(ethash): flashbots_getWork RPC with profit (#106)
* Calculate megabundle as soon as it's received (#112)
* Add v0.5 specification link (#118)
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.

None yet

4 participants