Skip to content

Commit

Permalink
feat: remove delegation whitelist (#62)
Browse files Browse the repository at this point in the history
After discussion w/ @onbjerg – this PR removes the delegation whitelist
check – allowing consumers to use their own delegation contracts.
Existing checks on gas limits to avoid abuse should be sufficient for
now.
  • Loading branch information
jxom authored Oct 28, 2024
1 parent e4c6f53 commit 3269b6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 33 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ Consult the [Kurtosis OP package](https://github.com/ethpandaops/optimism-packag

Odyssey has a custom `wallet_` namespace, that allows users to delegate their EOAs to a contract using EIP-7702, and perform transactions on those accounts, all funded by the sequencer.

To enable this namespace, set the environment variable `EXP1_SK` to a private key that will sign the transactions, and `EXP1_WHITELIST` to a comma-delimited list of checksummed addresses accounts are allowed to delegate to. The new RPC method, `odyssey_sendTransaction`, will only sign transactions that either:
To enable this namespace, set the environment variable `EXP1_SK` to a private key that will sign the transactions. The new RPC method, `wallet_sendTransaction`, will only sign transactions that either:

1. Delegate accounts to one of the whitelisted addresses using EIP-7702, or
1. Send transactions to an EIP-7702 EOA that is already delegated to a whitelisted address
1. Designates a contract address to an EOA via EIP-7702, or
1. Send transactions to an EIP-7702 EOA that is already delegated to an address

The `odyssey_sendTransaction` endpoint accepts the same fields as `eth_sendTransaction`, with these notable exceptions:

Expand All @@ -139,8 +139,6 @@ The following fields are ignored, as they are overwritten internally:
1. `gasLimit`
1. `chainId`

To get the list of contracts that are whitelisted for `odyssey_sendTransaction`, you can query `wallet_getCapabilities`.

### Security

See [SECURITY.md](SECURITY.md).
Expand Down
32 changes: 4 additions & 28 deletions crates/wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ pub trait OdysseyWalletApi {
///
/// The transaction will only be processed if:
///
/// - The transaction is an [EIP-7702][eip-7702] transaction that delegates to one of the
/// addresses listed in [`DelegationCapability`] (see [`Self::get_capabilities`])
/// - The transaction is an [EIP-7702][eip-7702] transaction.
/// - The transaction is an [EIP-1559][eip-1559] transaction to an EOA that is currently
/// delegated to one of the addresses above
/// - The value in the transaction is exactly 0.
Expand Down Expand Up @@ -123,19 +122,12 @@ pub enum OdysseyWalletError {
/// Requests with the nonce field set are rejected, as this is managed by the sequencer.
#[error("tx nonce is set")]
NonceSet,
/// An authorization item was invalid.
///
/// The item is invalid if it tries to delegate an account to a contract that is not
/// whitelisted.
#[error("invalid authorization address")]
InvalidAuthorization,
/// The to field of the transaction was invalid.
///
/// The destination is invalid if:
///
/// - There is no bytecode at the destination, or
/// - The bytecode is not an EIP-7702 delegation designator, or
/// - The delegation designator points to a contract that is not whitelisted
/// - The bytecode is not an EIP-7702 delegation designator
#[error("the destination of the transaction is not a delegated account")]
IllegalDestination,
/// The transaction request was invalid.
Expand Down Expand Up @@ -221,20 +213,6 @@ where
return Err(err.into());
}

let valid_delegations: &[Address] = self
.inner
.capabilities
.get(self.chain_id())
.map(|caps| caps.delegation.addresses.as_ref())
.unwrap_or_default();
if let Some(authorizations) = &request.authorization_list {
// check that all auth items delegate to a valid address
if authorizations.iter().any(|auth| !valid_delegations.contains(&auth.address)) {
self.inner.metrics.invalid_send_transaction_calls.increment(1);
return Err(OdysseyWalletError::InvalidAuthorization.into());
}
}

// validate destination
match (request.authorization_list.is_some(), request.to) {
// if this is an eip-1559 tx, ensure that it is an account that delegates to a
Expand All @@ -254,10 +232,8 @@ where
})
.unwrap_or_default();

// not a whitelisted address, or not an eip-7702 bytecode
if delegated_address == Address::ZERO
|| !valid_delegations.contains(&delegated_address)
{
// not eip-7702 bytecode
if delegated_address == Address::ZERO {
self.inner.metrics.invalid_send_transaction_calls.increment(1);
return Err(OdysseyWalletError::IllegalDestination.into());
}
Expand Down

0 comments on commit 3269b6a

Please sign in to comment.