Skip to content

Commit cf58520

Browse files
feat(errors): catch error and map to invalid params (#1146)
1 parent d9aadd3 commit cf58520

5 files changed

Lines changed: 32 additions & 15 deletions

File tree

crates/pool/proto/op_pool/op_pool.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ message MempoolError {
620620
TooManyExpectedStorageSlots too_many_expected_storage_slots = 19;
621621
UseUnsupportedEIP use_unsupported_eip = 20;
622622
AggregatorError aggregator = 21;
623+
Invalid7702AuthSignature invalid_7702_auth_signature = 22;
623624
}
624625
}
625626

@@ -660,6 +661,9 @@ message SenderAddressUsedAsAlternateEntity {
660661

661662
message DiscardedOnInsertError {}
662663

664+
message Invalid7702AuthSignature {
665+
string reason = 1;
666+
}
663667

664668
message AggregatorError {
665669
string reason = 1;

crates/pool/src/mempool/pool.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,8 @@ where
453453
.chain_spec
454454
.supports_eip7702(self.config.entry_point)
455455
{
456-
auth.validate(uo.sender())?;
456+
auth.validate(uo.sender())
457+
.map_err(|err| MempoolError::Invalid7702AuthSignature(err.to_string()))?;
457458
Ok(())
458459
} else {
459460
Err(MempoolError::EIPNotSupported("EIP-7702".to_string()))

crates/pool/src/server/remote/error.rs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ use super::protos::{
2828
CallGasLimitTooLow, CallHadValue, CalledBannedEntryPointMethod, CodeHashChanged, DidNotRevert,
2929
DiscardedOnInsertError, Entity, EntityThrottledError, EntityType, EntryPointRevert,
3030
ExecutionGasLimitEfficiencyTooLow, ExistingSenderWithInitCode, FactoryCalledCreate2Twice,
31-
FactoryIsNotContract, FactoryMustBeEmpty, InvalidAccountSignature, InvalidPaymasterSignature,
32-
InvalidSignature, InvalidStorageAccess, InvalidTimeRange, MaxFeePerGasTooLow,
33-
MaxOperationsReachedError, MaxPriorityFeePerGasTooLow, MempoolError as ProtoMempoolError,
34-
MultipleRolesViolation, NotStaked, OperationAlreadyKnownError, OperationDropTooSoon,
35-
OperationRevert, OutOfGas, OverMaxCost, PanicRevert, PaymasterBalanceTooLow,
36-
PaymasterDepositTooLow, PaymasterIsNotContract, PreVerificationGasTooLow,
37-
PrecheckViolationError as ProtoPrecheckViolationError, ReplacementUnderpricedError,
38-
SenderAddressUsedAsAlternateEntity, SenderFundsTooLow, SenderIsNotContractAndNoInitCode,
39-
SimulationViolationError as ProtoSimulationViolationError, TooManyExpectedStorageSlots,
40-
TotalGasLimitTooHigh, UnintendedRevert, UnintendedRevertWithMessage, UnknownEntryPointError,
41-
UnknownRevert, UnstakedPaymasterContext, UseUnsupportedEip, UsedForbiddenOpcode,
42-
UsedForbiddenPrecompile, ValidationRevert as ProtoValidationRevert,
43-
VerificationGasLimitBufferTooLow, VerificationGasLimitEfficiencyTooLow,
44-
VerificationGasLimitTooHigh, WrongNumberOfPhases,
31+
FactoryIsNotContract, FactoryMustBeEmpty, Invalid7702AuthSignature, InvalidAccountSignature,
32+
InvalidPaymasterSignature, InvalidSignature, InvalidStorageAccess, InvalidTimeRange,
33+
MaxFeePerGasTooLow, MaxOperationsReachedError, MaxPriorityFeePerGasTooLow,
34+
MempoolError as ProtoMempoolError, MultipleRolesViolation, NotStaked,
35+
OperationAlreadyKnownError, OperationDropTooSoon, OperationRevert, OutOfGas, OverMaxCost,
36+
PanicRevert, PaymasterBalanceTooLow, PaymasterDepositTooLow, PaymasterIsNotContract,
37+
PreVerificationGasTooLow, PrecheckViolationError as ProtoPrecheckViolationError,
38+
ReplacementUnderpricedError, SenderAddressUsedAsAlternateEntity, SenderFundsTooLow,
39+
SenderIsNotContractAndNoInitCode, SimulationViolationError as ProtoSimulationViolationError,
40+
TooManyExpectedStorageSlots, TotalGasLimitTooHigh, UnintendedRevert,
41+
UnintendedRevertWithMessage, UnknownEntryPointError, UnknownRevert, UnstakedPaymasterContext,
42+
UseUnsupportedEip, UsedForbiddenOpcode, UsedForbiddenPrecompile,
43+
ValidationRevert as ProtoValidationRevert, VerificationGasLimitBufferTooLow,
44+
VerificationGasLimitEfficiencyTooLow, VerificationGasLimitTooHigh, WrongNumberOfPhases,
4545
};
4646

4747
impl TryFrom<ProtoMempoolError> for PoolError {
@@ -141,6 +141,9 @@ impl TryFrom<ProtoMempoolError> for MempoolError {
141141
Some(mempool_error::Error::UseUnsupportedEip(e)) => {
142142
MempoolError::EIPNotSupported(e.eip_name)
143143
}
144+
Some(mempool_error::Error::Invalid7702AuthSignature(e)) => {
145+
MempoolError::Invalid7702AuthSignature(e.reason)
146+
}
144147
None => bail!("unknown proto mempool error"),
145148
})
146149
}
@@ -270,6 +273,11 @@ impl From<MempoolError> for ProtoMempoolError {
270273
eip_name: msg,
271274
})),
272275
},
276+
MempoolError::Invalid7702AuthSignature(msg) => ProtoMempoolError {
277+
error: Some(mempool_error::Error::Invalid7702AuthSignature(
278+
Invalid7702AuthSignature { reason: msg },
279+
)),
280+
},
273281
}
274282
}
275283
}

crates/rpc/src/eth/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ impl From<MempoolError> for EthRpcError {
315315
| MempoolError::VerificationGasLimitEfficiencyTooLow(_, _)
316316
| MempoolError::ExecutionGasLimitEfficiencyTooLow(_, _)
317317
| MempoolError::TooManyExpectedStorageSlots(_, _)
318+
| MempoolError::Invalid7702AuthSignature(_)
318319
| MempoolError::EIPNotSupported(_) => Self::InvalidParams(value.to_string()),
319320
}
320321
}

crates/types/src/pool/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ pub enum MempoolError {
7575
/// Operation was discarded on inserting due to size limit
7676
#[error("Operation was discarded on inserting")]
7777
DiscardedOnInsert,
78+
/// Operation 7702 Authorization tuple was signed with the wrong address
79+
#[error("Invalid 7702 Auth signature: {0}")]
80+
Invalid7702AuthSignature(String),
7881
/// Paymaster balance too low
7982
/// Spec rule: EREP-010
8083
#[error("Paymaster balance too low. Required balance: {0}. Current balance {1}")]

0 commit comments

Comments
 (0)