UP | HOME

A high-level overview.

Our goal here is to learn to use it safely, at a higher level, to make some money by front-running degens chasing shitcoins. For that we have to develop the right understanding of underlying concepts and APIs.

Everything stinks.

TL;DR

Webshit interfaces or browser extensions (Metamask) use web3.js, which JSON-RPC-es a node (geth), which “talks to the network” (by implementing the current revision of the protocols), maintains a stateful storage (which may include a local copy of the entire blockchain) and calls evm to run the code associated with addresses.

There is also web3.py which, basically, is translation from Javascript to bad Python. All the “clients” use web3.py.

Everything stateful imperative huge-class OO “all the way down”.

The point of using Python is availability of a whole ecosystem of high-quality “scientific” and ML libraries, which can be easily hooked in for some quick “exploration”, testing or rapid prototyping.

The current status

The ecosystem is already “too big to fail” (or “have crossed the threshold of immortality”), and just like PHP or Java will “stagnate forever”.

Any “ETH killer” thus is just a meme, because the amount of man-hours spent on ETH is orders of magnitude higher, and it continue of begin developed at a high rate of changes by an enthusiastic internet community.

It short, just like PHP, it stabilized, and it “works”, however crappy.

The inevitable conceptual complexity and redundancy is already slowing it down, and also rises an entry-barrier both for developers and competitors. It will become (already became?) sort of Enterprise Java (J2EE, JavaEE) shitfest, which is vastly complex, badly “designed” crap no one really wants to touch even for a salary.

This, again, proves the emergent social principle, that a huge enthusiastic amateur community beats everything, not in quality but in quantity (look at these node_modules, try not to puke).

One more important principle is that due to inherent low quality it will never be the only choice or a preferred choice (nowadays it is) when a real demand (beyond amateur enthusiasts) arise (seems unlikely), and then a way better (in quality) corporate solution, from Google-like shop, will quickly hit the marker.

Just as PHP long ceased to be “the default choice” for any webshit development, but still is out there (and will be there for a long time, thank to Wordpress and what not), ETH will be there too for a long, long time.

PHP all over again

The history not repeats itself but spirals to a new level.

Just exactly like PHP3+ we have a whole ecosystem, made by unqualified, uneducated, incompetent but over-zealous amateurs right from the start.

The EVM and its bytecode is one big embarrassment. Contracts call each other’s methods without any restrictions (imagine “desinging” an RPC system in such a way!).

The code is “imperative commands” which modify the “global state”. So, the order is crucial and the code in NON-reenterable. The same fundamental problem as with early C library code.

The classic attack exploited these properties. There are no fixes to this “technical debt”.

Solidity, which is supposed to be a high-level language is another embarrassment of an imperative “like an OO” but not OO amateur language, which has “methods” and “events” but no well-defined OO-semantics.

A contract is a sort of an “Object” (as in Java), but is not instantiated from a class “template”, but defined as a set of methods which access both its internal mutable state, and the global mutable state.

Getters and setters, “views” as “generated getters”, “events” are just implicit method-class in disguise, and all the other great design choices.

It uses some sort of static typing, but also a duck-typing, with no standard mechanism to define and type-check. An ERC-20 token is just a set of required (to be implemented) “methods” and “events”, but there is not way to typecheck these.

At the “client level” everything is still imperative, stateful with lame large imperative OO classes in Python or Javascript on top of it. Even the small benefits of OOP has been thrown out of the window – the code is badly structured.

The “provider” exposes an imperative, stateful (with access to the global mutable state of the node) JSON-RPC API. REST APIs are supposed to be stateless.

Of course, the “client libraries” (wrappers) (like web3.py) and nodes (like geth) are out of sync (as at the time of writing) and one has to know the exact versions which supposedly works together (the APIs are matched).

The abstractions and their names are literally idiotic – both concepts and in data-fields, and this tells everything about the state of the whole “project”.

It is literally a fucking mess of lowest quality amateur crap, both at the conceptual level an implementations.

Inconsistent and stupid naming reveals sloppy thinking and lack of any unification and minimization attempts, which is the direct result of a total lack of mathematical maturity.

