[HN Gopher] std::unique_ptr implementation backed by Ethereum NFTs
___________________________________________________________________
std::unique_ptr implementation backed by Ethereum NFTs
Author : abhorrence
Score : 534 points
Date : 2021-04-11 21:32 UTC (1 days ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| sergiotapia wrote:
| The Andy Kaufman of programmers
| tolbish wrote:
| > - void Seal::MakeSound() { std::cout << "Ow, ow, ow!" <<
| std::endl; }
| kmarc wrote:
| If you like this kind of humor, I'd recommend following Zhouwei
| Zhang on twitter[1] (not affiliated). His posts, I think,
| resonates well with HN's audience.
|
| [1]: https://twitter.com/zhuowei
| cinntaile wrote:
| I hope someone turns this into an NFT, to complete the circle.
| foota wrote:
| And you thought memory management was expensive _before_!
| DDR0 wrote:
| Actually it's cheaper this way, because you can sell the NFT to
| fund the operation. Before, you had to _pay_ for everything it
| ran on!
| TeMPOraL wrote:
| That's why everyone loves JavaScript so much. You don't have
| to pay for the electricity your code burns, _your users do_.
| neurostimulant wrote:
| I wonder if it's possible to run a linux vm (ala jslinux)
| in browser, connect them to the network via a proxy to
| allow the apps inside the linux vm to make arbitrary
| connections (I think I saw a jslinux clone that uses some
| form of proxy to allow tcp access from inside the vm, but
| forgot the name), then run a kubernetes worker node in
| them. Then you can try to make the page viral somehow and
| then enjoy your huge and free kubernetes cluster!
| TeMPOraL wrote:
| I have a sinking suspicion that Facebook's Messenger
| webapp is doing exactly that - its UI has been very laggy
| for me in the past months, and the issue persists through
| refreshes, browser reboots and system reboots.
|
| It's the only thing that makes sense. I mean, they
| couldn't have screwed up a _chat client_ that badly...
| foota wrote:
| They don't have the same depth of experience in
| developing chat apps as some other bay area companies.
| fctorial wrote:
| Technology gone berzerk.
| yjftsjthsd-h wrote:
| Well yes, but it's a joke specifically making fun of that, so
| it's not really berserk itself.
| mmastrac wrote:
| That's an expensive operation.
| joshspankit wrote:
| Was curious about this. If implemented, exactly how expensive
| would it get in the first 24h (assuming ETH at $2000USD)?
| masklinn wrote:
| Depends how often the pointer is moved. According to the
| author's Twitter at the time they were asked each move cost
| $18.69.
| joshspankit wrote:
| Sorry, I know my question depends on a lot of variables.
|
| I'm just looking for a "sanity check" example, but I only
| have a vague notion of pointer being a reference to a spot
| in memory, as well as knowing that doing transactions on
| the ETH network incurs fees.
|
| Are there any "power user" examples? Like, how much would
| it cost to run `ls` on a folder of 200 files, or encoding a
| video with `ffmpeg` (or insert proper example here since I
| don't know where `unique_ptr` is used lol)
| im3w1l wrote:
| It's a bit complictated, requiring npm and cargo and c++. But
| still, a "hello world" demonstration like this is very valuable.
| It wouldn't surprise me if real projects use this as a starting
| point.
| [deleted]
| varajelle wrote:
| I was wondering if it was a joke, until I saw the white paper.
| AndrewStephens wrote:
| That's the problem with all the idiotic blockchain projects
| around at the moment. I was only ninety percent sure it was a
| joke until about halfway through when the performance chart
| confirmed it but it is only slightly more ridiculous than
| several "legitimate" projects.
| chrismorgan wrote:
| Hmm, 994 bytes; that's rather small, wonder what's in it?--
|
| Ah.
| scharman wrote:
| ok, u got me - it was clearly a parody, but the whitepaper made
| me check and it took a few seconds to click. Love ur work!
| jb1991 wrote:
| Just look at the results from the "example program" for
| benchmarking.
| ShroudedNight wrote:
| To be fair, the paper _is_ white.
| Clewza313 wrote:
| From the readme: "As we all know, adding blockchain to a
| problem automatically makes it simple, transparent, and
| cryptographically secure."
| imron wrote:
| The benchmarks showing negligible performance differences also
| gave it away.
| iampims wrote:
| > Made with by a Blockchain Expert who wrote like 100 lines of
| Solidity in 2017 (which didn't work)
|
| This made me chuckle.
| jnwatson wrote:
| "For a limited time, you can buy any Git commit from this
| repository as a Non-Fungible Token on my Content-First Multimedia
| Proof-of-Authority revision-controlled realtime collaborative
| private enterprise blockchain (a shared Google Doc)."
|
| Made my day.
| somebodythere wrote:
| Making pointers on mainnet is expensive these days, I was able to
| stand up a Ganache testnet so that my pointers are created faster
| and at lower cost. Fantastic library.
| er4hn wrote:
| WARNING: This code is not safe to store secrets with.
|
| From the readme:
|
| > others may view the NFT/use the object, but only the owner can
| transfer/destroy the NFT/object. > absolutely no protection
| against just pirating the image represented by the NFT/copying
| the pointer out of the unique_ptr
|
| I would open an issue to support RFC 8959 and refuse to mint NFTs
| with secret-token URIs, but I think instead I will learn how to
| mint an NFT of RFC 8959.
| iudqnolq wrote:
| The author has an excellent reply to a question on twitter
|
| >> What are the gas prices like for copying a pointer?
|
| > Copying an nft_ptr is illegal. Moving an nft_ptr takes 87,169
| gas:
| https://goerli.etherscan.io/tx/0xcbe06fdd54bd9d221993c875022...
| at mainnet gas prices of ~100 Gwei, equal to 0.0087169 ETH, or
| $18.69 USD. (This was intentionally written to waste resources
| for no benefit, just like cryptocurrencies themselves)
|
| > The C++ "as-if" rule means the compiler is allowed to optimize
| away the move, but it still needs to charge the $18.
| TeMPOraL wrote:
| A masterfully executed satire!
|
| The paranoid part of me worries this will be used for real in the
| future.
|
| The thing with building abstractions is, once you cover enough
| pieces to make a complete abstraction, people might run away with
| it and build castles on top, completely ignoring that the
| abstraction is implemented in terms of a joke. And once enough
| software is built on it, it'll be easier to start optimizing the
| joke to work faster than to get rid of it...
|
| (Also, I don't see any mention what happens to the NFT when the
| nft_ptr goes out of scope.)
| newswasboring wrote:
| Your second paragraph paints a pretty grim scenario. Has this
| ever happened before? Someone building castles on a joke
| abstraction?
| mhh__ wrote:
| Javascript?
| [deleted]
| pjc50 wrote:
| Dogecoin?
| newswasboring wrote:
| What infrastructure in made on top of dogecoin? I feel like
| everyone uses it as a joke coin.
| davidhowlett wrote:
| Flask was originally an April fools joke with what the author
| thought was a silly design. It is now widely used, including
| in production systems at my company.
|
| http://mitsuhiko.pocoo.org/flask-pycon-2011.pdf
| newswasboring wrote:
| Lol this isn't grim at all. As far as I understand, they
| came up with a pretty good architecture as a joke.
| avery42 wrote:
| In case anyone wants a video of the original talk:
| https://archive.org/details/pyvideo_440___opening-the-flask
| connor4312 wrote:
| Joking aside, their white paper
| (https://raw.githubusercontent.com/zhuowei/nft_ptr/main/white...)
| is a must-read.
| m3kw9 wrote:
| Did I just got hacked reading this "white paper"?
| vanderZwan wrote:
| Perfect example of
| https://en.wikipedia.org/wiki/Does_exactly_what_it_says_on_t...
| mhh__ wrote:
| Maybe I'm too young, but I had no idea the phrase only
| originated in 1994
| ttul wrote:
| The presence of a white paper gives any project the luster of
| pseudo-academic rigor.
| beached_whale wrote:
| I just wanted to use a one word reply, but that might have
| lacked the context. So I will say, good job :)
| rfoo wrote:
| zajebisty
| athrowaway3z wrote:
| I was tempted to open an issue:
|
| Printing on green paper did not make it white.
| stevewodil wrote:
| Do it! Bug: printing the white paper on colored paper does
| not work as expected
| iudqnolq wrote:
| As are their benchmarks
|
| > nft_ptr has negligible performance overhead compared to
| std::unique_ptr, as shown by this benchmark on our example
| program:
|
| std::unique_ptr 0.005 seconds
|
| nft_ptr 3 minutes
| cbolton wrote:
| It would be nice to have energy consumption benchmarks too...
| benmanns wrote:
| And only one of these options costs $100s in gas fees.
| horsawlarway wrote:
| I loved this section of the readme - I nearly choked I was
| laughing so hard.
|
| That said, I don't really think 3 minutes is that terrible
| for what it's doing. But man the phrasing there tickled me.
| penguin_booze wrote:
| Thank you. I must say that this is the ONLY white paper I
| managed to understand, ever. Very concise. Kudos to the
| authors. I wish we had more like this.
| MauranKilom wrote:
| > Non-Fungible Tokens and std::unique_ptr have the exact same
| semantics:
|
| > [...] absolutely no protection against just pirating the image
| represented by the NFT/copying the pointer out of the unique_ptr
|
| Perfect!
| FeepingCreature wrote:
| "You can also help by going full r/roastme on my code: this is
| only my second Rust project, and I would appreciate guidance on
| my journey to carcinization."
|
| This is a very clever joke, so let me dissect it:
|
| The "carcinization" is a callout to, I presume, xkcd 2314 (
| https://xkcd.com/2314/ ), about how crustaceans tend to
| repeatedly evolve into crabs, and xkcd 2418 (
| https://xkcd.com/2418/ ), which makes the claim that any
| conversation with Randall evolves towards the topic of
| carcinization.
|
| A cutesy nickname for Rust fans is "Rustaceans". (Rust-aceans,
| like crustaceans.) With some creativity, we may then see the
| process of becoming an experienced Rust user as another instance
| of carcinization, especially given the similarity between xkcd's
| "metacarcinization" and the way that rustaceans, as fans are wont
| to do, tend to find a way to make the conversation about Rust.
| masklinn wrote:
| > The "carcinization" is a callout to, I presume, xkcd 2314 (
| https://xkcd.com/2314/ ), about how crustaceans tend to
| repeatedly evolve into crabs
|
| That's not an xkcd joke though, it's an actual observation of
| evolutionary biology, first published in 1916.
| FeepingCreature wrote:
| Correct, but I suspect most geeks who know the term know it
| from xkcd, and that supports the additional metajoke about
| changing the topic to talk about Rust.
| mhh__ wrote:
| Considering unique_ptr is not zero cost, this is fair game I say.
| beached_whale wrote:
| With clang you can make a unique_ptr that is though. It just
| cannot be used for the std one as that would break existing
| code. But clang has an attribute [[clang::trivial_abi]] and
| with that the cost really is zero compared to a pointer.
| hjnilsson wrote:
| Technical side-note: Are NFTs free to create and/or use? Or do
| they require contribution of processing power and/or paying "the
| Network" for it using your own ETH?
| Jhsto wrote:
| Kind of, you can use a development network to which you can get
| free tokens to pay the gas fees.
| joshspankit wrote:
| People are regularly paying $75-$250USD in gas fees to mint
| individual NFTs
| no-s wrote:
| > how to write a (trivial) program in Rust without fighting the
| borrow checker once
|
| curiously apt, yet true...
| mam2 wrote:
| "As we all know, adding blockchain to a problem automatically
| makes it simple, transparent, and cryptographically secure."
| qeternity wrote:
| > Future steps
|
| > nft_ptr instances are themselves ERC-20 tokens with 0 supply,
| for forward compatibility with our next library, nft_shared_ptr.
|
| > nft_shared_ptr will implement reference counting with security
| by selling shares to the owned object until the SEC complains.
|
| The whole repo is a goldmine but this really had me in stitches.
| TeMPOraL wrote:
| I'd love to see how they'll implement nft_weak_ptr and its
| creation from and conversion to a nft_shared_ptr :).
| richieartoul wrote:
| This is one of the most subtley funny things I've ever seen on
| H.N, specifically because the target audience is so small. You
| have to understand both C++ memory management and what an NFT is.
| aberoham wrote:
| They should have called out the usage of Nocode to create the
| white paper
| grandmczeb wrote:
| And it's written in rust!
| wyldfire wrote:
| Wow, I thought for sure it was a punchline, but no:
|
| > written in rust for the hipster cred.
|
| I'm probably a founding member of the Rust Evangelism Strike
| Force but stuff like this seems ... way overboard. Almost
| like a Poe's Law demonstration - it's hard to determine
| whether it's satire or not.
| nexuist wrote:
| These are my favorite coding projects. No business case, no
| practicality for non-developers (or developers for that
| matter), no long term support, no problem solving. Just a
| love/hate letter to software and the absurdity it brings to
| our world.
| gspr wrote:
| I assume you're very familiar with Tom7, and in
| particular his SIGBOVIK submissions, but just in case:
| Tom7!
|
| (Good starting point for anyone who's not:
| https://m.youtube.com/watch?v=HLRdruqQfRk )
| sanxiyn wrote:
| You may enjoy DOS Subsystem for Linux:
| https://github.com/haileysome/doslinux
| wyldfire wrote:
| I get the sense from other comments in this thread that I
| did indeed miss the point - it _is_ satire. Just a little
| too subtle IMO.
| sellyme wrote:
| > Just a little too subtle IMO.
|
| Direct quote from the linked page:
|
| > As we all know, adding blockchain to a problem
| _automatically_ makes it simple, transparent, and
| cryptographically secure.
| TeMPOraL wrote:
| Or:
|
| > nft_ptr has negligible performance overhead compared to
| std::unique_ptr, as shown by this benchmark on our
| example program: Implementation
| Runtime std::unique_ptr 0.005 seconds
| nft_ptr 3 minutes
| floatingatoll wrote:
| It's still a punchline
| pjc50 wrote:
| Of course it's satire; one of the most absurdist forms of
| satire is finding something ridiculous yet taken seriously,
| and treating it _far more seriously than that_.
|
| Of course it's written in Rust.
| wrigby wrote:
| Aside from the brilliant satire, it's worth pointing to the "What
| I Learned" section of the readme: how C++ smart
| pointers are implemented how to implement a Non-Fungible
| Token how the Ethereum ecosystem has evolved since I wrote
| my last smart contract in 2017 how to integrate my previous
| Solidity, Truffle, and Ganache workflow with new tools such as
| OpenZeppelin and hosted wallets how to write a (trivial)
| program in Rust without fighting the borrow checker once
| how to use rust-web3, serde_json, and the openssl crates
| how to call Rust from C
|
| I often struggle with deciding what to build as a practice
| project when I want to learn a new skill, and this is a good
| reminder that "humor" is an acceptable answer. Using a satirical
| project to learn how smart pointers are implemented is genius.
| MarkSweep wrote:
| This is great; now I feel like I have to rewrite
| programmerspoop.com in Rust to keep up.
| horsawlarway wrote:
| This is the hardest I've laughed all year. Mad props to the
| author for poking fun while doing a very cool (and crazy)
| project.
|
| Don't know why but the deadpan humor here really reminds me of
| reading Bill Bryson.
___________________________________________________________________
(page generated 2021-04-12 23:02 UTC)