Skip to content

Commit

Permalink
Accept useroperation with missing gas prices and limits eth_estimateU…
Browse files Browse the repository at this point in the history
…serOperationGas (#12)

* fix: accept useroperation with missing gas prices and limits eth_estimateUserOperationGas

* fix: add gas overhead for the entrypoint

* fix: only do binary search if call_gas_limit is zero

* Bump version
  • Loading branch information
sherifahmed990 authored May 22, 2024
1 parent 1e52bc2 commit 27db6e4
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 40 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "voltaire_bundler"
version = "v0.1.0-alpha.27"
version = "v0.1.0-alpha.29"
description = "EIP-4337 python Bundler"
authors = ["Candide Wallet Team"]
license = "LGPL"
Expand Down
Binary file modified voltaire-p2p
Binary file not shown.
1 change: 1 addition & 0 deletions voltaire_bundler/bundler/bundle/bundle_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ async def send_bundle(
user_operation.call_gas_limit
+ user_operation.verification_gas_limit * 3
)
gas_estimation += 10_000

call_data = encode_handleops_calldata(
user_operations_list, self.bundler_address
Expand Down
44 changes: 43 additions & 1 deletion voltaire_bundler/bundler/execution_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def __init__(
bundler_address: Address,
entrypoints: list[Address],
bundler_helper_byte_code: str,
entrypoint_mod_byte_code: str,
chain_id: int,
is_unsafe: bool,
is_legacy_mode: bool,
Expand Down Expand Up @@ -110,6 +111,7 @@ def __init__(
max_priority_fee_per_gas_percentage_multiplier,
max_verification_gas,
max_call_data_gas,
entrypoint_mod_byte_code,
)

self.user_operation_handler = UserOperationHandler(
Expand Down Expand Up @@ -301,7 +303,11 @@ async def _event_rpc_supportedEntryPoints(

async def _event_rpc_estimateUserOperationGas(
self, req_arguments: list) -> dict[str, str]:
user_operation: UserOperation = UserOperation(req_arguments[0])
user_operation_with_optional_params = (
fell_user_operation_optional_parameters(req_arguments[0])
)
user_operation: UserOperation = UserOperation(
user_operation_with_optional_params)
entrypoint_address: str = req_arguments[1]
state_override_set_dict: dict[str, Any] = {}
if req_arguments[2] is not None:
Expand Down Expand Up @@ -604,3 +610,39 @@ async def exception_handler_decorator(
except (ExecutionException, ValidationException) as excp:
rpc_call_response = {"payload": excp, "is_error": True}
return rpc_call_response


def fell_user_operation_optional_parameters(
user_operation_with_optional_params: dict[str, str]) -> dict[str, str]:
if (
"preVerificationGas" not in user_operation_with_optional_params
or
user_operation_with_optional_params["preVerificationGas"] is None
):
user_operation_with_optional_params["preVerificationGas"] = "0x"
if (
"verificationGasLimit" not in user_operation_with_optional_params
or
user_operation_with_optional_params["verificationGasLimit"] is None
):
user_operation_with_optional_params["verificationGasLimit"] = "0x"
if (
"callGasLimit" not in user_operation_with_optional_params
or
user_operation_with_optional_params["callGasLimit"] is None
):
user_operation_with_optional_params["callGasLimit"] = "0x"
if (
"maxFeePerGas" not in user_operation_with_optional_params
or
user_operation_with_optional_params["maxFeePerGas"] is None
):
user_operation_with_optional_params["maxFeePerGas"] = "0x"
if (
"maxPriorityFeePerGas" not in user_operation_with_optional_params
or
user_operation_with_optional_params["maxPriorityFeePerGas"] is None
):
user_operation_with_optional_params["maxPriorityFeePerGas"] = "0x"

return user_operation_with_optional_params
108 changes: 72 additions & 36 deletions voltaire_bundler/bundler/gas_manager.py

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions voltaire_bundler/cli_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class InitData:
bundler_pk: str
bundler_address: Address
bundler_helper_byte_code: str
entrypoint_mod_byte_code: str
chain_id: int
is_debug: bool
is_unsafe: bool
Expand Down Expand Up @@ -435,6 +436,18 @@ def init_bundler_helper():
return bundler_helper_byte_code


def init_entrypoint_mod():
package_directory = os.path.dirname(os.path.abspath(__file__))
entrypoint_mod_file = os.path.join(
package_directory, "utils", "EntryPointMod.json")

entrypoint_mod_byte_code_file = open(entrypoint_mod_file)
data = json.load(entrypoint_mod_byte_code_file)
entrypoint_mod_byte_code = data["bytecode"]

return entrypoint_mod_byte_code


def init_entrypoint_and_mempool_data(args: Namespace):
for (
entrypoint,
Expand Down Expand Up @@ -527,6 +540,7 @@ async def get_init_data(args: Namespace) -> InitData:
bundler_address, bundler_pk = init_bundler_address_and_secret(args)

bundler_helper_byte_code = init_bundler_helper()
entrypoint_mod_byte_code = init_entrypoint_mod()

if args.ethereum_node_debug_trace_call_url is None:
args.ethereum_node_debug_trace_call_url = args.ethereum_node_url
Expand All @@ -553,6 +567,7 @@ async def get_init_data(args: Namespace) -> InitData:
bundler_pk,
bundler_address,
bundler_helper_byte_code,
entrypoint_mod_byte_code,
args.chain_id,
args.debug,
args.unsafe,
Expand Down
1 change: 1 addition & 0 deletions voltaire_bundler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ async def main(cmd_args=sys.argv[1:], loop=None) -> None:
init_data.bundler_address,
init_data.entrypoints,
init_data.bundler_helper_byte_code,
init_data.entrypoint_mod_byte_code,
init_data.chain_id,
init_data.is_unsafe,
init_data.is_legacy_mode,
Expand Down
5 changes: 5 additions & 0 deletions voltaire_bundler/utils/EntryPointMod.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions voltaire_p2p/p2p_network/voltaire_version/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use target_info::Target;

pub const VERSION: &str = "Voltaire/v0.1.0a27";
pub const VERSION: &str = "Voltaire/v0.1.0a29";

/// Returns `VERSION`, but with platform information appended to the end.
///
/// ## Example
///
/// `Voltaire/v0.1.0a27/x86_64-linux`
/// `Voltaire/v0.1.0a29/x86_64-linux`
pub fn version_with_platform() -> String {
format!("{}/{}-{}", VERSION, Target::arch(), Target::os())
}

0 comments on commit 27db6e4

Please sign in to comment.