public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
From: Mike Hearn <mike@plan99•net>
To: Jonas Schnelli <jonas.schnelli@include7•ch>,
	 Bitcoin Dev <bitcoin-development@lists•sourceforge.net>
Subject: Re: [Bitcoin-development] Introducing BitcoinKit.framework
Date: Tue, 16 Jul 2013 11:51:57 +0200	[thread overview]
Message-ID: <CANEZrP2yQvmvwP_ZULdS2i+X6L9MeZ+DfidiuZPD2EHwLsN2MA@mail.gmail.com> (raw)
In-Reply-To: <2F20A509-13A9-4C84-86D7-A15C21BACD53@include7.ch>

[-- Attachment #1: Type: text/plain, Size: 3181 bytes --]

Let's re-add the list as this is a topic of general interest.

On Tue, Jul 16, 2013 at 11:36 AM, Jonas Schnelli <jonas.schnelli@include7•ch
> wrote:

> What do you think about extending the BitcoinKit.framework (based on
> bitcoind) so that the kit could handle the very basic SPV concept
> (getHeaders aka fast catchup, wallet-birthday, bloom filters)?
> Maybe it would be possible to only port some of the bitcoinj work to c++
> (and use it for extending BitcoinKit or bitcoind)?
> Maybe then it could also be a starting point for someone who likes to
> create a SPV mode for bitcoind?
>

Making bitcoind/Bitcoin-Qt support SPV mode was the original plan some
years ago, Satoshi even sent me some code he wrote that did the first
parts, but it was incomplete.

At the time, I decided to do a separate implementation for a few different
reasons. One is that my understanding of his code wasn't so good back then
and I lacked confidence to change it. Especially as there were no unit
tests back then (and still aren't any for most of it), making invasive
changes to the core validation code was and is highly risky. A separate
code base seemed to reduce the risk a lot.

Another reason is that Satoshi encouraged me to write a simple
re-implementation that people could learn from. And I wanted a documented,
object oriented API that people could use to build a variety of apps.

Yet another reason was bitcoind is security critical code that scrapes
complex data structures from untrusted sources on the internet, and it's
written in an unmanaged language. Ordinarily this would be a recipe for
disaster as a single overflow or memory management error could lead to
hacking and theft on a massive scale. It's like taking a chainsaw and using
it to carve an ice sculpture. Satoshi, incredibly, pulled it off, mostly by
using advanced C++ features that made his code hard to read for many people
and by being very, very careful. I was not convinced I could do such a good
job and was worried about accidentally introducing vulnerabilities.

A final reason is that it was clear that the bitcoind codebase would need
serious changes for mobiles, beyond that required for ordinary SPV support.
For example, Satoshi's code assumes it has access to block headers via a
std::map and that assumption is made in a lot of places. On Android phones,
you can't fit all the block headers in RAM. bitcoinj uses a circular ring
buffer of the last N thousand headers for this reason. It's quite different
to how bitcoind works.

All that said, it was a ton of work and it's still unclear that it was the
right call.

Anyway, your situation is a little different. Firstly you don't care about
mobiles, your app is intended for desktops. So the changes required are
less invasive. Also, there are more unit tests and more people with a good
understanding of the code these days, so perhaps the risk of introducing
bugs is lower. And these days we have some nice APIs for building apps so
that need is already met.

If you wanted to implement SPV mode in bitcoind, Gavin or I could send you
Satoshi's old patch although of course it is no longer usable. It would
indicate the basic cut lines though.

[-- Attachment #2: Type: text/html, Size: 3826 bytes --]

  parent reply	other threads:[~2013-07-16  9:52 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-15 10:07 Wendell
2013-07-15 13:19 ` Mike Hearn
2013-07-15 14:39   ` Wendell
2013-07-15 15:48     ` Mike Hearn
     [not found]       ` <3E7894A0-06F3-453D-87F8-975A244EBACF@include7.ch>
2013-07-15 20:08         ` Mike Hearn
     [not found]           ` <2BDA0943-22BB-4405-9AF0-86FB41FD04A6@include7.ch>
2013-07-16  9:21             ` Mike Hearn
     [not found]               ` <2F20A509-13A9-4C84-86D7-A15C21BACD53@include7.ch>
2013-07-16  9:51                 ` Mike Hearn [this message]
2013-07-16 10:17                   ` Wendell
2013-07-16 10:59                     ` Mike Hearn
2013-07-16 14:16                       ` [Bitcoin-development] SPV bitcoind? (was: Introducing BitcoinKit.framework) Wendell
2013-07-16 15:09                         ` Mike Hearn
2013-07-17 10:58                         ` Peter Todd
2013-07-17 12:29                           ` Mike Hearn
2013-07-17 14:32                             ` [Bitcoin-development] SPV bitcoind? Andreas Schildbach
2013-07-17 19:32                               ` Mike Hearn
2013-07-18 12:13                             ` [Bitcoin-development] SPV bitcoind? (was: Introducing BitcoinKit.framework) Peter Todd
2013-07-18 13:18                               ` Peter Todd
2013-07-18 13:38                               ` Mike Hearn
2013-07-17 13:37                           ` Wendell
2013-07-17 14:31                             ` Michael Gronager
2013-07-17 14:58                               ` Wendell
2013-07-17 19:33                                 ` Mike Hearn
2013-07-17 22:26                                   ` Michael Gronager
2013-07-17 23:04                                     ` Gregory Maxwell
2013-07-18  8:19                                     ` Mike Hearn
2013-07-18 11:40                                       ` Bazyli Zygan
2013-07-18 13:03                                         ` Michael Gronager
2013-07-18 13:16                                           ` Michael Gronager
2013-07-18 16:22                             ` Peter Todd
2013-07-18 16:46                               ` Wendell
2013-07-18 23:03                                 ` Peter Todd
2013-07-21 15:55                       ` [Bitcoin-development] Introducing BitcoinKit.framework Pieter Wuille
2013-07-21 17:20                         ` Mike Hearn
2013-07-22 13:08               ` Mike Hearn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANEZrP2yQvmvwP_ZULdS2i+X6L9MeZ+DfidiuZPD2EHwLsN2MA@mail.gmail.com \
    --to=mike@plan99$(echo .)net \
    --cc=bitcoin-development@lists$(echo .)sourceforge.net \
    --cc=jonas.schnelli@include7$(echo .)ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox