Skip to content
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

Feat/sepolia #575

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
384b937
begin implementation
starknetdev Jan 22, 2024
3072a37
Merge branch 'main' into feat/sepolia
starknetdev Jan 22, 2024
ee9ebe7
continue
starknetdev Jan 23, 2024
0c31f1a
continue
starknetdev Jan 23, 2024
6420623
continue
starknetdev Jan 23, 2024
29b1a45
continue
starknetdev Jan 23, 2024
13dd221
continue
starknetdev Jan 23, 2024
8e3630e
continue
starknetdev Jan 23, 2024
040e8eb
continue
starknetdev Jan 23, 2024
059c795
- update starknet-react
starknetdev Jan 23, 2024
67ee3a8
fix build
starknetdev Jan 23, 2024
5a2b42e
fix prefund amount for sepolia
starknetdev Jan 23, 2024
7d397f6
fix to sepolia indexer
starknetdev Jan 23, 2024
dbd19dc
update game and GT addresses
starknetdev Jan 23, 2024
f4f78f7
update indexer game address
starknetdev Jan 23, 2024
1ceb38c
Merge branch 'main' into feat/sepolia
starknetdev Mar 18, 2024
d1fa751
- update sepolia fees
starknetdev Apr 2, 2024
12300ca
LS V1.1 (#574)
starknetdev Apr 17, 2024
315a27d
change env
ponderingdemocritus Apr 17, 2024
ad5b81f
test change
ponderingdemocritus Apr 17, 2024
92b945b
faucet
ponderingdemocritus Apr 17, 2024
19b018d
change testnet from goerli to sepolia
loothero Apr 27, 2024
3f8faa8
Merge pull request #576 from BibliothecaDAO/change-testnet-to-sepolia
ponderingdemocritus Apr 27, 2024
f8981a5
fixes #577 number out of bounds during optimistic start
loothero Apr 27, 2024
276730e
interface
ponderingdemocritus Apr 27, 2024
2ac6e1c
merge
ponderingdemocritus Apr 27, 2024
39d07e7
Merge pull request #578 from BibliothecaDAO/577-optimistic-start-bug
ponderingdemocritus Apr 27, 2024
ad5bd3e
- add break page for sepolia
starknetdev May 20, 2024
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
Binary file modified .DS_Store
Binary file not shown.
363 changes: 247 additions & 116 deletions contracts/game/src/game/interfaces.cairo

Large diffs are not rendered by default.

730 changes: 357 additions & 373 deletions contracts/game/src/lib.cairo

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion indexer/env-mainnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GAME="0x03c10537fa0073b2dd5120242697dbf76d6173eb9f384d3bf3d284d53388a0b0"
START=368800
START=388900
MONGO_CONNECTION_STRING="mongodb://mongo:mongo@mongo:27017"
MONGO_DB="mongo"
STREAM_URL="https://mainnet.starknet.a5a.ch"
5 changes: 5 additions & 0 deletions indexer/env-sepolia
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
GAME="0x00e55a2cde54c0051a72e44e81ddeed12103cc1cd1a20dc14fe52520e69b14ea"
START=60000
MONGO_CONNECTION_STRING="mongodb://mongo:mongo@mongo:27017"
MONGO_DB="mongo"
STREAM_URL='https://sepolia.starknet.a5a.ch'
14 changes: 14 additions & 0 deletions indexer/graphql/Dockerfile.sepolia
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.9-buster

WORKDIR /app

COPY src .
COPY poetry.lock .
COPY pyproject.toml .

RUN python3 -m pip install poetry
RUN python3 -m pip install pycryptodome
RUN poetry config virtualenvs.create false
RUN poetry install

ENTRYPOINT [ "indexer", "graphql", "--mongo", "mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@34.245.17.93:27017", "--port", "8080" ]
4 changes: 2 additions & 2 deletions indexer/graphql/src/indexer/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -1601,8 +1601,8 @@ async def run_graphql_api(mongo=None, port="8080"):

ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_context.load_cert_chain(
"/etc/letsencrypt/live/survivor-mainnet-indexer.realms.world/fullchain.pem",
"/etc/letsencrypt/live/survivor-mainnet-indexer.realms.world/privkey.pem",
"/etc/letsencrypt/live/survivor-sepolia-indexer.realms.world/fullchain.pem",
"/etc/letsencrypt/live/survivor-sepolia-indexer.realms.world/privkey.pem",
)

runner = web.AppRunner(app)
Expand Down
12 changes: 6 additions & 6 deletions indexer/mainnet-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
restart: always
command:
- run
- --allow-env=/data/env-mainnet
- --allow-env=/data/env-sepolia
- /data/src/adventurers.ts
volumes:
- ./:/data/
Expand All @@ -49,7 +49,7 @@ services:
restart: always
command:
- run
- --allow-env=/data/env-mainnet
- --allow-env=/data/env-sepolia
- /data/src/battles.ts
volumes:
- ./:/data/
Expand All @@ -67,7 +67,7 @@ services:
restart: always
command:
- run
- --allow-env=/data/env-mainnet
- --allow-env=/data/env-sepolia
- /data/src/beasts.ts
volumes:
- ./:/data/
Expand All @@ -85,7 +85,7 @@ services:
restart: always
command:
- run
- --allow-env=/data/env-mainnet
- --allow-env=/data/env-sepolia
- /data/src/discoveries.ts
volumes:
- ./:/data/
Expand All @@ -103,7 +103,7 @@ services:
restart: always
command:
- run
- --allow-env=/data/env-mainnet
- --allow-env=/data/env-sepolia
- /data/src/items.ts
volumes:
- ./:/data/
Expand All @@ -121,7 +121,7 @@ services:
restart: always
command:
- run
- --allow-env=/data/env-mainnet
- --allow-env=/data/env-sepolia
- /data/src/scores.ts
volumes:
- ./:/data/
Expand Down
44 changes: 44 additions & 0 deletions indexer/restart-compose-sepolia.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Path to your docker-compose.yml file
COMPOSE_PATH="sepolia-compose.yaml"

# Container names (as specified in docker-compose.yml)
CONTAINER_NAMES=("indexer-adventurers_indexer-1" "indexer-battles_indexer-1" "indexer-beasts_indexer-1" "indexer-discoveries_indexer-1" "indexer-items_indexer-1" "indexer-scores_indexer-1")

# Time to wait between checks (5mins / 300 seconds)
INTERVAL=300

# Check if a block has been processed in the last minute
check_container_activity() {
local CONTAINER_NAME="$1"
LAST_LOG=$(docker logs "$CONTAINER_NAME" 2>&1 | tail -1) # Assuming you want the last log entry
echo "Extracted log: $LAST_LOG" # Print timestamp for verification
LAST_TIMESTAMP=$(echo "$LAST_LOG" | sed -E 's/\x1B\[[0-9;]*[JKmsu]//g' | cut -d' ' -f1)

echo "Extracted timestamp: $LAST_TIMESTAMP" # Print timestamp for verification

# Convert timestamp to epoch (seconds since 1970)
LAST_EPOCH=$(date -d "$LAST_TIMESTAMP" +%s)
CURRENT_EPOCH=$(date +%s)
echo "Current time difference: $((CURRENT_EPOCH - LAST_EPOCH)) seconds"

# If the difference is more than the interval, return 1 (unhealthy)
if (( CURRENT_EPOCH - LAST_EPOCH > INTERVAL )); then
return 1
else
return 0
fi
}

while true; do
for CONTAINER_NAME in "${CONTAINER_NAMES[@]}"; do
if ! check_container_activity "$CONTAINER_NAME"; then
echo "Container $CONTAINER_NAME seems to be stuck. Restarting..."
docker-compose -f $COMPOSE_PATH stop "$CONTAINER_NAME"
docker-compose -f $COMPOSE_PATH up -d "$CONTAINER_NAME"
# # Add a notification mechanism here if needed
fi
done
sleep $INTERVAL
done
7 changes: 0 additions & 7 deletions indexer/scripts/run_adventurers.sh

This file was deleted.

7 changes: 0 additions & 7 deletions indexer/scripts/run_battles.sh

This file was deleted.

7 changes: 0 additions & 7 deletions indexer/scripts/run_beasts.sh

This file was deleted.

7 changes: 0 additions & 7 deletions indexer/scripts/run_discoveries.sh

This file was deleted.

7 changes: 0 additions & 7 deletions indexer/scripts/run_items.sh

This file was deleted.

7 changes: 0 additions & 7 deletions indexer/scripts/run_scores.sh

This file was deleted.

147 changes: 147 additions & 0 deletions indexer/sepolia-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
version: '3.6'

services:
mongo:
image: mongo:6.0.8
restart: always
ports:
- "27017:27017"
volumes:
- mongo_data:/data/db
- ./scripts/mongo-init:/docker-entrypoint-initdb.d
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}
networks:
- indexer

