Files
tendermint/spec/light-client/detection/detection_003_reviewed.md
Callum Waters 1f0cf7762b spec: migrate v0.7.1. into v0.34 (#9262)
* Initial commit

* Add three timeouts and align pseudocode better with existing algorithm

* Align protocol with Tendermint code and add find valid value mechanism

* Prepare to Nuke Develop (#47)

* state -> step

* vote -> v

* New version of the algorithm and the proof

* New version of the algorithm and the proofs

* Added algorithm description

* Add algorithm description

* Add introduction

* Add conclusion

* Add conclusion file

* fix warnings (caption was defined twice)

- only the latter is used anyways (centers captions)
- this makes it possible to autom. building the paper

* Update grammar

* s/state_p/step_p

* Address Ismail's comments

* intro: language fixes

* definitions: language fixes

* consensus: various fixes

* proof: some fixes

* try to improve reviewability

* \eq -> =

* textwrap to 79

* various minor fixes

* proof: fix itemization

* proof: more minor fixes

* proof: timeouts are functions

* proof: fixes to lemma6

* Intro changes and improve title page

* Add Marko and Ming to acks

* add readme

* Format algorithm correctly

Clarify condition semantic and timeouts

Improve descriptions

* patform -> platform

* Ensure that rules are mutually exclusive

- various clarifications and small improvements

* Release v0.6

* small nits for smoother readability

* This PR is to create signed commits to be able to merge (#50)

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* Add consesnus and blockchain specs, (#52)

- Open questions
	- Do  we want to split lite client work from consesnsus
	- From the blockchain spec, is encoding nessecary in the spec

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* Add ABCI SPEC (#51)

- move the abci spec from tendermint to spec repo

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* spec/consensus/signing: add more details about nil and amnesia (#54)

- Add more details about nil votes and about amnesia attacks

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* Add Section for P2P (#53)

* Add Section for P2P

- moved over the section on p2p

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* add some more files

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* Fix model section

* Add non-recursive specification of Bisection algorithm

- Fix timing issues by introducing Delta parameter

* spec: update spec with tendermint updates (#62)

* spec: update spec with tendermint updates

- this in preperation of deleting the spec folder in docs in tendermint/tendermint

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* spec: added in reactors & p2p

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* spec: update readme in spec to comply with docs site

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* docs: addded more changes from tednermint/tendermint

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* reflect breaking changes made to Commit (#63)

* reflect breaking changes made to Commit

PR: https://github.com/tendermint/tendermint/pull/4146
Issue: https://github.com/tendermint/tendermint/issues/1648

* types: rename Commit#Precommits to Signatures

* update BlockIDFlagAbsent comment

* remove iota

* Clean up error conditions and simplify pseudocode

* Apply suggestions from code review

Co-Authored-By: Anca Zamfir <ancazamfir@users.noreply.github.com>

* Add spec doc about unconditional_peer, persistent_peers_max_dial of ADR-050 (#68)

* Add spec doc about unconditional_peer_ids, persistent_peers_max_dial_period of ADR-050

* Add indefinitely dialing condition

* Add sr25519 amino documentation (#67)

* sr25519 amino

* Update spec/blockchain/encoding.md

Co-Authored-By: Marko <marbar3778@yahoo.com>

* some suggestions for pseuodocode changes

* Improved error handling

* Add explanation on difference between trusted models

* Address reviewer's comments

* Addressing reviewer's comments

* Separating algorithm from proofs

* Intermediate commit (aligning spec with the code)

* Removing Store from API and providing end-to-end timing guarantees

* Address reviewer comment's. Intermediate commit

* light client dir and readmes

* titles

* add redirects

* add diagram

* detection TODO

* fix image

* update readme

* Aligh the correctness arguments with the pseudocode changes

* lite->light

* Fix link in readme

./light -> ./light-client

* p2p: Merlin based malleability fixes (#72)

* Update the secret connection spec with the use of merlin to eliminte handshake malleability

* Update spec/p2p/peer.md

Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com>

* Update spec/p2p/peer.md

Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com>

* Update spec/p2p/peer.md

Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com>

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>

* docs: update specs to remove cmn (#77)

- cmn was remvoed in favor of sub pkgs. cmn.kvpair is now kv.pair

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* evidence: Add time to evidence params (#69)

* evidence: Add time to evidence params

- this pr is grouped together with https://github.com/tendermint/tendermint/pull/4254, once that PR is merged then this one can be as well.

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* remove note

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* Apply suggestions from code review

Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com>

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>

* update link to the pex reactor

* add markdown link checker

* changed tab spacing

* removed folder-path flag

* first attempt at fixing all links

* second attempt at fixing all links

* codeowners: add code owners (#82)

* codeowners: add code owners

- added some codeowners
please comment if youd like to be added as well.

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* remove comment of repo maintainers

* remove .idea dir (#83)

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* RFC-001: configurable block retention (#84)

* Added RFC for truncated block history coordination

* Clarified minimum block retention

* Added hard checks on block retention and snapshot interval, and made some minor tweaks

* Genesis parameters are immutable

* Use local config for snapshot interval

* Reordered parameter descriptions

* Clarified local config option for snapshot-interval

* rewrite for ABCI commit response

* Renamed RFC

* add block retention diagram

* Removed retain_blocks table

* fix image numbers

* resolved open questions

* image quality

* accept RFC-001 (#86)

* abci: add basic description of ABCI Commit.ResponseHeight (#85)

Documentation for block pruning, once it's merged: tendermint/tendermint#4588.

Minimum documentation, for now - we probably shouldn't encourage using this feature too much until we release state sync.

* abci: add MaxAgeNumBlocks/MaxAgeDuration to EvidenceParams (#87)

* abci: update MaxAgeNumBlocks & MaxAgeDuration docs (#88)

* document state sync ABCI interface and P2P protocol (#90)

The corresponding Tendermint PRs are tendermint/tendermint#4704 and tendermint/tendermint#4705.

* Revert "document state sync ABCI interface and P2P protocol (#90)" (#92)

This reverts commit 9842b4b0fb.

* blockchain: change validator set sorting method (#91)

* abci: specify sorting of RequestInitChain.Validators

* blockchain: change validator sorting method

Refs https://github.com/tendermint/tendermint/issues/2478

* reactors/pex: specify hash function (#94)

https://github.com/tendermint/tendermint/pull/4810/files

* document state sync ABCI interface and P2P protocol (#93)

* Revert "Revert "document state sync ABCI interface and P2P protocol (#90)" (#92)"

This reverts commit 90797cef90.

* update with new enum case

* fix links

Co-authored-by: Erik Grinaker <erik@interchain.berlin>

* Update evidence params with MaxNum (#95)

evidence params now includes maxNum which is the maximum number of evidence that can be committed on a single block

* reactors/pex: masked IP is used as group key (#96)

* spec: add ProofTrialPeriod to EvidenceParam (#99)

* spec: modify Header.LastResultsHash (#97)

Refs: https://github.com/tendermint/tendermint/issues/1007
PR: https://github.com/tendermint/tendermint/pull/4845

* spec: link to abci server implementations (#100)

* spec: update evidence in blockchain.md (#108)

now evidence reflects the actual evidence present in the tendermint repo

* abci: add AppVersion to ConsensusParams (#106)

* abci: tweak node sync estimate (#115)

* spec/abci: expand on Validator#Address (#118)

Refs https://github.com/tendermint/tendermint/issues/3732

* blockchain: rename to core (#123)

* blockchain: remove duplicate evidence sections (#124)

* spec/consensus: canonical vs subjective commit

Refs https://github.com/tendermint/tendermint/issues/2769

* Apply suggestions from code review

Co-authored-by: Igor Konnov <igor.konnov@gmail.com>

* update spec with the removal of phantom validator evidence (#126)

* bring blockchain back

* add correct links

* spec: revert event hashing (#132)

* Evidence time is sourced from block time (#138)

* RFC-002: non-zero genesis (#119)

* abci: add ResponseInitChain.app_hash (#140)

* update hashing of empty inputs, and initial block LastResultsHash (#141)

* update evidence verification (#139)

* accept RFC-002 (#142)

* add description of arbitrary initial height (#135)

* update ResponseInitChain.app_hash description (#143)

* remove unused directories and update README (#145)

This change removes unused directories (`papers` and `research`) 
and updates the README to reflect our strategy for merging the 
informalsystems/tendermint-rs specs into this repository.

Partially addresses #121.

* ci: add markdown linter (#146)

* ci: add dependabot config (#148)

* build(deps): bump gaurav-nelson/github-action-markdown-link-check from 0.6.0 to 1.0.7 (#149)

Bumps [gaurav-nelson/github-action-markdown-link-check](https://github.com/gaurav-nelson/github-action-markdown-link-check) from 0.6.0 to 1.0.7.

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* docs: add sections to abci (#150)

* spec: update abci events (#151)

* spec: extract light-client to its own directory (#152)

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

* spec: remove evidences (#153)

* add a stale bot (#134)

* Current versions of light client specs from tendermint-rs (#158)

* current versions of light client specs from tendermint-rs

* markdown lint

* linting

* links

* links

* links

Co-authored-by: Marko Baricevic <marbar3778@yahoo.com>

* Fastsync spec from tendermint-rs (#157)

* fastsync spec from tendermint-rs

* fixed broken link

* fixed linting

* more fixes

* markdown lint

* move fast_sync to rust-spec

Co-authored-by: Marko Baricevic <marbar3778@yahoo.com>

* Update README.md (#160)

* spec/reactors/mempool: batch txs per peer (#155)

* spec/reactors/mempool: batch txs per peer

Refs https://github.com/tendermint/tendermint/issues/625

* update

* spec: Light client attack detector (#164)

* start with new detection and evidence spec

* more definitions at top

* sketch of functions

* pre post draft

* evidence proof

* typo

* evidence theory polished

* some TODOs resolved

* more TODOs

* links

* second to last revision before PR

* links

* I will read once more and then make a PR

* removed peer handling definitions

* secondary

* ready to review

* detector ready for review

* Update rust-spec/lightclient/detection/detection.md

Co-authored-by: Zarko Milosevic <zarko@informal.systems>

* Update rust-spec/lightclient/detection/detection.md

Co-authored-by: Zarko Milosevic <zarko@informal.systems>

* Update rust-spec/lightclient/detection/detection.md

Co-authored-by: Zarko Milosevic <zarko@informal.systems>

* Update rust-spec/lightclient/detection/detection.md

Co-authored-by: Zarko Milosevic <zarko@informal.systems>

* Update rust-spec/lightclient/detection/detection.md

Co-authored-by: Zarko Milosevic <zarko@informal.systems>

* Update rust-spec/lightclient/detection/detection.md

Co-authored-by: Zarko Milosevic <zarko@informal.systems>

* Update rust-spec/lightclient/detection/detection.md

* skip-trace

* PossibleCommit explained

* Update rust-spec/lightclient/detection/detection.md

Co-authored-by: Zarko Milosevic <zarko@informal.systems>

* comments by Zarko

* renamed and changed link in README

Co-authored-by: Zarko Milosevic <zarko@informal.systems>

* fixed an overlooked conflict (#167)

* describe valset sorting according to v0.34 requirements (#169)

* evidence: update data structures (#165)

* fix markdown linter (#172)

* TLA+ specs from MBT revision (#173)

* remove setOption (#181)

* spec: protobuf changes (#156)

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>

* first check latest with secondary (#184)

* Extending the blockchain specification (in the light client) to produce different ratios of faults (#183)

* cleaning unused definitions

* introduced the ratio of faulty processes

* Update README.md (#185)

* build(deps): bump gaurav-nelson/github-action-markdown-link-check from 1.0.7 to 1.0.8 (#188)

Bumps [gaurav-nelson/github-action-markdown-link-check](https://github.com/gaurav-nelson/github-action-markdown-link-check) from 1.0.7 to 1.0.8.
- [Release notes](https://github.com/gaurav-nelson/github-action-markdown-link-check/releases)
- [Commits](https://github.com/gaurav-nelson/github-action-markdown-link-check/compare/1.0.7...e3c371c731b2f494f856dc5de7f61cea4d519907)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* spec: update light client verification to match supervisor (#171)

* VDD renaming of verification spec + links fixed

* latest()

* backwards

* added TODOs

* link in old file to new name

* better text

* revision done. needs one more round of reading

* renamed constants in 001 according to TLA+ and impl

* ready for PR

* forgot linting

* Update rust-spec/lightclient/verification/verification_002_draft.md

* Update rust-spec/lightclient/verification/verification_002_draft.md

* added lightstore function needed for supervisor

* added lightstore functions for supervisor

* ident

* Update rust-spec/lightclient/verification/verification_002_draft.md

* github: issue template for proposals (#190)

* Sequential Supervisor (#186)

* move from tendermint-rs but needs discussion

* markdown lint

* TODO links replaced

* links

* links

* links lint

* Update rust-spec/lightclient/supervisor/supervisor.md

* Update rust-spec/lightclient/supervisor/supervisor.md

* Update rust-spec/lightclient/supervisor/supervisor.md

* Update rust-spec/lightclient/supervisor/supervisor.md

* moved peer handling definitions to supervisor

* polishing

* rename

* Update rust-spec/lightclient/supervisor/supervisor_001_draft.md

* Update rust-spec/lightclient/supervisor/supervisor_001_draft.md

* changes to maintain StateVerified again

* ready for changes in verification

* start of supervisor

* module name

* fixed

* more details

* supevisor completed. Now I have to add function to verification

* ready for review

* tla comment

* removed issues

* Update rust-spec/lightclient/supervisor/supervisor_001_draft.md

* intro text fixed

* indentation

* Update rust-spec/lightclient/supervisor/supervisor_001_draft.md

* comment to entry points

Co-authored-by: Marko Baricevic <marbar3778@yahoo.com>

* RFC: adopt zip 215 (#144)

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Core: move validation & data structures together (#176)

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

* docs: make blockchain not viewable (#211)

* evidence: update data structures to reflect added support of abci evidence (#213)

* encoding: add secp, ref zip215, tables (#212)

* Detector English Spec ready (#215)

Add detector English spec

* add Ivy proofs (#210)

* add Ivy proofs

* fix docker-compose command

* Light client detector spec in TLA+ and refactoring of light client verification TLA+ spec (#216)

Add light client detector spec in TLA+

* abci: lastcommitinfo.round extra sentence (#221)

* abci: add abci_version to requestInfo (#223)

* BFT requires _less than_ 1/3 faulty validators (#228)

Thanks fo spotting the imprecision in the text, @shahankhatch !

* Draft of evidence handling for discussion (#225)

* start with accountability deliverable

* problem statement

* draft function

* quite complete draft. ready to discuss with Igor

* Update isolate-attackers_001_draft.md

* Update isolate-attackers_001_draft.md

* Update isolate-attackers_001_draft.md

* Update isolate-attackers_001_draft.md

* Update isolate-attackers_001_draft.md

* ready for TLA+ to take over

* isolate

* isolateamnesiatodos

* Update isolate-attackers_001_draft.md

* Update rust-spec/lightclient/attacks/isolate-attackers_001_draft.md

Co-authored-by: Igor Konnov <konnov@forsyte.at>

* Update rust-spec/lightclient/attacks/isolate-attackers_001_draft.md

Co-authored-by: Igor Konnov <konnov@forsyte.at>

* Update rust-spec/lightclient/attacks/isolate-attackers_001_draft.md

Co-authored-by: Igor Konnov <konnov@forsyte.at>

* Update rust-spec/lightclient/attacks/isolate-attackers_001_draft.md

Co-authored-by: Igor Konnov <konnov@forsyte.at>

* Update rust-spec/lightclient/attacks/isolate-attackers_001_draft.md

Co-authored-by: Igor Konnov <konnov@forsyte.at>

* Update rust-spec/lightclient/attacks/isolate-attackers_001_draft.md

Co-authored-by: Igor Konnov <konnov@forsyte.at>

* Update rust-spec/lightclient/attacks/isolate-attackers_001_draft.md

Co-authored-by: Igor Konnov <konnov@forsyte.at>

* Update rust-spec/lightclient/attacks/isolate-attackers_001_draft.md

Co-authored-by: Igor Konnov <konnov@forsyte.at>

* The TLA+ specification of the attackers detection (#231)

* the working attackers isolation spec, needs more comments

* the TLA+ spec of the attackers isolation

* build(deps): bump gaurav-nelson/github-action-markdown-link-check (#233)

Bumps [gaurav-nelson/github-action-markdown-link-check](https://github.com/gaurav-nelson/github-action-markdown-link-check) from 1.0.8 to 1.0.11.
- [Release notes](https://github.com/gaurav-nelson/github-action-markdown-link-check/releases)
- [Commits](https://github.com/gaurav-nelson/github-action-markdown-link-check/compare/1.0.8...2a60e0fe41b5361f446ccace6621a1a2a5c324cf)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Computing attack types (#232)

Add light attack evidence handling

* Update README.md (#234)

* p2p: update frame size (#235)

Reflect the change made in https://github.com/tendermint/tendermint/pull/5805

The MTU (Maximum Transmission Unit) for Ethernet is 1500 bytes.
The IP header and the TCP header take up 20 bytes each at least (unless
optional header fields are used) and thus the max for (non-Jumbo frame)
Ethernet is 1500 - 20 -20 = 1460
Source: https://stackoverflow.com/a/3074427/820520

* build(deps): bump gaurav-nelson/github-action-markdown-link-check (#239)

Bumps [gaurav-nelson/github-action-markdown-link-check](https://github.com/gaurav-nelson/github-action-markdown-link-check) from 1.0.11 to 1.0.12.
- [Release notes](https://github.com/gaurav-nelson/github-action-markdown-link-check/releases)
- [Commits](https://github.com/gaurav-nelson/github-action-markdown-link-check/compare/1.0.11...0fe4911067fa322422f325b002d2038ba5602170)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* layout: add section titles (#240)

* reactors: remove bcv1 (#241)

* abci: rewrite to proto interface (#237)

* Update supervisor_001_draft.md (#243)

* spec: remove reactor section (#242)

Co-authored-by: Tess Rinearson <tess.rinearson@gmail.com>

* non-critical bugfix in the TLA+ spec (found by new version of apalache) (#244)

* params: remove block timeiota (#248)

* proto: add files (#246)

Co-authored-by: Erik Grinaker <erik@interchain.berlin>

* proto: modify height int64 to uint64 (#253)

* abci: note on concurrency (#258)

Co-authored-by: Marko <marbar3778@yahoo.com>

* spec: merge rust-spec (#252)

* Fix list of RFCs (#266)

* readme: cleanup (#262)

* modify readme

* add rfc and proto

* add rust=spec back to avoid breakage

* lint readme

* genesis: Explain fields in genesis file (#270)

* describe the genesis

* Update spec/core/genesis.md

Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

* add wording on app_state

* Update spec/core/genesis.md

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
Co-authored-by: Callum Waters <cmwaters19@gmail.com>

* p2p: links (#268)

* fix links

* fix more links

* Proposer-based timestamp specification (#261)

* added proposer-based timestamp spec

* Update spec/consensus/proposer-based-timestamp/pbts_001_draft.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update spec/consensus/proposer-based-timestamp/pbts_001_draft.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update spec/consensus/proposer-based-timestamp/pbts-algorithm_001_draft.md

Co-authored-by: Marko <marbar3778@yahoo.com>

* Update spec/consensus/proposer-based-timestamp/pbts-algorithm_001_draft.md

* Update spec/consensus/proposer-based-timestamp/pbts-sysmodel_001_draft.md

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

* fixes from PR

Co-authored-by: Josef Widder <44643235+josef-widder@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Callum Waters <cmwaters19@gmail.com>

* abci: reorder sidebar (#282)

* ABCI++ RFC (#254)

* ABCI++ RFC

This commit adds an RFC for ABCI++, which is a collection of three new phases of communication between the consensus engine and the application.

Co-authored-by: Sunny Aggarwal <sunnya97@protonmail.ch>

* Fix bugs pointed out by @liamsi

* Update rfc/004-abci++.md

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* Fix markdown lints

* Update rfc/004-abci++.md

Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com>

* Update rfc/004-abci++.md

Co-authored-by: Tess Rinearson <tess.rinearson@gmail.com>

* Update rfc/004-abci++.md

Co-authored-by: Tess Rinearson <tess.rinearson@gmail.com>

* Add information about the rename in the context section

* Bold RFC

* Add example for self-authenticating vote data

* More exposition of the term IPC

* Update pros / negatives

* Fix sentence fragment

* Add desc for no-ops

Co-authored-by: Sunny Aggarwal <sunnya97@protonmail.ch>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com>
Co-authored-by: Tess Rinearson <tess.rinearson@gmail.com>

* RFC: ReverseSync - fetching historical data (#224)

* core: update a few sections  (#284)

* p2p: update state sync messages for reverse sync (#285)

* Update README.md (#286)

* rpc: define spec for RPC (#276)

* add rpc spec and support outline

* add json

* add more routes remove unneeded ones

* add rest of rpc endpoints

* add jsonrpc calls

* add more jsonrpc calls

* fix blockchain

* cleanup unused links and add links to repos

* Update spec/rpc/README.md

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

* add missing param from consensus param

* Update spec/rpc/README.md

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

* Update spec/rpc/README.md

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

* fix cast and add doc to readme

Co-authored-by: Callum Waters <cmwaters19@gmail.com>
Co-authored-by: Marko Baricevic <markobaricevic@Fergalicious.local>

* A few improvements to the Ivy proof (#288)

* Avoid quantifier alternation cycle

The problematic quantifier alternation cycle arose because the
definition of accountability_violation was unfolded.

This commit also restructures the induction proof for clarity.

* add count_lines.sh

* fix typo and add forgotten complete=fo in comment

Co-authored-by: Giuliano <giuliano@eic-61-11.galois.com>

* Fixed a broken link (#291)

* fix message type for block-sync (#298)

* lint: fix lint errors (#301)

* build(deps): bump actions/stale from 3 to 3.0.18 (#300)

Bumps [actions/stale](https://github.com/actions/stale) from 3 to 3.0.18.
- [Release notes](https://github.com/actions/stale/releases)
- [Commits](https://github.com/actions/stale/compare/v3...v3.0.18)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump actions/stale from 3.0.18 to 3.0.19 (#302)

Bumps [actions/stale](https://github.com/actions/stale) from 3.0.18 to 3.0.19.
- [Release notes](https://github.com/actions/stale/releases)
- [Commits](https://github.com/actions/stale/compare/v3.0.18...v3.0.19)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* rename HasVote to ReceivedVote (#289)

* add a changelog to track changes (#303)

* add a changelog to track changes

* Update CHANGELOG.md

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

* rpc: clarify timestamps (#304)

* clarify timestamps

* changelog entry

* Update spec/rpc/README.md

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

* rpc: add chunked genesis endpoint (#299)

* rpc: add chunked genesis endpoint

* fix lint

* feedback

* add info about error

* fix lint

Co-authored-by: marbar3778 <marbar3778@yahoo.com>

* update ResponseCheckTx (#306)

* rpc: Add totalGasUSed to block_results response (#308)

* Add C++ code generation and test scenario (#310)

* add parameters to byzantine send action

* make net not trusted

it's not necessary since for proofs Ivy will assume that the environment
does not break action preconditions

* use require instead of assume

it seems that assume is not checked when other isolates call!

* add comment

* add comment

* run with random seed

* make domain model extractable to C++

* substitute require for assume

assumes in an action are not checked when the action is called! I.e.
they place no requirement on the caller; we're just assuming that the
caller is going to do the right thing. This wasn't very important here
but it leade to a minor inconsistency slipping through.

* make the net isolate not trusted

there was no need for it

* add tendermint_test.ivy

contains a simple test scenario that show that the specification is no
vacuuous

* update comment

* add comments

* throw if trying to parse nset value in the repl

* add comment

* minor refactoring

* add new pex messages (#312)

* build(deps): bump gaurav-nelson/github-action-markdown-link-check (#313)

Bumps [gaurav-nelson/github-action-markdown-link-check](https://github.com/gaurav-nelson/github-action-markdown-link-check) from 1.0.12 to 1.0.13.
- [Release notes](https://github.com/gaurav-nelson/github-action-markdown-link-check/releases)
- [Commits](https://github.com/gaurav-nelson/github-action-markdown-link-check/compare/1.0.12...1.0.13)

---
updated-dependencies:
- dependency-name: gaurav-nelson/github-action-markdown-link-check
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* update spec to reference currently used timestamp type (#317)

* build(deps): bump actions/stale from 3.0.19 to 4 (#319)

Bumps [actions/stale](https://github.com/actions/stale) from 3.0.19 to 4.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v3.0.19...v4)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* address discrepancies between spec and implementation (#322)

* update proto files for release (#318)

* stale bot: ignore issues (#325)

* evidence: add section explaining evidence (#324)

* statesync: new messages for gossiping consensus params (#328)

* rpc: update peer format in specification in NetInfo operation (#331)

* Update supervisor_001_draft.md (#334)

* core: text cleanup (#332)

* abci: clarify what abci stands for (#336)

* abci: clarify what abci stands for

* link to abci type protos.

* abci: clarify connection use in-process (#337)

* abci: clarify connection use in-process

* Update abci.md

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* invert abci explanations

* lint++

* lint++

* lint++

* lint++

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* proto: move proto files under the correct directory related to their package name (#344)

* abci.md fixup (#339)

* abci: points of clarification ahead of v0.1.0

* lint++

* typo

* lint++

* double word score

* grammar

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update spec/abci/abci.md

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* pr feedback

* wip

* update non-zero status code docs

* fix event description

* update CheckTx description

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* Update supervisor_001_draft.md (#333)

* Update supervisor_001_draft.md

If the only node in the *FullNodes* set is the primary, that was just deemed faulty, we can't find honest primary.

* Update supervisor_001_draft.md

* light: update initialization description (#320)

* apps.md fixups (#341)

* wip

* wip

* wip

* remove comments in favor of gh comments

* wip

* udpates to language, should must etc

* Apply suggestions from code review

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* remove tendermint cache description

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>

* proto: add tendermint go changes (#349)

* add missed proto files

* add abci changes

* rename blockchain to blocksync

* Update proto/tendermint/abci/types.proto

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

Co-authored-by: Callum Waters <cmwaters19@gmail.com>

* fix mockery generation script (#9094)

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>
Co-authored-by: Milosevic, Zarko <zare.milosevic@gmail.com>
Co-authored-by: Milosevic, Zarko <zare.milosevic@sicpa.com>
Co-authored-by: Zarko Milosevic <zarko@tendermint.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Zarko Milosevic <zarko@interchain.io>
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
Co-authored-by: Anca Zamfir <ancazamfir@users.noreply.github.com>
Co-authored-by: dongsamb <dongsamb@gmail.com>
Co-authored-by: Sunny Aggarwal <sunnya97@gmail.com>
Co-authored-by: Anca Zamfir <anca@interchain.io>
Co-authored-by: Ethan Buchman <ethan@coinculture.info>
Co-authored-by: Zarko Milosevic <zarko@informal.systems>
Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com>
Co-authored-by: Zaki Manian <zaki@tendermint.com>
Co-authored-by: Erik Grinaker <erik@interchain.berlin>
Co-authored-by: Tess Rinearson <tess.rinearson@gmail.com>
Co-authored-by: Alexander Simmerl <a.simmerl@gmail.com>
Co-authored-by: Igor Konnov <igor.konnov@gmail.com>
Co-authored-by: Sean Braithwaite <brapse@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Josef Widder <44643235+josef-widder@users.noreply.github.com>
Co-authored-by: Andrey Kuprianov <59489470+andrey-kuprianov@users.noreply.github.com>
Co-authored-by: Igor Konnov <konnov@forsyte.at>
Co-authored-by: Sam Hart <sam@hxrts.com>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Giuliano <giuliano@losa.fr>
Co-authored-by: Shahan Khatchadourian <shahan.k.code@gmail.com>
Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
Co-authored-by: istoilkovska <anili100@gmail.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Sam Kleinman <garen@tychoish.com>
Co-authored-by: Sunny Aggarwal <sunnya97@protonmail.ch>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Marko Baricevic <markobaricevic@Fergalicious.local>
Co-authored-by: Giuliano <giuliano@eic-61-11.galois.com>
Co-authored-by: Jordan Sexton <jordan@jordansexton.com>
Co-authored-by: MengXiangJian <805442788@qq.com>
Co-authored-by: Yixin Luo <18810541851@163.com>
Co-authored-by: crypto-facs <84574577+crypto-facs@users.noreply.github.com>
Co-authored-by: Giuliano <giuliano@galois.com>
Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com>
Co-authored-by: Mateusz Górski <goral09@users.noreply.github.com>
Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
Co-authored-by: Thane Thomson <connect@thanethomson.com>
2022-08-16 11:07:21 -04:00

31 KiB

Light Client Attack Detector

In this specification, we strengthen the light client to be resistant against so-called light client attacks. In a light client attack, all the correct Tendermint full nodes agree on the sequence of generated blocks (no fork), but a set of faulty full nodes attack a light client by generating (signing) a block that deviates from the block of the same height on the blockchain. In order to do so, some of these faulty full nodes must have been validators before and violate the assumption of more than two thirds of "correct voting power" [TMBC-FM-2THIRDS], as otherwise, if [TMBC-FM-2THIRDS] would hold, verification would satisfy [LCV-SEQ-SAFE.1].

An attack detector (or detector for short) is a mechanism that is used by the light client supervisor after verification of a new light block with the primary, to cross-check the newly learned light block with other peers (secondaries). It expects as input a light block with some height root (that serves as a root of trust), and a verification trace (a sequence of lightblocks) that the primary provided.

In case the detector observes a light client attack, it computes evidence data that can be used by Tendermint full nodes to isolate a set of faulty full nodes that are still within the unbonding period (more than 1/3 of the voting power of the validator set at some block of the chain), and report them via ABCI (application/blockchain interface) to the application of a Tendermint blockchain in order to punish faulty nodes.

Context of this document

The light client verification specification is designed for the Tendermint failure model (1/3 assumption) [TMBC-FM-2THIRDS]. It is safe under this assumption, and live if it can reliably (that is, no message loss, no duplication, and eventually delivered) and timely communicate with a correct full node. If [TMBC-FM-2THIRDS] assumption is violated, the light client can be fooled to trust a light block that was not generated by Tendermint consensus.

This specification, the attack detector, is a "second line of defense", in case the 1/3 assumption is violated. Its goal is to detect a light client attack (conflicting light blocks) and collect evidence. However, it is impractical to probe all full nodes. At this time we consider a simple scheme of maintaining an address book of known full nodes from which a small subset (e.g., 4) are chosen initially to communicate with. More involved book keeping with probabilistic guarantees can be considered at later stages of the project.

The light client maintains a simple address book containing addresses of full nodes that it can pick as primary and secondaries. To obtain a new light block, the light client first does verification with the primary, and then cross-checks the light block (and the trace of light blocks that led to it) with the secondaries using this specification.

Outline

Part I - Tendermint Consensus and Light Client Attacks

In this section we will give some mathematical definitions of what we mean by light client attacks (that are considered in this specification) and how they differ from main-chain forks. To this end, we start by defining some properties of the sequence of blocks that is decided upon by Tendermint consensus in normal operation (if the Tendermint failure model holds [TMBC-FM-2THIRDS]), and then define different deviations that correspond to attack scenarios. We consider the notion of light blocks and headers.

[TMBC-GENESIS.1]

Let Genesis be the agreed-upon initial block (file).

[TMBC-FUNC-SIGN.1]

Let b and c be two light blocks with b.Header.Height + 1 = c.Header.Height. We define the predicate signs(b,c) to hold iff c.Header.LastCommit is in PossibleCommit(b). [TMBC-SOUND-DISTR-POSS-COMMIT.1].

The above encodes sequential verification, that is, intuitively, b.Header.NextValidators = c.Header.Validators and 2/3 of these Validators signed c.

[TMBC-FUNC-SUPPORT.1]

Let b and c be two light blocks. We define the predicate supports(b,c,t) to hold iff

  • t - trustingPeriod < b.Header.Time < t
  • the voting power in b.NextValidators of nodes in c.Commit is more than 1/3 of TotalVotingPower(b.Header.NextValidators)

That is, if the Tendermint failure model holds, then c has been signed by at least one correct full node, cf. [TMBC-VAL-CONTAINS-CORR.1]. The following formalizes that b was properly generated by Tendermint; b can be traced back to genesis.

[TMBC-SEQ-ROOTED.1]

Let b be a light block. We define sequ-rooted(b) iff for all i, 1 <= i < h = b.Header.Height, there exist light blocks a(i) s.t.

  • a(1) = Genesis and
  • a(h) = b and
  • signs( a(i) , a(i+1) ).

The following formalizes that c is trusted based on b in skipping verification. Observe that we do not require here (yet) that b was properly generated.

[TMBC-SKIP-TRACE.1]

Let b and c be light blocks. We define skip-trace(b,c,t) if at time t there exists an integer h and a sequence a(1), ... a(h) s.t.

  • a(1) = b and
  • a(h) = c and
  • supports( a(i), a(i+1), t), for all i, 1 <= i < h.

We call such a sequence a(1), ... a(h) a verification trace.

The following formalizes that two light blocks of the same height should agree on the content of the header. Observe that b and c may disagree on the Commit. This is a special case if the canonical commit has not been decided on yet, that is, if b.Header.Height is the maximum height of all blocks decided upon by Tendermint at this moment.

[TMBC-SIGN-SKIP-MATCH.1]

Let a, b, c, be light blocks and t a time, we define sign-skip-match(a,b,c,t) = true iff the following implication evaluates to true:

  • sequ-rooted(a) and
  • b.Header.Height = c.Header.Height and
  • skip-trace(a,b,t)
  • skip-trace(a,c,t)

implies b.Header = c.Header.

Observe that sign-skip-match is defined via an implication. If it evaluates to false this means that the left-hand-side of the implication evaluates to true, and the right-hand-side evaluates to false. In particular, there are two different headers b and c that both can be verified from a common block a from the chain. Thus, the following describes an attack.

[TMBC-ATTACK.1]

If there exists three light blocks a, b, and c, with sign-skip-match(a,b,c,t) = false then we have an attack. We say we have an attack at height b.Header.Height and write attack(a,b,c,t).

The lightblock a need not be unique, that is, there may be several blocks that satisfy the above requirement for the same blocks b and c.

[TMBC-ATTACK.1] is a formalization of the violation of the agreement property based on the result of consensus, that is, the generated blocks.

Remark. Violation of agreement is only possible if more than 1/3 of the validators (or next validators) of some previous block deviated from the protocol. The upcoming "accountability" specification will describe how to compute a set of at least 1/3 faulty nodes from two conflicting blocks. []

There are different ways to characterize forks and attack scenarios. This specification uses the "node-based characterization of attacks" which focuses on what kinds of nodes are affected (light nodes vs. full nodes). For future reference and discussion we also provide a "block-based characterization of attacks" below.

Node-based characterization of attacks

[TMBC-MC-FORK.1]

We say there is a (main chain) fork at time t if

  • there are two correct full nodes i and j and
  • i is different from j and
  • i has decided on b and
  • j has decided on c and
  • there exist a such that attack(a,b,c,t).

[TMBC-LC-ATTACK.1]

We say there is a light client attack at time t, if

  • there is no (main chain) fork [TMBC-MC-FORK.1], and
  • there exist nodes that have computed light blocks b and c and
  • there exist a such that attack(a,b,c,t).

We say the attack is at height a.Header.Height.

In this specification we consider detection of light client attacks. Intuitively, the case we consider is that light block b is the one from the blockchain, and some attacker has computed c and tries to wrongly convince the light client that c is the block from the chain.

[TMBC-LC-ATTACK-EVIDENCE.1]

We consider the following case of a light client attack [TMBC-LC-ATTACK.1]:

  • attack(a,b,c,t)
  • there is a peer p1 that has a sequence chain of blocks from a to b
  • skip-trace(a,c,t): by [TMBC-SKIP-TRACE.1] there is a verification trace v of the form a = v(1), ... v(h) = c

Evidence for p1 (that proves an attack to p1) consists for index i of v(i) and v(i+1) such that

  • E1(i). v(i) is equal to the block of chain at height v(i).Height, and
  • E2(i). v(i+1) that is different from the block of chain at height v(i+1).height

Observe p1 can

  • check that v(i+1) differs from its block at that height, and
  • verify v(i+1) in one step from v(i) as v is a verification trace.

[TMBC-LC-EVIDENCE-DATA.1]

To prove the attack to p1, because of Point E1, it is sufficient to submit

  • v(i).Height (rather than v(i)).
  • v(i+1)

This information is evidence for height v(i).Height.

Block-based characterization of attacks

In this section we provide a different characterization of attacks. It is not defined on the nodes that are affected but purely on the content of the blocks. In that sense these definitions are less operational.

They might be relevant for a closer analysis of fork scenarios on the chain, which is out of the scope of this specification.

[TMBC-SIGN-UNIQUE.1]

Let b and c be light blocks, we define the predicate sign-unique(b,c) to evaluate to true iff the following implication evaluates to true:

  • b.Header.Height = c.Header.Height and
  • sequ-rooted(b) and
  • sequ-rooted(c)

implies b = c.

[TMBC-BLOCKS-MCFORK.1]

If there exists two light blocks b and c, with sign-unique(b,c) = false then we have a fork.

The difference of the above definition to [TMBC-MC-FORK.1] is subtle. The latter requires a full node being affected by a bad block while [TMBC-BLOCKS-MCFORK.1] just requires that a bad block exists, possibly in memory of an attacker. The following captures a light client fork. There is no fork up to the height of block b. However, c is of that height, is different, and passes skipping verification. It is a stricter property than [TMBC-LC-ATTACK.1], as [TMBC-LC-ATTACK.1] requires that no correct full node is affected.

[TMBC-BLOCKS-LCFORK.1]

Let a, b, c, be light blocks and t a time. We define light-client-fork(a,b,c,t) iff

  • sign-skip-match(a,b,c,t) = false and
  • sequ-rooted(b) and
  • b is "unique", that is, for all d, sequ-rooted(d) and d.Header.Height = b.Header.Height implies d = b

Finally, let us also define bogus blocks that have no support. Observe that bogus is even defined if there is a fork. Also, for the definition it would be sufficient to restrict a to a.height < b.height (which is implied by the definitions which unfold until supports()).

[TMBC-BOGUS.1]

Let b be a light block and t a time. We define bogus(b,t) iff

  • sequ-rooted(b) = false and
  • for all a, sequ-rooted(a) implies skip-trace(a,b,t) = false

Part II - Problem Statement

Informal Problem statement

There is no sequential specification: the detector only makes sense in a distributed systems where some nodes misbehave.

We work under the assumption that full nodes and validators are responsible for detecting attacks on the main chain, and the evidence reactor takes care of broadcasting evidence to communicate misbehaving nodes via ABCI to the application, and halt the chain in case of a fork. The point of this specification is to shield a light clients against attacks that cannot be detected by full nodes, and are fully addressed at light clients (and consequently IBC relayers, which use the light client protocols to observe the state of a blockchain). In order to provide full nodes the incentive to follow the protocols when communicating with the light client, this specification also considers the generation of evidence that will also be processed by the Tendermint blockchain.

[LCD-IP-MODEL.1]

The detector is designed under the assumption that

As a result some faulty full nodes may launch an attack on a light client.

The following requirements are operational in that they describe how things should be done, rather than what should be done. However, they do not constitute temporal logic verification conditions. For those, see [LCD-DIST-*] below.

The detector is called in the supervisor as follows

Evidences := AttackDetector(root_of_trust, verifiedLS);`

where

  • root-of-trust is a light block that is trusted (that is, except upon initialization, the primary and the secondaries agreed on in the past), and
  • verifiedLS is a lightstore that contains a verification trace that starts from a lightblock that can be verified with the root-of-trust in one step and ends with a lightblock of the height requested by the user
  • Evidences is a list of evidences for misbehavior

[LCD-IP-STATEMENT.1]

Whenever AttackDetector is called, the detector should for each secondary cross check the largest header in verifiedLS with the corresponding header of the same height provided by the secondary. If there is a deviation, the detector should try to replay the verification trace verifiedLS with the secondary

  • in case replaying leads to detection of a light client attack (one of the lightblocks differ from the one in verifiedLS with the same height), we should return evidence
  • if the secondary cannot provide a verification trace, we have no proof for an attack. Block b may be bogus. In this case the secondary is faulty and it should be replaced.

Assumptions

It is not in the interest of faulty full nodes to talk to the detector as long as the detector is connected to at least one correct full node. This would only increase the likelihood of misbehavior being detected. Also we cannot punish them easily (cheaply). The absence of a response need not be the fault of the full node.

Correct full nodes have the incentive to respond, because the detector may help them to understand whether their header is a good one. We can thus base liveness arguments of the detector on the assumptions that correct full nodes reliably talk to the detector.

[LCD-A-CorrFull.1]

At all times there is at least one correct full node among the primary and the secondaries.

For this version of the detection we take this assumption. It allows us to establish the invariant that the lightblock root-of-trust is always the one from the blockchain, and we can use it as starting point for the evidence computation. Moreover, it allows us to establish the invariant at the supervisor that any lightblock in the (top-level) lightstore is from the blockchain.
In the future we might design a lightclient based on the assumption that at least in regular intervals the lightclient is connected to a correct full node. This will require the detector to reconsider root-of-trust, and remove lightblocks from the top-level lightstore.

[LCD-A-RelComm.1]

Communication between the detector and a correct full node is reliable and bounded in time. Reliable communication means that messages are not lost, not duplicated, and eventually delivered. There is a (known) end-to-end delay Delta, such that if a message is sent at time t then it is received and processed by time t + Delta. This implies that we need a timeout of at least 2 Delta for remote procedure calls to ensure that the response of a correct peer arrives before the timeout expires.

Definitions

Evidence

Following the definition of [TMBC-LC-ATTACK-EVIDENCE.1], by evidence we refer to a variable of the following type

[LC-DATA-EVIDENCE.1]

type LightClientAttackEvidence struct {
    ConflictingBlock   LightBlock
    CommonHeight       int64

    // Evidence also includes application specific data which is not
    // part of verification but is sent to the application once the
    // evidence gets committed on chain.
}

As the above data is computed for a specific peer, the following data structure wraps the evidence and adds the peerID.

[LC-DATA-EVIDENCE-INT.1]

type InternalEvidence struct {
    Evidence           LightClientAttackEvidence
    Peer               PeerID
}

[LC-SUMBIT-EVIDENCE.1]

func submitEvidence(Evidences []InternalEvidence)
  • Expected postcondition
    • for each ev in Evidences: submit ev.Evidence to ev.Peer

LightStore

Lightblocks and LightStores are defined in the verification specification [LCV-DATA-LIGHTBLOCK.1] and [LCV-DATA-LIGHTSTORE.2]. See the verification specification for details.

Distributed Problem statement

As the attack detector is there to reduce the impact of faulty nodes, and faulty nodes imply that there is a distributed system, there is no sequential specification to which this distributed problem statement may refer to.

The detector gets as input a trusted lightblock called root and an auxiliary lightstore called primary_trace with lightblocks that have been verified before, and that were provided by the primary.

[LCD-DIST-INV-ATTACK.1]

If the detector returns evidence for height h [TMBC-LC-EVIDENCE-DATA.1], then there is an attack at height h. [TMBC-LC-ATTACK.1]

[LCD-DIST-INV-STORE.1]

If the detector does not return evidence, then primary_trace contains only blocks from the blockchain.

[LCD-DIST-LIVE.1]

The detector eventually terminates.

[LCD-DIST-TERM-NORMAL.1]

If

  • the primary_trace contains only blocks from the blockchain, and
  • there is no attack, and
  • Secondaries is always non-empty, and
  • the age of root is always less than the trusting period,

then the detector does not return evidence.

[LCD-DIST-TERM-ATTACK.1]

If

  • there is an attack, and
  • a secondary reports a block that conflicts with one of the blocks in primary_trace, and
  • Secondaries is always non-empty, and
  • the age of root is always less than the trusting period,

then the detector returns evidence.

Observe that above we require that "a secondary reports a block that conflicts". If there is an attack, but no secondary tries to launch it against the detector (or the message from the secondary is lost by the network), then there is nothing to detect for us.

[LCD-DIST-SAFE-SECONDARY.1]

No correct secondary is ever replaced.

[LCD-DIST-SAFE-BOGUS.1]

If

  • a secondary reports a bogus lightblock,
  • the age of root is always less than the trusting period,

then the secondary is replaced before the detector terminates.

The above property is quite operational (e.g., the usage of "reports"), but it captures closely the requirement. As the detector only makes sense in a distributed setting, and does not have a sequential specification, a less "pure" specification are acceptable.

Part III - Protocol

Functions and Data defined in other Specifications

From the supervisor

[LC-FUNC-REPLACE-SECONDARY.1]

Replace_Secondary(addr Address, root-of-trust LightBlock)

From the verifier

[LCV-FUNC-MAIN.2]

func VerifyToTarget(primary PeerID, root LightBlock,
                    targetHeight Height) (LightStore, Result)

Observe that VerifyToTarget does communication with the secondaries via the function FetchLightBlock.

Shared data of the light client

  • a pool of full nodes FullNodes that have not been contacted before
  • peer set called Secondaries
  • primary

Note that the lightStore is not needed to be shared.

Outline of solution

The problem laid out is solved by calling the function AttackDetector with a lightstore that contains a light block that has just been verified by the verifier.

Then AttackDetector downloads headers from the secondaries. In case a conflicting header is downloaded from a secondary, it calls CreateEvidenceForPeer which computes evidence in the case that indeed an attack is confirmed. It could be that the secondary reports a bogus block, which means that there need not be an attack, and the secondary is replaced.

Details of the functions

[LCD-FUNC-DETECTOR.2]:

func AttackDetector(root LightBlock, primary_trace []LightBlock)
                   ([]InternalEvidence) {

    Evidences := new []InternalEvidence;

    for each secondary in Secondaries {
        lb, result := FetchLightBlock(secondary,primary_trace.Latest().Header.Height);
        if result != ResultSuccess {
            Replace_Secondary(root);
        }
        else if lb.Header != primary_trace.Latest().Header {
  
            // we replay the primary trace with the secondary, in
            // order to generate evidence that we can submit to the
            // secondary. We return the evidence + the trace the
            // secondary told us that spans the evidence at its local store

            EvidenceForSecondary, newroot, secondary_trace, result :=
                    CreateEvidenceForPeer(secondary,
                                          root,
                                          primary_trace);
            if result == FaultyPeer {
                Replace_Secondary(root);
            }
            else if result == FoundEvidence {
                // the conflict is not bogus
                Evidences.Add(EvidenceForSecondary);
                // we replay the secondary trace with the primary, ...
                EvidenceForPrimary, _, result :=
                        CreateEvidenceForPeer(primary,
                                              newroot,
                                              secondary_trace);
                if result == FoundEvidence {
                    Evidences.Add(EvidenceForPrimary);
                }
                // At this point we do not care about the other error
                // codes. We already have generated evidence for an
                // attack and need to stop the lightclient. It does not
                // help to call replace_primary. Also we will use the
                // same primary to check with other secondaries in
                // later iterations of the loop
            }
            // In the case where the secondary reports NoEvidence
            // after initially it reported a conflicting header.
            // secondary is faulty
            Replace_Secondary(root);
        }
    }
    return Evidences;
}
  • Expected precondition
    • root and primary trace are a verification trace
  • Expected postcondition
    • solves the problem statement (if attack found, then evidence is reported)
  • Error condition
    • ErrorTrustExpired: fails if root expires (outside trusting period) [LCV-INV-TP.1]
    • ErrorNoPeers: if no peers are left to replace secondaries, and no evidence was found before that happened

func CreateEvidenceForPeer(peer PeerID, root LightBlock, trace LightStore)
                          (Evidence, LightBlock, LightStore, result) {

    common := root;

    for i in 1 .. len(trace) {
        auxLS, result := VerifyToTarget(peer, common, trace[i].Header.Height)
  
        if result != ResultSuccess {
            // something went wrong; peer did not provide a verifiable block
            return (nil, nil, nil, FaultyPeer)
        }
        else {
            if auxLS.LatestVerified().Header != trace[i].Header {
                // the header reported by the peer differs from the
                // reference header in trace but both could be
                // verified from common in one step.
                // we can create evidence for submission to the secondary
                ev := new InternalEvidence;
                ev.Evidence.ConflictingBlock := trace[i];
                // CommonHeight is used to indicate the type of attack
                // if the CommonHeight != ConflictingBlock.Height this 
                // is by definition a lunatic attack else it is an
                // equivocation attack
                ev.Evidence.CommonHeight := common.Height;
                ev.Peer := peer
                return (ev, common, auxLS, FoundEvidence)
            }
            else {
                // the peer agrees with the trace, we move common forward.
                // we could delete auxLS as it will be overwritten in
                // the next iteration
                common := trace[i]
            }
        }
    }
    return (nil, nil, nil, NoEvidence)
}
  • Expected precondition
    • root and trace are a verification trace
  • Expected postcondition
    • finds evidence where trace and peer diverge
  • Error condition
    • ErrorTrustExpired: fails if root expires (outside trusting period) [LCV-INV-TP.1]
    • If VerifyToTarget returns error but root is not expired then return FaultyPeer

Correctness arguments

On the existence of evidence

Proposition. In the case of attack, evidence [TMBC-LC-ATTACK-EVIDENCE.1] exists.
Proof. First observe that

  • (A). (NOT E2(i)) implies E1(i+1)

Now by contradiction assume there is no evidence. Thus

  • for all i, we have NOT E1(i) or NOT E2(i)
  • for i = 1 we have E1(1) and thus NOT E2(1) thus by induction on i, by (A) we have for all i that E1(i)
  • from attack we have E2(h-1), and as there is no evidence for i = h - 1 we get NOT E1(h-1). Contradiction. QED.

Argument for [LCD-DIST-INV-ATTACK.1]

Under the assumption that root and trace are a verification trace, when in CreateEvidenceForPeer the detector creates evidence, then the lightclient has seen two different headers (one via trace and one via VerifyToTarget) for the same height that can both be verified in one step.

Argument for [LCD-DIST-INV-STORE.1]

We assume that there is at least one correct peer, and there is no fork. As a result, the correct peer has the correct sequence of blocks. Since the primary_trace is checked block-by-block also against each secondary, and at no point evidence was generated that means at no point there were conflicting blocks.

Argument for [LCD-DIST-LIVE.1]

At the latest when [LCV-INV-TP.1] is violated, AttackDetector terminates.

Argument for [LCD-DIST-TERM-NORMAL.1]

As there are finitely many peers, eventually the main loop terminates. As there is no attack no evidence can be generated.

Argument for [LCD-DIST-TERM-ATTACK.1]

Argument similar to [LCD-DIST-TERM-NORMAL.1]

Argument for [LCD-DIST-SAFE-SECONDARY.1]

Secondaries are only replaced if they time-out or if they report bogus blocks. The former is ruled out by the timing assumption, the latter by correct peers only reporting blocks from the chain.

Argument for [LCD-DIST-SAFE-BOGUS.1]

Once a bogus block is recognized as such the secondary is removed.

References

links to other specifications/ADRs this document refers to

[verification] The specification of the light client verification.

[supervisor] The specification of the light client supervisor.