Skip to content

Commit

Permalink
Remove Sokol (#7224)
Browse files Browse the repository at this point in the history
  • Loading branch information
yperbasis authored Mar 30, 2023
1 parent d9f8cc2 commit f590ba3
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 245 deletions.
2 changes: 0 additions & 2 deletions common/paths/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ func DataDirForNetwork(datadir string, network string) string {
return networkDataDirCheckingLegacy(datadir, "rinkeby")
case networkname.GoerliChainName:
return networkDataDirCheckingLegacy(datadir, "goerli")
case networkname.SokolChainName:
return networkDataDirCheckingLegacy(datadir, "sokol")
case networkname.MumbaiChainName:
return networkDataDirCheckingLegacy(datadir, "mumbai")
case networkname.BorMainnetChainName:
Expand Down
57 changes: 2 additions & 55 deletions consensus/aura/aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
"github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/erigon/rlp"
"github.com/ledgerwatch/erigon/rpc"
)
Expand Down Expand Up @@ -209,7 +208,7 @@ func (e *EpochManager) zoomToAfter(chain consensus.ChainHeaderReader, er consens
// forks it will only need to be called for the block directly after
// epoch transition, in which case it will be O(1) and require a single
// DB lookup.
lastTransition, ok := epochTransitionFor2(chain, er, hash)
lastTransition, ok := epochTransitionFor(chain, er, hash)
if !ok {
if lastTransition.BlockNumber > DEBUG_LOG_FROM {
fmt.Printf("zoom1: %d\n", lastTransition.BlockNumber)
Expand Down Expand Up @@ -255,7 +254,7 @@ func (e *EpochManager) zoomToAfter(chain consensus.ChainHeaderReader, er consens
// /
// / The block corresponding the the parent hash must be stored already.
// nolint
func epochTransitionFor2(chain consensus.ChainHeaderReader, e consensus.EpochReader, parentHash libcommon.Hash) (transition EpochTransition, ok bool) {
func epochTransitionFor(chain consensus.ChainHeaderReader, e consensus.EpochReader, parentHash libcommon.Hash) (transition EpochTransition, ok bool) {
//TODO: probably this version of func doesn't support non-canonical epoch transitions
h := chain.GetHeaderByHash(parentHash)
if h == nil {
Expand All @@ -271,58 +270,6 @@ func epochTransitionFor2(chain consensus.ChainHeaderReader, e consensus.EpochRea
return EpochTransition{BlockNumber: num, BlockHash: hash, ProofRlp: transitionProof}, true
}

// nolint
func epochTransitionFor(chain consensus.ChainHeaderReader, e consensus.EpochReader, parentHash libcommon.Hash) (transition EpochTransition, ok bool) {
// slow path: loop back block by block
for {
h := chain.GetHeaderByHash(parentHash)
if h == nil {
return transition, false
}

// look for transition in database.
transitionProof, err := e.GetEpoch(h.Hash(), h.Number.Uint64())
if err != nil {
panic(err)
}

if transitionProof != nil {
return EpochTransition{
BlockNumber: h.Number.Uint64(),
BlockHash: h.Hash(),
ProofRlp: transitionProof,
}, true
}

// canonical hash -> fast breakout:
// get the last epoch transition up to this block.
//
// if `block_hash` is canonical it will only return transitions up to
// the parent.
canonical := chain.GetHeaderByNumber(h.Number.Uint64())
if canonical == nil {
return transition, false
}
//nolint
if canonical.Hash() == parentHash {
return EpochTransition{
BlockNumber: 0,
BlockHash: libcommon.HexToHash("0x5b28c1bfd3a15230c9a46b399cd0f9a6920d432e85381cc6a140b06e8410112f"),
ProofRlp: params.SokolGenesisEpochProof,
}, true
/* TODO:
return self
.epoch_transitions()
.map(|(_, t)| t)
.take_while(|t| t.block_number <= details.number)
.last();
*/
}

parentHash = h.Hash()
}
}

// AuRa
// nolint
type AuRa struct {
Expand Down
2 changes: 1 addition & 1 deletion consensus/aura/aura_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestRewardContract(t *testing.T) {
auraDB, require := memdb.NewTestDB(t), require.New(t)
engine, err := aura.NewAuRa(nil, auraDB, libcommon.Address{}, test.AuthorityRoundBlockRewardContract)
require.NoError(err)
m := stages.MockWithGenesisEngine(t, core.SokolGenesisBlock(), engine, false)
m := stages.MockWithGenesisEngine(t, core.ChiadoGenesisBlock(), engine, false)
m.EnableLogs()

var accBefore *accounts.Account
Expand Down
5 changes: 0 additions & 5 deletions consensus/aura/consensusconfig/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import (
"github.com/ledgerwatch/erigon/params/networkname"
)

//go:embed poasokol.json
var Sokol []byte

//go:embed poagnosis.json
var Gnosis []byte

Expand All @@ -20,8 +17,6 @@ var Test []byte

func GetConfigByChain(chainName string) []byte {
switch chainName {
case networkname.SokolChainName:
return Sokol
case networkname.GnosisChainName:
return Gnosis
case networkname.ChiadoChainName:
Expand Down
28 changes: 0 additions & 28 deletions consensus/aura/consensusconfig/poasokol.json

This file was deleted.

35 changes: 0 additions & 35 deletions core/allocs/sokol.json

This file was deleted.

Loading

0 comments on commit f590ba3

Please sign in to comment.