Commit graph

2074 commits

Author SHA1 Message Date
Gavin Andresen c4d884e20e No need for test fixture now that multisig is enabled on main network. 2012-10-29 13:34:35 -04:00
Pieter Wuille 28982cc9dc Remove P2SH transition code: P2SH violations may cause DoS trigger 2012-10-29 00:41:39 +01:00
Pieter Wuille 0b297a614f Bugfix: don't crash by trying to write unchanged best block 2012-10-28 19:14:51 +01:00
Philip Kaufmann 6b3783a9c9 fix some double-spaces in strings
- remove some unneeded stuff in sendcoinsentry.ui
- harmonize some "Error:"-messages
2012-10-25 22:25:50 +02:00
Pieter Wuille bb790aa24d First flush block tree, then coin set
As the coinset data refers to the best block, stored in the block
tree. Flushing the coin set first can cause inconsistencies if
the process gets killed in between.
2012-10-25 20:47:17 +02:00
tucenaber 3026baaa7c Added checks for null pointers in Shutdown
Estetics
2012-10-25 20:45:38 +02:00
Pieter Wuille 344620e953 Merge pull request #1904 from laanwj/2012_10_remove_getorder
remove "checkorder" P2P command
2012-10-25 11:41:22 -07:00
Pieter Wuille e74d0ab675 Merge pull request #1899 from Diapolo/proxy_optionsmodel
make optionsmodel query real proxy state for ::data()
2012-10-25 11:33:59 -07:00
Pieter Wuille 66444558a5 Merge pull request #1953 from gmaxwell/createnewblock-race
Fixes a race condition in CreateNewBlock and a future null deref on testnet.
2012-10-25 11:30:51 -07:00
Philip Kaufmann 847593228d fix some thread related log messages
- "ThreadIRCSeed started" was not displayed, even if the thread ran
  (although only for a short time as the "do we want this thread?"-checks
  happen IN ThreadIRCSeed2())
- the patch ensures we always get that message
- add a "ThreadIRCSeed trying to connect..." message
- add missing "ThreadDumpAddress started" message
2012-10-25 16:12:40 +02:00
Wladimir J. van der Laan 1f7c5c5a3e Merge pull request #1926 from laanwj/2012_10_maindummybounds
Fix out-of-bounds read in main (issue #1924)
2012-10-25 06:12:10 -07:00
Wladimir J. van der Laan 7a1786084d Merge pull request #1956 from laanwj/2012_10_prerelease_warning
Show warning when using prerelease version
2012-10-25 05:52:55 -07:00
Pieter Wuille 2e9e6641e1 Merge pull request #1955 from gmaxwell/gbt_paramfix
Don't force getblocktemplate to have a parameter.
2012-10-25 05:37:51 -07:00
Philip Kaufmann 83a3fb81f3 ensure AskPassphraseDialog::eventFilter forwards events
- instead of "return false;" use "return QDialog::eventFilter(object,
  event);" to harmonize this event filter with our default behaviour
- remove orphan spaces found while editting the files
2012-10-25 11:52:34 +02:00
Wladimir J. van der Laan 62e21fb5d0 Show warning when using prerelease version
Implements #1948

- Add macro `CLIENT_VERSION_IS_RELEASE` to clientversion.h
- When running a prerelease (the above macro is `false`):
  - In UI, show an orange warning bar at the top. This will be used for other
    warnings (and alerts) as well, instead of the status bar.
  - For `bitcoind`, show the warning in the "errors" field in `getinfo`
    response.
2012-10-25 07:33:45 +02:00
Gregory Maxwell 3beac9837f Don't force getblocktemplate to have a parameter.
This looks like it was just a munged merge when ultraprune
was committed.
2012-10-24 12:39:46 -04:00
Pieter Wuille 55913c9971 Merge pull request #1947 from centromere/freebsd_cpu_fix
Fixed 100% CPU utilization problem on FreeBSD 9
2012-10-24 02:15:54 -07:00
Wladimir J. van der Laan 4fbad9124e Fix out-of-bounds read noticed by Ricardo Correia
Sizeof() returned the size of a pointer instead of the size of the buffer.
Fixes issue #1924.
2012-10-24 08:26:50 +02:00
Gregory Maxwell faff50d129 Fixes a race condition in CreateNewBlock and a future null deref on testnet.
CreateNewBlock was reading pindexBest at the start before taking the lock
so it was possible to have the the block content not match the prevheader
and this can also trigger a newly added assert in ConnectBlock.