All the APIs are stateful, over-structured (because it seems so cool to them), full of unnecessary, redundant abstractions, thrown in at a whim without much thinking. I have already mention the idiotic naming.

And, of course, the worst possible kind of JSON everywhere.

Concepts

It could have been as clean and well-researched as Erlang, but these “architects” and “developers” never read a single book on the subject in their whole life

Anyway, we have to extract actual (and useful for us) high-level concepts, hiding all the ugly details and inconsistencies within.

Contract

A contract in the sense of Solidity is a code (its procedures) and data (the state variables) that resides at a specific address on the Ethereum blockchain.

So, it theory, it has to be some pure functions with send and receive primitives (and pattern-matching!), similar to Erlang processes. But they never read a single book.

Instead we have a fucking ad-hook mess by unqualified amateurs from all over the world.

Anyway, conceptually, there are procedures at addresses, executed inside of an instance of a Virtual Machine. These VMs ran on user’s computers, and execute procedures for gas fees.

These “procedures” are full of “getters” and “setters” and more like “OO objects with a state” (but there is no this) than pure message-passing “Actors”.

Just like it is with objects, calling methods is the way to send messages. This is just a proven wrong way, but how could “vitaliks” they know?

Like objects in, say, Python, everything is public and writable by anyone. Absolutely idiotic idea for a supposedly distributed system. This and similar fundamental fuckups is their technical debt.

Naive, young “vitaliks” dreamed about “objects” instead of Actors, method calls instead of asynchronous message-passing. Why, a distributed system by amateurs PHP coders.

Just keep in mind that originally everything has been based on fundamentally wrong principles, having nothing to do with how distributed systems should be designed and implemented.

And these 256bit integers LMAO, a boxed type without any hardware support. No proper Numeric Tower for mostly arithmetic workloads. Anyway, “vitaliks” is a meme multi-millionaire, and I am a literal nobody.

Node

Just like an Erlang node, but you know. These are imperative processes, which manage its stateful storage.

geth is a huge monolith Go program with a hundred of low-quality dependencies. What would one expect?

The user-level “interface” code (web3.js or web3.py) JSON-RPC it, and it, in turn, “talks to the network”.

EVM

Sort of JVM, you know, but “designed” by literal degens. It is supposed to be isolated (totally sandboxed) but in fact it rely on the stateful storage.

It executes the “contracts” - the code which is associated with particular addresses on the network.

I do not want to look into the EVM, I am pretty sure that they never read “The Implementation Of Functional Programming Languages”, never heard of graph reduction, what is BEAM and ignored the huge literature on the subject.

Our primary concern is how to call the contract code correctly and safely.

Addresses

Conceptually, Ethereum addresses are just like Erlang “names”, and the code must be pure with carefully designed primitives, just understand and follow the best practices of developing robust distributed systems.

An address is a particular cryptographic hash of something unique.

Account

This is a wrapper around the unique private key, which is just a big prime.

Private Key

Conceptually, everything rely on the well-understood key-pairs cryptography, which, in turns, rely on a pair of a huge prime numbers. This is OK, if we do not look at the implementation details.

Identities

From this we get cryptographic hashes as unique identities of various components. This is also OK.

Transactions

This is a broadcasted “message”, which contain “source” (From:) and “destination” (To:) addresses and the optional “amount” and “data” fields.

The “amount” is for transfer (kind of) transactions, the “data” is for calling the “contract” (specified by the “destination” address).

When calling a contract the “amount” field can be used too, but it is better to avoid this practice.

Messages

There are “internal transactions”, initiated by a contract, which are called messages.

Conceptually, every transaction is a “signed” message (from, to), and every message has to be some kind of a transaction.

So, now what?

For last 10 years they have managed to put ad-hook fixes and make it usable. So, by just using current solutions (geth and solc) very carefully one can use the ecosystem for some simple tasks.

The obvious ones are to collect transaction fees, just like Uniswap did.

Author: <schiptsov@gmail.com>

Email: lngnmn2@yahoo.com

Created: 2023-08-08 Tue 18:37

Emacs 29.1.50 (Org mode 9.7-pre)