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

Bor file structure updated #6167

Merged
merged 26 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ddb97cf
bor file structure updated
anshalshukla Nov 30, 2022
983030f
Heimdall gRPC added
anshalshukla Dec 8, 2022
9f81a38
Merge branch 'devel' into bor_updated_structure
anshalshukla Dec 8, 2022
ebbe82a
Fix bor changes
0xKrishna Dec 14, 2022
cf3e09a
minor fixes
anshalshukla Dec 14, 2022
0d4e38b
Spanner interface method signature updated
anshalshukla Dec 14, 2022
39c5189
config fix
anshalshukla Dec 14, 2022
c0544d6
bor structure updated
anshalshukla Dec 15, 2022
59e2b56
api.go updated
anshalshukla Dec 15, 2022
04cd8a0
linting updates
anshalshukla Dec 15, 2022
d0df70f
linting changes
anshalshukla Dec 15, 2022
d513eb1
heimdall grpc flag added
anshalshukla Dec 19, 2022
c67dc5a
heimdall grpc flag added
anshalshukla Dec 19, 2022
2b2c974
Merge branch 'devel' into bor_updated_structure
anshalshukla Jan 3, 2023
8c8cf0c
merge fixes
anshalshukla Jan 3, 2023
0658a8b
integration test golang version update
anshalshukla Jan 4, 2023
793260e
golang version for CI updated
anshalshukla Jan 4, 2023
b9d425a
fix lint errors
anshalshukla Jan 4, 2023
2eb058e
Merge branch 'devel' into bor_updated_structure
anshalshukla Jan 16, 2023
66a7e16
changes to metrics package reverted
anshalshukla Jan 23, 2023
75e77c3
PR Review Changes
anshalshukla Jan 23, 2023
dea7ed7
Merge branch 'devel' into bor_updated_structure
anshalshukla Jan 23, 2023
26f0778
remove WithExecutionContext method from bor
anshalshukla Jan 23, 2023
0eb0d8b
Merge branch 'devel' into bor_updated_structure
anshalshukla Jan 28, 2023
8b2a0fc
update atomic dependency
anshalshukla Jan 30, 2023
27e224e
Merge branch 'devel' into bor_updated_structure
anshalshukla Jan 30, 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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- run: git submodule update --init --recursive --force
- uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.19.x
- name: Install dependencies on Linux
if: runner.os == 'Linux'
run: sudo apt update && sudo apt install build-essential
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
- run: git submodule update --init --recursive --force
- uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.19.x

- uses: actions/cache@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- run: git submodule update --init --recursive --force
- uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.19.x
- name: Install dependencies on Linux
if: runner.os == 'Linux'
run: sudo apt update && sudo apt install build-essential
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
- run: git submodule update --init --recursive --force
- uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.19.x

- uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion cmd/erigon-el/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func NewBackend(stack *node.Node, config *ethconfig.Config, logger log.Logger) (
} else {
consensusConfig = &config.Ethash
}
backend.engine = ethconsensusconfig.CreateConsensusEngine(chainConfig, logger, consensusConfig, config.Miner.Notify, config.Miner.Noverify, config.HeimdallURL, config.WithoutHeimdall, stack.DataDir(), allSnapshots, false /* readonly */, backend.chainDB)
backend.engine = ethconsensusconfig.CreateConsensusEngine(chainConfig, logger, consensusConfig, config.Miner.Notify, config.Miner.Noverify, config.HeimdallgRPCAddress, config.HeimdallURL, config.WithoutHeimdall, stack.DataDir(), allSnapshots, false /* readonly */, backend.chainDB)
backend.forkValidator = engineapi.NewForkValidator(currentBlockNumber, inMemoryExecution, tmpdir)

if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/integration/commands/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
migration string
integrityFast, integritySlow bool
file string
HeimdallgRPCAddress string
HeimdallURL string
txtrace bool // Whether to trace the execution (should only be used together with `block`)
pruneFlag string
Expand Down
2 changes: 1 addition & 1 deletion cmd/integration/commands/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -1327,5 +1327,5 @@ func initConsensusEngine(cc *chain2.Config, datadir string, db kv.RwDB) (engine
} else {
consensusConfig = &config.Ethash
}
return ethconsensusconfig.CreateConsensusEngine(cc, l, consensusConfig, config.Miner.Notify, config.Miner.Noverify, config.HeimdallURL, config.WithoutHeimdall, datadir, snapshots, db.ReadOnly(), db)
return ethconsensusconfig.CreateConsensusEngine(cc, l, consensusConfig, config.Miner.Notify, config.Miner.Noverify, config.HeimdallgRPCAddress, config.HeimdallURL, config.WithoutHeimdall, datadir, snapshots, db.ReadOnly(), db)
}
4 changes: 2 additions & 2 deletions cmd/rpcdaemon/commands/bor_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/kv"

"github.com/ledgerwatch/erigon/consensus/bor"
"github.com/ledgerwatch/erigon/consensus/bor/valset"
"github.com/ledgerwatch/erigon/rpc"
)

