diff --git a/crates/core/component/auction/src/component/action_handler/dutch/withdraw.rs b/crates/core/component/auction/src/component/action_handler/dutch/withdraw.rs index 7eb0453d07..8a5e26a8a8 100644 --- a/crates/core/component/auction/src/component/action_handler/dutch/withdraw.rs +++ b/crates/core/component/auction/src/component/action_handler/dutch/withdraw.rs @@ -18,12 +18,18 @@ impl ActionHandler for ActionDutchAuctionWithdraw { self.seq ); + ensure!( + self.seq < u64::MAX, + "the sequence number maximum is `u64::MAX`" + ); + Ok(()) } async fn check_and_execute(&self, state: S) -> Result<()> { let auction_id = self.auction_id; + // Check that the auction exists and is a Dutch auction. let auction_state = state .get_dutch_auction_by_id(auction_id) .await @@ -33,6 +39,15 @@ impl ActionHandler for ActionDutchAuctionWithdraw { bail!("no auction found for id {auction_id}") }; + // Check that sequence number is incremented by one. + ensure!( + self.seq == auction_state.state.sequence.saturating_add(1), + "the action sequence number MUST be incremented by one (previous: {}, action: {})", + self.seq, + auction_state.state.sequence + ); + + // Check that the reported balance commitment, match the recorded reserves. let auction_input_reserves = Value { amount: auction_state.state.input_reserves, asset_id: auction_state.description.input.asset_id,