Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Rebroadcast transactions from minority forks #1155

Open
crazybits opened this issue Dec 17, 2014 · 6 comments
Open

Rebroadcast transactions from minority forks #1155

crazybits opened this issue Dec 17, 2014 · 6 comments

Comments

@crazybits
Copy link

will the transactions of blocks in shorter fork chain re-broadcast to network again after network switch from the shorter fork chain to the longer chain,if yes, please guide me to the handling code, thanks.

@dnotestein
Copy link
Contributor

no, it doesn't do this currently. I plan to make this change soon (been on my list after my rewrite of forking code, but various problems keep interrupting me). Anyways, this will only help for short forks, as expiration time for transactions is fairly quick (IIRC, around 2 1/2 hours).

@crazybits
Copy link
Author

thanks for clarification,if this feature implemented,we needn't to notify exchange to suspend the withdraw/deposit when fork chain is produced. i think this feature deserves a higher priority

@dnotestein
Copy link
Contributor

it's got a pretty high priority, believe me. Just the problems of late have been higher yet. Fortunately I hope they're resolved after tonight.

@crazybits crazybits changed the title [question] fork chain switch logic clarification [question] regarding fork chain switch logic Dec 18, 2014
@crazybits
Copy link
Author

Regarding the fork switching, i am not understand why need to have the following loop, appreciate if could help to clarify. thanks in advance.

https://github.com/BitShares/bitshares/blob/develop/libraries/blockchain/chain_database.cpp#L1609-L1641

do
{
.......
--highest_unchecked_block_number
}
while(highest_unchecked_block_number > 0)

@emfrias
Copy link
Contributor

emfrias commented Dec 23, 2014

This code is relevant when we get a block that links a chain of currently-unlinked blocks to our blockchain. Say we have the following blockchain except we've never seen block 'd'. Our head block will be block 'c', and blocks 'e' through 'i' are just sitting in the fork database marked as 'unlinked' because we don't have the block 'd' which completes the link to the genesis state. 'e' through 'i' also could be invalid (we don't know until we try to push them onto the blockchain, and we can't do that until we get the missing block)

         h-i
        /
a-b-c-[d]-e-f-g

When 'd' comes in, all of the blocks are now 'linked' and we can try to switch to the new longest fork (in this case, 'g'). We call switch_to_fork(g) to push blocks 'd', 'e', 'f', and 'g'. If these all succeed, the new head block will be 'g' and we'll return out of the loop. But say pushing block 'e' fails for some reason, maybe it has a duplicate transaction. When this happens, our head block will be 'd', the last block we successfully pushed. the e-f-g chain is now invalid, but the h-i is still longer than the chain we started with. That's the purpose of this loop -- if pushing e-f-g fails, it will try h-i next. It will keep trying the next longest chain that might be valid until it runs out of chains to try. If none of the new blocks are valid (including 'd'), the last call should be a switch_to_fork(c) which will return us to our original head block.

@crazybits
Copy link
Author

it is quite clear, thank you very much.

@vikramrajkumar vikramrajkumar modified the milestone: 0.9.0 Jan 7, 2015
@vikramrajkumar vikramrajkumar changed the title [question] regarding fork chain switch logic Rebroadcast transactions from minority forks Feb 26, 2015
@vikramrajkumar vikramrajkumar removed this from the dvs/0.10.0 milestone Jun 9, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants