Author

Topic: miner attack (Read 620 times)

member
Activity: 148
Merit: 45
https://bitaps.com/
October 24, 2015, 02:15:10 PM
#2
found  Smiley

When a block comes in:

    main.cpp:ProcessMessage deals with processing messages, and dispatches to:
    main.cpp:ProcessNewBlock deals with specifically processing block messages, which stores it on disk using AcceptBlock and then calls:
    main.cpp:ActivateBestChain tries to verify the potentially new best chain and switch to it. For every atomic "reorganization" step, it calls:
    main.cpp:ActivatebestChainStep which will try to verify new blocks to be added to the tip of the chain using:
    main.cpp:ConnectTip which does the actual processing using:
    main.cpp:ConnectBlock, which will iterate through the block's transactions and verify their inputs using:
    main.cpp:CheckInputs which builds up a list of CScriptCheck objects for each script execution to be performed, which are verified from another thread. ConnectBlock waits for these threads to finish and deal with the result. In those threads, we call:
    main.cpp:CScriptCheck::operator() which performs a single encapsulated script execution, using:
    script/interpreter.cpp:VerifyScript to do a verification of script, which consists of executing a scriptPubKey + its spending scriptSig using:
    script/interpreter.cpp:EvalScript.

member
Activity: 148
Merit: 45
https://bitaps.com/
October 24, 2015, 01:49:08 PM
#1


Today I reading bitcoind src, and try to find out where is pubkey script executed when node received new block with transaction, at example transaction from new block may not be exist in mempool

    Find function that execute script:

    https://github.com/bitcoin/bitcoin/search?utf8=%E2%9C%93&q=EvalScript

        src/script/interpreter.cpp in this file source code of EvalScript function

    Used only in this 2 files:

        src/policy/policy.cpp

        src/script/sign.cpp

    Review sign.cpp

Evalscript -> CombineSignatures -> /src/bitcoin-tx.cpp: MutateTxSign -> MutateTx -> CommandLineRawTx -> main

This functions used when we create ne transactions

    Review policy.cpp

Evalscript -> AreInputsStandard -> /src/main.cpp: AcceptToMemoryPool

AcceptToMemoryPool

    src/main.cpp later

    src/wallet/wallet.cpp -> CommitTransaction - this is create own transaction functional

    src/rpcrawtransaction.cpp -> sendrawtrnsaction - rpc function send rawtx

    src/txmempool.cpp -> no calls only comments

Last one is src/main.cpp

AcceptToMemoryPool -> ProcessMessage on message "tx" , new single tx to pool received AcceptToMemoryPool -> DisconnectTip

DisconnectTip -> InvalidateBlock invaludate block and send all transaction back to pool with all verifications and script eval

DisconnectTip -> ActivateBestChainStep :

  // Disconnect active blocks which are no longer in the best chain.
bool fBlocksDisconnected = false;
while (chainActive.Tip() && chainActive.Tip() != pindexFork) {
    if (!DisconnectTip(state))
        return false;
    fBlocksDisconnected = true;
}

If we have orphan tak out transactions from orphan to pool with all verifications

NO more other links found

From this I can conclude that in case node with bitcoind received new block with transactions that not in mempool we add this tx to blockchain without pubkeyscript execute.


Consequently if same "honest" miner include tx with invalid script, at example incorrect signature that spent same one coins, all bitcoind nodes add it to blockchain without eval script and not detect this

It is not posible to be true! Where is my error?
Jump to: