Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
11 changes: 11 additions & 0 deletions playground/configs/autopilot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ filter = "warn,autopilot=debug,shared=info,price_estimation=info"
[current-block]
poll-interval = "1s"

[run-loop]
solve-deadline = "20s"

[[gas-estimators]]
type = "Web3"

Expand All @@ -20,6 +23,14 @@ address = "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720"

[fee-policies]

[database]
write-url = "%DB_WRITE_URL"
read-url = "%DB_READ_URL"

[ethflow]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change should be necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing here that it's a required value and it gave me errors without it. Perhaps I'm wrong but it seemed like it just didn't have that value.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't hurt being here, but it shouldnt be required, it just wont index ethflow trades

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_playground actually creates an EthFlow order, so this should be here because of it.

contracts = ["0x04501b9b1d52e67f6862d157e00d13419d2d6e95"]
skip-event-sync = true

[order-quoting]
price-estimation-drivers = [{ name = "baseline", url = "http://driver/baseline" }]

Expand Down
2 changes: 1 addition & 1 deletion playground/configs/driver.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
app-data-fetching-enabled = true
orderbook-url = "http://orderbook"
orderbook-url = "http://orderbook:8080"
tx-gas-limit = "45000000"

[[solver]]
Expand Down
4 changes: 4 additions & 0 deletions playground/configs/orderbook.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
eip1271-skip-creation-validation = true

[shared]
node-url = "http://chain:8545"
simulation-node-url = "http://chain:8545"

[order-quoting]
price-estimation-drivers = [{ name = "baseline", url = "http://driver/baseline" }]

Expand Down
2 changes: 1 addition & 1 deletion playground/docker-compose.fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ services:
depends_on:
- db-migrations
ports:
- 8080:80 # API
- 8080:8080 # API
- 9586:9586 # metrics
- 6669:6669 # tokio console

Expand Down
2 changes: 1 addition & 1 deletion playground/docker-compose.non-interactive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ services:
depends_on:
- db-migrations
ports:
- 8080:80 # API
- 8080:8080 # API
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing that orderbook launches on 8080 internally, so shouldn't it be necessary?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the default, the change above maps 8080 on docker to 80 on host, which should allow you to write localhost instead of localhost:8080

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it viceversa? host:container? so the second 8080 relates to container port which orderbook currently launches on?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

@igorroncevic igorroncevic Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see the issue. playground/docker-compose.fork.yml:

Looks like that's a leftover from before, so I'd like to just delete playground/orderbook.toml and fix playground/configs/orderbook.toml to use port 80. Sounds good?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, lets make this playground/configs/orderbook.toml be the only one left
You can also delete configs/local/orderbook.toml

- 9586:9586 # metrics
- 6669:6669 # tokio console

Expand Down
12 changes: 3 additions & 9 deletions playground/tempo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@ distributor:
grpc:
endpoint: 0.0.0.0:4317

ingester:
trace_idle_period: 10s
max_block_bytes: 1_000_000

compactor:
compaction:
compacted_block_retention: 1h

storage:
trace:
backend: local
wal:
path: /tmp/tempo/wal
local:
path: /tmp/tempo
path: /tmp/tempo/blocks
55 changes: 46 additions & 9 deletions playground/test_playground.sh
Comment thread
jmg-duarte marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set -u

