Skip to content

Commit

Permalink
Feat/sim edit (#157)
Browse files Browse the repository at this point in the history
* Sim updates

* Sim err update

* Update script

* add folder

* Update readme

* new file in output

* Remove file

* Add example

* cd for github actions
  • Loading branch information
dhruv035 authored Jul 29, 2024
1 parent 8964287 commit f7301c9
Show file tree
Hide file tree
Showing 7 changed files with 2,352 additions and 975 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ out/

.DS_Store
.env
scripts/simulationData/simulationOutput/
scripts/simulationData/simulationOutput/simulationResults*.json
41 changes: 41 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Pitchlake Simulator

## Install packages

To install the modules go to the scripts directory and run the following
```
yarn
#or
npm install
#or
pnpm install
```
The original codebase uses [Scarb](https://docs.swmansion.com/scarb/) (2.6.4) to build and test the contracts. Be sure to setup [asdf](https://asdf-vm.com/) as well, to handle versioning.

To ensure you are setup, run the following command from the root of this directory and check the output matches:

```
❯ scarb --version
scarb 2.6.4 (c4c7c0bac 2024-03-19)
cairo: 2.6.3 (https://crates.io/crates/cairo-lang-compiler/2.6.3)
sierra: 1.5.0
```

You also need to install dojo to spinup a local instance of starknet chain Katana. Read documentation [here](https://book.dojoengine.org/)

```
#Install dojo
curl -L https://install.dojoengine.org | bash
#or
asdf plugin add dojo https://github.com/dojoengine/asdf-dojo
asdf install dojo latest
#Update dojo
dojoup
```

## Run simulation
To run the simulation you need to add the market data as marketData.json in scripts/simulationData directory. The simulation set's bidding price at reservePrice to run the rounds. To run the simulation execute the katana.sh bash script
```
bash katana.sh
```

10 changes: 3 additions & 7 deletions scripts/katana.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
#!/bin/bash

# Find available port using Python
PORT=$(python3 -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()')

echo "Starting katana on port $PORT"
katana --chain-id SN_SEPOLIA --host 127.0.0.1 --port 5050 --accounts "25" --seed "1" -b 2000 --dev &
# while ! nc -z localhost $PORT; do
# sleep 0.1 # wait for 1/10 of the second before check again
# done

cd scripts
./generate_abi.sh

# Run your Node script
echo "Running main.js on port $PORT"
cd scripts
node --loader ts-node/esm main.ts dev 5050
node --loader ts-node/esm simulation.ts dev 5050
lsof -i tcp:5050 | awk 'NR!=1 {print $2}' | xargs kill

# echo "Running smokeTesting.js on port $PORT"
# node ./scripts/intergration_test/smokeTesting.js dev $PORT
Expand Down
Loading

0 comments on commit f7301c9

Please sign in to comment.