[Bitcoin-dev] Bitcoin Scripting And Lisp

Pretty much all the opcodes in the first section are directly from chia lisp, while all the rest are to complete the “bitcoin” functionality. However, whether you do or don’t support that softfork, as far as the rest of the script is concerned, the expression will either fail entirely or evaluate as zero; so anyone who doesn’t support the softfork can just replace it with zero and continue on, treating it as if it had costed “cost” units. By contrast, chia lisp has fewer opcodes than Simplicity’s jets, has feasible approaches to low-impact soft forks to increase functionality, can be used with only two levels of abstraction (lisp with macros and the opcodes-only vm level) that seem not too bad to understand, and (in my opinion) doesn’t seem too hard to implement/maintain reasonably. A particular advantage of lisp-like approaches is that they treat code and data exactly the same — so if we’re trying to leave the option open for a transaction to supply some unexpected code on the witness stack, then lisp handles that really naturally: you were going to include data on the stack anyway, and code and data are the same, so you don’t have to do anything special at all.

One of the things people sometimes claim about bitcoin as an asset, is that it’s got both the advantage of having been first to market, but also that if some altcoin comes along with great new ideas, then those ideas can just be incorporated into bitcoin too, so bitcoin can preserve it’s lead even from innovators. The other is to use the “softfork” opcode — chia defines it as: (softfork cost code) though I think it would probably be better if it were (softfork cost version code) where the idea is that “code” will use the “x” opcode if there’s a problem, and anyone supporting the “version” softfork can verify that there aren’t any problems at a cost of “cost”. You could also allow things to be pushed onto the stack that (recursively) can push things onto the stack — the language “Joy” takes this approach. The thing that’s most appealing to me about bitcoin script as it stands (beyond “it works”) is that it’s really pretty simple in an engineering sense: it’s just a “forth” like system, where you put byte strings on a stack and have a few operators to manipulate them.

To me, it seems like chia lisp is a better answer to the problem here than the Simplicity language. The CREATE/ASSERT bundling stuff is interesting; and could be used to achieve functionality like the “transaction sponsorship” stuff. 100kB of serialized clvm code from a random block gzips to 60kB; optimising the serialization for small lists, and perhaps also for small literal numbers might be a feasible improvement; though it’s not clear to me how frequently serialization size would be the limiting factor for cost versus execution time or memory usage. And while I’ve never really coded in lisp at all, my understanding is that its biggest problems are all about doing things efficiently at large scales — but script’s problem space is for very small scale things, so there’s at least reason to hope that any problems lisp might have won’t actually show up for this use case. Both those essentially give you a lisp-like language — lisp is obviously all about lists, and a binary tree is just made of things or pairs of things, and pairs of things are just another way of saying “car” and “cdr”. For example, rather than the streaming-sha256 approach in Elements, where you could write: “a” SHA256INITIALIZE “b” SHA256UPDATE “c” SHA256UPDATE “d” SHA256FINALIZE to get the sha256 of “abcd” without having to CAT them first (important if they’d potentially overflow the 520B stack item limit), in chia lisp you write: (sha256 “a” “b” “c” “d”) which still has the benefit of streaming the inputs into the function, but only adds a single opcode, doesn’t involve representing the internal sha256 midstate on the stack, and generally seems easier to understand, at least to me.

Or perhaps you could arbitrarily limit the strings to a max of 520 bytes at a consensus level, and the corresponding Simplicity types to 4160 bits and go from there? Simplicity requires finite types. FOLD and in exactly the same context, I was wondering what the simplest possible language that had some sort of map construction was — I mean simplest in a “practical engineering” sense; I think Simplicity already has the Euclidean/Peano “least axioms” sense covered. I don’t think they’ve solved the broader problem, and thus I think it still makes more sense to stick with bitcoin’s current model here. At least I think so? The last two are extensions that are more food for thought than a real proposal. This would mean also being able to pull information about the utxo being spent to obtain its amount and scriptpubkey, which are committed to wit ANYPREVOUT. 0) 1 (if (l sigs) (if (checksig (f sigs) (f keys)) (checkmultisig (r sigs) (r keys) (- k 1)) (checkmultisig sigs (r keys) k) ) 0 ) ) Here each “sig” is a pair of a 64B bip340 signature and a 1B sighash; instead of a 65B string combining both, and sigs, keys are lists, and k is the number of successful signature checks you’re requiring for success.

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Comments

No comments to show.

New Casinos

BC Game: Get $100 bonus cash + 200 bonus spins

Ocean Casino: 200% match bonus up to $500 + 20 bonus spins

1 Free Spin credited for every $1 deposit. Up to $100 + 100 Spins

Monte Casino: Get 10 no deposit spins + $100 Bonus

Claim a 100% deposit bonus up to $250 + free spins

© Copyright 2024 Coin Play Casino
Powered by WordPress | Mercury Theme