summaryrefslogtreecommitdiff
path: root/91/07a6d3389c35261248efce6f3d7857b463a04e
blob: da788632ce9bdf199fc3084f27f68d0579346e3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
Return-Path: <ZmnSCPxj@protonmail.com>
Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137])
 by lists.linuxfoundation.org (Postfix) with ESMTP id 9747EC000B
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Thu, 10 Mar 2022 06:44:09 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by smtp4.osuosl.org (Postfix) with ESMTP id 63E89401CD
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Thu, 10 Mar 2022 06:44:09 +0000 (UTC)
X-Virus-Scanned: amavisd-new at osuosl.org
X-Spam-Flag: NO
X-Spam-Score: -1.599
X-Spam-Level: 
X-Spam-Status: No, score=-1.599 tagged_above=-999 required=5
 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
 DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 FROM_LOCAL_NOVOWEL=0.5, RCVD_IN_MSPIKE_H5=0.001,
 RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001]
 autolearn=ham autolearn_force=no
Authentication-Results: smtp4.osuosl.org (amavisd-new);
 dkim=pass (2048-bit key) header.d=protonmail.com
Received: from smtp4.osuosl.org ([127.0.0.1])
 by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id QauxeLJ8Rnmc
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Thu, 10 Mar 2022 06:44:08 +0000 (UTC)
X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0
Received: from mail-40135.protonmail.ch (mail-40135.protonmail.ch
 [185.70.40.135])
 by smtp4.osuosl.org (Postfix) with ESMTPS id B2AED401B8
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Thu, 10 Mar 2022 06:44:07 +0000 (UTC)
Date: Thu, 10 Mar 2022 06:43:56 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1646894644;
 bh=YzFjTAJBJO4qRl0IY4GIsw621JAn0Vox1s26xn0rBzg=;
 h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To:
 References:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID;
 b=niR0gMRlm4zMoYZ38MbPXc9qp/r3JvpW4Lu800DkiVAjr1pkYhizV6JeRDlFKlKYo
 i8Oiajhusqxs93uxeeNUwWRYVNErG0GJgUcrqTFa6HPAgefBV02G2ZVk5xGgQ52/2O
 Ik+MepIBld5kO6TYZ/HZWIAiis09uk7xDqG4DQy3JYF9viV91MOgcubTRleW8MENWT
 Ios64tRDZUvtLDItWg54ySglqACcS1mOJxOJR9nFHtBFSonbnqHxE9zCgIxqNjngew
 hTjKnz9nteClQEzz74r3jz0m3x9pduxnUSPCG+zu5vTO+W3+UgtenaI610NNP/TE2R
 CYoa9wsK0CFlg==
To: Billy Tetrud <billy.tetrud@gmail.com>
From: ZmnSCPxj <ZmnSCPxj@protonmail.com>
Reply-To: ZmnSCPxj <ZmnSCPxj@protonmail.com>
Message-ID: <8R8D_XAaz7xYHmgWXR-pc3_GVFRzBCNdRT6s3PdKblrnnZPirB0orzLpEUvynBZHNBTiqOM_EteDdUjdqXQ5ZmrGbdlgnnfjIihgFZIXpUM=@protonmail.com>
In-Reply-To: <CAGpPWDafWGcZJOUs4wSEt0DzFP8OXB4nrbx+9sUtTe5JfdwE_w@mail.gmail.com>
References: <EIwjydT0d68Z7Jv8_JlrCbQW6NHSSnIU5sWwE8eX2rm9K3djfzU3nQqUrmt44U8-L9sObegelHCV6Sk7h2nwq_HS1d26FophzjNU7xC_6SE=@protonmail.com>
 <CAGpPWDafWGcZJOUs4wSEt0DzFP8OXB4nrbx+9sUtTe5JfdwE_w@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Cc: Bitcoin Protocol Discussion <bitcoin-dev@lists.linuxfoundation.org>
Subject: Re: [bitcoin-dev] Jets (Was: `OP_FOLD`: A Looping Construct For
	Bitcoin SCRIPT)
X-BeenThere: bitcoin-dev@lists.linuxfoundation.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Bitcoin Protocol Discussion <bitcoin-dev.lists.linuxfoundation.org>
List-Unsubscribe: <https://lists.linuxfoundation.org/mailman/options/bitcoin-dev>, 
 <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=unsubscribe>
List-Archive: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/>
List-Post: <mailto:bitcoin-dev@lists.linuxfoundation.org>
List-Help: <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=help>
List-Subscribe: <https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev>, 
 <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Mar 2022 06:44:09 -0000

Good morning Billy,

> Hi=C2=A0ZmnSCPxj,
>
> >=C2=A0 Just ask a bunch of fullnodes to add this 1Mb of extra ignored da=
ta in this tiny 1-input-1-output transaction so I pay only a small fee
>
> I'm not suggesting that you wouldn't have to pay a fee for it. You'd pay =
a fee for it as normal, so there's no DOS vector. Doesn't adding extra=
=C2=A0witness data do what would be needed here? Eg simply adding extra dat=
a onto the witness script that will remain unconsumed after successful exec=
ution of the script?

I think we would want to have a cleanstack rule at some point (do not remem=
ber out-of-hand if Taproot already enforces one).

So now being nice to the network is *more* costly?
That just *dis*incentivizes jet usage.

> > how do new jets get introduced?
>
> In scenario A, new jets get introduced by being added to bitcoin software=
 as basically relay rules.=C2=A0
>
> > If a new jet requires coordinated deployment over the network, then you=
 might as well just softfork and be done with it.