I noticed this during a code review after twobitcoins reported that ab91bf39
(BIP30 for all blocks) could cause a null dereference on a modified node
that mined during the IBD, or on testnet when it reached heights 91842 and
91880 due to CreateNewBlock calling ConnectBlock with pindex->phashBlock NULL.
2012-10-24 02:13:03 -04:00
Pieter Wuille 4afc0b5411 Bugfix: actually use CCoinsViewMemPool 2012-10-23 01:43:33 +02:00
Pieter Wuille c2ed184f98 Added some comments
Some clarifications after a code review by Mike Hearn.
2012-10-23 00:27:17 +02:00
Pieter Wuille 1e64c2d585 Bugfix: off-by-one in priority calculation 2012-10-23 00:23:39 +02:00
Pieter Wuille 9e957fb3b1 Bugfix: add missing fee check 2012-10-23 00:23:39 +02:00
Pieter Wuille 56424040a4 Bugfix: off-by-one error in coinbase maturity check 2012-10-23 00:23:39 +02:00
Alex 39ad0aa692 Fixed 100% CPU utilization problem on FreeBSD 9 2012-10-22 08:37:17 -04:00
Gregory Maxwell 2ef15697f8 Merge pull request #1939 from sipa/bugfix_zerobalance
Bugfix: do not mark all future coins spent
2012-10-21 16:20:04 -07:00
Philip Kaufmann 729b180686 change blockchain -> block chain (spelling)
- Wiki says "block chain" is correct ;)
- remove some unneeded spaces I found in the source, while fixing the spelling
2012-10-21 21:32:25 +02:00
Philip Kaufmann 039bcbf12d remove init messages from ThreadImport()
- remove uiInterface.InitMessage() calls from ThreadImport(), as Qt
  doesn't like them getting called out of it's main thread and because the
  thread will continue to run after the GUI was loaded
2012-10-21 21:16:52 +02:00
Pieter Wuille 80fe60959d Tab instead of 4 spaces in makefile.mingw 2012-10-21 16:10:01 +02:00
Pieter Wuille ddba582377 Bugfix: do not mark all future coins spent 2012-10-21 15:19:19 +02:00
Gregory Maxwell d12b694106 Merge pull request #1938 from sipa/v0799
Update version numbers to 0.7.99
2012-10-21 03:12:25 -07:00
Pieter Wuille fcfa7a588e Update version numbers to 0.7.99 2012-10-21 12:10:08 +02:00
Gregory Maxwell 67e2c8a40a Merge pull request #1916 from jgarzik/caddrdb-bug
Fix: CAddrMan: verify pchMessageStart file marker, before reading address data
2012-10-20 15:06:25 -07:00
Pieter Wuille f50fb5470b Merge pull request #1936 from sipa/morehashwriter
Use CHashWriter also in SignatureHash(), and for message signing
2012-10-20 14:53:43 -07:00
Pieter Wuille 4ca60bba5c Remove BDB block database support 2012-10-20 23:08:57 +02:00
Pieter Wuille beeb57610c Add gettxout and gettxoutsetinfo RPCs 2012-10-20 23:08:57 +02:00
Pieter Wuille e1bfbab802 Add LevelDB MemEnv support
Support LevelDB memory-backed environments, and use them in unit tests.
2012-10-20 23:08:57 +02:00
Pieter Wuille 2d8a48292b LevelDB block and coin databases
Split off CBlockTreeDB and CCoinsViewDB into txdb-*.{cpp,h} files,
implemented by either LevelDB or BDB.

Based on code from earlier commits by Mike Hearn in his leveldb
branch.
2012-10-20 23:08:57 +02:00
Pieter Wuille 44d40f26dc Flush and sync block data 2012-10-20 23:08:57 +02:00
Pieter Wuille d979e6e36a Use singleton block tree database instance 2012-10-20 23:08:57 +02:00
Pieter Wuille 857c61df0b Prepare database format for multi-stage block processing
This commit adds a status field and a transaction counter to the block
indexes.
2012-10-20 23:08:57 +02:00
Pieter Wuille 4fea06db25 Automatically reorganize at startup to best known block
Given that the block tree database (chain.dat) and the active chain
database (coins.dat) are entirely separate now, it becomes legal to
swap one with another instance without affecting the other.

This commit introduces a check in the startup code that detects the
presence of a better chain in chain.dat that has not been activated
yet, and does so efficiently (in batch, while reusing the blk???.dat
files).
2012-10-20 23:08:57 +02:00
Pieter Wuille 13c51f20f6 Direct CCoins references
To prevent excessive copying of CCoins in and out of the CCoinsView
implementations, introduce a GetCoins() function in CCoinsViewCache
with returns a direct reference. The block validation and connection
logic is updated to require caching CCoinsViews, and exploits the
GetCoins() function heavily.
2012-10-20 23:08:57 +02:00
Pieter Wuille 64dd46fd05 Transaction hash caching
Use CBlock's vMerkleTree to cache transaction hashes, and pass them
along as argument in more function calls. During initial block download,
this results in every transaction's hash to be only computed once.
2012-10-20 23:08:57 +02:00
Pieter Wuille ae8bfd12da Batch block connection during IBD
During the initial block download (or -loadblock), delay connection
of new blocks a bit, and perform them in a single action. This reduces
the load on the database engine, as subsequent blocks often update an
earlier block's transaction already.
2012-10-20 23:08:57 +02:00
Pieter Wuille 450cbb0944 Ultraprune
This switches bitcoin's transaction/block verification logic to use a
"coin database", which contains all unredeemed transaction output scripts,
amounts and heights.

The name ultraprune comes from the fact that instead of a full transaction
index, we only (need to) keep an index with unspent outputs. For now, the
blocks themselves are kept as usual, although they are only necessary for
serving, rescanning and reorganizing.

The basic datastructures are CCoins (representing the coins of a single
transaction), and CCoinsView (representing a state of the coins database).
There are several implementations for CCoinsView. A dummy, one backed by
the coins database (coins.dat), one backed by the memory pool, and one
that adds a cache on top of it. FetchInputs, ConnectInputs, ConnectBlock,
DisconnectBlock, ... now operate on a generic CCoinsView.

The block switching logic now builds a single cached CCoinsView with
changes to be committed to the database before any changes are made.
This means no uncommitted changes are ever read from the database, and
should ease the transition to another database layer which does not
support transactions (but does support atomic writes), like LevelDB.

For the getrawtransaction() RPC call, access to a txid-to-disk index
would be preferable. As this index is not necessary or even useful
for any other part of the implementation, it is not provided. Instead,
getrawtransaction() uses the coin database to find the block height,
and then scans that block to find the requested transaction. This is
slow, but should suffice for debug purposes.
2012-10-20 23:08:57 +02:00
Pieter Wuille bba89aa82a Pre-allocate block and undo files in chunks
Introduce a AllocateFileRange() function in util, which wipes or
at least allocates a given range of a file. It can be overriden
by more efficient OS-dependent versions if necessary.

Block and undo files are now allocated in chunks of 16 and 1 MiB,
respectively.
2012-10-20 23:08:57 +02:00
Pieter Wuille 5382bcf8cd Multiple blocks per file
Change the block storage layer again, this time with multiple files
per block, but tracked by txindex.dat database entries. The file
format is exactly the same as the earlier blk00001.dat, but with
smaller files (128 MiB for now).

