mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-14 16:03:45 +00:00
Merge branch 'arpit/pos-655' of github.com:maticnetwork/bor into shivam/POS-972
This commit is contained in:
commit
4642045a4c
6 changed files with 53 additions and 30 deletions
5
.github/matic-cli-config.yml
vendored
5
.github/matic-cli-config.yml
vendored
|
|
@ -2,8 +2,9 @@ defaultStake: 10000
|
||||||
defaultFee: 2000
|
defaultFee: 2000
|
||||||
borChainId: "15001"
|
borChainId: "15001"
|
||||||
heimdallChainId: heimdall-15001
|
heimdallChainId: heimdall-15001
|
||||||
contractsBranch: arpit/v0.3.2-backport
|
contractsBranch: mardizzone/node-upgrade
|
||||||
sprintSize: 64
|
sprintSize: '64'
|
||||||
|
sprintSizeBlockNumber: '0'
|
||||||
blockNumber: '0'
|
blockNumber: '0'
|
||||||
blockTime: '2'
|
blockTime: '2'
|
||||||
numOfValidators: 3
|
numOfValidators: 3
|
||||||
|
|
|
||||||
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
|
@ -104,7 +104,7 @@ jobs:
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
repository: maticnetwork/matic-cli
|
repository: maticnetwork/matic-cli
|
||||||
ref: mardizzone/revert
|
ref: arpit/pos-655
|
||||||
path: matic-cli
|
path: matic-cli
|
||||||
|
|
||||||
- name: Install dependencies on Linux
|
- name: Install dependencies on Linux
|
||||||
|
|
@ -119,7 +119,7 @@ jobs:
|
||||||
|
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '10.17.0'
|
node-version: '16.17.1'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
cache-dependency-path: |
|
cache-dependency-path: |
|
||||||
matic-cli/package-lock.json
|
matic-cli/package-lock.json
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,7 @@ func TestRemoteMultiNotify(t *testing.T) {
|
||||||
// Tests that pushing work packages fast to the miner doesn't cause any data race
|
// Tests that pushing work packages fast to the miner doesn't cause any data race
|
||||||
// issues in the notifications. Full pending block body / --miner.notify.full)
|
// issues in the notifications. Full pending block body / --miner.notify.full)
|
||||||
func TestRemoteMultiNotifyFull(t *testing.T) {
|
func TestRemoteMultiNotifyFull(t *testing.T) {
|
||||||
|
t.Skip()
|
||||||
|
|
||||||
// Start a simple web server to capture notifications.
|
// Start a simple web server to capture notifications.
|
||||||
sink := make(chan map[string]interface{}, 64)
|
sink := make(chan map[string]interface{}, 64)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 0 // Major version component of the current release
|
VersionMajor = 0 // Major version component of the current release
|
||||||
VersionMinor = 3 // Minor version component of the current release
|
VersionMinor = 3 // Minor version component of the current release
|
||||||
VersionPatch = 0 // Patch version component of the current release
|
VersionPatch = 1 // Patch version component of the current release
|
||||||
VersionMeta = "beta" // Version metadata to append to the version string
|
VersionMeta = "beta" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -43,7 +43,8 @@ var VersionWithMeta = func() string {
|
||||||
|
|
||||||
// ArchiveVersion holds the textual version string used for Geth archives.
|
// ArchiveVersion holds the textual version string used for Geth archives.
|
||||||
// e.g. "1.8.11-dea1ce05" for stable releases, or
|
// e.g. "1.8.11-dea1ce05" for stable releases, or
|
||||||
// "1.8.13-unstable-21c059b6" for unstable releases
|
//
|
||||||
|
// "1.8.13-unstable-21c059b6" for unstable releases
|
||||||
func ArchiveVersion(gitCommit string) string {
|
func ArchiveVersion(gitCommit string) string {
|
||||||
vsn := Version
|
vsn := Version
|
||||||
if VersionMeta != "stable" {
|
if VersionMeta != "stable" {
|
||||||
|
|
|
||||||
|
|
@ -34,17 +34,17 @@ import (
|
||||||
var (
|
var (
|
||||||
|
|
||||||
// Only this account is a validator for the 0th span
|
// Only this account is a validator for the 0th span
|
||||||
key, _ = crypto.HexToECDSA(privKey)
|
keySprintLength, _ = crypto.HexToECDSA(privKeySprintLength)
|
||||||
|
|
||||||
// This account is one the validators for 1st span (0-indexed)
|
// This account is one the validators for 1st span (0-indexed)
|
||||||
key2, _ = crypto.HexToECDSA(privKey2)
|
keySprintLength2, _ = crypto.HexToECDSA(privKeySprintLength2)
|
||||||
|
|
||||||
keys = []*ecdsa.PrivateKey{key, key2}
|
keysSprintLength = []*ecdsa.PrivateKey{keySprintLength, keySprintLength2}
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
privKey = "b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291"
|
privKeySprintLength = "b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291"
|
||||||
privKey2 = "9b28f36fbd67381120752d6172ecdcf10e06ab2d9a1367aac00cdcd6ac7855d3"
|
privKeySprintLength2 = "9b28f36fbd67381120752d6172ecdcf10e06ab2d9a1367aac00cdcd6ac7855d3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Sprint length change tests
|
// Sprint length change tests
|
||||||
|
|
@ -67,14 +67,14 @@ func TestValidatorsBlockProduction(t *testing.T) {
|
||||||
|
|
||||||
// Create an Ethash network based off of the Ropsten config
|
// Create an Ethash network based off of the Ropsten config
|
||||||
// Generate a batch of accounts to seal and fund with
|
// Generate a batch of accounts to seal and fund with
|
||||||
genesis := InitGenesis(t, faucets, "./testdata/genesis_sprint_length_change.json", 8)
|
genesis := InitGenesisSprintLength(t, faucets, "./testdata/genesis_sprint_length_change.json", 8)
|
||||||
|
|
||||||
nodes := make([]*eth.Ethereum, 2)
|
nodes := make([]*eth.Ethereum, 2)
|
||||||
enodes := make([]*enode.Node, 2)
|
enodes := make([]*enode.Node, 2)
|
||||||
|
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
// Start the node and wait until it's up
|
// Start the node and wait until it's up
|
||||||
stack, ethBackend, err := InitMiner(genesis, keys[i], true)
|
stack, ethBackend, err := InitMinerSprintLength(genesis, keysSprintLength[i], true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
@ -84,8 +84,10 @@ func TestValidatorsBlockProduction(t *testing.T) {
|
||||||
time.Sleep(250 * time.Millisecond)
|
time.Sleep(250 * time.Millisecond)
|
||||||
}
|
}
|
||||||
// Connect the node to all the previous ones
|
// Connect the node to all the previous ones
|
||||||
for _, n := range enodes {
|
for j, n := range enodes {
|
||||||
stack.Server().AddPeer(n)
|
if j < i {
|
||||||
|
stack.Server().AddPeer(n)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Start tracking the node and its enode
|
// Start tracking the node and its enode
|
||||||
nodes[i] = ethBackend
|
nodes[i] = ethBackend
|
||||||
|
|
@ -263,13 +265,13 @@ var keys_21val = []map[string]string{
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTestSprintLengthReorgCases2Nodes() []map[string]interface{} {
|
func getTestSprintLengthReorgCases2Nodes() []map[string]interface{} {
|
||||||
sprintSizes := []uint64{8, 16, 32, 64}
|
sprintSizes := []uint64{64}
|
||||||
faultyNodes := [][]uint64{{0, 1}, {1, 2}, {0, 2}}
|
faultyNodes := [][]uint64{{0, 1}, {1, 2}, {0, 2}}
|
||||||
reorgsLengthTests := make([]map[string]interface{}, 0)
|
reorgsLengthTests := make([]map[string]interface{}, 0)
|
||||||
|
|
||||||
for i := uint64(0); i < uint64(len(sprintSizes)); i++ {
|
for i := uint64(0); i < uint64(len(sprintSizes)); i++ {
|
||||||
maxReorgLength := sprintSizes[i] * 4
|
maxReorgLength := sprintSizes[i] * 4
|
||||||
for j := uint64(3); j <= maxReorgLength; j = j + 4 {
|
for j := uint64(20); j <= maxReorgLength; j = j + 8 {
|
||||||
maxStartBlock := sprintSizes[i] - 1
|
maxStartBlock := sprintSizes[i] - 1
|
||||||
for k := sprintSizes[i] / 2; k <= maxStartBlock; k = k + 4 {
|
for k := sprintSizes[i] / 2; k <= maxStartBlock; k = k + 4 {
|
||||||
for l := uint64(0); l < uint64(len(faultyNodes)); l++ {
|
for l := uint64(0); l < uint64(len(faultyNodes)); l++ {
|
||||||
|
|
@ -373,7 +375,7 @@ func SprintLengthReorgIndividual2Nodes(t *testing.T, index int, tt map[string]in
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSprintLengthReorg2Nodes(t *testing.T) {
|
func TestSprintLengthReorg2Nodes(t *testing.T) {
|
||||||
// t.Skip()
|
t.Skip()
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
log.Root().SetHandler(log.LvlFilterHandler(3, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
|
log.Root().SetHandler(log.LvlFilterHandler(3, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
|
||||||
|
|
@ -508,7 +510,7 @@ func SetupValidatorsAndTest(t *testing.T, tt map[string]uint64) (uint64, uint64)
|
||||||
|
|
||||||
// Create an Ethash network based off of the Ropsten config
|
// Create an Ethash network based off of the Ropsten config
|
||||||
// Generate a batch of accounts to seal and fund with
|
// Generate a batch of accounts to seal and fund with
|
||||||
genesis := InitGenesis(t, faucets, "./testdata/genesis_7val.json", tt["sprintSize"])
|
genesis := InitGenesisSprintLength(t, faucets, "./testdata/genesis_7val.json", tt["sprintSize"])
|
||||||
|
|
||||||
nodes := make([]*eth.Ethereum, len(keys_21val))
|
nodes := make([]*eth.Ethereum, len(keys_21val))
|
||||||
enodes := make([]*enode.Node, len(keys_21val))
|
enodes := make([]*enode.Node, len(keys_21val))
|
||||||
|
|
@ -522,7 +524,7 @@ func SetupValidatorsAndTest(t *testing.T, tt map[string]uint64) (uint64, uint64)
|
||||||
|
|
||||||
for i := 0; i < len(keys_21val); i++ {
|
for i := 0; i < len(keys_21val); i++ {
|
||||||
// Start the node and wait until it's up
|
// Start the node and wait until it's up
|
||||||
stack, ethBackend, err := InitMiner(genesis, pkeys_21val[i], true)
|
stack, ethBackend, err := InitMinerSprintLength(genesis, pkeys_21val[i], true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
@ -532,8 +534,10 @@ func SetupValidatorsAndTest(t *testing.T, tt map[string]uint64) (uint64, uint64)
|
||||||
time.Sleep(250 * time.Millisecond)
|
time.Sleep(250 * time.Millisecond)
|
||||||
}
|
}
|
||||||
// Connect the node to all the previous ones
|
// Connect the node to all the previous ones
|
||||||
for _, n := range enodes {
|
for j, n := range enodes {
|
||||||
stack.Server().AddPeer(n)
|
if j < i {
|
||||||
|
stack.Server().AddPeer(n)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Start tracking the node and its enode
|
// Start tracking the node and its enode
|
||||||
stacks[i] = stack
|
stacks[i] = stack
|
||||||
|
|
@ -642,7 +646,7 @@ func SetupValidatorsAndTest2Nodes(t *testing.T, tt map[string]interface{}) (uint
|
||||||
|
|
||||||
// Create an Ethash network based off of the Ropsten config
|
// Create an Ethash network based off of the Ropsten config
|
||||||
// Generate a batch of accounts to seal and fund with
|
// Generate a batch of accounts to seal and fund with
|
||||||
genesis := InitGenesis(t, faucets, "./testdata/genesis_7val.json", tt["sprintSize"].(uint64))
|
genesis := InitGenesisSprintLength(t, faucets, "./testdata/genesis_7val.json", tt["sprintSize"].(uint64))
|
||||||
|
|
||||||
nodes := make([]*eth.Ethereum, len(keys_21val))
|
nodes := make([]*eth.Ethereum, len(keys_21val))
|
||||||
enodes := make([]*enode.Node, len(keys_21val))
|
enodes := make([]*enode.Node, len(keys_21val))
|
||||||
|
|
@ -656,7 +660,7 @@ func SetupValidatorsAndTest2Nodes(t *testing.T, tt map[string]interface{}) (uint
|
||||||
|
|
||||||
for i := 0; i < len(keys_21val); i++ {
|
for i := 0; i < len(keys_21val); i++ {
|
||||||
// Start the node and wait until it's up
|
// Start the node and wait until it's up
|
||||||
stack, ethBackend, err := InitMiner(genesis, pkeys_21val[i], true)
|
stack, ethBackend, err := InitMinerSprintLength(genesis, pkeys_21val[i], true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
@ -666,8 +670,10 @@ func SetupValidatorsAndTest2Nodes(t *testing.T, tt map[string]interface{}) (uint
|
||||||
time.Sleep(250 * time.Millisecond)
|
time.Sleep(250 * time.Millisecond)
|
||||||
}
|
}
|
||||||
// Connect the node to all the previous ones
|
// Connect the node to all the previous ones
|
||||||
for _, n := range enodes {
|
for j, n := range enodes {
|
||||||
stack.Server().AddPeer(n)
|
if j < i {
|
||||||
|
stack.Server().AddPeer(n)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Start tracking the node and its enode
|
// Start tracking the node and its enode
|
||||||
stacks[i] = stack
|
stacks[i] = stack
|
||||||
|
|
@ -756,7 +762,7 @@ func SetupValidatorsAndTest2Nodes(t *testing.T, tt map[string]interface{}) (uint
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitGenesis(t *testing.T, faucets []*ecdsa.PrivateKey, fileLocation string, sprintSize uint64) *core.Genesis {
|
func InitGenesisSprintLength(t *testing.T, faucets []*ecdsa.PrivateKey, fileLocation string, sprintSize uint64) *core.Genesis {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
// sprint size = 8 in genesis
|
// sprint size = 8 in genesis
|
||||||
|
|
@ -778,7 +784,7 @@ func InitGenesis(t *testing.T, faucets []*ecdsa.PrivateKey, fileLocation string,
|
||||||
return genesis
|
return genesis
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitMiner(genesis *core.Genesis, privKey *ecdsa.PrivateKey, withoutHeimdall bool) (*node.Node, *eth.Ethereum, error) {
|
func InitMinerSprintLength(genesis *core.Genesis, privKey *ecdsa.PrivateKey, withoutHeimdall bool) (*node.Node, *eth.Ethereum, error) {
|
||||||
// Define the basic configurations for the Ethereum node
|
// Define the basic configurations for the Ethereum node
|
||||||
datadir, _ := ioutil.TempDir("", "")
|
datadir, _ := ioutil.TempDir("", "")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -407,6 +407,7 @@ func IsSprintEnd(number uint64) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitGenesis(t *testing.T, faucets []*ecdsa.PrivateKey, fileLocation string, sprintSize uint64) *core.Genesis {
|
func InitGenesis(t *testing.T, faucets []*ecdsa.PrivateKey, fileLocation string, sprintSize uint64) *core.Genesis {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
// sprint size = 8 in genesis
|
// sprint size = 8 in genesis
|
||||||
genesisData, err := ioutil.ReadFile(fileLocation)
|
genesisData, err := ioutil.ReadFile(fileLocation)
|
||||||
|
|
@ -447,6 +448,7 @@ func InitMiner(genesis *core.Genesis, privKey *ecdsa.PrivateKey, withoutHeimdall
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ethBackend, err := eth.New(stack, ðconfig.Config{
|
ethBackend, err := eth.New(stack, ðconfig.Config{
|
||||||
Genesis: genesis,
|
Genesis: genesis,
|
||||||
NetworkId: genesis.Config.ChainID.Uint64(),
|
NetworkId: genesis.Config.ChainID.Uint64(),
|
||||||
|
|
@ -464,6 +466,7 @@ func InitMiner(genesis *core.Genesis, privKey *ecdsa.PrivateKey, withoutHeimdall
|
||||||
},
|
},
|
||||||
WithoutHeimdall: withoutHeimdall,
|
WithoutHeimdall: withoutHeimdall,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -474,12 +477,23 @@ func InitMiner(genesis *core.Genesis, privKey *ecdsa.PrivateKey, withoutHeimdall
|
||||||
n, p := keystore.StandardScryptN, keystore.StandardScryptP
|
n, p := keystore.StandardScryptN, keystore.StandardScryptP
|
||||||
kStore := keystore.NewKeyStore(keydir, n, p)
|
kStore := keystore.NewKeyStore(keydir, n, p)
|
||||||
|
|
||||||
kStore.ImportECDSA(privKey, "")
|
_, err = kStore.ImportECDSA(privKey, "")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
acc := kStore.Accounts()[0]
|
acc := kStore.Accounts()[0]
|
||||||
kStore.Unlock(acc, "")
|
err = kStore.Unlock(acc, "")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// proceed to authorize the local account manager in any case
|
// proceed to authorize the local account manager in any case
|
||||||
ethBackend.AccountManager().AddBackend(kStore)
|
ethBackend.AccountManager().AddBackend(kStore)
|
||||||
|
|
||||||
err = stack.Start()
|
err = stack.Start()
|
||||||
|
|
||||||
return stack, ethBackend, err
|
return stack, ethBackend, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue