lighthouse/beacon_node
Mac L d06f87486a Support duplicate keys in HTTP API query strings (#2908)
## Issues Addressed

Closes #2739
Closes #2812

## Proposed Changes

Support the deserialization of query strings containing duplicate keys into their corresponding types.
As `warp` does not support this feature natively (as discussed in #2739), it relies on the external library [`serde_array_query`](https://github.com/sigp/serde_array_query) (written by @michaelsproul)

This is backwards compatible meaning that both of the following requests will produce the same output:
```
curl "http://localhost:5052/eth/v1/events?topics=head,block"
```
```
curl "http://localhost:5052/eth/v1/events?topics=head&topics=block"
```

## Additional Info

Certain error messages have changed slightly.  This only affects endpoints which accept multiple values.
For example:
```
{"code":400,"message":"BAD_REQUEST: invalid query: Invalid query string","stacktraces":[]}
```
is now
```
{"code":400,"message":"BAD_REQUEST: unable to parse query","stacktraces":[]}
```


The serve order of the endpoints `get_beacon_state_validators` and `get_beacon_state_validators_id` have flipped:
```rust
.or(get_beacon_state_validators_id.boxed())
.or(get_beacon_state_validators.boxed())
``` 
This is to ensure proper error messages when filter fallback occurs due to the use of the `and_then` filter.

## Future Work
- Cleanup / remove filter fallback behaviour by substituting `and_then` with `then` where appropriate.
- Add regression tests for HTTP API error messages.

## Credits
- @mooori for doing the ground work of investigating possible solutions within the existing Rust ecosystem.
- @michaelsproul for writing [`serde_array_query`](https://github.com/sigp/serde_array_query) and for helping debug the behaviour of the `warp` filter fallback leading to incorrect error messages.
2022-01-20 09:14:19 +00:00
..
beacon_chain Update to spec v1.1.8 (#2893) 2022-01-19 00:24:19 +00:00
client Additional networking metrics (#2549) 2021-12-22 06:17:14 +00:00
eth1 Bump crate versions (#2829) 2021-12-02 14:29:57 +11:00
execution_layer Rust 1.58 lints (#2906) 2022-01-13 22:39:58 +00:00
genesis Bump crate versions (#2829) 2021-12-02 14:29:57 +11:00
http_api Support duplicate keys in HTTP API query strings (#2908) 2022-01-20 09:14:19 +00:00
http_metrics Additional networking metrics (#2549) 2021-12-22 06:17:14 +00:00
lighthouse_network Update to spec v1.1.8 (#2893) 2022-01-19 00:24:19 +00:00
network Lazy hashing for SignedBeaconBlock in sync (#2916) 2022-01-14 07:20:54 +00:00
operation_pool Bump crate versions (#2829) 2021-12-02 14:29:57 +11:00
src Update to spec v1.1.8 (#2893) 2022-01-19 00:24:19 +00:00
store Additional networking metrics (#2549) 2021-12-22 06:17:14 +00:00
tests Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
timer Update Lighthouse Dependencies (#2818) 2021-11-18 05:08:42 +00:00
Cargo.toml v2.1.0 (#2928) 2022-01-20 03:39:41 +00:00