--- Log opened Fri Jul 12 00:00:09 2019 01:18 -!- Dean_Guss [~dean@gateway/tor-sasl/deanguss] has joined #rust-bitcoin 01:23 -!- DeanGuss [~dean@gateway/tor-sasl/deanguss] has quit [Remote host closed the connection] 01:27 -!- instagibbs [~instagibb@pool-100-15-121-126.washdc.fios.verizon.net] has quit [Ping timeout: 245 seconds] 01:28 -!- instagibbs [~instagibb@pool-100-15-121-126.washdc.fios.verizon.net] has joined #rust-bitcoin 02:00 < stevenroose> dongcarl: didn't know "Use iter instead of into_iter as no move occurs" was a thing. Is into_iter really less efficient if no moves occur? Or just style? 02:22 -!- belcher [~belcher@unaffiliated/belcher] has quit [Quit: Leaving] 05:15 -!- elichai2 [uid212594@gateway/web/irccloud.com/x-juixrrwbybhjklzv] has joined #rust-bitcoin 05:52 < andytoshi> no move occurs regardless 05:52 < andytoshi> in `data.iter` you are "moving" a &[u8] which is 2 words wide and is copy anyway 05:53 < andytoshi> data.into_iter i mean 05:54 < andytoshi> also since when is Clone implemented for [u8;128]? 07:44 -!- belcher [~belcher@unaffiliated/belcher] has joined #rust-bitcoin 07:58 -!- michaelsdunn1 [~michaelsd@unaffiliated/michaelsdunn1] has joined #rust-bitcoin 08:06 < andytoshi> elichai2: cool idea about writing `secp256k1_context_create` and `secp256k1_context_destroy` in rust 08:06 < andytoshi> I think you should do it, we can release in rust-secp 0.14.1 08:11 < elichai2> Thanks :) you think these symbols should be provided by rust-secp256k1? 08:11 < andytoshi> yeah 08:12 < andytoshi> i think we can just put them in the FFI modules with the others 08:12 < andytoshi> in the `extern "C"` block and everything 08:20 -!- DeanWeen [~dean@gateway/tor-sasl/deanguss] has joined #rust-bitcoin 08:22 -!- Dean_Guss [~dean@gateway/tor-sasl/deanguss] has quit [Ping timeout: 260 seconds] 08:24 < elichai2> yeah 08:25 < elichai2> i'll do it later today(just got the new XPS 15 so i'll set it up first) 08:27 -!- DeanWeen [~dean@gateway/tor-sasl/deanguss] has quit [Ping timeout: 260 seconds] 08:40 < andytoshi> oo exciting 08:41 < andytoshi> i also have a new laptop, but its ssd and RAM aren't here yet so there's nothing i can do with it :/ 08:46 < elichai2> the wait is the hardest part heh 08:48 < elichai2> andytoshi: what do you think is the best way to make an equivilant of `free` in `secp256k1_context_destroy`? should I call `secp256k1_context_preallocated_size` again to reconstruct the Box pointer and drop it? should I implement my own `free` logic? 08:51 < andytoshi> elichai2: i'd construct a `Context` object, `mem::forget` it and return the pointer 08:51 < andytoshi> when creating 08:51 < andytoshi> and then reconstruct a `Context` and drop it to destroy 09:11 < elichai2> `Context` has no notion of the memory and doesn't implement anything in relation to the memory, create is easy (the same as we do in the `new` function, using the preallocated functions and a Box) 09:11 < andytoshi> Context implements Drop though 09:11 < andytoshi> what do you mean it has no notion of the memory 09:11 < andytoshi> how does its memory get deallocated? 09:12 < andytoshi> oh i see https://github.com/rust-bitcoin/rust-secp256k1/blob/master/src/lib.rs#L550 we implement Drop for specific kinds of contexts 09:12 < andytoshi> but you need to maintain the type (the rawptr is not enough) 09:14 < elichai2> that's the Secp256k1 struct. `secp256k1_context_create` should return `*mut Context` 09:15 < andytoshi> yeah i see 09:15 < andytoshi> this is a bit frustrating, in the libsecp API we sorta exploit the fact that C malloc/free does not track the allocation size 09:15 < andytoshi> but in rust we need to 09:17 < elichai2> you mean that it tracks it by itself? 09:17 < elichai2> we could maybe do this too, add another size_t bytes before the pointer, write the size, offset the pointer and use that 09:18 < andytoshi> we could except that the resulting pointer wouldn't work with the rest of the secp functions 09:18 < andytoshi> oh, offset you say 09:18 < andytoshi> hmmm 09:18 < andytoshi> it'd be hard to make that play nicely with the preallocated API 09:19 < andytoshi> though i guess we could just say "it's UB if you context_destroy anything that context_create didn't give you" 09:20 < andytoshi> we also have to be careful about alignment. though i think rust makes this much easier than C does 09:22 < andytoshi> maaybe we could just use mem::align_of::() and assume that's the machine alignment that preallocated_create needs 09:23 < elichai2> yeah, I can manage the alignment, (pretty sure rust core::ptr have helper functions for that), I hoped we could do that without recreating malloc/free lol 09:23 < elichai2> (afaiu this is technically what malloc/free do) 09:38 < andytoshi> yeah, it's a bit of a PITA but we can do it 09:38 < andytoshi> basically we have to allocate `mem::size_of::()` bytes to store the `usize` length plus an additional `mem::align_of::<[u8]>` so we can align the returned pointer correctly 11:29 -!- elichai2 [uid212594@gateway/web/irccloud.com/x-juixrrwbybhjklzv] has quit [] 11:56 -!- instagibbs [~instagibb@pool-100-15-121-126.washdc.fios.verizon.net] has quit [Quit: ZNC 1.6.3+deb1ubuntu0.1 - http://znc.in] 11:58 -!- instagibbs [~instagibb@pool-100-15-121-126.washdc.fios.verizon.net] has joined #rust-bitcoin 12:43 -!- elichai2 [uid212594@gateway/web/irccloud.com/x-hacfyzmcrztowdnz] has joined #rust-bitcoin 13:05 -!- Deangus [~manjaro-g@205.234.124.67] has joined #rust-bitcoin 15:22 -!- michaelsdunn1 [~michaelsd@unaffiliated/michaelsdunn1] has quit [Remote host closed the connection] 17:14 -!- Deangus [~manjaro-g@205.234.124.67] has quit [Remote host closed the connection] 21:34 < elichai2> andytoshi: what do you think? https://play.rust-lang.org/?gist=11885a92da3c095f070cb3cde2aaa585 do I need to test alignment too? do I care about endianess?(don't think so, the Context isn't portable anyway) --- Log closed Sat Jul 13 00:00:09 2019