block: remove Verify()

It's used in two places now:
 * Blockchain.AddBlock()
   This one does transaction duplication check of its own, doing it in
   Verify() is just a waste of time. Merkle tree root hash value check is
   still relevant though
 * Block.DecodeBinary()
   We're decoding blocks for the following purposes:
     - on restore from dump
       The block will be added to the chain via AddBlock() and that will do a
       full check of it (if configured to do so)
     - on retrieving the block from the DB (DAO)
       We trust the DB, if it's gone wild, this check won't really help
     - on receiving the block via P2P
       It's gonna be put into block queue and then end up in AddBlock() which
       will check it
     - on receiving the block via RPC (submitblock)
       It is to be passed into AddBlock()
     - on receiving the block via RPC in a client
       That's the only problematic case probably, but RPC client has to trust
       the server and it can check for the signature if it really
       cares. Or a separate in-client check might be added.

As we can see nothing really requires this verification to be done the way it
is now, AddBlock can just have a Merkle check and DecodeBinary can do fine
without it at all.
This commit is contained in:
Roman Khimov 2020-09-16 12:33:39 +03:00
parent 2e876b5593
commit ce09c82b25
4 changed files with 17 additions and 40 deletions

View file

@ -161,7 +161,10 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
},
serverResponse: b1Verbose,
result: func(c *Client) interface{} {
return getResultBlock1()
res := getResultBlock1()
// update hidden hash value.
_ = res.Block.ConsensusData.Hash()
return res
},
},
{
@ -190,7 +193,10 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
},
serverResponse: b1Verbose,
result: func(c *Client) interface{} {
return getResultBlock1()
res := getResultBlock1()
// update hidden hash value.
_ = res.Block.ConsensusData.Hash()
return res
},
},
},