Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BEP-126: Introduce Fast Finality Mechanism #936

Merged
merged 221 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
221 commits
Select commit Hold shift + click to select a range
878e602
[WIP]p2p protocol implement of fast finality
pythonberg1997 Feb 25, 2022
678ad21
vote broadcast
pythonberg1997 Feb 28, 2022
eeb6afb
vote broadcast
pythonberg1997 Feb 28, 2022
af3bed7
Fix review comments
pythonberg1997 Mar 1, 2022
f201365
Update vote broadcast routine
pythonberg1997 Mar 2, 2022
2dd4067
Update vote broadcast routine
pythonberg1997 Mar 3, 2022
8621182
Update vote broadcast routine
pythonberg1997 Mar 3, 2022
cbfad2b
Fix issue related votes broadcast
pythonberg1997 Mar 8, 2022
ed36f05
[R4R]Fast Finality: add bls account commands (#9)
NashBC Mar 8, 2022
a512633
add vote attestation to header (#10)
NashBC Mar 8, 2022
67b0aa8
[WIP]Fast Finality: reward distribution
pythonberg1997 Mar 1, 2022
a84f410
Some updates
pythonberg1997 Mar 2, 2022
43afdec
Some updates
pythonberg1997 Mar 3, 2022
c2fb5e2
Some updates
pythonberg1997 Mar 3, 2022
501070a
Correct data length of signature in precompiled contract
pythonberg1997 Mar 8, 2022
2d758ff
Implement finality reward distribution
pythonberg1997 Mar 9, 2022
d7238be
Minor errors fixed
pythonberg1997 Mar 14, 2022
3cee9cc
Minor errors fixed
pythonberg1997 Mar 14, 2022
4ecd1c9
Handle nil header issue
pythonberg1997 Mar 15, 2022
07a17fb
Handle nil header issue
pythonberg1997 Mar 15, 2022
304a3f9
Fix comment issues
pythonberg1997 Mar 15, 2022
f2a82e2
journal
calmbeing Feb 20, 2022
1094e27
vote manager
calmbeing Feb 22, 2022
24df294
update
calmbeing Feb 24, 2022
da0dfbf
Addressed comments from walt
calmbeing Mar 1, 2022
709b359
update
calmbeing Mar 3, 2022
d955dc0
addressed comments
calmbeing Mar 9, 2022
1e7f2f4
update
calmbeing Mar 10, 2022
142d450
add unit test
calmbeing Mar 14, 2022
015099e
resolved all comments
calmbeing Mar 15, 2022
1086892
fix compile error
unclezoro Mar 16, 2022
f1507cb
[R4R] Prepare for integration phase1 (#14)
realuncle Mar 17, 2022
3191b13
integrate vote pool related components into eth backend (#13)
calmbeing Mar 17, 2022
2e99878
Minor issues fixed
pythonberg1997 Mar 17, 2022
5293f37
Minor issues fixed
pythonberg1997 Mar 17, 2022
35ccef9
revert trimspace password
Mar 18, 2022
58bba9f
fix validator map issue
Mar 18, 2022
3a7a440
Update for integration
pythonberg1997 Mar 18, 2022
949f1f1
Update for integration
pythonberg1997 Mar 18, 2022
70d0335
add some logs for vote parts
Mar 21, 2022
3ff4d02
Change votesCh to voteCh and fix some typos
pythonberg1997 Mar 21, 2022
649405d
update the signal of startVote variable
Mar 21, 2022
183e1ef
Fix validator set verification errors
pythonberg1997 Mar 22, 2022
89bb539
update event type
Mar 22, 2022
60ddd42
Fix validator set verification errors
pythonberg1997 Mar 22, 2022
a09f8a0
Fix looking for peers error
pythonberg1997 Mar 22, 2022
debc674
Fix looking for peers error
pythonberg1997 Mar 22, 2022
0b95a9f
add prometheus metrics for vote pool
Mar 24, 2022
cb692b4
Fix voteMsg issue
pythonberg1997 Mar 24, 2022
1015871
fix the bug of bls verify peers' vote
Mar 24, 2022
4a26de4
fix the diff between voteHash and voteDataHash
Mar 24, 2022
27530b9
update logs
Mar 24, 2022
b897917
Fix head extra's length issue
pythonberg1997 Mar 25, 2022
1111183
Fix finality reward issue
pythonberg1997 Mar 25, 2022
cca3bb0
Fix finality reward issue
pythonberg1997 Mar 25, 2022
30d8d68
fix the issue of transfer futureVotes
Mar 26, 2022
8a531d3
update blsPassWordDirFlag to fileFlag
Mar 28, 2022
a6349f5
update prometheus metrics of vote pool
Mar 28, 2022
3b5e80b
add prometheus metrics for vote manager
calmbeing Mar 28, 2022
fec3cde
add prometheus metrics for vote journal and vote signer
calmbeing Mar 28, 2022
88cb5e2
fix parentHash bug
calmbeing Mar 29, 2022
80946cb
Fix validator out of index issue
pythonberg1997 Mar 30, 2022
c94d029
Update ETH68 UTs and finality reward code
pythonberg1997 Mar 31, 2022
cc50efc
change vote data struct
NashBC Mar 31, 2022
fc16513
[R4R]Update reward and slash parts for new fast finality mechanism (#21)
pythonberg1997 Apr 7, 2022
95d42e1
update vote parts based on new finality mechanism
calmbeing Apr 1, 2022
506f212
update
calmbeing Apr 2, 2022
0408079
fix comments
calmbeing Apr 6, 2022
7d95364
fix comments
calmbeing Apr 6, 2022
33b9797
update and add more unit tests
calmbeing Apr 7, 2022
ed90c8c
[R4R]Fast Finality: consensus part (#11)
NashBC Apr 8, 2022
bfa0614
changed log format
calmbeing Apr 8, 2022
6e137f6
fix panic (#24)
NashBC Apr 8, 2022
e1d77cf
Fix for loop issue of GetHighestFinalizedNumber
pythonberg1997 Apr 11, 2022
86ec0c5
move assemble attestation to finalize phase (#25)
NashBC Apr 12, 2022
44018e0
fix assemble vote attestation (#26)
NashBC Apr 12, 2022
00121e8
fix seal hash mismatch (#27)
NashBC Apr 12, 2022
59c5e48
remove TODO used for integration test before
calmbeing Apr 12, 2022
c8cce04
update logs
calmbeing Apr 13, 2022
bb596c1
fix transfer future votes logic
calmbeing Apr 13, 2022
5998963
update
calmbeing Apr 14, 2022
9900ab5
misc fix
NashBC Apr 21, 2022
48728e6
go.mod: upgrade to github.com/holiman/uint256 v1.2.0 (#22745)
holiman May 10, 2021
57d83e2
eth/protocols/snap: adapt to uint256 API changes (#22851)
fjl May 10, 2021
875e1ff
Add the check of whether nil votePool in handler
calmbeing Apr 21, 2022
b18da4e
fix panic
NashBC Apr 21, 2022
3444660
fix tests
NashBC Apr 21, 2022
06dac9b
Update UT of vote_pool (#5)
calmbeing Apr 24, 2022
cfa5d59
add parlia simulator
NashBC Apr 7, 2022
17edb19
comment console tests
NashBC Apr 24, 2022
ff0622b
Update contracts' ABI
pythonberg1997 Apr 25, 2022
87b77b5
Resolved comments
calmbeing Apr 26, 2022
cd5492d
Update for LynnFork (#7)
pythonberg1997 Apr 26, 2022
cb0b827
Fix first round final review PR comments
pythonberg1997 Apr 26, 2022
8718c7b
Fix wrong order of `distributeIncoming` and `distributeFinalityReward…
pythonberg1997 Apr 26, 2022
6309bbb
Remove rlphash
pythonberg1997 Apr 26, 2022
77e3e0e
resolved comments
calmbeing Apr 26, 2022
61a2813
fix comments (#11)
NashBC Apr 27, 2022
905fb8d
fix verify seal
NashBC Apr 29, 2022
308bb0b
Add subscribe new vote api
pythonberg1997 May 5, 2022
b27e424
Change vote hashes to votes
pythonberg1997 May 5, 2022
2941c87
Update system contracts' bytecode
pythonberg1997 May 6, 2022
1d497d3
Update test codes to pass CI jobs
pythonberg1997 May 6, 2022
cf58f83
Update test codes to pass CI jobs
pythonberg1997 May 6, 2022
4080a1f
export get highest justified or finalized block
NashBC May 5, 2022
b235667
add justified and finalized gauge
NashBC May 6, 2022
8ba2ab0
Fix error of applySystemContractUpgrade
pythonberg1997 May 7, 2022
9da3eae
Update genesis hash
pythonberg1997 May 7, 2022
4d08be1
fix sign recently
NashBC May 7, 2022
1519e91
fix abi unpack
NashBC May 9, 2022
7fccc24
update genesis hash
NashBC May 9, 2022
d75fbd5
Update Slash contract's abi
pythonberg1997 May 12, 2022
c538017
Update reward distribution logic
pythonberg1997 May 12, 2022
6cdaa92
Fix vote subscribe related issues
pythonberg1997 May 10, 2022
9c65be6
First round final review comments fixed
pythonberg1997 May 13, 2022
a43518c
Resolve final review comments
calmbeing May 13, 2022
282b0b3
Resolved comments from nash
calmbeing May 13, 2022
17326a1
minor update
calmbeing May 13, 2022
a61a40a
fix get finalized block in loop
NashBC May 13, 2022
8505054
fix comments
NashBC May 13, 2022
023fc17
Update genesis hash
calmbeing May 16, 2022
b462313
First round final review comments fixed
pythonberg1997 May 16, 2022
b61ea3e
Resolved comments
calmbeing May 16, 2022
b479494
Update
calmbeing May 16, 2022
582e609
Update
calmbeing May 17, 2022
c029c7f
Update to use lru for voteData buffer
calmbeing May 17, 2022
18d8adb
Add subscribe finalized header API
pythonberg1997 May 17, 2022
daafa45
Fix nil pointer issue
pythonberg1997 May 17, 2022
8c7551a
Minor update
calmbeing May 17, 2022
eeb0838
Deleted unnecessary func
calmbeing May 18, 2022
82e6d2a
Fix wrong type event issue
pythonberg1997 May 18, 2022
b7cb370
Update error returns
calmbeing May 18, 2022
271269c
Update
calmbeing May 18, 2022
6a17f37
Fix abi unmarshal failed issue
pythonberg1997 May 18, 2022
1156b85
Update logic to check nil interface
calmbeing May 18, 2022
45a8abe
Update handler
calmbeing May 19, 2022
e6d0ca6
Typo fixed
calmbeing May 19, 2022
4410a49
update
calmbeing May 19, 2022
20cc49f
update
calmbeing May 19, 2022
01c5702
Update BSCValidatorSet contract's abi
pythonberg1997 May 19, 2022
249c737
Fix rebase error
calmbeing May 20, 2022
bf7c07e
Update system contracts upgrade
pythonberg1997 May 20, 2022
cdeca70
Minor update after rebase on newest develop branch
calmbeing May 20, 2022
bf6b7f2
fix get justified header
NashBC May 18, 2022
5ae6d15
fix get finalized header
NashBC May 18, 2022
0e2c168
fix comments
NashBC May 20, 2022
e5abbed
Update system contracts' code
pythonberg1997 May 20, 2022
66459e5
fix the backoff time after boneh fork
NashBC May 26, 2022
b01ae3b
fix backoff time
NashBC May 27, 2022
01ec078
no initial delay for the first candidate validator
NashBC May 27, 2022
5ff2f1f
Add more debug logs for voteManager
calmbeing Jun 6, 2022
bd5e869
Fix startVote logic in voteManager
calmbeing Jun 8, 2022
c4d66b2
update
calmbeing Jun 8, 2022
dceab93
Merge pull request #32 from calmbeing/vote_part
calmbeing Jun 8, 2022
5ea41fd
Update precompile contracts set
pythonberg1997 Jun 9, 2022
c542b5c
Update system contracts' code
pythonberg1997 Jun 17, 2022
d854f73
Merge remote-tracking branch 'BNBChain/develop' into fast_finality
pythonberg1997 Aug 10, 2022
8eb1e7e
Fix merge conflicts
pythonberg1997 Aug 10, 2022
0e5a22a
Fix lint errors
pythonberg1997 Aug 10, 2022
c11d83b
Fix some audit comments
pythonberg1997 Jul 27, 2022
3c8981d
Minor updates
pythonberg1997 Jul 28, 2022
cdad474
Merge pull request #35 from Loverush/fast_finality
pythonberg1997 Aug 10, 2022
74efd80
Update Boneh fork's system contracts
pythonberg1997 Aug 15, 2022
c7ce054
Merge remote-tracking branch 'nodereal/fast_finality' into fast_finality
pythonberg1997 Aug 15, 2022
ee08803
change boneh fork liveness (#33)
NashBC Jan 10, 2023
6634a11
core: fix several bugs (#36)
NashBC Jan 11, 2023
df6fb5c
change naturallyJustifiedDist to keep consistency with vote quorum
buddh0 Jan 12, 2023
23d52c5
core: make explicit rules for reorganization even when conflicting bl…
buddh0 Jan 12, 2023
ad17b34
Merge remote-tracking branch 'upstream/master' into merge_fast_finality
NashBC Jan 12, 2023
dc9b8f9
Merge pull request #41 from NashBC/merge_fast_finality
realuncle Jan 12, 2023
4b59b9b
Merge pull request #42 from node-real/Nathan/fast_finality_bugfix
NathanBSC Jan 13, 2023
4bbad93
feat: update bls verification precompile contract (#45)
pythonberg1997 Jan 17, 2023
bba1be0
separate vote message as a standlone p2p protocol
NathanBSC Jan 11, 2023
0af0078
Merge pull request #46 from node-real/Nathan/fast_finality_p2p_separate
NathanBSC Feb 2, 2023
1978940
more rational gas and avoid running out of gas for blsSignatureVerify
NathanBSC Feb 20, 2023
43accd4
Merge pull request #49 from node-real/Nathan/fix_gas_blsSignatureVerify
NathanBSC Feb 20, 2023
1627f7e
improved boundary handling and related annotations in core/vote
NathanBSC Feb 21, 2023
c21a1a9
Merge pull request #50 from node-real/fast_finality_core_vote_review
NathanBSC Feb 21, 2023
a60dbbd
fix a bug about fetching snapshot of consensus when verifyVoteAttesta…
NathanBSC Feb 23, 2023
e6e1b68
Merge pull request #52 from node-real/get_snapshot_fail_verifyVoteAtt…
NathanBSC Feb 24, 2023
e7db16b
improve some codes in core/vote and consensus (#57)
NathanBSC Mar 1, 2023
cab13f2
upgrade: update system contracts' code of QA
pythonberg1997 Mar 8, 2023
a622aae
imporve liveness of block proposal layer
NathanBSC Mar 8, 2023
16c912a
Merge pull request #59 from node-real/improve-block-proposer-layer-li…
NathanBSC Mar 8, 2023
6a55acd
modify fork choice to prefer higher justified block number
NathanBSC Mar 3, 2023
c9a9990
Merge pull request #58 from node-real/modify_fork_choice
NathanBSC Mar 10, 2023
e60676d
fix BroadcastVote when GetTd, may lead to panic
NathanBSC Mar 13, 2023
7ef05f4
Merge pull request #62 from node-real/panic_when_GetTd
NathanBSC Mar 13, 2023
e8b33d9
improve code of bsc p2p protocol
NathanBSC Mar 9, 2023
53254e8
Merge pull request #60 from node-real/improve-bsc-p2p-protocol
NathanBSC Mar 13, 2023
8ed8a5a
fix mini bug for markVotes
NathanBSC Mar 14, 2023
812674f
Merge pull request #63 from node-real/fix_mini_bug_for_markVotes
NathanBSC Mar 15, 2023
b954496
modify func visibility in ForkChoice
NathanBSC Mar 14, 2023
41ed6c2
fix vote attestation security flaw and enable new fork choice rule af…
NathanBSC Mar 16, 2023
e7f452b
Merge pull request #65 from node-real/vote_attestation_security_flaw
NathanBSC Mar 16, 2023
8e76145
update depended version of btcd to v2.3.2 from v0.2x
buddh0 Mar 24, 2023
8851f52
Merge pull request #67 from node-real/update_prysm_version
NathanBSC Mar 28, 2023
0b61bee
Merge branch 'develop' into fast_finality
NathanBSC Mar 29, 2023
a97c9b8
Merge pull request #71 from node-real/merge_develop_into_fast_finality
NathanBSC Mar 29, 2023
5b863e4
enhance GetBlockByNumber by supporting 'safe' and 'finalized', follow…
NathanBSC Mar 28, 2023
10b7d98
Merge pull request #70 from node-real/GetBlockByNumber_finalized_safe
NathanBSC Mar 29, 2023
7e4a142
upgrade: update BonehUpgrade contracts code
pythonberg1997 Mar 29, 2023
96ddb5b
Merge pull request #72 from Pythonberg1997/fast_finality_dev
pythonberg1997 Mar 29, 2023
73167bd
fix UT in vote_pool_test
NathanBSC Mar 29, 2023
1a3b98e
use iavlMerkleProofValidatePlanck in PrecompiledContractsBoneh
NathanBSC Mar 29, 2023
65566ac
go.mod: upgrade to latest goja,following Geth
NathanBSC Mar 30, 2023
4f7fa5a
fix misspell: carefull t careful
NathanBSC Mar 30, 2023
c05b1dc
recover integration-test
NathanBSC Mar 30, 2023
85259a2
recover integration-test, partII
NathanBSC Mar 30, 2023
b123f68
recover integration-test, partIII
NathanBSC Mar 30, 2023
499b226
recover integration-test, finaly
NathanBSC Mar 30, 2023
0b23178
fix integration-test, finaly...
NathanBSC Mar 30, 2023
270a7ab
Fast finality abi and code style (#77)
NathanBSC Apr 4, 2023
d173cbf
improve log style when Verify vote attestation fail (#78)
NathanBSC Apr 4, 2023
fba030c
distribute additional reward for collecting more votes than needed
NathanBSC Apr 4, 2023
6f79937
Merge pull request #79 from node-real/addtional-reward-for-collecting…
NathanBSC Apr 4, 2023
032dd84
upgrade: update BonehUpgrade contracts code
pythonberg1997 Apr 7, 2023
6623499
fix: update boneh upgrade code for rialto
NathanBSC Apr 8, 2023
4b1fb61
fix: update boneh upgrade code for rialto
NathanBSC Apr 10, 2023
9f74997
Merge branch 'develop' into fast_finality
NathanBSC Apr 10, 2023
6bf2516
add flag to make blst portable
NathanBSC Apr 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ profile.cov
**/yarn-error.log
cmd/geth/node/
cmd/geth/__debug_bin
cmd/bootnode/bootnode
graphql/__debug_bin
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ ARG BUILDNUM=""
# Build Geth in a stock Go builder container
FROM golang:1.19-alpine as builder

RUN apk add --no-cache make gcc musl-dev linux-headers git bash
RUN apk add --no-cache make cmake gcc musl-dev linux-headers git bash build-base libc-dev
# Get dependencies - will also be cached if we won't change go.mod/go.sum
COPY go.mod /go-ethereum/
COPY go.sum /go-ethereum/
RUN cd /go-ethereum && go mod download

ADD . /go-ethereum
ENV CGO_CFLAGS="-O -D__BLST_PORTABLE__"
ENV CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__"
RUN cd /go-ethereum && go run build/ci.go install ./cmd/geth

# Pull Geth into a second stage deploy alpine container
Expand All @@ -26,9 +28,10 @@ ENV BSC_HOME=/bsc
ENV HOME=${BSC_HOME}
ENV DATA_DIR=/data

ARG VERSION_GCC=11.2.1_git20220219-r2
ENV PACKAGES ca-certificates jq \
bash bind-tools tini \
grep curl sed
grep curl sed gcc==${VERSION_GCC}

RUN apk add --no-cache $PACKAGES \
&& rm -rf /var/cache/apk/* \
Expand Down Expand Up @@ -56,4 +59,4 @@ USER ${BSC_USER_UID}:${BSC_USER_GID}
# rpc ws graphql
EXPOSE 8545 8546 8547 30303 30303/udp

ENTRYPOINT ["/sbin/tini", "--", "./docker-entrypoint.sh"]
ENTRYPOINT ["/sbin/tini", "--", "./docker-entrypoint.sh"]
25 changes: 22 additions & 3 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,11 +826,22 @@ type filterBackend struct {
func (fb *filterBackend) ChainDb() ethdb.Database { return fb.db }
func (fb *filterBackend) EventMux() *event.TypeMux { panic("not supported") }

func (fb *filterBackend) HeaderByNumber(ctx context.Context, block rpc.BlockNumber) (*types.Header, error) {
if block == rpc.LatestBlockNumber {
func (fb *filterBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) {
switch number {
case rpc.PendingBlockNumber:
if block := fb.backend.pendingBlock; block != nil {
return block.Header(), nil
}
return nil, nil
case rpc.LatestBlockNumber:
return fb.bc.CurrentHeader(), nil
case rpc.FinalizedBlockNumber:
return fb.bc.CurrentFinalBlock(), nil
case rpc.SafeBlockNumber:
return fb.bc.CurrentSafeBlock(), nil
default:
return fb.bc.GetHeaderByNumber(uint64(number.Int64())), nil
}
return fb.bc.GetHeaderByNumber(uint64(block.Int64())), nil
}

func (fb *filterBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
Expand Down Expand Up @@ -869,10 +880,18 @@ func (fb *filterBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.
return nullSubscription()
}

func (fb *filterBackend) SubscribeNewVoteEvent(ch chan<- core.NewVoteEvent) event.Subscription {
return nullSubscription()
}

func (fb *filterBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription {
return fb.bc.SubscribeChainEvent(ch)
}

func (fb *filterBackend) SubscribeFinalizedHeaderEvent(ch chan<- core.FinalizedHeaderEvent) event.Subscription {
return fb.bc.SubscribeFinalizedHeaderEvent(ch)
}

func (fb *filterBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription {
return fb.bc.SubscribeRemovedLogsEvent(ch)
}
Expand Down
18 changes: 18 additions & 0 deletions beacon/engine/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2022 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

// just for prysm compile pass
package engine
Loading