tigerbeetle-node 0.5.2 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +97 -78
  2. package/dist/benchmark.js +96 -94
  3. package/dist/benchmark.js.map +1 -1
  4. package/dist/index.d.ts +82 -82
  5. package/dist/index.js +74 -93
  6. package/dist/index.js.map +1 -1
  7. package/dist/test.js +134 -111
  8. package/dist/test.js.map +1 -1
  9. package/package.json +3 -2
  10. package/scripts/download_node_headers.sh +3 -1
  11. package/src/benchmark.ts +114 -118
  12. package/src/index.ts +102 -111
  13. package/src/node.zig +55 -63
  14. package/src/test.ts +146 -125
  15. package/src/tigerbeetle/scripts/benchmark.bat +46 -0
  16. package/src/tigerbeetle/scripts/benchmark.sh +5 -0
  17. package/src/tigerbeetle/scripts/install_zig.bat +109 -109
  18. package/src/tigerbeetle/scripts/install_zig.sh +8 -4
  19. package/src/tigerbeetle/scripts/vopr.bat +47 -47
  20. package/src/tigerbeetle/scripts/vopr.sh +2 -2
  21. package/src/tigerbeetle/src/benchmark.zig +65 -102
  22. package/src/tigerbeetle/src/cli.zig +39 -18
  23. package/src/tigerbeetle/src/config.zig +44 -25
  24. package/src/tigerbeetle/src/demo.zig +2 -15
  25. package/src/tigerbeetle/src/demo_01_create_accounts.zig +10 -10
  26. package/src/tigerbeetle/src/demo_03_create_transfers.zig +5 -3
  27. package/src/tigerbeetle/src/{demo_04_create_transfers_two_phase_commit.zig → demo_04_create_pending_transfers.zig} +18 -12
  28. package/src/tigerbeetle/src/demo_05_post_pending_transfers.zig +37 -0
  29. package/src/tigerbeetle/src/demo_06_void_pending_transfers.zig +24 -0
  30. package/src/tigerbeetle/src/demo_07_lookup_transfers.zig +1 -1
  31. package/src/tigerbeetle/src/io/benchmark.zig +24 -49
  32. package/src/tigerbeetle/src/io/darwin.zig +175 -44
  33. package/src/tigerbeetle/src/io/linux.zig +177 -72
  34. package/src/tigerbeetle/src/io/test.zig +61 -39
  35. package/src/tigerbeetle/src/io/windows.zig +1161 -0
  36. package/src/tigerbeetle/src/io.zig +2 -0
  37. package/src/tigerbeetle/src/main.zig +31 -10
  38. package/src/tigerbeetle/src/message_bus.zig +49 -61
  39. package/src/tigerbeetle/src/message_pool.zig +66 -57
  40. package/src/tigerbeetle/src/ring_buffer.zig +55 -3
  41. package/src/tigerbeetle/src/simulator.zig +108 -12
  42. package/src/tigerbeetle/src/state_machine.zig +1813 -816
  43. package/src/tigerbeetle/src/storage.zig +0 -230
  44. package/src/tigerbeetle/src/test/cluster.zig +168 -38
  45. package/src/tigerbeetle/src/test/message_bus.zig +4 -3
  46. package/src/tigerbeetle/src/test/network.zig +13 -16
  47. package/src/tigerbeetle/src/test/packet_simulator.zig +14 -1
  48. package/src/tigerbeetle/src/test/state_checker.zig +6 -3
  49. package/src/tigerbeetle/src/test/state_machine.zig +8 -7
  50. package/src/tigerbeetle/src/test/storage.zig +99 -40
  51. package/src/tigerbeetle/src/tigerbeetle.zig +108 -101
  52. package/src/tigerbeetle/src/time.zig +58 -11
  53. package/src/tigerbeetle/src/vsr/client.zig +18 -32
  54. package/src/tigerbeetle/src/vsr/clock.zig +1 -1
  55. package/src/tigerbeetle/src/vsr/journal.zig +1388 -464
  56. package/src/tigerbeetle/src/vsr/replica.zig +1340 -576
  57. package/src/tigerbeetle/src/vsr.zig +452 -40
  58. package/src/translate.zig +10 -0
  59. package/src/tigerbeetle/src/demo_05_accept_transfers.zig +0 -23
  60. package/src/tigerbeetle/src/demo_06_reject_transfers.zig +0 -17
  61. package/src/tigerbeetle/src/format_test.zig +0 -69