etcd:
image: docker.io/bitnami/etcd:3.5
environment:
ALLOW_NONE_AUTHENTICATION: "yes"
volumes:
- etcd_data:/bitnami/etcd
networks:
- indexer


adventurers_indexer:
image: quay.io/apibara/sink-mongo:0.4.2
depends_on:
- etcd
- mongo
restart: always
command:
- run
- --allow-env=/data/env-sepolia
- /data/src/adventurers.ts
volumes:
- ./:/data/
environment:
PERSIST_TO_ETCD: http://etcd:2379
SINK_ID: adventurers
AUTH_TOKEN: ${AUTH_TOKEN}
networks:
- indexer

battles_indexer:
image: quay.io/apibara/sink-mongo:0.4.2
depends_on:
- etcd
- mongo
restart: always
command:
- run
- --allow-env=/data/env-sepolia
- /data/src/battles.ts
volumes:
- ./:/data/
environment:
PERSIST_TO_ETCD: http://etcd:2379
SINK_ID: battles
AUTH_TOKEN: ${AUTH_TOKEN}
networks:
- indexer

beasts_indexer:
image: quay.io/apibara/sink-mongo:0.4.2
depends_on:
- etcd
- mongo
restart: always
command:
- run
- --allow-env=/data/env-sepolia
- /data/src/beasts.ts
volumes:
- ./:/data/
environment:
PERSIST_TO_ETCD: http://etcd:2379
SINK_ID: beasts
AUTH_TOKEN: ${AUTH_TOKEN}
networks:
- indexer

