ralexstokes / mev-rs

a gateway to a network of block builders
Other
411 stars 76 forks source link

Builder only supports basic ether transfer to EOA for proposer payments #248

Closed ralexstokes closed 4 months ago

ralexstokes commented 4 months ago

https://github.com/ralexstokes/mev-rs/blob/86bd5fee136889cccec75e3efd29269cc2cbaf50/mev-build-rs/src/payload/builder.rs#L57-L67

When going to make a payment to the proposer in the MEV auction, the builder currently hardcodes a gas limit that only covers a basic ether transfer. This assumption is violated in the event, e.g. the recipient is a smart contract like when paying a staking pool.

There are a few options to fix this:

1) Hardcode a much higher limit, e.g. 200k gas: simple, but still leaves room for an expensive recipient to fail the payment. 2) Detect if the recipient account has code attached or not and use the base or higher (fixed) limit accordingly: strikes a good balance b/t computation and safety; we would still want to use only enough gas when possible to avoid issues around reorgs/replay attacks. 3) Try to measure how much gas any recipient would need, at runtime, and use that limit: most precise, but also most expensive.

I think (2) is a good medium-term path forward.

rodrigoherrerai commented 4 months ago

I can give it a try

ralexstokes commented 4 months ago

I think ill close this as fixed by #251, thanks to @rodrigoherrerai for the contribution!

we could consider doing something more sophisticated but then we need to be sensitive to computation costs in a relative hot path of block building