Skip to content

Commit

Permalink
chore: remove (deprecated) deps on build/ proxy-constants
Browse files Browse the repository at this point in the history
This is a large diff, yet should have exactly zero functional changes

Ideally as a result of this some parts of the depchain will become lighter,
with downstream reaping the same benefits as the team that initiated this split.

P.S. work was done to form better intuition of current dependency graph
  • Loading branch information
ribasushi committed Jul 16, 2024
1 parent 1f743ef commit cf7e5bb
Show file tree
Hide file tree
Showing 139 changed files with 555 additions and 536 deletions.
4 changes: 2 additions & 2 deletions api/docgen/docgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/filecoin-project/lotus/api"
apitypes "github.com/filecoin-project/lotus/api/types"
"github.com/filecoin-project/lotus/api/v0api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
Expand Down Expand Up @@ -123,7 +123,7 @@ func init() {
addExample(time.Minute)

addExample(network.ReachabilityPublic)
addExample(build.TestNetworkVersion)
addExample(buildconstants.TestNetworkVersion)
allocationId := verifreg.AllocationId(0)
addExample(allocationId)
addExample(&allocationId)
Expand Down
4 changes: 2 additions & 2 deletions blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"

bstore "github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/metrics"
Expand Down Expand Up @@ -59,7 +59,7 @@ var (
enableDebugLogWriteTraces = false

// upgradeBoundary is the boundary before and after an upgrade where we suppress compaction
upgradeBoundary = build.Finality
upgradeBoundary = policy.ChainFinality
)

type CompactType int
Expand Down
8 changes: 4 additions & 4 deletions blockstore/splitstore/splitstore_compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/filecoin-project/go-state-types/abi"

"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/metrics"
)
Expand All @@ -39,11 +39,11 @@ var (
// === :: cold (already archived)
// ≡≡≡ :: to be archived in this compaction
// --- :: hot
CompactionThreshold = 5 * build.Finality
CompactionThreshold = 5 * policy.ChainFinality

// CompactionBoundary is the number of epochs from the current epoch at which
// we will walk the chain for live objects.
CompactionBoundary = 4 * build.Finality
CompactionBoundary = 4 * policy.ChainFinality

// SyncGapTime is the time delay from a tipset's min timestamp before we decide
// there is a sync gap
Expand Down Expand Up @@ -551,7 +551,7 @@ func (s *SplitStore) doCompact(curTs *types.TipSet) error {
boundaryEpoch := currentEpoch - CompactionBoundary

var inclMsgsEpoch abi.ChainEpoch
inclMsgsRange := abi.ChainEpoch(s.cfg.HotStoreMessageRetention) * build.Finality
inclMsgsRange := abi.ChainEpoch(s.cfg.HotStoreMessageRetention) * policy.ChainFinality
if inclMsgsRange < boundaryEpoch {
inclMsgsEpoch = boundaryEpoch - inclMsgsRange
}
Expand Down
6 changes: 3 additions & 3 deletions blockstore/splitstore/splitstore_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

"github.com/filecoin-project/lotus/api"
bstore "github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/metrics"
)
Expand Down Expand Up @@ -44,7 +44,7 @@ var (

// PruneThreshold is the number of epochs that need to have elapsed
// from the previously pruned epoch to trigger a new prune
PruneThreshold = 7 * build.Finality
PruneThreshold = 7 * policy.ChainFinality
)

// GCHotStore runs online GC on the chain state in the hotstore according the to options specified
Expand Down Expand Up @@ -79,7 +79,7 @@ func (s *SplitStore) PruneChain(opts api.PruneOpts) error {
switch {
case retainState > 0:
retainStateP = func(depth int64) bool {
return depth <= int64(CompactionBoundary)+retainState*int64(build.Finality)
return depth <= int64(CompactionBoundary)+retainState*int64(policy.ChainFinality)
}
case retainState < 0:
retainStateP = func(_ int64) bool { return true }
Expand Down
4 changes: 2 additions & 2 deletions blockstore/splitstore/splitstore_warmup.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (

"github.com/filecoin-project/go-state-types/abi"

"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/types"
)

var (
// WarmupBoundary is the number of epochs to load state during warmup.
WarmupBoundary = build.Finality
WarmupBoundary = policy.ChainFinality
)

// warmup acquires the compaction lock and spawns a goroutine to warm up the hotstore;
Expand Down
9 changes: 5 additions & 4 deletions build/builtin_actors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
actorstypes "github.com/filecoin-project/go-state-types/actors"

"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
)
Expand All @@ -39,13 +40,13 @@ func init() {
}
BundleOverrides[actorstypes.Version(av)] = path
}
if err := loadManifests(NetworkBundle); err != nil {
if err := loadManifests(buildconstants.NetworkBundle); err != nil {
panic(err)
}

// The following code cid existed temporarily on the calibnet testnet, as a "buggy" storage miner actor implementation.
// We include them in our builtin bundle, but intentionally omit from metadata.
if NetworkBundle == "calibrationnet" {
if buildconstants.NetworkBundle == "calibrationnet" {
actors.AddActorMeta("storageminer", cid.MustParse("bafk2bzacecnh2ouohmonvebq7uughh4h3ppmg4cjsk74dzxlbbtlcij4xbzxq"), actorstypes.Version12)
actors.AddActorMeta("storageminer", cid.MustParse("bafk2bzaced7emkbbnrewv5uvrokxpf5tlm4jslu2jsv77ofw2yqdglg657uie"), actorstypes.Version12)
actors.AddActorMeta("verifiedregistry", cid.MustParse("bafk2bzacednskl3bykz5qpo54z2j2p4q44t5of4ktd6vs6ymmg2zebsbxazkm"), actorstypes.Version13)
Expand All @@ -54,13 +55,13 @@ func init() {

// UseNetworkBundle switches to a different network bundle, by name.
func UseNetworkBundle(netw string) error {
if NetworkBundle == netw {
if buildconstants.NetworkBundle == netw {
return nil
}
if err := loadManifests(netw); err != nil {
return err
}
NetworkBundle = netw
buildconstants.NetworkBundle = netw
return nil
}

Expand Down
7 changes: 0 additions & 7 deletions build/limits.go

This file was deleted.

2 changes: 2 additions & 0 deletions build/params_shared_vals.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ var PackingEfficiencyNum int64 = buildconstants.PackingEfficiencyNum // Depr
var PackingEfficiencyDenom int64 = buildconstants.PackingEfficiencyDenom // Deprecated: Use buildconstants.PackingEfficiencyDenom instead

const TestNetworkVersion = buildconstants.TestNetworkVersion // Deprecated: Use buildconstants.TestNetworkVersion instead

var MinerFDLimit = buildconstants.MinerFDLimit // Deprecated: Use buildconstants.MinerFDLimit instead
4 changes: 2 additions & 2 deletions chain/badtscache.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/hashicorp/golang-lru/arc/v2"
"github.com/ipfs/go-cid"

"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/build/buildconstants"
)

type BadBlockCache struct {
Expand Down Expand Up @@ -43,7 +43,7 @@ func (bbr BadBlockReason) String() string {
}

func NewBadBlockCache() *BadBlockCache {
cache, err := arc.NewARC[cid.Cid, BadBlockReason](build.BadBlockCacheSize)
cache, err := arc.NewARC[cid.Cid, BadBlockReason](buildconstants.BadBlockCacheSize)
if err != nil {
panic(err) // ok
}
Expand Down
5 changes: 3 additions & 2 deletions chain/beacon/drand/drand.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/filecoin-project/go-state-types/network"

"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/chain/beacon"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/modules/dtypes"
Expand All @@ -35,7 +36,7 @@ var log = logging.Logger("drand")
// We connect to drand peers via their public HTTP endpoints. The peers are
// enumerated in the drandServers variable.
//
// The root trust for the Drand chain is configured from build.DrandChain.
// The root trust for the Drand chain is configured from buildconstants.DrandConfigs
type DrandBeacon struct {
isChained bool
client dclient.Client
Expand Down Expand Up @@ -239,7 +240,7 @@ var _ beacon.RandomBeacon = (*DrandBeacon)(nil)
func BeaconScheduleFromDrandSchedule(dcs dtypes.DrandSchedule, genesisTime uint64, ps *pubsub.PubSub) (beacon.Schedule, error) {
shd := beacon.Schedule{}
for _, dc := range dcs {
bc, err := NewDrandBeacon(genesisTime, build.BlockDelaySecs, ps, dc.Config)
bc, err := NewDrandBeacon(genesisTime, buildconstants.BlockDelaySecs, ps, dc.Config)
if err != nil {
return nil, xerrors.Errorf("creating drand beacon: %w", err)
}
Expand Down
9 changes: 4 additions & 5 deletions chain/beacon/drand/drand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ import (

"github.com/filecoin-project/go-state-types/network"

"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/build/buildconstants"
)

func TestPrintGroupInfo(t *testing.T) {
server := build.DrandConfigs[buildconstants.DrandTestnet].Servers[0]
chainInfo := build.DrandConfigs[buildconstants.DrandTestnet].ChainInfoJSON
server := buildconstants.DrandConfigs[buildconstants.DrandTestnet].Servers[0]
chainInfo := buildconstants.DrandConfigs[buildconstants.DrandTestnet].ChainInfoJSON

drandChain, err := dchain.InfoFromJSON(bytes.NewReader([]byte(chainInfo)))
assert.NoError(t, err)
Expand All @@ -38,7 +37,7 @@ func TestPrintGroupInfo(t *testing.T) {

func TestMaxBeaconRoundForEpoch(t *testing.T) {
todayTs := uint64(1652222222)
db, err := NewDrandBeacon(todayTs, build.BlockDelaySecs, nil, build.DrandConfigs[buildconstants.DrandTestnet])
db, err := NewDrandBeacon(todayTs, buildconstants.BlockDelaySecs, nil, buildconstants.DrandConfigs[buildconstants.DrandTestnet])
assert.NoError(t, err)
assert.True(t, db.IsChained())
mbr15 := db.MaxBeaconRoundForEpoch(network.Version15, 100)
Expand All @@ -48,7 +47,7 @@ func TestMaxBeaconRoundForEpoch(t *testing.T) {

func TestQuicknetIsChained(t *testing.T) {
todayTs := uint64(1652222222)
db, err := NewDrandBeacon(todayTs, build.BlockDelaySecs, nil, build.DrandConfigs[buildconstants.DrandQuicknet])
db, err := NewDrandBeacon(todayTs, buildconstants.BlockDelaySecs, nil, buildconstants.DrandConfigs[buildconstants.DrandQuicknet])
assert.NoError(t, err)
assert.False(t, db.IsChained())
}
5 changes: 2 additions & 3 deletions chain/consensus/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

"github.com/filecoin-project/lotus/api"
bstore "github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/state"
Expand Down Expand Up @@ -77,7 +76,7 @@ func CommonBlkChecks(ctx context.Context, sm *stmgr.StateManager, cs *store.Chai
b *types.FullBlock, baseTs *types.TipSet) []async.ErrorFuture {
h := b.Header
msgsCheck := async.Err(func() error {
if b.Cid() == build.WhitelistedBlock {
if b.Cid() == buildconstants.WhitelistedBlock {
return nil
}

Expand Down Expand Up @@ -473,7 +472,7 @@ func decodeAndCheckBlock(msg *pubsub.Message) (*types.BlockMsg, string, error) {
return nil, "invalid", xerrors.Errorf("error decoding block: %w", err)
}

if count := len(blk.BlsMessages) + len(blk.SecpkMessages); count > build.BlockMessageLimit {
if count := len(blk.BlsMessages) + len(blk.SecpkMessages); count > buildconstants.BlockMessageLimit {
return nil, "too_many_messages", fmt.Errorf("block contains too many messages (%d)", count)
}

Expand Down
3 changes: 1 addition & 2 deletions chain/consensus/compute_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
exported7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/exported"

"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin/cron"
Expand Down Expand Up @@ -168,7 +167,7 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context,
}
}

ts := genesis.Timestamp + build.BlockDelaySecs*(uint64(i))
ts := genesis.Timestamp + buildconstants.BlockDelaySecs*(uint64(i))
vmCron, err := makeVm(pstate, i, ts)
if err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("making cron vm: %w", err)
Expand Down
14 changes: 8 additions & 6 deletions chain/consensus/filcns/filecoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import (

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/chain"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/actors/builtin/reward"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/beacon"
"github.com/filecoin-project/lotus/chain/consensus"
"github.com/filecoin-project/lotus/chain/rand"
Expand Down Expand Up @@ -141,12 +143,12 @@ func (filec *FilecoinEC) ValidateBlock(ctx context.Context, b *types.FullBlock)
}

nulls := h.Height - (baseTs.Height() + 1)
if tgtTs := baseTs.MinTimestamp() + build.BlockDelaySecs*uint64(nulls+1); h.Timestamp != tgtTs {
if tgtTs := baseTs.MinTimestamp() + buildconstants.BlockDelaySecs*uint64(nulls+1); h.Timestamp != tgtTs {
return xerrors.Errorf("block has wrong timestamp: %d != %d", h.Timestamp, tgtTs)
}

now := uint64(build.Clock.Now().Unix())
if h.Timestamp > now+build.AllowableClockDriftSecs {
if h.Timestamp > now+buildconstants.AllowableClockDriftSecs {
return xerrors.Errorf("block was from the future (now=%d, blk=%d): %w", now, h.Timestamp, consensus.ErrTemporal)
}
if h.Timestamp > now {
Expand Down Expand Up @@ -256,7 +258,7 @@ func (filec *FilecoinEC) ValidateBlock(ctx context.Context, b *types.FullBlock)
return xerrors.Errorf("failed to marshal miner address to cbor: %w", err)
}

if h.Height > build.UpgradeSmokeHeight {
if h.Height > buildconstants.UpgradeSmokeHeight {
buf.Write(baseTs.MinTicket().VRFProof)
}

Expand All @@ -265,7 +267,7 @@ func (filec *FilecoinEC) ValidateBlock(ctx context.Context, b *types.FullBlock)
beaconBase = h.BeaconEntries[len(h.BeaconEntries)-1]
}

vrfBase, err := rand.DrawRandomnessFromBase(beaconBase.Data, crypto.DomainSeparationTag_TicketProduction, h.Height-build.TicketRandomnessLookback, buf.Bytes())
vrfBase, err := rand.DrawRandomnessFromBase(beaconBase.Data, crypto.DomainSeparationTag_TicketProduction, h.Height-buildconstants.TicketRandomnessLookback, buf.Bytes())
if err != nil {
return xerrors.Errorf("failed to compute vrf base for ticket: %w", err)
}
Expand Down Expand Up @@ -394,12 +396,12 @@ func (filec *FilecoinEC) IsEpochInConsensusRange(epoch abi.ChainEpoch) bool {
//
// We use _our_ current head, not the expected head, because the network's head can lag on
// catch-up (after a network outage).
if epoch < filec.store.GetHeaviestTipSet().Height()-build.Finality {
if epoch < filec.store.GetHeaviestTipSet().Height()-policy.ChainFinality {
return false
}

now := uint64(build.Clock.Now().Unix())
return epoch <= (abi.ChainEpoch((now-filec.genesis.MinTimestamp())/build.BlockDelaySecs) + MaxHeightDrift)
return epoch <= (abi.ChainEpoch((now-filec.genesis.MinTimestamp())/buildconstants.BlockDelaySecs) + MaxHeightDrift)
}

func (filec *FilecoinEC) minerIsValid(ctx context.Context, maddr address.Address, baseTs *types.TipSet) error {
Expand Down
Loading

0 comments on commit cf7e5bb

Please sign in to comment.