>
> It would not need a coordinated deployment. However, the more nodes that =
supported that jet, the more efficient using it would be for the network.=
=C2=A0
>
> > If a new jet can just be entered into some configuration file, how do y=
ou coordinate those between multiple users so that there *is* some benefit =
for relay?
>
> When a new version of bitcoin comes out, people generally upgrade to it e=
ventually. No coordination is needed. 100% of the network need not support =
a jet. Just some critical mass to=C2=A0get some benefit.=C2=A0

How large is the critical mass needed?

If you use witness to transport jet information across non-upgraded nodes, =
then that disincentivizes use of jets and you can only incentivize jets by =
softfork, so you might as well just get a softfork.

If you have no way to transport jet information from an upgraded through a =
non-upgraded back to an upgraded node, then I think you need a fairly large=
 buy-in from users before non-upgraded nodes are rare enough that relay is =
not much affected, and if the required buy-in is large enough, you might as=
 well softfork.

> > Having a static lookup table is better since you can pattern-match on s=
trings of specific, static length
>
> Sorry, better than what exactly?=C2=A0

Than using a dynamic lookup table, which is how I understood your previous =
email about "scripts in the 1000 past blocks".

> > How does the unupgraded-to-upgraded boundary work?
> <snip>
> When the non-jet aware node sends this to a jet-aware node, that node wou=
ld see the extra items on the stack after script execution, and would inter=
pret them as an OP_JET call specifying that OP_JET should replace the witne=
ss items starting at index 0 with `1b5f03cf=C2=A0=C2=A0OP_JET`. It does thi=
s and then sends that along to the next hop.

It would have to validate as well that the SCRIPT sub-section matches the j=
et, else I could pretend to be a non-jet-aware node and give you a SCRIPT s=
ub-section that does not match the jet and would cause your validation to d=
iverge from other nodes.

Adler32 seems a bit short though, it seems to me that it may lead to two di=
fferent SCRIPT subsections hashing to the same hash.

Suppose I have two different node softwares.
One uses a particular interpretation for a particular Adler32 hash.
The other uses a different interpretation.
If we are not careful, if these two jet-aware software talk to each other, =
they will ban each other from the network and cause a chainsplit.
Since the Bitcoin software is open source, nothing prevents anyone from usi=
ng a different SCRIPT subsection for a particular Adler32 hash if they find=
 a collision and can somehow convince people to run their modified software=
.

> In order to support this without a soft fork, this extra otherwise unnece=
ssary=C2=A0data would be needed, but for jets that represent long scripts, =
the extra witness data could be well worth it (for the network).=C2=A0
>
> However, this extra data would be a disincentive to do transactions this =
way, even when its=C2=A0better for the network. So it might not be worth do=
ing it this way without a soft fork. But with a soft fork to upgrade nodes =
to support an OP_JET opcode, the extra witness data can be removed (replace=
d with out-of-band script fragment transmission for nodes that don't suppor=
t a particular jet).=C2=A0

Which is why I pointed out that each individual jet may very well require a=
 softfork, or enough buy-in that you might as well just softfork.

> One interesting additional thing that could be done with this mechanism i=
s to add higher-order function ability to jets, which could allow nodes to =
add OP_FOLD or similar functions as a jet without requiring additional soft=
 forks.=C2=A0 Hypothetically, you could imagine a jet script that uses an O=
P_LOOP jet be written as follows:
>
> 5=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Loop 5 times
> 1=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Loop the next 1 operat=
ion
> 3c1g14ad=C2=A0
> OP_JET
> OP_ADD=C2=A0 # The 1 operation to loop
>
> The above would sum up 5 numbers from the stack. And while this summation=
 jet can't be represented in bitcoin script on its own (since bitcoin scrip=
t can't manipulate opcode calls), the jet *call* can still be represented a=
s:
>
> OP_ADD=C2=A0=C2=A0
> OP_ADD=C2=A0=C2=A0
> OP_ADD=C2=A0=C2=A0
> OP_ADD=C2=A0=C2=A0
> OP_ADD=C2=A0=C2=A0
>
> which means all of the above replacement functionality would work just as=
 well.=C2=A0
>
> So my point here is that jets implemented in a way similar to this would =
give a much wider range of "code as compression" possibilities than impleme=
nting a single opcode like op_fold.=C2=A0

Yes, that is certainly the case, and nothing really prevents us bringing "p=
rogramming as compression" to its logical conclusion.

> > To make jets more useful, we should redesign the language so that `OP_P=
USH` is not in the opcode stream, but instead, we have a separate table of =
constants that is attached / concatenated to the actual SCRIPT.
>
> This can already be done, right? You just have to redesign the script to =
consume and swap/rot around the data in the right way to separate them out =
from the main script body.=C2=A0

Yes, but that implies additional operations (and execution overhead), incre=
asing the costs to use jets, which makes it even less palatable to use jets=
, *in addition to* the witness hack disincentivizing jets.

So I would suggest that, if we were to seriously pursue jets, we should rea=
lly replace most of the `OP_PUSH` opcodes with variants that look up in a s=
tatic table at the start, before the executable script body.
I.e. opcodes 0x01 to 0x4e instead mean "push contents of `c1` to `c78` from=
 the constants table", and have aliases `a` through `z` for `c1` to `c26`, =
etc.
That way, replacing the `OP_PUSH` is shorter in the actual SCRIPT (instead =
of a bunch of stack manipulations) and hopefully the overhead of the consta=
nts table can be kept low.

In particular, this helps jets compose more easily; if we want a SCRIPT tha=
t incorporates an existing jet, we do not have to manipulate the stack in a=
 way that the existing jet expects, we just load the proper data into the c=
onstants table.

Or something, anyway.
This seems a fair amount of complexity here.

Regards,
ZmnSCPxj