Skip to content

Commit

Permalink
docs: initial gas token doc
Browse files Browse the repository at this point in the history
  • Loading branch information
praetoriansentry committed Mar 22, 2024
1 parent 28d1c1a commit 5bd1e46
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 825 deletions.
668 changes: 0 additions & 668 deletions cdk/main.star

This file was deleted.

143 changes: 0 additions & 143 deletions cdk/params.yml

This file was deleted.

Binary file added docs/gas-token-img/01_bridge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/gas-token-img/02_bridge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/gas-token-img/03_bridge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/gas-token-img/04_bridge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/gas-token-img/05_bridge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/gas-token-img/06_bridge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/gas-token-img/07_bridge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/gas-token-img/08_bridge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/gas-token-img/mm-cdk-l1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/gas-token-img/mm-cdk-l2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 64 additions & 2 deletions docs/gas-token.org
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,68 @@ URL in your browser.
kurtosis port print cdk-v1 zkevm-bridge-ui-001 bridge-ui
#+end_src

"$(kurtosis port print cdk-v1 zkevm-node-rpc-001 http-rpc)"
You'll need to need to add RPCs for L1 and L2 your browser
wallet. Because the URLs are using HTTP instead of HTTPS, you'll need
to [[https://support.metamask.io/hc/en-us/articles/360043227612-How-to-add-a-custom-network-RPC][add the RPCs]] manually to Metamask. The URL for the L1 and L2 RPCs
can be retrieved with these commands:

#+begin_src bash
kurtosis port print cdk-v1 el-1-geth-lighthouse rpc
kurtosis port print cdk-v1 zkevm-node-rpc-001 http-rpc
#+end_src

Additionally, if you used the mnemonic ~code...quality~, you'll also
want to [[https://support.metamask.io/hc/en-us/articles/360015489331-How-to-import-an-account#h_01G01W07NV7Q94M7P1EBD5BYM4][import an account]] using a private key. The first derived
private key from the ~code...quality~ mnemonic is
~42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa~.

Now we'll need to add the gas token to the bridge interface and
attempt to bridge. First, you'll need to click the token dropdown
menu:

[[file:gas-token-img/01_bridge.png]]

In the modal, you'll want to paste the ERC 20 Gas Token address that
we found earlier with this command:
#+begin_src bash
cat /tmp/zkevm/create_rollup_parameters.json | jq '.gasTokenAddress'
#+end_src

[[file:gas-token-img/02_bridge.png]]

Confirm the details of your token and then click the add button.

[[file:gas-token-img/03_bridge.png]]

Now that the token has been added, you'll need to select the token for
bridging.

[[file:gas-token-img/04_bridge.png]]

At this point you should be all set to actually make the bridge

[[file:gas-token-img/05_bridge.png]]

Now your bridge deposit should be pending.
[[file:gas-token-img/06_bridge.png]]

After some time, your transaction should show as claimed. If it
doesn't, it's possible the autoclaiming service on L2 is not
funded. You should be able to send it some ether on L2 by running a
command like this:

#+begin_src bash
cast send --legacy \
--value 10ether \
--private-key 0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625 \
--rpc-url "$(kurtosis port print cdk-v1 zkevm-node-rpc-001 http-rpc)" \
0x5f5dB0D4D58310F53713eF4Df80ba6717868A9f8
#+end_src

[[file:gas-token-img/07_bridge.png]]

At this point if you switch Metamask to your L2 network, you should
see the bridge value as native value on L2.

[[file:gas-token-img/08_bridge.png]]

42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa
14 changes: 2 additions & 12 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def run(plan, args):
zkevm_bridge_address = extract_json_key_from_service(plan, "contracts" + args["deployment_suffix"], "/opt/zkevm/bridge-config.toml", "PolygonBridgeAddress") # "L2PolygonBridgeAddresses"
rollup_manager_address = extract_json_key_from_service(plan, "contracts" + args["deployment_suffix"], "/opt/zkevm/bridge-config.toml", "PolygonRollupManagerAddress")
polygon_zkevm_address = extract_json_key_from_service(plan, "contracts" + args["deployment_suffix"], "/opt/zkevm/bridge-config.toml", "PolygonZkEVMAddress")
l1_ip_address = extract_ip_address_from_service(plan, "el-1-geth-lighthouse")
l1_eth_service = plan.get_service(name="el-1-geth-lighthouse")

# Fetch port
polygon_zkevm_rpc_http_port = service_map["rpc"].ports["http-rpc"]
Expand All @@ -290,7 +290,7 @@ def run(plan, args):
),
},
env_vars = {
"ETHEREUM_RPC_URL": "http://{}".format(l1_ip_address),
"ETHEREUM_RPC_URL": "http://{}:{}".format(l1_eth_service.ip_address, l1_eth_service.ports["rpc"].number),
"POLYGON_ZK_EVM_RPC_URL": "http://{}:{}".format(service_map["rpc"].ip_address, polygon_zkevm_rpc_http_port.number),
"BRIDGE_API_URL": "http://{}:{}".format(zkevm_bridge_service.ip_address, bridge_api_http_port.number),
"ETHEREUM_BRIDGE_CONTRACT_ADDRESS": zkevm_bridge_address,
Expand Down Expand Up @@ -372,13 +372,3 @@ def extract_json_key_from_service(
result = plan.exec(service_name=service_name, recipe=exec_recipe)
return result["output"]


def extract_ip_address_from_service(
plan, service_name
):
plan.print("Extracting IP address...")
exec_recipe = ExecRecipe(
command=["/bin/sh", "-c", "echo -n $(hostname -i) ; echo -n \":8545\" "]
)
result = plan.exec(service_name=service_name, recipe=exec_recipe)
return result["output"]

0 comments on commit 5bd1e46

Please sign in to comment.