From efb71358c512def8f6a0d896e1bea4f6acae3882 Mon Sep 17 00:00:00 2001 From: Philip Taffet Date: Mon, 28 Oct 2024 15:48:54 -0500 Subject: [PATCH] pack/compute_budget_program: add support for max_loaded_data_cnt, clean up deprecated code paths --- src/ballet/pack/fd_compute_budget_program.h | 193 ++++++------ src/ballet/pack/fixtures/txn1.bin | Bin 0 -> 702 bytes src/ballet/pack/fixtures/txn2.bin | Bin 0 -> 543 bytes src/ballet/pack/fixtures/txn3.bin | Bin 0 -> 683 bytes src/ballet/pack/fixtures/txn4.bin | Bin 0 -> 624 bytes src/ballet/pack/fixtures/txn5.bin | Bin 0 -> 1218 bytes src/ballet/pack/fixtures/txn6.bin | Bin 0 -> 353 bytes src/ballet/pack/fixtures/txn7.bin | Bin 0 -> 501 bytes src/ballet/pack/test_compute_budget_program.c | 288 +++--------------- 9 files changed, 141 insertions(+), 340 deletions(-) create mode 100644 src/ballet/pack/fixtures/txn1.bin create mode 100644 src/ballet/pack/fixtures/txn2.bin create mode 100644 src/ballet/pack/fixtures/txn3.bin create mode 100644 src/ballet/pack/fixtures/txn4.bin create mode 100644 src/ballet/pack/fixtures/txn5.bin create mode 100644 src/ballet/pack/fixtures/txn6.bin create mode 100644 src/ballet/pack/fixtures/txn7.bin diff --git a/src/ballet/pack/fd_compute_budget_program.h b/src/ballet/pack/fd_compute_budget_program.h index 6b1191264e..be36d7663f 100644 --- a/src/ballet/pack/fd_compute_budget_program.h +++ b/src/ballet/pack/fd_compute_budget_program.h @@ -3,28 +3,25 @@ #include "../fd_ballet_base.h" #include "../txn/fd_txn.h" -/* This header contains utility functions for parsing compute budget program - instructions from a transaction. I.e. given a transaction, what is its - compute budget limit (in compute units) and what is the additional reward - for including it? Unfortunately, due to the way compute budget program - instructions are included in transactions, this is a per-transaction - stateful process. +/* This header contains utility functions for parsing compute budget + program instructions from a transaction. I.e. given a transaction, + what is its compute budget limit (in compute units) and what is the + additional reward for including it? Unfortunately, due to the way + compute budget program instructions are included in transactions, + this is a per-transaction stateful process. - This code is designed for high-performance use and so only error checks data - coming from the transaction. */ + This code is designed for high-performance use and so only error + checks data coming from the transaction. */ /* In general, compute budget instructions can occur at most once in a - transaction. If an instruction is duplicated, the transaction is malformed - and fails. However, there's an exception to this rule, which is that - RequestUnitsDeprecated counts as both a SetComputeUnitLimit and a - SetComputeUnitPrice instruction. These flags are used to keep track of what - instructions have been seen so far. - Have I seen a ... */ + transaction. If an instruction is duplicated, the transaction is + malformed and fails. These flags are used to keep track of what + instructions have been seen so far. Have I seen a ... */ #define FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_CU ((ushort)0x01) /* ... SetComputeUnitLimit ... */ #define FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_FEE ((ushort)0x02) /* ... SetComputeUnitPrice ... */ #define FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_HEAP ((ushort)0x04) /* ... RequestHeapFrame ... */ -#define FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_TOTAL_FEE ((ushort)0x08) /* ... RequestUnitsDeprecated ... */ +#define FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_LOADED_DATA_SZ ((ushort)0x08) /* ... LoadedAccountDataSize ... */ /* ... so far? */ @@ -47,6 +44,9 @@ static const uchar FD_COMPUTE_BUDGET_PROGRAM_ID[FD_TXN_ACCT_ADDR_SZ] = { #define FD_COMPUTE_BUDGET_DEFAULT_INSTR_CU_LIMIT ( 200000UL) #define FD_COMPUTE_BUDGET_MAX_CU_LIMIT (1400000UL) +/* Max loaded data size is 64 MiB */ +#define FD_COMPUTE_BUDGET_MAX_LOADED_DATA_SZ (64UL*1024UL*1024UL) + /* ---- End consensus-critical constants */ @@ -55,22 +55,23 @@ struct fd_compute_budget_program_private_state { above for their meaning. */ ushort flags; /* compute_budge_instr_cnt: How many compute budget instructions have been - parsed so far? compute_budget_instr_cnt in [0, 3]. */ + parsed so far? compute_budget_instr_cnt in [0, 4]. */ ushort compute_budget_instr_cnt; /* compute_units: if SET_CU is in flags, this stores the total requested compute units for the whole transaction. Otherwise 0. Realistically should be less than 12M, but there's nothing enforcing that at this stage. */ uint compute_units; - /* total_fee: if SET_TOTAL_FEE is in flags, this stores the total additional - fee for the transaction. Otherwise 0. */ - uint total_fee; + /* loaded_acct_data_sz: if SET_LOADED_DATA_SZ is in flags, this stores + the max total data (in bytes) that the transaction will load from + the accounts it references. Otherwise, 0. */ + uint loaded_acct_data_sz; /* heap_size: if SET_HEAP is in flags, this stores the size in bytes of the BPF heap used for executing this transaction. Otherwise, 0. Must be a multiple of 1024. */ uint heap_size; - /* micro_lamports_per_cu: if SET_FEE is in flags but SET_TOTAL_FEE is not, - this stores the requested prioritization fee in micro-lamports per compute - unit. Otherwise, 0. */ + /* micro_lamports_per_cu: if SET_FEE is in flags, this stores the + requested prioritization fee in micro-lamports per compute unit. + Otherwise, 0. */ ulong micro_lamports_per_cu; }; typedef struct fd_compute_budget_program_private_state fd_compute_budget_program_state_t; @@ -79,8 +80,7 @@ typedef struct fd_compute_budget_program_private_state fd_compute_budget_program fd_compute_budget_program_state_t to prepare it for parsing a transaction. Also equivalent to just initializing the state on the stack with = {0}. */ static inline void fd_compute_budget_program_init( fd_compute_budget_program_state_t * state ) { - fd_compute_budget_program_state_t zero = {0}; - *state = zero; + *state = (fd_compute_budget_program_state_t) {0}; } /* fd_compute_budget_program_parse: Parses a single ComputeBudgetProgram instruction. Updates the state stored in state. Returns 0 if the @@ -95,17 +95,9 @@ fd_compute_budget_program_parse( uchar const * instr_data, if( FD_UNLIKELY( data_sz<5 ) ) return 0; switch( *instr_data ) { case 0: - /* Parse a RequestUnitsDeprecated instruction */ - if( FD_UNLIKELY( data_sz<9 ) ) return 0; - if( FD_UNLIKELY( (state->flags & (FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_CU | FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_FEE))!=0 ) ) - return 0; - state->compute_units = FD_LOAD( uint, instr_data+1 ); - state->total_fee = FD_LOAD( uint, instr_data+5 ); - state->compute_units = fd_uint_min( state->compute_units, FD_COMPUTE_BUDGET_MAX_CU_LIMIT ); - state->flags |= (FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_CU | FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_FEE | - FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_TOTAL_FEE); - state->compute_budget_instr_cnt++; - return 1; + /* Formerly RequestUnitsDeprecated, but invalid since + EfhYd3SafzGT472tYQDUc4dPd2xdEfKs5fwkowUgVt4W. */ + return 0; case 1: /* Parse a RequestHeapFrame instruction */ if( FD_UNLIKELY( data_sz<5 ) ) return 0; @@ -132,6 +124,16 @@ fd_compute_budget_program_parse( uchar const * instr_data, state->flags |= FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_FEE; state->compute_budget_instr_cnt++; return 1; + case 4: + /* Parse a SetLoadedAccountsDataSizeLimit instruction */ + if( FD_UNLIKELY( data_sz<5 ) ) return 0; + if( FD_UNLIKELY( (state->flags & FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_LOADED_DATA_SZ)!=0 ) ) return 0; + state->loaded_acct_data_sz = FD_LOAD( uint, instr_data+1 ); + if( FD_UNLIKELY( state->loaded_acct_data_sz==0U ) ) return 0; + state->loaded_acct_data_sz = fd_uint_min( state->loaded_acct_data_sz, FD_COMPUTE_BUDGET_MAX_LOADED_DATA_SZ ); + state->flags |= FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_LOADED_DATA_SZ; + state->compute_budget_instr_cnt++; + return 1; default: return 0; } @@ -163,73 +165,62 @@ fd_compute_budget_program_finalize( fd_compute_budget_program_state_t const * st *out_compute = (uint)cu_limit; - /* Note: Prior to feature flag use_default_units_in_fee_calculation - (e.g. Solana mainnet today), the per-instruction version of the CU - limit is used as the actual CU limit, but a flat amount of 1.4M CUs - is used to calculate the fee when no limit is provided. */ -#if PRE_USE_DEFAULT_UNITS_IN_FEE_CALCULATION - if( FD_LIKELY( (state->flags & FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_CU)==0U ) ) { - cu_limit = FD_COMPUTE_BUDGET_MAX_CU_LIMIT; - } -#endif - ulong total_fee = 0UL; - if( FD_LIKELY( (state->flags & FD_COMPUTE_BUDGET_PROGRAM_FLAG_SET_TOTAL_FEE)==0U ) ) { - /* We need to compute max(ceil((cu_limit * micro_lamports_per_cu)/10^6), - ULONG_MAX). Unfortunately, the product can overflow. Solana solves - this by doing the arithmetic with ultra-wide integers, but that puts a - 128-bit division on the critical path. Gross. It's frustrating because - the overflow case likely results in a transaction that's so expensive - nobody can afford it anyways, but we should not break compatibility with - Solana over this. Instead we'll do the arithmetic carefully: - Let cu_limit = c_h*10^6 + c_l, where 0 <= c_l < 10^6. - Similarly, let micro_lamports_per_cu = p_h*10^6 + p_l, where - 0 <= p_l < 10^6. Since cu_limit < 2^32, c_h < 2^13; - micro_lamports_per_cu < 2^64, so p_h<2^45. - - ceil( (cu_limit * micro_lamports_per_cu)/10^6) - = ceil( ((c_h*10^6+c_l)*(p_h*10^6+p_l))/10^6 ) - = c_h*p_h*10^6 + c_h*p_l + c_l*p_h + ceil( (c_l*p_l)/10^6 ) - c_h*p_h < 2^58, so we can compute it with normal multiplication. - If c_h*p_h > floor(ULONG_MAX/10^6), then we know c_h*p_h*10^6 will hit - the saturation point. The "cross" terms are less than 2^64 by - construction (since we divided by 10^6 and then multiply by something - strictly less than 10^6). c_l*p_l < 10^12 < 2^40, so that's safe as - well. - In fact, the sum of the right three terms is no larger than: - floor((2^32-1)/10^6)*(10^6-1) + (10^6-1)*floor((2^64-1)/10^6) + 10^6-1 - == 0xffffef3a08574e4c < 2^64, so we can do the additions without - worrying about overflow. - Of course, we still need to check the final addition of the first term - with the remaining terms. As a bonus, all of the divisions can now be - done via "magic multiplication." - - Note that this computation was done before I was aware of the - 1.4M CU limit. Taking that limit into account could make the - code a little cleaner, but we'll just keep the version that - supports CU limits up to UINT_MAX, since I'm sure the limit will - go up someday. */ - do { - ulong c_h = cu_limit / FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT; - ulong c_l = cu_limit % FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT; - ulong p_h = state->micro_lamports_per_cu / FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT; - ulong p_l = state->micro_lamports_per_cu % FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT; - - ulong hh = c_h * p_h; - if( FD_UNLIKELY( hh>(ULONG_MAX/FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT) ) ) { - total_fee = ULONG_MAX; - break; - } - hh *= FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT; - - ulong hl = c_h*p_l + c_l*p_h; - ulong ll = (c_l*p_l + FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT - 1UL)/FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT; - ulong right_three_terms = hl + ll; - - total_fee = hh + right_three_terms; - if( FD_UNLIKELY( total_feetotal_fee; + + /* We need to compute max(ceil((cu_limit * micro_lamports_per_cu)/10^6), + ULONG_MAX). Unfortunately, the product can overflow. Solana solves + this by doing the arithmetic with ultra-wide integers, but that puts a + 128-bit division on the critical path. Gross. It's frustrating because + the overflow case likely results in a transaction that's so expensive + nobody can afford it anyways, but we should not break compatibility with + Solana over this. Instead we'll do the arithmetic carefully: + Let cu_limit = c_h*10^6 + c_l, where 0 <= c_l < 10^6. + Similarly, let micro_lamports_per_cu = p_h*10^6 + p_l, where + 0 <= p_l < 10^6. Since cu_limit < 2^32, c_h < 2^13; + micro_lamports_per_cu < 2^64, so p_h<2^45. + + ceil( (cu_limit * micro_lamports_per_cu)/10^6) + = ceil( ((c_h*10^6+c_l)*(p_h*10^6+p_l))/10^6 ) + = c_h*p_h*10^6 + c_h*p_l + c_l*p_h + ceil( (c_l*p_l)/10^6 ) + c_h*p_h < 2^58, so we can compute it with normal multiplication. + If c_h*p_h > floor(ULONG_MAX/10^6), then we know c_h*p_h*10^6 will hit + the saturation point. The "cross" terms are less than 2^64 by + construction (since we divided by 10^6 and then multiply by something + strictly less than 10^6). c_l*p_l < 10^12 < 2^40, so that's safe as + well. + In fact, the sum of the right three terms is no larger than: + floor((2^32-1)/10^6)*(10^6-1) + (10^6-1)*floor((2^64-1)/10^6) + 10^6-1 + == 0xffffef3a08574e4c < 2^64, so we can do the additions without + worrying about overflow. + Of course, we still need to check the final addition of the first term + with the remaining terms. As a bonus, all of the divisions can now be + done via "magic multiplication." + + Note that this computation was done before I was aware of the + 1.4M CU limit. Taking that limit into account could make the + code a little cleaner, but we'll just keep the version that + supports CU limits up to UINT_MAX, since I'm sure the limit will + go up someday. */ + do { + ulong c_h = cu_limit / FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT; + ulong c_l = cu_limit % FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT; + ulong p_h = state->micro_lamports_per_cu / FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT; + ulong p_l = state->micro_lamports_per_cu % FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT; + + ulong hh = c_h * p_h; + if( FD_UNLIKELY( hh>(ULONG_MAX/FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT) ) ) { + total_fee = ULONG_MAX; + break; + } + hh *= FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT; + + ulong hl = c_h*p_l + c_l*p_h; + ulong ll = (c_l*p_l + FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT - 1UL)/FD_COMPUTE_BUDGET_MICRO_LAMPORTS_PER_LAMPORT; + ulong right_three_terms = hl + ll; + + total_fee = hh + right_three_terms; + if( FD_UNLIKELY( total_feeWmt!f-& z^6mEnL-*G~{ilSNZhEY|SBJNOk%5W#h2ktL?|ikkVAefN2gT-#t$Yx*=G&2}z2y%N zGMgSLeDF`9j*Bm$<+M-6hBZy>%4?)EO5^T-e;W|4GdCmejWDC-w6q0{CoDQlgeP9H zHNKktqL)YYjFL2W^OduOUaCBWttQMfRLc5JzFmGx;!N1I>^n9m(|?_H74Vs?+jIS} zAIpm8>)Pkc+}zN9b!qkzL;cksZ`m4)Hh282xqNp*mhs1qn01n;94uMBzWnTc=Tuh7 zZi}t==g&Kv}i;`Ca6uudz&e$83~rVBGz97RLK z9K&>ONf`vZY|)6@I?Ldx*o2fUtxd-N~c=q!>Jx_NZ z{VtTP<2>8Sfq^iX;Sr&^Qr~OcgRT3fR>YfeI?injFsjojP}oXifq x%wUsvm>3v=7zp+hn}8@FhY4MP8C`${U4Ru`fDK)M9bJF}U4Ro^fD1){0RWu>_KE-i literal 0 HcmV?d00001 diff --git a/src/ballet/pack/fixtures/txn2.bin b/src/ballet/pack/fixtures/txn2.bin new file mode 100644 index 0000000000000000000000000000000000000000..eba47ebf21b5fe596b7abebd9123dc77dd0e4312 GIT binary patch literal 543 zcmV+)0^t1t_R*qNP9I&f0XXs~{HcE2$DGzoNk7?ypmST6j`>^Sp#^QVG6XC%H&zH3)TyRf=2;H3>H`KwZ{;BuGXLzYx^lyt z=e&&NyT$hsYb-;XIzRvb0DJeK6{)P%!fIsIa4FbB6%|pYbD?{3F7hZV>{pRxBLe{_ z85$QB00;vI1_T8K85$cL00s*T4-F0u7yu6l5)lvz2@@3*9U2}F4h0d6^#A|>00031 z000RB00jadp$7m000{$`IsgCw00007iX)+)PA9s_xkWCLgSaYAWPgbbrF_AU-3 z-zLJ51?%na`|JYg=#ksrqa`?t$w-q$l%63ssRWC0|5qm z#}f^j(Q3IO`B5qBKO8J<7A<}w`urw*NVUjIAsg8OBO(BUF+hrz$W#Bj5)=i$uCudP z5lMgdo1q=jaqreQL2bYUy}ZA{0=c^9;h(KA${Z(kw=s1RgA4AkW~av1SWVdQmS%=* zaAoHK_W-1?oq1?qG>!&js`n&m*N>IrSEsC@P_u%=gz9qE!=wh8n3tNIn*p5zzVV|p h54(BmuGi6h(JWshUCHZR?!RwaGI38ME^EC20m>402UqFB_&4op?QIEOQyvo9X;q2v@)Xa7vaM<34!@EJ=Rco`aBiMPxk3@rsCoY8Oo~y7_bc(rD zSTB;w1J@1tajWVgVDGx4k|=o*GoIdsGa>z^s~$V5z?zJ&?#p^IkdD%+*AIOeve%#N zTUWEd0lQI2h8-jC*cI2HrE~-$>B9Rb!7rYWz9e2 zff7|4CYY0@bXuZ%S!RqSVmBxmdn6x?pNNjWR@$ipZbKfIgS?4J9YeQ`0|rKK0a>JYFyo}|$#rG0xEJK?*KmY&$2B*~*87y2;A&kjPJxcL^SlaFgo1y(gjQa@w8&frxz|JPsbnSFr4%k)Hv9Fz;VMM(mNw=&z;I`Jo;0t^5J z0zg6!01ple3IzZL0RjXA2nPuc4J<{WUCMZVOt}Cl1^@s60000c000000000lSz7=A R000013IG5A00000001MvD7ydv literal 0 HcmV?d00001 diff --git a/src/ballet/pack/fixtures/txn4.bin b/src/ballet/pack/fixtures/txn4.bin new file mode 100644 index 0000000000000000000000000000000000000000..d991637904ef9527d125b9cf47e07bb78525042a GIT binary patch literal 624 zcmZP+C6aC-%6HTa4On%{?xz{_nW8#P3J7t9$>o&*J*2 zxI|*MZ_k^&Bkj+e%AU?k*L1em^P0uQ8qTJ>Vd?B&fuCyLtLHSH*xvY%#q!AZ{pGo_ z@BeBDUAlio{_mODTU1l^PCA^cX5G16_;1i##Gk$pGxS^`6o zoYx9ITk=QKWy!CmzG**F7q9KNW-Z;-;%?h z+|ie~+Ut7oRY~V>bLE?rHbu)A!ybH_oECN7<+f^^Myve?+eNX!e@%kBnc3t@4SjEnZt^ znSaZ=8-DcV8tdQ(k(XmqnAzO&pDKzQ{eQD|SJC0w&-e5^-F@`CP_~ZqY%2$#+t2F< zR9dZZjryshVdtJFkW=rea_-ONqRy|)^>;5yW%#%H`*siI( zD*NC(&;HeuoODAN6xn6_9&2w?2~~UIU&O-2z{&JOg%M;H1CY(E=m%ypaIiBlGjOx= r@-Q;8^RTgSGchtV0C}A35@~FB%;BU3oWzNrYRgO$Np6`=ZRr&b%`N%ZudkoUsr%&dI)4rYlpk>aMC;NR$ z#q+OxQQ)lT@Sp4B{rkTP9(;vXb?|OY7D@E_ISem;KpeB4-%>;qU4% zsS~Q-b8Wx1_q$tFNAP=FrudbMxp%eyKC{U!=E2NePuZBR91uPKPjJe9y$QbY?>xS- z?Jek9f5O^TRc5}^`&qtG;-8u}K2s5T5D@qGvh9EWx9WGFZ9Xirr7ESsx1A-=x=88s zP3`R!aVe$=I;E5MCYUW~td`TgQPHL{^Fx8~sd+cH9j?D09{S;pbK2DNrgJkF?reWK zt*I!NeM{3@#frWr&4WP#p|AHAJui6N!W6AB*IdxOXUfDAMIYkyPt59_WbU#5w4mtw z`69xTJWp-p_gtN-m|bt;!xCqtx=X$PO3&f~!;G^5TkfgknkX%jnfr*x*7MAQwVfg? z>>nnu> z%zBkNCv$k;^gLq5bl6^@e8O9?#X&v`cTSJ_sJLh)&;K{IKelz9EmRJFT+^7J-X{H@BJD-146)iW~iZvvya};n~mk^gP{t^t({Dj`M6Q z2L=WPUiQEh8oJAbS^sIyG2c1kX-na4K~v^pfgk$>T$gcud&hS7+r#Ur3n$+^{m|{) z>&i7UTUy`7N1IQy>iODQ_n%?qitp`3f~#kL4_&$D{JG4U>4v_+Q;Sxv9aYHF{*aR5#z2q%*3c#!Agv(XGDd>1SMk3Iw6j#3IInY Bdcyz! literal 0 HcmV?d00001 diff --git a/src/ballet/pack/fixtures/txn6.bin b/src/ballet/pack/fixtures/txn6.bin new file mode 100644 index 0000000000000000000000000000000000000000..e81a356afe608be9e8f29d2c337ee279486f902c GIT binary patch literal 353 zcmZSllJkG^-#O<6rpfB0`@gNZ(|teg>2x;!*>+bSv@YnIo}k+Lvu(=jjX(B??`%2i zeaiM`|4gF>YX*)zOp6m{b>}lRFfy>P)%p8fV11|F;cOxLXY$kLU(y-xWYdf9ukUi0 ze#xI zS-Y#~@a*S%dYfYZE#rip7g?}3`{}0-}d;Td&i_Kn4v-M9;p0Q)v zYxY(Ag;O6yZ&lvnyxaWu8i$Br7G?%kri51v49pCi%oE}n!OjJWu{b#KGqA8QF)*@< ZF#`p;GOk_Im^Cw$k&%Im0i^0b0|1s3h7&*DbsH@Z=ny)>TK%e#|-0 zxlnO_*|~??w(pobd-lJyFXeoU49pxw0iwtHW~>ffR+=!$YU<&#uRJqc7WH2J$38`v z>+IQAUwvxK#q862;sowTvS%>7e%8EvpXLG4^i!X;Y>&ooE@;iF*sYxUgsqfa?V-^T zby20wnm66|?YnuF&z|k?&Bq!4=GEPovn`F2sWP>URa-EhBfv>)N2JsHDGopTCNE9) z{&iKjZ&_?>$ez#Q-Scdfj`{J;Q{^%GpBe*eM`#i6GA&)T{8fd`p_zuQ;vQu$ z7#dn+O&iZI__JaC=F)=y{|mO>b^P8eFZ-wB?3ok$=RA6G_J6jwpJ>(s(QfN^-k0_| e-<+gyO+{kg(}k}$mdbAAx9jIWu;ttC`O*MM9@GT@ literal 0 HcmV?d00001 diff --git a/src/ballet/pack/test_compute_budget_program.c b/src/ballet/pack/test_compute_budget_program.c index 1057aa44c0..ac7f3f95a1 100644 --- a/src/ballet/pack/test_compute_budget_program.c +++ b/src/ballet/pack/test_compute_budget_program.c @@ -1,230 +1,26 @@ #include "fd_compute_budget_program.h" -/* 700k CU, 0 extra fee (deprecated) */ -unsigned char txn1[1191] = { -0x01,0xfd,0x9b,0xec,0x91,0x1b,0x63,0x54,0x7e,0x72,0x48,0xd2,0x0e,0x87,0x76,0x39, -0xc3,0x0b,0xdf,0xb3,0x0a,0x11,0x55,0x58,0xee,0x6a,0x18,0x1c,0x9e,0xa5,0x50,0x17, -0x6e,0x7f,0xec,0xf6,0xa2,0x95,0x7b,0x52,0x47,0x0a,0x78,0xc0,0xe9,0xfc,0x53,0x97, -0xb7,0xfc,0x46,0xcf,0x46,0x19,0x72,0xa8,0x07,0xb6,0x48,0xa3,0x0a,0x88,0x06,0xa1, -0x07,0x01,0x00,0x1b,0x1d,0x11,0x64,0x91,0xfb,0x15,0x92,0x23,0xf0,0xec,0xab,0xaa, -0x10,0xc1,0x3a,0x2b,0x59,0x7c,0x81,0x1e,0xe0,0x01,0x34,0x2d,0x3f,0x78,0x55,0x41, -0xec,0xb4,0x3d,0x0f,0x81,0x55,0x6b,0xb3,0xaf,0x23,0xd8,0x79,0xc5,0x8f,0x44,0x83, -0x89,0x27,0x2e,0x84,0xe8,0x9e,0xab,0xb0,0x54,0x74,0x8a,0xb9,0x54,0x58,0x2f,0x92, -0xca,0x03,0xd7,0x0d,0xf9,0x59,0x66,0x8c,0x25,0x62,0x37,0x28,0x19,0x7b,0x24,0x1f, -0x8d,0x9f,0x88,0x8e,0xbe,0x56,0xda,0xa9,0x03,0x6e,0x43,0x1e,0x97,0x83,0xbc,0x89, -0x49,0x1d,0x43,0xb7,0x8d,0x08,0x41,0x3a,0xa6,0x21,0x31,0x0c,0x1f,0x15,0xb3,0x53, -0x5b,0x3f,0x3d,0x6c,0xd3,0x4e,0x1e,0xd7,0x46,0x7c,0xf1,0xe8,0x0f,0xf8,0x03,0x51, -0x02,0x64,0x88,0x84,0xfe,0x15,0xad,0xd9,0x50,0x22,0xae,0x13,0x56,0x3a,0x11,0x99, -0x2e,0x72,0x7c,0x91,0xbd,0xb6,0xb5,0x5b,0xc1,0x83,0xd9,0xd7,0x47,0x43,0x6c,0x80, -0xa4,0x83,0xd8,0xc8,0x64,0x93,0xda,0x33,0x52,0xf9,0xf1,0xd1,0x05,0xfd,0xfe,0x49, -0x71,0xcf,0xa8,0x0e,0x9d,0xd7,0x77,0xbf,0xc5,0xd0,0xf6,0x83,0xeb,0xb6,0xe1,0x29, -0x4b,0x92,0x13,0x7b,0xb7,0xe6,0x2d,0xf6,0xc8,0xb4,0xa8,0x5f,0xe1,0xa6,0x7d,0xb4, -0x4d,0xc1,0x2d,0xe5,0xdb,0x33,0x0f,0x7a,0xc6,0x6b,0x72,0xdc,0x65,0x8a,0xfe,0xdf, -0x0f,0x4a,0x41,0x5b,0x43,0xff,0x61,0x49,0x1a,0x93,0x11,0x12,0xdd,0xf1,0xbd,0x81, -0x47,0xcd,0x1b,0x64,0x13,0x75,0xf7,0x9f,0x58,0x25,0x12,0x6d,0x66,0x54,0x80,0x87, -0x46,0x34,0xfd,0x0a,0xce,0xba,0xa2,0x84,0xea,0xf2,0x3e,0xdf,0x97,0x5b,0x37,0x1b, -0xa2,0x81,0x87,0x72,0xf9,0x3d,0xba,0xe7,0x28,0x36,0xbb,0xde,0xa2,0x8b,0x07,0xd4, -0x0f,0x3c,0xf8,0xb4,0x85,0xc4,0x15,0xde,0x8d,0x2e,0xba,0x7d,0xb2,0x16,0x52,0x7d, -0xff,0x4b,0x60,0xe8,0xf3,0xa5,0x31,0x1c,0x74,0x0d,0xad,0xb2,0x33,0xe1,0x3e,0x12, -0x54,0x7e,0x22,0x67,0x50,0xef,0x0d,0x8b,0x6f,0xda,0x2c,0xeb,0xa4,0x1d,0xa1,0x5d, -0x40,0x95,0xd1,0xda,0x39,0x2a,0x0d,0x2f,0x8e,0xd0,0xc6,0xc7,0xbc,0x0f,0x4c,0xfa, -0xc8,0xc2,0x80,0xb5,0x6d,0x23,0x24,0x5b,0xb7,0x42,0x54,0xe6,0x5a,0x98,0xcc,0x3f, -0xf4,0xa3,0x74,0x43,0xd7,0x9f,0x52,0x7e,0x44,0xe4,0x49,0x75,0x0a,0xd3,0x04,0x53, -0x8b,0x00,0x6f,0x21,0xbc,0x72,0xd6,0xe8,0xcd,0xf5,0xc7,0x4b,0x97,0x97,0x50,0xd6, -0x0d,0xf1,0x1b,0x4c,0x14,0xae,0x06,0x19,0xad,0x14,0xc1,0x84,0x07,0xc1,0xe6,0xec, -0x60,0xf9,0x39,0x6e,0x96,0xea,0xa0,0x20,0xc6,0x1c,0xc4,0x79,0x71,0x28,0x13,0x46, -0x1c,0xe1,0x53,0x89,0x4a,0x96,0xa6,0xc0,0x0b,0x21,0xed,0x0c,0xfc,0x27,0x98,0xd1, -0xf9,0xa9,0xe9,0xc9,0x4a,0x2b,0x89,0xb9,0xdc,0x8f,0xdf,0x9f,0x34,0x70,0x9a,0x5b, -0x10,0x6b,0x47,0x2f,0x0f,0x39,0xbb,0x6c,0xa9,0xce,0x04,0xb0,0xfd,0x7f,0x2e,0x97, -0x16,0x88,0xe2,0xe5,0x3b,0xef,0x94,0xac,0xc2,0xfb,0x09,0xeb,0x97,0x6c,0x6e,0xb3, -0x00,0x0b,0xab,0x89,0x8c,0xab,0x89,0x1d,0x5b,0x80,0x07,0x02,0xcd,0x1d,0xc8,0x8e, -0x61,0xd7,0xc3,0xc5,0xe6,0xc2,0x28,0x9a,0x6a,0x43,0xd2,0xce,0x91,0xc6,0xf5,0x5c, -0xae,0xc3,0x70,0xf4,0xac,0xc3,0x8a,0x2e,0xd4,0x77,0xf5,0x88,0x13,0x33,0x4c,0x6d, -0x03,0x74,0x9f,0xf2,0xa4,0xcd,0x98,0xf5,0xb4,0x00,0x2c,0x7a,0xf3,0xa4,0x90,0x12, -0x63,0xab,0x55,0xa0,0x3a,0x3f,0x2b,0xd6,0xb0,0xf1,0x8c,0x77,0x8e,0x9f,0xc3,0xe9, -0x5b,0x82,0x1a,0x35,0xa8,0x6c,0x84,0x3e,0x63,0x3a,0xf9,0xfb,0xde,0x7b,0x4e,0x0e, -0x41,0x62,0x16,0x9b,0xb0,0x96,0x00,0x36,0x38,0x4a,0xd6,0xaa,0x55,0x0d,0x5e,0xab, -0x72,0xf4,0xe0,0xba,0x98,0x4d,0x5b,0x7d,0x27,0xf0,0x0d,0x40,0x0e,0x69,0x00,0x69, -0xf1,0xbc,0xca,0xc2,0x81,0xe1,0xec,0xe5,0x98,0xd4,0xcc,0x76,0x21,0x70,0xd8,0xde, -0x86,0xc3,0xbb,0x41,0xde,0x8a,0x21,0x64,0x5b,0x4d,0xf4,0xd3,0x83,0x3e,0x4e,0x64, -0x54,0x01,0x69,0xe2,0x5d,0x8e,0x69,0xb0,0x70,0xd2,0xe5,0xfd,0x60,0x61,0x49,0xc3, -0x9b,0xb0,0xc8,0xa5,0x1f,0xdd,0x94,0x34,0xf0,0x8c,0x12,0xc3,0x5a,0xe2,0x52,0x1a, -0x55,0xc7,0x64,0x08,0x57,0x0f,0x9a,0xb2,0x40,0x4b,0x15,0x0b,0x06,0x6f,0x2b,0x4f, -0x04,0xf3,0x9a,0x72,0xf1,0xb6,0x15,0x0c,0xb2,0x54,0x90,0x99,0xa7,0xe3,0x3a,0x7b, -0x7b,0xf9,0xf4,0x96,0x40,0xa8,0xc4,0x13,0x82,0xf8,0x4c,0x9e,0x20,0xac,0x25,0x15, -0xf6,0x5d,0x56,0xe2,0x16,0x83,0xc8,0x73,0x5f,0xe1,0xa4,0xaa,0xe1,0xf6,0x3f,0x30, -0xd6,0xcf,0x16,0x53,0xe9,0x6b,0xc5,0x9f,0xa0,0xfc,0x6d,0xc2,0x61,0x5c,0x1f,0x4c, -0xe7,0xc0,0xb6,0x3a,0x92,0xa3,0xc6,0x35,0x9e,0x19,0x41,0x3d,0xfa,0xdb,0x16,0xc7, -0xe7,0x1c,0x83,0xe1,0x12,0x68,0x37,0x66,0xcd,0xd4,0x22,0xe9,0x8b,0xc7,0x16,0xb5, -0x3a,0x88,0xe2,0xa5,0x68,0x62,0xc6,0x56,0x91,0x12,0x46,0x76,0xdc,0xf5,0x58,0xe8, -0x8a,0xce,0xbe,0x36,0x24,0xa0,0xe7,0x59,0x09,0x16,0xd7,0x15,0x58,0x51,0x0b,0xe8, -0x78,0xaf,0xed,0xf1,0x46,0xd7,0xf4,0xe8,0xf8,0x07,0x95,0xc5,0x4a,0x3f,0x0f,0xc3, -0xc6,0x9b,0x3e,0xf7,0x42,0x20,0xa4,0x31,0xe3,0x41,0xd0,0x3b,0x33,0x21,0x2e,0x55, -0xda,0xf0,0x08,0x6a,0xbc,0x03,0x06,0x46,0x6f,0xe5,0x21,0x17,0x32,0xff,0xec,0xad, -0xba,0x72,0xc3,0x9b,0xe7,0xbc,0x8c,0xe5,0xbb,0xc5,0xf7,0x12,0x6b,0x2c,0x43,0x9b, -0x3a,0x40,0x00,0x00,0x00,0x08,0x66,0x9c,0x91,0x98,0x54,0x4c,0x1f,0x62,0xdb,0xb6, -0x4e,0xe6,0x68,0x77,0xce,0x58,0x43,0xc7,0x44,0xb7,0x57,0x5d,0xa0,0xbd,0x7b,0x91, -0x62,0x52,0x3f,0x63,0xbd,0xa5,0xa3,0x89,0xe0,0x87,0x4c,0xae,0x89,0xf3,0xac,0xf9, -0xa7,0x4a,0xb7,0x90,0x5c,0x64,0xc5,0x3a,0xdd,0x7a,0x80,0x90,0x9c,0x10,0xac,0xdc, -0xe6,0x2d,0xc1,0x13,0x5a,0x02,0x1b,0x00,0x09,0x00,0x60,0xae,0x0a,0x00,0x00,0x00, -0x00,0x00,0x1c,0x1c,0x00,0x02,0x01,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b, -0x0c,0x0d,0x0e,0x0f,0x10,0x07,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a, -0x76,0xf1,0xdc,0x83,0x57,0xf5,0x92,0xc9,0x83,0x0e,0x00,0x00,0x00,0x03,0x00,0x00, -0x00,0x41,0x50,0x45,0x04,0x00,0x00,0x00,0x41,0x56,0x41,0x58,0x03,0x00,0x00,0x00, -0x42,0x54,0x43,0x03,0x00,0x00,0x00,0x45,0x54,0x48,0x03,0x00,0x00,0x00,0x47,0x4d, -0x54,0x04,0x00,0x00,0x00,0x4e,0x45,0x41,0x52,0x03,0x00,0x00,0x00,0x53,0x4f,0x4c, -0x03,0x00,0x00,0x00,0x53,0x52,0x4d,0x03,0x00,0x00,0x00,0x53,0x59,0x4e,0x04,0x00, -0x00,0x00,0x55,0x53,0x44,0x43,0x04,0x00,0x00,0x00,0x55,0x53,0x44,0x54,0x03,0x00, -0x00,0x00,0x55,0x53,0x54,0x04,0x00,0x00,0x00,0x6d,0x53,0x4f,0x4c,0x05,0x00,0x00, -0x00,0x77,0x65,0x45,0x54,0x48,0x00}; +FD_IMPORT_BINARY( txn1, "src/ballet/pack/fixtures/txn1.bin" ); /* 0.2 lamports per CU, doesn't set number of CUs */ +FD_IMPORT_BINARY( txn2, "src/ballet/pack/fixtures/txn2.bin" ); /* 500k CU, 15001 ulamports per CU; total fee: 12501 lamports */ +FD_IMPORT_BINARY( txn3, "src/ballet/pack/fixtures/txn3.bin" ); /* Just 1M CU, no extra fee */ +FD_IMPORT_BINARY( txn4, "src/ballet/pack/fixtures/txn4.bin" ); /* 75k CU, 20001 ulamports per CU, the CU request has trailing data */ +FD_IMPORT_BINARY( txn5, "src/ballet/pack/fixtures/txn5.bin" ); /* Requests 6M CUs, so only allotted 1.4M CUs, total fee of 33,000 lamports */ +FD_IMPORT_BINARY( txn6, "src/ballet/pack/fixtures/txn6.bin" ); /* Includes a requested_loaded_accounts_data_size_limit instruction */ +FD_IMPORT_BINARY( txn7, "src/ballet/pack/fixtures/txn7.bin" ); /* Requests additional heap */ -/* 500k CU, 15001 ulamports per CU; total fee: 12501 lamports */ -unsigned char txn2[543] = { -0x01,0xf6,0xd1,0xa2,0x56,0x4e,0x1f,0x5d,0xb3,0x01,0x38,0xf2,0x28,0xfc,0xa9,0x7e, -0xdc,0xc7,0x9c,0xd6,0x4c,0x49,0x3f,0xd9,0x84,0xa0,0x73,0x5b,0x96,0x8e,0xf9,0x5b, -0xe2,0xa1,0x05,0x6d,0xb5,0x32,0x04,0x2c,0x3c,0x31,0xfd,0x2b,0x1b,0xa6,0x55,0xc5, -0x66,0xd6,0xda,0xa3,0xa2,0xc2,0x93,0xe2,0xdf,0xa9,0xb0,0x13,0x35,0x02,0x7c,0x3a, -0x0b,0x80,0x01,0x00,0x02,0x03,0x05,0x2a,0x20,0x4c,0x36,0xe4,0xb8,0x06,0xce,0x32, -0xb5,0x39,0x47,0x4b,0x8e,0x6d,0xb7,0x89,0x55,0xe6,0x4b,0x66,0x04,0x3f,0xbb,0xa4, -0x31,0xef,0x28,0x9a,0x3d,0x30,0xc6,0x89,0x6d,0x1d,0xad,0x6d,0xcd,0x87,0xcd,0x94, -0x2b,0x31,0xf1,0x9b,0x6e,0xcf,0x6a,0x45,0x17,0x37,0x56,0x08,0x18,0xd4,0xa9,0xa6, -0x59,0xe6,0x59,0x0e,0xb4,0xea,0x03,0x06,0x46,0x6f,0xe5,0x21,0x17,0x32,0xff,0xec, -0xad,0xba,0x72,0xc3,0x9b,0xe7,0xbc,0x8c,0xe5,0xbb,0xc5,0xf7,0x12,0x6b,0x2c,0x43, -0x9b,0x3a,0x40,0x00,0x00,0x00,0x7b,0xf7,0xa0,0x15,0xa9,0xac,0xd5,0xc2,0x6a,0x64, -0xd5,0x70,0x29,0xd8,0x43,0x15,0x15,0x51,0xa6,0x73,0xa1,0x7b,0x72,0x2e,0xf2,0x28, -0x2b,0xec,0x57,0x91,0x65,0x23,0x03,0x01,0x28,0x19,0x1a,0x17,0x16,0x00,0x08,0x03, -0x07,0x06,0x04,0x05,0x05,0x19,0x1a,0x1b,0x1c,0x00,0x06,0x0b,0x0c,0x0f,0x0d,0x0e, -0x0e,0x18,0x00,0x0f,0x08,0x12,0x11,0x10,0x0a,0x09,0x13,0x15,0x14,0x1d,0x1a,0x1e, -0x0f,0x0e,0x05,0x11,0x8c,0xf5,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x09, -0x02,0x00,0x05,0x02,0x20,0xa1,0x07,0x00,0x02,0x00,0x09,0x03,0x99,0x3a,0x00,0x00, -0x00,0x00,0x00,0x00,0x07,0x8a,0x23,0xa1,0x9f,0xe3,0xb6,0xb3,0x66,0x1e,0x03,0x79, -0x93,0x64,0x03,0x67,0xf7,0x71,0x42,0x69,0x51,0x84,0x0c,0xa3,0x30,0xf6,0x2e,0x0e, -0x25,0xdf,0x26,0xc2,0x91,0x05,0xeb,0xed,0xef,0xfb,0xec,0x02,0xe9,0xe8,0x91,0xdb, -0xde,0xa3,0x24,0x67,0x29,0xdd,0x0a,0xa0,0xbd,0x6d,0x7b,0x79,0x8e,0x8f,0x24,0x26, -0xc9,0x7f,0x16,0x6e,0xf2,0xad,0x7e,0xb9,0xf8,0xc8,0xe0,0xc6,0x3d,0xaa,0x01,0x08, -0x03,0x03,0x01,0x06,0x7b,0xc7,0x13,0x0d,0x9a,0xd1,0x6a,0xb9,0x22,0xf9,0x51,0x29, -0xeb,0x3f,0x1c,0x2c,0x6c,0x16,0x2d,0x7e,0x23,0xfa,0xfc,0x26,0x7c,0x48,0xb5,0xc8, -0x4b,0x21,0x1b,0xd9,0x02,0x23,0x22,0x00,0x83,0x31,0x40,0x8a,0x96,0xc8,0x53,0xff, -0xbb,0x12,0x14,0x05,0xbf,0xae,0xb3,0xb3,0x58,0x11,0x49,0x7f,0xf7,0x9b,0xa1,0x1d, -0xd2,0x71,0xef,0xd6,0x37,0x41,0x6d,0xc0,0x04,0xbd,0xbc,0xbf,0xc1,0x02,0xb9,0xba, -0xe7,0xe1,0x9f,0xad,0x30,0xca,0x1c,0x27,0x75,0xb7,0x31,0x75,0x12,0x83,0x0b,0xee, -0xb0,0x66,0xa7,0xc6,0xd6,0x58,0x4d,0xd8,0xf0,0x96,0x66,0x86,0x6c,0x70,0x65,0xe7, -0x01,0xf7,0x00,0xa4,0xaf,0x9d,0x79,0x68,0x5f,0x34,0x8e,0x06,0x64,0xaa,0xf7,0x24, -0x69,0xd7,0x8f,0x95,0xe2,0x57,0xa7,0xac,0xa1,0x50,0xb3,0x82,0xc3,0x84,0xea,0x72, -0xd6,0xc3,0xa4,0x06,0x99,0x98,0x97,0x9a,0x9c,0x9b,0x01,0x9d,0x03,0xbe,0xf1,0xa3, -0x34,0x0f,0xbb,0x79,0xeb,0xae,0xd7,0xd1,0x7d,0xd1,0x2c,0x5f,0x23,0x5d,0xc9,0xeb, -0x5d,0xee,0xbf,0x6f,0x5b,0x32,0x71,0x4f,0x23,0x2e,0x6b,0xbd,0x00,0x01,0xca}; -/* Just 1M CU, no extra fee */ -unsigned char txn3[683] = { -0x01,0x36,0x76,0xa3,0x72,0x35,0xb1,0xdb,0x3a,0xcb,0xf5,0xd1,0x60,0x7d,0x61,0x40, -0xd3,0x25,0x70,0x3e,0x81,0xd6,0x79,0x07,0x54,0xef,0xdb,0xa8,0xb0,0x0c,0x4b,0xe6, -0xd4,0x68,0x65,0x18,0x9f,0x6d,0xe5,0xd5,0xa5,0x2e,0x1f,0x05,0x3f,0x81,0x7a,0x1b, -0x2f,0xa4,0xc8,0xdd,0x21,0x57,0xe2,0x01,0x90,0x35,0x07,0xca,0xe8,0x9c,0x7c,0x1a, -0x06,0x01,0x00,0x05,0x10,0x98,0x63,0x71,0x34,0xb7,0xae,0x9f,0x06,0xb8,0x77,0xeb, -0x41,0x14,0xd1,0x9b,0x06,0xdf,0x83,0x5b,0x02,0xe1,0x07,0x25,0x91,0x60,0x92,0xc1, -0x1a,0x47,0xc3,0xe0,0x4a,0x1c,0x4d,0x84,0x4d,0x54,0x21,0x3f,0x6d,0x52,0x50,0xad, -0xb8,0x1f,0xa3,0xf0,0x46,0xfc,0xf2,0xaf,0x77,0x30,0xcf,0x2c,0x8a,0x24,0xcb,0xe6, -0x2a,0xa7,0x60,0x23,0x6b,0x2b,0x98,0x37,0x28,0x58,0xb3,0xe8,0x02,0xc6,0x8e,0xa0, -0x92,0x1b,0x25,0xe8,0xe2,0xf0,0x23,0x13,0x9b,0x62,0xbe,0x8c,0xc6,0x79,0xc3,0x84, -0x53,0x1a,0x27,0x94,0xcd,0x3a,0x5d,0xe5,0xd9,0x4e,0xe6,0xc1,0x67,0x87,0xd9,0x02, -0x5f,0x20,0x4e,0xd3,0x3c,0x17,0xfc,0x3d,0x55,0xe9,0x70,0xfd,0xb6,0x25,0x25,0x46, -0xf6,0xa1,0x79,0x81,0x71,0x4d,0x5b,0x7d,0x27,0xf0,0x0d,0x40,0x0e,0x69,0x00,0x69, -0xf1,0xbc,0xca,0xc2,0x81,0xe1,0xec,0xe5,0x98,0xd4,0xcc,0x76,0x21,0x70,0xd8,0xde, -0x86,0xc3,0xbb,0x41,0xde,0x55,0x6b,0xb3,0xaf,0x23,0xd8,0x79,0xc5,0x8f,0x44,0x83, -0x89,0x27,0x2e,0x84,0xe8,0x9e,0xab,0xb0,0x54,0x74,0x8a,0xb9,0x54,0x58,0x2f,0x92, -0xca,0x03,0xd7,0x0d,0xf9,0x71,0xab,0xea,0x22,0x60,0xef,0xba,0xa3,0x92,0x28,0x79, -0x11,0x33,0x9e,0xde,0x85,0x33,0x21,0xfd,0xa6,0xab,0x1e,0x3b,0xaa,0xc0,0x9a,0x8c, -0xaf,0xee,0xcb,0x7a,0x32,0x90,0x8e,0xd2,0xa9,0xd7,0x0f,0x7d,0x19,0xb2,0xd7,0x9f, -0xec,0x5b,0x57,0xb3,0xc0,0x01,0xbb,0x51,0x49,0x86,0x1d,0x23,0xef,0xd9,0x60,0x8b, -0x75,0x91,0x17,0xed,0xd2,0xb1,0x11,0x0e,0xad,0xc2,0x76,0xd3,0xe5,0x0f,0xc3,0x44, -0x44,0x8d,0x8e,0x3d,0x4d,0x5b,0x64,0x00,0xee,0x50,0x9a,0x59,0x51,0x7a,0xec,0x52, -0x35,0xed,0x4b,0xca,0x4b,0xc6,0x9d,0x77,0x8e,0x2d,0x0d,0x58,0x33,0x34,0xe1,0x12, -0x8f,0xda,0x66,0x46,0x74,0xbc,0x8a,0xbc,0x8d,0x22,0x07,0x6c,0x70,0x6c,0x32,0x3b, -0xf1,0x86,0x75,0xa0,0x06,0xf8,0x8f,0xf8,0x80,0x36,0xd7,0x1e,0x1b,0xc9,0xe1,0x35, -0x3a,0x75,0x65,0x02,0x45,0x65,0xcd,0x3f,0xe4,0x81,0x12,0x55,0x1b,0x26,0x98,0x93, -0xa5,0x74,0x5a,0xa2,0x7a,0x59,0x66,0x8c,0x25,0x62,0x37,0x28,0x19,0x7b,0x24,0x1f, -0x8d,0x9f,0x88,0x8e,0xbe,0x56,0xda,0xa9,0x03,0x6e,0x43,0x1e,0x97,0x83,0xbc,0x89, -0x49,0x1d,0x43,0xb7,0x8d,0x03,0x06,0x46,0x6f,0xe5,0x21,0x17,0x32,0xff,0xec,0xad, -0xba,0x72,0xc3,0x9b,0xe7,0xbc,0x8c,0xe5,0xbb,0xc5,0xf7,0x12,0x6b,0x2c,0x43,0x9b, -0x3a,0x40,0x00,0x00,0x00,0x06,0xa7,0xd5,0x17,0x19,0x2c,0x5c,0x51,0x21,0x8c,0xc9, -0x4c,0x3d,0x4a,0xf1,0x7f,0x58,0xda,0xee,0x08,0x9b,0xa1,0xfd,0x44,0xe3,0xdb,0xd9, -0x8a,0x00,0x00,0x00,0x00,0x08,0x41,0x3a,0xa6,0x21,0x31,0x0c,0x1f,0x15,0xb3,0x53, -0x5b,0x3f,0x3d,0x6c,0xd3,0x4e,0x1e,0xd7,0x46,0x7c,0xf1,0xe8,0x0f,0xf8,0x03,0x51, -0x02,0x64,0x88,0x84,0xfe,0x08,0x66,0x9c,0x91,0x98,0x54,0x4c,0x1f,0x62,0xdb,0xb6, -0x4e,0xe6,0x68,0x77,0xce,0x58,0x43,0xc7,0x44,0xb7,0x57,0x5d,0xa0,0xbd,0x7b,0x91, -0x62,0x52,0x3f,0x63,0xbd,0xce,0xe0,0x55,0x38,0xff,0xd7,0x5f,0xed,0x99,0x7d,0x80, -0xc1,0xcb,0xf4,0x44,0x89,0x1c,0x94,0x0b,0xb8,0x45,0x49,0x02,0x86,0xb7,0x32,0xdb, -0xd7,0x3a,0xf1,0x27,0x9f,0x02,0x0c,0x00,0x05,0x02,0x40,0x42,0x0f,0x00,0x0f,0x0e, -0x0b,0x0a,0x05,0x00,0x06,0x01,0x02,0x04,0x03,0x08,0x07,0x09,0x0e,0x0d,0x2c,0x45, -0xa1,0x5d,0xca,0x78,0x7e,0x4c,0xb9,0x00,0x29,0x06,0x00,0x00,0x00,0x00,0x00,0x00, -0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2f,0x59,0x5b,0x00,0x00,0x00,0x00,0x00, -0x01,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; - -/* 1 M CU, 5 lamports extra (deprecated) */ -unsigned char txn4[783] = { -0x01,0x9e,0x83,0xce,0xfa,0x47,0x4e,0x86,0x41,0xd2,0x1c,0x2d,0x29,0x2f,0x7d,0xde, -0x1e,0xa1,0x7f,0xd3,0xb4,0xfa,0x72,0x07,0xad,0xfb,0x9b,0x60,0xe3,0x1d,0x60,0x01, -0x5f,0x70,0x6f,0x99,0xbd,0x95,0x7b,0xdf,0x0e,0x8d,0xd5,0x27,0x24,0x92,0x69,0xf0, -0x14,0x49,0x33,0xa5,0xfe,0x64,0xf5,0x6e,0x22,0x05,0x41,0x7c,0xdc,0x7e,0xfc,0xed, -0x03,0x01,0x00,0x06,0x13,0xec,0x40,0xfc,0x11,0x7b,0x68,0x5b,0xa1,0x32,0x60,0x9a, -0x09,0x66,0x93,0x9e,0x54,0x06,0x6a,0x12,0x5f,0x7c,0x6e,0x6e,0x6d,0xff,0x2c,0x2c, -0x9e,0x32,0x1a,0x34,0xbf,0x0b,0x26,0xf6,0x60,0xe3,0xbf,0x82,0xb5,0x1f,0xdc,0x0d, -0x5e,0x27,0x2c,0x3a,0x52,0xea,0xe6,0x22,0x82,0x9c,0xa3,0x7c,0xe4,0x0c,0xb4,0x7b, -0xb1,0xa3,0xcd,0xcf,0xcc,0x8d,0x83,0x85,0x60,0x8b,0xdb,0x27,0x90,0x0a,0x0c,0xe3, -0x3d,0xbf,0x3c,0xca,0x79,0x7c,0x6e,0x89,0xe3,0x3e,0xa8,0x52,0xec,0xc6,0xf4,0xae, -0x8d,0x52,0xc0,0xd7,0xe3,0xf8,0x76,0xe7,0x0e,0x49,0x6e,0x7d,0x11,0x9a,0x5e,0x75, -0x67,0x04,0x3e,0x6f,0x15,0x62,0xb5,0xe4,0x8f,0x9b,0x13,0x33,0x01,0xb2,0xd8,0x45, -0x66,0x78,0xbd,0x00,0x95,0x4d,0x14,0xa9,0x42,0x80,0x3e,0xd9,0x37,0x3a,0x93,0xf2, -0x4d,0xcd,0x7e,0xf7,0xa1,0x37,0x84,0xc8,0x09,0xc9,0x8c,0x22,0xef,0xb7,0x60,0x8e, -0xec,0xda,0xd0,0xbe,0x36,0x87,0xa7,0x95,0xa1,0x23,0x62,0x20,0x9c,0x8f,0x81,0x5f, -0x93,0x4c,0x76,0x1e,0xb9,0x51,0x7d,0x05,0x8e,0x9e,0xf9,0x25,0x85,0xab,0xea,0xe5, -0x01,0xac,0xbe,0x15,0x06,0x58,0x36,0x47,0x2b,0xde,0x7d,0x79,0x58,0x1f,0x3a,0xaf, -0x98,0x6b,0x63,0xa7,0x27,0xd8,0xbd,0x67,0x1e,0xf7,0x58,0x82,0x8c,0x5c,0x16,0x29, -0xd4,0xe7,0x89,0xaf,0xea,0x4d,0xde,0xdc,0x50,0xef,0xcc,0x7c,0x5d,0x91,0x3a,0x23, -0x10,0x4d,0x04,0xae,0xa6,0x73,0x93,0xda,0x27,0x83,0x5f,0xda,0x11,0x99,0xfb,0xbd, -0x39,0xc9,0xda,0xcd,0xfb,0xef,0x22,0x13,0x99,0x3d,0xa5,0x9a,0x11,0x7e,0xc4,0x4e, -0xd5,0x3c,0x9f,0xbb,0xe4,0xb9,0xee,0xd6,0xdb,0x34,0xbb,0x41,0x53,0xba,0x36,0xb6, -0x1e,0xd1,0x02,0xa5,0x6c,0x4f,0xc6,0x95,0xb8,0x4c,0x7f,0x4a,0x4a,0x9d,0xb0,0xb1, -0xc6,0x95,0x70,0xbd,0xa1,0xd7,0x84,0x39,0x71,0x25,0xda,0x32,0xff,0xa5,0x9b,0x7b, -0xdb,0xf3,0x04,0x6c,0x4e,0xe7,0x12,0x80,0xb9,0xe2,0x70,0xb3,0x36,0xd8,0x88,0xfd, -0xfc,0xf7,0x47,0xea,0x01,0xed,0x56,0x65,0x46,0xea,0x14,0xfb,0x23,0x32,0xd4,0x0c, -0xf5,0x43,0xc8,0x0d,0x28,0x66,0x0e,0x34,0xdf,0x05,0xe2,0x31,0xb8,0x80,0x8a,0xb6, -0x35,0x8f,0x95,0x62,0xd5,0xc4,0x18,0x03,0x12,0x03,0x29,0x6d,0x19,0xbf,0x08,0xd2, -0x10,0x34,0x44,0xc0,0xa2,0xe1,0x90,0xab,0x12,0x1a,0x93,0xed,0xdf,0xf2,0x76,0x9b, -0x78,0xc0,0x0e,0x74,0x94,0x79,0xf6,0xf7,0xe7,0xbb,0xbf,0xd7,0xe0,0xe3,0xd8,0xc9, -0x28,0xe7,0x5f,0xde,0x3b,0x03,0x06,0x46,0x6f,0xe5,0x21,0x17,0x32,0xff,0xec,0xad, -0xba,0x72,0xc3,0x9b,0xe7,0xbc,0x8c,0xe5,0xbb,0xc5,0xf7,0x12,0x6b,0x2c,0x43,0x9b, -0x3a,0x40,0x00,0x00,0x00,0x20,0x95,0xdd,0x92,0x49,0x29,0xc6,0x68,0x2e,0x9f,0xf6, -0xc1,0x1b,0x0e,0x1b,0xdd,0xce,0xf2,0x9f,0x1a,0xd2,0x21,0x1e,0x89,0x2a,0x4f,0xb8, -0x8e,0xa5,0xd1,0xad,0xa1,0x85,0x0f,0x2d,0x6e,0x02,0xa4,0x7a,0xf8,0x24,0xd0,0x9a, -0xb6,0x9d,0xc4,0x2d,0x70,0xcb,0x28,0xcb,0xfa,0x24,0x9f,0xb7,0xee,0x57,0xb9,0xd2, -0x56,0xc1,0x27,0x62,0xef,0x06,0xdd,0xf6,0xe1,0xd7,0x65,0xa1,0x93,0xd9,0xcb,0xe1, -0x46,0xce,0xeb,0x79,0xac,0x1c,0xb4,0x85,0xed,0x5f,0x5b,0x37,0x91,0x3a,0x8c,0xf5, -0x85,0x7e,0xff,0x00,0xa9,0x06,0xa7,0xd5,0x17,0x19,0x2c,0x5c,0x51,0x21,0x8c,0xc9, -0x4c,0x3d,0x4a,0xf1,0x7f,0x58,0xda,0xee,0x08,0x9b,0xa1,0xfd,0x44,0xe3,0xdb,0xd9, -0x8a,0x00,0x00,0x00,0x00,0x8e,0x49,0x8f,0x61,0x98,0x49,0x25,0x4c,0x31,0x6b,0xad, -0x93,0x70,0x5d,0x16,0x07,0xbc,0xd8,0x02,0xbe,0x79,0x92,0x0a,0x47,0x32,0x13,0xf4, -0xb1,0x94,0x03,0x56,0xb1,0x54,0x68,0xa7,0xaa,0xc2,0xc3,0xc5,0xcc,0x88,0x83,0xd2, -0xbe,0x1d,0xb8,0x0e,0xfe,0x85,0x39,0xcc,0xb3,0x37,0x14,0xc3,0xfd,0x6c,0x61,0x7b, -0x84,0xdc,0x69,0xe2,0xcc,0x02,0x0d,0x00,0x09,0x00,0x40,0x42,0x0f,0x00,0x05,0x00, -0x00,0x00,0x12,0x11,0x00,0x0e,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a, -0x0b,0x0c,0x0f,0x10,0x11,0x29,0xe0,0xbd,0x77,0x84,0xcf,0x36,0x13,0x17,0x01,0x20, -0xa1,0x07,0x00,0x00,0x00,0x00,0x00,0xa0,0x00,0x00,0x00,0xa0,0xbb,0x0d,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2f,0x63,0x15,0x00,0x00,0x00,0x00,0x00}; - -unsigned char parsed[FD_TXN_MAX_SZ]; +uchar parsed[FD_TXN_MAX_SZ]; void -test_txn( uchar * payload, - ulong payload_sz, - ulong expected_max_cu, - ulong expected_fee_lamports ) { /* Excludes per-signature fee */ +test_txn( uchar const * payload, + ulong payload_sz, + ulong expected_max_cu, + ulong expected_fee_lamports ) { /* Excludes per-signature fee */ FD_TEST( fd_txn_parse( payload, payload_sz, parsed, NULL ) ); fd_txn_t * txn = (fd_txn_t*)parsed; fd_compute_budget_program_state_t state; fd_compute_budget_program_init( &state ); - uchar * addresses = payload + txn->acct_addr_off; + uchar const * addresses = payload + txn->acct_addr_off; for( ulong i=0UL; iinstr_cnt; i++ ) { if( !memcmp( addresses+FD_TXN_ACCT_ADDR_SZ*txn->instr[ i ].program_id, FD_COMPUTE_BUDGET_PROGRAM_ID, FD_TXN_ACCT_ADDR_SZ ) ) { FD_TEST( fd_compute_budget_program_parse( payload+txn->instr[ i ].data_off, txn->instr[ i ].data_sz, &state ) ); @@ -241,11 +37,13 @@ FD_FN_CONST int test_duplicate( ulong request_units_deprecated_cnt, ulong request_heap_frame_cnt, ulong set_compute_unit_limit_cnt, - ulong set_compute_unit_price_cnt ) { + ulong set_compute_unit_price_cnt, + ulong set_max_loaded_data_cnt ) { uchar const request_units_deprecated[ 9UL ] = { 0, 4,3,2,0, 8,7,6,5 }; uchar const request_heap_frame [ 5UL ] = { 1, 0,0,1,0 }; uchar const set_compute_unit_limit [ 5UL ] = { 2, 4,3,2,0 }; uchar const set_compute_unit_price [ 9UL ] = { 3, 8,7,6,5,4,3,2,1 }; + uchar const set_max_loaded_data [ 5UL ] = { 4, 4,3,2,0 }; fd_compute_budget_program_state_t state; fd_compute_budget_program_init( &state ); @@ -258,6 +56,8 @@ test_duplicate( ulong request_units_deprecated_cnt, all_valid &= fd_compute_budget_program_parse( set_compute_unit_limit, 5UL, &state ); for( ulong i=0UL; i>1; test_txn( txn2, sizeof(txn2), 1000000UL, ULONG_MAX>>1 ); /* Product>2^64 */ - *cu_limit = 1400000U; *ulamports = ULONG_MAX; test_txn( txn2, sizeof(txn2), 1400000UL, ULONG_MAX ); /* Result>2^64 */ - *cu_limit = 1400000U; *ulamports = 1UL<<44; test_txn( txn2, sizeof(txn2), 1400000UL, 24629060462183UL ); /* Product<2^64 */ - *cu_limit = 1U; *ulamports = 1UL; test_txn( txn2, sizeof(txn2), 1UL, 1UL ); /* Test ceil */ - - FD_TEST( test_duplicate( 1, 1, 0, 0 ) == 1 ); - FD_TEST( test_duplicate( 2, 0, 0, 0 ) == 0 ); - FD_TEST( test_duplicate( 0, 1, 1, 1 ) == 1 ); - FD_TEST( test_duplicate( 1, 1, 1, 1 ) == 0 ); - FD_TEST( test_duplicate( 0, 0, 2, 1 ) == 0 ); - FD_TEST( test_duplicate( 0, 0, 1, 2 ) == 0 ); - FD_TEST( test_duplicate( 1, 0, 1, 0 ) == 0 ); - FD_TEST( test_duplicate( 1, 0, 0, 1 ) == 0 ); + test_txn( txn1, txn1_sz, 1400000UL, 280000UL ); + test_txn( txn2, txn2_sz, 500000UL, 7501UL ); + test_txn( txn3, txn3_sz, 1000000UL, 0UL ); + test_txn( txn4, txn4_sz, 75000UL, 1501UL ); + test_txn( txn5, txn5_sz, 1400000UL, 28000UL ); + test_txn( txn6, txn6_sz, 60000UL, 5400UL ); + test_txn( txn7, txn7_sz, 1400000UL, 0UL ); + + uchar _txn2[ txn2_sz ]; + fd_memcpy( _txn2, txn2, txn2_sz ); + + uint * cu_limit = (uint *) &_txn2[ 260 ]; + ulong * ulamports = (ulong *) &_txn2[ 268 ]; + *cu_limit = 1000000U; *ulamports = 1000000UL; test_txn( _txn2, txn2_sz, 1000000UL, 1000000UL ); /* No overflow */ + *cu_limit = 1000000U; *ulamports = ULONG_MAX>>1; test_txn( _txn2, txn2_sz, 1000000UL, ULONG_MAX>>1 ); /* Product>2^64 */ + *cu_limit = 1400000U; *ulamports = ULONG_MAX; test_txn( _txn2, txn2_sz, 1400000UL, ULONG_MAX ); /* Result>2^64 */ + *cu_limit = 1400000U; *ulamports = 1UL<<44; test_txn( _txn2, txn2_sz, 1400000UL, 24629060462183UL ); /* Product<2^64 */ + *cu_limit = 1U; *ulamports = 1UL; test_txn( _txn2, txn2_sz, 1UL, 1UL ); /* Test ceil */ + + FD_TEST( test_duplicate( 1, 1, 0, 0, 0 ) == 0 ); + FD_TEST( test_duplicate( 2, 0, 0, 0, 0 ) == 0 ); + FD_TEST( test_duplicate( 0, 1, 1, 1, 1 ) == 1 ); + FD_TEST( test_duplicate( 1, 1, 1, 1, 0 ) == 0 ); + FD_TEST( test_duplicate( 0, 0, 2, 1, 0 ) == 0 ); + FD_TEST( test_duplicate( 0, 0, 1, 2, 0 ) == 0 ); + FD_TEST( test_duplicate( 1, 0, 1, 0, 0 ) == 0 ); + FD_TEST( test_duplicate( 1, 0, 0, 1, 0 ) == 0 ); + FD_TEST( test_duplicate( 0, 1, 1, 1, 2 ) == 0 ); + FD_TEST( test_duplicate( 0, 1, 1, 0, 1 ) == 1 ); + FD_TEST( test_duplicate( 0, 1, 0, 1, 1 ) == 1 ); + FD_TEST( test_duplicate( 0, 0, 1, 1, 1 ) == 1 ); fd_rng_delete( fd_rng_leave( rng ) );