Skip to content

Commit

Permalink
Always enable custom interactions and paying ETH to SCs (#2309)
Browse files Browse the repository at this point in the history
# Description
We no longer need to be able to disable creating orders with custom
interactions of orders paying ETH to smart contracts.

# Changes
Delete dead code

## How to test
CI, tests should continue to pass
  • Loading branch information
MartinquaXD authored Jan 22, 2024
1 parent 789fdd3 commit 8cbd962
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 74 deletions.
2 changes: 0 additions & 2 deletions crates/e2e/src/setup/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,10 @@ impl<'a> Services<'a> {
pub async fn start_api(&self, extra_args: Vec<String>) {
let args = [
"orderbook".to_string(),
"--enable-custom-interactions=true".to_string(),
format!(
"--hooks-contract-address={:?}",
self.contracts.hooks.address()
),
"--enable-eth-smart-contract-payments=true".to_string(),
]
.into_iter()
.chain(self.api_autopilot_solver_arguments())
Expand Down
3 changes: 0 additions & 3 deletions crates/orderbook/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1202,11 +1202,9 @@ components:
UnsupportedOrderType,
InsufficientValidTo,
ExcessiveValidTo,
TransferEthToContract,
InvalidNativeSellToken,
SameBuyAndSellToken,
UnsupportedToken,
UnsupportedCustomInteraction
InvalidAppData,
AppDataHashMismatch,
AppdataFromMismatch,
Expand Down Expand Up @@ -1254,7 +1252,6 @@ components:
InsufficientValidTo,
ExcessiveValidTo,
InvalidSignature,
TransferEthToContract,
TransferSimulationFailed,
UnsupportedToken,
WrongOwner,
Expand Down
14 changes: 0 additions & 14 deletions crates/orderbook/src/api/post_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ impl IntoWarpReply for PartialValidationErrorWrapper {
error("ExcessiveValidTo", "validTo is too far into the future"),
StatusCode::BAD_REQUEST,
),
PartialValidationError::TransferEthToContract => with_status(
error(
"TransferEthToContract",
"Sending Ether to smart contract wallets is currently not supported",
),
StatusCode::BAD_REQUEST,
),
PartialValidationError::InvalidNativeSellToken => with_status(
error(
"InvalidNativeSellToken",
Expand Down Expand Up @@ -100,13 +93,6 @@ pub struct AppDataValidationErrorWrapper(pub AppDataValidationError);
impl IntoWarpReply for AppDataValidationErrorWrapper {
fn into_warp_reply(self) -> ApiReply {
match self.0 {
AppDataValidationError::UnsupportedCustomInteraction => with_status(
error(
"UnsupportedCustomInteraction",
"The specified custom pre- or post- interaction is unsupported",
),
StatusCode::BAD_REQUEST,
),
AppDataValidationError::Invalid(err) => with_status(
error("InvalidAppData", format!("{:?}", err)),
StatusCode::BAD_REQUEST,
Expand Down
20 changes: 0 additions & 20 deletions crates/orderbook/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ pub struct Arguments {
#[clap(long, env, default_value = "10")]
pub max_limit_orders_per_user: u64,

/// Enable buy ETH orders paying to smart contract wallets.
#[clap(long, env, action = clap::ArgAction::Set, default_value = "false")]
pub enable_eth_smart_contract_payments: bool,

/// Enable support for orders with custom pre- and post-interactions.
#[clap(long, env, action = clap::ArgAction::Set, default_value = "false")]
pub enable_custom_interactions: bool,

/// If set, the orderbook will use this IPFS gateway to fetch full app data
/// for orders that only specify the contract app data hash.
#[clap(long, env)]
Expand Down Expand Up @@ -176,13 +168,11 @@ impl std::fmt::Display for Arguments {
native_price_estimators,
fast_price_estimation_results_required,
max_limit_orders_per_user,
enable_custom_interactions,
ipfs_gateway,
ipfs_pinata_auth,
hooks_contract_address,
app_data_size_limit,
db_url,
enable_eth_smart_contract_payments,
} = self;

write!(f, "{}", shared)?;
Expand Down Expand Up @@ -239,11 +229,6 @@ impl std::fmt::Display for Arguments {
"max_limit_orders_per_user: {}",
max_limit_orders_per_user
)?;
writeln!(
f,
"enable_custom_interactions: {:?}",
enable_custom_interactions
)?;
writeln!(f, "ipfs_gateway: {:?}", ipfs_gateway)?;
display_secret_option(f, "ipfs_pinata_auth", ipfs_pinata_auth)?;
display_option(
Expand All @@ -252,11 +237,6 @@ impl std::fmt::Display for Arguments {
&hooks_contract_address.map(|a| format!("{a:?}")),
)?;
writeln!(f, "app_data_size_limit: {}", app_data_size_limit)?;
writeln!(
f,
"enable_eth_smart_contract_payments: {}",
enable_eth_smart_contract_payments
)?;

Ok(())
}
Expand Down
2 changes: 0 additions & 2 deletions crates/orderbook/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,6 @@ pub async fn run(args: Arguments) {
Arc::new(CachedCodeFetcher::new(Arc::new(web3.clone()))),
app_data_validator.clone(),
)
.with_eth_smart_contract_payments(args.enable_eth_smart_contract_payments)
.with_custom_interactions(args.enable_custom_interactions)
.with_verified_quotes(args.price_estimation.trade_simulator.is_some()),
);
let ipfs = args
Expand Down
33 changes: 0 additions & 33 deletions crates/shared/src/order_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ pub trait OrderValidating: Send + Sync {
pub enum PartialValidationError {
Forbidden,
ValidTo(OrderValidToError),
TransferEthToContract,
InvalidNativeSellToken,
SameBuyAndSellToken,
UnsupportedBuyTokenDestination(BuyTokenDestination),
Expand All @@ -129,7 +128,6 @@ pub enum AppDataValidationError {
actual: AppDataHash,
},
Invalid(anyhow::Error),
UnsupportedCustomInteraction,
}

#[derive(Debug)]
Expand Down Expand Up @@ -252,8 +250,6 @@ pub struct OrderValidator {
limit_order_counter: Arc<dyn LimitOrderCounting>,
max_limit_orders_per_user: u64,
pub code_fetcher: Arc<dyn CodeFetching>,
pub enable_eth_smart_contract_payments: bool,
enable_custom_interactions: bool,
app_data_validator: crate::app_data::Validator,
request_verified_quotes: bool,
}
Expand Down Expand Up @@ -344,23 +340,11 @@ impl OrderValidator {
limit_order_counter,
max_limit_orders_per_user,
code_fetcher,
enable_eth_smart_contract_payments: false,
enable_custom_interactions: false,
app_data_validator,
request_verified_quotes: false,
}
}

pub fn with_eth_smart_contract_payments(mut self, enable: bool) -> Self {
self.enable_eth_smart_contract_payments = enable;
self
}

pub fn with_custom_interactions(mut self, enable: bool) -> Self {
self.enable_custom_interactions = enable;
self
}

pub fn with_verified_quotes(mut self, enable: bool) -> Self {
self.request_verified_quotes = enable;
self
Expand Down Expand Up @@ -454,16 +438,6 @@ impl OrderValidating for OrderValidator {
if order.sell_token == BUY_ETH_ADDRESS {
return Err(PartialValidationError::InvalidNativeSellToken);
}
if !self.enable_eth_smart_contract_payments && order.buy_token == BUY_ETH_ADDRESS {
let code_size = self
.code_fetcher
.code_size(order.receiver)
.await
.map_err(PartialValidationError::Other)?;
if code_size != 0 {
return Err(PartialValidationError::TransferEthToContract);
}
}

for &token in &[order.sell_token, order.buy_token] {
if let TokenQuality::Bad { reason } = self
Expand Down Expand Up @@ -522,11 +496,6 @@ impl OrderValidating for OrderValidator {
OrderCreationAppData::Full { full } => validate(full)?,
};

if !self.enable_custom_interactions && !app_data.protocol.hooks.is_empty() {
// contains some custom interactions while feature is disabled
return Err(AppDataValidationError::UnsupportedCustomInteraction);
}

let interactions = self.custom_interactions(&app_data.protocol.hooks);

Ok(OrderAppData {
Expand Down Expand Up @@ -1358,7 +1327,6 @@ mod tests {
.returning(|_| Ok(0u64));

let validator = OrderValidator {
enable_custom_interactions: true,
signature_validator: Arc::new(signature_validator),
..validator
};
Expand All @@ -1385,7 +1353,6 @@ mod tests {
.returning(|_| Err(SignatureValidationError::Invalid));

let validator = OrderValidator {
enable_custom_interactions: true,
signature_validator: Arc::new(signature_validator),
eip1271_skip_creation_validation: true,
..validator
Expand Down

0 comments on commit 8cbd962

Please sign in to comment.