eth-prototype 1.2.0__tar.gz → 1.2.1b1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/PKG-INFO +1 -1
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/eth_prototype.egg-info/PKG-INFO +1 -1
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/ethproto/aa_bundler.py +62 -17
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/.coveragerc +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/.github/workflows/publish.yaml +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/.github/workflows/test.yaml +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/.gitignore +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/.isort.cfg +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/.pre-commit-config.yaml +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/.readthedocs.yml +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/AUTHORS.rst +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/CHANGELOG.rst +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/LICENSE.txt +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/README.md +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/docs/Makefile +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/docs/_static/.gitignore +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/docs/authors.rst +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/docs/changelog.rst +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/docs/conf.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/docs/index.rst +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/docs/license.rst +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/docs/readme.rst +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/docs/requirements.txt +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/pyproject.toml +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/setup.cfg +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/setup.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/eth_prototype.egg-info/SOURCES.txt +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/eth_prototype.egg-info/dependency_links.txt +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/eth_prototype.egg-info/not-zip-safe +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/eth_prototype.egg-info/requires.txt +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/eth_prototype.egg-info/top_level.txt +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/ethproto/__init__.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/ethproto/build_artifacts.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/ethproto/contracts.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/ethproto/defender_relay.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/ethproto/w3wrappers.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/ethproto/wadray.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/ethproto/wrappers.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/conftest.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/README.md +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/artifacts2/TestCurrency.sol/TestCurrency.json +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/Count.sol +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/Counter.sol +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/CounterUpgradeable.sol +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/CounterUpgradeableWithLibrary.sol +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/CounterWithLibrary.sol +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/Datatypes.sol +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/EventLauncher.sol +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/TestCurrency.sol +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/TestCurrencyUUPS.sol +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/TestNFT.sol +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/hardhat.config.js +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/package-lock.json +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/package.json +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/test_aa_bundler.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/test_build_artifacts.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/test_contracts.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/test_defender.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/test_time_control.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/test_w3.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/test_wadray.py +0 -0
- {eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tox.ini +0 -0
@@ -1,4 +1,5 @@
|
|
1
1
|
import random
|
2
|
+
from collections import defaultdict
|
2
3
|
from enum import Enum
|
3
4
|
from warnings import warn
|
4
5
|
|
@@ -22,6 +23,7 @@ AA_BUNDLER_PROVIDER = env.str("AA_BUNDLER_PROVIDER", "alchemy")
|
|
22
23
|
AA_BUNDLER_GAS_LIMIT_FACTOR = env.float("AA_BUNDLER_GAS_LIMIT_FACTOR", 1)
|
23
24
|
AA_BUNDLER_PRIORITY_GAS_PRICE_FACTOR = env.float("AA_BUNDLER_PRIORITY_GAS_PRICE_FACTOR", 1)
|
24
25
|
AA_BUNDLER_BASE_GAS_PRICE_FACTOR = env.float("AA_BUNDLER_BASE_GAS_PRICE_FACTOR", 1)
|
26
|
+
AA_BUNDLER_VERIFICATION_GAS_FACTOR = env.float("AA_BUNDLER_VERIFICATION_GAS_FACTOR", 1)
|
25
27
|
|
26
28
|
NonceMode = Enum(
|
27
29
|
"NonceMode",
|
@@ -51,7 +53,7 @@ GET_NONCE_ABI = [
|
|
51
53
|
}
|
52
54
|
]
|
53
55
|
|
54
|
-
NONCE_CACHE =
|
56
|
+
NONCE_CACHE = defaultdict(lambda: 0)
|
55
57
|
RANDOM_NONCE_KEY = None
|
56
58
|
|
57
59
|
|
@@ -69,6 +71,10 @@ def _to_uint(x):
|
|
69
71
|
raise RuntimeError(f"Invalid int value {x}")
|
70
72
|
|
71
73
|
|
74
|
+
def apply_factor(x, factor):
|
75
|
+
return int(_to_uint(x) * factor)
|
76
|
+
|
77
|
+
|
72
78
|
def pack_user_operation(user_operation):
|
73
79
|
# https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/interfaces/PackedUserOperation.sol
|
74
80
|
return {
|
@@ -153,20 +159,25 @@ def get_nonce_and_key(w3, tx, nonce_mode, entry_point=AA_BUNDLER_ENTRYPOINT, fet
|
|
153
159
|
if nonce is None:
|
154
160
|
if fetch or nonce_mode == NonceMode.FIXED_KEY_FETCH_ALWAYS:
|
155
161
|
nonce = fetch_nonce(w3, get_sender(tx), entry_point, nonce_key)
|
156
|
-
elif nonce_key not in NONCE_CACHE:
|
157
|
-
nonce = 0
|
158
162
|
else:
|
159
163
|
nonce = NONCE_CACHE[nonce_key]
|
160
164
|
return nonce_key, nonce
|
161
165
|
|
162
166
|
|
163
|
-
def
|
167
|
+
def consume_nonce(nonce_key, nonce):
|
168
|
+
NONCE_CACHE[nonce_key] = max(NONCE_CACHE[nonce_key], nonce + 1)
|
169
|
+
|
170
|
+
|
171
|
+
def check_nonce_error(resp, retry_nonce):
|
172
|
+
"""Returns the next nonce if resp contains a nonce error and retries weren't exhausted
|
173
|
+
Raises RevertError otherwise
|
174
|
+
"""
|
164
175
|
if "AA25" in resp["error"]["message"] and AA_BUNDLER_MAX_GETNONCE_RETRIES > 0:
|
165
176
|
# Retry fetching the nonce
|
166
177
|
if retry_nonce == AA_BUNDLER_MAX_GETNONCE_RETRIES:
|
167
178
|
raise RevertError(resp["error"]["message"])
|
168
179
|
warn(f'{resp["error"]["message"]} error, I will retry fetching the nonce')
|
169
|
-
return
|
180
|
+
return (retry_nonce or 0) + 1
|
170
181
|
else:
|
171
182
|
raise RevertError(resp["error"]["message"])
|
172
183
|
|
@@ -185,7 +196,7 @@ def get_sender(tx):
|
|
185
196
|
return tx["from"]
|
186
197
|
|
187
198
|
|
188
|
-
def
|
199
|
+
def build_user_operation(w3, tx, retry_nonce=None):
|
189
200
|
nonce_key, nonce = get_nonce_and_key(
|
190
201
|
w3, tx, AA_BUNDLER_NONCE_MODE, entry_point=AA_BUNDLER_ENTRYPOINT, fetch=retry_nonce is not None
|
191
202
|
)
|
@@ -210,18 +221,19 @@ def send_transaction(w3, tx, retry_nonce=None):
|
|
210
221
|
"eth_estimateUserOperationGas", [user_operation, AA_BUNDLER_ENTRYPOINT]
|
211
222
|
)
|
212
223
|
if "error" in resp:
|
213
|
-
|
224
|
+
next_nonce = check_nonce_error(resp, retry_nonce)
|
225
|
+
return build_user_operation(w3, tx, retry_nonce=next_nonce)
|
214
226
|
|
215
227
|
user_operation.update(resp["result"])
|
216
228
|
|
217
229
|
resp = w3.provider.make_request("rundler_maxPriorityFeePerGas", [])
|
218
230
|
if "error" in resp:
|
219
231
|
raise RevertError(resp["error"]["message"])
|
220
|
-
max_priority_fee_per_gas =
|
232
|
+
max_priority_fee_per_gas = apply_factor(resp["result"], AA_BUNDLER_PRIORITY_GAS_PRICE_FACTOR)
|
221
233
|
user_operation["maxPriorityFeePerGas"] = hex(max_priority_fee_per_gas)
|
222
234
|
user_operation["maxFeePerGas"] = hex(max_priority_fee_per_gas + get_base_fee(w3))
|
223
235
|
user_operation["callGasLimit"] = hex(
|
224
|
-
|
236
|
+
apply_factor(user_operation["callGasLimit"], AA_BUNDLER_GAS_LIMIT_FACTOR)
|
225
237
|
)
|
226
238
|
elif AA_BUNDLER_PROVIDER == "gelato":
|
227
239
|
user_operation.update(
|
@@ -233,21 +245,54 @@ def send_transaction(w3, tx, retry_nonce=None):
|
|
233
245
|
"maxPriorityFeePerGas": "0x00",
|
234
246
|
}
|
235
247
|
)
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
)
|
240
|
-
|
248
|
+
elif AA_BUNDLER_PROVIDER == "generic":
|
249
|
+
resp = w3.provider.make_request(
|
250
|
+
"eth_estimateUserOperationGas", [user_operation, AA_BUNDLER_ENTRYPOINT]
|
251
|
+
)
|
252
|
+
if "error" in resp:
|
253
|
+
next_nonce = check_nonce_error(resp, retry_nonce)
|
254
|
+
return build_user_operation(w3, tx, retry_nonce=next_nonce)
|
255
|
+
|
256
|
+
user_operation.update(resp["result"])
|
257
|
+
|
258
|
+
user_operation["verificationGasLimit"] = apply_factor(
|
259
|
+
user_operation["verificationGasLimit"], AA_BUNDLER_VERIFICATION_GAS_FACTOR
|
260
|
+
)
|
261
|
+
if "maxPriorityFeePerGas" in user_operation:
|
262
|
+
user_operation["maxPriorityFeePerGas"] = apply_factor(
|
263
|
+
user_operation["maxPriorityFeePerGas"], AA_BUNDLER_PRIORITY_GAS_PRICE_FACTOR
|
264
|
+
)
|
265
|
+
|
266
|
+
if "callGasLimit" in user_operation:
|
267
|
+
user_operation["callGasLimit"] = apply_factor(
|
268
|
+
user_operation["callGasLimit"], AA_BUNDLER_GAS_LIMIT_FACTOR
|
269
|
+
)
|
270
|
+
|
271
|
+
else:
|
272
|
+
warn(f"Unknown AA_BUNDLER_PROVIDER: {AA_BUNDLER_PROVIDER}")
|
273
|
+
|
241
274
|
# Remove paymaster related fields
|
242
275
|
user_operation.pop("paymaster", None)
|
243
276
|
user_operation.pop("paymasterData", None)
|
244
277
|
user_operation.pop("paymasterVerificationGasLimit", None)
|
245
278
|
user_operation.pop("paymasterPostOpGasLimit", None)
|
246
279
|
|
280
|
+
# Consume the nonce, even if the userop may fail later
|
281
|
+
consume_nonce(nonce_key, nonce)
|
282
|
+
|
283
|
+
return user_operation
|
284
|
+
|
285
|
+
|
286
|
+
def send_transaction(w3, tx, retry_nonce=None):
|
287
|
+
user_operation = build_user_operation(w3, tx, retry_nonce)
|
288
|
+
user_operation["signature"] = add_0x_prefix(
|
289
|
+
sign_user_operation(
|
290
|
+
AA_BUNDLER_EXECUTOR_PK, user_operation, tx["chainId"], AA_BUNDLER_ENTRYPOINT
|
291
|
+
).hex()
|
292
|
+
)
|
247
293
|
resp = w3.provider.make_request("eth_sendUserOperation", [user_operation, AA_BUNDLER_ENTRYPOINT])
|
248
294
|
if "error" in resp:
|
249
|
-
|
295
|
+
next_nonce = check_nonce_error(resp, retry_nonce)
|
296
|
+
return send_transaction(w3, tx, retry_nonce=next_nonce)
|
250
297
|
|
251
|
-
# Store nonce in the cache, so next time uses a new nonce
|
252
|
-
NONCE_CACHE[nonce_key] = nonce + 1
|
253
298
|
return {"userOpHash": resp["result"]}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/src/eth_prototype.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/CounterUpgradeable.sol
RENAMED
File without changes
|
File without changes
|
{eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/CounterWithLibrary.sol
RENAMED
File without changes
|
File without changes
|
{eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/EventLauncher.sol
RENAMED
File without changes
|
{eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/TestCurrency.sol
RENAMED
File without changes
|
{eth_prototype-1.2.0 → eth_prototype-1.2.1b1}/tests/hardhat-project/contracts/TestCurrencyUUPS.sol
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|