Add slot to the error context of EpochRewardsPeriodActiveErrorData and SlotNotEpochBoundaryErrorData#6962
Conversation
|
If this PR represents a change to the public RPC API:
Thank you for keeping the RPC clients in sync with the server API @steveluscher. |
…` and `SlotNotEpochBoundaryErrorData`
f409de3 to
a0e3390
Compare
slot to the error context of EpochRewardsPeriodActiveErrorDataslot to the error context of EpochRewardsPeriodActiveErrorData and SlotNotEpochBoundaryErrorData
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6962 +/- ##
=========================================
- Coverage 83.2% 83.2% -0.1%
=========================================
Files 853 853
Lines 374698 374726 +28
=========================================
+ Hits 311800 311819 +19
- Misses 62898 62907 +9 🚀 New features to boost your workflow:
|
buffalojoec
left a comment
There was a problem hiding this comment.
The changes look fine to me, but it should probably be documented in the changelog as a breaking change with 3.0.0.
Wait, what on Earth? Why are these structs Everything still typechecks when you remove |
Yeah they are all unfortunately leaked to the public API. agave/rpc-client-api/src/lib.rs Line 4 in 78d5954 Also, it changes the object structure in the https://www.jsonrpc.org/specification#error_object
Okay, but it's really no big deal to just add a changelog entry! We're on 3.0.0 right now. |
|
😱 New commits were pushed while the automerge label was present. |
|
Except, of course, from the Rust perspective, I legit don't understand why adding a property to the error |
Rust is strongly typed, so adding a new field to a struct breaks previous versions of that struct that did not have this field. If you have a struct, you might initialize it like this: struct MyInfo {
pub id: u64,
pub count: u64,
}
let _ = MyInfo { id: 0, count: 0 };Whenever there's suddenly a new field, you'd get a compiler error telling you that you're missing a field in the initialization. Furthermore, APIs like Similarly, Going from |
|
I totally get all that about Rust. Very seriously though, I am confident that there are zero people constructing this struct in the wild, and that making it
Like, literally, we could probably replace the whole thing with |
Actually, I feel strongly enough about not repeating the same mistake over again, that I pushed 0ab1060, even though it requires another review. |
I know, but it's mostly because of this: agave/docs/src/backwards-compatibility.md Line 60 in f915e9d If you want, since it's a major release, you could see about just making the whole module private now. |
Oh no. What. Why? agave/rpc-client/src/http_sender.rs Lines 203 to 208 in f915e9d |
…rializing _old_ data by making `slot` an Option
|
Alright, here's a compromise.
|
…` and `SlotNotEpochBoundaryErrorData` (anza-xyz#6962) * Add `slot` to the error context of `EpochRewardsPeriodActiveErrorData` and `SlotNotEpochBoundaryErrorData` * Add CHANGELOG entries * Directly serialize the JSON-RPC error data, rather than bouncing it through a struct * Make `EpochRewardsPeriodActiveErrorData` from the perspective of deserializing _old_ data by making `slot` an Option
Problem
Without
sloton the error context here, clients can't localize this message. That is to say they can't convert the error code-32017or-32018to a localized message that includes the value ofslotby combining the context data with a custom message.Summary of Changes
slottoEpochRewardsPeriodActiveErrorDataSlotNotEpochBoundaryErrorDatawith aslotproperty