Skip to content
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

feat(3322-tigerbeetle): bump tb from 0.15.4 to 0.16.29 #3323

Merged
merged 5 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion infrastructure/helm/tigerbeetle/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ statefulset:
repository: ghcr.io/tigerbeetle/tigerbeetle
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "0.15.4"
tag: "0.16.29"

proxyImage:
repository: nginx
Expand Down
2 changes: 1 addition & 1 deletion localenv/tigerbeetle/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
tigerbeetle:
image: ghcr.io/tigerbeetle/tigerbeetle:0.15.4
image: ghcr.io/tigerbeetle/tigerbeetle:0.16.29
privileged: true
volumes:
- tigerbeetle-data:/var/lib/tigerbeetle
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"pg": "^8.11.3",
"pino": "^8.19.0",
"raw-body": "^2.5.2",
"tigerbeetle-node": "0.15.4",
"tigerbeetle-node": "0.16.29",
"token-introspection": "workspace:*",
"uuid": "^9.0.1"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/accounting/tigerbeetle/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ describe('TigerBeetle Accounting Service', (): void => {
} else {
await expect(
accountingService.getBalance(sourceAccount.asset.id)
).resolves.toEqual(BigInt(0))
).resolves.toEqual(0n)

await expect(
accountingService.getBalance(destinationAccount.asset.id)
Expand All @@ -481,7 +481,7 @@ describe('TigerBeetle Accounting Service', (): void => {

await expect(
accountingService.getBalance(destinationAccount.id)
).resolves.toEqual(BigInt(0))
).resolves.toEqual(0n)

if (post) {
await expect(trxOrError.post()).resolves.toBeUndefined()
Expand Down
20 changes: 19 additions & 1 deletion packages/backend/src/accounting/tigerbeetle/transfers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ type TransfersError = {
}

export type TransferUserData128 = string | number | bigint
/**
* See: https://docs.tigerbeetle.com/reference/transfer/#amount
* The maximum value for amount in TigerBeetle is (2^128 - 1), which is the maximum value that can fit in an unsigned 128-bit integer.
* However, JavaScript and TypeScript do not support native 128-bit integers. Instead, you can represent this number using BigInt, which supports arbitrarily large integers.
* In Zig, amount is: [u128]
*/
const TB_AMOUNT_MAX = BigInt(2n ** 128n - 1n)
const TB_AMOUNT_MIN = 0n

interface TransferOptions {
transferRef?: TransferUserData128
Expand Down Expand Up @@ -103,9 +111,15 @@ export async function createTransfers(
if (transfer.postId) {
tbTransfer.flags |= TransferFlags.post_pending_transfer
tbTransfer.pending_id = toTigerBeetleId(transfer.postId)
// We only support setting the posting transfer amount to match the pending transfer:
// https://docs.tigerbeetle.com/reference/transfer/#amount
tbTransfer.amount = TB_AMOUNT_MAX
} else if (transfer.voidId) {
tbTransfer.flags |= TransferFlags.void_pending_transfer
tbTransfer.pending_id = toTigerBeetleId(transfer.voidId)
// We only support setting the void transfer amount to match the pending transfer:
// https://docs.tigerbeetle.com/reference/transfer/#amount
tbTransfer.amount = TB_AMOUNT_MIN
}
}

Expand Down Expand Up @@ -178,7 +192,11 @@ export async function getAccountTransfers(
timestamp_min: 0n,
timestamp_max: 0n,
limit,
flags: AccountFilterFlags.credits | AccountFilterFlags.debits
flags: AccountFilterFlags.credits | AccountFilterFlags.debits,
code: 0, //disabled
user_data_32: 0, //disabled
user_data_64: 0n, //disabled
user_data_128: 0n //disabled
}
const tbAccountTransfers: TbTransfer[] =
await deps.tigerBeetle.getAccountTransfers(filter)
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/tests/tigerbeetle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function startTigerBeetleContainer(clusterId?: number): Promise<{
const tigerBeetleClusterId = clusterId || Config.tigerBeetleClusterId
const { name: tigerBeetleDir } = tmp.dirSync({ unsafeCleanup: true })
const tigerBeetleFile = `cluster_${tigerBeetleClusterId}_replica_0_test.tigerbeetle`
const tigerBeetleContainerVersion = 'ghcr.io/tigerbeetle/tigerbeetle:0.15.4'
const tigerBeetleContainerVersion = 'ghcr.io/tigerbeetle/tigerbeetle:0.16.29'

const tbContFormat = await new GenericContainer(tigerBeetleContainerVersion)
.withExposedPorts(TIGERBEETLE_PORT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ services:
- '3005:3005'

tigerbeetle:
image: ghcr.io/tigerbeetle/tigerbeetle:0.15.4
image: ghcr.io/tigerbeetle/tigerbeetle:0.16.29
privileged: true
volumes:
- tigerbeetle-data:/var/lib/tigerbeetle
Expand Down
Loading
Loading