mirror of
https://github.com/0xbow-io/privacy-pools-core.git
synced 2026-01-10 09:58:00 -05:00
feat: rejecting relays where feeCommitment value quote is different from withdrawn
This commit is contained in:
@@ -16,6 +16,7 @@ export enum ErrorCode {
|
||||
CONTEXT_MISMATCH = "CONTEXT_MISMATCH",
|
||||
RELAYER_COMMITMENT_REJECTED = "RELAYER_COMMITMENT_REJECTED",
|
||||
INSUFFICIENT_WITHDRAWN_VALUE = "INSUFFICIENT_WITHDRAWN_VALUE",
|
||||
MISMATCHING_WITHDRAWN_VALUE = "MISMATCHING_WITHDRAWN_VALUE",
|
||||
ASSET_NOT_SUPPORTED = "ASSET_NOT_SUPPORTED",
|
||||
|
||||
// Config errors
|
||||
@@ -252,6 +253,14 @@ export class WithdrawalValidationError extends RelayerError {
|
||||
);
|
||||
}
|
||||
|
||||
public static withdrawnValueMismatch(details: string) {
|
||||
return new WithdrawalValidationError(
|
||||
"Withdrawn value is too small",
|
||||
ErrorCode.INSUFFICIENT_WITHDRAWN_VALUE,
|
||||
details,
|
||||
);
|
||||
}
|
||||
|
||||
public static override assetNotSupported(details: string) {
|
||||
return new WithdrawalValidationError(
|
||||
"Asset not supported on this chain",
|
||||
|
||||
@@ -236,9 +236,9 @@ export class PrivacyPoolRelayer {
|
||||
const { feeRecipient, relayFeeBPS } = decodeWithdrawalData(withdrawalData);
|
||||
const proofSignals = parseSignals(wp.proof.publicSignals);
|
||||
|
||||
if ((wp.feeCommitment !== undefined) && (wp.feeCommitment.amount > proofSignals.withdrawnValue)) {
|
||||
if ((wp.feeCommitment !== undefined) && (wp.feeCommitment.amount !== proofSignals.withdrawnValue)) {
|
||||
throw WithdrawalValidationError.withdrawnValueTooSmall(
|
||||
`WithdrawnValue too small: expected "${wp.feeCommitment.amount}", got "${proofSignals.withdrawnValue}".`,
|
||||
`WithdrawnValue mismatch: expected "${wp.feeCommitment.amount}", got "${proofSignals.withdrawnValue}".`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user