Skip to content

Commit

Permalink
Remove base58 printf extension
Browse files Browse the repository at this point in the history
  • Loading branch information
riptl authored and ripatel-fd committed Jan 8, 2024
1 parent 0d35462 commit 9f376fc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 96 deletions.
8 changes: 4 additions & 4 deletions src/app/fdctl/run/tiles/fd_verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ after_frag( void * _ctx,
/* Sanity check that should never fail. We should have atleast
FD_TPU_DCACHE_MTU bytes available. */
if( FD_UNLIKELY( *opt_sz < sizeof(ushort) ) ) {
FD_LOG_ERR( ("invalid opt_sz(%x)", *opt_sz ) );
FD_LOG_ERR( ("invalid opt_sz(%lx)", *opt_sz ) );
}

uchar * udp_payload = (uchar *)fd_chunk_to_laddr( ctx->out_mem, ctx->out_chunk );
Expand All @@ -112,7 +112,7 @@ after_frag( void * _ctx,
FD_LOG_ERR( ("invalid payload_sz(%x)", payload_sz) );
}

/* txn contents are located in shared memory accessible to the dedup tile
/* txn contents are located in shared memory accessible to the dedup tile
and the contents are controlled by the quic tile. We must perform
validation */
fd_txn_t * txn = (fd_txn_t*) fd_ulong_align_up( (ulong)(udp_payload) + payload_sz, 2UL );
Expand All @@ -121,11 +121,11 @@ after_frag( void * _ctx,
ushort message_off = txn->message_off;
ushort acct_addr_off = txn->acct_addr_off;
ushort signature_off = txn->signature_off;

if( FD_UNLIKELY( message_off >= payload_sz || acct_addr_off + FD_TXN_ACCT_ADDR_SZ > payload_sz || signature_off + FD_TXN_SIGNATURE_SZ > payload_sz ) ) {
FD_LOG_ERR( ("txn is invalid: payload_sz = %x, message_off = %x, acct_addr_off = %x, signature_off = %x", payload_sz, message_off, acct_addr_off, signature_off ) );
}

uchar local_sig[FD_TXN_SIGNATURE_SZ] __attribute__((aligned(8)));
ulong const * public_key = (ulong const *)(udp_payload + acct_addr_off);
uchar const * msg = (uchar const *)(udp_payload + message_off);
Expand Down
2 changes: 0 additions & 2 deletions src/flamenco/Local.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$(call make-lib,fd_flamenco)
$(call add-hdrs,fd_flamenco_base.h fd_flamenco.h)
$(call add-objs,fd_flamenco,fd_flamenco)
$(call make-unit-test,test_flamenco,test_flamenco,fd_flamenco fd_ballet fd_util)
$(call run-unit-test,test_flamenco)
57 changes: 4 additions & 53 deletions src/flamenco/fd_flamenco.c
Original file line number Diff line number Diff line change
@@ -1,59 +1,10 @@
#include "fd_flamenco_base.h"
#include <stdio.h>
#include <string.h>

/* glibc specific *****************************************************/

#if defined(__GLIBC__)

#include <printf.h>
#include "../ballet/base58/fd_base58.h"

static int
fd_printf_specifier_base58( FILE * stream,
struct printf_info const * info,
void const * const * args ) {

void const * mem = *((void const * const *)args[0]);
char out[ FD_BASE58_ENCODED_64_SZ ];

if( FD_UNLIKELY( !mem ) )
return fprintf( stream, "<NULL>" );

switch( info->width ) {
case 32:
fd_base58_encode_32( mem, NULL, out );
break;
case 64:
fd_base58_encode_64( mem, NULL, out );
break;
default:
return fprintf( stream, "<unsupported Base58 width>" );
}
return fprintf( stream, "%s", out );
}

static int
fd_printf_specifier_base58_arginfo( struct printf_info const * info __attribute__((unused)),
ulong n,
int * argtypes,
int * size ) {
if( FD_LIKELY( n>=1UL ) ) {
argtypes[ 0 ] = PA_POINTER;
size [ 0 ] = sizeof(void *);
}
return 1;
}

#endif

void
fd_flamenco_boot( int * pargc __attribute__((unused)),
char *** pargv __attribute__((unused)) ) {
#if defined(__GLIBC__)
FD_TEST( 0==register_printf_specifier( 'J', fd_printf_specifier_base58, fd_printf_specifier_base58_arginfo ) );
#endif
/* TODO implement printf specifiers for non-glibc */
fd_flamenco_boot( int * pargc,
char *** pargv ) {
/* TODO runtime-specific startup tasks here */
(void)pargc; (void)pargv;
}

void
Expand Down
37 changes: 0 additions & 37 deletions src/flamenco/test_flamenco.c

This file was deleted.

0 comments on commit 9f376fc

Please sign in to comment.