#Development Chat
1 messages · Page 3 of 1
The only issue with having it in model would be that model would conditionally depend on futures-core
@ocean nest I think I will have a look at the Docker stuff and see if I can get it running again.
(If we go the trait route)
Yeah that was one of the reasons I think a twilight-gateway-model crate or something could work
Though it would have to be updated in lockstep with twilight-model
At least major updates
eh
the issue is
with the extension trait you'll still depend on gateway for the message type
and we don't want circular dependencies
model can't depend on gateway
Argh you are right, hmm
we could move the message type to the new crate too
having it in model is definitely wrong
that would defeat the purpose a bit tho
gateway would transitively depend on model again
:^)
twilight-gateway-types <- twilight-gateway-model -> twilight-model
^
|
twilight-gateway
This seems wrong as well
wait that is wrong
I'm not too sure if this is worth having to add two new crates
Yeah that seems messy
@wild marlin the docker failures are because recent nightlies removed -Z gcc-ld
ah
I can fix it as well, been doing docker musl aarch stuff at work anyway
should be as easy as using a different option I guess
oh
tbh we can just use -fuse-ld
exists since GCC 9
I got an MVP extension trait working (taking &mut self to avoid borrow checker issues)
Also, the original reason for parse being public was that Event::GatewayClose didn't exist and it felt cruel for users to have to re-implement it if they needed access to close codes. With Event::GatewayClose and a Stream extension trait (Result<Message, Err> -> Result<Option<Event>, Err>) I don't think it needs to remain public.
we could try locally after downgrading the metrics crate
It should remain public but I'll take a look at my code again xD
I'll revisit this later but I think this is the only way I'm able to do exactly this
I need the raw message and the parsed event later
That seems more like a hack
I think for low-level usage, deserialize_wanted should just remain public
If it's supposed to be low-level then its signature ought to be String -> Result<Option<GatewayEvent>, Err> instead of Result<Message, Err> -> Result<Option<Event>, Err>
for which method? Currently deserialize_wanted takes Message and EventTypeFlags which seems good to me
the stream extension should take EventTypeFlags and go from Result<Message, Err> to Result<Option<Event>, Err>, yeah
it can just call deserialize_wanted
I meant that parse should be kept as is then and deserialize_wanted should not be kept as it's not as low level
Ah. Yeah I'm totally fine with keeping parse instead
i'll try to look at it this weekend. but things have been crazy busy for me
TBH this is the sort of thing we could still change after a release candidate
if your only remaining concern was the From impls I hope that isn't too much to review
And if you don't find time, just let us know and I guess we'll just merge it and see what the feedback to the rc looks like
In the end this is mostly just API design, we probably won't get it 100% right initially
i think so but i'll try to take a look at it to be sure, it has been a while
I named the stream extension method deserialize but I'm totally open to changing it to something better
I think naming it something like deserialize_next might be more descriptive
And matches what it does more precisely
or parse_next if we're keeping the parse method for low-level usage
I dislike adding next to it since it doesn't poll the stream for you (though that might be an even better behaviour?). Currently it's like filter_map except that it takes &mut self instead of self
I.e. instead of returning a type implementing Stream it could return a type implementing Future (like StreamExt::next)
then we might even call it next_event lol
I think we should rename the returned struct to Events and the method events that at least to me seems like how others are naming a streamExt
Also maybe we should call it something else than StreamExt maybe EventStreamExt? or what do you think+
It is so weird to call it events
But maybe I'm wrong, I'll have to read the source again
events as a name would make sense if it creates a new stream
but not if it polls and deserializes
Praxis is always calling extension trait's {Origin}Ext, import conflicts can be solved by underscore import (use twilight_gateway::StreamExt as _)
The tokio StreamExt docs does not agree that is a good idea o
which iirc we wanted to avoid
An extension trait for the Stream trait that provides a variety of convenient combinator functions.
that's specifically referring to futures_util::StreamExt which collides with some methods of tokio_stream::StreamExt (like tokio_stream::StreamExt::next and futures_util::StreamExt::next). But no other stream extension defines a events method so it should be fine for us
That's cause we don't want to replicate Shard's methods. But the shard remains accessible right now and the stream is a private type
Can you access the stream inside of the event loop?
is it not exclusivly held by the EventStream?
You can
I think the stream is dropped immediately
And recreated on the new iteration
But I'll check the PR again now to see what you did
that's right
Ahh makes sense
let mut stream = shard.events(EventTypeFlags::all());
while let Some(item) = stream.next().await {
// borrow check error
// printlin!("{:?}", shard.id());
}
yeah since we create a new stream in the loop and call .next on it, it works
this is actually really neat
It wasn't what I originally envisioned but it's also not bad
I wanted an extension that added a method to a stream that yields messages which functions like next but also calls parse
creating a new stream is just as viable
although I believe a new stream is only really superior if you can make use of the stream by not re-creating it
stream.events(...).next() vs stream.next_event(...), basically
most stream methods are free, but not all (like timeout(), which does a syscall + registers a tokio timer) so to avoid footguns it might be better to not return a stream
With next_event(...) we'd just have to return a type that implements Future
should be very straightforward
delegate to poll_next and call parse
In fact, we could even bump our msrv and have it be an async fn directly
or just make it a direct method on Shard without a StreamExt trait at all
I'm against that since we have poll_next so why not use it
1.75 is a tad bit too recent for my taste as well
Nah, with an extension you can do things like stream.filter(...).next_event(...)
not that it would make a lot of sense but I prefer at least having the option
The problem is that filter and pretty much all stream methods take self such that it's tricky or impossible to access the shard afterwards
I don't see why you'd filter away raw websocket messages anyways, next_event would do that for you
but having the method on the shard directly just feels wrong
@wild marlin what do you think
Tbh I like the next_event method the most as that is the simplest way, and we could make the raw stream accessible if users want it. If that method live in the trait or the stream itself I am not sure
I think both could work, and if we put it in the trait it allows some more experiments with where it lives in the future
opted for StreamExt::next_event
Nice, let's try to get it merged this weekend
@karmic aurora Why was the examples/gateway-parallel.rs example removed?
I think we should have a least one rather simple example using multiple shards, at the moment it is only the reshard example
Made a review and apart from that it looks good.
I did nit about that too but the README examples are exactly that
Then I think we should probably just duplicate it
I like having examples in the folder
But if you others have a differing opinion then it is fine
I want to follow the precedence set in #2127
We don't duplicate the current README examples in /examples/
I just think it is a bit odd that the examples we have is not how most want to use it
But yeah feel free to merge
= note: the following trait bounds were not satisfied:
`twilight_gateway::Shard<Arc<InMemoryQueue>>: futures_util::Stream`
which is required by `twilight_gateway::Shard<Arc<InMemoryQueue>>: futures_util::StreamExt`
what did I miss
twilight_gateway::Shard<InMemoryQueue> implements it
Versions?
i use git deps
for all crates
well that is problematic
error[E0277]: the trait bound `Arc<InMemoryQueue>: Queue` is not satisfied
--> twilight-gateway/src/shard.rs:969:22
|
969 | assert_impl_all!(Shard<Arc<InMemoryQueue>>: Stream);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Queue` is not implemented for `Arc<InMemoryQueue>`
|
= help: the following other types implement trait `Queue`:
InMemoryQueue
&T
ah nvm InMemoryQueue is clone now
@silent marsh its annoying to test tokio-websockets locally, it seems that the non msrv thing might be broken
And sorry for the review after you merged it 
for testing runs fine, doc-tests run into a rustc bug tho
us being behind the latest api changes I guess. if anyone wants to bring us up to date, we could reimburse you for your work
I'll try to find some time to work on the lib
Indeed, I've been very busy with school stuff =.=
@karmic aurora https://github.com/twilight-rs/twilight/pull/2235 what's the status of this PR? may I take it from there to add the field to the cache?
We've been lagging behind on PRs.. well
also for the generic cache https://github.com/twilight-rs/twilight/pull/2179
^^ should this be merged
that's the one PR holding back a release, Erk had some concerns that I'll address when I find some time
maaaaybe I can do it this evening
great
I have some private conversation with Adrian about what I think should be changed when he has time for it
Ahh I should read the rest of the chat
ahhh
understood
ahash 0.8.8 (via simd-json -> halfbrown -> hasbrown) bumped its MSRV to 1.72 and broke CI
Do we want to bump our MSRV just because of that
well maintaining different MSRVs for different feature combinations is meh
creates confusion for users
Agreed
Generally speaking, 4-5 releases old is fine
yeah 4 releases back
That's about a little more than half a year
I guess we can push ahead and bump the MSRV to 1.72
yeah feel free to PR it
I'll get to it today after I finish up the final steps to rust-lang/rust 120840 :v
@wild marlin @karmic aurora @jaunty jewel I've updated #2179 with Erk's idea (basically collecting the trait bounds into a supertrait). This makes the code more readable, it's essentially just an alias for the generics. I've had some talk with Erk about the naming of these types, but overall I think what we have now is fine and in line with the names of the other new traits introduced.
And I'll PR the MSRV bump
seems like ahash is backing away from the MSRV change but no new release yet
i think we should still bump it
having headroom is always nice and it allows for some refactorings
since we stay on the same minor release for quite a while now apparently, we should make some space for newer language features to be used in PRs
well indeed
I'll do the pr tmr on next
don't forget to run cargo clippy --fix and update the badges

hmm for some reason github is broken when I try to approve the changes, but maybe it is just the bad train internet
Now it went through, in the 3rd attempt
Actually I'll PR the MSRV bump really quick after #2316 as well... I just want to be done xD
But without CI there is no point in merging anything
Hmm now that I'm looking at it, I assume vilgot wants #2315 as well
Can someone clarify what "in order" means here? https://discord.com/developers/docs/topics/gateway#sharding-max-concurrency
My understanding is that the intra-bucket order doesn't matter but is it really the case that each rate_limit_key must be the minimum shard? I've never seen any library, including ours, handling this. I've written a patch that switches to priority queues, but I'm unsure whether or not to PR it.
I would assume this would trigger bugs during mass-disconnects…
Do an RC
any reviewers?
type annotations needed for `InMemoryCache<CacheModels>`
cannot satisfy `_: CacheableModels`
the trait `CacheableModels` is implemented for `DefaultCacheModels`rustcClick for full compiler diagnostic
@karmic aurora btw compiler still needs it
that's because new is defined in the impl<CacheModels: CacheableModels> InMemoryCache<CacheModels> section
but I don't want to get rid of the constructor for everyone with custom types
til
we could add a new new_default() instead
but i think that doesn't really make up for it
PR is rebased, waiting for CI then I'll merge
that's the kind of thing we'll find out in feedback from RCs i guess
I'll head to bed, once we get another review on #2315 I will do RCs tomorrow

I approved and I’ll merge
I'll do the releases now
Gonna have some fun writing changelogs ^~^
lol our changelog script broke
newer cargo versions changed output of cargo metadata --no-deps --format-version 1
I thought that was what --format-version 1 was supposed to help with.
Yeah that seems to be the JSON format only
But the file paths look different
I'll look at it deeper when I'm done with releases
ahh makes sense I guess maybe
For now cargo +1.64 metadata works around it for me xD
uhh seems like cargo-release is stuck halfway through
the dry run worked but now it hangs at 100% cpu
Packaging twilight-gateway-queue v0.16.0-rc.1 (/home/jens/twilight/twilight-gateway-queue)
Verifying twilight-gateway-queue v0.16.0-rc.1 (/home/jens/twilight/twilight-gateway-queue)
Updating crates.io index
error: failed to verify package tarball
Caused by:
failed to select a version for the requirement `twilight-http = "^0.16.0-rc.1"`
candidate versions found which didn't match: 0.15.4, 0.15.3, 0.15.2, ...
location searched: crates.io index
required by package `twilight-gateway-queue v0.16.0-rc.1 (/home/jens/twilight/target/package/twilight-gateway-queue-0.16.0-rc.1)`
if you are looking for the prerelease package it needs to be specified explicitly
twilight-http = { version = "0.15.0-rc.1" }
perhaps a crate was updated and forgotten to be re-vendored?
huh
it just decided to publish gateway-queue before http
i think cargo-release messed up badly, idk how
AAAAAAAAAAAAAAAAA
and cargo-release did not change the version in the CHANGELOG.md files
or does it not do that for pre-releases
mmh seems so
@wild marlin @karmic aurora how do we want to do this? Releases are out on crates.io.
Should I publish release notes in GitHub release and mark it as a pre-release? (I'd rather put the full changelog in a stable GitHub release later and not do one for now)
Should I do an announcement in #announcements? (I think we should)
Should we write a book entry for a pre-release? Seems weird
I think the best thing to do is having me write a book entry now, PR it but don't merge it until we release a stable 0.16
We can add a chapter to the book that is to be updated with any changes
I'm writing one as we speak :)
And yeah I agree we should do a #announcements
Will do the announcement once i have a book PR up
Maybe we should merge it as well so we can point to the page
hmm yeah sure
i hate writing changelogs, i'm never sure what to mention
if i mention every single commit i'm never gonna finish
I think it's best to consider it a sort of upgrade guide
That's the part I wrote so far
The Discord API catchup part is the one that bothers me
I will probably do a bit of catchup this weekend I think we are a bit behind, though that is probably more for 0.16.½
once the book stuff is merged i'll announce the release
Could you add the imports to the example or at least the new trait to highlight it?
Otherwise it looks good
good call
the 0.15 one didn't have all imports, but I'll add the trait
Added!
@karmic aurora i'm hopping on a train now so if there's anything else you want reordered, feel free to just do it :)
Also, I'd aim for a stable release next weekend unless we hear of any breaking bugs

So I did get an indirect bug report via my gateway-proxy repo
This is a very interesting catch
I'm not 100% what the right decision is here API-wise
Either tokio-websockets should only use the configured connector if the scheme is wss, or twilight should set the connector to plain if the proxy URL is set
I think there's arguments for both
or both
I personally think that setting a connector should equal use this, no matter what
Then I think doing both would be a good way forward.
The scheme guessing should be best-effort in case a connector hasn't been set
I am not sure I agree with that since scheme is how you decide if you should use tls in the first place
if it is not wss tls should not be used
Seems like you're right then
I'm mainly worried about nonstandard protocols that build on websockets and may use a different scheme
I am not even sure other libraries will say ok if the protocol is not ws/wss
But I guess connect_on is the solution for that...
Yeah that would make sense, if you allows "bring your own socket" people can do whatever
I personally think twilight should remain untouched
It's entirely possible to run the gateway proxy behind nginx or so with TLS
All that's needed is a small change to tokio-websockets to use plaintext with ws scheme no matter if a connector is configured

I'll have to figure out whether the current unreleased changes are breaking or not...
If they are, I'll have to drop an 0.6 release
They shouldn't be, but 0.5.1 was technically a breaking release even though I thought it wasn't >.<
I saw hyper-rustls had a CI check for semver compatibility
Will try to set that up
we don't need to bump tokio-websockets if we call Client::connect_on directly
I think a better solution is to fix the bug in tokio-websockets
soft breaking changes that fix bugs are generally allowed by semver
I'm mostly referring to the resolver trait
But that should be backwards compatible
I see
Hmm I am not sure if this is the tws patch or my stuff acting up
@tame nimbus have you seen that error?
i have not
Then it is probably my codes fault
hmm reallyu strange I just tried when I got home and now it works, guess it might just have been a issue with the train internet or something
strange
that looks like a TLS error?
@silent marsh I just found a issue with tokio-websockets, you can create invalid strings:
use bytes::Bytes;
use tokio_websockets::{Payload, Message};
fn main() {
let arr = Bytes::from(vec![0,0,0]);
let bla = Payload::from(arr);
let msg = Message::text(bla);
let ub = msg.as_text().unwrap();
println!("{} | {:?}", ub, ub.as_bytes());
}
It is just assumed that any frame with the text opcode only contains valid text
I would hate for Message::text to perform utf8 validation
Then this impl should be removed https://github.com/Gelbpunkt/tokio-websockets/blob/5ea9d73b3c112944b1ce4e8798e6acfcfc83676e/src/proto/types.rs#L280
maybe we can extend payload with a flag whether it's valid utf8
No
That doesn't solve anything
oh yeah wrong one, that one and the bytes impl, but then it is probably better to find another solution
You do UTF8 validation on the incoming messages right?
yes
this is not really an issue tbh
the code snippet you sent is the only way to reproduce it, and that's not something you're supposed to do (create a message yourself and then treat it as a received one)
Well it is a way to do UB, so it is not a issue with the usage, but it breaks the invariants of std string.
Yeah it is not something that you will run into by accident
The entire idea behind having Message::text take a payload is to allow serializing e.g. JSON into a BytesMut and then using that to avoid allocations
Which is why I don't want to change that API
I'd just say add a documentation comment for Message::text saying payload must be valid UTF-8 and call it a day
Performing validation of the payload is useless overhead
I'm not going to mark that as unsafe either, it doesn't cause UB when the API is used as intended
I disagree with that statement very much.
allowing users to encounter UB by using safe rust sounds like a bad idea
I agree, but marking an API as unsafe that isn't unsafe unless you basically write code that is complete garbage and no-op is not great design either
Then we should go back to the drawing board to figure out a way to ensure it.
The UTF8 validation could be done in as_str, but then you do double work in the usual case.
Yeah that could work
we can set that for incoming messages after they are validated
And then do UTF8 validation if you turn it into a string when it is false.
and unvalidated gets checked in as_text
Ideally I'd want Message::text to perform the check but that's such a ridiculous overhead I'd rather not
@wild marlin If you have a moment or two, I'll open two PRs now for the fixes

@silent marsh re the first one, tbh I think there should be added a new error that is returned if it not wss or ws instead of just asuming it is plain if it is not wss
I think so too but that's breaking
Okay screw it, let's just do 0.6 with all the fixes
Being afraid of version numbers doesn't help anyone
I think together with changing as_text to returning a result it is worth
as_text currently already returns an Option
ugh
Option<Result<&str, Error>> feels weird
not really
None is intended for when the message isn't a text message
but this API is generally awkward
I'd rather panic
this is impossible to encounter unless you construct and deconstruct the message yourself
which is already a red flag
Yeah maybe it makes sense to panic.
Just getting some food, but I will have a look at the PR's later.
Both the pr's look good
i'll let vilgot look at the second one just to be sure
payload internals are mostly his design idea
I think I can probably move utf8_validated to the Payload struct
might make the code more readable
since the methods that mutate it are &mut self
Just spotted a small thing when I had another look, the //SAFETY comment is outdated
which one?
"Opcode is Text so the payload is valid UTF-8"
ahh
I guess that can be completely removed
Ah no, I want to keep the safety comments for all unsafe usage
@silent marsh I still don't like the as_text docs.
Me neither
I have no idea how to improve them though
I can totally see how people might misread them
/// Returns a reference to the message payload as a string if it is a text
/// message. For received messages, this is zero-cost.
///
/// # Panics
///
/// It is theoretically possible to craft a text message via
/// [`Message::text`] using a payload with invalid UTF-8. This will not
/// cause undefined behavior when sending, since the remote end is required
/// to validate the UTF-8. In the extremely unlikely and undesirable event
/// that this crafted message's payload is then casted to a string by
/// calling this method, it will panic to avoid undefined behavior.
how about this?
I think less is more, or whatever.
I don't really know how to explain it shorter without making it less easy to confuse
I guess the second sentence could be removed
/// It is theoretically possible to craft a text message via
/// [`Message::text`] using a payload with invalid UTF-8, since that method
/// avoids validating UTF-8 for performance reasons. In the extremely
/// unlikely and undesirable event that this crafted message's payload is
/// then casted to a string by calling this method, it will panic.
maybe undesirable is the wrong word here, what i want to express it that this is a massive antipattern and should never be done
/// It is theoretically possible to craft a text message via
/// [`Message::text`] using a payload with invalid UTF-8, since that method
/// avoids validating UTF-8 for performance reasons. If the crafted
/// message's payload is then casted to a string by calling this method,
/// it will panic. This edge case indicates flawed logic in caller code.
This turned into quite a bit of text. TL;DR I prefer my exact review suggestion.
For received messages, this is zero-cost.
As a user, I would assume the method to be optimized so pointing it out feels odd. Why would it ever not be zero-cost if possible?
The standard library sometimes annotates conversions as guaranteed O(1), for example, but I don't think that use-case if needed here since there's no alternative to this method (where the standard library would offers specialized alternatives).
This method will panic when the message was created via
Message::textwith invalid UTF-8. This does not include received messages, they are validated during the decoding stage.
I think the first sentence is enough. The internals of howpoll_nextcreates itsMessages is not something users should worry about so the documentation need only mention public constructors. Also let's not forget that the struct level documentation forMessageincludes
Received messages are always validated prior to dealing with them, so all the type casting methods are either almost or fully zero cost.
It is theoretically possible to craft a text message via
Message::textusing a payload with invalid UTF-8, since that method avoids validating UTF-8 for performance reasons. If the crafted message's payload is then casted to a string by calling this method, it will panic. This edge case indicates flawed logic in caller code.
Way to complicated. The docs should be very simple and structured so users can skip the verbiage and only focus on the panic conditions.
Ah yeah I completely forgot the top-level struct documentation
That makes things a lot easier here
@karmic aurora Pushed to match your review suggestion
besides yanking 0.5.1 does this also warrants a rustsec entry (essentially a CVE)?
i don't think so
and neither do i think we should yank 0.5.1
the code to cause UB makes no sense
not really sure I agree with the "makes no sense" part. If theres code out there that can cause UB from safe code it should be yanked once a replacement is available
i don't feel like breaking people's lockfiles over an issue that isn't present in anyone's code
Lock files will not be broken
Yanking prevents crates from newly depending on the yanked version
Oh sorry @tame nimbus i had not seen you were working on twilight 0.16 as well
I made a pr that depends upon your pr https://github.com/serenity-rs/songbird/pull/227
yikes
That is one of the most confusing errors I've seen so far
I assume it's because the Resolver trait does not mandate the Future to be Send?
I cannot reproduce anything like this locally xD
Gai is Send, so is the ClientBuilder
the hell :D
The error?
i can totally see people manually making this to unit test their code and messing up
a proper test would fail but you could run into it
I was able to reproduce it in the end and added a regression test
This sucks a bit because I'll have to bump minor version again
That's why generics are nicer than trait objects
This is a generic though :/
Ah oh well i guess you are referring to the dyn Future
I didn't want to raise MSRV by that much
I'm considering just requiring the return type to be a oneshot::Receiver<Result<SocketAddr, Error>>
Most async trait fn's will have a Send bound for this exact reason, requiring a channel is excessive
All tokio interfacing libraries are already plagued by send bounds
Oh sorry, I didn't realize that. Is the : Send bound then necessary on Resolver?
I'm not 100% sure. The code as it is now matches what async_trait would require so I went with that to be safe
async_trait has a where Self: Send bound
Relaxing the bound is thankfully not a breaking change 😅
seems like CI in twilight passes with 0.7 so I can relax now
I meant if it was the Error type that caused it.
Ah no, it was the missing Send bound on the future
Since that future is then awaited in a tokio task XD
Should we touch out a rc.2 of the gateway?
I think we should rather just do the release on the weekend, that was the only bug report and it was very minor
@silent marsh Do you have time to do it today?
I should have time, albeit only later at night. If I don't get to it today, I have time all day tomorrow
edit: Yeah I'll do it tomorrow afternoon
Sounds good
By the way, there's a new rustls version that switches the default crypto provider to aws-lc-rs, which I'm not particularly fond of
The platform compatibility of aws-lc-rs is much worse than ring
Argh, fun even more stupid features to add to all our crates.
This also mean that any crate that does not remove the default features is just unsupported on freebsd.
Yeah we'll have to offer a selection between aws-lc-rs and ring
And should probably default to ring...
I still don't understand why they did that
"it's FIPS compliant" does not strike me as a great argument since that's opt in
It's not fips compliment by default
that's what I meant by opt in, yeah
Ahh yeah, I should have finished that line 
from what I've read on their discord platform compatibility is an oversight but they don't wanna go back
And soon you also have the Microsoft lib that is fips compliant as well
I wonder what happens if I compile rustls on freebsd, does it actually complain about platform stuff
from what I've read, this should break BSD and RISCV targets out of the box (?)
2 secs let me try on my freebsd vps
I guess your FreeBSD and the Power machine are good testing areas xD
I wiped my Pi 4 that was running FreeBSD
Compiling aws-lc-sys v0.13.2
error: failed to run custom build command for `aws-lc-sys v0.13.2`
Caused by:
process didn't exit successfully: `/home/erk/dev/rustls/target/debug/build/aws-lc-sys-d18c1cf2bfcc51a2/build-script-main` (exit status: 101)
--- stdout
cargo:rustc-cfg=use_bindgen_generated
--- stderr
Missing dependency: cmake
thread 'main' panicked at /home/erk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.13.2/builder/main.rs:256:34:
called `Result::unwrap()` on an `Err` value: "Required build dependency is missing. Halting build."
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Great error :)
Going to be fun to make a pr to every single crate that just writes rustls = "0.23" 
:^)
lol aws-lc-sys will actually compile on other platforms, the only reason it does not is because they pre-generate the bindgen bindings for some of them.
(if it will work on other platforms is still a open question)
/home/erk/dev/aws-lc-rs/aws-lc-sys/src:
drwxr-xr-x. 1 erk erk 388 8 mar 09:47 .
drwxr-xr-x. 1 erk erk 228 8 mar 09:47 ..
-rw-r--r--. 1 erk erk 2247 8 mar 09:47 lib.rs
-rw-r--r--. 1 erk erk 927498 8 mar 09:47 linux_x86_64_crypto.rs
-rw-r--r--. 1 erk erk 1124362 8 mar 09:47 linux_x86_64_crypto_ssl.rs
-rw-r--r--. 1 erk erk 925324 8 mar 09:47 linux_x86_crypto.rs
-rw-r--r--. 1 erk erk 1122179 8 mar 09:47 linux_x86_crypto_ssl.rs
-rw-r--r--. 1 erk erk 925309 8 mar 09:47 linux_aarch64_crypto.rs
-rw-r--r--. 1 erk erk 1122173 8 mar 09:47 linux_aarch64_crypto_ssl.rs
-rw-r--r--. 1 erk erk 928864 8 mar 09:47 macos_x86_64_crypto.rs
-rw-r--r--. 1 erk erk 1126349 8 mar 09:47 macos_x86_64_crypto_ssl.rs
Which just makes it so much worse, because it does not even support windows...
Or wait it says it does support windows???
Ahh for that you need to build the bindings yourself.
it needs nasm on windows
Yeah, the build tools, cmake, nasm and llvm.
*a old build tools, the newest one is unsupported.
I think the big shitstorm hasn't started yet because tokio-rustls hasn't had a release yet
But I imagine there'll be a lot of complaints once it's out
Yeah one of the most common complaints with ring was poor support, but this seems worse.
Ring has done a lot to work across a lot of platforms now
I can't wait for the day when RustCrypto is usable
will be nice yeah
It's always seemed silly to me that the pure rust TLS implementation had a C crypto component
I dont think twilight should expose awc-lc-rs. its not useful to end users of the library afaict
No one needs FIPS compliance talking to Discord on their Linux server
i disagree, aws-lc-rs generally is faster than ring and therefore a viable option, just not by default
do you have the benchmark link onhand?
But what should we expose? should we just add 2 more features to each of our crates that may use rustls?
both are using the same C code underneath, boringSSL :P
so im curious to see
Note that RustCrypto performance is generally inferior than ring, but in exchange you got a pure Rust implementation that theoretically compiles everywhere Rust was ported to. In our case, we need to have std but foundational support for future no_std expansion is already here.
This package is still in its very early phase, so until we think the code is okay for general public use, this won't be published to crates.io anytime soon.

pretty much...
that's how all crates that depend on rustls will have to do it
speaking of tls stuff I guess, is twilight going to support the new rustls certificate library?
And then if symcrypt is added to upstream, we should add another feature :)
You mean rustls-webpki or is there something else?
platform verifier or something
Really stretching the definition of useful 
i think there will come a point where twilight just has to say "no we arent going to support x TLS feature"
its pretty high up in people's dependency stacks and increases cognitive overhead
The alternative is doing like songbird is doing and tell people that they have to add feature to rustls themselves, but that is also error prone and adds a new place where things can go wrong.
View rustls continuous benchmarking results and performance regressions on Bencher
(songbird does that not with rustls, but with symphonia)
I imagine there's a better side by side comparison somewhere
probably the right option tbh. If you know enough about the crates to know you want a different cryptography library, you should know how to enable crate features?
They rendered them in the repo but only on PRs
man this website is slow as hell
But that one has metrics for aws-lc-rs and ring and renders them nicely
yes
the new hyper-rustls release will have support for it
and I think it's pretty neat, should be the new default in my opinion
I think we should cut twilight with the current version and then delay the decision to update it to after we have published 0.16 
(current as in the current in twilight)
somewhat frustrating that I cant find any throughput benchmarks
someone linked some a while ago on discord, sec
tbh I am the strange person that uses native-tls so it does not really matter that much for me.
openssl is a strange choice these days, yes
see the bonus 1 section
aws-lc-rs is anywhere from 6% slower to 62% faster than ring
rustls does not support ktls
And it did not use to work at all on odd platforms which was the reason I started to use native-tls.
Like now it works on big endian and everything
yeah fair
It does now
Is that not the one that is linux only
this crate is compatible with rustls ever since they exposed secret extraction
yeah it is
i personally know my own HTTP servers will not be exposed to enough traffic that kTLS matters
so the benefit of keeping more in Rust is nice
I should try to make rustls work with ktls on freebsd
I think last I looked at it I stopped because I had to do a bunch of libc prs to make it work without a bunch of custom stuff.
@karmic aurora Can you rebase https://github.com/twilight-rs/twilight/pull/2235 when you have some time so we can get that added.
@silent marsh, @ocean nest i have made a pr to fix the docker issue, have a look https://github.com/twilight-rs/http-proxy/pull/77
yay checks passed so id assume it works
Could someone take over this PR?
@silent marsh (and @ocean nest) i will probably remove the build-std stuff, as it seems to give a bunch of errors with aarch64
Ratelimited Discord HTTP API proxy. Contribute to twilight-rs/http-proxy development by creating an account on GitHub.
There are some issues referencing this in the rust repo and in the compiler_builtins repo
That's fixable by linking in libgcc
rustup target add aarch64-unknown-linux-musl will download a libgcc for the target
I've never gotten it to work with the compiler_rt stuff, but libgcc works fine
Okay now it works
This did not do it for some reason so I added libgcc-12-dev-arm64-cross from Debian.
I have just rebased Vilgot's code so it should be ready for review if anyone have a bit of time: https://github.com/twilight-rs/twilight/pull/2235
still needs the cache integration
there should be a new mapping and generic
I don't think there is missing a new generic? only a ResourceType possible right?
Or should we add a guild_events global thing?
I guess that is what you want.
Yes
And a new resource type alongside as well, yep
@silent marsh Should be done now.
I also went ahead and integrated with the other scheduled events events
Which might be a bit outside of the scope but I was there and it would be strange if it was not included.
@wild marlin I have a couple of issues with that new dockerfile but not much time for leaving an actual review. My main problem with it is that you're hardcoding cross compilation targets, while the old file allowed for cross compiling to any target
No it did not
It did
You just had to specify the targets via --build-arg
This new file hardcodes the arm64 libgcc installation and supported targets
Ahh in that way
Yeah it did work with musl targets, though none of them was tested.
The reason I have to hardcode the libgcc is a bug in rust, which is rather annoying
back when I wrote the file I built 32-bit ARM and s390x just to see that it works
and I think it's important to have a dockerfile that allows for self-compiling to any target musl/alpine supports
otherwise this is internal only and not usable by people who need to build it themselves
The issue is not that, the issue is that you need to use gcc to build your own stdlib
(on arm at least)
If I removed that it would have as good support as the last one.
(and did a bit of fiddeling with some env variables)
you're still hardcoding the targets in .cargo/config.toml though
Yeah, but that can be changed to be as before
yes and the old file worked around that by downloading a cross compilation toolchain which bundles the libgcc
Yeah, if you want I can change it back to musl.cc if you think that is the better way to cross compile.
considering it allows for more supported targets I think it is
I was messing around with using LLVM and compiler-rt
btw this is the cause
I was trying to get it working by using https://crates.io/crates/compiler_builtins
but that didn't work for me
yeah I was telling it to use the C fallback
ahh
it is the better way though
LLVM over GCC has a long list of advantages
linking in libgcc alone has some licensing implications afair
that bothers me a bit as well but I'd prefer using that for now until we get a full LLVM build working
yeah I had that set up properly and building fine
but it still gave me the symbol errors anyways
was weird
I should try it again
iirc my issue was that it then built compiler-builtins twice
and probably linked in the wrong one
what a cluster of a crate
@silent marsh Do you plan of updating rustls in Twilight before we release 0.16?
Yes
tokio-websockets is basically ready, I hope hyper-rustls won't take too long
Oh, hyper-rustls is ready already
Even better then
Oh yeah was jsut about to say that
And it seems the tracing thing have been fixed as well so I think your patch to tokio-websockets is ready, let me know if you want a second review of it or something
The tracing thing was fixed by bumping tokio-util to 0.7.3
(And dropping the very ehhh redundant hyper support)
Maybe you should also not that in the commit that ends up on the main branch
I was going to add a commit to export make_key and then note that as the replacement
We should probably get this merged as well https://github.com/twilight-rs/twilight/pull/2235
And maybe the lavalink v4 stuff
tbh i think lavalink v4 needs a lot more testing and the PR is far from ready
i wanted to leave a review on that PR last week but didn't get to it
We could just leave out lavalink for 0.16 for now if we want to get it out
@wild marlin is https://github.com/twilight-rs/twilight/pull/2326 supposed to not pass CI?
Tbh I am not sure what is making skeptic fail
Also it needs the other or for everything to pass
I merged the other CI fix
I am not going to be near a computer before tomorrow evening so I can have a look at it then
The version v0.7.0 linked at "https://github.com/rust-lang/crates.io-index/blob/master/to/ki/tokio-websockets" corresponds to a tokio-rustls dependency version of "^0.25". Howev...
how is this even an issue
it makes for a good release timing excuse but man what is this
I guess the error makes sense if you have not understood how the crates system works with releases and such, but yeah a bit of a misguided issue
what can i do to help with getting entitlements merged 👀
@opal juniper Do you have time to finish it up? Or would you be okay with someone else taking it across the finish line?
https://github.com/twilight-rs/twilight/pull/2282
I’m ok with someone else picking it up
@woven elbow, @jaunty jewel and @ocean nest if you have some time the comments should be resolved
which pr are we talking ab
if its the new dockerfile one theres just one small nit then lgtm
The new docker file has some other issues with supporting a wide range
does it not show the latest commit on mobile or something
I am pretty sure I fixed that so I don't know what's up
ill check on pc in a sec
even on web its not changed
Hmm it is for me, is there a refresh button on the top line?
I think the message might have gotten messed up for some unknown reason
I'm so afraid of making releases because I know I'll forget something
Happened again just now
https://github.com/Gelbpunkt/tokio-websockets/pull/53 <@&910940740325093418> you might want to take a look?
LGTM
I am back and once again looking to get https://github.com/twilight-rs/twilight/pull/2205 merged.
(Please ping if you want my attention on something.)
@autumn sequoia Not really for the PR as I think it can be added later, but does the Digest trait not allow to do the streaming thing which we have talked abount before
The Digest trait does support generating hash digests in a streaming fashion, but that's a separate thing from signature verification.
The status of streaming signature verification currently appears to be "PR approved, but not yet merged"
Ahh makes sense, I thought you could use a hash digest for verification.
I gave you a small review most of it looks nice, just a few small things.
Lemme go through them right now
(And yeah, hash digests are in fact part of verification. It's just that there's a few other ✨Mathy Parts✨ that I wouldn't feel comfortable trying to do outside of the crypto crate maintained by actual cryptographers.)
Yeah makes sense, I think we can update it to use a possible streaming verifier at some point when it gets merged.
Can we just temporarily remove the rust-skeptic CI step until we figure things out?
Yeah
@silent marsh would we just reconnect if we got a rsv1
made a pr for just removing it all.
I'd have to check the twilight code
But the websocket connection is definitely unrecoverable from that
Yes, we would reconnect
Receiving the protocol error would mean disconnect(CloseInitiator::Transport) gets called
Which then sets the shard state to Disconnected with 0 reconnect attempts so far
Okay nice at least we don't die because I have heard of multiple incidents now.
@ocean nest if you have some time a quick look at reviewing https://github.com/twilight-rs/twilight/pull/2330 would be nice.
I just realized that the lavalink code does not reuse TLS connectors whatsoever...
and then I tried adding that in but it's impossible to do it without exposing tokio-websockets as a dependency on NodeConfig
We should really get rid of lavalink in its current form
I'm finishing up the rustls 0.23 stuff for a stable release right now
kinda noticed that my filesystem got corrupted during that tho :D
@wild marlin uhm is it intended that lavalink unconditionally disables tls
i see so many issues in this crate lol
why does the crate even have TLS features when ws:// and http:// is hardcoded
guess I'll fix that in my pr
the entire code is inherently flawed
Actually I also think we should merge #2205 before a release.
Implementing #2169. This PR is not complete, but I felt like making what I wrote just now public quickly so people know progress exists.
@autumn sequoia If you rebase it now all the errors should be gone.
Done. Let's see what happens 
@silent marsh Which features are we going to end up with with rustls?
looks something like this
i still need to figure out how to deal with people who don't enable a crypto backend
http will error lazily and gateway will error at compile time, which is pretty meh
@thick seal PR on discord repo got merged: https://github.com/discord/discord-api-docs/pull/6717
Does anyone know how to do generate these bytes as shown here for this test: https://github.com/twilight-rs/twilight/blob/08ed124a201e24fda6e130100465d94b1ea7a877/twilight-http/src/response/mod.rs#L642
I think the way we did it was to write a small patch that wrote out the raw bytes before decompressing though I am not sure, like I am not sure if it is generated or more captured.
Probably captured from struct -> json -> compressed
Ah yeah that is possible as well
@wild marlin I brought this up earlier in chat, but for https://github.com/twilight-rs/twilight/pull/2347#discussion_r1606369453, I think it would make things more ergonomic if we utilized structs for query parameters and have them serialized into a string using something like https://docs.rs/serde_qs/latest/serde_qs/ (listed in serde’s output formats page)
Maybe something like this could work as well? https://docs.rs/query-string-builder/latest/query_string_builder/
A query string builder for percent encoding key-value pairs
I am not quite sure what the best way is tbh
That works too, it’s mainly a difference between automated and serialization or building it manually (in a more consistent way)
The latter would be the easier to migrate to imo
Yeah that was what I was thinking
I prefer the smaller dependency list of the builder
Is there a more efficient way to do this? My end goal is that I have a wrapper that takes any iterable and implements a string version to display all of it's elements via Display?
I also removed the clone bound by defining a Iterable trait, but the clone will just be a memcpy in your case since IntoIterator is implemented for &'a Vec<T> (and most other collections) so this isn't really an optimization.
use std::fmt;
trait Iterable {
type Iter<'a>: Iterator<Item = Self::Item<'a>>
where
Self: 'a;
type Item<'a>
where
Self: 'a;
fn iter(&self) -> Self::Iter<'_>;
}
impl<T> Iterable for Vec<T> {
type Iter<'a> = std::slice::Iter<'a, T>
where
Self: 'a;
type Item<'a> = &'a T
where
Self: 'a;
fn iter(&self) -> Self::Iter<'_> {
self.into_iter()
}
}
struct DisplayIterable<'a, T>(&'a T);
impl<'a, T, U> fmt::Display for DisplayIterable<'a, T>
where
T: Iterable<Item<'a> = U>,
U: fmt::Display,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for item in self.0.iter() {
item.fmt(f)?;
f.write_str(", ")?;
}
Ok(())
}
}
Here's the above with IntoIterator. I changed Clone for Copy to ensure it's only used on references, i.e. no deep clones
Your display implementation is a bit different than Siris's as it will write a extra , after the last element.
Modified yours a bit, the clone is redundant if T already implements Copy, but thanks this was what I was looking for.
If you want to ensure that there is not a trailing seperator you can do something like https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=08044f7e59752280fd626f9104d6d681
Yeah I ended up doing .map.collect.join(“,”)
👍
No, but this probably fits better in #1017541980273770528 if you have a specific use case.
note that Formatter::write_str and Display::fmt are lazy, so you incur an additional allocation that way
Lets continue query builder discussions in #1243086999817162804
Anyone have time for a review?
I still believe that this shouldn't exist
If you look at the PR, the utility saves a whopping 7 lines of code in the example, half of which is due to reformatting
That doesn't sound worth the maintainance effort required to keep this up to date with new dependency releases
Well I disagree, I think this is specifically what the util crate is for
Like the snowflake module saves like a couple of lines of code.
In my view, what would go in the utility crate could be an integration with a web framework to provide a one-stop solution for the entire request parsing, body validation, etc. In the current state this is a renamed wrapper around dalek, which I just don't think is good enough of a case to add it.
So for it to be merged you want something like a tower layer added?
Something like that, or an integration with http
I think that is something that can be added, but I don't think it should be coupled with this pr
Then we have to change our development practices as we have generally been rather careful with not exposing crates.
Yeah but the entire thing that this PR does it re-expose dalek and call it a utility, which is a joke
It doesn't relieve any work from you like what snowflake utils do
You just replace dalek types with util types
okay, I guess I will add what you want in that case, because I would rather see this being added.
The only arguable case I've seen in favor of the PR in its current state was that it would make it a no brainer for users when deciding how to validate the requests
But having the example in its current state in my view is sufficient for that
Also regarding this: the crate's utility as a utility is very limited if we don't provide integration with stable ecosystem crates like http 1.0
The issue with tower is that even its service trait isn't 1.0 yet
The body trait makes this rather difficult to do in a nice way.
So tower_http does have a way to set up validation of requests but I don't think there is any way to access the body from those which is rather annoying
Anyone have any good idea of how to handle this?
This actually also goes against what @karmic aurora said which is probably the reason it has not been done: https://github.com/twilight-rs/twilight/issues/2169
I would just like to put up that i think the 7 lines it saves are not representative of how much work and time it saves in a real application
Signature verification can be troublesome (selecting and adding dependencies and learning their APIs) imo. I think users are more likely to create interaction-based bots if there's an easy to use and official API
@karmic aurora https://github.com/twilight-rs/twilight/pull/2314#discussion_r1621800639
by this do you mean a trait returning certain structs (https://api.twilight.rs/twilight_mention/fmt/trait.Mention.html) or constructing format structs by themselves (https://api.twilight.rs/twilight_model/user/struct.DiscriminatorDisplay.html) ?
Mention a resource, such as an emoji or user.
Display formatter for a user discriminator.
I'm imagining just pub struct Bold<F>(pub F), but there might be a better, more convenient, API
ed25519 signature validation, the most controversial PR to cross Twilight's GitHub repositories in years 

If anyone knows how to fix the test for https://github.com/twilight-rs/twilight/pull/2346, I could need assistance on that
InviteType::name for Group is "Group", but the test's assert expects "Group DM"
Oh sorry I should've been more specific. That one I can fix, I meant to say for updating this test: https://github.com/twilight-rs/twilight/blob/08ed124a201e24fda6e130100465d94b1ea7a877/twilight-http/src/response/mod.rs#L642
I tried the compressing the json into bytes but the test still fails
at which step?
serde_json from_slice
doesn't serde provide a helpful error message?
I think it just gives a format error
you can inspect the json by first calling str::from_utf8
That's correct. I got the impression that y'all didn't want that integration with other crates, because it'd be a larger maintenance burden.
That said, I'm no longer willing to offer to write that integration.
I might be willing to write it, but I honestly think that writing it in a stable way is Not Worth It™️
afaik no rust web libraries are 1.0 yet
Hyper is
The issue with this that it is rather annoying to gain access to the body of a request because of how they have been made.
And if you make the body non generic it will break stuff
And then comes the other issues wuth service which means you have to implement your own futures and stuff as well, so you probably need pinning and everything gets annoying then.
there isn't really anything to be made with hyper, though- iirc it doesn't have middleware, extractors... it just gives you a request, expecting a response
tower::Service is relatively stable as it's a re-export of tower_service::Service (latest release was november 2019)
Now implementing it as a service IA rather annoying because of body types
I didn't look into this until now, but I guess coercion is broken when number literals are used: https://github.com/rust-lang/rust-analyzer/issues/11847
rust-analyzer version: bc08b8e 2022-03-28 stable rustc version: 1.59.0 (9d1b2106e 2022-02-23) I tried the example in https://smallcultfollowing.com/babysteps//blog/2022/03/29/dyn-can-we-make-dyn-si...
Can anyone reproduce this error? https://github.com/twilight-rs/twilight/actions/runs/9344937154/job/25716928886
yeah I don't have the motivation to engage with this process anymore
https://github.com/twilight-rs/twilight/pull/2205#issuecomment-2143895751
I know you think it's not a lot of work, and it's not, but asking me to do this in more than one session is a great way to make me burn two full days on this instead of one.
maybe if we were still in 2023 and I had the same spare time as I did when I decided "yeah sure I'll try getting a utility for this into the library I'm promoting"
my PR has the "Allow edits by maintainers" box checked. if you want to make a bunch of little changes to it, you can do it without funneling them through me
I promise I won't care
Oh, I should state an alternative. If you don't want to do that, I can close the PR and just publish another crate that does just this for people. I even already glued one together way back, https://git.catmonad.xyz/Monadic-Cat/twilight-signature-validation. I'd just polish that and move on with my life.
.
Without my twilight hat on: You should definitely feel empowered to drop it at this point. One year over a very simple concept represents a severe process failure imo
hat off just because I don't engage in the code these days
i'm more then willing to take it over, but I'm not sure if that's something github supports
And yeah, the process does not seem to be particularly efficient
fully understandable, I am quite dissapointed with how the process have been.
Why doesn't https://docs.rs/twilight-model/0.16.0-rc.1/twilight_model/channel/permission_overwrite/struct.PermissionOverwrite.html impl Copy?
Permission overwrite data for a role or member.
should i make a pr for that
or is adding copy something that can be taken care of in bugfixing
You are welcome to send in a pr for it
now that was a fast pull request
i'm looking at retries on 429 responses to twilight. would that be something that can be in default twilight or does that need a feature flag?
If it does not add any dependencies and is off by default it could be in without flags imo
not done it yet but in theory it shouldn't need any deps. if a cow works it shouldn't increase memory usage significantly either
our request bodies are Body, so clones should already be ~free
yeah, currently doing that. just now trying to get all the types to behave cause we pass this stuff around deeply
without bypassing rate limits, not sure yet if that part works as expected yet
ok i was a bit to optimistic, gona need to do some more work to make it actually wait for the rate limited rather then just blindly retry
Could a ResourceType be added for just the MEMBER_CURRENT, rather then all members?
It's currently not a problem for me because I don't use the guild members intent, but I can see it being one down the road.
I had (and still have) a patch for that and it was rejected about 2 years ago
I agree that it is extremely useful
why was it rejected?
Aa far as I remember, it was something along the lines of "discord doesn't separate this out as a new intent or model, so we don't want to treat it like one"
should i make a pr to change NonZero* to NonZero<T> that was added in the latest rust update or is that not worth bumping our msrv
@silent marsh @ocean nest I made a new dockerfile PR with no controversial changes just to make it work again: https://github.com/twilight-rs/http-proxy/pull/79
Would appriciate a quick review, it does not have many changes.
I was going to mention https://blog.rust-lang.org/2024/05/17/enabling-rust-lld-on-linux.html, but that's just for x86_64 and we're doing multiarch
The issue is more that we do some funky stuff with nightly, that being we build the std and such.
Otherwise you could make a better solution.
I updated the http proxy so we can fix the issue in #1250065796881715210 if anyone have time for a quick review: https://github.com/twilight-rs/http-proxy/pull/80
Thanks
@karmic aurora I have turned on auto-removal of branches on the repo now (also did it on the gateway-queue repo)
Yeah never got around to getting the byte representation for the test
No the wrong name() method on the enum
Oh yeah that’s trivial, I’ll update that when I get home
yeah but i suspect NonZero* types will be deprecated soon ig we can wait till then
@opal juniper This is the old json for the compression test, can you send back the changes then I figure out the byte array for you:
{"code": "twilight-rs", "guild": {"id": "745809834183753828", "name": "Twilight", "splash": "9d70baddb90a36979015ace8aadeb92e", "banner": null, "description": null, "icon": "089f35e5d0a28ff4927a7f825d71f41c", "features": ["THREE_DAY_THREAD_ARCHIVE", "WELCOME_SCREEN_ENABLED", "NEW_THREAD_PERMISSIONS", "THREADS_ENABLED", "MEMBER_VERIFICATION_GATE_ENABLED", "VERIFIED", "VANITY_URL", "NEWS", "INVITE_SPLASH", "ANIMATED_ICON", "PREVIEW_ENABLED", "COMMUNITY"], "verification_level": 3, "vanity_url_code": "twilight-rs", "welcome_screen": {"description": "Support and development of Twilight, the ecosystem of Rust libraries for the Discord API. https://twilight.rs", "welcome_channels": [{"channel_id": "745811192102125578", "description": "Ask for help with Twilight", "emoji_id": "832667826547851305", "emoji_name": "rust"}, {"channel_id": "745811216579952680", "description": "Talk about Twilight development", "emoji_id": "745916458541776926", "emoji_name": "twilight"}, {"channel_id": "745813247705481246", "description": "Read library update changelogs", "emoji_id": null, "emoji_name": "\ud83d\udce3"}, {"channel_id": "745811486819221544", "description": "Keep up with GitHub development", "emoji_id": null, "emoji_name": "\ud83d\udcd6"}]}, "nsfw": false, "nsfw_level": 0}, "channel": {"id": "745809834183753832", "name": "info", "type": 0}}
Ok we can do that
They were actually transformed into type aliases of the generic type. I think deprecation is at least a year away
aliasing it makes sense for dry code i guess we’ll see what happens
A small fix to rate limiting if anyone has time: https://github.com/twilight-rs/twilight/pull/2356
Can someone approve https://github.com/twilight-rs/http-proxy/pull/81 so I can merge it lol.
done
@silent marsh that sounds complicated, and I am not sure I can see it for me at the moment but I will look forward to a poc (re: <#1254760954194038794 message>)
It is definitely complicated but I can see that being useful
I've seen so many questions in #1017541980273770528 regarding comparing state before and after cache updates
ugh no, there goes my idea XD
This won't work because of the Event enum. It would work for individual structs
Actually nvm, that's okay
We can make Event return () and the specific updates return a type
https://github.com/Gelbpunkt/twilight/commit/c40612438410c7313eb92ac2fea1c306c888da40 @wild marlin here's a POC
I only implemented it for the channel events for now, it gets repetitive
This lets you do cool things like
let channel_before_update = match cache.update(&channel_update) {
UpdateResult::Processed(old_channel) => channel,
UpdateResult::Ignored => panic!("I never disabled channel processing in the cache"),
};```
(I'd add an unwrap to `UpdateResult` if others like this POC)
@wild marlin I have a suspicion that the unavailable guilds handling is incorrect
Based on what a user is telling me it seems that the cache state is just plain wrong
On main?
Yeah
I'm not 100% sure to be honest
But there's a lot of issues with the cache changes recently
They're basically all missing getters
All I did was update twilight in the gateway proxy and apparently now the guild unavailable state is just wrong
But the user I'm in contact with regarding this hasn't provided me any logs or payloads, so I can't really tell what is going on
So before it would not work at all if the guild became unavailable since it would just fail to deserialize
So if it was right before I am not sure it was right before
It might be wrong as well now though
I'm not 100% sure who is to blame here
Could very well be a bug in discord.py (the library they are using)
Without payloads we won't know
Have you tried with your own bot? If you have identifies to spare.
The only change I did was sending the unavailable guilds via a GUILD_CREATE instead of a GUILD_DELETE btw
Else I can try it out but I don't think my bot is in enough guilds for one of them to be unavailable
since now twilight-model allows for that and discord docs document that as valid
Hmm, maybe the serialize is wrong?
I got this from them
Apparently the guild isn't marked as unavailable properly in their bot yet all the fields are unpopulated (i.e. it is supposed to be unavailable)
discord.py just completely ignores GUILD_CREATE payloads with unavailable set to true, which is pretty fair I think
Yeah I guess so
Then the question is if it is something we should look into solving or we should let the bot dev solve?
I don't really know yet
Hmm I think it is in your end @silent marsh
GuildCreate should only be used if it is unavailible from the start I think
Otherwise GuildDelete should be used
Are you sure?
Meh, I'm not 100% sure
To me this means that guild creates with unavailable guilds are allowed in GUILD_CREATE events for backfilling OR when the bot joins a new unavailable guild
Only on initial connection
I think that is the key point there
When it is not part of initial connection it is not allowed
w/e, I switched back to sending guild delete events
@silent marsh @karmic aurora I would like some feedback on this one if you have time https://github.com/twilight-rs/twilight/pull/2361
I made it after the report in #1259665584577314887.
This adds a new construct that can be used to only deserialize a
specific boolean value. We then use that value to ensure that only
guilds which are actually unavailable get deserialized as such.
Though on the other hand it means that we are probably failing to deserialize some guilds for other reasons.
I think you should add a test case for an available guild
In the deserializer for guild_create
currently it only tests an unavailable guild
and from my understanding the issue was never the deserialization of unavailable guilds, but rather available guilds being deserialized as unavailable?
Yeah because the normal guild deserilizer fails and then it fits into unavailible guild.
So it kinda shadows the error.
Meh, this is hard to test
Because it points to our guild struct being wrong or failing to deserialize
We definitely need to fix both
Yeah which is why I would be really interested in test data
But a test case could at least ensure that we see an error with a guild payload we can't deserialize
Seems that their issue was somewhere else, but I think it is still a good idea to ensure that it does not do odd stuff.
I will fix up the pr tomorrow probably.
did some reviews but gave up on the retries on rate limit stuff for now. i don't understand the internals of the twilight request sending code with the rate limiter enough to get it to behave
it's all too connected in ways that are very confusing and hard to follow
ok so it's easier for me to basically just wrap the entire client, duplicate the methods i need and handle 429 retries that way. so guess i'm going that route for now. wanted to upstream it but it just doesn't seem doable
Could I get another review for https://github.com/twilight-rs/twilight/issues/2344
Can I get a review of https://github.com/twilight-rs/twilight/pull/2359 in exchange?
Can I get a review on https://github.com/twilight-rs/twilight/pull/2340? Upstream PR has been merged.
has a merge conflict that needs resolving
Fixed
@wild marlin I think it's time we decide how to properly approach the rustls upgrade
https://github.com/Gelbpunkt/twilight/commit/7094fd19be769bc1edfef50e21d78391a10d42e8 functionally works, but I'm not happy with the feature flag situation
The issue is that no default features won't compile because a crypto backend needs to be selected
And even if it would compile - it would result in runtime panics from rustls
I don't think that choosing a preferred implementation ourselves is good. aws-lc-rs has legitimate usecases (supports more and safer key exchange algorithms and is generally faster than ring)
So I think that the only reasonable way forward is to not panic in order to unbreak powerset CI and instead emit a compile time warning
IMO this is the best way because it would technically allow the user to provide their own crypto implementation if they call the rustls method to make it the global default
sorry, just despawned for a week, will have a look at it.
@karmic aurora you may be interested in https://github.com/Gelbpunkt/tokio-websockets/pull/56
and what do we do about MSRV? I wouldn't mind moving along tokio to 1.70, we're on a rather old MSRV by ecosystem standards already
Hy
(and does not work on arm
)
Can we do both this and a compile time warning?
We should have a preferred if both are chosen, but besides that I agree.
Sure. I'll add a flag to disable the warning because "I know what I'm doing, shut up" is a valid usecase here
hmmm to my knowledge it works on ARM
Hmm, yeah it says so, I just remember running into issues, but maybe I remember wrong.
I think that is the best way to go then.
I'm in favor of moving to the latest version with useful additions, e.g. async fn traits. But I doubt anyone would have serious issues with us even bumping all the way to 1.80
I wanted to bump to 1.79 for tokio-websockets because split_at_mut_unchecked was stabilized there and allows me to remove unsafe raw pointer code
I'll do a last release of tokio-websockets 0.8 after bytes 1.7.0 is released (should happen today or tomorrow), and then a new 0.9 with MSRV 1.79 for the split_at_mut_unchecked and async traits. We should bump MSRV in twilight accordingly, update rustls, fix the guild create deserialization and then release a stable 0.16.
Will try to PR it today, haven't had time due to exams recently
Actually, compile time warnings are not possible :( They were never added to std
aaaand we're gatekept by hyper-rustls' shortsightedness :D
<#1015156984007381033 message>
Let's see what they respond
Time for with_provider_and_*_arc
ugh
rustls is such a cool project but they really gotta get down to reality when it comes to crate maintainer pov for downstream
I hope Dirkjan sees it and decides on a way forward now that I proposed two ways
What are they doing?
tl;dr the crypto provider stuff for rustls is a gigantic mess to implement in a dependency chain
Ah ,dependency loop issues?
they have a solution for that: users can configure a default provider in rustls via feature flags OR install a global default via a method, which rustls can then always fetch on the fly when you call its new methods
but of course they feature gate the methods for that behind the provider flags in their own crates XD
well yes, why would you want ring and aws-lc-rs in your dependency tree at once if you only use one?
no, you did not get what i meant
the methods that it calls do not actually require having those installed/added as dependencies!
since rustls takes care of everything related to the selection on its own if you let it
See https://docs.rs/rustls/latest/rustls/client/struct.ClientConfig.html#method.builder :
Create a builder for a client configuration with the process-default CryptoProvider and safe protocol version defaults.
vs https://docs.rs/rustls/latest/rustls/client/struct.ClientConfig.html#method.builder_with_provider :
Create a builder for a client configuration with a specific CryptoProvider.
Now read https://docs.rs/rustls/latest/rustls/crypto/struct.CryptoProvider.html#using-the-per-process-default-cryptoprovider and start questioning why hyper-rustls does not use the process-default method UNLESS you enable a specific crypto provider
Common configuration for (typically) all connections made by a program.
Controls core cryptography used by rustls.
Tbh I am not too sure if we should support simd-json, it's mostly a pain
Especially Seeing #1271866310468304966
@valid oracle apparently simd-json breaks things.
I removed it from serenity ages ago
Are there any realistic benchmarks or people relying on simd-json in production who have seen a meaningful performance improvement?
I'm just guessing here, but I can't imagine a scenario where JSON serialization would be the bottleneck of the bot.
simd-json is not a performance improvement for serenity,
is somewhat of a Cunningham's Law trigger, but we have seen no numbers that say simd-json are worth the maintenance burden and possible footgun
I removed simd-json after discord had a slight whoopsie and was sending fucked avatar hashes for some users, and my first thought was "disable simd-json, maybe it's fucking with things"
the maintainance effort from our side is low so I see no reason to remove it
upstream development is still active so we should just report these bugs instead of keeping our grudges to ourselves, otherwise nothing will happen
I'd be really pissed as a library maintainer if people kept complaining about my library being buggy but never filed bug reports
@wild marlin is that deserialization issue in simd-json the reason why our guild create deserialization fails?
or is there more to it
Seems to be it
Ah nice, very good
@silent marsh re your tws pr, would the idea then be to install the provider further up eg in twilight or in the users app?
in the user's app
the benefit for twilight is that Connector::new is unconditionally available
so we can actually use it in the gateway even if no crypto provider is enabled via crate features
could we please get #2366 fixed up and merged? I want to do an MSRV bump after that
chore(clippy): Resolve Clippy 1.80 lints, authored by @Erk- <t:1723320917:R>
Done
awesome, thanks
ill wait for CI and then approve and merge
what do we want to bump MSRV to? follow tws and go 1.79? or do we want anything more recent?
i think 1.79 gives us enough headroom for now
tbh I would be fine with either that or simply just taking the latest released version when we release.
let's bump to 1.79 for now then and reconsider this at release
btw i got too tired of hyper-rustls api shenanigans so for the rustls 0.23 PR i decided to build ClientConfigs ourselves... it's basically the same amount of verbosity as using the hyper-rustls builders
lol, failing MSRV check means clippy doesn't run... Pain :D
do we wanna bump MSRV in a separate PR and ignore CI or can you bump it in the clippy fix PR?
I have bumped it
the READMEs and stuff will need to be updated as well
two secs
Done now
Remember to write both things in the merge commit message
sorry was a bit busy, will look again now
oh fun, clippy CI is failing
i guess higher msrv allows for some new methods in lint resolutions
yup those are 1.77+
hope you don't mind me force pushing your branch with the clippy suggested fixes
anyone opposed to depending on the rc version of simd-json at least for now?
I think the deserialization fix for us is critical enough - in the current state, simd-json support is broken and I'd prefer it to work with an rc dependency rather than keeping it broken for now
we can always upgrade to a stable release later without making breaking changes on our end
I think it is OK to do so
https://github.com/twilight-rs/twilight/pull/2367 is ready for review now
@wild marlin any particular reason for the MustBeBool thing?
https://github.com/serde-rs/serde/issues/880#issuecomment-294315051 looks like a viable alternative
having MustBeBool in our public API feels... wrong
That one only works with json since it uses serde_json stuff internakly
hmm right
i wonder if we can somehow not have this as a struct field
something like a private type with it that we use for deserializing
and then our deserializer converts it into the other type if it deserialized into the intermediate unavailable guild type
Can't remember if I tried that I think I tried the one you linked until I saw it used serde_json. But it is also a few months since I looked at it.
this works for me
(mod mustbe is copied from your PR)
I would prefer this so that we can hide the MustBeBool type
That looks fine, then we can just use upstream mustbe as well
Feel free to push a commit with that if you want
Sure, will do
Not sure about the naming but it doesn't really matter if it's private xD
(though I am not a fan of monostate using macros so baybe we can just keep mustbe)

with that PR and the rustls and simd-json ones I'd be down for a new rc release
for a stable release i want the lavalink v4 stuff in
I would want https://github.com/twilight-rs/twilight/pull/2323 as well
This pr implements the newly added user applications, this have had some testing done, but is still missing quite a bit of documentation and maybe a bit of bike-shedding about type names and/or lay...