@@ -1,109 +1,109 @@
1
- @echo off
2
-
3
- set ZIG_RELEASE_DEFAULT=0.9.0
4
-
5
- :: Determine the Zig build:
6
- if "%~1"=="" (
7
- set ZIG_RELEASE=%ZIG_RELEASE_DEFAULT%
8
- ) else if "%~1"=="latest" (
9
- set ZIG_RELEASE=builds
10
- ) else (
11
- set ZIG_RELEASE=%~1
12
- )
13
-
14
- :: Checks format of release version.
15
- echo.%ZIG_RELEASE% | findstr /b /r /c:"builds" /c:"^[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*">nul || (echo.Unexpected release format. && exit 1)
16
-
17
- set ZIG_OS=windows
18
- set ZIG_ARCH=x86_64
19
-
20
- set ZIG_TARGET=zig-%ZIG_OS%-%ZIG_ARCH%
21
-
22
- :: Determine the build, split the JSON line on whitespace and extract the 2nd field:
23
- for /f "tokens=2" %%a in ('curl --silent https://ziglang.org/download/index.json ^| findstr %ZIG_TARGET% ^| findstr %ZIG_RELEASE%' ) do (
24
- set ZIG_URL=%%a
25
- )
26
-
27
- :: Then remove quotes and commas:
28
- for /f %%b in ("%ZIG_URL:,=%") do (
29
- set ZIG_URL=%%~b
30
- )
31
-
32
- :: Checks the ZIG_URL variable follows the expected format.
33
- echo.%ZIG_URL% | findstr /b /r /c:"https://ziglang.org/builds/" /c:"https://ziglang.org/download/%ZIG_RELEASE%">nul || (echo.Unexpected release URL format. && exit 1)
34
-
35
- if "%ZIG_RELEASE%"=="builds" (
36
- echo Installing Zig latest build...
37
- ) else (
38
- echo Installing Zig %ZIG_RELEASE% release build...
39
- )
40
-
41
- :: Using variable modifiers to determine the directory and filename from the URL:
42
- :: %~ni Expands %i to a file name only and %~xi Expands %i to a file name extension only.
43
- for /f %%i in ("%ZIG_URL%") do (
44
- set ZIG_DIRECTORY=%%~ni
45
- set ZIG_TARBALL=%%~nxi
46
- )
47
-
48
- :: Checks the ZIG_DIRECTORY variable follows the expected format.
49
- echo.%ZIG_DIRECTORY% | findstr /b /r /c:"zig-win64-" /c:"zig-windows-x86_64-">nul || (echo.Unexpected zip directory name format. && exit 1)
50
-
51
- :: Making sure we download to the same output document, without wget adding "-1" etc. if the file was previously partially downloaded:
52
- if exist %ZIG_TARBALL% (
53
- del /q %ZIG_TARBALL%
54
- if exist %ZIG_TARBALL% (
55
- echo Failed to delete %ZIG_TARBALL%.
56
- exit 1
57
- )
58
- )
59
-
60
- echo Downloading %ZIG_URL%...
61
- curl --silent --progress-bar --output %ZIG_TARBALL% %ZIG_URL%
62
- if not exist %ZIG_TARBALL% (
63
- echo Failed to download Zig zip file.
64
- exit 1
65
- )
66
-
67
- :: Replace any existing Zig installation so that we can install or upgrade:
68
- echo Removing any existing 'zig' and %ZIG_DIRECTORY% folders before extracting.
69
- if exist zig\ (
70
- rd /s /q zig\
71
- :: Ensure the directory has been deleted.
72
- if exist zig\ (
73
- echo The ‘zig’ directory could not be deleted.
74
- exit 1
75
- )
76
- )
77
-
78
- if exist %ZIG_DIRECTORY%\ (
79
- rd /s /q %ZIG_DIRECTORY%
80
- :: Ensure the directory has been deleted.
81
- if exist %ZIG_DIRECTORY% (
82
- echo The %ZIG_DIRECTORY% directory could not be deleted.
83
- exit 1
84
- )
85
- )
86
-
87
- :: Extract and then remove the downloaded tarball:
88
- echo Extracting %ZIG_TARBALL%...
89
- powershell -Command "Expand-Archive %ZIG_TARBALL% -DestinationPath ."
90
- if not exist %ZIG_TARBALL% (
91
- echo Failed to extract zip file.
92
- exit 1
93
- )
94
-
95
- echo Installing %ZIG_DIRECTORY% to 'zig' in current working directory...
96
- ren %ZIG_DIRECTORY% zig
97
- if exist %ZIG_DIRECTORY% (
98
- echo Failed to rename %ZIG_DIRECTORY% to zig.
99
- exit 1
100
- )
101
-
102
- :: Removes the zip file
103
- del /q %ZIG_TARBALL%
104
- if exist %ZIG_TARBALL% (
105
- echo Failed to delete %ZIG_TARBALL% file.
106
- exit 1
107
- )
108
-
109
- echo "Congratulations, you have successfully installed Zig version %ZIG_RELEASE%. Enjoy!"
1
+ @echo off
2
+
3
+ set ZIG_RELEASE_DEFAULT=0.9.1
4
+
5
+ :: Determine the Zig build:
6
+ if "%~1"=="" (
7
+ set ZIG_RELEASE=%ZIG_RELEASE_DEFAULT%
8
+ ) else if "%~1"=="latest" (
9
+ set ZIG_RELEASE=builds
10
+ ) else (
11
+ set ZIG_RELEASE=%~1
12
+ )
13
+
14
+ :: Checks format of release version.
15
+ echo.%ZIG_RELEASE% | findstr /b /r /c:"builds" /c:"^[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*">nul || (echo.Unexpected release format. && exit 1)
16
+
17
+ set ZIG_OS=windows
18
+ set ZIG_ARCH=x86_64
19
+
20
+ set ZIG_TARGET=zig-%ZIG_OS%-%ZIG_ARCH%
21
+
22
+ :: Determine the build, split the JSON line on whitespace and extract the 2nd field:
23
+ for /f "tokens=2" %%a in ('curl --silent https://ziglang.org/download/index.json ^| findstr %ZIG_TARGET% ^| findstr %ZIG_RELEASE%' ) do (
24
+ set ZIG_URL=%%a
25
+ )
26
+
27
+ :: Then remove quotes and commas:
28
+ for /f %%b in ("%ZIG_URL:,=%") do (
29
+ set ZIG_URL=%%~b
30
+ )
31
+
32
+ :: Checks the ZIG_URL variable follows the expected format.
33
+ echo.%ZIG_URL% | findstr /b /r /c:"https://ziglang.org/builds/" /c:"https://ziglang.org/download/%ZIG_RELEASE%">nul || (echo.Unexpected release URL format. && exit 1)
34
+
35
+ if "%ZIG_RELEASE%"=="builds" (
36
+ echo Installing Zig latest build...
37
+ ) else (
38
+ echo Installing Zig %ZIG_RELEASE% release build...
39
+ )
40
+
41
+ :: Using variable modifiers to determine the directory and filename from the URL:
42
+ :: %%~ni Expands %%i to a file name only and %%~xi Expands %%i to a file name extension only.
43
+ for /f %%i in ("%ZIG_URL%") do (
44
+ set ZIG_DIRECTORY=%%~ni
45
+ set ZIG_TARBALL=%%~nxi
46
+ )
47
+
48
+ :: Checks the ZIG_DIRECTORY variable follows the expected format.
49
+ echo.%ZIG_DIRECTORY% | findstr /b /r /c:"zig-win64-" /c:"zig-windows-x86_64-">nul || (echo.Unexpected zip directory name format. && exit 1)
50
+
51
+ :: Making sure we download to the same output document, without wget adding "-1" etc. if the file was previously partially downloaded:
52
+ if exist %ZIG_TARBALL% (
53
+ del /q %ZIG_TARBALL%
54
+ if exist %ZIG_TARBALL% (
55
+ echo Failed to delete %ZIG_TARBALL%.
56
+ exit 1
57
+ )
58
+ )
59
+
60
+ echo Downloading %ZIG_URL%...
61
+ curl --silent --progress-bar --output %ZIG_TARBALL% %ZIG_URL%
62
+ if not exist %ZIG_TARBALL% (
63
+ echo Failed to download Zig zip file.
64
+ exit 1
65
+ )
66
+
67
+ :: Replace any existing Zig installation so that we can install or upgrade:
68
+ echo Removing any existing 'zig' and %ZIG_DIRECTORY% folders before extracting.
69
+ if exist zig\ (
70
+ rd /s /q zig\
71
+ :: Ensure the directory has been deleted.
72
+ if exist zig\ (
73
+ echo The ‘zig’ directory could not be deleted.
74
+ exit 1
75
+ )
76
+ )
77
+
78
+ if exist %ZIG_DIRECTORY%\ (
79
+ rd /s /q %ZIG_DIRECTORY%
80
+ :: Ensure the directory has been deleted.
81
+ if exist %ZIG_DIRECTORY% (
82
+ echo The %ZIG_DIRECTORY% directory could not be deleted.
83
+ exit 1
84
+ )
85
+ )
86
+
87
+ :: Extract and then remove the downloaded tarball:
88
+ echo Extracting %ZIG_TARBALL%...
89
+ powershell -Command "Expand-Archive %ZIG_TARBALL% -DestinationPath ."
90
+ if not exist %ZIG_TARBALL% (
91
+ echo Failed to extract zip file.
92
+ exit 1
93
+ )
94
+
95
+ echo Installing %ZIG_DIRECTORY% to 'zig' in current working directory...
96
+ ren %ZIG_DIRECTORY% zig
97
+ if exist %ZIG_DIRECTORY% (
98
+ echo Failed to rename %ZIG_DIRECTORY% to zig.
99
+ exit 1
100
+ )
101
+
102
+ :: Removes the zip file
103
+ del /q %ZIG_TARBALL%
104
+ if exist %ZIG_TARBALL% (
105
+ echo Failed to delete %ZIG_TARBALL% file.
106
+ exit 1
107
+ )
108
+
109
+ echo "Congratulations, you have successfully installed Zig version %ZIG_RELEASE%. Enjoy!"
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
  set -e
