Skip to content

Commit 34b3998

Browse files
committed
Merge remote-tracking branch 'origin/main' into asiegel/rpc-resurrect
2 parents dc105d7 + 992ba39 commit 34b3998

File tree

100 files changed

+2409
-1957
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2409
-1957
lines changed

book/api/cli.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,20 @@ $ fdctl shred-version
152152
9065
153153
```
154154

155+
## `metrics`
156+
Prints the current validator metrics to stdout. Metrics can typically
157+
be accessed via. HTTP when the `metric` tile is enabled, but the
158+
command can be used even if the metrics server is not enabled, or the
159+
validator has crashed.
160+
161+
```sh [bash]
162+
$ fdctl metrics --config ~/config.toml
163+
# HELP tile_pid The process ID of the tile.
164+
# TYPE tile_pid gauge
165+
tile_pid{kind="netlnk",kind_id="0"} 627750
166+
tile_pid{kind="net",kind_id="0"} 627759
167+
```
168+
155169
## `set-identity`
156170
Changes the identity key of a running validator. The `<keypair>`
157171
argument is required and must be the path to an Agave style

contrib/test/run_test_vectors.sh

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22

3+
# FIXME This whole file should just really be a firedancer-dev
4+
# invocation with parallelism natively implemented in C.
5+
36
set -ex
47

58
DIR="$( dirname -- "${BASH_SOURCE[0]}"; )"; # Get the directory name
@@ -8,6 +11,8 @@ cd $DIR/../..
811

912
OBJDIR=${OBJDIR:-build/native/gcc}
1013
NUM_PROCESSES=${NUM_PROCESSES:-12}
14+
PAGE_SZ=gigantic
15+
PAGE_CNT=$(( 6 * $NUM_PROCESSES ))
1116

1217
if [ "$LOG_PATH" == "" ]; then
1318
LOG_PATH="`mktemp -d`"
@@ -30,27 +35,39 @@ else
3035
cd dump/test-vectors
3136
fi
3237

33-
git fetch -q --depth=1 origin $GIT_REF
34-
git checkout -q $GIT_REF
38+
if ! git checkout -q $GIT_REF; then
39+
git fetch -q --depth=1 origin $GIT_REF
40+
git checkout -q FETCH_HEAD
41+
fi
3542
cd ../..
3643

37-
LOG=$LOG_PATH/test_exec_block
38-
find dump/test-vectors/block/fixtures/* -type f -name '*.fix' | xargs -P $NUM_PROCESSES -n 1000 ./$OBJDIR/unit-test/test_exec_sol_compat --log-path $LOG --wksp-page-sz 1073741824
44+
WKSP=run-test-vectors
45+
# If workspace already exists, reset it (and hope that it has the correct size)
46+
if ./$OBJDIR/bin/fd_wksp_ctl query $WKSP --log-path '' >/dev/null 2>/dev/null; then
47+
./$OBJDIR/bin/fd_wksp_ctl reset $WKSP --log-path ''
48+
else
49+
./$OBJDIR/bin/fd_wksp_ctl new run-test-vectors $PAGE_CNT $PAGE_SZ 0 0644 --log-path ''
50+
fi
51+
52+
SOL_COMPAT=( "$OBJDIR/unit-test/test_sol_compat" "--wksp" "$WKSP" --tile-cpus "f,0-$(( $NUM_PROCESSES - 1 ))" )
53+
54+
export FD_LOG_PATH=$LOG_PATH/test_exec_block
55+
${SOL_COMPAT[@]} dump/test-vectors/block/fixtures
3956

40-
LOG=$LOG_PATH/test_exec_syscall
41-
find dump/test-vectors/syscall/fixtures/* -type f -name '*.fix' | xargs -P $NUM_PROCESSES -n 1000 ./$OBJDIR/unit-test/test_exec_sol_compat --log-path $LOG --wksp-page-sz 1073741824
57+
export FD_LOG_PATH=$LOG_PATH/test_exec_syscall
58+
${SOL_COMPAT[@]} dump/test-vectors/syscall/fixtures
4259

43-
LOG=$LOG_PATH/test_exec_interp
44-
find dump/test-vectors/vm_interp/fixtures/* -type f -name '*.fix' | xargs -P $NUM_PROCESSES -n 1000 ./$OBJDIR/unit-test/test_exec_sol_compat --log-path $LOG --wksp-page-sz 1073741824
60+
export FD_LOG_PATH=$LOG_PATH/test_exec_interp
61+
${SOL_COMPAT[@]} dump/test-vectors/vm_interp/fixtures
4562

46-
LOG=$LOG_PATH/test_exec_txn
47-
find dump/test-vectors/txn/fixtures/* -type f -name '*.fix' | xargs -P $NUM_PROCESSES ./$OBJDIR/unit-test/test_exec_sol_compat --log-path $LOG --wksp-page-sz 1073741824
63+
export FD_LOG_PATH=$LOG_PATH/test_exec_txn
64+
${SOL_COMPAT[@]} dump/test-vectors/txn/fixtures
4865

4966
zstd -df dump/test-vectors/elf_loader/fixtures/*.zst
50-
LOG=$LOG_PATH/test_elf_loader
51-
find dump/test-vectors/elf_loader/fixtures/* -type f -name '*.fix' | xargs -P $NUM_PROCESSES -n 1000 ./$OBJDIR/unit-test/test_exec_sol_compat --log-path $LOG --wksp-page-sz 1073741824
67+
export FD_LOG_PATH=$LOG_PATH/test_elf_loader
68+
${SOL_COMPAT[@]} dump/test-vectors/elf_loader/fixtures
5269

53-
LOG=$LOG_PATH/test_exec_instr
54-
find dump/test-vectors/instr/fixtures/* -type f -name '*.fix' | xargs -P $NUM_PROCESSES -n 1000 ./$OBJDIR/unit-test/test_exec_sol_compat --log-path $LOG --wksp-page-sz 1073741824
70+
export FD_LOG_PATH=$LOG_PATH/test_exec_instr
71+
${SOL_COMPAT[@]} dump/test-vectors/instr/fixtures
5572

5673
echo Test vectors success
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
36b61931456ceaaa8f755fe070e5d1c70a835a2d
1+
ac1cdc5030baa26590b2d7ef99845c2e70c49d51

src/app/fdctl/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ extern action_t fd_action_set_identity;
9696
extern action_t fd_action_get_identity;
9797
extern action_t fd_action_help;
9898
extern action_t fd_action_version;
99+
extern action_t fd_action_metrics;
99100

100101
action_t * ACTIONS[] = {
101102
&fd_action_run,
@@ -111,6 +112,7 @@ action_t * ACTIONS[] = {
111112
&fd_action_get_identity,
112113
&fd_action_help,
113114
&fd_action_version,
115+
&fd_action_metrics,
114116
NULL,
115117
};
116118

src/app/fddev/main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ extern action_t fd_action_dev1;
125125
extern action_t fd_action_dump;
126126
extern action_t fd_action_flame;
127127
extern action_t fd_action_help;
128+
extern action_t fd_action_metrics;
128129
extern action_t fd_action_load;
129130
extern action_t fd_action_pktgen;
130131
extern action_t fd_action_quic_trace;
@@ -145,6 +146,7 @@ action_t * ACTIONS[] = {
145146
&fd_action_set_identity,
146147
&fd_action_get_identity,
147148
&fd_action_help,
149+
&fd_action_metrics,
148150
&fd_action_version,
149151
&fd_action_bench,
150152
&fd_action_bundle_client,

src/app/firedancer-dev/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ extern action_t fd_action_dev;
170170
extern action_t fd_action_dump;
171171
extern action_t fd_action_flame;
172172
extern action_t fd_action_help;
173+
extern action_t fd_action_metrics;
173174
extern action_t fd_action_load;
174175
extern action_t fd_action_pktgen;
175176
extern action_t fd_action_quic_trace;
@@ -195,6 +196,7 @@ action_t * ACTIONS[] = {
195196
&fd_action_netconf,
196197
&fd_action_set_identity,
197198
&fd_action_help,
199+
&fd_action_metrics,
198200
&fd_action_version,
199201
&fd_action_bench,
200202
&fd_action_bundle_client,

src/app/firedancer/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ extern action_t fd_action_mem;
125125
extern action_t fd_action_netconf;
126126
extern action_t fd_action_set_identity;
127127
extern action_t fd_action_help;
128+
extern action_t fd_action_metrics;
128129
extern action_t fd_action_version;
129130
extern action_t fd_action_shred_version;
130131

@@ -139,6 +140,7 @@ action_t * ACTIONS[] = {
139140
&fd_action_netconf,
140141
&fd_action_set_identity,
141142
&fd_action_help,
143+
&fd_action_metrics,
142144
&fd_action_version,
143145
&fd_action_shred_version,
144146
NULL,

src/app/shared/Local.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ $(call add-objs,boot/fd_boot,fdctl_shared)
1515
$(call add-objs,commands/help,fdctl_shared)
1616
$(call add-objs,commands/keys,fdctl_shared)
1717
$(call add-objs,commands/mem,fdctl_shared)
18+
$(call add-objs,commands/metrics,fdctl_shared)
1819
$(call add-objs,commands/netconf,fdctl_shared)
1920
$(call add-objs,commands/ready,fdctl_shared)
2021
$(call add-objs,commands/set_identity,fdctl_shared)

src/app/shared/commands/metrics.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include "../fd_config.h"
2+
#include "../fd_action.h"
3+
4+
#include "../../../disco/metrics/fd_prometheus.h"
5+
#include "../../../waltz/http/fd_http_server_private.h"
6+
7+
#include <unistd.h>
8+
#include <errno.h>
9+
#include <stdlib.h>
10+
11+
extern action_t * ACTIONS[];
12+
13+
void
14+
metrics_cmd_fn( args_t * args FD_PARAM_UNUSED,
15+
config_t * config ) {
16+
fd_http_server_params_t params = {
17+
.max_connection_cnt = 0UL,
18+
.max_ws_connection_cnt = 0UL,
19+
.max_request_len = 0UL,
20+
.max_ws_recv_frame_len = 0UL,
21+
.max_ws_send_frame_cnt = 0UL,
22+
.outgoing_buffer_sz = (1UL<<28UL), /* 256MiB */
23+
};
24+
25+
fd_topo_join_workspaces( &config->topo, FD_SHMEM_JOIN_MODE_READ_ONLY );
26+
fd_topo_fill( &config->topo );
27+
28+
void * mem = aligned_alloc( fd_http_server_align(), fd_http_server_footprint( params ) );
29+
FD_TEST( mem );
30+
fd_http_server_t * http = fd_http_server_new( mem, params, (fd_http_server_callbacks_t){0}, NULL );
31+
fd_prometheus_render_all( &config->topo, http );
32+
33+
ulong bytes_written = 0UL;
34+
while( bytes_written<http->oring_sz ) {
35+
long written = write( STDOUT_FILENO, http->oring+bytes_written, http->oring_sz-bytes_written );
36+
if( FD_UNLIKELY( -1==written ) ) FD_LOG_ERR(( "write() failed: %d (%s)", errno, fd_io_strerror( errno ) ));
37+
bytes_written += http->oring_sz;
38+
}
39+
}
40+
41+
action_t fd_action_metrics = {
42+
.name = "metrics",
43+
.args = NULL,
44+
.fn = metrics_cmd_fn,
45+
.perm = NULL,
46+
.description = "Print the current validator Prometheus metrics to STDOUT",
47+
.is_immediate = 0,
48+
.is_diagnostic = 1,
49+
};

src/app/shared/commands/metrics.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef HEADER_fd_src_app_shared_commands_metrics_h
2+
#define HEADER_fd_src_app_shared_commands_metrics_h
3+
4+
#include "../fd_config.h"
5+
6+
FD_PROTOTYPES_BEGIN
7+
8+
void metrics_cmd_fn( args_t * args, config_t * config );
9+
10+
FD_PROTOTYPES_END
11+
12+
extern action_t fd_action_metrics;
13+
14+
#endif /* HEADER_fd_src_app_shared_commands_metrics_h */

0 commit comments

Comments
 (0)