Expand All @@ -17,7 +17,7 @@ type BorAPI interface {
GetSigners(number *rpc.BlockNumber) ([]libcommon.Address, error)
GetSignersAtHash(hash libcommon.Hash) ([]libcommon.Address, error)
GetCurrentProposer() (libcommon.Address, error)
GetCurrentValidators() ([]*bor.Validator, error)
GetCurrentValidators() ([]*valset.Validator, error)
GetRootHash(start uint64, end uint64) (string, error)
}

Expand Down
7 changes: 4 additions & 3 deletions cmd/rpcdaemon/commands/bor_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ledgerwatch/erigon-lib/kv"

"github.com/ledgerwatch/erigon/consensus/bor"
"github.com/ledgerwatch/erigon/consensus/bor/valset"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/rpc"
Expand Down Expand Up @@ -118,7 +119,7 @@ func validateHeaderExtraField(extraBytes []byte) error {
}

// validatorContains checks for a validator in given validator set
func validatorContains(a []*bor.Validator, x *bor.Validator) (*bor.Validator, bool) {
func validatorContains(a []*valset.Validator, x *valset.Validator) (*valset.Validator, bool) {
for _, n := range a {
if bytes.Equal(n.Address.Bytes(), x.Address.Bytes()) {
return n, true
Expand All @@ -128,11 +129,11 @@ func validatorContains(a []*bor.Validator, x *bor.Validator) (*bor.Validator, bo
}

// getUpdatedValidatorSet applies changes to a validator set and returns a new validator set
func getUpdatedValidatorSet(oldValidatorSet *ValidatorSet, newVals []*bor.Validator) *ValidatorSet {
func getUpdatedValidatorSet(oldValidatorSet *ValidatorSet, newVals []*valset.Validator) *ValidatorSet {
v := oldValidatorSet
oldVals := v.Validators

changes := make([]*bor.Validator, 0, len(oldVals))
changes := make([]*valset.Validator, 0, len(oldVals))
for _, ov := range oldVals {
if f, ok := validatorContains(newVals, ov); ok {
ov.VotingPower = f.VotingPower
Expand Down
13 changes: 7 additions & 6 deletions cmd/rpcdaemon/commands/bor_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/ledgerwatch/erigon/consensus"
"github.com/ledgerwatch/erigon/consensus/bor"
"github.com/ledgerwatch/erigon/consensus/bor/valset"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/crypto"
Expand Down Expand Up @@ -184,10 +185,10 @@ func (api *BorImpl) GetCurrentProposer() (libcommon.Address, error) {
}

// GetCurrentValidators gets the current validators
func (api *BorImpl) GetCurrentValidators() ([]*bor.Validator, error) {
func (api *BorImpl) GetCurrentValidators() ([]*valset.Validator, error) {
snap, err := api.GetSnapshot(nil)
if err != nil {
return make([]*bor.Validator, 0), err
return make([]*valset.Validator, 0), err
}
return snap.ValidatorSet.Validators, nil
}
Expand All @@ -207,11 +208,11 @@ func (api *BorImpl) GetRootHash(start, end uint64) (string, error) {
header := rawdb.ReadCurrentHeader(tx)
var currentHeaderNumber uint64 = 0
if header == nil {
return "", &bor.InvalidStartEndBlockError{Start: start, End: end, CurrentHeader: currentHeaderNumber}
return "", &valset.InvalidStartEndBlockError{Start: start, End: end, CurrentHeader: currentHeaderNumber}
}
currentHeaderNumber = header.Number.Uint64()
if start > end || end > currentHeaderNumber {
return "", &bor.InvalidStartEndBlockError{Start: start, End: end, CurrentHeader: currentHeaderNumber}
return "", &valset.InvalidStartEndBlockError{Start: start, End: end, CurrentHeader: currentHeaderNumber}
}
blockHeaders := make([]*types.Header, end-start+1)
for number := start; number <= end; number++ {
Expand Down Expand Up @@ -343,7 +344,7 @@ func (s *Snapshot) apply(headers []*types.Header) (*Snapshot, error) {
validatorBytes := header.Extra[extraVanity : len(header.Extra)-extraSeal]

// get validators from headers and use that for new validator set
newVals, _ := bor.ParseValidators(validatorBytes)
newVals, _ := valset.ParseValidators(validatorBytes)
v := getUpdatedValidatorSet(snap.ValidatorSet.Copy(), newVals)
v.IncrementProposerPriority(1)
snap.ValidatorSet = v
Expand Down Expand Up @@ -418,7 +419,7 @@ func loadSnapshot(api *BorImpl, db kv.Tx, borDb kv.Tx, hash libcommon.Hash) (*Sn
snap.config = config.Bor

// update total voting power
if err := snap.ValidatorSet.updateTotalVotingPower(); err != nil {
if err := snap.ValidatorSet.UpdateTotalVotingPower(); err != nil {
return nil, err
}

Expand Down
Loading