discoveries_indexer:
image: quay.io/apibara/sink-mongo:0.4.2
depends_on:
- etcd
- mongo
restart: always
command:
- run
- --allow-env=/data/env-sepolia
- /data/src/discoveries.ts
volumes:
- ./:/data/
environment:
PERSIST_TO_ETCD: http://etcd:2379
SINK_ID: discoveries
AUTH_TOKEN: ${AUTH_TOKEN}
networks:
- indexer

items_indexer:
image: quay.io/apibara/sink-mongo:0.4.2
depends_on:
- etcd
- mongo
restart: always
command:
- run
- --allow-env=/data/env-sepolia
- /data/src/items.ts
volumes:
- ./:/data/
environment:
PERSIST_TO_ETCD: http://etcd:2379
SINK_ID: items
AUTH_TOKEN: ${AUTH_TOKEN}
networks:
- indexer

scores_indexer:
image: quay.io/apibara/sink-mongo:0.4.2
depends_on:
- etcd
- mongo
restart: always
command:
- run
- --allow-env=/data/env-sepolia
- /data/src/scores.ts
volumes:
- ./:/data/
environment:
PERSIST_TO_ETCD: http://etcd:2379
SINK_ID: scores
AUTH_TOKEN: ${AUTH_TOKEN}
networks:
- indexer

volumes:
etcd_data:
mongo_data:

networks:
indexer:
60 changes: 60 additions & 0 deletions scripts/stress_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import requests
import threading

def simulate_adventurer_getter():
url = 'https://survivor-goerli-indexer.realms.world/graphql'

# Example GraphQL query to get all adventurer information
query = '''
query {
adventurers {
actionsPerBlock
beastHealth
charisma
chest
createdTime
dexterity
foot
gold
hand
head
health
id
intelligence
lastAction
lastUpdatedTime
luck
name
neck
owner
revealBlock
ring
startBlock
statUpgrades
strength
timestamp
vitality
waist
weapon
wisdom
xp
}
}
'''

response = requests.post(url, json={'query': query})
print(f"{response.status_code}, {response.text}")

def main():
query_threads = []

for i in range(1):
thread = threading.Thread(target=simulate_adventurer_getter)
thread.start()
query_threads.append(thread)

for thread in query_threads:
thread.join()

if __name__ == "__main__":
main()
Loading
Loading