-
Notifications
You must be signed in to change notification settings - Fork 163
fix(playground): repair local compose config; prettier test_playground.sh output
#4352
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
Changes from 3 commits
69c5508
73250d4
0a533d4
d679bc7
562f607
d69af8b
e89980b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,7 +86,7 @@ services: | |
| depends_on: | ||
| - db-migrations | ||
| ports: | ||
| - 8080:80 # API | ||
| - 8080:8080 # API | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this really necessary?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it viceversa?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but the orderbook config binds it to 80: https://github.com/cowprotocol/services/blob/main/playground/orderbook.toml#L2
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, I see the issue.
Looks like that's a leftover from before, so I'd like to just delete
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, lets make this |
||
| - 9586:9586 # metrics | ||
| - 6669:6669 # tokio console | ||
|
|
||
|
|
||
|
jmg-duarte marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ set -u | |
|
|
||
| # Setup parameters | ||
| HOST=localhost:8080 | ||
| OTTERSCAN_URL=${OTTERSCAN_URL:-http://localhost:8003} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isnt this set by default in the dockerfile + docker compose?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compose defines the port mapping, but it does not export 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.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair point, I'll simply hardcode it to |
||
| WETH_ADDRESS="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" # WETH token | ||
| SELL_TOKEN=$WETH_ADDRESS | ||
| BUY_TOKEN="0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" # USDC token | ||
|
|
@@ -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 "Waiting until all services are ready..." | ||
| 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' \ | ||
|
|
@@ -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" \ | ||
|
|
@@ -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 ">>> 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 --retry 5 --retry-delay 2 --retry-all-errors -s --show-error --max-time 10 --connect-timeout 3 \ | ||
| -H 'accept: application/json' \ | ||
|
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 | ||
|
|
||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_playgroundactually creates an EthFlow order, so this should be here because of it.