From b51af1f8ffa2c9d282899838a738900e0c1fc428 Mon Sep 17 00:00:00 2001
From: Patrice Tisserand
Date: Tue, 6 Feb 2024 12:04:40 +0100
Subject: [PATCH] CI: use tool-versions instead of hardcoded scarb version
---
.github/workflows/contracts.yml | 2 +-
.tool-versions | 1 -
apps/blockchain/ethereum/.env.anvil | 5 ++--
apps/blockchain/ethereum/Makefile | 18 +++++------
apps/blockchain/ethereum/foundry.toml | 3 ++
.../ethereum/script/LocalTesting.s.sol | 2 +-
.../ethereum/script/Starklane.s.sol | 4 +--
apps/blockchain/starknet/.env.katana | 8 +++--
apps/blockchain/starknet/.tool-versions | 4 +--
apps/blockchain/starknet/Makefile | 15 +++++++---
apps/blockchain/starknet/README.md | 2 +-
apps/blockchain/starknet/Scarb.toml | 5 +++-
.../starknet/data/katana_account.json | 4 +--
apps/indexer/Makefile | 12 ++++----
apps/indexer/docker-compose.yml | 30 ++++++++++++++-----
apps/indexer/local.config | 6 ++--
16 files changed, 77 insertions(+), 44 deletions(-)
delete mode 100644 .tool-versions
diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml
index 9fa1d2c4..4500dfad 100644
--- a/.github/workflows/contracts.yml
+++ b/.github/workflows/contracts.yml
@@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v3
- uses: software-mansion/setup-scarb@v1
with:
- scarb-version: "0.6.0"
+ tool-versions: apps/blockchain/starknet/.tool-versions
- run: scarb build
working-directory: apps/blockchain/starknet
diff --git a/.tool-versions b/.tool-versions
deleted file mode 100644
index 99555848..00000000
--- a/.tool-versions
+++ /dev/null
@@ -1 +0,0 @@
-scarb 0.6.0
diff --git a/apps/blockchain/ethereum/.env.anvil b/apps/blockchain/ethereum/.env.anvil
index 7c8e73a1..fa32bf64 100644
--- a/apps/blockchain/ethereum/.env.anvil
+++ b/apps/blockchain/ethereum/.env.anvil
@@ -1,6 +1,6 @@
# General config.
ETH_RPC_URL=http://127.0.0.1:8545
-ETHERSCAN_API_KEY=0x1
+ETHERSCAN_API_KEY=YGJJHTCQBYE2C336HMUCY5P27MJY885IIN
LOCAL_LOGS=logs/
# Account related variables (EOA account).
@@ -10,8 +10,9 @@ ACCOUNT_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
# Starklane L1 variables.
STARKNET_CORE_L1_ADDRESS=0x0000000000000000000000000000000000000000
STARKLANE_L1_PROXY_ADDRESS=0x0000000000000000000000000000000000000000
+# STARKLANE_L1_PROXY_ADDRESS=0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0
# Starklane L2 variables.
-STARKLANE_L2_ADDRESS=0x0348c73fe84aef749add99dddccda56bee301c45b8e29a6f01db59a752b4f711
+STARKLANE_L2_ADDRESS=0x075af152a7ad8c32726093fdf9820de103854d15a8ef4fae11d2739671ff1f9e
STARKLANE_L2_SELECTOR=0x005d25c8970b257e237fddc686e4a2711310774d2277107e1ebaf3e0a68dd037
OWNER_L2_ADDRESS=0x1
diff --git a/apps/blockchain/ethereum/Makefile b/apps/blockchain/ethereum/Makefile
index 1b4898cd..d55d3b89 100644
--- a/apps/blockchain/ethereum/Makefile
+++ b/apps/blockchain/ethereum/Makefile
@@ -13,7 +13,7 @@ sgr0 := $(shell tput sgr0)
# Starklane local setup.
starklane_local_setup:
- forge script --broadcast --verify --rpc-url ${ETH_RPC_URL} script/LocalTesting.s.sol:LocalSetup
+ forge script --broadcast --rpc-url ${ETH_RPC_URL} script/LocalTesting.s.sol:LocalSetup
# Starklane deposit tokens
starklane_deposit:
@@ -21,7 +21,7 @@ starklane_deposit:
@echo "usage: make starklane_deposit config=.yourconfig.env proxy=0x1234"
@printf "$(sgr0)\n"
export STARKLANE_L1_PROXY_ADDRESS=$(proxy) && \
- forge script --broadcast --verify --rpc-url ${ETH_RPC_URL} --sender ${ACCOUNT_ADDRESS} script/Starklane.s.sol:Deposit
+ forge script --broadcast --rpc-url ${ETH_RPC_URL} --sender ${ACCOUNT_ADDRESS} script/Starklane.s.sol:Deposit
# Starklane withdraw tokens
starklane_withdraw:
@@ -29,12 +29,12 @@ starklane_withdraw:
@echo "usage: make starklane_withdraw config=.yourconfig.env proxy=0x1234"
@printf "$(sgr0)\n"
export STARKLANE_L1_PROXY_ADDRESS=$(proxy) && \
- forge script --broadcast --verify --rpc-url ${ETH_RPC_URL} --sender ${ACCOUNT_ADDRESS} script/Starklane.s.sol:WithdrawSN
+ forge script --broadcast --rpc-url ${ETH_RPC_URL} --sender ${ACCOUNT_ADDRESS} script/Starklane.s.sol:WithdrawSN
# Starklane deploy impl + proxy.
starklane_deploy:
export STARKLANE_L1_PROXY_ADDRESS=0x0000000000000000000000000000000000000000 && \
- forge script --broadcast --verify --rpc-url ${ETH_RPC_URL} script/Starklane.s.sol:Deploy
+ forge script --broadcast --rpc-url ${ETH_RPC_URL} script/Starklane.s.sol:Deploy
# Starklane upgrade.
starklane_upgrade:
@@ -42,12 +42,12 @@ starklane_upgrade:
@echo "usage: make starklane_upgrade config=.yourconfig.env proxy=0x1234"
@printf "$(sgr0)\n"
export STARKLANE_L1_PROXY_ADDRESS=$(proxy) && \
- forge script --broadcast --verify --rpc-url ${ETH_RPC_URL} script/Starklane.s.sol:Deploy
+ forge script --broadcast --rpc-url ${ETH_RPC_URL} script/Starklane.s.sol:Deploy
# ERC721Bridgeable deploy impl + proxy.
erc721_deploy:
export ERC721_PROXY_ADDRESS=0x0000000000000000000000000000000000000000 && \
- forge script --broadcast --verify --rpc-url ${ETH_RPC_URL} script/ERC721.s.sol:Deploy
+ forge script --broadcast --rpc-url ${ETH_RPC_URL} script/ERC721.s.sol:Deploy
# ERC721Bridgeable upgrade.
erc721_upgrade:
@@ -55,12 +55,12 @@ erc721_upgrade:
@echo "usage: make erc721_upgrade config=.yourconfig.env proxy=0x1234"
@printf "$(sgr0)\n"
export ERC721_PROXY_ADDRESS=$(proxy) && \
- forge script --broadcast --verify --rpc-url ${ETH_RPC_URL} script/ERC721.s.sol:Deploy
+ forge script --broadcast --rpc-url ${ETH_RPC_URL} script/ERC721.s.sol:Deploy
# ERC1155Bridgeable deploy impl + proxy.
erc1155_deploy:
export ERC1155_PROXY_ADDRESS=0x0000000000000000000000000000000000000000 && \
- forge script --broadcast --verify --rpc-url ${ETH_RPC_URL} script/ERC1155.s.sol:Deploy
+ forge script --broadcast --rpc-url ${ETH_RPC_URL} script/ERC1155.s.sol:Deploy
# ERC1155Bridgeable upgrade.
erc1155_upgrade:
@@ -68,5 +68,5 @@ erc1155_upgrade:
@echo "usage: make erc1155_upgrade config=.yourconfig.env proxy=0x1234"
@printf "$(sgr0)\n"
export ERC1155_PROXY_ADDRESS=$(proxy) && \
- forge script --broadcast --verify --rpc-url ${ETH_RPC_URL} script/ERC1155.s.sol:Deploy
+ forge script --broadcast --rpc-url ${ETH_RPC_URL} script/ERC1155.s.sol:Deploy
diff --git a/apps/blockchain/ethereum/foundry.toml b/apps/blockchain/ethereum/foundry.toml
index 4c553e8f..95b138d6 100644
--- a/apps/blockchain/ethereum/foundry.toml
+++ b/apps/blockchain/ethereum/foundry.toml
@@ -9,6 +9,9 @@ fs_permissions = [{ access = "read-write", path = "./logs"}]
[rpc_endpoints]
goerli = "${GOERLI_RPC_URL}"
+anvil = "http://127.0.0.1:8545"
+
[etherscan]
goerli = { key = "${ETHERSCAN_API_KEY}" }
+anvil = { key = "${ETHERSCAN_API_KEY", chainId=31337}
diff --git a/apps/blockchain/ethereum/script/LocalTesting.s.sol b/apps/blockchain/ethereum/script/LocalTesting.s.sol
index afce61ca..6bd5517b 100644
--- a/apps/blockchain/ethereum/script/LocalTesting.s.sol
+++ b/apps/blockchain/ethereum/script/LocalTesting.s.sol
@@ -72,7 +72,7 @@ contract LocalSetup is Script {
"mintRangeFree(address,uint256,uint256)",
config.deployerAddress,
0,
- 10
+ 20
)
);
diff --git a/apps/blockchain/ethereum/script/Starklane.s.sol b/apps/blockchain/ethereum/script/Starklane.s.sol
index a32921a4..0333623b 100644
--- a/apps/blockchain/ethereum/script/Starklane.s.sol
+++ b/apps/blockchain/ethereum/script/Starklane.s.sol
@@ -73,8 +73,8 @@ contract Deposit is Script {
Starklane(payable(proxyAddress)).depositTokens{value: 50000}(
0x112233,
- 0x9156d2D0aad192859888919Cb91c1270BF21D881,
- Cairo.snaddressWrap(0x01024e16519da35d35b0637c32d0611cc36b724f69cdea25e8007cd6a7cffa51),
+ 0xC3e6f1F1d9d76A07E87b1F9625021a33efdbEa21,
+ Cairo.snaddressWrap(0x02d34A8edAdDBc0D6E6B10e4fd833d5A5A2161282aaDB3cA3d57f57820437C2A),
ids,
false
);
diff --git a/apps/blockchain/starknet/.env.katana b/apps/blockchain/starknet/.env.katana
index 9cd7a705..dfc9966d 100644
--- a/apps/blockchain/starknet/.env.katana
+++ b/apps/blockchain/starknet/.env.katana
@@ -1,9 +1,13 @@
STARKNET_ACCOUNT=./data/katana_account.json
STARKNET_RPC=http://0.0.0.0:5050
#STARKNET_KEYSTORE=./data/katana_key.json
-PRIVATE_KEY=0x0300001800000000300000180000000000030000000000003006001800006600
+PRIVATE_KEY=0x1800000000300000180000000000030000000000003006001800006600
-ADMIN_ACCOUNT_ADDR=0x03ee9e18edc71a6df30ac3aca2e0b02a198fbce19b7480a63a0d71cbd76652e0
+ADMIN_ACCOUNT_ADDR=0x517ececd29116499f4a1b64b094da79ba08dfd54a3edaa316134c41f8160973
ETH_ACCOUNT=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
BRIDGE_L1_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
+# | Account address | 0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691
+# | Private key | 0x71d7bb07b9a64f6f78ac4c816aff4da9
+# | Public key | 0x39d9e6ce352ad4530a0ef5d5a18fd3303c3606a7fa6ac5b620020ad681cc33b
+
diff --git a/apps/blockchain/starknet/.tool-versions b/apps/blockchain/starknet/.tool-versions
index 297bd98a..dc810b31 100644
--- a/apps/blockchain/starknet/.tool-versions
+++ b/apps/blockchain/starknet/.tool-versions
@@ -1,2 +1,2 @@
-scarb 2.4.3
-starknet-foundry 0.13.1
+scarb 2.4.4
+starknet-foundry 0.15.0
diff --git a/apps/blockchain/starknet/Makefile b/apps/blockchain/starknet/Makefile
index c0f86c14..7c3284b4 100644
--- a/apps/blockchain/starknet/Makefile
+++ b/apps/blockchain/starknet/Makefile
@@ -36,6 +36,7 @@ declare:
@printf "${bold}Ensure you don't forget the contract argument:\n${normal}"
@echo "${shiny}usage: make declare config=.yourconfig.env contract=./target/dev/contract.sierra.json${normal}\n"
starkli declare $(contract) ${priv_key}
+ sleep 2
# Starklane deploy
starklane_deploy:
@@ -48,6 +49,7 @@ starklane_upgrade_auto:
scarb build
$(eval new_class_hash=$(shell starkli class-hash ./target/dev/starklane_bridge.sierra.json))
starkli declare ./target/dev/starklane_bridge.sierra.json ${priv_key}
+ sleep 2
starkli invoke $(bridge) upgrade ${new_class_hash} ${priv_key}
# Deposit tokens.
@@ -56,6 +58,7 @@ starklane_deposit:
@echo "${shiny}usage: make starklane_deposit config=.yourconfig.env bridge=0x... collection=0x... owner_l1=0x... withdraw_auto=0 tokens=\"1 1 0\"\n${normal}"
$(eval salt=$(shell date +%s%N))
starkli invoke $(bridge) deposit_tokens ${salt} $(collection) $(owner_l1) $(tokens) $(withdraw_auto) 0 ${priv_key}
+ sleep 2
# ERC721 bridgeable deploy
# For now, only supports name and symbol of length 1.
@@ -67,30 +70,34 @@ erc721b_deploy:
# Starklane local setup.
# Use a salt to ensure fixed addresses waiting for starkli address book.
starklane_local_setup:
+ -mkdir -p logs
scarb build
# Declaring contracts
starkli declare ./target/dev/starklane_erc721_bridgeable.sierra.json ${priv_key}
+ sleep 2
starkli declare ./target/dev/starklane_bridge.sierra.json ${priv_key}
-
+ sleep 2
# Deploying Bridge
script -q -f -c "starkli deploy --salt 0x1234 ${bridge_class_hash} "${ADMIN_ACCOUNT_ADDR}" "${BRIDGE_L1_ADDRESS}" ${erc721b_class_hash} ${priv_key}" logs/a.txt
-
+ sleep 2
$(eval bridge_addr=$(shell cat logs/a.txt | tail -n 3 | head -n 1 | sed "s/\x1B\[[0-9;]*[JKmsu]//g"))
echo "-------------> BRIDGE: ${bridge_addr}"
# Deploying ERC721b
script -q -f -c "starkli deploy --salt 0x8822 ${erc721b_class_hash} 1 str:collection_2 1 str:C2 ${bridge_addr} ${ADMIN_ACCOUNT_ADDR} ${priv_key}" logs/b.txt
-
+ sleep 2
$(eval erc721_addr=$(shell tail -n 3 logs/b.txt | head -n 1 | sed "s/\x1B\[[0-9;]*[JKmsu]//g"))
echo "---> ERC721: ${erc721_addr}"
# Minting and set approval for transfer
starkli invoke ${erc721_addr} mint_range_free ${ADMIN_ACCOUNT_ADDR} u256:0 u256:100 ${priv_key}
+ sleep 2
starkli invoke ${erc721_addr} set_approval_for_all ${bridge_addr} 1 ${priv_key}
-
+ sleep 2
+
# Deposit tokens
$(eval salt=$(shell date +%s%N))
starkli invoke ${bridge_addr} deposit_tokens ${salt} ${erc721_addr} ${ETH_ACCOUNT} 2 u256:1 u256:2 1 0 ${priv_key}
diff --git a/apps/blockchain/starknet/README.md b/apps/blockchain/starknet/README.md
index 8ecdb1a4..8d8d4ece 100644
--- a/apps/blockchain/starknet/README.md
+++ b/apps/blockchain/starknet/README.md
@@ -18,6 +18,6 @@ You can always [clone the fork](https://github.com/glihm/starknet-foundry/tree/c
Once forge is installed, you can run:
```bash
-snforge
+snforge test
```
diff --git a/apps/blockchain/starknet/Scarb.toml b/apps/blockchain/starknet/Scarb.toml
index 410bd6aa..238212fa 100644
--- a/apps/blockchain/starknet/Scarb.toml
+++ b/apps/blockchain/starknet/Scarb.toml
@@ -4,7 +4,7 @@ version = "0.1.0"
[dependencies]
starknet = ">=2.4.0"
-snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.13.1" }
+snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.15.0" }
[[target.starknet-contract]]
sierra = true
@@ -12,3 +12,6 @@ casm = true
[lib]
+[tool.sncast.katana]
+account = "katana_account"
+url = "http://127.0.0.1:5050"
\ No newline at end of file
diff --git a/apps/blockchain/starknet/data/katana_account.json b/apps/blockchain/starknet/data/katana_account.json
index 86b40a04..788b3102 100644
--- a/apps/blockchain/starknet/data/katana_account.json
+++ b/apps/blockchain/starknet/data/katana_account.json
@@ -3,11 +3,11 @@
"variant": {
"type": "open_zeppelin",
"version": 1,
- "public_key": "0x1b7b37a580d91bc3ad4f9933ed61f3a395e0e51c9dd5553323b8ca3942bb44e"
+ "public_key": "0x2b191c2f3ecf685a91af7cf72a43e7b90e2e41220175de5c4f7498981b10053"
},
"deployment": {
"status": "deployed",
"class_hash": "0x4d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f",
- "address": "0x3ee9e18edc71a6df30ac3aca2e0b02a198fbce19b7480a63a0d71cbd76652e0"
+ "address": "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"
}
}
diff --git a/apps/indexer/Makefile b/apps/indexer/Makefile
index 6cf4d537..832fc14b 100644
--- a/apps/indexer/Makefile
+++ b/apps/indexer/Makefile
@@ -10,12 +10,12 @@ local_setup_with_devnodes:
sleep 1
@make start_local_devnodes
sleep 1
- make -C ../blockchain/ethereum/ starklane_local_setup config=.env.anvil
- make -C ../blockchain/starknet/ starklane_local_setup config=.env.katana
+ @make local_setup
+
start_local_devnodes:
@echo "Starting devnodes..."
- ~/starknet/dojo/target/release/katana &
+ katana &
anvil &
stop_local_devnodes:
@@ -24,14 +24,14 @@ stop_local_devnodes:
- pkill anvil
db_reset:
- sudo docker-compose -f ./docker-compose.yml down
+ docker-compose -f ./docker-compose.yml down
docker volume rm indexer_starklane_testnet -f
- sudo docker-compose -f ./docker-compose.yml up -d
+ docker-compose -f ./docker-compose.yml up -d
run_dev:
cargo build
@make db_reset
- RUST_LOG=debug cargo run -- --config-file local.config --mongodb mongodb://localhost:27017/starklane
+ RUST_LOG=debug cargo run -- --config-file local.config --mongodb mongodb://localhost:27017/starklane --api-server-ip 127.0.0.1:8080
run_server:
RUST_LOG=starklane_indexer=debug cargo run -- --config-file testnet.config --mongodb mongodb://localhost:27017/starklane_testnet --api-server-ip 127.0.0.1:7890
diff --git a/apps/indexer/docker-compose.yml b/apps/indexer/docker-compose.yml
index ced84eba..83e7588f 100644
--- a/apps/indexer/docker-compose.yml
+++ b/apps/indexer/docker-compose.yml
@@ -1,16 +1,32 @@
version: '3.1'
services:
-
- starklane_db:
- # TODO: add volume for persistence when alpha is ready.
+ indexer:
+ container_name: starklane_indexer
+ # build: .
+ image: ptisserand/starklane-indexer:latest
+ environment:
+ - RUST_LOG=starklane_indexer=DEBUG
+ command: >
+ starklane_indexer --config-file /etc/testnet.config \
+ --mongodb mongodb://${MONGODB_HOSTNAME}:${MONGODB_PORT}/${MONGODB_DB} \
+ --api-server-ip 0.0.0.0:${INDEXER_PORT}
+ volumes:
+ - ./testnet.config:/etc/testnet.config:ro
+ ports:
+ - ${INDEXER_PORT}:${INDEXER_PORT}
+ links:
+ - db:${MONGODB_HOSTNAME}
+ depends_on:
+ - db
+
+ db:
container_name: starklane_db
image: mongo
restart: always
- ports:
- - 27017:27017
volumes:
- - starklane_testnet:/data/db
+ - starklane_data:/data/db
+
volumes:
- starklane_testnet:
+ starklane_data:
diff --git a/apps/indexer/local.config b/apps/indexer/local.config
index c4d32d4a..9bc04336 100644
--- a/apps/indexer/local.config
+++ b/apps/indexer/local.config
@@ -12,10 +12,10 @@
"rpc_url": "http://127.0.0.1:5050",
"from_block": "0",
"to_block": "latest",
- "bridge_address": "0x06013ab73b5c619898e581ab4405e9b90805868cb14187e4ce001fe8fca8b0cd",
+ "bridge_address": "0x5a33d45ccca68ca8a27c26a42fc64cf3bc29c4d99e7ef361b3c5da5847cd461",
"fetch_interval": 1,
- "account_address": "0x03ee9e18edc71a6df30ac3aca2e0b02a198fbce19b7480a63a0d71cbd76652e0",
- "account_private_key": "0x0300001800000000300000180000000000030000000000003006001800006600"
+ "account_address": "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03",
+ "account_private_key": "0x1800000000300000180000000000030000000000003006001800006600"
},
"xchain_txor": {
"enabled": true,