20 votes
Accepted

How can a DApp detect a fork or chain reorganization using web3.js or additional libraries?

Here's code that waits specified number of blocks and verifies the transaction receipt is still valid. If a fork occurs and the replay fails, the receipt check should fail and the callback will call ...
user avatar
  • 4,161
19 votes
Accepted

How should I handle blockchain forks in my DApp?

There are a few modules around that let you keep track of the "state" of a transaction (unconfirmed, X confirmations, conflicting transaction exists and is being confirmed, fully confirmed, definitely ...
user avatar
16 votes
Accepted

parity Ropsten testnet forked at block 296151?

So, the geth monitoring-node first seems to have imported the same one as reported above: Jan 06 23:29:21 geth-testnet: I0106 22:29:21.064938 core/blockchain.go:1073] imported 1 blocks, 14 txs ( ...
user avatar
7 votes
Accepted

What prevents miners from cooperating and causing intentional chain reorgs?

Nothing prevents collusion From former Bitcoin Core developer Greg Maxwell https://old.reddit.com/r/Bitcoin/comments/ddddfl/question_on_the_vulnerability_of_bitcoin/f2g9e7b The attack would work just ...
user avatar
  • 77.8k
6 votes

Distribution of chain-reorganization events?

From looking at the block stats on etherscan over the last 20 days, it looks like there are approximately: 475-525 single depth reorgs per day (uncle blocks) 1-2 reorgs with depth of two per day I ...
user avatar
6 votes
Accepted

Can a transaction get lost?

Blockchains based on Proof of Work are probabilistic, and as more blocks are built upon the block containing a transaction, the probability of a chain reorganization removing that block and ...
user avatar
  • 77.8k
5 votes

How can a DApp detect a fork or chain reorganization using web3.js or additional libraries?

I can't comment whether there is or is not a function for this in web3. What I do know is that Geth and Mist have transaction replay. This means that in case of a reorganisation it will process ...
user avatar
  • 1,765
3 votes

What prevents miners from cooperating and causing intentional chain reorgs?

As Mikko mentioned, it would be super difficult for them to start cooperating in such a way. If their miners find out, they can just easily switch to an "honest" pool. But assuming that ...
user avatar
3 votes

What happens to transactions in orphaned/forked blocks?

According to Ethereum White Paper transactions of orphan (uncle) will be added to the chain anyways. As described by Sompolinsky and Zohar, GHOST solves the first issue of network security loss ...
user avatar
  • 209
3 votes

How can a DApp detect a fork or chain reorganization using web3.js or additional libraries?

Currently I don't think there is a way to do that. Currently the docs say to just wait 12 blocks to make sure that a hard fork didn't happen and use getCode(). https://github.com/ethereum/wiki/wiki/...
user avatar
  • 1,628
2 votes

How can a DApp detect a fork or chain reorganization using web3.js or additional libraries?

On web3 API, section contract events, it is said that the object given to the callback has a removed field. If you listen for your event and a reorganization occurs, you should be notified by an event ...
user avatar
2 votes
Accepted

What happens to transactions in orphaned/forked blocks?

The behavior in Ethereum is the same as in Bitcoin. At first the transactions seem to have gone through, but after a better chain is found it is as if the txs never happened.
user avatar
  • 33.8k
2 votes
Accepted

Chain Reorganization (TX HASH Change)

If the chain is reorganised then any transactions contained within blocks in the 'old' chain will not exist. This blog post outlines reorganisations in more detail. "Roughly speaking, the chances of ...
user avatar
2 votes
Accepted

What is the accepted methodology for verifying the integrity of pulled chain data?

You simply need to pick a confirmation limit that you are happy with. A common one in the ETH ecosystem is 12, so you would only consider data 'safe' if it was mined at least 12 blocks ago. You can ...
user avatar
  • 33.8k
2 votes

In what cases if any, does a transaction get lost from the network forever?

Yes. But the exact circumstances are hard to pin down as it varies between nodes. Each node on the Ethereum network will maintain it's own finite list of pending transactions. This is configurable on ...
user avatar
  • 645
2 votes

Log index change during chain reorganization

In a chain reorganization the order of the transaction can change, some transactions can be removed, and new ones added replacing others. Since the log order follows the order of the transactions a ...
user avatar
  • 29.2k
2 votes

Distribution of chain-reorganization events?

Just to follow on from Daniel's answer, here's a crappy Python scraper to scrape Etherscan and count the number of ephemeral forks of different lengths. Results: Forks of length 1: 6526 Forks of ...
user avatar
2 votes
Accepted

Etherscan Forked Blocks' Reorg-Depth is Incorrect?

Let's suppose a node has this state A -> B -> C -> D New blocks arrive and the situation becomes: A -> B' -> C' -> D' -> E -> F | B (Where B is ...
user avatar
  • 29.2k
2 votes

How to test chain reorganization with testrpc?

I don't know of a way to accomplish that with TestRPC. There might be a better way than described below. I think I would make a private chain with Geth and low-difficulty/fast blocks in the genesis ...
user avatar
  • 50.5k
1 vote
Accepted

How does oraclize deal with chain reorg?

As the application developer, you need to handle this yourself. There's a little documentation here. You send (and get returned) a queryId. You should check that this is valid inside your ...
user avatar
  • 399
1 vote

Transactions and smart contracts during reorganization

Partial answer... When it comes to smart contracts, how smart contracts deal with this kind of revert/rollback problems due to chain reorganization? The smart contract itself doesn't need to deal ...
user avatar
1 vote

What does MetaMask mean by stop injecting web3.js?

If MetaMask will stop injecting web3 this means web3.currentProvider is not gonna work anymore properly. My advice is to handle the change and not getting your app crashed by downloading your own web3 ...
user avatar
1 vote

How to test chain reorganization with testrpc?

It wouldnt be possible to do it with test rpc as it only mints blocks when transactions arrives, and isnt connected to other remote nodes, so there would never be discrepancies between nodes. We have ...
user avatar
  • 1,168
1 vote

Distribution of chain-reorganization events?

Just to add to @Daniel's great answer: the amount of necessary confirmations depends on the needed amount of surety. How sure does the party need to be that the block won't get reverted? As noted, ...
user avatar
1 vote
Accepted

Syncing events on Database - Dealing with blockchain reorganization

If you want a reorganization free testnet, try Kovan. Ropsten is proof of work, and anyone who can point enough hashpower to it can rewrite the chain for a considerable number of blocks. Kovan is ...
user avatar
  • 3,790
1 vote

Persistent "deep transaction reorg" whilst syncing full geth node

A reorg is done only if a block being imported on a side fork leads to a higher total difficulty on that particular fork than the canonical fork. The blocks nonetheless still need to be valid. As ...
user avatar
1 vote

Persistent "deep transaction reorg" whilst syncing full geth node

Manually add some well-reputed peers/bootnodes. The following guide runs through how to do this using geth, either via IPC or a config file: https://github.com/ethereum/go-ethereum/wiki/Connecting-to-...
user avatar
  • 1,021
1 vote

Geth Websocket Behavior during reorganization

If reorgs happen are you are subscribed with the PUB/SUB feature {"id": 1, "method": "eth_subscribe", "params": ["newHeads", {}]} You will start to get new blocks. 1, 2, 3, 4, ... And on reorgs ...
user avatar
1 vote

Geth Websocket Behavior during reorganization

For the first question, according the docs, what you get should be as follows. Say the last 3 blocks you mentioned are called a, b, and c, and the 4 new blocks are A, B, C, D. It should be that a, b,...
user avatar
1 vote

How can a DApp detect a fork or chain reorganization using web3.js or additional libraries?

Yes , there is a way to do it: When a fork occurs, the hash of the Block (or State) will change, so all you have to do is to get the hash of the last Block (or State) before you submit a transaction. ...
user avatar
  • 3,356

Only top scored, non community-wiki answers of a minimum length are eligible