# Setup parameters
HOST=localhost:8080
OTTERSCAN_URL=${OTTERSCAN_URL:-http://localhost:8003}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isnt this set by default in the dockerfile + docker compose?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compose defines the port mapping, but it does not export OTTERSCAN_URL into the host shell.

The script runs on the host, so if we want a configurable value here we need to set it in the script or require the user to export it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the script doesnt care for otterscan, the test_playground is something one off
and writing it here doesnt export is to the host shell either, scripts spawn they own bash shells so when they finish the variables basically get wipped

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, I'll simply hardcode it to http://localhost:8003 so it's easier to find

WETH_ADDRESS="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" # WETH token
SELL_TOKEN=$WETH_ADDRESS
BUY_TOKEN="0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" # USDC token
Expand All @@ -21,19 +22,19 @@ APPDATA='{"version":"1.3.0","metadata":{}}'
PRIVATE_KEY="0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6"

# Wait for 2 minutes for all services are read
echo "Waiting until all services are ready"
echo -e "Waiting until all services are ready..."
Comment thread
igorroncevic marked this conversation as resolved.
Outdated
curl --retry 24 --retry-delay 5 --retry-all-errors --fail-with-body -s --show-error \
-H 'accept:application/json' \
http://$HOST/api/v1/token/$BUY_TOKEN/native_price > /dev/null

# Run test flow
echo "Using private key:" $PRIVATE_KEY
echo -e "\n- Private key: $PRIVATE_KEY"
receiver=$(cast wallet address $PRIVATE_KEY)

# Calculate AppData hash
app_data_hash=$(cast keccak $APPDATA)

echo "Request price quote for buying USDC for WETH"
echo -e "\n>>> Requesting price quote for buying USDC for WETH..."
quote_response=$( curl --retry 5 --fail-with-body -s --show-error -X 'POST' \
"http://$HOST/api/v1/quote" \
-H 'accept: application/json' \
Expand Down Expand Up @@ -78,8 +79,10 @@ orderUid=$(docker exec playground-chain-1 cast abi-encode \
"$COW_ETHFLOW_CONTRACT" \
"0xffffffff"
)
echo "Order UID: $orderUid"
echo " Order UID: $orderUid"
echo

echo -e ">>> Creating order on-chain...\n"
docker exec playground-chain-1 cast send \
--json \
--private-key "$PRIVATE_KEY" \
Expand All @@ -88,14 +91,48 @@ docker exec playground-chain-1 cast send \
"createOrder((address, address, uint256, uint256, bytes32, uint256, uint32, bool, int64))" \
"($BUY_TOKEN,$receiver,$sellAmount,$buyAmount,$app_data_hash,$feeAmount,$validTo,false,$quoteId)" > /dev/null

print_settlement_tx() {
trade_response=$(curl --retry 5 --fail-with-body -s --show-error -X 'GET' \
"http://$HOST/api/v1/trades?orderUid=$orderUid" \
-H 'accept: application/json')
tx_hash=$(jq -r '.[0].txHash // empty' <<< "${trade_response}")

if [ -n "$tx_hash" ]; then
echo -e "\n-------------------------------------------------- SUCCESS ---------------------------------------------------"
echo " Settlement tx hash: $tx_hash"
echo " Inspect with: cast receipt $tx_hash --rpc-url http://localhost:8545"
echo " Open in Otterscan: $OTTERSCAN_URL/tx/$tx_hash"
echo "--------------------------------------------------------------------------------------------------------------"
else
echo "Settlement tx hash not available yet"
fi
}

echo -e ">>> Polling order status..."
for i in $(seq 1 24);
do
orderStatus=$( curl --retry 5 --fail-with-body -s --show-error -X 'GET' \
"http://$HOST/api/v1/orders/$orderUid/status" \
-H 'accept: application/json' | jq -r '.type')
echo -e -n "Order status: $orderStatus \r"
status_response=$(curl -s --show-error --max-time 10 --connect-timeout 3 \
-H 'accept: application/json' \
Comment thread
igorroncevic marked this conversation as resolved.
-w '\n%{http_code}' \
"http://$HOST/api/v1/orders/$orderUid/status") || {
echo "Polling failed while checking order status"
exit 1
}
status_http_code=$(tail -n 1 <<< "${status_response}")
status_body=$(sed '$d' <<< "${status_response}")

if [ "$status_http_code" = "404" ]; then
orderStatus="indexing"
elif [ "$status_http_code" = "200" ]; then
orderStatus=$(jq -r '.type' <<< "${status_body}")
else
echo "Unexpected order status response ($status_http_code): ${status_body}"
exit 1
fi

echo " Order status: $orderStatus"
if [ "$orderStatus" = "traded" ]; then
echo -e "\nSuccess"
print_settlement_tx
exit 0
fi
sleep 5
Expand Down
Loading