Hic inserere motto

ben_vulpes base58 encoding in Common Lisp

January 24, 2021 — shinohai

As the anniversary of the fall of TMSR approaches the decay of the once-proud institution is evident in the rapidly decreasing number of websites of former Lords., formerly operated by ben_vulpes (WoT:ben_vulpes) is sadly one of these castles specifically because the guy wrote the defacto introduction to vtronics (archived) and some interesting posts on common lisp.

One forgotten item I found particularly useful was an implementation of base58 encoding in common lisp. Sadly I could find no archive of the original article but after a bit of digging I found a copy of the code contained within saved on an old hard drive. I'm quoting it below so I have a handy reference for future projects.

(defparameter +b58-alphabet+ "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")

(defun b58-encode (bytes)
  (let ((string (make-string-output-stream))
        (bignum (loop for i to (- (length bytes) 1) summing
               (* (elt bytes i)
                  (expt 256 i)))))

   (loop while (> bignum 0) do
        (multiple-value-bind (x r) (floor bignum (length +b58-alphabet+))
          (write-char (elt +b58-alphabet+ r) string)
          (setf bignum x)))

   (loop for b across (reverse bytes) do
        (if (= 0 b)
            (write-char (elt +b58-alphabet+ 0) string)

   (reverse (get-output-stream-string string))))

Tags: Bitcoin, Lisp, News

Botworks - ircbot and logbot genesis

June 21, 2020 — shinohai

Alf has reminded me several times that it might be helpful to publish the sauce for my ircbot setup so this post is an attempt to do just that, and generally make it easier to install the bot components using V. My botworks tree uses trinque's lisp ircbot and logbot combo as the starting point.

A lot of good patches are scattered about on former republican blogs, though it seems I could get none of them to play nice with esthlos-v so a regrind was in order. For ircbot these are:

trinque's ircbot-genesis-kv.vpatch.

ben_vulpes' ircbot-multiple-channels-kv.vpatch.

whaack's ircbot-no-suicide-on-reconnect-kv.vpatch.

Assuming you already have SBCL and quicklisp, you can then use `V` to press ircbot and move the output to your local-projects directory:

v press ircbot-no-suicide-on-reconnect-kv out

mv out/ircbot ~/quicklisp/local-projects

The process is repeated to add the logbot system. While testing the regrinds I came upon a curious problem where adding ben_vulpes "logbot-multiple-channels" patch caused an error when trying to start logbot. Simply pressing the logbot genesis and running the bot is working, so I will continue to debug the issue and post results in a future botworks piece. The logbot requires that postgres be installed on your system, whaack has a good piece on how to do this on his blog, if you aren't familiar with setting that part up.

v press logbot-genesis-kv.vpatch

mv out/logbot ~/quicklisp/local-projects

With both of these components installed where ASDF can find them running the bot is as simple as firing up a REPL, adding your parameters and connecting to it according to the instructions in the "logbot/USAGE" file.


Put together a better prefixed command system, the system I am currently using works but needs quite a bit of polish before being worthy of turning into a vpatch.

Cobble together a www log reader for use with the logbot system.

Links to useful lisp botworks resources:

trinque's sources:

ben_vulpes' post on multiple channels:

spyked's botworks vpatches:

whaack's post on setting up trinque's logbot:

Tags: News, Lisp, UNIX

Notes on esthlos-v and some restructuring thereof

January 30, 2020 — shinohai

This particular post will serve as a place to put my notes on esthlos-v, which I have been reading over in an attempt to polish it up for personal use. Now there are many fine implementations of "V" out there already, and I admit mod6's "" has served me well over time, but this particular "V" is delightfully readable and the code is well commented.

Way back in ancient Greece, the word "esthlos" meant that "something exists" or at least is true. Even though the author of esthlos-v vanished into internet space some time ago, and apparently abandoned work on the project, we'll retain the original name since it seems rather fitting for a tool used to magic software into existence.

I will expound upon the contents of esthlos-v in a later piece, though for now I am adding a single new vpatch: "esthlos-v_makefile-and-vdiff.vpatch" - this patch contains simple modifications to the original Makefile so it will build both "v.lisp" and "cl-keccak" as standalone binaries at the same time, and install them if the operator so desires. A modified version of phf's original that uses cl-keccak instead of sha512sum is included. This vpatch and it's corresponding seal can be found in the esthlos-v mirror here.

Tags: News, Lisp, UNIX

Essential kit items: Building SBCL on Gentoo with musl

November 08, 2019 — shinohai

Steel Bank Common Lisp is another must-have tool in my kit, since I use it to run my hybrid irc/Telegram bot and many other daily use items. In my previous post I documented how I managed to get gcc-4.9.4 massaged into shape, so this post will serve as a reference on how to do the same for SBCL so in the future I don't have to spend the day researching fixes and locating obscure patchsets.

When building many things using musl, one will often run into "undefined reference to `memcpy@GLIBC_*'" type errors, since glibc uses versioned symbols and musl does not. SBCL is no different, but fortunately a little digging turned up a working patchset on the SBCL mailing list which works beautifully, so I didn't have to spend the better part of a day cobbling one together as I did for gcc. I have preserved a copy of the patchset here and will definitely do my best to maintain these into the future should any major changes occur.

Much like Ada, SBCL requires itself or another ANSI common lisp to build. I decided to use CLISP (version 2.49.92) to perform this task, as it can be quickly built from sources using gcc only (and I didn't want to use a pre-built sbcl binary of unknown provenance). After getting clisp in place, building SBCL is mostly painless using the following steps:

I downloaded the 1.5.7 sources from my site and verified the checksums:

curl -O
curl -O

Unpack the sources and enter the directory:

tar xjf sbcl-1.5.7-source.tar.bz2 && cd sbcl-1.5.7

Get the musl patchset and apply them:

wget -q -r -nd -N --no-parent -R "index.html*"
for i in *.patch; do patch -p1 < $i; done

Build using CLISP and install:

./ "clisp" --fancy

The above recipe has so far worked quite nicely, having been tested by running the above mentioned irc bot and a few other essential lisp programs. I will update this post if/when any bugs are found or if any changes are made.

Tags: News, Linux, Lisp