Skip to content

Commit 4a99e03

Browse files
committed
fix(mu): isWallet add config to disable hb check
1 parent cadd705 commit 4a99e03

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed

servers/cu/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ to be retrieved from the dryrun cache.
151151
If a eval stream is more nonces behind than this limit, a 503 is returned.
152152
- `SU_ROUTER_URL`: the SU router url to default to when checking if target is a wallet
153153
- `HB_ROUTER_URL`: the HB router url to default to when checking if target is a wallet
154+
- `ENABLE_HB_WALLET_CHECK`: whether to enable HB wallet check when checking if target is a wallet
154155

155156
## Tests
156157

servers/cu/src/domain/model.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,11 @@ export const domainConfigSchema = z.object({
270270
/**
271271
* The HB router url to default to when checking if target is a wallet
272272
*/
273-
HB_ROUTER_URL: z.string()
273+
HB_ROUTER_URL: z.string(),
274+
/**
275+
* Whether to enable HB wallet check when checking if target is a wallet
276+
*/
277+
ENABLE_HB_WALLET_CHECK: z.boolean()
274278
})
275279

276280
export const bufferSchema = z.any().refine(buffer => {

servers/mu/src/config.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export const domainConfigSchema = z.object({
8484
IP_WALLET_RATE_LIMIT_INTERVAL: positiveIntSchema,
8585
STALE_CURSOR_RANGE: positiveIntSchema,
8686
SU_ROUTER_URL: z.string(),
87-
HB_ROUTER_URL: z.string()
87+
HB_ROUTER_URL: z.string(),
88+
ENABLE_HB_WALLET_CHECK: z.boolean()
8889
})
8990

9091
/**
@@ -145,7 +146,8 @@ const CONFIG_ENVS = {
145146
IP_WALLET_RATE_LIMIT_INTERVAL: process.env.IP_WALLET_RATE_LIMIT_INTERVAL || 1000 * 60 * 60,
146147
STALE_CURSOR_RANGE: process.env.STALE_CURSOR_RANGE || 1 * 24 * 60 * 60 * 1000,
147148
SU_ROUTER_URL: process.env.SU_ROUTER_URL || 'https://su-router.ao-testnet.xyz',
148-
HB_ROUTER_URL: process.env.HB_ROUTER_URL || 'https://forward.computer'
149+
HB_ROUTER_URL: process.env.HB_ROUTER_URL || 'https://forward.computer',
150+
ENABLE_HB_WALLET_CHECK: process.env.ENABLE_HB_WALLET_CHECK !== 'false'
149151
},
150152
production: {
151153
MODE,
@@ -183,7 +185,8 @@ const CONFIG_ENVS = {
183185
IP_WALLET_RATE_LIMIT_INTERVAL: process.env.IP_WALLET_RATE_LIMIT_INTERVAL || 1000 * 60 * 60,
184186
STALE_CURSOR_RANGE: process.env.STALE_CURSOR_RANGE || 1 * 24 * 60 * 60 * 1000,
185187
SU_ROUTER_URL: process.env.SU_ROUTER_URL || 'https://su-router.ao-testnet.xyz',
186-
HB_ROUTER_URL: process.env.HB_ROUTER_URL || 'https://forward.computer'
188+
HB_ROUTER_URL: process.env.HB_ROUTER_URL || 'https://forward.computer',
189+
ENABLE_HB_WALLET_CHECK: process.env.ENABLE_HB_WALLET_CHECK !== 'false'
187190
}
188191
}
189192

servers/mu/src/domain/clients/gateway.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function isWalletWith ({
88
GRAPHQL_URL,
99
SU_ROUTER_URL,
1010
HB_ROUTER_URL,
11+
ENABLE_HB_WALLET_CHECK,
1112
logger,
1213
setById,
1314
getById
@@ -55,15 +56,19 @@ function isWalletWith ({
5556
}
5657

5758
// Step 2: Check HyperBeam
58-
try {
59-
logger({ log: `Step 2: Checking HyperBeam for process ${id}`, logId })
60-
const hyperbeamResponse = await walletFetch(`${HB_ROUTER_URL}/${id}[email protected]/info/[email protected]`)
61-
if (hyperbeamResponse.status === 200) {
62-
logger({ log: `Found process in HyperBeam for ${id}`, logId })
63-
return setById(id, { isWallet: false }).then(() => false)
59+
if (ENABLE_HB_WALLET_CHECK) {
60+
try {
61+
logger({ log: `Step 2: Checking HyperBeam for process ${id}`, logId })
62+
const hyperbeamResponse = await walletFetch(`${HB_ROUTER_URL}/${id}[email protected]/info/[email protected]`)
63+
if (hyperbeamResponse.status === 200) {
64+
logger({ log: `Found process in HyperBeam for ${id}`, logId })
65+
return setById(id, { isWallet: false }).then(() => false)
66+
}
67+
} catch (err) {
68+
logger({ log: `Step 2: HyperBeam check failed for ${id}: ${err.message}`, logId })
6469
}
65-
} catch (err) {
66-
logger({ log: `Step 2: HyperBeam check failed for ${id}: ${err.message}`, logId })
70+
} else {
71+
logger({ log: `Step 2: Skipping HyperBeam check for ${id}`, logId })
6772
}
6873

6974
// Step 3: Check Arweave

servers/mu/src/domain/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export const createApis = async (ctx) => {
9696
const STALE_CURSOR_RANGE = ctx.STALE_CURSOR_RANGE
9797
const SU_ROUTER_URL = ctx.SU_ROUTER_URL
9898
const HB_ROUTER_URL = ctx.HB_ROUTER_URL
99+
const ENABLE_HB_WALLET_CHECK = ctx.ENABLE_HB_WALLET_CHECK
99100

100101
const logger = ctx.logger
101102
const fetch = ctx.fetch
@@ -233,7 +234,7 @@ export const createApis = async (ctx) => {
233234
fetchHyperBeamResult: cuClient.fetchHyperBeamResultWith({ fetch, HB_URL, histogram, logger: sendDataItemLogger }),
234235
fetchSchedulerProcess: schedulerClient.fetchSchedulerProcessWith({ getByProcess, setByProcess, fetch, histogram, logger: sendDataItemLogger }),
235236
crank,
236-
isWallet: gatewayClient.isWalletWith({ fetch, histogram, ARWEAVE_URL, GRAPHQL_URL, SU_ROUTER_URL, HB_ROUTER_URL, logger: sendDataItemLogger }),
237+
isWallet: gatewayClient.isWalletWith({ fetch, histogram, ARWEAVE_URL, GRAPHQL_URL, SU_ROUTER_URL, HB_ROUTER_URL, ENABLE_HB_WALLET_CHECK, logger: sendDataItemLogger }),
237238
isHyperBeamProcess: gatewayClient.isHyperBeamProcessWith({ fetch, GRAPHQL_URL, logger: sendDataItemLogger, getIsHyperBeamProcess, setIsHyperBeamProcess }),
238239
logger: sendDataItemLogger,
239240
writeDataItemArweave: uploaderClient.uploadDataItemWith({ UPLOADER_URL, logger: sendDataItemLogger, fetch, histogram }),
@@ -388,6 +389,7 @@ export const createResultApis = async (ctx) => {
388389
const RELAY_MAP = ctx.RELAY_MAP
389390
const SU_ROUTER_URL = ctx.SU_ROUTER_URL
390391
const HB_ROUTER_URL = ctx.HB_ROUTER_URL
392+
const ENABLE_HB_WALLET_CHECK = ctx.ENABLE_HB_WALLET_CHECK
391393

392394
const logger = ctx.logger
393395
const fetch = ctx.fetch
@@ -427,7 +429,7 @@ export const createResultApis = async (ctx) => {
427429
buildAndSign: signerClient.buildAndSignWith({ MU_WALLET, logger: processMsgLogger }),
428430
fetchResult: cuClient.resultWith({ fetch: fetchWithCache, histogram, CU_URL, logger: processMsgLogger }),
429431
fetchHyperBeamResult: cuClient.fetchHyperBeamResultWith({ fetch, HB_URL, histogram, logger: processMsgLogger }),
430-
isWallet: gatewayClient.isWalletWith({ fetch, histogram, ARWEAVE_URL, GRAPHQL_URL, SU_ROUTER_URL, HB_ROUTER_URL, logger: processMsgLogger, setById, getById }),
432+
isWallet: gatewayClient.isWalletWith({ fetch, histogram, ARWEAVE_URL, GRAPHQL_URL, SU_ROUTER_URL, HB_ROUTER_URL, ENABLE_HB_WALLET_CHECK, logger: processMsgLogger, setById, getById }),
431433
writeDataItemArweave: uploaderClient.uploadDataItemWith({ UPLOADER_URL, logger: processMsgLogger, fetch, histogram }),
432434
isHyperBeamProcess: gatewayClient.isHyperBeamProcessWith({ fetch, GRAPHQL_URL, logger: processMsgLogger, getIsHyperBeamProcess, setIsHyperBeamProcess }),
433435
RELAY_MAP,

0 commit comments

Comments
 (0)