Skip to content

Commit

Permalink
fix: accept lowercase entrypoint for rpc parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sherifahmed990 committed Oct 3, 2024
1 parent 32c1fbd commit 88e0de0
Showing 1 changed file with 68 additions and 18 deletions.
86 changes: 68 additions & 18 deletions voltaire_bundler/execution_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,17 @@ async def _event_rpc_estimateUserOperationGas(
"Invalide state override set",
)

entrypoint: Address = req_arguments[1]
if entrypoint == LocalMempoolManagerV7.entrypoint:
input_entrypoint: Address = req_arguments[1]
if isinstance(input_entrypoint, str):
input_entrypoint = Address(input_entrypoint.lower())
else:
raise ValidationException(
ValidationExceptionCode.InvalidFields,
"Invalid entrypoint",
)

if input_entrypoint == LocalMempoolManagerV7.entrypoint_lowercase:
entrypoint = LocalMempoolManagerV7.entrypoint
user_operation_with_optional_params = (
fell_user_operation_optional_parameters(
req_arguments[0]))
Expand All @@ -271,8 +280,9 @@ async def _event_rpc_estimateUserOperationGas(
"preVerificationGas": preverification_gas_hex,
"verificationGasLimit": verification_gas_hex,
}
elif (entrypoint == LocalMempoolManagerV6.entrypoint and
elif (input_entrypoint == LocalMempoolManagerV6.entrypoint_lowercase and
self.user_operation_handler_v6 is not None):
entrypoint = LocalMempoolManagerV6.entrypoint
user_operation_with_optional_params = (
fell_user_operation_optional_parameters(
req_arguments[0])
Expand Down Expand Up @@ -304,11 +314,19 @@ async def _event_rpc_estimateUserOperationGas(

async def _event_rpc_sendUserOperation(self, req_arguments: list) -> str:
useroperation_arg = req_arguments[0]
entrypoint = req_arguments[1]
if entrypoint == LocalMempoolManagerV7.entrypoint:
input_entrypoint: Address = req_arguments[1]
if isinstance(input_entrypoint, str):
input_entrypoint = Address(input_entrypoint.lower())
else:
raise ValidationException(
ValidationExceptionCode.InvalidFields,
"Invalid entrypoint",
)

if input_entrypoint == LocalMempoolManagerV7.entrypoint_lowercase:
user_operation = UserOperationV7(useroperation_arg)
local_mempool = self.local_mempool_manager_v7
elif (entrypoint == LocalMempoolManagerV6.entrypoint and
elif (input_entrypoint == LocalMempoolManagerV6.entrypoint_lowercase and
self.local_mempool_manager_v6 is not None):
user_operation = UserOperationV6(useroperation_arg)
local_mempool = self.local_mempool_manager_v6
Expand Down Expand Up @@ -408,10 +426,18 @@ async def _event_debug_bundler_clearState(self, _) -> str:

async def _event_debug_bundler_dumpMempool(
self, req_arguments: list) -> list[dict[str, str | None]]:
entrypoint = req_arguments[0]
if entrypoint == LocalMempoolManagerV7.entrypoint:
input_entrypoint: Address = req_arguments[0]
if isinstance(input_entrypoint, str):
input_entrypoint = Address(input_entrypoint.lower())
else:
raise ValidationException(
ValidationExceptionCode.InvalidFields,
"Invalid entrypoint",
)

if input_entrypoint == LocalMempoolManagerV7.entrypoint_lowercase:
local_mempool = self.local_mempool_manager_v7
elif (entrypoint == LocalMempoolManagerV6.entrypoint and
elif (input_entrypoint == LocalMempoolManagerV6.entrypoint_lowercase and
self.local_mempool_manager_v6 is not None):
local_mempool = self.local_mempool_manager_v6
else:
Expand All @@ -429,11 +455,18 @@ async def _event_debug_bundler_dumpMempool(

async def _event_debug_bundler_setReputation(
self, req_arguments: list) -> str:
entrypoint = req_arguments[1]
input_entrypoint: Address = req_arguments[1]
if isinstance(input_entrypoint, str):
input_entrypoint = Address(input_entrypoint.lower())
else:
raise ValidationException(
ValidationExceptionCode.InvalidFields,
"Invalid entrypoint",
)

if entrypoint == LocalMempoolManagerV7.entrypoint:
if input_entrypoint == LocalMempoolManagerV7.entrypoint_lowercase:
local_mempool = self.local_mempool_manager_v7
elif (entrypoint == LocalMempoolManagerV6.entrypoint and
elif (input_entrypoint == LocalMempoolManagerV6.entrypoint_lowercase and
self.local_mempool_manager_v6 is not None):
local_mempool = self.local_mempool_manager_v6
else:
Expand Down Expand Up @@ -472,11 +505,18 @@ async def _event_debug_bundler_clearReputation(self, _: list) -> str:

async def _event_debug_bundler_dumpReputation(
self, req_arguments: list) -> list[dict[str, str]]:
entrypoint = req_arguments[0]
input_entrypoint: Address = req_arguments[0]
if isinstance(input_entrypoint, str):
input_entrypoint = Address(input_entrypoint.lower())
else:
raise ValidationException(
ValidationExceptionCode.InvalidFields,
"Invalid entrypoint",
)

if entrypoint == LocalMempoolManagerV7.entrypoint:
if input_entrypoint == LocalMempoolManagerV7.entrypoint_lowercase:
local_mempool = self.local_mempool_manager_v7
elif (entrypoint == LocalMempoolManagerV6.entrypoint and
elif (input_entrypoint == LocalMempoolManagerV6.entrypoint_lowercase and
self.local_mempool_manager_v6 is not None):
local_mempool = self.local_mempool_manager_v6
else:
Expand All @@ -493,11 +533,21 @@ async def _event_debug_bundler_dumpReputation(
async def _event_debug_bundler_getStakeStatus(
self, req_arguments: list) -> dict:
address = req_arguments[0]
entrypoint = req_arguments[1]
if entrypoint == LocalMempoolManagerV7.entrypoint:
input_entrypoint: Address = req_arguments[1]
if isinstance(input_entrypoint, str):
input_entrypoint = Address(input_entrypoint.lower())
else:
raise ValidationException(
ValidationExceptionCode.InvalidFields,
"Invalid entrypoint",
)

if input_entrypoint == LocalMempoolManagerV7.entrypoint_lowercase:
entrypoint = LocalMempoolManagerV7.entrypoint
local_mempool = self.local_mempool_manager_v7
elif (entrypoint == LocalMempoolManagerV6.entrypoint and
elif (input_entrypoint == LocalMempoolManagerV6.entrypoint_lowercase and
self.local_mempool_manager_v6 is not None):
entrypoint = LocalMempoolManagerV6.entrypoint
local_mempool = self.local_mempool_manager_v6
else:
raise ValidationException(
Expand Down

0 comments on commit 88e0de0

Please sign in to comment.