diff --git a/configs/local/orderbook.toml b/configs/local/orderbook.toml deleted file mode 100644 index f5b1a0e54a..0000000000 --- a/configs/local/orderbook.toml +++ /dev/null @@ -1,19 +0,0 @@ -eip1271-skip-creation-validation = true -bind-address = "0.0.0.0:80" - -[shared] -node-url = "http://chain:8545" -simulation-node-url = "http://chain:8545" - -[shared.tracing] -collector-endpoint = "http://tempo:4317" - -[database] -write-url = "%DB_WRITE_URL" -read-url = "%DB_READ_URL" - -[native-price-estimation] -estimators = [[{ type = "Driver", name = "baseline", url = "http://driver/baseline" }]] - -[order-quoting] -price-estimation-drivers = [{ name = "baseline", url = "http://driver/baseline" }] diff --git a/playground/configs/autopilot.toml b/playground/configs/autopilot.toml index 93b0664c58..937eb9f1ee 100644 --- a/playground/configs/autopilot.toml +++ b/playground/configs/autopilot.toml @@ -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" @@ -20,6 +23,14 @@ address = "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720" [fee-policies] +[database] +write-url = "%DB_WRITE_URL" +read-url = "%DB_READ_URL" + +[ethflow] +contracts = ["0x04501b9b1d52e67f6862d157e00d13419d2d6e95"] +skip-event-sync = true + [order-quoting] price-estimation-drivers = [{ name = "baseline", url = "http://driver/baseline" }] diff --git a/playground/configs/orderbook.toml b/playground/configs/orderbook.toml index 7d8f3c490b..f5b1a0e54a 100644 --- a/playground/configs/orderbook.toml +++ b/playground/configs/orderbook.toml @@ -1,11 +1,19 @@ eip1271-skip-creation-validation = true +bind-address = "0.0.0.0:80" -[order-quoting] -price-estimation-drivers = [{ name = "baseline", url = "http://driver/baseline" }] +[shared] +node-url = "http://chain:8545" +simulation-node-url = "http://chain:8545" -[native-price-estimation] -estimators = [[{ type = "Driver", name = "baseline", url = "http://driver/baseline" }]] +[shared.tracing] +collector-endpoint = "http://tempo:4317" [database] write-url = "%DB_WRITE_URL" read-url = "%DB_READ_URL" + +[native-price-estimation] +estimators = [[{ type = "Driver", name = "baseline", url = "http://driver/baseline" }]] + +[order-quoting] +price-estimation-drivers = [{ name = "baseline", url = "http://driver/baseline" }] diff --git a/playground/orderbook.toml b/playground/orderbook.toml deleted file mode 100644 index f5b1a0e54a..0000000000 --- a/playground/orderbook.toml +++ /dev/null @@ -1,19 +0,0 @@ -eip1271-skip-creation-validation = true -bind-address = "0.0.0.0:80" - -[shared] -node-url = "http://chain:8545" -simulation-node-url = "http://chain:8545" - -[shared.tracing] -collector-endpoint = "http://tempo:4317" - -[database] -write-url = "%DB_WRITE_URL" -read-url = "%DB_READ_URL" - -[native-price-estimation] -estimators = [[{ type = "Driver", name = "baseline", url = "http://driver/baseline" }]] - -[order-quoting] -price-estimation-drivers = [{ name = "baseline", url = "http://driver/baseline" }] diff --git a/playground/tempo.yaml b/playground/tempo.yaml index b20547a4b4..95d84e7d5c 100644 --- a/playground/tempo.yaml +++ b/playground/tempo.yaml @@ -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 diff --git a/playground/test_playground.sh b/playground/test_playground.sh index c19586e850..981df88352 100755 --- a/playground/test_playground.sh +++ b/playground/test_playground.sh @@ -7,6 +7,7 @@ set -u # Setup parameters HOST=localhost:8080 +OTTERSCAN_URL=http://localhost:8003 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 -e "\n 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' \ + -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