The database entries track how many bytes each block file already
uses, how many blocks are in it, which range of heights is present
and which range of dates.
2012-10-20 23:08:57 +02:00
Pieter Wuille 8adf48dc9b Preliminary undo file creation
Create files (one per block) with undo information for the transactions
in it.
2012-10-20 23:08:57 +02:00
Pieter Wuille 630fd8dcb6 One file per block
Refactor of the block storage code, which now stores one file per block.
This will allow easier pruning, as blocks can be removed individually.
2012-10-20 23:08:57 +02:00
Pieter Wuille 44ac1c0fe3 Add CTxUndo: transaction undo information
The CTxUndo class encapsulates data necessary to undo the effects of
a transaction on the txout set, namely the previous outputs consumed
by it (script + amount), and potentially transaction meta-data when
it is spent entirely.
2012-10-20 23:08:56 +02:00
Pieter Wuille 10fd8604d7 Add CCoins: pruned list of transaction outputs
The CCoins class represents a pruned set of transaction outputs from
a given transaction. It only retains information about its height in
the block chain, whether it was a coinbase transaction, and its
unspent outputs (script + amount).

It has a custom serializer that has very low redundancy.
2012-10-20 23:08:56 +02:00
Pieter Wuille 0fa593d0fb Compact serialization for amounts
Special serializer/deserializer for amount values. It is optimized for
values which have few non-zero digits in decimal representation. Most
amounts currently in the txout set take only 1 or 2 bytes to
represent.
2012-10-20 23:08:56 +02:00
Pieter Wuille 69fc8047a9 Compact serialization for scripts
Special serializers for script which detect common cases and encode
them much more efficiently. 3 special cases are defined:
* Pay to pubkey hash (encoded as 21 bytes)
* Pay to script hash (encoded as 21 bytes)
* Pay to pubkey starting with 0x02, 0x03 or 0x04 (encoded as 33 bytes)

Other scripts up to 121 bytes require 1 byte + script length. Above
that, scripts up to 16505 bytes require 2 bytes + script length.
2012-10-20 23:08:56 +02:00
Pieter Wuille 4d6144f97f Compact serialization for variable-length integers
Variable-length integers: bytes are a MSB base-128 encoding of the number.
The high bit in each byte signifies whether another digit follows. To make
the encoding is one-to-one, one is subtracted from all but the last digit.
Thus, the byte sequence a[] with length len, where all but the last byte
has bit 128 set, encodes the number:

  (a[len-1] & 0x7F) + sum(i=1..len-1, 128^i*((a[len-i-1] & 0x7F)+1))

Properties:
* Very small (0-127: 1 byte, 128-16511: 2 bytes, 16512-2113663: 3 bytes)
* Every integer has exactly one encoding
* Encoding does not depend on size of original integer type
2012-10-20 23:08:56 +02:00
Pieter Wuille 43b7905e98 LevelDB glue
Database-independent glue for supporting LevelDB databases.

Based on code from earlier commits by Mike Hearn in his leveldb
branch.
2012-10-20 23:08:56 +02:00
Pieter Wuille 3ff3a2bd60 Makefile integration of LevelDB 2012-10-20 23:08:56 +02:00
Pieter Wuille 9f56678fce Backport Win32 LevelDB env from C++0x to C++
Since the gitian mingw compiler doesn't support C++0x yet.
2012-10-20 23:08:56 +02:00
Pieter Wuille 9d503a7285 Disable libsnappy detection in LevelDB 2012-10-20 23:08:56 +02:00
justmoon 94a50fb339 Leveldb Windows port by Edouard Alligand, adapted for MingW by me. 2012-10-20 23:08:56 +02:00
Mike Hearn 5e650d6d2d Import LevelDB 1.5, it will be used for the transaction database. 2012-10-20 23:08:56 +02:00
Jeff Garzik 38ac953b9d Merge pull request #1880 from sipa/threadimport
Move external block import to separate thread
2012-10-20 13:36:36 -07:00
Jeff Garzik dee0ee2ac9 Merge pull request #1742 from sipa/canonical
Check for canonical public keys and signatures
2012-10-20 10:56:04 -07:00
Pieter Wuille 66b02c93e6 Move external block import to separate thread 2012-10-20 01:54:10 +02:00
Pieter Wuille 8980a50924 Use CHashWriter also in SignatureHash(), and for message signing 2012-10-19 23:18:07 +02:00
Wladimir J. van der Laan 485d667748 Revert "Merge pull request #1931 from laanwj/2012_10_newicons"
This reverts commit 199d88cf90, reversing
changes made to 65bc1573e7.

