Skip to content

Commit

Permalink
temporary tps increase
Browse files Browse the repository at this point in the history
  • Loading branch information
yHSJ committed Dec 3, 2024
1 parent c5b882b commit d4c8339
Show file tree
Hide file tree
Showing 8 changed files with 345 additions and 246 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- "main"
- "fast-submit-test"

jobs:
docker:
Expand Down Expand Up @@ -43,7 +44,7 @@ jobs:
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{version}}
type=sha
- name: Extract metadata (tags, labels) for the AI docker image
id: meta_ai
uses: docker/metadata-action@v5
Expand Down Expand Up @@ -88,4 +89,4 @@ jobs:
platforms: linux/amd64
push: true
tags: ${{ steps.meta_ai.outputs.tags }}
labels: ${{ steps.meta_ai.outputs.labels }}
labels: ${{ steps.meta_ai.outputs.labels }}
39 changes: 24 additions & 15 deletions referee/referee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import { KinesisClient, PutRecordsCommand } from "@aws-sdk/client-kinesis";
import { Packet } from "utils/HydraMultiplayer/base.js";
import { fromHex, toHex } from "utils/helpers.js";



const NETWORK_ID = Number(process.env.NETWORK_ID);
const HYDRA_NODE = "http://localhost:4001/";
const RECORD_STATS = true;

const kinesis = new KinesisClient({
region: process.env.AWS_REGION === "ap-southeast-1" ? "ap-southeast-1" : "us-east-1",
region:
process.env.AWS_REGION === "ap-southeast-1"
? "ap-southeast-1"
: "us-east-1",
});
const encoder = new TextEncoder();

Expand Down Expand Up @@ -111,7 +112,6 @@ const module = await createModule({
},
});
global.Module = module;

