Page MenuHomePhabricator

Discourage selfish mining by favoring blocks with more accurate timestamps
AbandonedPublic

Authored by jasonbcox on Mar 14 2018, 03:27.

Details

Reviewers
deadalnix
schancel
Group Reviewers
Restricted Project
Summary

Implements changes for T207, T208, T209

Selfish mining paper, for reference: https://arxiv.org/pdf/1311.0243v1.pdf

Some stats from my experiment with selfish mining over a period 753 blocks:

  • min time received compared to header timestamp: -26 sec (so the header timestamp was 26 seconds in the future. lol)
  • max time received compared to header timestamp: 166 sec
  • median: 0
  • mean: 3.34661
  • stddev: 11.896

No apparently selfish blocks were captured during this time period.

The selfish mining threshold is slightly under one standard deviation. Let me know if you think this value should be larger, just keep in mind that it's only used for breaking ties.

Test Plan

make check && test_runner.py sendheaders-selfish-mining.py

Diff Detail

Repository
rABC Bitcoin ABC
Branch
ts
Lint
Lint Passed
SeverityLocationCodeMessage
Auto-Fixsrc/net_processing.cpp:1CFMTCode style violation
Auto-Fixsrc/validation.cpp:1CFMTCode style violation
Unit
No Test Coverage
Build Status
Buildable 2067
Build 2281: Bitcoin ABC Buildbot (legacy)
Build 2280: arc lint + arc unit

Event Timeline

There are some linting errors, but I'll wait until the first round of feedback before I fix them.

deadalnix requested changes to this revision.Mar 14 2018, 09:26

Can you please split up the way you record the time stamp from the way you use it ? It'll make the scope of the discussion more focused and will allow to make progress faster.

src/chain.h
246

This should be in the CBlockIndex.

src/primitives/block.h
32

This is supposed to contains the block data themselves. The CBlockIndex or whatever its name is is the right thing for these kind of infos.

src/util.h
98

I think it's a good idea to log always this. A block arrive every 10 mins, so it's not like it is going to be a flood.

This revision now requires changes to proceed.Mar 14 2018, 09:26
jasonbcox marked an inline comment as done.
jasonbcox added inline comments.
src/chain.h
246

;)

Untitled.png (450×761 px, 78 KB)

src/primitives/block.h
32

Conceptually, this makes sense. I'll keep digging to see if I can remove this without clobbering the implementation more so than this line already does.

src/util.h
98

I guess that makes sense. It allows people to debug their relationship with the network in terms of lag time from block creation to arriving at their machine (assuming honest blocks).

src/chain.h
246

alright, I'm crazy XD

Working to split this diff into chunks... I'll leave this diff open for a top-level view of the change, but will not be landing it.

src/primitives/block.h
32

Did some digging and confirmed it's possible to remove this from block.h. My initial impression is to add nTimeReceived as a param to ProcessNewBlock(). This way, once the index pointer is acquired, nTimeReceived can be set. And this operation should be done for all new blocks received.