Kicking the Hornet's Nest - part 7

Kicking the Hornet's Nest - part 7

# Kicking the Hornet's Nest - third edition - part 7

All links, digital (pdf, txt, docx, md) and book in print, can be found at https://hive.blog/@crrdlx/satoshi

Edited by [crrdlx](@crrdlx), npub:

```

npub1qpdufhjpel94srm3ett2azgf49m9dp3n5nm2j0rt0l2mlmc3ux3qza082j

```


### Kicking the Hornet's Nest pages 125 - 150

Getting antsy to port to Linux? It's not a decision to be taken lightly

because once it's done, it doubles my testing and building workload.

Although I am worried about Liberty's Wine crashes.

I've tried to be as portable as possible and use standard C stuff

instead of Windows calls. The threading is _beginthread which is part

of the standard C library. wxWidgets has wxCriticalSection stuff we can

use. The sockets code is send/recv stuff which I think is the same as

unix because Microsoft ported sockets from BSD. We need direct control

over sockets, it wouldn't be a good idea to get behind an abstraction

layer. wxWidgets is a good place to look for cross-platform support

functions. I want to avoid #ifdefing up the code if we can. Anything

that's used more than once probably becomes a function in util.cpp that

has the #ifdef in it.

BTW, I have a lot of uncommitted changes right now because it includes

some crucial protocol transitions that can't be unleashed on the network

until I've tested the heck out of it. It shouldn't be too much longer.

Can you make the setup uninstall the Startup folder icon? I figure it

should install and uninstall an icon in a regular program group, and

just uninstall the Startup folder one. I guess it doesn't matter that

much whether it installs and uninstalls the Startup folder icon or just

uninstalls it.

Martii Malmi (AKA Sirius) “COPA trial” email #46

Date: Thu, 29 Oct 2009 02:05:30 +0000

From: Satoshi Nakamoto <satoshin@gmx.com>

Subject: Re: Fw: bitcoin.sourceforge.net

To: mmalmi@cc.hut.fi

I'll convert the CriticalSection code to wxCriticalSection and upload it

