diff --git a/docs/design/TCP.md b/docs/design/TCP.md index a46a72e..dd5722a 100644 --- a/docs/design/TCP.md +++ b/docs/design/TCP.md @@ -102,6 +102,11 @@ upper bound. To find the actual MTU, have to have a don't fragment field (which is these days generally set by default on UDP) and empirically track the largest packet that makes it on this connection. Which TCP does. +MTU (packet size) and MSS (data size, $MTU-40$) is a +[messy problem](https://www.cisco.com/c/en/us/support/docs/ip/generic-routing-encapsulation-gre/25885-pmtud-ipfrag.html) +Which can be side stepped by always sending packets +of size 576 contiaing 536 bytes of data. + ## first baby steps To try and puzzle this out, I need to build a client server that can listen on diff --git a/docs/design/peer_socket.md b/docs/design/peer_socket.md index eca13bc..90c2eda 100644 --- a/docs/design/peer_socket.md +++ b/docs/design/peer_socket.md @@ -67,8 +67,142 @@ well be handled by an instance of a class containing only a database index. # Representing concurrent communicating processes +node.js represents them as continuations. Rust tokio represents them +as something like continuations. Go represents them lightweight +threads, which is a far more natural and easier to use representation, +but under the hood they are something like continuations, and the abstraction +leaks a little. The abstraction leaks a little in the case you have one +concurrent process on one machine communicating with another concurrent +process on another machine. + +Well, in C++, going to make instances of a class, that register +call backs, and the callback is the event. Which had an instance +of a class registered with the callback. Which in C++ is a pointer +to a method of an object, which has no end of syntax that no one +ever manages to get their head around. + +So if `dog` is method pointer with the argument `bark`, just say +`std::invoke(dog, bark)` and let the compiler figure out how +to do it. `bark` is, of course, the data supplied by the message +and `dog` is the concurrent communicating process plus its registered +callback. And since the process is sequential, it knows the data +for the message that this is a reply to. + A message may contain a reply-to field and or an in-regards-to field. +In general, the in-regards-to field identifies the state machine +on the server and the client, and remains unchanged for the life +of the state machines. Therefore its handler function remains unchanged, +though it may do different things depending +on the state of the state machine and depending on the type of the message. + +If the message only has an in-regards-to field, then the callback function for it +will normally be reginstered for the life of the councurrent process (instance) + +If it is an in-reply-to, the dispatch mechanism will unregister the handler when it +dispatches the message. If you are going to receive multiple messages in response +to a single message, then you create a new instance. + +In C, one represents actions of concurrent processes by a +C function that takes a callback function, so in C++, +a member function that takes a member function callback +(warning, scary and counter intuitive syntax). + +Member to function pointers are a huge mess containing +one hundred workarounds, and the best workaround is to not use them. +People have a whole lot of ingenious ways to not use them, for example +a base class that passes its primary function call to one of many +derived classes. Which solution does not seem applicable to our +problem. + +`std:invoke` is syntax sugar for calling weird and wonderful +callable things - it figures out the syntax for you at compile +time according to the type, and is strongly recommended, because +with the wide variety of C++ callable things, no one can stretch +their brain around the differing syntaxes. + +The many, many, clever ways of not using member pointers +just do not cut it, for the return address on a message ultimately maps +to a function pointer, or something that is exactly equivalent to a function pointer. + +Of course, we very frequently do not have any state, and you just +cannot have a member function to a static function. One way around +this problem is just to have one concurrent process whose state just +does not change, one concurrent process that cheerfully handles +messages from an unlimited number of correspondents, all using the same +`in-regards-to`, which may well be a well known named number, the functional +equivalent of a static web page. It is a concurrent process, +like all the others, and has its own data like all the others, but its +data does not change when it responds to a message, so never expects an +in-reply-to response, or if does, creates a dynamic instance of another +type to handle that. Because it does not remember what messages it sent +out, the in-reply-to field is no use to it. + +Or, possibly our concurrent process, which is static and stateless +in memory, nonetheless keeps state in the database, in which case +it looks up the in-reply-to field in the database to find +the context. But a database lookup can hang a thread, +which we do not want to stall network facing threads. + +So we have a single database handling thread that sequentially handles a queue +of messages from network facing threads driving network facing concurrent +processes, drives database facing concurrent processes, +which dispatch the result into a queue that is handled by +network facing threads that drive network facing concurrent +processes. + +So, a single thread that handles the network card, despatching +message out from a queue in memory, and in from queue in memory, and does not +usually or routinely do memory allocation or release, or handles them itself +if they are standard, common, and known to be capable of being quickly handled, +a single thread that handles concurrent systems that are purely +memory to memory, but could involve dynamic allocation of memory, +and a single thread that handles concurrent state machines that do database +lookups and writes and possibly dynamic memory allocation, but do not +directly interact with the network, handing that task over to concurrent +state machines in the networking thread. + +So a message comes in through the wire, where it is handled +by a concurrent process, probably a state machine with per connection +state, though it might have substates, child concurrent processes, +for reassembling one multipart message without hanging the next, + +It then passes that message to a state machine in the application +layer, which is queued up in the queue for the thread or threads appropriate +to its destination concurrent process, and receives messages from those threads, +which it then despatches to the wire. + +A concurrent process is of course created by another +concurrent process, so when it completes, +does a callback on the concurrent process that created it, +and any concurrent processes it has created +are abruptly discarded. So our external messages and events +involve a whole lot of purely internal messages and events. +And the event handler has to know what internal object this +message came from, +which for external messages is the in-regards-to field, +or is implicit in the in-reply-to field. + +If you could be receiving events from different kinds of +objects about different matters, well, you have to have +different kinds of handlers. And usually you are only +receiving messages from only one such object, but in +irritatingly many special cases, several such objects. + +But it does not make sense to write for the fully general case +when the fully general case is so uncommon, so we handle this +case ad-hoc by a special field, which is defined only for this +message type, not defined as a general quality of all messages. + +It typically makes sense to assume we are handling only one kind +of message, possibly of variant type, from one object, and in +the other, special, cases, we address that case ad hoc by additional +message fields. + +But if we support `std:variant`, there is a whole lot of overlap +between handling things by a new variant, and handling things +by a new callback member. + The recipient must have associated a handler, consisting of a call back and an opaque pointer to the state of the concurrent process on the recipient with the messages referenced by at least one of diff --git a/docs/libraries.md b/docs/libraries.md index fdc5539..3db30a8 100644 --- a/docs/libraries.md +++ b/docs/libraries.md @@ -367,6 +367,17 @@ Of course missing from this from Jim's long list of plans are DDoS protection, a The net is vast and deep. Maybe we need to start cobbling these pieces together. The era of centralized censorship needs to end. Musk will likely lose either way, and he's only one man against the might of so many paper tigers that happen to be winning the information war. +## Lightning node + +[`rust-lightning`]:https://github.com/lightningdevkit/rust-lightning +{target="_blank"} + + [`rust-lightning`] is a general purpose library for writing lightning nodes, running under Tokio, that is used in one actual lightning node implementation. + + It is intended to be integrated into on-chain wallets. + + It provides the channel state as "a binary blob that you can store any way you want" -- which is to say, ready to be backed up onto the social net. + # Consensus diff --git a/docs/manifesto/sox_accounting.md b/docs/manifesto/sox_accounting.md index 96ad369..6f4d7e0 100644 --- a/docs/manifesto/sox_accounting.md +++ b/docs/manifesto/sox_accounting.md @@ -53,7 +53,7 @@ And suddenly people stopped being willing to pay Enron cash on the barrelhead for goods, suddenly stopped being willing to sell Enron goods on credit. Suddenly Enron could no longer pay its employees, nor its landlord. Its employees stopped turning up, its landlord chucked their -furniture out into the street. +stuff out into the street. Problem solved. @@ -118,14 +118,34 @@ was an earthly reflection of the divine scales of justice and the symmetry of Go When the dust settled over the Great Minority Mortgage Meltdown it became apparent that the books of the financial entities involved had little connection to God's creation. +The trouble with postmodern accounting is that what goes into the asset column, +what goes into the liability column, and what goes into the equity column +bears little relationship to what is actually an asset, a liability, or equity, +little relationship to God Creation. + +(Modernity begins in the seventeenth century, with joint stock +publicly traded limited liability corporation, the industrial revolution, +and the scientific revolution. Postmodernity is practices radically different from, +and fundamentally opposed to, the principles of the that era. Such as detaching +the columns of the books from the real things that correspond to those names. If +science is done by consensus, rather than the scientific method described in "the +skeptical chymist", it is postmodern science, and if the entries in the books do not +actually correspond to real liability, real assets, and real equity, +it is postmodern bookkeeping. Postmodern science is failing to produce the results +that modern science produced, and postmodern bookkeeping is failing +to produce the results that modern bookkeeping produced.) + The state has been attacking the cohesion of the corporation just as it has been attacking the cohesion of the family. Modern corporate capitalism is incompatible with SoX, -because if your books are detached from reality, +because if your books are detached from reality. lies that hostile outsiders demand that you believe, the corporation has lost that which makes it one person. -When the books are lie imposed on you by hostile outsiders you lose cohesion around profit, +When the books are a lie imposed on you by hostile outsiders you lose cohesion around profit, making things, buying, selling, and satisfying the customer, and instead substitute cohesion around gay sex, minority representation, and abortion rights. +If the names of the columns do not mean what they say, people do not care about the effects +of their actions on those columns. + Notice Musk's tactic of making each of his enterprises a moral crusade, and also of giving them a legal form that evades SoX accounting. Which legal form does not permit their shares to be publicly traded. @@ -192,7 +212,7 @@ that when it blesses the books it has prepared as Sox compliant, the regulators will pretend to believe. Which is great for the very respectable accountants, who get paid a great deal of money, and great for the regulators, who get paid off, but is terrible for businesses who pay a great -deal of money and do not in fact get books that accurately tell +deal of money and do not in fact get books that accurately tell management how the business is doing, and considerably worse for startups trying to go public, since the potential investors know that the books do not accurately tell the investors how the business is doing. diff --git a/docs/names/zookos_triangle.svg b/docs/names/zookos_triangle.svg index 0d46c0b..dc9941f 100644 --- a/docs/names/zookos_triangle.svg +++ b/docs/names/zookos_triangle.svg @@ -3,7 +3,7 @@ width="width: 100%" height="100%" viewBox="-2500 -2400 4870 4300" style="background-color:#ddd"> - - +