From b5fa4288b8ba9db75c0dbc50cea7806fc552429b Mon Sep 17 00:00:00 2001 From: m-lord-renkse <160488334+m-lord-renkse@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:03:50 +0100 Subject: [PATCH] Driver & Autopilot: Remove deny_unknown_fields (#3137) # Description Remove `deny_unknown_fields` from the `Deserialized` objects in order to avoid crashing when new fields are added. --- .../autopilot/src/infra/solvers/dto/reveal.rs | 4 +-- .../autopilot/src/infra/solvers/dto/settle.rs | 4 +-- .../autopilot/src/infra/solvers/dto/solve.rs | 8 ++--- .../src/infra/api/routes/quote/dto/order.rs | 4 +-- .../src/infra/api/routes/solve/dto/auction.rs | 22 ++++++------- .../driver/src/infra/solver/dto/solution.rs | 32 +++++++++---------- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/crates/autopilot/src/infra/solvers/dto/reveal.rs b/crates/autopilot/src/infra/solvers/dto/reveal.rs index e8ac28f02a..f963fce1a5 100644 --- a/crates/autopilot/src/infra/solvers/dto/reveal.rs +++ b/crates/autopilot/src/infra/solvers/dto/reveal.rs @@ -18,7 +18,7 @@ pub struct Request { #[serde_as] #[derive(Clone, Debug, Default, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct Calldata { #[serde(with = "bytes_hex")] pub internalized: Vec, @@ -27,7 +27,7 @@ pub struct Calldata { } #[derive(Clone, Debug, Default, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct Response { pub calldata: Calldata, } diff --git a/crates/autopilot/src/infra/solvers/dto/settle.rs b/crates/autopilot/src/infra/solvers/dto/settle.rs index 0269e9425d..ef7f34465a 100644 --- a/crates/autopilot/src/infra/solvers/dto/settle.rs +++ b/crates/autopilot/src/infra/solvers/dto/settle.rs @@ -21,7 +21,7 @@ pub struct Request { #[serde_as] #[derive(Clone, Debug, Default, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct Response { pub calldata: Calldata, pub tx_hash: H256, @@ -29,7 +29,7 @@ pub struct Response { #[serde_as] #[derive(Clone, Debug, Default, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct Calldata { #[serde(with = "bytes_hex")] pub internalized: Vec, diff --git a/crates/autopilot/src/infra/solvers/dto/solve.rs b/crates/autopilot/src/infra/solvers/dto/solve.rs index 693fec6d76..3ec1de1ff5 100644 --- a/crates/autopilot/src/infra/solvers/dto/solve.rs +++ b/crates/autopilot/src/infra/solvers/dto/solve.rs @@ -116,7 +116,7 @@ impl Solution { /// settled on-chain. #[serde_as] #[derive(Clone, Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct TradedOrder { side: Side, sell_token: H160, @@ -158,7 +158,7 @@ impl TradedOrder { #[serde_as] #[derive(Clone, Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub enum Side { Buy, Sell, @@ -166,7 +166,7 @@ pub enum Side { #[serde_as] #[derive(Clone, Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct Solution { /// Unique ID of the solution (per driver competition), used to identify /// it in subsequent requests (reveal, settle). @@ -214,7 +214,7 @@ where } #[derive(Clone, Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct Response { pub solutions: Vec, } diff --git a/crates/driver/src/infra/api/routes/quote/dto/order.rs b/crates/driver/src/infra/api/routes/quote/dto/order.rs index 6bf7115560..81feb86cfa 100644 --- a/crates/driver/src/infra/api/routes/quote/dto/order.rs +++ b/crates/driver/src/infra/api/routes/quote/dto/order.rs @@ -25,7 +25,7 @@ impl Order { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct Order { sell_token: eth::H160, buy_token: eth::H160, @@ -36,7 +36,7 @@ pub struct Order { } #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] enum Kind { Sell, Buy, diff --git a/crates/driver/src/infra/api/routes/solve/dto/auction.rs b/crates/driver/src/infra/api/routes/solve/dto/auction.rs index 6da629a6b3..38138face1 100644 --- a/crates/driver/src/infra/api/routes/solve/dto/auction.rs +++ b/crates/driver/src/infra/api/routes/solve/dto/auction.rs @@ -197,7 +197,7 @@ impl From for Error { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct Auction { #[serde_as(as = "serde_with::DisplayFromStr")] id: i64, @@ -216,7 +216,7 @@ impl Auction { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] struct Token { pub address: eth::H160, #[serde_as(as = "Option")] @@ -226,7 +226,7 @@ struct Token { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] struct Order { #[serde_as(as = "serialize::Hex")] uid: [u8; order::UID_LEN], @@ -262,7 +262,7 @@ struct Order { } #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] enum Kind { Sell, Buy, @@ -270,7 +270,7 @@ enum Kind { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] struct Interaction { target: eth::H160, #[serde_as(as = "serialize::U256")] @@ -280,7 +280,7 @@ struct Interaction { } #[derive(Debug, Default, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] enum SellTokenBalance { #[default] Erc20, @@ -289,7 +289,7 @@ enum SellTokenBalance { } #[derive(Debug, Default, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] enum BuyTokenBalance { #[default] Erc20, @@ -297,7 +297,7 @@ enum BuyTokenBalance { } #[derive(Debug, Deserialize)] -#[serde(rename_all = "lowercase", deny_unknown_fields)] +#[serde(rename_all = "lowercase")] enum SigningScheme { Eip712, EthSign, @@ -306,14 +306,14 @@ enum SigningScheme { } #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] enum Class { Market, Limit, } #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] enum FeePolicy { #[serde(rename_all = "camelCase")] Surplus { factor: f64, max_volume_factor: f64 }, @@ -329,7 +329,7 @@ enum FeePolicy { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct Quote { #[serde_as(as = "serialize::U256")] pub sell_amount: eth::U256, diff --git a/crates/driver/src/infra/solver/dto/solution.rs b/crates/driver/src/infra/solver/dto/solution.rs index 68bf60a4a4..cab042285d 100644 --- a/crates/driver/src/infra/solver/dto/solution.rs +++ b/crates/driver/src/infra/solver/dto/solution.rs @@ -223,14 +223,14 @@ impl Solutions { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct Solutions { solutions: Vec, } #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct Solution { id: u64, #[serde_as(as = "HashMap<_, serialize::U256>")] @@ -245,7 +245,7 @@ pub struct Solution { } #[derive(Debug, Deserialize)] -#[serde(tag = "kind", rename_all = "camelCase", deny_unknown_fields)] +#[serde(tag = "kind", rename_all = "camelCase")] enum Trade { Fulfillment(Fulfillment), Jit(JitTrade), @@ -253,7 +253,7 @@ enum Trade { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] struct Fulfillment { #[serde_as(as = "serialize::Hex")] order: [u8; order::UID_LEN], @@ -265,7 +265,7 @@ struct Fulfillment { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] struct JitTrade { order: JitOrder, #[serde_as(as = "serialize::U256")] @@ -277,7 +277,7 @@ struct JitTrade { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] struct JitOrder { sell_token: eth::H160, buy_token: eth::H160, @@ -376,14 +376,14 @@ impl JitOrder { } #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] enum Kind { Sell, Buy, } #[derive(Debug, Deserialize)] -#[serde(tag = "kind", rename_all = "camelCase", deny_unknown_fields)] +#[serde(tag = "kind", rename_all = "camelCase")] enum Interaction { Liquidity(LiquidityInteraction), Custom(CustomInteraction), @@ -391,7 +391,7 @@ enum Interaction { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] struct LiquidityInteraction { internalize: bool, #[serde_as(as = "serde_with::DisplayFromStr")] @@ -406,7 +406,7 @@ struct LiquidityInteraction { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] struct CustomInteraction { internalize: bool, target: eth::H160, @@ -421,7 +421,7 @@ struct CustomInteraction { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] struct Asset { token: eth::H160, #[serde_as(as = "serialize::U256")] @@ -430,7 +430,7 @@ struct Asset { #[serde_as] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] struct Allowance { token: eth::H160, spender: eth::H160, @@ -439,7 +439,7 @@ struct Allowance { } #[derive(Debug, Default, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] enum SellTokenBalance { #[default] Erc20, @@ -448,7 +448,7 @@ enum SellTokenBalance { } #[derive(Debug, Default, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] enum BuyTokenBalance { #[default] Erc20, @@ -456,7 +456,7 @@ enum BuyTokenBalance { } #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(rename_all = "camelCase")] enum SigningScheme { Eip712, EthSign, @@ -467,7 +467,7 @@ enum SigningScheme { #[serde_as] #[allow(dead_code)] #[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase", deny_unknown_fields, tag = "kind")] +#[serde(rename_all = "camelCase", tag = "kind")] pub enum Score { Solver { #[serde_as(as = "serialize::U256")]