Skip to content

Commit

Permalink
CI: use tool-versions instead of hardcoded scarb version
Browse files Browse the repository at this point in the history
  • Loading branch information
ptisserand committed Feb 6, 2024
1 parent e7fefc1 commit b51af1f
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion .tool-versions

This file was deleted.

5 changes: 3 additions & 2 deletions apps/blockchain/ethereum/.env.anvil
Original file line number Diff line number Diff line change
@@ -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).
Expand All @@ -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
18 changes: 9 additions & 9 deletions apps/blockchain/ethereum/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,60 @@ 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:
@printf "$(bold)Ensure you don't forget the proxy argument:\n"
@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:
@printf "$(bold)Ensure you don't forget the proxy argument:\n"
@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:
@printf "$(bold)Ensure you don't forget the proxy argument:\n"
@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:
@printf "$(bold)Ensure you don't forget the proxy argument:\n"
@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:
@printf "$(bold)Ensure you don't forget the proxy argument:\n"
@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

3 changes: 3 additions & 0 deletions apps/blockchain/ethereum/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
2 changes: 1 addition & 1 deletion apps/blockchain/ethereum/script/LocalTesting.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ contract LocalSetup is Script {
"mintRangeFree(address,uint256,uint256)",
config.deployerAddress,
0,
10
20
)
);

Expand Down
4 changes: 2 additions & 2 deletions apps/blockchain/ethereum/script/Starklane.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
8 changes: 6 additions & 2 deletions apps/blockchain/starknet/.env.katana
Original file line number Diff line number Diff line change
@@ -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

4 changes: 2 additions & 2 deletions apps/blockchain/starknet/.tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scarb 2.4.3
starknet-foundry 0.13.1
scarb 2.4.4
starknet-foundry 0.15.0
15 changes: 11 additions & 4 deletions apps/blockchain/starknet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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}
2 changes: 1 addition & 1 deletion apps/blockchain/starknet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

5 changes: 4 additions & 1 deletion apps/blockchain/starknet/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ 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
casm = true

[lib]

[tool.sncast.katana]
account = "katana_account"
url = "http://127.0.0.1:5050"
4 changes: 2 additions & 2 deletions apps/blockchain/starknet/data/katana_account.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
12 changes: 6 additions & 6 deletions apps/indexer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
30 changes: 23 additions & 7 deletions apps/indexer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
6 changes: 3 additions & 3 deletions apps/indexer/local.config
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b51af1f

Please sign in to comment.