License is worse instead of better. Will only accept public domain and
MIT-licensed icons from now on.
2012-10-14 20:49:06 +02:00
xanatos cddda5d9f0 Changed connect?_16.png to non-GPL one and changed the assets attribution. 2012-10-14 13:01:38 +02:00
xanatos b96238a9c9 Changed the spinner to a non-GPL one, added instructions on how to regenerate it, changed the assets attribution, removed old spinner + old spinner's sources. 2012-10-14 12:34:07 +02:00
Philip Kaufmann 34710818a7 Bitcoin-Qt: intregrate current translations from Transifex 2012-10-12 15:51:49 +02:00
Philip Kaufmann 0e005c3ddc Bitcoin-Qt: update english translation master file 2012-10-12 15:45:27 +02:00
Wladimir J. van der Laan 22bb049011 Fix a use-after-free problem in initialization (#1920)
Don't store the result of c_str().

Luckily, this only affects logging, though it could crash or leak
sensitive data to the log in rare cases.
2012-10-12 03:09:05 +02:00
Wladimir J. van der Laan 16f3618c13 Merge pull request #1879 from sipa/fdatasync
Use fdatasync instead of fsync on supported platforms
2012-10-11 00:42:47 -07:00
Wladimir J. van der Laan 24694e24ed Merge pull request #1913 from sipa/noi2p
Remove I2P support from netbase
2012-10-11 00:41:33 -07:00
Wladimir J. van der Laan fae3989ffc Merge pull request #1900 from Diapolo/optionsmodel_getters
move most explicit getters in optionsmodel to header
2012-10-11 00:40:20 -07:00
Wladimir J. van der Laan 089b10a28a Merge pull request #1911 from Diapolo/fix_signed_unsigned
fix wrong (signed/unsigned) printf format specifier in bitcoinrpc.cpp
2012-10-11 00:40:08 -07:00
Wladimir J. van der Laan ac0ad5dc63 Merge pull request #1901 from laanwj/2012_10_remove_strlcpy
get rid of strlcpy.h
2012-10-11 00:39:51 -07:00
Gavin Andresen 1d1f32d16d Bump versions for 0.7.1 release 2012-10-09 12:37:35 -04:00
Gavin Andresen de038acd96 Fix bad merge, pszDataDir duplication 2012-10-09 12:28:00 -04:00
Gavin Andresen 673021410f Merge branch 'wallet_exceptions' of github.com:gavinandresen/bitcoin-git 2012-10-09 12:14:26 -04:00
Gavin Andresen cf64347d70 Merge branch 'crash_at_exit' of github.com:gavinandresen/bitcoin-git 2012-10-09 12:10:18 -04:00
Wladimir J. van der Laan 0a5ce30bc1 Merge pull request #1915 from Diapolo/Qt5_compat_leftover
change Q_WS_MAC -> Q_OS_MAC (Qt5 compatibility)
2012-10-08 22:28:24 -07:00
Jeff Garzik de2b9459bd Merge pull request #1834 from jgarzik/kickblocks
P2P: Do not request blocks from peers with fewer blocks than us
2012-10-08 15:15:58 -07:00
Jeff Garzik b855abb8db Revert "Send 'mempool' P2P command at the start of each P2P session"
Fat-fingered on github, and merged this too early.

This reverts commit 22f9b06903.
2012-10-08 18:14:15 -04:00
Jeff Garzik 56caa38a67 Merge pull request #1833 from jgarzik/mempool-query
Send 'mempool' P2P command at the start of each P2P session
2012-10-08 15:12:25 -07:00
Gavin Andresen d0b3e77a08 Don't try to verify a non-existent wallet.dat 2012-10-08 17:46:46 -04:00
Gavin Andresen eed1785f70 Handle corrupt wallets gracefully.
Corrupt wallets used to cause a DB_RUNRECOVERY uncaught exception and a
crash. This commit does three things:

1) Runs a BDB verify early in the startup process, and if there is a
low-level problem with the database:
  + Moves the bad wallet.dat to wallet.timestamp.bak
  + Runs a 'salvage' operation to get key/value pairs, and
    writes them to a new wallet.dat
  + Continues with startup.

