Commit graph

72 commits

Author SHA1 Message Date
Liam Lai
69c38ac490 fix broken the tests and one bug 2023-08-02 09:27:46 +10:00
wgr523
d578e092cd
stop reorg at committed blocks (#276)
This PR makes committed blocks non-reorg-able inside `Blockchain` struct. This ensures V2 consensus safety property in the aspect of blockchain head: committed blocks' state will not be reorg and users will always see committed blocks (or their child blocks) as current head of the blockchain.

* stop reorg at committed blocks

* fix tests

* fix tests
2023-06-08 01:16:13 +08:00
Liam
2df16bbd37
merge waitPeriod into minePeriod (#274)
* merge waitperiod into mindePeriod

* merge waitperiod into mindePeriod
2023-05-31 23:40:50 +10:00
wgr523
cd74061ac2
Extend masternode candidate (#261)
* V2 truncate MaxMasternodes from candidates after penalty,
V1 same as before

TestUpdateMultipleMasterNodes: test V2, in snapshot we have all candidates, but at epoch switch, we pick MaxMasternodes

* code looks better
2023-05-16 21:43:56 +08:00
Liam
153f8d296d
Fix API penalty bug and add more info in api (#262)
* fix api bug

* remove cmd
2023-05-16 21:23:02 +10:00
Liam
7b657f0c4e
API: getMasternode and getPoolStatus (#258)
* API: getMasternode and getPoolStatus

* fix test
2023-05-01 23:01:39 +10:00
Liam Lai
65ffdcd0a9 fix test 2023-02-23 14:22:30 +08:00
Jerome
2ca1d0461d
Fix issue when resync is not getting the right consensus config values (#221)
* Fix issue when resync is not getting the right consensus config values

* add test and fix log bug

* fix test

* delete temp file

Co-authored-by: Liam Lai <liam.icheng.lai@gmail.com>
2023-01-17 21:34:42 +08:00
Liam
c4f9a552e5
Multi config bug fix (#216)
* refactor multi config
remove pool cleaner
correct message and log level
2022-12-17 20:23:46 +08:00
Liam
6ffbd3e141
Xin 259 support multi v2 config (#210)
* update timeout period and waittime

* remove wrong comment

* update config for preparing test
2022-12-06 20:08:56 +08:00
Liam
a75c315eb5
fix penalty calculation bug (#189) 2022-10-09 14:06:04 +08:00
Liam
2b3e059abf
xin-244 re-snyc blocks from v1 to v2 (#186)
* xin-244 re-snyc blocks from v1 to v2

* remove log

* correct log

* constant value

* remove comment
2022-10-04 23:33:13 +08:00
Jerome
c710bd98a5
Xin-200 Vote Equivocation (#111) (#172)
* Xin-200 Vote Equivocation (#111)

* add vote same round detection

add test for vote same round detect

finish process equivocate (not finish report)

* finish vote equivocation report, refactor code (vote -> forensics)

* finish process equivocate and report, and test

* add return err

Co-authored-by: wgr523 <wgr523@gmail.com>
2022-08-13 11:50:56 +05:30
Jerome
cfb5c6ce39
pass the forensics Id at root level (#107) 2022-07-05 22:01:36 +10:00
Jerome
533fe250db
forensics shall send unique id (#106) 2022-07-05 00:31:09 +02:00
Jerome
3ebaea1945
update forensics proof data structure to accomedate vote type (#104)
* update forensics proof data structure to accomedate vote type

* refactor log

* change blocknum type to uint64

* fix test

Co-authored-by: Liam Lai <liam.icheng.lai@gmail.com>
2022-06-29 23:58:18 +02:00
Liam
1cac82825d
xin-176 use local masternode to verify signature (#98)
* use local masternode to verify signature

* refactor verify header
2022-06-05 12:53:50 +02:00
Liam
50ae0c95fd
xin-197 xin-198 fix devnet issues (#99)
* xin-197 xin-198 fix devnet issues

* update log
2022-06-05 11:06:32 +02:00
Jerome
7effc71547
allow forensics send msg to stats server (#95)
* allow forensics send msg to stats server

* add test for forensics reporting mechanism
2022-05-25 19:42:30 +10:00
Liam
ca6a645fca
refactor and improve log (#92)
* refactor and improve log

* fix conflict and test
2022-05-23 02:34:32 +01:00
Liam
882add50f5
bug fix for snapshot failed to load from db (#91) 2022-05-22 19:15:25 -05:00
Jerome
455cacc1b7
move XDC consensus types into core (#93) 2022-05-22 11:43:25 +10:00
Liam
5fffa0cd43
xin-188 update penalty limit epoch constant for v2 and shorter test (#87) 2022-05-18 11:17:32 -04:00
Jerome
2f40b63ca8
Re-define the forensics report format and complete the internal forensics logic (#90) 2022-05-16 17:30:45 +10:00
Jerome
ba144d898f
process forensics (#84)
* process forensics

* Found common signers at same round for forensics

* find attackers

* add test for forensics

* run setCommittedQCs after processForensics
2022-05-03 21:18:28 +10:00
Liam
98621f0993
Merge branch 'dev-upgrade' into xin-176 2022-05-02 21:55:12 -06:00
wgr523
49cecaa9af
XIN-176 fix (#85)
* fix bug in isEpochSwitchAtRound, fix penalty test TestHookPenaltyV2Mining

* fix authorised test

* fix things

* revert a test
2022-05-02 22:46:55 -05:00
Jerome
eb35d4e32e
Add set committed QC function in forensics (#83) 2022-04-23 10:33:56 +10:00
Jerome
6c48d5be6c
Xin 181 178 (#80)
* add skeleton forensics

* remove duplicated penalty check in verify header
2022-04-10 09:40:32 +10:00
Liam
92857e50e5
xin-177 check penalty only on epoch switch block and Add Hook on initial (#78)
* check penalty only on epoch switch block

* skip calculate penalty on first v2 block

* clean code, its doing same thing
2022-04-02 22:59:39 -06:00
Jerome
0ded664f0c
add highestSelfMinedRound to make sure we mine once per round (#79) 2022-04-03 12:45:25 +10:00
Jerome
0241d40699
verify headers shall use parent block if not present in the chain (#77) 2022-04-01 00:11:04 -06:00
Jerome
cb67e8e26a
Xin 163 (#76)
* clean up the pool old round

* add unit test to cover the vote key format

* add gapNumber to the vote pool key

* fix race condition in pool

* remove verify gap number in vote handler
2022-04-01 14:59:16 +11:00
Jerome
b98005a8dd
Xin 166 (#75)
* typo and checkYourturnWithinFinalisedMasternodes func name to yourturn

* remove redundant code from verifyQC

* Verify QC to optionally pass parent header. This is used to help verifyHeaders

* move difficulty into its own file
2022-03-27 20:39:40 +11:00
wgr523
b790b077c9
XIN-164 add GapNumber inside Vote, and tests (#74) 2022-03-25 23:22:24 +08:00
Jerome
ee025383c1
check yourturn again during prepare (#72) 2022-03-25 21:03:37 +11:00
Jerome
d55229677d
verify header including validator (#71)
* verify header including validator

* re-structure v1 v2 tests

* remove unused test function

* add test to check coinbase and validator address matches

* refactor engine v2 to group private functions into same file
2022-03-20 21:14:35 +11:00
Jerome
9bb1a6e1b3
XIN-159, 160 and 161 (#69)
* XIN-159, 160 and 161

* update the bft handler to make sure we don't process dis-qualified messages

* add verify header missing checks and its tests
2022-03-13 22:00:26 +11:00
Liam
a4b362ae9a
Xin 147 initial for both first v2 block and further, also introduce getExtraField function (#64)
* refactor initial and introduce getExtraField function

* add test for initial

* refactor snapshot

* initial first snapshot only
2022-03-08 20:34:11 +01:00
Jerome
8363641b2c
check against master node list before sending out anything (#67)
* check against master node list before sending out anything

* remove duplicated signatures from QC

* add break when checking allowed to send
2022-03-08 09:12:52 +11:00
Jerome
6090b7f02e
XIN-154 fix verify header bug on Validators (#66) 2022-03-07 18:53:55 +08:00
Liam
d975ba4014
xin-153 Broadcast syncInfo when consecutive timeouts of same round (#65)
* Broadcast syncInfo when consecutive timeouts of same round

* add test

* revert test period
2022-03-05 01:52:20 +01:00
Jerome
e493ddfd6d
add verifyTC and verifyTimeoutMessage (#63)
* add verifyTC and verifyTimeoutMessage

* remove v2 func from adaptor
2022-03-02 09:17:57 +11:00
Jerome
d773e15ca8
Xin 137 (#62)
* add GapNumber

* fix broken countdown test

* add gapNumber to existing tests
2022-02-28 18:51:42 +11:00
Jerome
97985fda85
move verify QC into verify header, fix broken tests etc (#61) 2022-02-27 10:25:26 +11:00
Jerome
431c870fa0
verify vote (#50)
* verify vote

* fix vote tests and add temporary solution for initialize

* remove the drop peer comment
2022-02-26 17:42:08 +11:00
Liam
0ab7bfbcbd
Merge pull request #58 from hash-laboratories-au/XIN-125-happy-path-fix
Xin 125 happy path fix
2022-02-21 02:51:48 +03:00
Jianrong
c77a641638 add verify blockInfo function 2022-02-20 21:06:05 +11:00
Jianrong
cddeaf2db1 add v2 verify header 2022-02-19 19:36:32 +11:00
wgr523
89acbdd742
XIN-121 Reward hook (#57)
* v2 Hook Reward, need test

* test reward

* fix RewardHook due to modifying params config directly (#56)

* more test

* finish test

Co-authored-by: Jerome <wjrjerome@gmail.com>
2022-02-19 15:31:19 +11:00