Skip to content

Commit 09048b2

Browse files
author
Stuart Reed
authored
Create Access List Async RPC Method (#3167)
* Async create access list method and test * Update test for async createAccessList * News update * Update news
1 parent f30c6ad commit 09048b2

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

newsfragments/3167.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Implement async ``eth_createAccessList`` RPC method to create an EIP-2930 access list.

web3/_utils/module_testing/eth_module.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,42 @@ async def test_eth_get_code_with_block_identifier(
11171117
assert isinstance(code, HexBytes)
11181118
assert len(code) > 0
11191119

1120+
@pytest.mark.asyncio
1121+
async def test_eth_create_access_list(
1122+
self,
1123+
async_w3: "AsyncWeb3",
1124+
async_unlocked_account_dual_type: ChecksumAddress,
1125+
async_math_contract: "Contract",
1126+
) -> None:
1127+
# Initialize transaction for gas estimation
1128+
txn_params: TxParams = {
1129+
"from": async_unlocked_account_dual_type,
1130+
"value": Wei(1),
1131+
"gas": 21000,
1132+
}
1133+
txn = async_math_contract._prepare_transaction(
1134+
fn_name="incrementCounter",
1135+
fn_args=[1],
1136+
transaction=txn_params,
1137+
)
1138+
1139+
# create access list using data from transaction
1140+
response = await async_w3.eth.create_access_list(
1141+
{
1142+
"from": async_unlocked_account_dual_type,
1143+
"to": async_math_contract.address,
1144+
"data": txn["data"],
1145+
}
1146+
)
1147+
1148+
assert is_dict(response)
1149+
access_list = response["accessList"]
1150+
assert len(access_list) > 0
1151+
assert access_list[0]["address"] is not None
1152+
assert is_checksum_address(access_list[0]["address"])
1153+
assert len(access_list[0]["storageKeys"][0]) == 32
1154+
assert int(response["gasUsed"]) >= 0
1155+
11201156
@pytest.mark.asyncio
11211157
async def test_eth_get_transaction_count(
11221158
self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress

web3/eth/async_eth.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
BlockIdentifier,
7676
BlockParams,
7777
CallOverride,
78+
CreateAccessListResponse,
7879
FeeHistory,
7980
FilterParams,
8081
LogReceipt,
@@ -294,6 +295,22 @@ async def _durin_call(
294295

295296
raise TooManyRequests("Too many CCIP read redirects")
296297

298+
# eth_createAccessList
299+
300+
_create_access_list: Method[
301+
Callable[
302+
[TxParams, Optional[BlockIdentifier]],
303+
Awaitable[CreateAccessListResponse],
304+
]
305+
] = Method(RPC.eth_createAccessList, mungers=[BaseEth.create_access_list_munger])
306+
307+
async def create_access_list(
308+
self,
309+
transaction: TxParams,
310+
block_identifier: Optional[BlockIdentifier] = None,
311+
) -> CreateAccessListResponse:
312+
return await self._create_access_list(transaction, block_identifier)
313+
297314
# eth_estimateGas
298315

299316
_estimate_gas: Method[

0 commit comments

Comments
 (0)