2) Much more tolerant of serialization errors. All errors in deserialization
are reported by tolerated EXCEPT for errors related to reading keypairs
or master key records-- those are reported and then shut down, so the user
can get help (or recover from a backup).

3) Adds a new -salvagewallet option, which:
 + Moves the wallet.dat to wallet.timestamp.bak
 + extracts ONLY keypairs and master keys into a new wallet.dat
 + soft-sets -rescan, to recreate transaction history

This was tested by randomly corrupting testnet wallets using a little
python script I wrote (https://gist.github.com/3812689)
2012-10-08 17:46:45 -04:00
Gavin Andresen 8d5f461cb6 Handle incompatible BDB environments
Before, opening a -datadir that was created with a new
version of Berkeley DB would result in an un-caught DB_RUNRECOVERY
exception.

After these changes, the error is caught and the user is told
that there is a problem and is told how to try to recover from
it.
2012-10-08 17:25:17 -04:00
Gavin Andresen c2bb42168b Merge branch 'BDB_DOWNGRADE' 2012-10-08 17:18:17 -04:00
Gavin Andresen e4954b1297 Handle incompatible BDB environments
Before, opening a -datadir that was created with a new
version of Berkeley DB would result in an un-caught DB_RUNRECOVERY
exception.

After these changes, the error is caught and the user is told
that there is a problem and is told how to try to recover from
it.
2012-10-08 15:51:59 -04:00
Jeff Garzik bd2e140571 CAddrMan: verify pchMessageStart file marker, before reading address data
This avoids the case where you read the address data, before noticing it is
the wrong network.
2012-10-08 13:41:57 -04:00
Philip Kaufmann ada2a39691 change Q_WS_MAC -> Q_OS_MAC (Qt5 compatibility)
- I missed that one in my former pull
2012-10-07 18:50:03 +02:00
Philip Kaufmann 5e5c102f2f make optionsmodel query real proxy state for ::data()
- don't rely on the QSettings for cases ProxyUse and ProxySocksVersion and
  query the real values via the GetProxy() call
- add a missing "succesful =" for case ProxyUse in ::setData()
2012-10-07 17:59:41 +02:00
Pieter Wuille 43de64949c Merge pull request #1859 from Diapolo/proxy_locks
add LOCK() for proxy related data-structures
2012-10-07 07:03:06 -07:00
Pieter Wuille e996521390 Use fdatasync instead of fsync on supported platforms 2012-10-07 15:51:40 +02:00
Pieter Wuille 4e882b7960 Remove I2P support from netbase
I2P apparently needs 256 bits to store a fully routable address. Garlicat
requires a centralized lookup service to map the 80-bit addresses to fully
routable ones (as far as I understood), so that's not really usable in our
situation.

To support I2P routing and peer exchange for it, another solution is needed.
This will most likely imply a network protocol change, and extension of the
'addr' message.
2012-10-07 15:10:14 +02:00
Wladimir J. van der Laan 6032e4f4e7 get rid of strlcpy.h
Don't use hand-rolled string manipulation routine with a fixed
buffer in the bitcoin core, instead make use of c++ strings and boost.
2012-10-07 14:38:37 +02:00
Philip Kaufmann 95e625d235 fix wrong (signed/unsigned) printf format specifier in bitcoinrpc.cpp
- also includes the required bitcoinstrings.cpp update
2012-10-05 23:31:58 +02:00
Wladimir J. van der Laan ee0b648536 Merge pull request #1906 from laanwj/2012_10_help_stdout
Send --help message to stdout i.s.o stderr
2012-10-05 11:24:09 -07:00
Wladimir J. van der Laan a6be58d536 Merge pull request #1905 from laanwj/2012_10_startup_gui_error
When datadir missing, show messagebox instead of printing error to stderr
2012-10-04 22:28:44 -07:00
Pieter Wuille 39930ca6ae Merge pull request #1908 from laanwj/2012_10_rpcerrors
Document RPC error codes
2012-10-04 17:17:53 -07:00