Commit bf09a76
committed
feat!: add block hash to log store
We want to expose some event metadata to users of Aztec.js (see: #16245).
An important metadata attribute is block hash. Block number is not enough due to the possibliity of reorgs.
Currently, in archiver nodes, logs are stored by block number, and the corresponding block hash is lost. This works at the archiver, because the archiver is designed to prune its stores and start over each time a reorg is detected.
Users who download data from the node, however, have no reasonably efficient way of detecting whether the log data they downloaded is still valid unless they also get a block hash to pin the logs they get to.
So we can bridge this gap in one of two ways:
1. Whenever the node gets a request for logs, it queries the block store to resolve block hashes from block numbers. This works because archiver provides strong guarantees that the data stored corresponds to only one chain. However, it it introduces more store reads
2. At the time of storing logs, we can also store the block hash corresponding to the block number at the moment of storing. this increments the size needed to store the logs of each indexed block by 1 Fr, but in exchange for that we can just unpack the block hash from the logs we're processing without needing extra reads from block store. It also makes block addition a bit more expensive since now we'll be potentially calculating one hash per block (although since `addBlocks` receives them and `hash()` is cached maybe it's not even the case?)
This PR implements option 2, but if I'm hitting any no-no's please let me know
Note that this PR bumps the ARCHIVER_DB_VERSION, since it modifies how we index public and contract class logs.
Closes F-2201 parent 9fdec79 commit bf09a76
File tree
7 files changed
+210
-51
lines changed- yarn-project
- archiver/src/archiver
- kv_archiver_store
- pxe/src/contract_function_simulator
- stdlib/src/logs
7 files changed
+210
-51
lines changedLines changed: 76 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
905 | 905 | | |
906 | 906 | | |
907 | 907 | | |
| 908 | + | |
908 | 909 | | |
909 | 910 | | |
910 | 911 | | |
911 | 912 | | |
912 | 913 | | |
913 | 914 | | |
914 | 915 | | |
| 916 | + | |
915 | 917 | | |
916 | 918 | | |
917 | 919 | | |
| |||
929 | 931 | | |
930 | 932 | | |
931 | 933 | | |
| 934 | + | |
932 | 935 | | |
933 | 936 | | |
934 | 937 | | |
935 | 938 | | |
936 | 939 | | |
| 940 | + | |
937 | 941 | | |
938 | 942 | | |
939 | 943 | | |
| |||
959 | 963 | | |
960 | 964 | | |
961 | 965 | | |
| 966 | + | |
962 | 967 | | |
963 | 968 | | |
964 | 969 | | |
965 | 970 | | |
966 | 971 | | |
| 972 | + | |
967 | 973 | | |
968 | 974 | | |
969 | 975 | | |
| |||
983 | 989 | | |
984 | 990 | | |
985 | 991 | | |
| 992 | + | |
986 | 993 | | |
987 | 994 | | |
988 | 995 | | |
| |||
1050 | 1057 | | |
1051 | 1058 | | |
1052 | 1059 | | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
1053 | 1071 | | |
1054 | 1072 | | |
1055 | 1073 | | |
| |||
1092 | 1110 | | |
1093 | 1111 | | |
1094 | 1112 | | |
| 1113 | + | |
1095 | 1114 | | |
1096 | | - | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
1097 | 1121 | | |
1098 | 1122 | | |
1099 | 1123 | | |
| |||
1115 | 1139 | | |
1116 | 1140 | | |
1117 | 1141 | | |
1118 | | - | |
| 1142 | + | |
1119 | 1143 | | |
1120 | 1144 | | |
1121 | 1145 | | |
| |||
1147 | 1171 | | |
1148 | 1172 | | |
1149 | 1173 | | |
1150 | | - | |
| 1174 | + | |
1151 | 1175 | | |
1152 | 1176 | | |
1153 | 1177 | | |
1154 | 1178 | | |
1155 | 1179 | | |
1156 | | - | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
1157 | 1186 | | |
1158 | 1187 | | |
1159 | 1188 | | |
1160 | 1189 | | |
1161 | 1190 | | |
1162 | 1191 | | |
1163 | | - | |
| 1192 | + | |
1164 | 1193 | | |
1165 | 1194 | | |
1166 | 1195 | | |
| |||
1171 | 1200 | | |
1172 | 1201 | | |
1173 | 1202 | | |
| 1203 | + | |
1174 | 1204 | | |
1175 | | - | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
1176 | 1211 | | |
1177 | 1212 | | |
1178 | 1213 | | |
| |||
1192 | 1227 | | |
1193 | 1228 | | |
1194 | 1229 | | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
1195 | 1264 | | |
1196 | 1265 | | |
1197 | 1266 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
0 commit comments