Skip to content

Commit 9bcc13c

Browse files
Upgrade validator (#184)
Upgrade validator
1 parent 124a97b commit 9bcc13c

File tree

15 files changed

+842
-1125
lines changed

15 files changed

+842
-1125
lines changed

consensus/tests/engine_v2_tests/api_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestGetMissedRoundsInEpochByBlockNum(t *testing.T) {
6666
startingBlockNum := currentBlock.Number().Int64() + 1
6767
// Skipped the round
6868
roundNumber := startingBlockNum + 2
69-
block := CreateBlock(blockchain, chainConfig, currentBlock, int(startingBlockNum), roundNumber, blockCoinBase, signer, signFn, nil, nil, "c2bf7b59be5184fc1148be5db14692b2dc89a1b345895d3e8d0ee7b8a7607450")
69+
block := CreateBlock(blockchain, chainConfig, currentBlock, int(startingBlockNum), roundNumber, blockCoinBase, signer, signFn, nil, nil, "25cb20ed8e7f21934d832318bc912e99e8745b4b3018e65d30bafc565df19c3a")
7070
err := blockchain.InsertBlock(block)
7171
if err != nil {
7272
t.Fatal(err)

consensus/tests/engine_v2_tests/helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ func PrepareXDCTestBlockChainWith128Candidates(t *testing.T, numOfBlocks int, ch
559559
blockCoinBase = signer.Hex()
560560
}
561561
roundNumber := int64(i) - chainConfig.XDPoS.V2.SwitchBlock.Int64()
562-
block := CreateBlock(blockchain, chainConfig, currentBlock, i, roundNumber, blockCoinBase, signer, signFn, nil, nil, "c2bf7b59be5184fc1148be5db14692b2dc89a1b345895d3e8d0ee7b8a7607450")
562+
block := CreateBlock(blockchain, chainConfig, currentBlock, i, roundNumber, blockCoinBase, signer, signFn, nil, nil, "25cb20ed8e7f21934d832318bc912e99e8745b4b3018e65d30bafc565df19c3a")
563563
err = blockchain.InsertBlock(block)
564564
if err != nil {
565565
t.Fatal(err)
@@ -614,7 +614,7 @@ func PrepareQCandProcess(t *testing.T, blockchain *BlockChain, currentBlock *typ
614614
func CreateBlock(blockchain *BlockChain, chainConfig *params.ChainConfig, startingBlock *types.Block, blockNumber int, roundNumber int64, blockCoinBase string, signer common.Address, signFn func(account accounts.Account, hash []byte) ([]byte, error), penalties []common.Address, signersKey []*ecdsa.PrivateKey, merkleRoot string) *types.Block {
615615
currentBlock := startingBlock
616616
if len(merkleRoot) == 0 {
617-
merkleRoot = "711be05c0b9d89bd511dd4c20ade1820b2c1fb13343ee0cedd3869150eb2d377"
617+
merkleRoot = "c778a53427689109ddaedda8c5271caaf622da65dfbb1b38b47561d4b0c94ac3"
618618
}
619619
var header *types.Header
620620
statedb, err := blockchain.State()

consensus/tests/engine_v2_tests/mine_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestYourTurnInitialV2(t *testing.T) {
2828
t.Logf("Inserting block with propose at 11...")
2929
blockCoinbaseA := "0xaaa0000000000000000000000000000000000011"
3030
//Get from block validator error message
31-
merkleRoot := "711be05c0b9d89bd511dd4c20ade1820b2c1fb13343ee0cedd3869150eb2d377"
31+
merkleRoot := "c778a53427689109ddaedda8c5271caaf622da65dfbb1b38b47561d4b0c94ac3"
3232
extraInBytes := generateV2Extra(11, parentBlock, signer, signFn, nil)
3333

3434
header := &types.Header{
@@ -79,7 +79,7 @@ func TestShouldMineOncePerRound(t *testing.T) {
7979
_, err := adaptor.Seal(blockchain, block910, nil)
8080
assert.Nil(t, err)
8181
time.Sleep(time.Duration(minePeriod) * time.Second)
82-
merkleRoot := "711be05c0b9d89bd511dd4c20ade1820b2c1fb13343ee0cedd3869150eb2d377"
82+
merkleRoot := "c778a53427689109ddaedda8c5271caaf622da65dfbb1b38b47561d4b0c94ac3"
8383

8484
header := &types.Header{
8585
Root: common.HexToHash(merkleRoot),
@@ -128,7 +128,7 @@ func TestUpdateMasterNodes(t *testing.T) {
128128
t.Fatal(err)
129129
}
130130
//Get from block validator error message
131-
merkleRoot := "2f34d88e4afb95a51b5dd3b157bdec944790c033bbf6e990cc7f946ad07d47c4"
131+
merkleRoot := "41ad5ea0d4c46f36548b27a946fe51e3cefd4d8567cb5c3398ebb570f99d9ee3"
132132
header := &types.Header{
133133
Root: common.HexToHash(merkleRoot),
134134
Number: big.NewInt(int64(1350)),
@@ -270,7 +270,7 @@ func TestUpdateMultipleMasterNodes(t *testing.T) {
270270
t.Logf("Inserting block with propose at 1350...")
271271
blockCoinbaseA := "0xaaa0000000000000000000000000000000001350"
272272
//Get from block validator error message
273-
merkleRoot := "c2bf7b59be5184fc1148be5db14692b2dc89a1b345895d3e8d0ee7b8a7607450"
273+
merkleRoot := "25cb20ed8e7f21934d832318bc912e99e8745b4b3018e65d30bafc565df19c3a"
274274
parentBlock := CreateBlock(blockchain, config, currentBlock, 1350, 450, blockCoinbaseA, signer, signFn, nil, nil, merkleRoot)
275275
err := blockchain.InsertBlock(parentBlock)
276276
assert.Nil(t, err)

consensus/tests/engine_v2_tests/penalty_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestHookPenaltyV2TwoEpoch(t *testing.T) {
3838
header1335 := blockchain.GetHeaderByNumber(config.XDPoS.Epoch + config.XDPoS.Gap - uint64(common.MergeSignRange))
3939
tx, err := signingTxWithKey(header1335, 0, voterKey)
4040
assert.Nil(t, err)
41-
block1349 := CreateBlock(blockchain, conf, block1348, 1349, 1358, signer.Hex(), signer, signFn, nil, nil, "c2bf7b59be5184fc1148be5db14692b2dc89a1b345895d3e8d0ee7b8a7607450")
41+
block1349 := CreateBlock(blockchain, conf, block1348, 1349, 1358, signer.Hex(), signer, signFn, nil, nil, "25cb20ed8e7f21934d832318bc912e99e8745b4b3018e65d30bafc565df19c3a")
4242
err = blockchain.InsertBlock(block1349)
4343
assert.Nil(t, err)
4444
adaptor.CacheSigningTxs(block1349.Hash(), []*types.Transaction{tx})

consensus/tests/engine_v2_tests/verify_header_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestShouldVerifyBlock(t *testing.T) {
7878
err = adaptor.VerifyHeader(blockchain, invalidPenaltiesExistBlock, true)
7979
assert.Equal(t, utils.ErrInvalidFieldInNonGapPlusOneSwitch, err)
8080

81-
merkleRoot := "711be05c0b9d89bd511dd4c20ade1820b2c1fb13343ee0cedd3869150eb2d377"
81+
merkleRoot := "c778a53427689109ddaedda8c5271caaf622da65dfbb1b38b47561d4b0c94ac3"
8282
parentNotExistBlock := blockchain.GetBlockByNumber(901).Header()
8383
parentNotExistBlock.ParentHash = common.HexToHash(merkleRoot)
8484
err = adaptor.VerifyHeader(blockchain, parentNotExistBlock, true)

contracts/validator/contract/validator.go

Lines changed: 159 additions & 108 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/validator/src/.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ cache/
33
artifacts/
44
node_modules/
55
.vscode/
6+
7+
yarn.lock
8+
9+
abi
610
abigen
7-
yarn.lock
11+
bytecode

contracts/validator/src/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ node scripts/deployToGenesis.js
3838
./abigen --abi abi --bin bytecode --pkg contract --type XDCValidator --out ../contract/validator.go
3939
```
4040

41-
If you don't have `abigen`, compile it. It's in `cmd/abigen/main.go` in XDC main repo (or Geth repo).
41+
If you don't have `abigen`, compile it. It's in `cmd/abigen/main.go` in XDC main repo (or Geth repo). and run `go build`
4242

4343
3. Go `../contract/validator.go` change `github.com/ethereum/go-ethereum` to `ethereum "github.com/XinFinOrg/XDC-Subnet"`
4444

0 commit comments

Comments
 (0)