Coder Social home page Coder Social logo

btcchain's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

btcchain's Issues

Optimize Duplicate Transaction Input Check

Profiling has shown that the duplicate input transaction check is taking around 6% of the total CheckTransactionSanity processing time. This is much higher than it should be.

Save index to a file

Rather than having to recreate the node index on every load, which is a bit time consuming and makes startup take longer, it would be nice to save the index to disk.

A few key points:

  • Chain should accept the location to write the index to so the caller can specify it
  • The index updating code would also need to update the file and handle data consistency issues
  • It might make sense to write the node index for the entire chain and only load the necessary pieces as this could open opportunities to better optimize reverify chain operations

Broken tests with forked repo

The test suite is broken for any fork of this repository due to some weird directory structure assumption.

$ mkdir -p GOPATH/src/github.com/conformal
$ cd $GOPATH/src/github.com/conformal
$ git clone [email protected]/btcchain.git
$ cd btcchain
$ go test
PASS
ok      github.com/conformal/btcchain   0.045s

After this, if you clone your repo within a different parent directory...

$ mkdir -p GOPATH/src/github.com/foobar
$ cd $GOPATH/src/github.com/foobar
$ git clone [email protected]/btcchain.git
$ cd btcchain
$ go test
# github.com/foobar/btcchain_test
./chain_test.go:48: undefined: btcchain.TstSetCoinbaseMaturity
./reorganization_test.go:58: undefined: btcchain.TstSetCoinbaseMaturity
./timesorter_test.go:44: undefined: btcchain.TstTimeSorter
./validate_test.go:108: undefined: btcchain.TstCheckSerializedHeight
FAIL      github.com/foobar/btcchain [build failed]

Add a new behavior flag for a "dry run".

In order to support getblocktemplate block proposals, the chain code needs to be able to handle running the exact same checks on a proposed block as a normal block submission, but without actually accepting it or modifying the state in any way.

There is already an internal branch which implements this. I'm only creating this ticket for tracking purposes.

Error in removeBlockNode when adding new block causes extension of main chain to fail

I received the following error in btcd:

06:07:08 2014-01-28 [INF] BMGR: Processed 1 block in the last 4m23.26s (213 transactions, height 282872, 2014-01-28 06:09:02 -0500 EST)
06:16:47 2014-01-28 [INF] BMGR: Processed 1 block in the last 9m39.17s (472 transactions, height 282873, 2014-01-28 06:16:34 -0500 EST)
06:20:15 2014-01-28 [ERR] BMGR: Failed to process block 00000000000000015151fe4c165e0cb0aa40f6afeda65653cdd35972eb90de8b: removeBlockNode must be called with a  node at the front of the chain - node 0000000000000000f828169b0b1416d4c568b6204ddf8aaffca90fdb1a57fad0
06:25:56 2014-01-28 [INF] CHAN: Adding orphan block 00000000000000017b916aaf3430e5b9678e53bd5f3d4bbcaf63d2c023a58bc4 with parent 00000000000000015151fe4c165e0cb0aa40f6afeda65653cdd35972eb90de8b
06:25:56 2014-01-28 [INF] BMGR: Processed 1 block in the last 9m9.02s (241 transactions, height 282873, 2014-01-28 06:16:34 -0500 EST)
06:30:53 2014-01-28 [INF] CHAN: Adding orphan block 00000000000000016e30a8993bdb6c8f1da2e2003ffdced97baec98b4dc372f1 with parent 00000000000000017b916aaf3430e5b9678e53bd5f3d4bbcaf63d2c023a58bc4
06:30:53 2014-01-28 [INF] BMGR: Processed 1 block in the last 4m56.63s (225 transactions, height 282873, 2014-01-28 06:16:34 -0500 EST)
06:32:54 2014-01-28 [INF] CHAN: Adding orphan block 0000000000000000bec1ee6417bea3819a0c22c679ff8a86a0b2c1e6af94a5d5 with parent 00000000000000016e30a8993bdb6c8f1da2e2003ffdced97baec98b4dc372f1

Looks like the pruneBlockNodes() calls removeBlockNode() as it tries to prune old blocks. I believe there is a subtle bug the chain reorg that causes the parent/child links to not be as expected. The referenced block that can't be cleaned is #280857 / 0000000000000000f828169b0b1416d4c568b6204ddf8aaffca90fdb1a57fad0, and it looks like I had a chain reorg that happened there earlier:

12:53:02 2014-01-16 [INF] BMGR: Processed 1 block in the last 11m56.2s (600 transactions, height 280855, 2014-01-16 12:52:30 -0500 EST)
12:57:12 2014-01-16 [INF] BMGR: Processed 1 block in the last 4m10.14s (180 transactions, height 280856, 2014-01-16 12:56:31 -0500 EST)
13:21:27 2014-01-16 [INF] CHAN: Adding orphan block 0000000000000000f828169b0b1416d4c568b6204ddf8aaffca90fdb1a57fad0 with parent 00000000000000022523d34eb24d113483380e22d190c2fb3da6764b6a623cbd
13:21:27 2014-01-16 [INF] BMGR: Processed 1 block in the last 24m14.78s (20 transactions, height 280856, 2014-01-16 12:56:31 -0500 EST)
13:21:27 2014-01-16 [INF] CHAN: FORK: Block 00000000000000022523d34eb24d113483380e22d190c2fb3da6764b6a623cbd forks the chain at height 280855/block 00000000000000013262988187eb10d1ce3d5fdf65add44037e4329d705f6fb3, but does not cause a reorganize
13:21:27 2014-01-16 [INF] CHAN: REORGANIZE: Block 0000000000000000f828169b0b1416d4c568b6204ddf8aaffca90fdb1a57fad0 is causing a reorganize.
13:21:28 2014-01-16 [INF] CHAN: REORGANIZE: Chain forks at 00000000000000013262988187eb10d1ce3d5fdf65add44037e4329d705f6fb3
13:21:28 2014-01-16 [INF] CHAN: REORGANIZE: Old best chain head was 000000000000000194c8b3b6f9fe2840e5f6f391a3706adf18f97549da866c55
13:21:28 2014-01-16 [INF] CHAN: REORGANIZE: New best chain head is 0000000000000000f828169b0b1416d4c568b6204ddf8aaffca90fdb1a57fad0
13:40:39 2014-01-16 [INF] BMGR: Processed 2 blocks in the last 19m12.31s (1572 transactions, height 280858, 2014-01-16 13:39:53 -0500 EST)
13:41:59 2014-01-16 [INF] BMGR: Processed 1 block in the last 1m19.15s (205 transactions, height 280859, 2014-01-16 13:41:47 -0500 EST)

testnet3 block validation error on block 21066

When running btcd on testnet block chain download gets stuck on block 21066 with the following error message:

[16:51:24 2013-10-06] [INF] [BTCD] [BMGR] Rejected block 0000000004053156021d8e42459d284220a7f6e087bf78f30179c3703ca4eefa: the coinbase signature script serialized block height is 152138 when 21066 was expected

Interesting to note 152138 = 0x02524a and 21066 = 0x524a. It seems that some kind of length byte gets taken into the value.
I have not looked in detail into block coinbase structure and don't know if it is the appropriate way to fix this, but following change to btcchain/validate.go allows btcd to get past this block:

diff --git a/validate.go b/validate.go
index b1e9a35..c39606e 100644
--- a/validate.go
+++ b/validate.go
@@ -507,7 +507,7 @@ func checkSerializedHeight(coinbaseTx *btcwire.MsgTx, wantHeight int64) error {
        }

        serializedHeightBytes := make([]byte, 4, 4)
-       copy(serializedHeightBytes, sigScript[1:4])
+       copy(serializedHeightBytes, sigScript[1:sigScript[0] + 1])
        serializedHeight := binary.LittleEndian.Uint32(serializedHeightBytes)
        if int64(serializedHeight) != wantHeight {
                str := fmt.Sprintf("the coinbase signature script serialized "+

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.