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

Use EIP712 signing scheme for bids #2808

Open
wants to merge 1 commit into
base: express-lane-timeboost-early-submission-grace
Choose a base branch
from

Conversation

Tristan-Wilson
Copy link
Member

The ExpressLaneAuction contract auction resolution methods take Bid objects as arguments which were previously expected to have the signature field populated by using the "\x19Ethereum Signed Message:..." hashing scheme applied over bid, contract, and chain details, then signed. The contracts were updated to use EIP 712 which standardizes a hashing scheme for structured data.

Briefly, EIP 712 produces the hash to be signed as follows: keccak256("\x19\x01" ‖ domainSeparator ‖ hashStruct(message)). The domainSeparator includes chain and contract details to prevent replay attacks, and in our code we just fetch it from the contract using domainSeparator() which internally uses the OpenZepplin library to calculate it for the contract. hashStruct encodes type information about the struct, in this case the "Bid(uint64 round,address expressLaneController,uint256 amount)" along with the data. Geth has an implementation of hashStruct that we use here.

The BidderClient generates the signature and the BidValidator uses the signature and the hash to recover the sender, so these are the places that needed to be updated. This PR also removes Bid.ToMessageBytes as this serialization format was only used for generating the data to be signed under the old scheme, and makes private ValidatedBid.bidBytes and bigIntHash() since these are only used for tiebreaking in the BidCache and nothing to do with signing.

Testing done

Bidding and auction resolution works again after updating to the new contracts.

timeboost-auctioneer-1     | INFO [11-27|23:21:47.007] Resolving auction with single bid        round=3                                                     
sequencer-1                | INFO [11-27|23:21:47.008] Prioritizing auction resolution transaction from auctioneer txHash=0x6ff8058fd7ffb30089a9199a422675d8
a882a3cf541e925e8a4799c638314af9                                                                                                                            
sequencer-1                | INFO [11-27|23:21:47.008] Popped the auction resolution tx         txHash=6ff805..314af9                                       
sequencer-1                | INFO [11-27|23:21:47.183] New express lane controller assigned     round=3 controller=0xC3c76AaAA7C483c5099aeC225bA5E4269373F16
b                                                                                                                                                           
sequencer-1                | WARN [11-27|23:21:47.183] New express lane controller did not match previous controller round=3 previous=0x00000000000000000000
00000000000000000000 new=0xC3c76AaAA7C483c5099aeC225bA5E4269373F16b                                                                                         
timeboost-auctioneer-1     | INFO [11-27|23:21:48.011] Auction resolved successfully            txHash=0x6ff8058fd7ffb30089a9199a422675d8a882a3cf541e925e8a4
799c638314af9   

The ExpressLaneAuction contract auction resolution methods take Bid
objects as arguments which were previously expected to have the
signature field populated by using the "\x19Ethereum Signed Message:..."
hashing scheme applied over bid, contract, and chain details, then
signed. The contracts were updated to use EIP 712 which standardizes a
hashing scheme for structured data.

Briefly, EIP 712 produces the hash to be signed as follows:
keccak256("\x19\x01" ‖ domainSeparator ‖ hashStruct(message)). The
domainSeparator includes chain and contract details to prevent replay
attacks, and in our code we just fetch it from the contract using
domainSeparator() which internally uses the OpenZepplin library to
calculate it for the contract. hashStruct encodes type information about
the struct, in this case the "Bid(uint64 round,address
expressLaneController,uint256 amount)" along with the data. Geth has an
implementation of hashStruct that we use here.

The BidderClient generates the signature and the BidValidator uses the
signature and the hash to recover the sender, so these are the places
that needed to be updated. This PR also removes Bid.ToMessageBytes as
this serialization format was only used for generating the data to be
signed under the old scheme, and makes private ValidatedBid.bidBytes and
bigIntHash() since these are only used for tiebreaking in the BidCache
and nothing to do with signing.
@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant