understanding setlastblock

+1 vote

hello,

i think i do not really understand the setlastblock call;

i have a chain with only one node; i invoked the following calls

  1. issue new assets => the corresponding transaction is mined in block 14; also seen in multichain-explorer
  2. pause mining,incoming
  3. setlastblock to 10 => the transaction gets into mempool again (seen in explorer); getinfo tells me that i'm at block 10
  4. clearmempool => the transaction vanishes from multichain-explorer
  5. resume mining,incoming => the transaction appears again mined in block 14

my target was to revoke the transaction itself;

=> is my understanding wrong, do i something wrong, do i miss something

thanks and regards

Thomas

PS: i tried the same with two node (only one miner)

 

asked Sep 20, 2016 by tkdp

1 Answer

+1 vote

The setlastblock call sets the current "best tip" of the blockchain in this node, but it does not remove blocks from the "tree" which contains all of the forks. So after this node mines block 11 (which will be different from the original block 11), it still finds the longer original branch in the tree, and switches back to that branch. If you consider that a node will usually be only one of many in the network, and one of many miners, removing the branch locally will not be effective anyway, because other nodes will still have a copy of it.

If you really want to revoke a transaction, after each block is mined on the new branch, you will have to recursively pause mining, then setlastblock to that new block, then resume mining. Once the new branch is longer than the previous one, it will represent the new network consensus. But the transaction you wish to revoke will still be in the mempool of other nodes, so it would have to be cleared from those as well.

In summary, I would say that blockchains are not designed to allow transactions to be revoked :)

answered Sep 21, 2016 by MultiChain
yes sure one blockchain target is not to change anything in the past;
is only for my understanding and for arguing;
1.
the next question is: can i see somewhere the forked branches?
2.
for your above given description is my understanding right?
steps needed:
pause ...; setlastblock 10; clearmempool; resume ...; pause ...; setlastblock 11; clearmempool; resume; pause...; .... ; setlastblock 14; clearmempool; resume;

in this way i were until now not able to revoke the transaction

thanks and regards
Thomas
Try calling getchaintips to learn about the forks (you can then pass the block hash to getblock to learn more about each block in each fork).

You need to call setlastblock with the hash of the specific block that was mined, rather than just a block height, because the block height will just send you back on the original chain you were trying to get off.
...