Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: stdo on August 26, 2017, 02:15:08 PM



Title: How to judge illegal transactions?
Post by: stdo on August 26, 2017, 02:15:08 PM
I wonder how the bitcoin protocol judge illegal transactions. As they say, the miner will look throughout the public ledger to make sure the transaction is alright. There are thousands of transactions in each block, if the miner has to check throughout the public ledger for each transaction, this would be very inefficient.


Title: Re: How to judge illegal transactions?
Post by: aleksej996 on August 26, 2017, 04:29:06 PM
You really just need to look for transactions that you would include in blocks, the highest fee ones. Miners already look through all the transactions, that is how they know which are the highest fee onces. They even check if their parent transaction is not confirmed and if they both average out at a high enough fee and so on for their parent's parent transaction, hence the Child-pay-for-parent method of getting your transactions confirmed.

There would also be no real way of forcing miners to check for legality of transactions, since miners can be anonymous, just like other Bitcoin users.


Title: Re: How to judge illegal transactions?
Post by: achow101 on August 26, 2017, 04:32:24 PM
Every single full node (not just miners) fully verifies every single transaction it receives. It does the same for every block. Since blocks and transactions can be mostly validated in parallel, it really isn't all that slow. Furthermore, the entire blockchain is not rechecked for every block, nor does it need to be rescanned for every block. Node software has more efficient ways of checking up transaction by storing various data separately, e.g. maintaining a separate database for the UTXO set which is used for checking transaction validity. Furthermore transactions in new blocks don't need to be revalidated if you have already seen them in your mempool. So that saves validation time as well.


Title: Re: How to judge illegal transactions?
Post by: zertsekel on August 26, 2017, 04:40:05 PM
I wonder if Bitcoin Core, when first installed, rechecks **all** the transactions from the genesis block...
Does anyone know?


Title: Re: How to judge illegal transactions?
Post by: aleksej996 on August 26, 2017, 04:46:54 PM
I wonder if Bitcoin Core, when first installed, rechecks **all** the transactions from the genesis block...
Does anyone know?

Yes. It does it while it is downloading them.


Title: Re: How to judge illegal transactions?
Post by: zertsekel on August 26, 2017, 04:55:53 PM
I wonder if Bitcoin Core, when first installed, rechecks **all** the transactions from the genesis block...
Does anyone know?

Yes. It does it while it is downloading them.

What if I download the Bitcoin Blockchain via torrent?
Do all the pre-existing transactions get checked as well?


Title: Re: How to judge illegal transactions?
Post by: aleksej996 on August 26, 2017, 05:04:12 PM
I think only the last couple of them. Maybe if you don't download the chainstate files then it will have to in order to generate them. otherwise with downloading a whole data directory, I think only a couple of last ones.

There isn't really a benefit of downloading from a torrent, just a risk. Bitcoin is already peer to peer so downloading a blockchain is already like a torrent, it is just slower because it checks them. Maybe there is even an option for Bitcoin Core not to check them while downloading so you get the same effect, but maybe still safer, since you get it from the network and not just some guy.


Title: Re: How to judge illegal transactions?
Post by: zertsekel on August 26, 2017, 05:16:25 PM
I think there is a bitcoin daemon configuration flag that enables to "trust" pre-existing blocks... Not sure though...


Title: Re: How to judge illegal transactions?
Post by: achow101 on August 26, 2017, 05:24:14 PM
What if I download the Bitcoin Blockchain via torrent?
Do all the pre-existing transactions get checked as well?
Yes. It will check all transactions and blocks it knows of. If a transaction is in a block that has a specific descendant block (the assumevalid block), then signatures are not checked. Everything else is still checked. Note that using the bootstrap.dat torrent will be slower than syncing from p2p.


Title: Re: How to judge illegal transactions?
Post by: HeroC on August 26, 2017, 05:26:50 PM
I think there is a bitcoin daemon configuration flag that enables to "trust" pre-existing blocks... Not sure though...

Not sure why you'd need to use it, syncing is much faster now and verifying transactions doesn't take that much CPU power.


Title: Re: How to judge illegal transactions?
Post by: luv2drnkbr on August 28, 2017, 11:04:46 PM
I wonder how the bitcoin protocol judge illegal transactions. As they say, the miner will look throughout the public ledger to make sure the transaction is alright. There are thousands of transactions in each block, if the miner has to check throughout the public ledger for each transaction, this would be very inefficient.

Every full node does this.  That's why syncing takes forever.  Yes, it's inefficient.  But it's also the only way we know how to have such a system operate.


Title: Re: How to judge illegal transactions?
Post by: AGD on September 08, 2017, 11:13:21 AM
I wonder how the bitcoin protocol judge illegal transactions. As they say, the miner will look throughout the public ledger to make sure the transaction is alright. There are thousands of transactions in each block, if the miner has to check throughout the public ledger for each transaction, this would be very inefficient.

There are valid inputs and valid (because authorized by a signature of a private key) outputs. There is no need to check the whole public ledger (blockchain). If an address had no valid (like illegal) input, there will be a balance of 0. If the address had a valid input, which already was confirmed by the network, it can be spent by signing with the private key.


Title: Re: How to judge illegal transactions?
Post by: jal007 on September 08, 2017, 04:29:28 PM
you should learn about blockchain and how transactions are saved there


Title: Re: How to judge illegal transactions?
Post by: Syke on September 08, 2017, 07:40:15 PM
I wonder how the bitcoin protocol judge illegal transactions. As they say, the miner will look throughout the public ledger to make sure the transaction is alright. There are thousands of transactions in each block, if the miner has to check throughout the public ledger for each transaction, this would be very inefficient.

What would you rather have, inefficiency or inaccuracy for a monetary system?