--- Log opened Thu Nov 02 00:00:14 2023 01:19 -!- duderonomy [~duderonom@h66-220-99-202.bendor.broadband.dynamic.tds.net] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…] 02:42 -!- salvatoshi [~salvatosh@genymobile-2-6-86.fib.nerim.net] has joined #bitcoin-rust 06:09 -!- DarrylTheFish [~DarrylThe@user/DarrylTheFish] has joined #bitcoin-rust 06:09 -!- DarrylTheFish [~DarrylThe@user/DarrylTheFish] has quit [Max SendQ exceeded] 06:41 -!- Ademan [~ademan@47.185.95.178] has quit [Quit: leaving] 06:56 -!- pablomartin [~pablomart@92.118.61.223] has joined #bitcoin-rust 08:00 < stevenroose> Uff, I'm struggling with some complicated refactor here 08:00 < stevenroose> I wanted one simple thing: while parsing instructions from a script, keep track of where in the script I am. This is needed for dealing with OP_CODESEPARATOR 08:01 < stevenroose> But the whole construction we have around Instructions etc is based on an iterator and not generic. 08:01 < stevenroose> I think making it generic would be quite ugly and annoying. 08:01 < stevenroose> So I started to try and write a Instruction::parse_next(script: &Script) function, but it turns out all (many) the helper methods in that code are made to deal with this iterator 08:36 -!- Guest7221 [~Guest7221@user/nex8192] has left #bitcoin-rust [Error from remote client] 08:54 -!- Ademan [~Ademan@47.185.95.178] has joined #bitcoin-rust 09:05 -!- duderonomy [~duderonom@h66-220-99-202.bendor.broadband.dynamic.tds.net] has joined #bitcoin-rust 09:57 -!- salvatoshi [~salvatosh@genymobile-2-6-86.fib.nerim.net] has quit [Ping timeout: 245 seconds] 10:08 -!- salvatoshi [~salvatosh@141.255.129.219] has joined #bitcoin-rust 11:22 -!- salvatoshi_ [~salvatosh@141.255.129.219] has joined #bitcoin-rust 11:22 -!- salvatoshi [~salvatosh@141.255.129.219] has quit [Read error: Connection reset by peer] 11:41 < andytoshi> stevenroose: i think the Instructions iterator should keep track of the current script index 11:41 < andytoshi> and maybe even yield it 11:42 < andytoshi> like, right now Instruction is an enum .. but maybe it should be a structure similar to what bitcoin core has, which has an opcode, an optional byte slice (for pushes), a script index, etc 11:42 < stevenroose> I actually found a workaround to do it 11:42 < stevenroose> I kept my refactor in a branch, but it was getting messy 11:43 < stevenroose> because Instructions has `.to_script()` you can get the byte position of the next opcode using `original_script.len() - instructions.as_script().len()` 11:43 < stevenroose> *because Instructions has `.as_script()` you can get the byte position of the next opcode using `original_script.len() - instructions.as_script().len()` 11:43 < stevenroose> But yeah I don't really like the implementation using the iterator and totally abstracting away the script 11:44 < stevenroose> andytoshi: Especially not since then we introduce a second function to parse scriptints (one specifically for iterators), which increases bug surface for already-tricky scriptint code 11:45 < stevenroose> I am doing various small improvements in a branhc as long as I am working on this interpreter thing, some of them I will push faster but others I'll wait around until I have time to followup PRs. 11:45 < stevenroose> fun fact: it took me 5 minutes to implement OP_CAT (naive without size restrictions) and let users optionally enable it 11:59 < stevenroose> andytoshi: what I mostly dislike is that you can't use Instructions to go back to a script, because it doesn't maintain non-minimally encoded push data 12:01 < stevenroose> so f.e. in pre-segwit checksig, you need to remove the signature push from the scriptcode (it seems..) that would be easy with `.instructions().filter(..).for_each(|i| builder.add(i))` or something 12:01 < stevenroose> but it's pretty non-trivial if you have to account for non-minimal pushes 12:02 -!- salvatoshi_ [~salvatosh@141.255.129.219] has quit [Read error: Connection reset by peer] 12:13 -!- Guest7221 [~Guest7221@user/nex8192] has joined #bitcoin-rust 12:16 < stevenroose> This code is hard to read in Core, but it seems that I don't actually have to remove the size prefixes only the actual signature itself from the raw bytes, so that's ok 12:41 < andytoshi> stevenroose: yeah, agreed on all counts 12:41 < andytoshi> i might PR to replace the Instruction enum with a struct that preserves all the data 12:41 < andytoshi> though if you have a workaround for now i guess it's not too urgent 12:46 < andytoshi> commented on your issue 12:59 < stevenroose> thanks 14:19 -!- salvatoshi_ [~salvatosh@lfbn-idf3-1-1331-187.w92-170.abo.wanadoo.fr] has joined #bitcoin-rust 14:44 -!- salvatoshi_ [~salvatosh@lfbn-idf3-1-1331-187.w92-170.abo.wanadoo.fr] has quit [Ping timeout: 240 seconds] 17:47 -!- Guest7221 [~Guest7221@user/nex8192] has left #bitcoin-rust [Error from remote client] 17:49 -!- pablomartin [~pablomart@92.118.61.223] has quit [Ping timeout: 255 seconds] 19:31 -!- duderonomy [~duderonom@h66-220-99-202.bendor.broadband.dynamic.tds.net] has quit [Ping timeout: 260 seconds] 20:17 -!- pablomartin [~pablomart@92.118.61.217] has joined #bitcoin-rust 22:14 -!- pablomartin [~pablomart@92.118.61.217] has quit [Ping timeout: 272 seconds] 22:44 -!- Ademan [~Ademan@47.185.95.178] has quit [Ping timeout: 260 seconds] --- Log closed Fri Nov 03 00:00:16 2023