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

move borfinality package out of eth #8407

Merged
merged 5 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import (

"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/consensus"
"github.com/ledgerwatch/erigon/consensus/bor/finality"
"github.com/ledgerwatch/erigon/consensus/bor/finality/flags"
"github.com/ledgerwatch/erigon/consensus/bor/finality/whitelist"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall/span"
"github.com/ledgerwatch/erigon/consensus/bor/statefull"
Expand All @@ -39,9 +42,6 @@ import (
"github.com/ledgerwatch/erigon/core/types/accounts"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/crypto/cryptopool"
"github.com/ledgerwatch/erigon/eth/borfinality"
"github.com/ledgerwatch/erigon/eth/borfinality/flags"
"github.com/ledgerwatch/erigon/eth/borfinality/whitelist"
"github.com/ledgerwatch/erigon/rlp"
"github.com/ledgerwatch/erigon/rpc"
"github.com/ledgerwatch/erigon/turbo/services"
Expand Down Expand Up @@ -1302,7 +1302,7 @@ func (f FinalityAPIFunc) GetRootHash(start uint64, end uint64) (string, error) {
func (c *Bor) Start(chainDB kv.RwDB) {
if flags.Milestone {
whitelist.RegisterService(c.DB)
borfinality.Whitelist(c.HeimdallClient, c.DB, chainDB, c.blockReader, c.logger,
finality.Whitelist(c.HeimdallClient, c.DB, chainDB, c.blockReader, c.logger,
FinalityAPIFunc(func(start uint64, end uint64) (string, error) {
ctx := context.Background()
tx, err := chainDB.BeginRo(ctx)
Expand Down
5 changes: 3 additions & 2 deletions eth/borfinality/api.go → consensus/bor/finality/api.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package borfinality
package finality

import (
"github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/consensus/bor/finality/whitelist"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/eth/borfinality/whitelist"
)

func GetFinalizedBlockNumber(tx kv.Tx) uint64 {
Expand All @@ -29,6 +29,7 @@ func GetFinalizedBlockNumber(tx kv.Tx) uint64 {

doExist, number, hash = service.GetWhitelistedCheckpoint()
if doExist && number <= currentBlockNum.Number.Uint64() {

blockHeader := rawdb.ReadHeaderByNumber(tx, number)

if blockHeader == nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// nolint
package borfinality
package finality

import (
"context"
"errors"
"fmt"

"github.com/ledgerwatch/erigon/consensus/bor/finality/generics"
"github.com/ledgerwatch/erigon/consensus/bor/finality/whitelist"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/eth/borfinality/generics"
"github.com/ledgerwatch/erigon/eth/borfinality/whitelist"
"github.com/ledgerwatch/erigon/metrics"
"github.com/ledgerwatch/log/v3"
)
Expand Down Expand Up @@ -139,6 +139,10 @@ func borVerify(ctx context.Context, config *config, start uint64, end uint64, ha
log.Debug("Failed to get end block hash while whitelisting", "err", err)
return hash, errEndBlock
}
if block == nil {
log.Debug("Current header behind the end block", "block", end)
return hash, errEndBlock
}

hash = fmt.Sprintf("%v", block.Hash())

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/eth/borfinality/generics"
"github.com/ledgerwatch/erigon/consensus/bor/finality/generics"
"github.com/ledgerwatch/log/v3"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package borfinality
package finality

import (
"context"
Expand All @@ -7,9 +7,9 @@ import (
"time"

"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/consensus/bor/finality/flags"
"github.com/ledgerwatch/erigon/consensus/bor/finality/whitelist"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall"
"github.com/ledgerwatch/erigon/eth/borfinality/flags"
"github.com/ledgerwatch/erigon/eth/borfinality/whitelist"
"github.com/ledgerwatch/erigon/turbo/services"
"github.com/ledgerwatch/log/v3"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package whitelist

import (
"github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon/consensus/bor/finality/rawdb"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/eth/borfinality/rawdb"
"github.com/ledgerwatch/erigon/metrics"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/consensus/bor/finality/rawdb"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/eth/borfinality/rawdb"
"github.com/ledgerwatch/log/v3"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package whitelist

import (
"github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon/consensus/bor/finality/flags"
"github.com/ledgerwatch/erigon/consensus/bor/finality/rawdb"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/eth/borfinality/flags"
"github.com/ledgerwatch/erigon/eth/borfinality/rawdb"
"github.com/ledgerwatch/erigon/metrics"
"github.com/ledgerwatch/log/v3"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/consensus/bor/finality/rawdb"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/eth/borfinality/rawdb"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/memdb"
"github.com/ledgerwatch/erigon/consensus/bor/finality/rawdb"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/eth/borfinality/rawdb"
"github.com/stretchr/testify/require"

"pgregory.net/rapid"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package borfinality
package finality

import (
"context"
"errors"

"github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon/consensus/bor/finality/whitelist"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall"
"github.com/ledgerwatch/erigon/eth/borfinality/whitelist"
"github.com/ledgerwatch/log/v3"
)

Expand Down
2 changes: 1 addition & 1 deletion consensus/bor/heimdall/heimall.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"

"github.com/ledgerwatch/erigon/consensus/bor/clerk"
"github.com/ledgerwatch/erigon/consensus/bor/finality/generics"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall/checkpoint"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall/milestone"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall/span"
"github.com/ledgerwatch/erigon/eth/borfinality/generics"
)

func MilestoneRewindPending() bool {
Expand Down
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import (

"github.com/ledgerwatch/erigon/consensus"
"github.com/ledgerwatch/erigon/consensus/bor"
"github.com/ledgerwatch/erigon/consensus/bor/finality/flags"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall"
"github.com/ledgerwatch/erigon/consensus/bor/heimdallgrpc"
"github.com/ledgerwatch/erigon/consensus/clique"
Expand All @@ -105,7 +106,6 @@ import (
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/core/vm"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/eth/borfinality/flags"
"github.com/ledgerwatch/erigon/eth/ethconfig"
"github.com/ledgerwatch/erigon/eth/ethconsensusconfig"
"github.com/ledgerwatch/erigon/eth/ethutils"
Expand Down
4 changes: 2 additions & 2 deletions eth/stagedsync/stage_bor_heimdall.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/accounts/abi"
"github.com/ledgerwatch/erigon/consensus/bor/contract"
"github.com/ledgerwatch/erigon/consensus/bor/finality/generics"
"github.com/ledgerwatch/erigon/consensus/bor/finality/whitelist"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/dataflow"
"github.com/ledgerwatch/erigon/eth/borfinality/generics"
"github.com/ledgerwatch/erigon/eth/borfinality/whitelist"
"github.com/ledgerwatch/erigon/eth/stagedsync/stages"
"github.com/ledgerwatch/erigon/rlp"
"github.com/ledgerwatch/erigon/turbo/services"
Expand Down
2 changes: 1 addition & 1 deletion turbo/jsonrpc/bor_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (

"github.com/ledgerwatch/erigon/consensus"
"github.com/ledgerwatch/erigon/consensus/bor"
"github.com/ledgerwatch/erigon/consensus/bor/finality/whitelist"
"github.com/ledgerwatch/erigon/consensus/bor/valset"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/eth/borfinality/whitelist"
"github.com/ledgerwatch/erigon/rpc"
)

Expand Down
4 changes: 2 additions & 2 deletions turbo/jsonrpc/erigon_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/ledgerwatch/erigon-lib/common"

"github.com/ledgerwatch/erigon/common/hexutil"
borfinality "github.com/ledgerwatch/erigon/consensus/bor/finality"
"github.com/ledgerwatch/erigon/consensus/bor/finality/whitelist"
"github.com/ledgerwatch/erigon/core/forkid"
"github.com/ledgerwatch/erigon/eth/borfinality"
"github.com/ledgerwatch/erigon/eth/borfinality/whitelist"
"github.com/ledgerwatch/erigon/rpc"
"github.com/ledgerwatch/erigon/turbo/rpchelper"
)
Expand Down
4 changes: 2 additions & 2 deletions turbo/rpchelper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/kvcache"
"github.com/ledgerwatch/erigon-lib/kv/rawdbv3"
borfinality "github.com/ledgerwatch/erigon/consensus/bor/finality"
"github.com/ledgerwatch/erigon/consensus/bor/finality/whitelist"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/systemcontracts"
"github.com/ledgerwatch/erigon/eth/borfinality"
"github.com/ledgerwatch/erigon/eth/borfinality/whitelist"
"github.com/ledgerwatch/erigon/eth/ethconfig"
"github.com/ledgerwatch/erigon/eth/stagedsync/stages"
"github.com/ledgerwatch/erigon/rpc"
Expand Down
2 changes: 1 addition & 1 deletion turbo/stages/stageloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import (
"github.com/ledgerwatch/erigon/turbo/silkworm"

"github.com/ledgerwatch/erigon/cmd/sentry/sentry"
"github.com/ledgerwatch/erigon/consensus/bor/finality/flags"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall"
"github.com/ledgerwatch/erigon/consensus/misc"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/rawdb/blockio"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/core/vm"
"github.com/ledgerwatch/erigon/eth/borfinality/flags"
"github.com/ledgerwatch/erigon/eth/ethconfig"
"github.com/ledgerwatch/erigon/eth/stagedsync"
"github.com/ledgerwatch/erigon/eth/stagedsync/stages"
Expand Down
Loading