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 OK
SeverityLocationCodeMessage
Auto-Fixsrc/net_processing.cpp:1CFMTCode style violation
Auto-Fixsrc/validation.cpp:1CFMTCode style violation
Unit
No Unit Test Coverage
Build Status
Buildable 2067
Build 2281: Bitcoin ABC Buildbot (legacy)
Build 2280: arc lint + arc unit

Event Timeline

jasonbcox created this revision.Mar 14 2018, 03:27
Herald added a reviewer: Restricted Project. · View Herald TranscriptMar 14 2018, 03:27
jasonbcox edited the summary of this revision. (Show Details)Mar 14 2018, 03:32

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 planned changes to this revision.Mar 14 2018, 16:13
jasonbcox marked an inline comment as done.
jasonbcox added inline comments.
src/chain.h
246

;)

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).

deadalnix added inline comments.Apr 10 2018, 23:07
src/chain.h
246

alright, I'm crazy XD

jasonbcox marked 3 inline comments as done.Apr 14 2018, 16:27

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.

jasonbcox marked 3 inline comments as done.Apr 14 2018, 16:28
jasonbcox abandoned this revision.May 23 2018, 06:03