3
3
 
4
- ZIG_RELEASE_DEFAULT="0.9.0"
4
+ ZIG_RELEASE_DEFAULT="0.9.1"
5
5
 
6
6
  # Default to the release build, or allow the latest dev build, or an explicit release version:
7
7
  if [ -z "$1" ]; then
@@ -40,9 +40,11 @@ ZIG_TARGET="zig-$ZIG_OS-$ZIG_ARCH"
40
40
 
41
41
  # Determine the build, split the JSON line on whitespace and extract the 2nd field, then remove quotes and commas:
42
42
  if command -v wget &> /dev/null; then
43
- ZIG_URL=`wget --quiet -O - https://ziglang.org/download/index.json | grep "$ZIG_TARGET" | grep "$ZIG_RELEASE" | awk '{print $2}' | sed 's/[",]//g'`
43
+ # -4 forces `wget` to connect to ipv4 addresses, as ipv6 fails to resolve on certain distros.
44
+ # Only A records (for ipv4) are used in DNS:
45
+ ZIG_URL=`wget -4 --quiet -O - https://ziglang.org/download/index.json | grep -F "$ZIG_TARGET" | grep -F "$ZIG_RELEASE" | awk '{print $2}' | sed 's/[",]//g'`
44
46
  else
45
- ZIG_URL=`curl --silent https://ziglang.org/download/index.json | grep "$ZIG_TARGET" | grep "$ZIG_RELEASE" | awk '{print $2}' | sed 's/[",]//g'`
47
+ ZIG_URL=`curl --silent https://ziglang.org/download/index.json | grep -F "$ZIG_TARGET" | grep -F "$ZIG_RELEASE" | awk '{print $2}' | sed 's/[",]//g'`
46
48
  fi
47
49
 
48
50
  # Ensure that the release is actually hosted on the ziglang.org website:
@@ -58,7 +60,9 @@ ZIG_DIRECTORY=`basename "$ZIG_TARBALL" .tar.xz`
58
60
  # Download, making sure we download to the same output document, without wget adding "-1" etc. if the file was previously partially downloaded:
59
61
  echo "Downloading $ZIG_URL..."
60
62
  if command -v wget &> /dev/null; then
61
- wget --quiet --show-progress --output-document=$ZIG_TARBALL $ZIG_URL
63
+ # -4 forces `wget` to connect to ipv4 addresses, as ipv6 fails to resolve on certain distros.
64
+ # Only A records (for ipv4) are used in DNS:
65
+ wget -4 --quiet --show-progress --output-document=$ZIG_TARBALL $ZIG_URL
62
66
  else
63
67
  curl --silent --progress-bar --output $ZIG_TARBALL $ZIG_URL
64
68
  fi
@@ -1,48 +1,48 @@
1
- :: Installs Zig if needed and runs the VOPR
2
- @echo off
3
-
4
- :: Install Zig if a zig folder does not already exist:
5
- if not exist zig\ (
6
- :: Installs the latest version of Zig
7
- call scripts\install_zig.bat
8
- :: Checks that the Zig folder now exists
9
- if not exist zig\ (
10
- echo The Zig installation failed.
11
- exit 1
12
- )
13
- echo Running the TigerBeetle VOPR for the first time...
14
- echo Visit https://www.tigerbeetle.com
15
- )
16
-
17
- :: If a seed is provided as an argument then replay the seed, otherwise test 1,000 seeds:
18
- if not "%~1"=="" (
19
- :: Build in fast ReleaseSafe mode if required, useful where you don't need debug logging:
20
- if "%~2"=="-OReleaseSafe" (
21
- echo Replaying seed %~1 in ReleaseSafe mode...
22
- call zig\zig run src\simulator.zig -OReleaseSafe -- %~1
23
- if not %ERRORLEVEL%==0 (
24
- echo Cannot replay the %~1 seed using the VOPR.
25
- exit 1
26
- )
27
- ) else (
28
- echo Replaying seed %~1 in Debug mode with full debug logging enabled...
29
- call zig\zig run src\simulator.zig -ODebug -- %~1
30
- if not %ERRORLEVEL%==0 (
31
- echo Cannot run the VOPR.
32
- exit 1
33
- )
34
- )
35
- ) else (
36
- call zig\zig build-exe src\simulator.zig -OReleaseSafe
37
- if not %ERRORLEVEL%==0 (
38
- echo Cannot run the VOPR.
39
- exit 1
40
- )
41
- for %%i in (1,1,1000) do (
42
- call simulator
43
- if not %ERRORLEVEL%==0 (
44
- echo Cannot run a seed using the VOPR.
45
- exit 1
46
- )
47
- )
1
+ :: Installs Zig if needed and runs the VOPR
2
+ @echo off
3
+
4
+ :: Install Zig if a zig folder does not already exist:
5
+ if not exist zig\ (
6
+ :: Installs the latest version of Zig
7
+ call scripts\install_zig.bat
8
+ :: Checks that the Zig folder now exists
9
+ if not exist zig\ (
10
+ echo The Zig installation failed.
11
+ exit 1
12
+ )
13
+ echo Running the TigerBeetle VOPR for the first time...
14
+ echo Visit https://www.tigerbeetle.com
15
+ )
16
+
17
+ :: If a seed is provided as an argument then replay the seed, otherwise test 1,000 seeds:
18
+ if not "%~1"=="" (
19
+ :: Build in fast ReleaseSafe mode if required, useful where you don't need debug logging:
20
+ if "%~2"=="-OReleaseSafe" (
21
+ echo Replaying seed %~1 in ReleaseSafe mode...
22
+ call zig\zig run src\simulator.zig -OReleaseSafe -- %~1
23
+ if not %ERRORLEVEL%==0 (
24
+ echo Cannot replay the %~1 seed using the VOPR.
25
+ exit 1
26
+ )
27
+ ) else (
28
+ echo Replaying seed %~1 in Debug mode with full debug logging enabled...
29
+ call zig\zig run src\simulator.zig -ODebug -- %~1
30
+ if not %ERRORLEVEL%==0 (
31
+ echo Cannot run the VOPR.
32
+ exit 1
33
+ )
34
+ )
35
+ ) else (
36
+ call zig\zig build-exe src\simulator.zig -OReleaseSafe
37
+ if not %ERRORLEVEL%==0 (
38
+ echo Cannot run the VOPR.
39
+ exit 1
40
+ )
41
+ for %%i in (1,1,1000) do (
42
+ call simulator
43
+ if not %ERRORLEVEL%==0 (
44
+ echo Cannot run a seed using the VOPR.
45
+ exit 1
46
+ )
47
+ )
48
48
  )
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
  set -e
3
3
 
4
- # Install Zig 0.8.0 if it does not already exist:
4
+ # Install Zig if it does not already exist:
5
5
  if [ ! -d "zig" ]; then
6
- scripts/install_zig.sh 0.8.0
6
+ scripts/install_zig.sh
7
7
  echo ""
8
8
  echo "Running the TigerBeetle VOPR for the first time..."
9
9
  echo "Visit https://www.tigerbeetle.com"