Files
serai/processor/ethereum/deployer
Luke Parker 184c02714a alloy-core 1.0, alloy 0.14, revm 0.22 (001)
This moves to Rust 1.86 as were prior on Rust 1.81, and the new alloy
dependencies require 1.82.

The revm API changes were notable for us. Instead of relying on a modified call
instruction (with deep introspection into the EVM design), we now use the more
recent and now more prominent Inspector API. This:

1) Lets us perform far less introspection
2) Forces us to rewrite the gas estimation code we just had audited

Thankfully, it itself should be much easier to read/review, and our existing
test suite has extensively validated it.

This resolves 001 which was a concern for if/when this upgrade occurs. By doing
it now, with a dedicated test case ensuring the issue we would have had with
alloy-core 0.8 and `validate=false` isn't actively an issue, we resolve it.
2025-04-12 08:09:09 -04:00
..
2024-09-19 23:36:32 -07:00
2024-09-19 23:36:32 -07:00

Ethereum Smart Contracts Deployer

The deployer for Serai's Ethereum contracts.

Goals

It should be possible to efficiently locate the Serai Router on a blockchain with the EVM, without relying on any centralized (or even federated) entities. While deploying and locating an instance of the Router would be trivial, by using a fixed signature for the deployment transaction, the Router must be constructed with the correct key for the Serai network (or set to have the correct key post-construction). Since this cannot be guaranteed to occur, the process must be retryable and the first successful invocation must be efficiently findable.

Methodology

We define a contract, the Deployer, to deploy the Router. This contract could use CREATE2 with the key representing Serai as the salt, yet this would be open to collision attacks with just 2**80 complexity. Instead, we use CREATE which would require 2**80 on-chain transactions (infeasible) to use as the basis of a collision.

In order to efficiently find the contract for a key, the Deployer contract saves the addresses of deployed contracts (indexed by the initialization code's hash). This allows using a single call to a contract with a known address to find the proper Router. Saving the address to the state enables finding the Router's address even if the connected-to node's logs have been pruned for historical blocks.