to SVN (it's a little tricky). I don't know what to do for

TryEnterCriticalSection though. I think I'm almost ready to check

everything in.

You're probably right, it's about time to do a linux build. I've been

working on getting my linux machine set up and building the dependencies.

> Ok. I replaced the Windows thread and socket library includes with their

> POSIX equivalents, and now it only gives a few errors, mostly from the

> CriticalSections. If I make it work, I'll put it into svn/branches, it

> doesn't need to be an official release yet.

Martii Malmi (AKA Sirius) “COPA trial” email #48

Date: Thu, 29 Oct 2009 06:38:30 +0000

From: Satoshi Nakamoto <satoshin@gmx.com>

Subject: Re: Linux build

To: mmalmi@cc.hut.fi

The easy solution I took was to look at the wxWidgets source code and

see how they did it. They just mapped it to wxMutex on non-MSW, which

does have TryEnter, so that mapped in perfectly.

I checked in all my backlog of changes to SVN, including the overhaul of

CCriticalSection in util.h and OpenSSL's mutex callback in util.cpp to

do everything with wxWidgets when not on Windows.

If we get it working on Linux, I'll run my test suite against it here

off-network first, then we can give an unreleased build to

LibertyStandard to test for a while before going public.

Martii Malmi (AKA Sirius) “COPA trial” email #49

Date: Fri, 30 Oct 2009 01:05:45 +0000

From: Satoshi Nakamoto <satoshin@gmx.com>

Subject: Re: Linux build

To: Martti Malmi <mmalmi@cc.hut.fi>

I fixed some non-portable stuff I came across:

QueryPerformanceCounter

%I64d in printf format strings

Sleep

CheckDiskSpace

If there's any other unportable stuff you know of I should fix, let me know.

I think I'll move debug.log and db.log into the same directory as the

data files (%appdata%\Bitcoin), rather than whatever the current

directory happens to be.

Martii Malmi (AKA Sirius) “COPA trial” email #51

Date: Sat, 31 Oct 2009 20:09:58 +0000

From: Satoshi Nakamoto <satoshin@gmx.com>

Subject: Re: Linux build

To: mmalmi@cc.hut.fi

heapchk() is just a MSVCRT debugging thing that's not being used. It

can be a no-op on Linux. OpenSSL automatically uses /dev/urandom to

seed on Linux, so RandAddSeedPerfmon can also be a no-op.

Don't let it connect to the network before we've tested it thoroughly

off-net. If you have two computers, unplug the internet and use

"bitcoin -connect=<ip>" to connect to each other, one windows and one

linux. -connect will allow you to connect to non-routable addresses

like 192.168.x.x. We don't want to reflect badly on the reliability of

the network if it throws off some malformed crud we hadn't thought to

check for yet, or discovers something else anti-social to do on the network.

I have time that I can do some testing when you've got something

buildable to test. I can include it in the stress test I'm currently

running on the changes so far.

mmalmi@cc.hut.fi wrote:

> I made an #ifdef to replace QueryPerformanceCounter with Linux's

> gettimeofday in util.h. Some Unicode/ANSI errors were resolved without

> code changes when I updated to wxWidgets 2.9. The only compile error I'm

> getting in Linux at the moment is from heapchk() in util.h.

>

>> I fixed some non-portable stuff I came across:

>> QueryPerformanceCounter

>> %I64d in printf format strings

>> Sleep

>> CheckDiskSpace

>>

>> If there's any other unportable stuff you know of I should fix, let me

>> know.

>>

>> I think I'll move debug.log and db.log into the same directory as the

>> data files (%appdata%\Bitcoin), rather than whatever the current

>> directory happens to be.

>

Martii Malmi (AKA Sirius) “COPA trial” email #53

Date: Tue, 03 Nov 2009 15:53:25 +0000

From: Satoshi Nakamoto <satoshin@gmx.com>

Subject: Re: Linux build, proxy

To: mmalmi@cc.hut.fi

Great, I've been looking forward to working on the Linux build.

If you connect to Freenode's hidden service, then they tell you they've

also banned TOR from that due to abuse and it kicks you off. There's a

several step procedure you can do to run a password utility on unix and

e-mail request an account that you could login with, but that's getting

pretty complicated. I wonder if we could get away with applying for one

account and then everyone use the same account? I suppose the IRC

server probably limits accounts to one login, or some admin might not

like to see a dozen logins on the same account.

Besides the IRC part, how did your test of proxy go? Since you've been

connected before, your addr.dat contains known node addresses, but

without IRC to know which ones are online, it takes a long time to find

them. There are normally 1 to 3 other nodes besides you that can accept

incoming connections, and existing nodes that already know you would

eventually connect to you. How many connections did you get, and how

long did it take? I guess to know whether it successfully connected

outbound through TOR you'd need to search debug.log for "connected".

To originally connect with TOR without connecting normally once to get

seeded, you'd have to know the address of an existing node that can

accept incoming connections and seed it like this:

bitcoin -proxy=127.0.0.1:9050 -addnode=<ip of a node>

If some nodes that accept incoming connects were willing to have their

IP coded into the program, it could seed automatically. Or some IP seed

addresses posted on a Wiki page with the instructions.

Another option is to search the world again for an IRC server that

doesn't ban TOR nodes. Or if we could get someone to set one up. IRC

servers ban TOR because they have actual text chat on them... if there

was one with just bots and junk then it wouldn't care. Probably should

post a question on the forum or the mailing list and see if anyone knows

one.

Another problem is that TOR users can't accept incoming connections, and

we have so few that can. If everyone goes to TOR, there won't be any

nodes to connect to.

We have a shortage of nodes that can accept incoming connections. It

generally ranges from 2 to 4 lately. We need to emphasize the

importance to people of setting up port forwarding on their router.

Every P2P file sharing program has instructions how to do it. We should

have a paragraph on the bitcoin.sourceforge.net homepage urging people

to set up port forwarding to accept incoming connections, and a link to

a site that describes how to do it for each router.

mmalmi@cc.hut.fi wrote:

> I uploaded what I've ported so far to the svn/branches. Util, script, db

> and the headers compile fully now and net.cpp partially, so there's

> still work to do.

>

_> beginthread doesn't have a direct Linux equivalent, so I used Boost

> threads instead.

>

> I couldn't get connected using the Tor SOCKS proxy. That might be

> because of the Freenode Tor policy which requires connecting to their

> hidden service: http://freenode.net/ircservers.shtml#tor_

>

Martii Malmi (AKA Sirius) “COPA trial” email #54

Date: Wed, 04 Nov 2009 05:38:17 +0000

From: Satoshi Nakamoto <satoshin@gmx.com>

Subject: Re: Linux build

To: mmalmi@cc.hut.fi

It was almost there. I fixed a few things and got it to finish

compiling but I don't know the system libraries to link to so there's

undefined references galore.

I changed the makefile to look for things under /usr/local and in their

default "make install" locations. I wrote what I did and switches I

used in build-unix.txt. I'm currently using wxWidgets 2.8.9 for now

because it's the same version as on Windows and I don't want to wonder

if there's version change issues at the same time as platform change.

2.8.10 or 2.9.0 are probably fine though. I went with the

single-library compile of wxWidgets since we're linking to almost every

library anyway.

I added xpm files, which is what they use everywhere else but Windows

instead of RC files. They're clever C files that define graphics in

static arrays. The bitcoin icon has 5 different versions but I couldn't

figure out how that works in xpm so I only put the biggest one. Maybe

on GTK it scales it for you. I don't know if these are right or what,

but they compile.

mmalmi@cc.hut.fi wrote:

> I uploaded what I've ported so far to the svn/branches. Util, script, db

> and the headers compile fully now and net.cpp partially, so there's

> still work to do.

>

_> beginthread doesn't have a direct Linux equivalent, so I used Boost

> threads instead.

>

Martii Malmi (AKA Sirius) “COPA trial” email #55

Date: Wed, 04 Nov 2009 20:38:03 +0000

From: Satoshi Nakamoto <satoshin@gmx.com>

Subject: Re: Linux build

To: mmalmi@cc.hut.fi

Just letting you know I'm still working on the Linux build so we don't

duplicate work. I got it linked and ran it and working through runtime

issues like getting it switched to load bitmaps from xpm instead of

resources.

There are debian packages available for some of the dependencies instead

of having to compile them ourselves:

apt-get install build-essential

apt-get install libgtk2.0-dev

apt-get install libssl-dev

I need to see if Berkeley DB or Boost have packages.

We'll shared-link OpenSSL, I'm pretty sure it's always preinstalled on

Linux. GTK has to be shared linked. I'm not completely sure if it's

preinstalled by default.


No comments yet.