fanquake
61849f0464
Merge bitcoin/bitcoin#27918 : fuzz: addrman, avoid ConsumeDeserializable when possible
...
025fda0a76893d09d19ec9a6c0ba86ad11c466f7 fuzz: addrman, avoid `ConsumeDeserializable` when possible (brunoerg)
Pull request description:
Using specific functions like `ConsumeService`, `ConsumeAddress` and `ConsumeNetAddr` may be more effective than using `ConsumeDeserializable`. They always return some value while `ConsumeDeserializable` may return `std::nullopt`.
E.g.: In this part of the code, if `op_net_addr` is `std::nullopt`, we basically generated the addresses (if so) unnecessarily, because we won't be able to use them:
```cpp
std::vector<CAddress> addresses;
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
const std::optional<CAddress> opt_address = ConsumeDeserializable<CAddress>(fuzzed_data_provider);
if (!opt_address) {
break;
}
addresses.push_back(*opt_address);
}
const std::optional<CNetAddr> opt_net_addr = ConsumeDeserializable<CNetAddr>(fuzzed_data_provider);
if (opt_net_addr) {
addr_man.Add(addresses, *opt_net_addr, std::chrono::seconds{ConsumeTime(fuzzed_data_provider, 0, 100000000)});
}
```
Also, if we are not calling `Add` effectively, it would also be affect other functions that may "depend" on it.
ACKs for top commit:
dergoegge:
Code review ACK 025fda0a76893d09d19ec9a6c0ba86ad11c466f7
Tree-SHA512: 02450bec0b084c15ba0cd1cbdfbac067c8fea4ccf27be0c86d54e020f029a6c749a16d8e0558f9d6d35a7ca9db8916f180c872f09474702b5591129e9be0d192
2023-08-03 17:32:46 +01:00
..
2023-08-01 16:38:06 +01:00
2023-06-29 14:41:33 +01:00
2023-04-03 14:44:48 +01:00
2023-06-12 19:47:19 +01:00
2022-08-13 13:55:38 +01:00
2023-07-24 15:32:00 +02:00
2023-07-10 10:50:50 -03:00
2023-06-15 10:27:56 -06:00
2023-06-12 12:54:49 -04:00
2023-05-20 12:08:13 +02:00
2023-07-11 12:30:56 -04:00
2022-09-29 16:43:30 +01:00
2023-01-31 18:48:50 +01:00
2022-10-23 15:03:04 +01:00
2023-07-31 16:18:20 -04:00
2023-06-26 09:43:38 +01:00
2022-12-24 23:49:50 +00:00
2023-07-19 16:43:12 -04:00
2023-07-30 11:21:40 +01:00
2023-07-20 11:16:45 -04:00
2023-07-18 15:25:05 +01:00
2023-07-24 22:33:40 -07:00
2023-08-03 17:32:46 +01:00
2023-07-27 14:24:52 +02:00
2023-07-20 13:37:21 +01:00
2023-07-24 15:32:00 +02:00
2023-05-26 13:41:07 -03:00
2023-06-29 11:59:31 +01:00
2023-07-17 14:45:42 +01:00
2023-06-29 16:14:07 -06:00
2023-05-29 13:26:31 +02:00
2023-05-26 15:47:55 -07:00
2023-05-26 15:47:55 -07:00
2023-05-24 12:03:18 -07:00
2022-12-24 23:49:50 +00:00
2023-02-01 11:33:35 +01:00
2023-05-04 20:57:51 +01:00
2023-05-20 12:08:13 +02:00
2023-03-23 12:55:18 +01:00
2022-12-24 23:49:50 +00:00
2022-12-24 23:49:50 +00:00
2022-12-24 23:49:50 +00:00
2023-07-11 12:30:56 -04:00
2023-05-20 12:08:13 +02:00
2023-07-25 17:40:07 +02:00
2023-05-20 12:08:13 +02:00
2023-05-20 12:08:13 +02:00
2023-06-16 10:38:19 +01:00
2023-05-20 12:08:13 +02:00
2023-02-15 14:42:28 -08:00
2023-07-17 13:27:46 +02:00
2022-12-24 23:49:50 +00:00
2022-12-24 23:49:50 +00:00
2023-07-24 16:23:38 -04:00
2023-05-25 19:24:05 +02:00
2023-05-25 19:24:05 +02:00
2023-05-10 10:39:58 +02:00
2023-05-10 10:39:58 +02:00
2023-04-20 06:08:22 -07:00
2023-06-16 10:38:19 +01:00
2022-12-24 23:49:50 +00:00
2022-12-24 23:49:50 +00:00
2023-03-23 19:38:38 +01:00
2023-03-23 19:38:38 +01:00
2023-07-25 17:40:07 +02:00
2023-07-25 17:40:07 +02:00
2023-05-20 12:08:13 +02:00
2023-01-31 11:50:10 +00:00
2023-03-23 12:55:18 +01:00
2023-07-24 15:32:35 +02:00
2023-03-15 16:42:42 +01:00
2023-03-15 16:42:42 +01:00
2022-12-24 23:49:50 +00:00
2022-12-24 23:49:50 +00:00
2023-04-19 10:48:30 +02:00
2023-05-09 18:48:52 +02:00
2023-05-20 12:08:13 +02:00
2023-03-23 12:52:00 +01:00
2023-04-03 14:41:22 +01:00
2022-12-24 23:49:50 +00:00
2023-07-12 10:01:51 +02:00
2022-12-12 21:06:04 +00:00
2022-12-12 21:06:04 +00:00
2023-05-09 18:47:14 +02:00
2023-06-28 12:20:25 +01:00
2022-12-24 23:49:50 +00:00
2023-05-20 12:08:13 +02:00
2023-03-23 12:55:18 +01:00
2023-07-25 14:34:15 +01:00
2023-07-10 10:47:17 -03:00
2023-05-25 06:30:10 +00:00
2023-06-23 14:22:33 -04:00
2023-06-23 14:22:33 -04:00
2023-06-15 10:27:56 -06:00
2023-06-15 10:27:56 -06:00
2023-08-01 16:38:06 +01:00
2023-07-12 09:59:55 +02:00
2022-06-23 15:33:01 +02:00
2022-07-21 10:42:09 +01:00
2023-02-27 13:53:29 +00:00
2023-02-03 22:33:14 +01:00
2022-09-13 17:15:17 +01:00
2022-11-17 14:52:45 +00:00
2023-07-19 10:26:11 +01:00
2023-07-27 14:24:52 +02:00
2023-06-16 10:38:19 +01:00
2023-01-28 15:24:13 +00:00
2023-03-23 19:38:38 +01:00
2023-05-30 11:39:59 -04:00
2022-12-24 23:49:50 +00:00
2023-07-24 18:35:30 +02:00
2023-07-24 18:35:30 +02:00
2022-12-24 23:49:50 +00:00
2023-07-17 13:27:46 +02:00
2023-07-13 13:50:58 -04:00
2023-06-05 11:02:47 -04:00
2023-07-17 13:27:46 +02:00
2023-06-28 16:35:45 -05:00
2023-05-26 13:41:07 -03:00
2022-12-24 23:49:50 +00:00
2022-12-24 23:49:50 +00:00
2023-04-16 23:48:05 +02:00
2022-12-24 23:49:50 +00:00
2022-12-24 23:49:50 +00:00
2022-12-24 23:49:50 +00:00
2023-03-26 15:49:52 +02:00
2023-07-11 19:26:52 +02:00
2023-05-15 10:18:58 +02:00
2023-04-21 14:06:12 -04:00
2023-04-21 14:06:12 -04:00
2023-06-23 14:22:33 -04:00
2023-06-27 10:13:37 +02:00
2023-06-30 12:09:44 +02:00
2023-06-30 12:09:44 +02:00
2023-04-03 14:44:48 +01:00
2023-06-12 10:24:14 -03:00
2023-01-12 13:42:44 +00:00
2023-06-16 10:38:19 +01:00
2022-12-24 23:49:50 +00:00
2023-06-30 12:09:45 +02:00
2023-06-28 09:52:33 +02:00
2023-06-28 09:52:33 +02:00
2023-05-20 12:08:13 +02:00
2023-07-24 15:32:35 +02:00
2023-07-19 18:12:42 +02:00
2023-07-19 18:12:42 +02:00
2023-01-25 09:33:26 +01:00
2023-04-19 10:48:30 +02:00
2022-12-24 23:49:50 +00:00
2023-01-31 11:50:10 +00:00
2023-06-16 10:38:19 +01:00
2023-03-23 12:55:18 +01:00
2023-06-28 09:52:27 +02:00
2023-06-28 09:52:27 +02:00
2023-07-22 07:46:49 +01:00
2023-07-22 07:46:49 +01:00
2023-06-20 10:23:08 +02:00
2023-06-20 10:23:08 +02:00
2023-07-17 13:27:46 +02:00
2022-12-10 14:34:44 -06:00
2023-06-28 15:12:12 -04:00
2023-07-31 16:18:20 -04:00
2023-07-24 16:27:04 -04:00
2023-02-01 11:33:35 +01:00
2023-01-05 09:05:14 +00:00
2023-05-15 10:18:58 +02:00
2023-01-03 19:31:29 -06:00
2022-12-24 23:49:50 +00:00
2022-12-24 23:49:50 +00:00
2023-05-20 12:08:13 +02:00