const hydra = new HydraMultiplayerServer({
key: keys,
address: keys.address,
Expand Down Expand Up @@ -354,21 +354,30 @@ const args = [
"-config",
"default.cfg",
];
try {
module.callMain(args);
} catch (e) {
console.error(e);
}
// try {
// module.callMain(args);
// } catch (e) {
// console.error(e);
// }

while (!done) {
await new Promise((resolve) => setTimeout(resolve, 1000));
timeout -= 1000;
if (timeout <= 0) {
console.log("Game timed out.");
done = true;
while (true) {
if (!hydra.hydra.isConnected()) {
continue;
}
// According to https://www.doomworld.com/forum/topic/99810-how-much-data-does-online-dming-consume/ assumptions, the network packet is about 6 bytes
await hydra.SendPacket(0, 0, new Uint8Array([0, 0, 0, 0, 0, 0]));
await new Promise((resolve) => setTimeout(resolve, 1));
}

// while (!done) {
// await new Promise((resolve) => setTimeout(resolve, 1000));
// timeout -= 1000;
// if (timeout <= 0) {
// console.log("Game timed out.");
// done = true;
// }
// }

console.log("Game finished.");
try {
console.log("Ending game. Marking game as 'Aborted'.");
Expand Down
114 changes: 44 additions & 70 deletions referee/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@
tslib "^2.6.2"

"@aws-sdk/client-kinesis@^3.696.0":
version "3.696.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/client-kinesis/-/client-kinesis-3.696.0.tgz#f4da916e665ab6a3f41d60638bd5a808e3d3a09e"
integrity sha512-CuLlB+Km7ACbZzOma6JRpY9w633JhCqRijH8mHz05wxzv5oyrrTM+izICBES3PtZKCNMgcY0K+yZScAG7qBg9w==
version "3.699.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/client-kinesis/-/client-kinesis-3.699.0.tgz#8d502419fed59b6aa881b4a6d4c6ff66e80140b8"
integrity sha512-jxmFlJVJslx+Mgyo4SVvTZSyOrdcyGclE1dvDO17qmzmY2yLfHrYZD2OliAI/Wfof0j+NSK7bVojfDrfiwWZHA==
dependencies:
"@aws-crypto/sha256-browser" "5.2.0"
"@aws-crypto/sha256-js" "5.2.0"
"@aws-sdk/client-sso-oidc" "3.696.0"
"@aws-sdk/client-sts" "3.696.0"
"@aws-sdk/client-sso-oidc" "3.699.0"
"@aws-sdk/client-sts" "3.699.0"
"@aws-sdk/core" "3.696.0"
"@aws-sdk/credential-provider-node" "3.696.0"
"@aws-sdk/credential-provider-node" "3.699.0"
"@aws-sdk/middleware-host-header" "3.696.0"
"@aws-sdk/middleware-logger" "3.696.0"
"@aws-sdk/middleware-recursion-detection" "3.696.0"
Expand Down Expand Up @@ -100,15 +100,15 @@
"@smithy/util-waiter" "^3.1.9"
tslib "^2.6.2"

"@aws-sdk/client-sso-oidc@3.696.0":
version "3.696.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.696.0.tgz#b6a92ae876d3fdaa986bd70bbb329dcbcd12ea2b"
integrity sha512-ikxQ3mo86d1mAq5zTaQAh8rLBERwL+I4MUYu/IVYW2hhl9J2SDsl0SgnKeXQG6S8zWuHcBO587zsZaRta1MQ/g==
"@aws-sdk/client-sso-oidc@3.699.0":
version "3.699.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.699.0.tgz#a35665e681abd518b56330bc7dab63041fbdaf83"
integrity sha512-u8a1GorY5D1l+4FQAf4XBUC1T10/t7neuwT21r0ymrtMFSK2a9QqVHKMoLkvavAwyhJnARSBM9/UQC797PFOFw==
dependencies:
"@aws-crypto/sha256-browser" "5.2.0"
"@aws-crypto/sha256-js" "5.2.0"
"@aws-sdk/core" "3.696.0"
"@aws-sdk/credential-provider-node" "3.696.0"
"@aws-sdk/credential-provider-node" "3.699.0"
"@aws-sdk/middleware-host-header" "3.696.0"
"@aws-sdk/middleware-logger" "3.696.0"
"@aws-sdk/middleware-recursion-detection" "3.696.0"
Expand Down Expand Up @@ -189,16 +189,16 @@
"@smithy/util-utf8" "^3.0.0"
tslib "^2.6.2"

"@aws-sdk/client-sts@3.696.0":
version "3.696.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/client-sts/-/client-sts-3.696.0.tgz#58d820a6d6f62626fd3177e7c0dc90027f0c6c3c"
integrity sha512-eJOxR8/UyI7kGSRyE751Ea7MKEzllQs7eNveDJy9OP4t/jsN/P19HJ1YHeA1np40JRTUBfqa6WLAAiIXsk8rkg==
"@aws-sdk/client-sts@3.699.0":
version "3.699.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/client-sts/-/client-sts-3.699.0.tgz#9419be6bbf3809008128117afea8b9129b5a959d"
integrity sha512-++lsn4x2YXsZPIzFVwv3fSUVM55ZT0WRFmPeNilYIhZClxHLmVAWKH4I55cY9ry60/aTKYjzOXkWwyBKGsGvQg==
dependencies:
"@aws-crypto/sha256-browser" "5.2.0"
"@aws-crypto/sha256-js" "5.2.0"
"@aws-sdk/client-sso-oidc" "3.696.0"
"@aws-sdk/client-sso-oidc" "3.699.0"
"@aws-sdk/core" "3.696.0"
"@aws-sdk/credential-provider-node" "3.696.0"
"@aws-sdk/credential-provider-node" "3.699.0"
"@aws-sdk/middleware-host-header" "3.696.0"
"@aws-sdk/middleware-logger" "3.696.0"
"@aws-sdk/middleware-recursion-detection" "3.696.0"
Expand Down Expand Up @@ -279,16 +279,16 @@
"@smithy/util-stream" "^3.3.1"
tslib "^2.6.2"

"@aws-sdk/credential-provider-ini@3.696.0":
version "3.696.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.696.0.tgz#8b162db836c81582f249e24adff48f01cacca402"
integrity sha512-9WsZZofjPjNAAZhIh7c7FOhLK8CR3RnGgUm1tdZzV6ZSM1BuS2m6rdwIilRxAh3fxxKDkmW/r/aYmmCYwA+AYA==
"@aws-sdk/credential-provider-ini@3.699.0":
version "3.699.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.699.0.tgz#7919a454b05c5446d04a0d3270807046a029ee30"
integrity sha512-dXmCqjJnKmG37Q+nLjPVu22mNkrGHY8hYoOt3Jo9R2zr5MYV7s/NHsCHr+7E+BZ+tfZYLRPeB1wkpTeHiEcdRw==
dependencies:
"@aws-sdk/core" "3.696.0"
"@aws-sdk/credential-provider-env" "3.696.0"
"@aws-sdk/credential-provider-http" "3.696.0"
"@aws-sdk/credential-provider-process" "3.696.0"
"@aws-sdk/credential-provider-sso" "3.696.0"
"@aws-sdk/credential-provider-sso" "3.699.0"
"@aws-sdk/credential-provider-web-identity" "3.696.0"
"@aws-sdk/types" "3.696.0"
"@smithy/credential-provider-imds" "^3.2.6"
Expand All @@ -297,16 +297,16 @@
"@smithy/types" "^3.7.1"
tslib "^2.6.2"

"@aws-sdk/credential-provider-node@3.696.0":
version "3.696.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-node/-/credential-provider-node-3.696.0.tgz#6d8d97a85444bfd3c5a1aded9ce894f68e6d3547"
integrity sha512-8F6y5FcfRuMJouC5s207Ko1mcVvOXReBOlJmhIwE4QH1CnO/CliIyepnAZrRQ659mo5wIuquz6gXnpYbitEVMg==
"@aws-sdk/credential-provider-node@3.699.0":
version "3.699.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-node/-/credential-provider-node-3.699.0.tgz#6a1e32a49a7fa71d10c85a927267d1782444def1"
integrity sha512-MmEmNDo1bBtTgRmdNfdQksXu4uXe66s0p1hi1YPrn1h59Q605eq/xiWbGL6/3KdkViH6eGUuABeV2ODld86ylg==
dependencies:
"@aws-sdk/credential-provider-env" "3.696.0"
"@aws-sdk/credential-provider-http" "3.696.0"
"@aws-sdk/credential-provider-ini" "3.696.0"
"@aws-sdk/credential-provider-ini" "3.699.0"
"@aws-sdk/credential-provider-process" "3.696.0"
"@aws-sdk/credential-provider-sso" "3.696.0"
"@aws-sdk/credential-provider-sso" "3.699.0"
"@aws-sdk/credential-provider-web-identity" "3.696.0"
"@aws-sdk/types" "3.696.0"
"@smithy/credential-provider-imds" "^3.2.6"
Expand All @@ -327,14 +327,14 @@
"@smithy/types" "^3.7.1"
tslib "^2.6.2"

"@aws-sdk/credential-provider-sso@3.696.0":
version "3.696.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.696.0.tgz#3e58608e7c330e08206af496a14764f82a776acf"
integrity sha512-4SSZ9Nk08JSu4/rX1a+dEac/Ims1HCXfV7YLUe5LGdtRLSKRoQQUy+hkFaGYoSugP/p1UfUPl3BuTO9Vv8z1pA==
"@aws-sdk/credential-provider-sso@3.699.0":
version "3.699.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.699.0.tgz#515e2ecd407bace3141b8b192505631de415667e"
integrity sha512-Ekp2cZG4pl9D8+uKWm4qO1xcm8/MeiI8f+dnlZm8aQzizeC+aXYy9GyoclSf6daK8KfRPiRfM7ZHBBL5dAfdMA==
dependencies:
"@aws-sdk/client-sso" "3.696.0"
"@aws-sdk/core" "3.696.0"
"@aws-sdk/token-providers" "3.696.0"
"@aws-sdk/token-providers" "3.699.0"
"@aws-sdk/types" "3.696.0"
"@smithy/property-provider" "^3.1.9"
"@smithy/shared-ini-file-loader" "^3.1.10"
Expand Down Expand Up @@ -406,10 +406,10 @@
"@smithy/util-middleware" "^3.0.10"
tslib "^2.6.2"

"@aws-sdk/token-providers@3.696.0":
version "3.696.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/token-providers/-/token-providers-3.696.0.tgz#22ca7cf0901885d2f01aed6fe664e5162ae58108"
integrity sha512-fvTcMADrkwRdNwVmJXi2pSPf1iizmUqczrR1KusH4XehI/KybS4U6ViskRT0v07vpxwL7x+iaD/8fR0PUu5L/g==
"@aws-sdk/token-providers@3.699.0":
version "3.699.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/token-providers/-/token-providers-3.699.0.tgz#354990dd52d651c1f7a64c4c0894c868cdc81de2"
integrity sha512-kuiEW9DWs7fNos/SM+y58HCPhcIzm1nEZLhe2/7/6+TvAYLuEWURYsbK48gzsxXlaJ2k/jGY3nIsA7RptbMOwA==
dependencies:
"@aws-sdk/types" "3.696.0"
"@smithy/property-provider" "^3.1.9"
Expand Down Expand Up @@ -749,9 +749,9 @@
"@multiformats/multiaddr" "^12.0.0"

"@multiformats/multiaddr@^12.0.0", "@multiformats/multiaddr@^12.1.14":
version "12.3.3"
resolved "https://registry.yarnpkg.com/@multiformats/multiaddr/-/multiaddr-12.3.3.tgz#eddd0a61a542fc0120da7b5f6fc250177762e6d4"
integrity sha512-3POIUN7myk8JbO8oi/FEyZoLQW2XMhwM/uB7hG5Zl1PgdXJR8UTH9QdQEp1jM358kd3yn+vtS4fFJdqdRk+O7A==
version "12.3.4"
resolved "https://registry.yarnpkg.com/@multiformats/multiaddr/-/multiaddr-12.3.4.tgz#3dd3d7d76f95ce9c8768770e8008a99de9b7ba49"
integrity sha512-R4pEEUyWGrRo16TSflz80Yr6XNbPirix1pfPqDLXsDZ4aaIrhZ7cez9jnyRQgci6DuuqSyZAdJKV6SdxpZ7Oiw==
dependencies:
"@chainsafe/is-ip" "^2.0.1"
"@chainsafe/netmask" "^2.0.0"
Expand All @@ -777,12 +777,7 @@
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.6.0.tgz#d4bfb516ad6e7b5111c216a5cc7075f4cf19e6c5"
integrity sha512-YUULf0Uk4/mAA89w+k3+yUYh6NrEvxZa5T6SY3wlMvE2chHkxFUUIDI8/XW1QSC357iA5pSnqt7XEhvFOqmDyQ==

"@noble/hashes@^1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.5.0.tgz#abadc5ca20332db2b1b2aa3e496e9af1213570b0"
integrity sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==

"@noble/hashes@~1.6.0":
"@noble/hashes@^1.5.0", "@noble/hashes@~1.6.0":
version "1.6.1"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.6.1.tgz#df6e5943edcea504bac61395926d6fd67869a0d5"
integrity sha512-pq5D8h10hHBjyqX+cfBm0i8JUXJ0UhczFc4r74zbuT9XgewFo2E3J1cOaGtdZynILNmQ685YWGzGE1Zv6io50w==
Expand Down Expand Up @@ -3402,16 +3397,7 @@ ssri@^9.0.0:
dependencies:
minipass "^3.1.1"

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -3436,14 +3422,7 @@ string_decoder@^1.1.1:
dependencies:
safe-buffer "~5.2.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -3516,16 +3495,11 @@ ts-log@^2.2.4:
resolved "https://registry.yarnpkg.com/ts-log/-/ts-log-2.2.7.tgz#4f4512144898b77c9984e91587076fcb8518688e"
integrity sha512-320x5Ggei84AxzlXp91QkIGSw5wgaLT6GeAH0KsqDmRZdVWW2OiSeVvElVoatk3f7nicwXlElXsoFkARiGE2yg==

tslib@^2.1.0:
tslib@^2.1.0, tslib@^2.6.2:
version "2.8.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==

tslib@^2.6.2:
version "2.8.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.0.tgz#d124c86c3c05a40a91e6fdea4021bd31d377971b"
integrity sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==

tuf-js@^1.1.7:
version "1.1.7"
resolved "https://registry.yarnpkg.com/tuf-js/-/tuf-js-1.1.7.tgz#21b7ae92a9373015be77dfe0cb282a80ec3bbe43"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/HydraMultiplayer/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function decodeGame(raw: Uint8Array): TGame {
referee_key_hash: referee_key_hash,
playerCount,
botCount,
players: player_payments.map(p => p.payment_key_hash),
players: player_payments.map((p) => p.payment_key_hash),
state: stateTag,
winner: winnerRaw,
cheater: cheaterRaw,
Expand Down
5 changes: 4 additions & 1 deletion src/utils/HydraMultiplayer/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class HydraMultiplayerServer extends HydraMultiplayer {
if (this.latestUTxO) {
return;
}
console.log("Selecting UTxO");
await this.hydra.populateUTxO();
const utxos = await this.hydra.getUtxos(this.address);
// TODO:
Expand All @@ -36,12 +37,14 @@ export class HydraMultiplayerServer extends HydraMultiplayer {
// The other is the 0 ada UTxO created during the new game transaction
// If we want to ensure we don't spend the initial state utxo,
// we need to add something identifying for the "admin UTxO" (perhaps a datum)
this.latestUTxO = utxos.find((u) => !u.datumHash && !u.assets.lovelace)!;
this.latestUTxO = utxos[0]!;
console.log("UTxO Selected");
}
protected override buildTx(datum: string): [UTxO, string] {
if (!this.latestUTxO) {
throw new Error("No latest UTxO");
}

const datumLength = datum.length / 2;
let datumLengthHex = datumLength.toString(16);
if (datumLengthHex.length % 2 !== 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/HydraMultiplayer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const PacketArray = PacketArraySchema as unknown as TPacketArray;

export const GameSchema = Data.Object({
referee_payment: Data.Object({
payment_key_hash: Data.Bytes()
payment_key_hash: Data.Bytes(),
}),
playerCountRaw: Data.Integer(),
botCountRaw: Data.Integer(),
Expand Down
Loading

0 comments on commit d4c8339

Please sign in to comment.