Line data Source code
1 : #ifndef HEADER_fd_src_disco_pack_fd_pack_tip_prog_blacklist_h
2 : #define HEADER_fd_src_disco_pack_fd_pack_tip_prog_blacklist_h
3 :
4 : #include "../../ballet/txn/fd_txn.h" /* for fd_acct_addr_t */
5 : #include "../../ballet/fd_ballet_base.h"
6 :
7 : #define MAP_PERFECT_NAME fd_pack_tip_prog_blacklist
8 : #define MAP_PERFECT_LG_TBL_SZ 5
9 : #define MAP_PERFECT_T fd_acct_addr_t
10 379797 : #define MAP_PERFECT_HASH_C 240642447U
11 : #define MAP_PERFECT_KEY b
12 : #define MAP_PERFECT_KEY_T fd_acct_addr_t const *
13 : #define MAP_PERFECT_ZERO_KEY (0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0)
14 : #define MAP_PERFECT_COMPLEX_KEY 1
15 379797 : #define MAP_PERFECT_KEYS_EQUAL(k1,k2) (!memcmp( (k1), (k2), 32UL ))
16 :
17 379797 : #define PERFECT_HASH( u ) (((MAP_PERFECT_HASH_C*(u))>>27)&0x1FU)
18 :
19 : #define MAP_PERFECT_HASH_PP( a00,a01,a02,a03,a04,a05,a06,a07,a08,a09,a10,a11,a12,a13,a14,a15, \
20 : a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31) \
21 : PERFECT_HASH( (a08 | (a09<<8) | (a10<<16) | (a11<<24)) )
22 379797 : #define MAP_PERFECT_HASH_R( ptr ) PERFECT_HASH( fd_uint_load_4( (uchar const *)ptr->b + 8UL ) )
23 :
24 : /* Mainnet tip payment program */
25 : #define _T1pyyaTNZsKv2WcRAB8oVnk93mLJw2XzjtVYqCsaHqt 0x06U,0xaaU,0x09U,0x54U,0x8bU,0x50U,0x47U,0x6aU,0xd4U,0x62U,0xf9U,0x1fU,0x89U,0xa3U,0x01U,0x50U, \
26 : 0x33U,0x26U,0x4fU,0xc9U,0xabU,0xd5U,0x27U,0x00U,0x20U,0xa9U,0xd1U,0x42U,0x33U,0x47U,0x42U,0xfbU
27 : /* Testnet tip payment program */
28 : #define _DCN82qDxJAQuSqHhv2BJuAgi41SPeKZB5ioBCTMNDrCC 0xb5U,0x35U,0x83U,0x8dU,0x16U,0x31U,0x39U,0x77U,0xe9U,0xbfU,0xddU,0xfcU,0xe2U,0x14U,0x57U,0x81U, \
29 : 0xf5U,0x24U,0x0bU,0x69U,0x71U,0x03U,0x6bU,0x3bU,0x9fU,0x62U,0x11U,0x07U,0x1dU,0x0dU,0x93U,0x1dU
30 : /* Mainnet tip payment config account */
31 : #define _HgzT81VF1xZ3FT9Eq1pHhea7Wcfq2bv4tWTP3VvJ8Y9D 0xf7U,0xf9U,0x9aU,0x09U,0x42U,0xfaU,0xc7U,0x88U,0x05U,0x49U,0x43U,0xabU,0xbcU,0xf9U,0x46U,0xb1U, \
32 : 0xf9U,0xb9U,0x16U,0xcbU,0xe1U,0x0aU,0xedU,0xcfU,0xa9U,0x96U,0x76U,0x65U,0x37U,0x1cU,0xa2U,0x80U
33 : /* Testnet tip payment config account */
34 : #define _AXaHLTKzVyRUccE8bPskqsnc1YcTd648PjmMwKWS7R6N 0x8dU,0x8eU,0x3dU,0x00U,0x46U,0x5aU,0x5cU,0xa3U,0x4eU,0x92U,0x0dU,0x79U,0x8eU,0xd8U,0x35U,0xecU, \
35 : 0x86U,0x45U,0x36U,0x7aU,0x12U,0x38U,0x74U,0x38U,0xb1U,0x6aU,0x85U,0x39U,0x80U,0x37U,0x2eU,0xb7U
36 : /* Mainnet tip accounts 0-7 */
37 : #define _96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5 0x78U,0x52U,0x1cU,0xb1U,0x79U,0xceU,0xbbU,0x85U,0x89U,0xb5U,0x56U,0xa2U,0xd5U,0xecU,0x94U,0xd2U, \
38 : 0x49U,0x86U,0x82U,0xfdU,0xf9U,0xbbU,0x2aU,0xf5U,0xadU,0x64U,0xe4U,0x91U,0xccU,0x41U,0x53U,0xdaU
39 : #define _HFqU5x63VTqvQss8hp11i4wVV8bD44PvwucfZ2bU7gRe 0xf1U,0x87U,0xecU,0x87U,0xd1U,0xf7U,0x45U,0xcbU,0x3aU,0x03U,0x38U,0x4aU,0x26U,0xa6U,0x9eU,0xdaU, \
40 : 0x0cU,0xa2U,0xd1U,0xaaU,0x0fU,0x41U,0xe4U,0x24U,0x16U,0x37U,0x7eU,0x91U,0xffU,0x5bU,0x5dU,0x31U
41 : #define _Cw8CFyM9FkoMi7K7Crf6HNQqf4uEMzpKw6QNghXLvLkY 0xb1U,0x4eU,0x0dU,0xe5U,0x5eU,0x9fU,0xbaU,0x86U,0x39U,0x6eU,0xbfU,0xd5U,0x48U,0xcfU,0xf8U,0xc9U, \
42 : 0x20U,0x11U,0xeaU,0xc7U,0xb7U,0x5bU,0xaaU,0x9bU,0x2dU,0x9cU,0x6aU,0x86U,0xf5U,0xa1U,0x71U,0x41U
43 : #define _ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49 0x88U,0xf1U,0xffU,0xa3U,0xa2U,0xdfU,0xe6U,0x17U,0xbdU,0xc4U,0xe3U,0x57U,0x32U,0x51U,0xa3U,0x22U, \
44 : 0xe3U,0xfcU,0xaeU,0x81U,0xe5U,0xa4U,0x57U,0x39U,0x0eU,0x64U,0x75U,0x1cU,0x00U,0xa4U,0x65U,0xe2U
45 : #define _DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh 0xbcU,0x2bU,0x57U,0x06U,0x5eU,0xf1U,0xddU,0x66U,0x54U,0x30U,0xbeU,0x60U,0x6bU,0xa6U,0x59U,0x6cU, \
46 : 0x02U,0x95U,0x30U,0x1bU,0xadU,0xefU,0x8bU,0x5aU,0xfcU,0x41U,0x01U,0x41U,0x50U,0xf4U,0x12U,0x74U
47 : #define _ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt 0x89U,0x07U,0x7dU,0x55U,0xa5U,0xbbU,0x13U,0x30U,0x76U,0x3eU,0xb7U,0x67U,0xf5U,0x5eU,0xc0U,0x77U, \
48 : 0xb4U,0x1aU,0x0dU,0x07U,0x5fU,0x7dU,0xe1U,0xd7U,0x3fU,0xbaU,0xcaU,0x3cU,0x63U,0xd5U,0x54U,0x71U
49 : #define _DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL 0xbfU,0x97U,0x1bU,0x59U,0x10U,0x8bU,0x5bU,0x85U,0xa0U,0x4fU,0xb0U,0x93U,0xf1U,0xe2U,0x1bU,0x4eU, \
50 : 0x3fU,0xd4U,0xc4U,0xc8U,0xf4U,0x87U,0xddU,0x09U,0xb9U,0x57U,0x52U,0x76U,0x9fU,0x0dU,0xd8U,0xc3U
51 : #define _3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT 0x20U,0x26U,0x10U,0x1eU,0xc2U,0x03U,0x28U,0x96U,0x4aU,0x32U,0xabU,0xabU,0x13U,0x6cU,0x54U,0x05U, \
52 : 0xb9U,0x1fU,0x3aU,0xe3U,0x8eU,0xe4U,0xf6U,0x4cU,0xb6U,0xbdU,0xe8U,0x79U,0xb8U,0x68U,0x38U,0xd2U
53 :
54 : /* Testnet tip accounts 0-7 */
55 : #define _BkMx5bRzQeP6tUZgzEs3xeDWJfQiLYvNDqSgmGZKYJDq 0x9fU,0xb0U,0x88U,0x29U,0xddU,0x15U,0xf4U,0x5dU,0x12U,0x90U,0x6fU,0xaeU,0x14U,0xe0U,0x98U,0x59U, \
56 : 0xc8U,0x5aU,0x08U,0x5aU,0xe5U,0xabU,0xddU,0x18U,0xd4U,0x06U,0x6eU,0xcbU,0xaeU,0x33U,0x59U,0x04U
57 : #define _CwWZzvRgmxj9WLLhdoWUVrHZ1J8db3w2iptKuAitHqoC 0xb1U,0x67U,0x5aU,0x84U,0xd4U,0x5cU,0xc8U,0x0eU,0xe2U,0x8bU,0x61U,0xcbU,0x77U,0x00U,0x57U,0x75U, \
58 : 0xcbU,0xecU,0x91U,0xc3U,0xb2U,0x0dU,0x02U,0x7dU,0x22U,0x23U,0x45U,0x57U,0xcdU,0xf0U,0xa2U,0xc7U
59 : #define _4uRnem4BfVpZBv7kShVxUYtcipscgZMSHi3B9CSL6gAA 0x3aU,0x01U,0x4aU,0x29U,0xbaU,0x3dU,0xc1U,0x18U,0x72U,0x58U,0x86U,0x66U,0x5bU,0xbcU,0xd4U,0xb1U, \
60 : 0x22U,0x11U,0x8bU,0x6dU,0x7aU,0xbbU,0x97U,0x68U,0x17U,0xd1U,0xabU,0x46U,0x4fU,0x0bU,0x84U,0xe7U
61 : #define _AzfhMPcx3qjbvCK3UUy868qmc5L451W341cpFqdL3EBe 0x94U,0x7fU,0x0aU,0xb6U,0x0eU,0xc2U,0xb3U,0x78U,0xd7U,0xe5U,0x26U,0xfeU,0xc0U,0x0aU,0xe4U,0x83U, \
62 : 0x85U,0x6fU,0x7cU,0xfbU,0x80U,0x80U,0x9cU,0x93U,0x9dU,0xbbU,0xcfU,0x59U,0xf9U,0x55U,0x78U,0x3dU
63 : #define _84DrGKhycCUGfLzw8hXsUYX9SnWdh2wW3ozsTPrC5xyg 0x68U,0xd5U,0x14U,0x6aU,0xceU,0x68U,0x5eU,0x90U,0x68U,0x46U,0xaeU,0xebU,0x49U,0x25U,0xfcU,0xe3U, \
64 : 0xedU,0xffU,0xd2U,0x69U,0x2cU,0x06U,0x03U,0xe5U,0x33U,0x2cU,0x02U,0x38U,0xfcU,0x39U,0x4aU,0x03U
65 : #define _7aewvu8fMf1DK4fKoMXKfs3h3wpAQ7r7D8T1C71LmMF 0x01U,0xafU,0x89U,0xb0U,0x58U,0xdcU,0xafU,0x4dU,0x6dU,0x7aU,0xa0U,0x9cU,0xf9U,0x7cU,0xfdU,0xf3U, \
66 : 0xc1U,0x57U,0xf4U,0x4dU,0x89U,0x61U,0xcdU,0x63U,0x30U,0x20U,0xf2U,0x74U,0x00U,0x99U,0x1eU,0x3eU
67 : #define _G2d63CEgKBdgtpYT2BuheYQ9HFuFCenuHLNyKVpqAuSD 0xdfU,0x49U,0xb0U,0x30U,0xe2U,0xa5U,0x16U,0x75U,0xfbU,0x82U,0xd4U,0x13U,0x7fU,0x96U,0x9aU,0x79U, \
68 : 0x8fU,0xc4U,0xa5U,0x91U,0xccU,0xdaU,0x47U,0x56U,0x16U,0x37U,0xa7U,0x60U,0x0eU,0xd6U,0xf9U,0xceU
69 : #define _F7ThiQUBYiEcyaxpmMuUeACdoiSLKg4SZZ8JSfpFNwAf 0xd1U,0xabU,0x4bU,0x38U,0x6aU,0x2eU,0x14U,0x66U,0x41U,0x55U,0xedU,0xc4U,0xb8U,0xa1U,0x10U,0xdeU, \
70 : 0xfbU,0x01U,0x17U,0x53U,0x34U,0x51U,0xaeU,0x60U,0xb5U,0xdaU,0x02U,0xc2U,0x7eU,0xe8U,0xa7U,0x50U
71 :
72 : /* This blacklist is really two different blacklists: one for
73 : transactions that come from bundles and another for transactions that
74 : don't come from bundles. For bundles, we only prevent them from
75 : using the tip payment program. That prevents an attack where someone
76 : submits a bundle that changes the tip receiver to themself, allowing
77 : them to steal the rest of the tips for the slot. For non-bundles, we
78 : prevent the tip program for the same reason, but we also prevent
79 : access to the tip accounts and the config accounts, just to prevent
80 : potential contention.
81 :
82 : To implement this, the hash value is chosen specially. The first two
83 : keys, the mainnet and testnet tip payment programs, respectively map
84 : to keys 1 and 0. This means we can do a quick check: lookup each
85 : pubkey in the map. If it comes from a bundle add the additional
86 : check that the index is <= 1 before throwing the transaction out. */
87 : #define MAP_PERFECT_0 ( _T1pyyaTNZsKv2WcRAB8oVnk93mLJw2XzjtVYqCsaHqt ),
88 : #define MAP_PERFECT_1 ( _DCN82qDxJAQuSqHhv2BJuAgi41SPeKZB5ioBCTMNDrCC ),
89 : #define MAP_PERFECT_2 ( _HgzT81VF1xZ3FT9Eq1pHhea7Wcfq2bv4tWTP3VvJ8Y9D ),
90 : #define MAP_PERFECT_3 ( _AXaHLTKzVyRUccE8bPskqsnc1YcTd648PjmMwKWS7R6N ),
91 : #define MAP_PERFECT_4 ( _96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5 ),
92 : #define MAP_PERFECT_5 ( _HFqU5x63VTqvQss8hp11i4wVV8bD44PvwucfZ2bU7gRe ),
93 : #define MAP_PERFECT_6 ( _Cw8CFyM9FkoMi7K7Crf6HNQqf4uEMzpKw6QNghXLvLkY ),
94 : #define MAP_PERFECT_7 ( _ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49 ),
95 : #define MAP_PERFECT_8 ( _DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh ),
96 : #define MAP_PERFECT_9 ( _ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt ),
97 : #define MAP_PERFECT_10 ( _DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL ),
98 : #define MAP_PERFECT_11 ( _3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT ),
99 : #define MAP_PERFECT_12 ( _BkMx5bRzQeP6tUZgzEs3xeDWJfQiLYvNDqSgmGZKYJDq ),
100 : #define MAP_PERFECT_13 ( _CwWZzvRgmxj9WLLhdoWUVrHZ1J8db3w2iptKuAitHqoC ),
101 : #define MAP_PERFECT_14 ( _4uRnem4BfVpZBv7kShVxUYtcipscgZMSHi3B9CSL6gAA ),
102 : #define MAP_PERFECT_15 ( _AzfhMPcx3qjbvCK3UUy868qmc5L451W341cpFqdL3EBe ),
103 : #define MAP_PERFECT_16 ( _84DrGKhycCUGfLzw8hXsUYX9SnWdh2wW3ozsTPrC5xyg ),
104 : #define MAP_PERFECT_17 ( _7aewvu8fMf1DK4fKoMXKfs3h3wpAQ7r7D8T1C71LmMF ),
105 : #define MAP_PERFECT_18 ( _G2d63CEgKBdgtpYT2BuheYQ9HFuFCenuHLNyKVpqAuSD ),
106 : #define MAP_PERFECT_19 ( _F7ThiQUBYiEcyaxpmMuUeACdoiSLKg4SZZ8JSfpFNwAf ),
107 :
108 : #include "../../util/tmpl/fd_map_perfect.c"
109 : #undef PERFECT_HASH
110 :
111 : /* fd_pack_tip_prog_check_blacklist checks if a transaction that uses the
112 : specified account address should be allowed to execute, assuming
113 : Firedancer is configured to use a bundle engine. acct points to the
114 : specified account address, which has no particular alignment
115 : constraint. Returns a value in {0, 1, 3} with the following meaning:
116 : 0: the specified account is allowed in any transaction
117 : 1: the specified account is forbidden for non-bundle transactions
118 : but allowed for bundle transactions.
119 : 3: the specified account is forbidden for both bundle and non-bundle
120 : transactions.
121 : (the value 2 is unused but reserved in for accounts that are
122 : forbidden in bundle transaction but allowed in non-bundle
123 : transactions. You can maybe make an argument to include consensus
124 : accounts in this group, but I don't see a need to)
125 :
126 : The return values are chosen to facilitate aggregation using bitwise
127 : or. */
128 : static inline int
129 379731 : fd_pack_tip_prog_check_blacklist( fd_acct_addr_t const * acct ) {
130 379731 : uint hash = fd_pack_tip_prog_blacklist_hash_or_default( acct );
131 379731 : return (hash!=UINT_MAX) + 2*(hash<=1U);
132 : /* GCC inserts a branch in the more readable version:
133 : return fd_int_if( hash==UINT_MAX, 0, fd_int_if( hash<=1U, 3, 1 ) );
134 : */
135 379731 : }
136 :
137 : /* fd_pack_tip_is_tip_account checks if an account address is a a tip
138 : account or not. If it is, it returns 1, otherwise it returns 0. The
139 : hash of the tip program accounts map to <=1 and the config accounts
140 : map to >=30. */
141 :
142 : static inline int
143 66 : fd_pack_tip_is_tip_account( fd_acct_addr_t const * acct ) {
144 66 : uint hash = fd_pack_tip_prog_blacklist_hash_or_default( acct );
145 66 : return (hash!=UINT_MAX) && (hash>1U) && (hash<30U);
146 66 : }
147 :
148 : #undef _T1pyyaTNZsKv2WcRAB8oVnk93mLJw2XzjtVYqCsaHqt
149 : #undef _DCN82qDxJAQuSqHhv2BJuAgi41SPeKZB5ioBCTMNDrCC
150 : #undef _HgzT81VF1xZ3FT9Eq1pHhea7Wcfq2bv4tWTP3VvJ8Y9D
151 : #undef _AXaHLTKzVyRUccE8bPskqsnc1YcTd648PjmMwKWS7R6N
152 : #undef _96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5
153 : #undef _HFqU5x63VTqvQss8hp11i4wVV8bD44PvwucfZ2bU7gRe
154 : #undef _Cw8CFyM9FkoMi7K7Crf6HNQqf4uEMzpKw6QNghXLvLkY
155 : #undef _ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49
156 : #undef _DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh
157 : #undef _ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt
158 : #undef _DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL
159 : #undef _3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT
160 : #undef _BkMx5bRzQeP6tUZgzEs3xeDWJfQiLYvNDqSgmGZKYJDq
161 : #undef _CwWZzvRgmxj9WLLhdoWUVrHZ1J8db3w2iptKuAitHqoC
162 : #undef _4uRnem4BfVpZBv7kShVxUYtcipscgZMSHi3B9CSL6gAA
163 : #undef _AzfhMPcx3qjbvCK3UUy868qmc5L451W341cpFqdL3EBe
164 : #undef _84DrGKhycCUGfLzw8hXsUYX9SnWdh2wW3ozsTPrC5xyg
165 : #undef _7aewvu8fMf1DK4fKoMXKfs3h3wpAQ7r7D8T1C71LmMF
166 : #undef _G2d63CEgKBdgtpYT2BuheYQ9HFuFCenuHLNyKVpqAuSD
167 : #undef _F7ThiQUBYiEcyaxpmMuUeACdoiSLKg4SZZ8JSfpFNwAf
168 :
169 : #endif /* HEADER_fd_src_disco_pack_fd_pack_tip_prog_blacklist_h */
|