lighthouse/beacon_node/http_api/src
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
..
attester_duties.rs Rust 1.54.0 lints (#2483) 2021-07-30 01:11:47 +00:00
block_id.rs Use the forwards iterator more often (#2376) 2021-05-31 04:18:20 +00:00
database.rs Implement checkpoint sync (#2244) 2021-09-22 00:37:28 +00:00
lib.rs Support duplicate keys in HTTP API query strings (#2908) 2022-01-20 09:14:19 +00:00
metrics.rs Metrics and DEBG log for late gossip blocks (#2533) 2021-08-23 00:59:14 +00:00
proposer_duties.rs Rust 1.54.0 lints (#2483) 2021-07-30 01:11:47 +00:00
state_id.rs Fork schedule api (#2525) 2021-08-24 01:36:27 +00:00
sync_committees.rs Rename eth2_libp2p to lighthouse_network (#2702) 2021-10-19 00:30:39 +00:00
validator_inclusion.rs Validator monitor support for sync committees (#2476) 2021-08-31 23:31:36 +00:00
version.rs Add API version headers and map_fork_name! (#2745) 2021-10-28 01:18:04 +00:00