forked from paradigmxyz/reth
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
L2 builder preparation #34
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
packages/protocol/scripts/L2_txn_simulation/sendATxnToL2Rpc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from web3 import Web3 | ||
from eth_abi import encode | ||
import argparse | ||
|
||
RPC_URL_L2 = 'http://127.0.0.1:' # Anything is fine for now as long as we dont have the L2 network, but if we have we can automate nonce and gas settings | ||
w3_taiko_l2 = Web3(Web3.HTTPProvider(RPC_URL_L2)) | ||
|
||
# Some pre-loaded ETH addresses from Kurtosis private network (NO secret, no harm to use for private testnets!) | ||
sender_addresses = ['0x8943545177806ED17B9F23F0a21ee5948eCaa776'] | ||
sender_pks = ['bcdf20249abf0ed6d944c0288fad489e33f66b3960d9e6229c1cd214ed3bbe31'] | ||
|
||
receiver = '0xf93Ee4Cf8c6c40b329b0c0626F28333c132CF241' # This address also has pre-loaded ETH addresses | ||
|
||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument("-p", "--port", help="port on localhost", | ||
type=str, required=True) | ||
# parser.add_argument("-c", "--chainid", help="l2 chainId", | ||
# type=int, required=True) | ||
|
||
transaction_list = [] | ||
|
||
if __name__ == "__main__": | ||
args = parser.parse_args() | ||
port = args.port | ||
w3_taiko_l2 = Web3(Web3.HTTPProvider(RPC_URL_L2+port)) | ||
chainId = 167010 | ||
|
||
# Build the new tx list | ||
idx = 0 | ||
for sender in sender_addresses: | ||
# Build the tx | ||
transaction = { | ||
'chainId': chainId, | ||
'from': sender, | ||
'to': receiver, | ||
'value': w3_taiko_l2.to_wei('1', 'ether'), | ||
'nonce': w3_taiko_l2.eth.get_transaction_count(sender), | ||
'gas': 200000, | ||
'maxFeePerGas': 2000000000, # w3_taiko_l2.eth.gas_price or something | ||
'maxPriorityFeePerGas': 1000000000, | ||
} | ||
|
||
# Debug prints of balance | ||
# # Get the balance | ||
# balance_wei = w3_taiko_l2.eth.get_balance(sender) | ||
|
||
# # Convert balance from Wei to Ether | ||
# balance_eth = w3_taiko_l2.from_wei(balance_wei, 'ether') | ||
# print("Balance before:", balance_eth) | ||
|
||
# 2. Sign tx with a private key | ||
signed_txn = w3_taiko_l2.eth.account.sign_transaction(transaction, sender_pks[idx]) | ||
|
||
# print("RawTransaction:") | ||
# print(signed_txn.rawTransaction) | ||
print("RawTransaction.hex():") | ||
print(signed_txn.rawTransaction.hex()) | ||
|
||
txn_hash = w3_taiko_l2.eth.send_raw_transaction(signed_txn.rawTransaction) | ||
print("Txn hash:") | ||
print(txn_hash.hex()) | ||
|
||
# # Get the balance | ||
# balance_wei = w3_taiko_l2.eth.get_balance(sender) | ||
|
||
# # Convert balance from Wei to Ether | ||
# balance_eth = w3_taiko_l2.from_wei(balance_wei, 'ether') | ||
# print("Balance after:", balance_eth) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Brechtpd Could you please have a look on the above comments:
chain_id
, tho i could not find a way to extract it fromSignature
Maybe it is not even the best approach to distinguish tho seems obvious ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would guess ideally the node is configured differently in some way between L1 and L2. With L2 having a somewhat custom payload builder likely, and then instead of propegating the block through the network like done on L1, it would instead propose the block to the gwyneth smart contract (probably something related to the engine api, but haven't looked up the normal flow for this).
On the other hand, we can also just make it easy for now and just collect the tx here and propose the block to the smart contract when it's configured as an L2 node and then we can see later. Normally, the block building wil be done through something like rbuilder, so reth itself only really needs to be able to sync with a given tx list (and the internal payload builder would only be a fallback path).