From 9f376fcbddacf97d981410ebef0f5e298366cab0 Mon Sep 17 00:00:00 2001 From: Richard Patel Date: Mon, 8 Jan 2024 21:13:06 +0000 Subject: [PATCH] Remove base58 printf extension --- src/app/fdctl/run/tiles/fd_verify.c | 8 ++-- src/flamenco/Local.mk | 2 - src/flamenco/fd_flamenco.c | 57 ++--------------------------- src/flamenco/test_flamenco.c | 37 ------------------- 4 files changed, 8 insertions(+), 96 deletions(-) delete mode 100644 src/flamenco/test_flamenco.c diff --git a/src/app/fdctl/run/tiles/fd_verify.c b/src/app/fdctl/run/tiles/fd_verify.c index de92dddb78..3f037aed07 100644 --- a/src/app/fdctl/run/tiles/fd_verify.c +++ b/src/app/fdctl/run/tiles/fd_verify.c @@ -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 ); @@ -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 ); @@ -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); diff --git a/src/flamenco/Local.mk b/src/flamenco/Local.mk index 4c9343474a..2868b1eeec 100644 --- a/src/flamenco/Local.mk +++ b/src/flamenco/Local.mk @@ -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) diff --git a/src/flamenco/fd_flamenco.c b/src/flamenco/fd_flamenco.c index ca7f1bef5b..40a69a140d 100644 --- a/src/flamenco/fd_flamenco.c +++ b/src/flamenco/fd_flamenco.c @@ -1,59 +1,10 @@ #include "fd_flamenco_base.h" -#include -#include - -/* glibc specific *****************************************************/ - -#if defined(__GLIBC__) - -#include -#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, "" ); - - 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, "" ); - } - 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 diff --git a/src/flamenco/test_flamenco.c b/src/flamenco/test_flamenco.c deleted file mode 100644 index d66a8c35ae..0000000000 --- a/src/flamenco/test_flamenco.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "fd_flamenco.h" - -int -main( int argc, - char ** argv ) { - fd_boot ( &argc, &argv ); - fd_flamenco_boot( &argc, &argv ); - - static const uchar buf32[ 32UL ] = - { 0xad,0x23,0x76,0x6d,0xde,0xe6,0xe9,0x9c,0xa3,0x34,0x0e,0xe5,0xbe,0xac,0x08,0x84, - 0xc8,0x9d,0xdb,0xc7,0x4d,0xfe,0x24,0x8f,0xea,0x56,0x13,0x56,0x98,0xba,0xfd,0xd1 }; - static const uchar buf64[ 64UL ] = - { 0xe8,0x52,0xe3,0x69,0x0d,0xa0,0xeb,0xf5,0xb4,0x66,0xed,0x0c,0x89,0x6b,0x2c,0x8f, - 0xea,0xe6,0x0e,0x3b,0x23,0xc0,0x37,0xfc,0xdd,0x68,0xbf,0xc2,0xe4,0x60,0x7b,0x47, - 0xb9,0x79,0x02,0x2e,0x4c,0xf6,0x2a,0x04,0x26,0x4e,0xef,0x55,0x94,0x0e,0xc8,0x57, - 0xb3,0x46,0xf1,0xa4,0x11,0x5b,0xaa,0x1a,0xc8,0x3d,0x3b,0x05,0xca,0xa8,0x23,0x00 }; - - static const char format[] = "%32J %64J %3J %J %32J ..."; - static const char expected[] = - "Certusm1sa411sMpV9FPqU5dXAYhmmhygvxJ23S6hJ24 " - "5eQS44iKV8B4b4gTt4tPZLPSHtD7F78fFDhbHDknsrAE1vUipnDf3pK6h5eZ8CqWqFgZPoYY6XHKUuvyt7BLWHpb " - " " - " " - " " - "..."; - - ulong len; - char buf[ 256UL ]; - fd_cstr_printf( buf, 256UL, &len, format, buf32, buf64, buf32, buf32, NULL ); - FD_TEST( 0==strcmp( buf, expected ) ); - FD_TEST( len==strlen( expected ) ); - - FD_LOG_NOTICE(( "pass" )); - fd_flamenco_halt(); - fd_halt(); - return 0; -}