Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
42db643
add dymension/
danwt Apr 15, 2025
1ce28ec
add erc20 memo
danwt Apr 15, 2025
d22c393
fix dymension readme
danwt Apr 15, 2025
e4c8ec6
check point
danwt Apr 15, 2025
961cd35
please
danwt Apr 15, 2025
4901ade
check point
danwt Apr 15, 2025
7207308
I need to add cli support for memos, but first, lets see if cast works?
danwt Apr 15, 2025
ad7d237
ready to try again with adapted transferRemoteMemo call
danwt Apr 15, 2025
e3aceb4
check point
danwt Apr 15, 2025
29aebfd
pre delete erc20memo fac
danwt Apr 15, 2025
b629a72
confirm transferRemoteMemo is callable
danwt Apr 15, 2025
94825a4
hack in the changes from original sealevel work 08b8712d99
danwt Apr 15, 2025
5b62307
confirm solidity client changes build, but didnt retest
danwt Apr 15, 2025
b6eec62
time to proceed
danwt Apr 15, 2025
bafe992
adds a yarn project which is used for the scripting
danwt Apr 15, 2025
3112097
not sure its the right thing this cosmos script...
danwt Apr 15, 2025
49670d4
check point
danwt Apr 15, 2025
059f110
script not quite working but might as well add the eth side
danwt Apr 15, 2025
80f979a
check point
danwt Apr 16, 2025
ee13608
make a manual script
danwt Apr 16, 2025
e14ee7c
check point
danwt Apr 16, 2025
b4c51cf
check point
danwt Apr 16, 2025
4773325
found some kyve testnet exsamples for relayer and chain registry, ill…
danwt Apr 16, 2025
0e37fed
check point
danwt Apr 16, 2025
4f88fb7
check point
danwt Apr 17, 2025
e33947b
check point
danwt Apr 17, 2025
febc275
check point
danwt Apr 17, 2025
b745550
check point
danwt Apr 17, 2025
59ed4a8
check point
danwt Apr 17, 2025
42f5f8a
check point
danwt Apr 17, 2025
c9cadc3
check point
danwt Apr 17, 2025
0e1ad69
confirm working up until relayer message context skipping problem
danwt Apr 17, 2025
572f434
check point
danwt Apr 17, 2025
1da96cb
check point
danwt Apr 17, 2025
aee0eff
going to try with collateral synthetic, and also with the igp
danwt Apr 17, 2025
31611ec
what is the next attack?: will try with just synthetic and with the i…
danwt Apr 17, 2025
41f0963
rename hub test -> dymension test
danwt Apr 17, 2025
141bdba
check point
danwt Apr 17, 2025
13bfa93
check point
danwt Apr 17, 2025
9865f23
check point
danwt Apr 18, 2025
fee4777
dont think there are any regresions
danwt Apr 21, 2025
c5ca90f
check point
danwt Apr 21, 2025
908e637
need to check the foreign deployment bit
danwt Apr 21, 2025
7f9b97f
adds script changes and config changes needed to deploy the warp
danwt Apr 21, 2025
435c8bd
check point
danwt Apr 21, 2025
a0c8b6f
start adding local eth validator, untested
danwt Apr 21, 2025
5fb31d4
check point
danwt Apr 21, 2025
83f65a0
check point
danwt Apr 22, 2025
35ce20b
check point
danwt Apr 22, 2025
ec2b9e7
check point
danwt Apr 22, 2025
5d74ab1
pre add back the hyp native memo and erc20 memo solidity tokens
danwt Apr 22, 2025
08585e7
add back the hyp native memo and erc20 memo solidity tokens, untested
danwt Apr 22, 2025
0475252
check point
danwt Apr 22, 2025
cfeed5d
check point
danwt Apr 22, 2025
9a23efd
check point
danwt Apr 22, 2025
09f6a9a
check point
danwt Apr 22, 2025
288f67c
confirm yarn test:forge passes, and typescript yarn build does not co…
danwt Apr 22, 2025
8fcd404
confirm all typescript builds
danwt Apr 22, 2025
f0d801a
check point
danwt Apr 22, 2025
c85192d
CONFIRM NO REGRESSION FOR SOLIDITY NATIVE MEMO TEST
danwt Apr 22, 2025
1d4ef54
confirm native memo working
danwt Apr 22, 2025
08b656b
add relayer
danwt Apr 22, 2025
9cadbf6
check that committing works
danwt May 2, 2025
62d35aa
merge main and fix conflict in typescript/../Token.ts
danwt May 2, 2025
020f1ce
cp
danwt May 7, 2025
1f642b6
check
danwt May 7, 2025
da132dc
Merge branch 'main-dym' into danwt/main-dym-01
danwt May 7, 2025
273b610
start to add a test with cli but wont bother
danwt May 7, 2025
c4c2b94
del dymension_test2
danwt May 7, 2025
f9a6b39
work on the scripts, but something broken in relayer start
danwt May 7, 2025
05bce73
demonstrates a successful transfer hub -> eth
danwt May 7, 2025
60eb053
save changes to readme
danwt May 7, 2025
7efaf08
commands improvements
danwt May 7, 2025
cad644d
fix dym gas price
danwt May 7, 2025
eaf848f
pre modify for memo
danwt May 7, 2025
7d6aa6d
pre del node project in dymension_test
danwt May 7, 2025
a846f48
del node project in dymension_test
danwt May 7, 2025
63e2461
working on the new commands (unfinished)
danwt May 7, 2025
5f9af25
progress
danwt May 7, 2025
a77e709
get as far as send back on synthetic memo hypERC20memo contract to co…
danwt May 7, 2025
9c42fa3
finish confirmation for eth
danwt May 7, 2025
59f5abf
Partially improve Solana <-> Dym e2e (#3)
danwt May 8, 2025
a4a8aaa
demonstrate what duc will e2e test (#4)
danwt May 8, 2025
a82893b
bumps
danwt May 8, 2025
a2c44cc
fix
danwt May 8, 2025
3b3f604
fix cmds
danwt May 14, 2025
a9f4ff5
Update rust/sealevel/client/src/main.rs
danwt May 16, 2025
9a6b7da
Update dymension/dymension.readme.txt
danwt May 16, 2025
3f510d1
Update dymension/dymension.readme.txt
danwt May 16, 2025
40137b2
remove unimpl
danwt May 16, 2025
588b814
add switch cases for nativememo, collateralmemo to token.ts
danwt May 16, 2025
58596c2
add missing line from sealevel client
danwt May 16, 2025
00b8642
solana synth (untested) (#6)
danwt May 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
**/*repomix*

node_modules
test_deploy.env

Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
[submodule "solidity/lib/fx-portal"]
path = solidity/lib/fx-portal
url = https://github.com/0xPolygon/fx-portal
[submodule "dymension/foo_test/foundry/lib/forge-std"]
path = dymension/foo_test/foundry/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "dymension/foo_test/foundry/lib/openzeppelin-contracts"]
path = dymension/foo_test/foundry/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
61 changes: 61 additions & 0 deletions dymension/dymension.readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Testing
yarn test:forge --match-contract HypERC20MemoTest
yarn test:forge --match-contract HypERC20CollateralMemoTest
yarn test:forge --match-contract HypNativeMemoTest
cargo test --test functional

Notes
Ethereum
HypERC20 = Synthetic
HypERC20Collateral = Collateral
HypNative = Native
Solana
hyperlane-sealevel-token = Synthetic
hyperlane-sealevel-token-collateral = Collateral
hyperlane-sealevel-token-native = Native

Change list
Ethereum
Copied HypERC20 and modified to include memo in transferFromSender
Copied test for HypERC20 and added memo check
Copied HypNative and modified to include memo in transferFromSender
Copied test for HypNative and added memo check
Extended HypERC20Collateral with override to include memo in transferFromSender
Copied test for HypeERC20Collateral and added memo check
Solana
Added hyperlane-sealevel-token-native-memo
Added hyperlane-sealevel-token-collateral-memo
Added hyperlane-sealevel-token-memo

Improvements to be made (possibly)
Ethereum
Just have a method to do both the memo setting and the transfer remote
Solana
Find a way to remove the plugin.rs duplication in the tokens

How to work on the typescript CLI:
The CLI depends on the SDK, so first do yarn build from typescript/sdk, and only then will yarn build from typescript/cli work
How to rebuild and reinstall?
# in top level (hyperlane-monorepo)
yarn clean; yarn build; # CLEAN IS VERY IMPORTANT!
#in typescript/cli
npm uninstall -g @hyperlane-xyz/cli;
yarn install
yarn build
yarn bundle
npm install -g
hyperlane --version

How to build rust agents:
cd rust/main
cargo build --release --bin relayer
cargo build --release --bin validator

How to manage solana versions:
# initial install
curl --proto '=https' --tlsv1.2 -sSfL https://solana-install.solana.workers.dev | bash
# then agave-install or solana-install
solana-install init v1.18.18
solana-install init v1.14.20
sh -c "$(curl -sSfL https://release.anza.xyz/v2.2.13/install)"

1 change: 1 addition & 0 deletions dymension/ethereum_test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp/
14 changes: 14 additions & 0 deletions dymension/ethereum_test/chains/anvil0/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# yaml-language-server: $schema=../schema.json
chainId: 31337
displayName: Anvil0
domainId: 31337
isTestnet: true
name: anvil0
nativeToken:
decimals: 18
name: Ether
symbol: ETH
protocol: ethereum
rpcUrls:
- http: http://localhost:8545
technicalStack: other
41 changes: 41 additions & 0 deletions dymension/ethereum_test/chains/dymension/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# yaml-language-server: $schema=../schema.json
# see https://github.com/hyperlane-xyz/hyperlane-registry/blob/main/chains/kyvetestnet/metadata.yaml
bech32Prefix: dym
# todo can add block explorers
blocks:
confirmations: 1
estimateBlockTime: 6
reorgPeriod: 1
canonicalAsset: adym
chainId: dymension_100-1
contractAddressBytes: 32
deployer:
name: DYMENSION
url: https://example.com # TODO
displayName: Dymension Hub Local
gasCurrencyCoinGeckoId: dymension
# Generated from: console.log(parseInt('0x'+Buffer.from('DYMENSION').toString('hex')))
domainId: 1260813472
gasPrice:
amount: "100000000000.0"
denom: adym
grpcUrls:
- http: http://127.0.0.1:8090
index: # TODO ??
from: 10 # low block start
isTestnet: true
name: dymension
nativeToken:
decimals: 18
denom: adym
name: ADYM # dym or adym
symbol: ADYM # dym or adym
protocol: cosmosnative
restUrls:
- http: http://localhost:1318
rpcUrls: # (JSON COMET ONE, e.g. /block?height)
- http: http://localhost:36657
slip44: 118 #??
technicalStack: other
transactionOverrides:
gasPrice: "2.0" # TODO: ??
196 changes: 196 additions & 0 deletions dymension/ethereum_test/commands.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
export BASE_PATH="/Users/danwt/Documents/dym/d-hyperlane-monorepo"
export HUB_BASE_PATH="/Users/danwt/Documents/dym/d-dymension/scripts/hyperlane_test"

#########################################################################################
#########################################################################################
# Q: What is this?
# A: Some commands to run Dymension Hub + Anvil instance and connect them and relay between them
# Scenario: Dymension Hub will have collateral ADYM and Anvil will have synthetic memo
#########################################################################################

# clean slate
trash ~/.hyperlane; trash ~/.dymension

##############################################################################################
##############################################################################################
# PART 1: Start chains and deploy contracts

################
# ENV:

source $HUB_BASE_PATH/env.sh

export HYP_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
export HYP_ADDR="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
export HYP_ADDR_ZEROS="0x000000000000000000000000f39Fd6e51aad88F6F4ce6aB8827279cffFb92266" # this is zero padded regular address
export RELAYER_ADDR="dym15428vq2uzwhm3taey9sr9x5vm6tk78ewtfeeth" # relayer derives from HYP_KEY
export HUB_DOMAIN=1260813472
export ETH_DOMAIN=31337
export DENOM="adym"

################
# START NODES:

# HUB
cd dymension/ # hub repo
bash scripts/setup_local.sh
dymd start --log_level=debug
# see ping pub for explorer

# ETHEREUM
anvil --port 8545 --chain-id 31337 --block-time 1 # make sure rollapp-evm not listening on same port
# see otterscan for explorer

#################
# DEPLOY HYPERLANE CORE TO ETH:
cd hyperlane-monorepo/dymension/ethereum_test

trash ~/.hyperlane; mkdir ~/.hyperlane; cp -r chains ~/.hyperlane/chains;

# only deploy anvil0, without block explorer
hyperlane core deploy

################
# HUB:

hub tx hyperlane ism create-noop "${HUB_FLAGS[@]}"
sleep 7;
ISM=$(curl -s http://localhost:1318/hyperlane/v1/isms | jq '.isms.[0].id' -r); echo $ISM;

hub tx hyperlane hooks noop create "${HUB_FLAGS[@]}"
sleep 7;
NOOP_HOOK=$(curl -s http://localhost:1318/hyperlane/v1/noop_hooks | jq '.noop_hooks.[0].id' -r); echo $NOOP_HOOK;

hub tx hyperlane mailbox create $ISM $HUB_DOMAIN "${HUB_FLAGS[@]}"
sleep 7;
MAILBOX=$(curl -s http://localhost:1318/hyperlane/v1/mailboxes | jq '.mailboxes.[0].id' -r); echo $MAILBOX;

hub tx hyperlane hooks merkle create $MAILBOX "${HUB_FLAGS[@]}"
sleep 7;
MERKLE_HOOK=$(curl -s http://localhost:1318/hyperlane/v1/merkle_tree_hooks | jq '.merkle_tree_hooks.[0].id' -r); echo $MERKLE_HOOK;

# update mailbox again. default hook (e.g. IGP), required hook (e.g. merkle tree)
hub tx hyperlane mailbox set $MAILBOX --default-hook $NOOP_HOOK --required-hook $MERKLE_HOOK "${HUB_FLAGS[@]}"

hub tx hyperlane-transfer create-collateral-token $MAILBOX $DENOM "${HUB_FLAGS[@]}"
sleep 7;
TOKEN_ID=$(curl -s http://localhost:1318/hyperlane/v1/tokens | jq '.tokens.[0].id' -r); echo $TOKEN_ID

################
# ANVIL:

# cd hyperlane-monorepo/dymension/ethereum_test

# populate addresses https://github.com/hyperlane-xyz/hyperlane-registry/blob/main/chains/kyvetestnet/addresses.yaml
touch ~/.hyperlane/chains/dymension/addresses.yaml
dasel put -f ~/.hyperlane/chains/dymension/addresses.yaml 'interchainGasPaymaster' -v $NOOP_HOOK
dasel put -f ~/.hyperlane/chains/dymension/addresses.yaml 'interchainSecurityModule' -v $ISM
dasel put -f ~/.hyperlane/chains/dymension/addresses.yaml 'mailbox' -v $MAILBOX
dasel put -f ~/.hyperlane/chains/dymension/addresses.yaml 'merkleTreeHook' -v $MERKLE_HOOK
dasel put -f ~/.hyperlane/chains/dymension/addresses.yaml 'validatorAnnounce' -v $MAILBOX
# then manually add quotes to the addresses (!!)

# also, check configs/warp-route-deployment.yaml matches
dasel put -f configs/warp-route-deployment.yaml 'dymension.token' -v $TOKEN_ID
dasel put -f configs/warp-route-deployment.yaml 'dymension.foreignDeployment' -v $TOKEN_ID
dasel put -f configs/warp-route-deployment.yaml 'dymension.mailbox' -v $MAILBOX
# then manually add quotes to the addresses (!!)

# now use hyperlane CLI to deploy only the contracts needed on anvil, making use of a foreign deployment config for dymension side
# it will say to deploy to dymension too, but it won't
hyperlane warp deploy

################
# FINISH HUB SETUP:

ETH_TOKEN_CONTRACT_RAW=$(dasel -f ~/.hyperlane/deployments/warp_routes/ADYM/anvil0-config.yaml -r yaml 'tokens.index(0).addressOrDenom'); echo $ETH_TOKEN_CONTRACT_RAW;
# manual step TODO: automate
ETH_TOKEN_CONTRACT="0x0000000000000000000000004A679253410272dd5232B3Ff7cF5dbB88f295319" # Need to zero pad it! (with 0x000000000000000000000000)

hub tx hyperlane-transfer enroll-remote-router $TOKEN_ID $ETH_DOMAIN $ETH_TOKEN_CONTRACT 0 "${HUB_FLAGS[@]}" # gas = 0
sleep 7;
curl -s http://localhost:1318/hyperlane/v1/tokens/$TOKEN_ID/remote_routers # check

##############################################################################################
##############################################################################################
# PART 1: SETUP RELAYERS AND VALIDATORS
# https://docs.hyperlane.xyz/docs/guides/deploy-hyperlane-local-agents
# build agent binaries if needed

MONO_WORKING_DIR=/Users/danwt/Documents/dym/d-hyperlane-monorepo/dymension/ethereum_test
RELAYER_DB=$MONO_WORKING_DIR/tmp/hyperlane_db_relayer
trash $MONO_WORKING_DIR/tmp/
mkdir $MONO_WORKING_DIR/tmp/

#################################
# RELAYING
# https://docs.hyperlane.xyz/docs/operate/relayer/run-relayer

# regen config
cd hyperlane-monorepo/dymension/ethereum_test
hyperlane registry agent-config --chains anvil0,dymension # DO NOT USE, DOES NOT PROPERLY INCLUDE GRPC URLS, USE PRECONFIGURED

export CONFIG_FILES=$MONO_WORKING_DIR/configs/agent-config.json
# see reference https://docs.hyperlane.xyz/docs/operate/config-reference#config_files

cd rust/main

# need to fund relayer
dymd tx bank send hub-user $RELAYER_ADDR 1000000000000000000000adym "${HUB_FLAGS[@]}"

./target/release/relayer \
--db $RELAYER_DB \
--relayChains anvil0,dymension \
--allowLocalCheckpointSyncers true \
--defaultSigner.key $HYP_KEY \
--metrics-port 9091 \
--chains.dymension.signer.type cosmosKey \
--chains.dymension.signer.prefix dym \
--chains.dymension.signer.key $HYP_KEY \
--log.level debug

#################################
# DO A TRANSFER HUB -> ETHEREUM

AMT=1000
hub tx hyperlane-transfer transfer $TOKEN_ID $ETH_DOMAIN $HYP_ADDR_ZEROS $AMT "${HUB_FLAGS[@]}" --max-hyperlane-fee 1000adym --gas-limit 10000000000
sleep 5;
curl -s http://localhost:1318/hyperlane/v1/tokens/$TOKEN_ID/bridged_supply

# If relaying worked, should have amt tokens here
cast call $ETH_TOKEN_CONTRACT_RAW "balanceOf(address)(uint256)" $HYP_ADDR --rpc-url http://localhost:8545

# fund relayer
dymd tx bank send hub-user $RELAYER_ADDR 1000000000000000000000adym "${HUB_FLAGS[@]}"

HUB_RECEIVER_ADDR_NATIVE="dym1yvq7swunxwduq5kkmuftqccxgqk3f6nsaf3sqz"
HUB_RECEIVER_ADDR=$(dymd q forward hl-eth-recipient $HUB_RECEIVER_ADDR_NATIVE)
# args are destination, recipient, amount
AMT=5
DEMO_MEMO="0x68656c6c6f" # 'hello'
cast send $ETH_TOKEN_CONTRACT_RAW "transferRemoteMemo(uint32,bytes32,uint256,bytes)" $HUB_DOMAIN $HUB_RECEIVER_ADDR $AMT $DEMO_MEMO --private-key $HYP_KEY --rpc-url http://localhost:8545
# note: if using a native token type on ethereum, need to also send some eth ('--value 1')

# confirm tx has memo event on hub
# confirm tx has memo event on anvil
cast call $ETH_TOKEN_CONTRACT_RAW "memoOf(bytes32)(bytes)" $HUB_RECEIVER_ADDR --rpc-url http://localhost:8545

dymd q bank balances $HUB_RECEIVER_ADDR_NATIVE

##############################################################################################
##############################################################################################
# APPENDIX: DEBUGGING

# eth balance:
cast balance $HYP_ADDR --rpc-url http://localhost:8545

# Explorer, uses https://github.com/otterscan/otterscan
docker pull otterscan/otterscan:latest
docker run -p 5100:80 \
-e OTTERSCAN_RPC_URL="http://host.docker.internal:8545" \
otterscan/otterscan:latest
# visit http://localhost:5100/

# Hub: https://github.com/ping-pub/explorer
yarn --ignore-engines && yarn serve
# visit http://localhost:5173/
Empty file.
Loading
Loading