From 21abfc69fb552b92fa3ce223e863f1d582dec237 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Sun, 14 Jul 2024 09:06:08 -0500 Subject: [PATCH] feat: api: Clean API for Miners (#12112) * proofparams alternate * createminer * const factored from /build and types updated to use it * buildconstants for more places * deprecate msg * itest cleanup * alerting interface * house cleaning * rm policy and drand from buildconstants * clean up curio further * aussie waffle * pr fixes * fix lints * little fixes * oops this got updated * unbreak test builds * test fixes * comments - cleanups * itests fix alerting * rm obsolete alertinginterface * spelling oops * changelog * tests need buildconstants port * Fully migrate BlockGasTarget * ulimit should not depend on build * complete the simplest deprecations * bringing back versions --- CHANGELOG.md | 1 + build/buildconstants/drand.go | 12 ++ build/buildconstants/limits.go | 6 + build/buildconstants/params.go | 25 ++++ build/{ => buildconstants}/params_2k.go | 13 +- .../{ => buildconstants}/params_butterfly.go | 13 +- build/{ => buildconstants}/params_calibnet.go | 13 +- build/{ => buildconstants}/params_debug.go | 2 +- build/{ => buildconstants}/params_interop.go | 16 +-- build/{ => buildconstants}/params_mainnet.go | 8 +- build/buildconstants/params_shared_vals.go | 109 +++++++++++++++ .../{ => buildconstants}/params_testground.go | 16 +-- build/buildconstants/shared_funcs.go | 33 +++++ build/drand.go | 55 ++++---- build/limits.go | 5 +- build/parameters.go | 87 ++++++++++-- build/params_shared_funcs.go | 31 ++--- build/params_shared_vals.go | 109 ++++++--------- build/params_testground_vals.go | 12 ++ build/proof-params/parameters.go | 19 +++ build/version.go | 38 ++--- chain/beacon/drand/drand_test.go | 9 +- chain/consensus/common.go | 3 +- chain/consensus/compute_state.go | 3 +- chain/lf3/manifest.go | 5 +- chain/messagepool/repub.go | 3 +- chain/messagepool/selection.go | 11 +- chain/messagepool/selection_test.go | 39 +++--- chain/stmgr/call.go | 4 +- chain/store/basefee.go | 17 +-- chain/store/basefee_test.go | 9 +- chain/types/bigint.go | 6 +- chain/types/electionproof.go | 6 +- chain/types/ethtypes/eth_types.go | 4 +- chain/types/fil.go | 6 +- chain/types/message.go | 8 +- chain/types/mock/chain.go | 6 +- chain/types_test.go | 6 +- chain/vm/gas.go | 2 +- cli/chain.go | 7 +- cli/mpool.go | 6 +- cli/spcli/actor.go | 117 +--------------- cli/spcli/createminer/create_miner.go | 130 ++++++++++++++++++ cli/util/epoch.go | 12 +- cmd/lotus-shed/gas-estimation.go | 3 +- cmd/lotus-shed/mpool.go | 4 +- .../simulation/blockbuilder/blockbuilder.go | 6 +- cmd/tvx/codenames_test.go | 4 +- itests/api_test.go | 7 +- itests/eth_block_hash_test.go | 4 +- itests/eth_hash_lookup_test.go | 3 +- itests/fevm_test.go | 3 +- itests/kit/ensemble.go | 7 +- itests/kit/evm.go | 4 +- lib/ulimit/ulimit.go | 4 +- lib/ulimit/ulimit_test.go | 4 +- miner/miner.go | 3 +- node/builder.go | 3 +- node/impl/full/eth.go | 17 +-- node/impl/full/eth_utils.go | 5 +- node/impl/full/gas.go | 13 +- node/impl/full/gas_test.go | 24 ++-- node/impl/full/state.go | 13 +- tools/stats/points/collect.go | 7 +- 64 files changed, 711 insertions(+), 469 deletions(-) create mode 100644 build/buildconstants/drand.go create mode 100644 build/buildconstants/limits.go create mode 100644 build/buildconstants/params.go rename build/{ => buildconstants}/params_2k.go (93%) rename build/{ => buildconstants}/params_butterfly.go (86%) rename build/{ => buildconstants}/params_calibnet.go (90%) rename build/{ => buildconstants}/params_debug.go (87%) rename build/{ => buildconstants}/params_interop.go (92%) rename build/{ => buildconstants}/params_mainnet.go (95%) create mode 100644 build/buildconstants/params_shared_vals.go rename build/{ => buildconstants}/params_testground.go (93%) create mode 100644 build/buildconstants/shared_funcs.go create mode 100644 build/params_testground_vals.go create mode 100644 build/proof-params/parameters.go create mode 100644 cli/spcli/createminer/create_miner.go diff --git a/CHANGELOG.md b/CHANGELOG.md index bfb91552674..79f7d55f0c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - https://github.com/filecoin-project/lotus/pull/12203: Fix slice modification bug in ETH Tx Events Bloom Filter - https://github.com/filecoin-project/lotus/pull/12221: Fix a nil reference panic in the ETH Trace API +- https://github.com/filecoin-project/lotus/pull/12112: Moved consts from build/ to build/buildconstants/ for ligher curio deps. ## ☢️ Upgrade Warnings ☢️ diff --git a/build/buildconstants/drand.go b/build/buildconstants/drand.go new file mode 100644 index 00000000000..7925acdbaa9 --- /dev/null +++ b/build/buildconstants/drand.go @@ -0,0 +1,12 @@ +package buildconstants + +type DrandEnum int + +const ( + DrandMainnet DrandEnum = iota + 1 + DrandTestnet + DrandDevnet + DrandLocalnet + DrandIncentinet + DrandQuicknet +) diff --git a/build/buildconstants/limits.go b/build/buildconstants/limits.go new file mode 100644 index 00000000000..1a2024479be --- /dev/null +++ b/build/buildconstants/limits.go @@ -0,0 +1,6 @@ +package buildconstants + +var ( + DefaultFDLimit uint64 = 16 << 10 + MinerFDLimit uint64 = 100_000 +) diff --git a/build/buildconstants/params.go b/build/buildconstants/params.go new file mode 100644 index 00000000000..bdee1add2ad --- /dev/null +++ b/build/buildconstants/params.go @@ -0,0 +1,25 @@ +package buildconstants + +import "github.com/filecoin-project/go-state-types/network" + +var BuildType int + +const ( + BuildDefault = 0 + BuildMainnet = 0x1 + Build2k = 0x2 + BuildDebug = 0x3 + BuildCalibnet = 0x4 + BuildInteropnet = 0x5 + BuildButterflynet = 0x7 +) + +var Devnet = true + +// Used by tests and some obscure tooling +/* inline-gen template +const TestNetworkVersion = network.Version{{.latestNetworkVersion}} +/* inline-gen start */ +const TestNetworkVersion = network.Version23 + +/* inline-gen end */ diff --git a/build/params_2k.go b/build/buildconstants/params_2k.go similarity index 93% rename from build/params_2k.go rename to build/buildconstants/params_2k.go index 8ac5ab56956..64cede0d3fa 100644 --- a/build/params_2k.go +++ b/build/buildconstants/params_2k.go @@ -1,7 +1,7 @@ //go:build debug || 2k // +build debug 2k -package build +package buildconstants import ( "os" @@ -10,17 +10,13 @@ import ( "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" - actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" - - "github.com/filecoin-project/lotus/chain/actors/policy" ) const BootstrappersFile = "" const GenesisFile = "" var NetworkBundle = "devnet" -var BundleOverrides map[actorstypes.Version]string var ActorDebugging = true var GenesisNetworkVersion = network.Version22 @@ -95,11 +91,6 @@ var MinVerifiedDealSize = abi.NewStoragePower(256) var PreCommitChallengeDelay = abi.ChainEpoch(10) func init() { - policy.SetSupportedProofTypes(SupportedProofTypes...) - policy.SetConsensusMinerMinPower(ConsensusMinerMinPower) - policy.SetMinVerifiedDealSize(MinVerifiedDealSize) - policy.SetPreCommitChallengeDelay(PreCommitChallengeDelay) - getGenesisNetworkVersion := func(ev string, def network.Version) network.Version { hs, found := os.LookupEnv(ev) if found { @@ -189,6 +180,6 @@ const Eip155ChainId = 31415926 var WhitelistedBlock = cid.Undef -const f3Enabled = true +const F3Enabled = true const ManifestServerID = "12D3KooWHcNBkqXEBrsjoveQvj6zDF3vK5S9tAfqyYaQF1LGSJwG" const F3BootstrapEpoch abi.ChainEpoch = 100 diff --git a/build/params_butterfly.go b/build/buildconstants/params_butterfly.go similarity index 86% rename from build/params_butterfly.go rename to build/buildconstants/params_butterfly.go index 124d0b298b9..e8d76473073 100644 --- a/build/params_butterfly.go +++ b/build/buildconstants/params_butterfly.go @@ -1,18 +1,15 @@ //go:build butterflynet // +build butterflynet -package build +package buildconstants import ( "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" - - "github.com/filecoin-project/lotus/chain/actors/policy" ) var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ @@ -22,7 +19,6 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ const GenesisNetworkVersion = network.Version22 var NetworkBundle = "butterflynet" -var BundleOverrides map[actorstypes.Version]string var ActorDebugging = false const BootstrappersFile = "butterflynet.pi" @@ -79,11 +75,6 @@ var MinVerifiedDealSize = abi.NewStoragePower(1 << 20) var PreCommitChallengeDelay = abi.ChainEpoch(150) func init() { - policy.SetSupportedProofTypes(SupportedProofTypes...) - policy.SetConsensusMinerMinPower(ConsensusMinerMinPower) - policy.SetMinVerifiedDealSize(MinVerifiedDealSize) - policy.SetPreCommitChallengeDelay(PreCommitChallengeDelay) - SetAddressNetwork(address.Testnet) Devnet = true @@ -106,6 +97,6 @@ const Eip155ChainId = 3141592 var WhitelistedBlock = cid.Undef -const f3Enabled = true +const F3Enabled = true const ManifestServerID = "12D3KooWJr9jy4ngtJNR7JC1xgLFra3DjEtyxskRYWvBK9TC3Yn6" const F3BootstrapEpoch abi.ChainEpoch = 200 diff --git a/build/params_calibnet.go b/build/buildconstants/params_calibnet.go similarity index 90% rename from build/params_calibnet.go rename to build/buildconstants/params_calibnet.go index b2232c0466b..4d2b1cec4e9 100644 --- a/build/params_calibnet.go +++ b/build/buildconstants/params_calibnet.go @@ -1,7 +1,7 @@ //go:build calibnet // +build calibnet -package build +package buildconstants import ( "os" @@ -11,11 +11,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" - - "github.com/filecoin-project/lotus/chain/actors/policy" ) var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ @@ -26,7 +23,6 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ const GenesisNetworkVersion = network.Version0 var NetworkBundle = "calibrationnet" -var BundleOverrides map[actorstypes.Version]string var ActorDebugging = false const BootstrappersFile = "calibnet.pi" @@ -110,11 +106,6 @@ var MinVerifiedDealSize = abi.NewStoragePower(1 << 20) var PreCommitChallengeDelay = abi.ChainEpoch(150) func init() { - policy.SetSupportedProofTypes(SupportedProofTypes...) - policy.SetConsensusMinerMinPower(ConsensusMinerMinPower) - policy.SetMinVerifiedDealSize(MinVerifiedDealSize) - policy.SetPreCommitChallengeDelay(PreCommitChallengeDelay) - SetAddressNetwork(address.Testnet) Devnet = true @@ -152,6 +143,6 @@ const Eip155ChainId = 314159 var WhitelistedBlock = cid.Undef -const f3Enabled = true +const F3Enabled = true const ManifestServerID = "12D3KooWS9vD9uwm8u2uPyJV32QBAhKAmPYwmziAgr3Xzk2FU1Mr" const F3BootstrapEpoch abi.ChainEpoch = UpgradeWaffleHeight + 100 diff --git a/build/params_debug.go b/build/buildconstants/params_debug.go similarity index 87% rename from build/params_debug.go rename to build/buildconstants/params_debug.go index e977cda0562..29facea2ac5 100644 --- a/build/params_debug.go +++ b/build/buildconstants/params_debug.go @@ -1,7 +1,7 @@ //go:build debug // +build debug -package build +package buildconstants func init() { InsecurePoStValidation = true diff --git a/build/params_interop.go b/build/buildconstants/params_interop.go similarity index 92% rename from build/params_interop.go rename to build/buildconstants/params_interop.go index fefe9b5b7ea..a2fb4faf293 100644 --- a/build/params_interop.go +++ b/build/buildconstants/params_interop.go @@ -1,25 +1,24 @@ //go:build interopnet // +build interopnet -package build +package buildconstants import ( "os" "strconv" "github.com/ipfs/go-cid" + logging "github.com/ipfs/go-log/v2" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" - - "github.com/filecoin-project/lotus/chain/actors/policy" ) +var log = logging.Logger("buildconstants") + var NetworkBundle = "caterpillarnet" -var BundleOverrides map[actorstypes.Version]string var ActorDebugging = false const BootstrappersFile = "interopnet.pi" @@ -82,11 +81,6 @@ var MinVerifiedDealSize = abi.NewStoragePower(256) var PreCommitChallengeDelay = abi.ChainEpoch(10) func init() { - policy.SetSupportedProofTypes(SupportedProofTypes...) - policy.SetConsensusMinerMinPower(ConsensusMinerMinPower) - policy.SetMinVerifiedDealSize(MinVerifiedDealSize) - policy.SetPreCommitChallengeDelay(PreCommitChallengeDelay) - getUpgradeHeight := func(ev string, def abi.ChainEpoch) abi.ChainEpoch { hs, found := os.LookupEnv(ev) if found { @@ -145,6 +139,6 @@ const Eip155ChainId = 3141592 var WhitelistedBlock = cid.Undef -const f3Enabled = true +const F3Enabled = true const ManifestServerID = "12D3KooWQJ2rdVnG4okDUB6yHQhAjNutGNemcM7XzqC9Eo4z9Jce" const F3BootstrapEpoch abi.ChainEpoch = 1000 diff --git a/build/params_mainnet.go b/build/buildconstants/params_mainnet.go similarity index 95% rename from build/params_mainnet.go rename to build/buildconstants/params_mainnet.go index e99fc89a56f..1dfe97afe1a 100644 --- a/build/params_mainnet.go +++ b/build/buildconstants/params_mainnet.go @@ -1,7 +1,7 @@ //go:build !debug && !2k && !testground && !calibnet && !butterflynet && !interopnet // +build !debug,!2k,!testground,!calibnet,!butterflynet,!interopnet -package build +package buildconstants import ( "math" @@ -10,7 +10,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" ) @@ -23,8 +22,7 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ var NetworkBundle = "mainnet" -// NOTE: DO NOT change this unless you REALLY know what you're doing. This is consensus critical. -var BundleOverrides map[actorstypes.Version]string +var MinVerifiedDealSize = abi.NewStoragePower(1 << 20) // NOTE: DO NOT change this unless you REALLY know what you're doing. This is consensus critical. const ActorDebugging = false @@ -169,6 +167,6 @@ const Eip155ChainId = 314 // WhitelistedBlock skips checks on message validity in this block to sidestep the zero-bls signature var WhitelistedBlock = MustParseCid("bafy2bzaceapyg2uyzk7vueh3xccxkuwbz3nxewjyguoxvhx77malc2lzn2ybi") -const f3Enabled = false +const F3Enabled = false const ManifestServerID = "12D3KooWENMwUF9YxvQxar7uBWJtZkA6amvK4xWmKXfSiHUo2Qq7" const F3BootstrapEpoch abi.ChainEpoch = -1 diff --git a/build/buildconstants/params_shared_vals.go b/build/buildconstants/params_shared_vals.go new file mode 100644 index 00000000000..0a3798099a9 --- /dev/null +++ b/build/buildconstants/params_shared_vals.go @@ -0,0 +1,109 @@ +//go:build !testground +// +build !testground + +package buildconstants + +import ( + "math/big" + "os" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" + + "github.com/filecoin-project/lotus/chain/actors/policy" +) + +// ///// +// Storage + +const UnixfsChunkSize uint64 = 1 << 20 +const UnixfsLinksPerLevel = 1024 + +// ///// +// Consensus / Network + +const AllowableClockDriftSecs = uint64(1) + +// Blocks (e) +var BlocksPerEpoch = uint64(builtin2.ExpectedLeadersPerEpoch) + +// Epochs +const MessageConfidence = uint64(5) + +// constants for Weight calculation +// The ratio of weight contributed by short-term vs long-term factors in a given round +const WRatioNum = int64(1) +const WRatioDen = uint64(2) + +// ///// +// Proofs + +// Epochs +// TODO: unused +const SealRandomnessLookback = policy.SealRandomnessLookback + +// ///// +// Mining + +// Epochs +const TicketRandomnessLookback = abi.ChainEpoch(1) + +// ///// +// Address + +const AddressMainnetEnvVar = "_mainnet_" + +// the 'f' prefix doesn't matter +var ZeroAddress = MustParseAddress("f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a") + +const FilBase = uint64(2_000_000_000) +const FilAllocStorageMining = uint64(1_100_000_000) + +const FilecoinPrecision = uint64(1_000_000_000_000_000_000) +const FilReserved = uint64(300_000_000) + +var InitialRewardBalance *big.Int +var InitialFilReserved *big.Int + +func init() { + InitialRewardBalance = big.NewInt(int64(FilAllocStorageMining)) + InitialRewardBalance = InitialRewardBalance.Mul(InitialRewardBalance, big.NewInt(int64(FilecoinPrecision))) + + InitialFilReserved = big.NewInt(int64(FilReserved)) + InitialFilReserved = InitialFilReserved.Mul(InitialFilReserved, big.NewInt(int64(FilecoinPrecision))) + + if os.Getenv("LOTUS_ADDRESS_TYPE") == AddressMainnetEnvVar { + SetAddressNetwork(address.Mainnet) + } +} + +// Sync +const BadBlockCacheSize = 1 << 15 + +// assuming 4000 messages per round, this lets us not lose any messages across a +// 10 block reorg. +const BlsSignatureCacheSize = 40000 + +// Size of signature verification cache +// 32k keeps the cache around 10MB in size, max +const VerifSigCacheSize = 32000 + +// /////// +// Limits + +const BlockMessageLimit = 10000 + +var BlockGasLimit = int64(10_000_000_000) +var BlockGasTarget = BlockGasLimit / 2 + +const BaseFeeMaxChangeDenom = 8 // 12.5% +const InitialBaseFee = 100e6 +const MinimumBaseFee = 100 +const PackingEfficiencyNum = 4 +const PackingEfficiencyDenom = 5 + +// revive:disable-next-line:exported +// Actor consts +// TODO: pieceSize unused from actors +var MinDealDuration, MaxDealDuration = policy.DealDurationBounds(0) diff --git a/build/params_testground.go b/build/buildconstants/params_testground.go similarity index 93% rename from build/params_testground.go rename to build/buildconstants/params_testground.go index 209d8050056..ee442927fff 100644 --- a/build/params_testground.go +++ b/build/buildconstants/params_testground.go @@ -5,7 +5,7 @@ // // Its purpose is to unlock various degrees of flexibility and parametrization // when writing Testground plans for Lotus. -package build +package buildconstants import ( "math/big" @@ -13,7 +13,6 @@ import ( "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" - actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" @@ -52,8 +51,6 @@ var ( BlsSignatureCacheSize = 40000 VerifSigCacheSize = 32000 - SealRandomnessLookback = policy.SealRandomnessLookback - TicketRandomnessLookback = abi.ChainEpoch(1) FilBase uint64 = 2_000_000_000 @@ -117,28 +114,29 @@ var ( GenesisNetworkVersion = network.Version0 NetworkBundle = "devnet" - BundleOverrides map[actorstypes.Version]string ActorDebugging = true NewestNetworkVersion = network.Version16 ActorUpgradeNetworkVersion = network.Version16 - Devnet = true ZeroAddress = MustParseAddress("f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a") WhitelistedBlock = cid.Undef BootstrappersFile = "" GenesisFile = "" - f3Enabled = false + F3Enabled = false ManifestServerID = "" F3BootstrapEpoch abi.ChainEpoch = -1 ) -const Finality = policy.ChainFinality -const ForkLengthThreshold = Finality +func init() { + Devnet = true +} const BootstrapPeerThreshold = 1 // ChainId defines the chain ID used in the Ethereum JSON-RPC endpoint. // As per https://github.com/ethereum-lists/chains const Eip155ChainId = 31415926 + +var MinDealDuration, MaxDealDuration = policy.DealDurationBounds(0) diff --git a/build/buildconstants/shared_funcs.go b/build/buildconstants/shared_funcs.go new file mode 100644 index 00000000000..c440e78e6e9 --- /dev/null +++ b/build/buildconstants/shared_funcs.go @@ -0,0 +1,33 @@ +package buildconstants + +import ( + "github.com/ipfs/go-cid" + logging "github.com/ipfs/go-log/v2" + + "github.com/filecoin-project/go-address" +) + +// moved from now-defunct build/paramfetch.go +var log = logging.Logger("build/buildtypes") + +func SetAddressNetwork(n address.Network) { + address.CurrentNetwork = n +} + +func MustParseAddress(addr string) address.Address { + ret, err := address.NewFromString(addr) + if err != nil { + panic(err) + } + + return ret +} + +func MustParseCid(c string) cid.Cid { + ret, err := cid.Decode(c) + if err != nil { + panic(err) + } + + return ret +} diff --git a/build/drand.go b/build/drand.go index c4ba4b3b7af..9b54be057e7 100644 --- a/build/drand.go +++ b/build/drand.go @@ -3,35 +3,19 @@ package build import ( "sort" + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/node/modules/dtypes" ) -type DrandEnum int +var DrandMainnet = buildconstants.DrandMainnet +var DrandTestnet = buildconstants.DrandTestnet +var DrandDevnet = buildconstants.DrandDevnet +var DrandLocalnet = buildconstants.DrandLocalnet +var DrandIncentinet = buildconstants.DrandIncentinet +var DrandQuicknet = buildconstants.DrandQuicknet -func DrandConfigSchedule() dtypes.DrandSchedule { - out := dtypes.DrandSchedule{} - for start, network := range DrandSchedule { - out = append(out, dtypes.DrandPoint{Start: start, Config: DrandConfigs[network]}) - } - - sort.Slice(out, func(i, j int) bool { - return out[i].Start < out[j].Start - }) - - return out -} - -const ( - DrandMainnet DrandEnum = iota + 1 - DrandTestnet - DrandDevnet - DrandLocalnet - DrandIncentinet - DrandQuicknet -) - -var DrandConfigs = map[DrandEnum]dtypes.DrandConfig{ - DrandMainnet: { +var DrandConfigs = map[buildconstants.DrandEnum]dtypes.DrandConfig{ + buildconstants.DrandMainnet: { Servers: []string{ "https://api.drand.sh", "https://api2.drand.sh", @@ -47,7 +31,7 @@ var DrandConfigs = map[DrandEnum]dtypes.DrandConfig{ IsChained: true, ChainInfoJSON: `{"public_key":"868f005eb8e6e4ca0a47c8a77ceaa5309a47978a7c71bc5cce96366b5d7a569937c529eeda66c7293784a9402801af31","period":30,"genesis_time":1595431050,"hash":"8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce","groupHash":"176f93498eac9ca337150b46d21dd58673ea4e3581185f869672e59fa4cb390a"}`, }, - DrandQuicknet: { + buildconstants.DrandQuicknet: { Servers: []string{ "https://api.drand.sh", "https://api2.drand.sh", @@ -63,7 +47,7 @@ var DrandConfigs = map[DrandEnum]dtypes.DrandConfig{ IsChained: false, ChainInfoJSON: `{"public_key":"83cf0f2896adee7eb8b5f01fcad3912212c437e0073e911fb90022d3e760183c8c4b450b6a0a6c3ac6a5776a2d1064510d1fec758c921cc22b0e17e63aaf4bcb5ed66304de9cf809bd274ca73bab4af5a6e9c76a4bc09e76eae8991ef5ece45a","period":3,"genesis_time":1692803367,"hash":"52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971","groupHash":"f477d5c89f21a17c863a7f937c6a6d15859414d2be09cd448d4279af331c5d3e","schemeID":"bls-unchained-g1-rfc9380","metadata":{"beaconID":"quicknet"}}`, }, - DrandTestnet: { + buildconstants.DrandTestnet: { Servers: []string{ "https://pl-eu.testnet.drand.sh", "https://pl-us.testnet.drand.sh", @@ -75,7 +59,7 @@ var DrandConfigs = map[DrandEnum]dtypes.DrandConfig{ IsChained: true, ChainInfoJSON: `{"public_key":"922a2e93828ff83345bae533f5172669a26c02dc76d6bf59c80892e12ab1455c229211886f35bb56af6d5bea981024df","period":25,"genesis_time":1590445175,"hash":"84b2234fb34e835dccd048255d7ad3194b81af7d978c3bf157e3469592ae4e02","groupHash":"4dd408e5fdff9323c76a9b6f087ba8fdc5a6da907bd9217d9d10f2287d081957"}`, }, - DrandDevnet: { + buildconstants.DrandDevnet: { Servers: []string{ "https://dev1.drand.sh", "https://dev2.drand.sh", @@ -87,8 +71,21 @@ var DrandConfigs = map[DrandEnum]dtypes.DrandConfig{ IsChained: true, ChainInfoJSON: `{"public_key":"8cda589f88914aa728fd183f383980b35789ce81b274e5daee1f338b77d02566ef4d3fb0098af1f844f10f9c803c1827","period":25,"genesis_time":1595348225,"hash":"e73b7dc3c4f6a236378220c0dd6aa110eb16eed26c11259606e07ee122838d4f","groupHash":"567d4785122a5a3e75a9bc9911d7ea807dd85ff76b78dc4ff06b075712898607"}`, }, - DrandIncentinet: { + buildconstants.DrandIncentinet: { IsChained: true, ChainInfoJSON: `{"public_key":"8cad0c72c606ab27d36ee06de1d5b2db1faf92e447025ca37575ab3a8aac2eaae83192f846fc9e158bc738423753d000","period":30,"genesis_time":1595873820,"hash":"80c8b872c714f4c00fdd3daa465d5514049f457f01f85a4caf68cdcd394ba039","groupHash":"d9406aaed487f7af71851b4399448e311f2328923d454e971536c05398ce2d9b"}`, }, } + +func DrandConfigSchedule() dtypes.DrandSchedule { + out := dtypes.DrandSchedule{} + for start, network := range buildconstants.DrandSchedule { + out = append(out, dtypes.DrandPoint{Start: start, Config: DrandConfigs[network]}) + } + + sort.Slice(out, func(i, j int) bool { + return out[i].Start < out[j].Start + }) + + return out +} diff --git a/build/limits.go b/build/limits.go index 93d56577c44..5cf3eda88d1 100644 --- a/build/limits.go +++ b/build/limits.go @@ -1,6 +1,7 @@ package build +import "github.com/filecoin-project/lotus/build/buildconstants" + var ( - DefaultFDLimit uint64 = 16 << 10 - MinerFDLimit uint64 = 100_000 + MinerFDLimit uint64 = buildconstants.MinerFDLimit ) diff --git a/build/parameters.go b/build/parameters.go index 9e60f12a6a3..31243e96fcd 100644 --- a/build/parameters.go +++ b/build/parameters.go @@ -1,19 +1,84 @@ package build import ( - _ "embed" + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + + "github.com/filecoin-project/lotus/build/buildconstants" + proofparams "github.com/filecoin-project/lotus/build/proof-params" + "github.com/filecoin-project/lotus/chain/actors/policy" ) -//go:embed proof-params/parameters.json -var params []byte +var ParametersJSON = proofparams.ParametersJSON +var SrsJSON = proofparams.SrsJSON + +// NOTE: DO NOT change this unless you REALLY know what you're doing. This is consensus critical. +var BundleOverrides map[actorstypes.Version]string + +var BootstrappersFile = buildconstants.BootstrappersFile // Deprecated: Use buildconstants.BootstrappersFile instead + +var GenesisFile = buildconstants.GenesisFile // Deprecated: Use buildconstants.GenesisFile instead + +var NetworkBundle = buildconstants.NetworkBundle // Deprecated: Use buildconstants.NetworkBundle instead +var ActorDebugging = buildconstants.ActorDebugging // Deprecated: Use buildconstants.ActorDebugging instead + +var GenesisNetworkVersion = buildconstants.GenesisNetworkVersion // Deprecated: Use buildconstants.GenesisNetworkVersion instead + +var UpgradeBreezeHeight abi.ChainEpoch = buildconstants.UpgradeBreezeHeight // Deprecated: Use buildconstants.UpgradeBreezeHeight instead + +var BreezeGasTampingDuration abi.ChainEpoch = buildconstants.BreezeGasTampingDuration // Deprecated: Use buildconstants.BreezeGasTampingDuration instead + +// upgrade heights +var UpgradeSmokeHeight abi.ChainEpoch = buildconstants.UpgradeSmokeHeight // Deprecated: Use buildconstants.UpgradeSmokeHeight instead +var UpgradeIgnitionHeight abi.ChainEpoch = buildconstants.UpgradeIgnitionHeight // Deprecated: Use buildconstants.UpgradeIgnitionHeight instead +var UpgradeRefuelHeight abi.ChainEpoch = buildconstants.UpgradeRefuelHeight // Deprecated: Use buildconstants.UpgradeRefuelHeight instead +var UpgradeTapeHeight abi.ChainEpoch = buildconstants.UpgradeTapeHeight // Deprecated: Use buildconstants.UpgradeTapeHeight instead +var UpgradeAssemblyHeight abi.ChainEpoch = buildconstants.UpgradeAssemblyHeight // Deprecated: Use buildconstants.UpgradeAssemblyHeight instead +var UpgradeLiftoffHeight abi.ChainEpoch = buildconstants.UpgradeLiftoffHeight // Deprecated: Use buildconstants.UpgradeLiftoffHeight instead +var UpgradeKumquatHeight abi.ChainEpoch = buildconstants.UpgradeKumquatHeight // Deprecated: Use buildconstants.UpgradeKumquatHeight instead +var UpgradeCalicoHeight abi.ChainEpoch = buildconstants.UpgradeCalicoHeight // Deprecated: Use buildconstants.UpgradeCalicoHeight instead +var UpgradePersianHeight abi.ChainEpoch = buildconstants.UpgradePersianHeight // Deprecated: Use buildconstants.UpgradePersianHeight instead +var UpgradeOrangeHeight abi.ChainEpoch = buildconstants.UpgradeOrangeHeight // Deprecated: Use buildconstants.UpgradeOrangeHeight instead +var UpgradeClausHeight abi.ChainEpoch = buildconstants.UpgradeClausHeight // Deprecated: Use buildconstants.UpgradeClausHeight instead +var UpgradeTrustHeight abi.ChainEpoch = buildconstants.UpgradeTrustHeight // Deprecated: Use buildconstants.UpgradeTrustHeight instead +var UpgradeNorwegianHeight abi.ChainEpoch = buildconstants.UpgradeNorwegianHeight // Deprecated: Use buildconstants.UpgradeNorwegianHeight instead +var UpgradeTurboHeight abi.ChainEpoch = buildconstants.UpgradeTurboHeight // Deprecated: Use buildconstants.UpgradeTurboHeight instead +var UpgradeHyperdriveHeight abi.ChainEpoch = buildconstants.UpgradeHyperdriveHeight // Deprecated: Use buildconstants.UpgradeHyperdriveHeight instead +var UpgradeChocolateHeight abi.ChainEpoch = buildconstants.UpgradeChocolateHeight // Deprecated: Use buildconstants.UpgradeChocolateHeight instead +var UpgradeOhSnapHeight abi.ChainEpoch = buildconstants.UpgradeOhSnapHeight // Deprecated: Use buildconstants.UpgradeOhSnapHeight instead +var UpgradeSkyrHeight abi.ChainEpoch = buildconstants.UpgradeSkyrHeight // Deprecated: Use buildconstants.UpgradeSkyrHeight instead +var UpgradeSharkHeight abi.ChainEpoch = buildconstants.UpgradeSharkHeight // Deprecated: Use buildconstants.UpgradeSharkHeight instead +var UpgradeHyggeHeight abi.ChainEpoch = buildconstants.UpgradeHyggeHeight // Deprecated: Use buildconstants.UpgradeHyggeHeight instead +var UpgradeLightningHeight abi.ChainEpoch = buildconstants.UpgradeLightningHeight // Deprecated: Use buildconstants.UpgradeLightningHeight instead +var UpgradeThunderHeight abi.ChainEpoch = buildconstants.UpgradeThunderHeight // Deprecated: Use buildconstants.UpgradeThunderHeight instead +var UpgradeWatermelonHeight abi.ChainEpoch = buildconstants.UpgradeWatermelonHeight // Deprecated: Use buildconstants.UpgradeWatermelonHeight instead +var UpgradeDragonHeight abi.ChainEpoch = buildconstants.UpgradeDragonHeight // Deprecated: Use buildconstants.UpgradeDragonHeight instead +var UpgradePhoenixHeight abi.ChainEpoch = buildconstants.UpgradePhoenixHeight // Deprecated: Use buildconstants.UpgradePhoenixHeight instead +var UpgradeWaffleHeight abi.ChainEpoch = buildconstants.UpgradeWaffleHeight // Deprecated: Use buildconstants.UpgradeWaffleHeight instead + +// This fix upgrade only ran on calibrationnet +var UpgradeWatermelonFixHeight abi.ChainEpoch = buildconstants.UpgradeWatermelonFixHeight // Deprecated: Use buildconstants.UpgradeWatermelonFixHeight instead + +// This fix upgrade only ran on calibrationnet +var UpgradeWatermelonFix2Height abi.ChainEpoch = buildconstants.UpgradeWatermelonFix2Height // Deprecated: Use buildconstants.UpgradeWatermelonFix2Height instead + +// This fix upgrade only ran on calibrationnet +var UpgradeCalibrationDragonFixHeight abi.ChainEpoch = buildconstants.UpgradeCalibrationDragonFixHeight // Deprecated: Use buildconstants.UpgradeCalibrationDragonFixHeight instead + +var SupportedProofTypes = buildconstants.SupportedProofTypes // Deprecated: Use buildconstants.SupportedProofTypes instead +var ConsensusMinerMinPower = buildconstants.ConsensusMinerMinPower // Deprecated: Use buildconstants.ConsensusMinerMinPower instead +var PreCommitChallengeDelay = buildconstants.PreCommitChallengeDelay // Deprecated: Use buildconstants.PreCommitChallengeDelay instead + +var BlockDelaySecs = buildconstants.BlockDelaySecs // Deprecated: Use buildconstants.BlockDelaySecs instead + +var PropagationDelaySecs = buildconstants.PropagationDelaySecs // Deprecated: Use buildconstants.PropagationDelaySecs instead + +const BootstrapPeerThreshold = buildconstants.BootstrapPeerThreshold // Deprecated: Use buildconstants.BootstrapPeerThreshold instead -//go:embed proof-params/srs-inner-product.json -var srs []byte +// ChainId defines the chain ID used in the Ethereum JSON-RPC endpoint. +// As per https://github.com/ethereum-lists/chains +const Eip155ChainId = buildconstants.Eip155ChainId // Deprecated: Use buildconstants.Eip155ChainId instead -func ParametersJSON() []byte { - return params -} +var WhitelistedBlock = buildconstants.WhitelistedBlock // Deprecated: Use buildconstants.WhitelistedBlock instead -func SrsJSON() []byte { - return srs -} +const Finality = policy.ChainFinality // Deprecated: Use policy.ChainFinality instead diff --git a/build/params_shared_funcs.go b/build/params_shared_funcs.go index 84ffd6f4513..706bafcb303 100644 --- a/build/params_shared_funcs.go +++ b/build/params_shared_funcs.go @@ -3,11 +3,9 @@ package build import ( "os" - "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p/core/protocol" - "github.com/filecoin-project/go-address" - + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -30,29 +28,16 @@ func DhtProtocolName(netName dtypes.NetworkName) protocol.ID { return protocol.ID("/fil/kad/" + string(netName)) } -func SetAddressNetwork(n address.Network) { - address.CurrentNetwork = n -} - -func MustParseAddress(addr string) address.Address { - ret, err := address.NewFromString(addr) - if err != nil { - panic(err) - } - - return ret -} +// Deprecated: Use buildconstants.SetAddressNetwork instead. +var SetAddressNetwork = buildconstants.SetAddressNetwork -func MustParseCid(c string) cid.Cid { - ret, err := cid.Decode(c) - if err != nil { - panic(err) - } +// Deprecated: Use buildconstants.MustParseAddress instead. +var MustParseAddress = buildconstants.MustParseAddress - return ret -} +// Deprecated: Use buildconstants.MustParseCid instead. +var MustParseCid = buildconstants.MustParseCid func IsF3Enabled() bool { const F3DisableEnvKey = "LOTUS_DISABLE_F3" - return f3Enabled && len(os.Getenv(F3DisableEnvKey)) == 0 + return buildconstants.F3Enabled && len(os.Getenv(F3DisableEnvKey)) == 0 } diff --git a/build/params_shared_vals.go b/build/params_shared_vals.go index 4d759dfa4a5..ab1bca3bb59 100644 --- a/build/params_shared_vals.go +++ b/build/params_shared_vals.go @@ -1,119 +1,94 @@ -//go:build !testground -// +build !testground - package build import ( "math/big" - "os" - - "github.com/filecoin-project/go-address" - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/network" - builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/chain/actors/policy" ) // ///// -// Consensus / Network +// Storage -const AllowableClockDriftSecs = uint64(1) +var UnixfsChunkSize uint64 = buildconstants.UnixfsChunkSize // Deprecated: Use buildconstants.UnixfsChunkSize instead +var UnixfsLinksPerLevel = buildconstants.UnixfsLinksPerLevel // Deprecated: Use buildconstants.UnixfsLinksPerLevel instead -// Used by tests and some obscure tooling -/* inline-gen template -const TestNetworkVersion = network.Version{{.latestNetworkVersion}} -/* inline-gen start */ -const TestNetworkVersion = network.Version23 +// ///// +// Consensus / Network -/* inline-gen end */ +var AllowableClockDriftSecs = buildconstants.AllowableClockDriftSecs // Deprecated: Use buildconstants.AllowableClockDriftSecs instead // Epochs -const ForkLengthThreshold = Finality +const ForkLengthThreshold = Finality // Deprecated: Use Finality instead // Blocks (e) -var BlocksPerEpoch = uint64(builtin2.ExpectedLeadersPerEpoch) +var BlocksPerEpoch = buildconstants.BlocksPerEpoch // Deprecated: Use buildconstants.BlocksPerEpoch instead // Epochs -const Finality = policy.ChainFinality -const MessageConfidence = uint64(5) +var MessageConfidence = buildconstants.MessageConfidence // Deprecated: Use buildconstants.MessageConfidence instead -// constants for Weight calculation -// The ratio of weight contributed by short-term vs long-term factors in a given round -const WRatioNum = int64(1) -const WRatioDen = uint64(2) - -// ///// -// Proofs - -// Epochs -// TODO: unused -const SealRandomnessLookback = policy.SealRandomnessLookback +var WRatioNum = buildconstants.WRatioNum // Deprecated: Use buildconstants.WRatioNum instead +var WRatioDen = buildconstants.WRatioDen // Deprecated: Use buildconstants.WRatioDen instead // ///// // Mining // Epochs -const TicketRandomnessLookback = abi.ChainEpoch(1) - -// ///// -// Address - -const AddressMainnetEnvVar = "_mainnet_" +var TicketRandomnessLookback = buildconstants.TicketRandomnessLookback // Deprecated: Use buildconstants.TicketRandomnessLookback instead // the 'f' prefix doesn't matter -var ZeroAddress = MustParseAddress("f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a") - +var ZeroAddress = buildconstants.ZeroAddress // Deprecated: Use buildconstants.ZeroAddress instead // ///// // Devnet settings -var Devnet = true +var Devnet = buildconstants.Devnet // Deprecated: Use buildconstants.Devnet instead -const FilBase = uint64(2_000_000_000) -const FilAllocStorageMining = uint64(1_100_000_000) +var FilBase = buildconstants.FilBase // Deprecated: Use buildconstants.FilBase instead +var FilAllocStorageMining = buildconstants.FilAllocStorageMining // Deprecated: Use buildconstants.FilAllocStorageMining instead -const FilecoinPrecision = uint64(1_000_000_000_000_000_000) -const FilReserved = uint64(300_000_000) +var FilecoinPrecision = buildconstants.FilecoinPrecision // Deprecated: Use buildconstants.FilecoinPrecision instead +var FilReserved = buildconstants.FilReserved // Deprecated: Use buildconstants.FilReserved instead var InitialRewardBalance *big.Int var InitialFilReserved *big.Int -// TODO: Move other important consts here - func init() { InitialRewardBalance = big.NewInt(int64(FilAllocStorageMining)) InitialRewardBalance = InitialRewardBalance.Mul(InitialRewardBalance, big.NewInt(int64(FilecoinPrecision))) InitialFilReserved = big.NewInt(int64(FilReserved)) InitialFilReserved = InitialFilReserved.Mul(InitialFilReserved, big.NewInt(int64(FilecoinPrecision))) - - if os.Getenv("LOTUS_ADDRESS_TYPE") == AddressMainnetEnvVar { - SetAddressNetwork(address.Mainnet) - } } // Sync -const BadBlockCacheSize = 1 << 15 +var BadBlockCacheSize = buildconstants.BadBlockCacheSize // Deprecated: Use buildconstants.BadBlockCacheSize instead -// assuming 4000 messages per round, this lets us not lose any messages across a -// 10 block reorg. -const BlsSignatureCacheSize = 40000 +var BlsSignatureCacheSize = buildconstants.BlsSignatureCacheSize // Deprecated: Use buildconstants.BlsSignatureCacheSize instead -// Size of signature verification cache -// 32k keeps the cache around 10MB in size, max -const VerifSigCacheSize = 32000 +var VerifSigCacheSize = buildconstants.VerifSigCacheSize // Deprecated: Use buildconstants.VerifSigCacheSize instead // /////// // Limits -// TODO: If this is gonna stay, it should move to specs-actors -const BlockMessageLimit = 10000 +var BlockMessageLimit = buildconstants.BlockMessageLimit // Deprecated: Use buildconstants.BlockMessageLimit instead -var BlockGasLimit = int64(10_000_000_000) -var BlockGasTarget = BlockGasLimit / 2 +var BlockGasLimit = buildconstants.BlockGasLimit // Deprecated: Use buildconstants.BlockGasLimit instead +var BlockGasTarget = buildconstants.BlockGasTarget // Deprecated: Use buildconstants.BlockGasTarget instead -const BaseFeeMaxChangeDenom = 8 // 12.5% -const InitialBaseFee = 100e6 -const MinimumBaseFee = 100 -const PackingEfficiencyNum = 4 -const PackingEfficiencyDenom = 5 +var BaseFeeMaxChangeDenom int64 = buildconstants.BaseFeeMaxChangeDenom // Deprecated: Use buildconstants.BaseFeeMaxChangeDenom instead +var InitialBaseFee int64 = buildconstants.InitialBaseFee // Deprecated: Use buildconstants.InitialBaseFee instead +var MinimumBaseFee int64 = buildconstants.MinimumBaseFee // Deprecated: Use buildconstants.MinimumBaseFee instead +var PackingEfficiencyNum int64 = buildconstants.PackingEfficiencyNum // Deprecated: Use buildconstants.PackingEfficiencyNum instead +var PackingEfficiencyDenom int64 = buildconstants.PackingEfficiencyDenom // Deprecated: Use buildconstants.PackingEfficiencyDenom instead + +var MinDealDuration = buildconstants.MinDealDuration // Deprecated: Use buildconstants.MinDealDuration instead +var MaxDealDuration = buildconstants.MaxDealDuration // Deprecated: Use buildconstants.MaxDealDuration instead + +const TestNetworkVersion = buildconstants.TestNetworkVersion // Deprecated: Use buildconstants.TestNetworkVersion instead + +func init() { + policy.SetSupportedProofTypes(buildconstants.SupportedProofTypes...) + policy.SetConsensusMinerMinPower(buildconstants.ConsensusMinerMinPower) + policy.SetMinVerifiedDealSize(buildconstants.MinVerifiedDealSize) + policy.SetPreCommitChallengeDelay(buildconstants.PreCommitChallengeDelay) +} diff --git a/build/params_testground_vals.go b/build/params_testground_vals.go new file mode 100644 index 00000000000..4503f76dcfb --- /dev/null +++ b/build/params_testground_vals.go @@ -0,0 +1,12 @@ +//go:build testground +// +build testground + +package build + +import ( + "github.com/filecoin-project/lotus/chain/actors/policy" +) + +// Actor consts +// TODO: pieceSize unused from actors +var MinDealDuration, MaxDealDuration = policy.DealDurationBounds(0) diff --git a/build/proof-params/parameters.go b/build/proof-params/parameters.go new file mode 100644 index 00000000000..1bef20f60f7 --- /dev/null +++ b/build/proof-params/parameters.go @@ -0,0 +1,19 @@ +package proofparams + +import ( + _ "embed" +) + +//go:embed parameters.json +var params []byte + +//go:embed srs-inner-product.json +var srs []byte + +func ParametersJSON() []byte { + return params +} + +func SrsJSON() []byte { + return srs +} diff --git a/build/version.go b/build/version.go index 8dd3a210a50..5ee2bf71d49 100644 --- a/build/version.go +++ b/build/version.go @@ -1,37 +1,37 @@ package build -import "os" +import ( + "os" + + "github.com/filecoin-project/lotus/build/buildconstants" +) type BuildVersion string var CurrentCommit string -var BuildType int - -const ( - BuildDefault = 0 - BuildMainnet = 0x1 - Build2k = 0x2 - BuildDebug = 0x3 - BuildCalibnet = 0x4 - BuildInteropnet = 0x5 - BuildButterflynet = 0x7 -) +var BuildType = buildconstants.BuildType // Deprecated: Use buildconstants.BuildType instead +var BuildMainnet = buildconstants.BuildMainnet // Deprecated: Use buildconstants.BuildMainnet instead +var Build2k = buildconstants.Build2k // Deprecated: Use buildconstants.Build2k instead +var BuildDebug = buildconstants.BuildDebug // Deprecated: Use buildconstants.BuildDebug instead +var BuildCalibnet = buildconstants.BuildCalibnet // Deprecated: Use buildconstants.BuildCalibnet instead +var BuildInteropnet = buildconstants.BuildInteropnet // Deprecated: Use buildconstants.BuildInteropnet instead +var BuildButterflynet = buildconstants.BuildButterflynet // Deprecated: Use buildconstants.BuildButterflynet instead func BuildTypeString() string { switch BuildType { - case BuildDefault: + case buildconstants.BuildDefault: return "" - case BuildMainnet: + case buildconstants.BuildMainnet: return "+mainnet" - case Build2k: + case buildconstants.Build2k: return "+2k" - case BuildDebug: + case buildconstants.BuildDebug: return "+debug" - case BuildCalibnet: + case buildconstants.BuildCalibnet: return "+calibnet" - case BuildInteropnet: + case buildconstants.BuildInteropnet: return "+interopnet" - case BuildButterflynet: + case buildconstants.BuildButterflynet: return "+butterflynet" default: return "+huh?" diff --git a/chain/beacon/drand/drand_test.go b/chain/beacon/drand/drand_test.go index c35c0da18f5..06ae8ae2c35 100644 --- a/chain/beacon/drand/drand_test.go +++ b/chain/beacon/drand/drand_test.go @@ -15,11 +15,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[build.DrandTestnet].Servers[0] - chainInfo := build.DrandConfigs[build.DrandTestnet].ChainInfoJSON + server := build.DrandConfigs[buildconstants.DrandTestnet].Servers[0] + chainInfo := build.DrandConfigs[buildconstants.DrandTestnet].ChainInfoJSON drandChain, err := dchain.InfoFromJSON(bytes.NewReader([]byte(chainInfo))) assert.NoError(t, err) @@ -37,7 +38,7 @@ func TestPrintGroupInfo(t *testing.T) { func TestMaxBeaconRoundForEpoch(t *testing.T) { todayTs := uint64(1652222222) - db, err := NewDrandBeacon(todayTs, build.BlockDelaySecs, nil, build.DrandConfigs[build.DrandTestnet]) + db, err := NewDrandBeacon(todayTs, build.BlockDelaySecs, nil, build.DrandConfigs[buildconstants.DrandTestnet]) assert.NoError(t, err) assert.True(t, db.IsChained()) mbr15 := db.MaxBeaconRoundForEpoch(network.Version15, 100) @@ -47,7 +48,7 @@ func TestMaxBeaconRoundForEpoch(t *testing.T) { func TestQuicknetIsChained(t *testing.T) { todayTs := uint64(1652222222) - db, err := NewDrandBeacon(todayTs, build.BlockDelaySecs, nil, build.DrandConfigs[build.DrandQuicknet]) + db, err := NewDrandBeacon(todayTs, build.BlockDelaySecs, nil, build.DrandConfigs[buildconstants.DrandQuicknet]) assert.NoError(t, err) assert.False(t, db.IsChained()) } diff --git a/chain/consensus/common.go b/chain/consensus/common.go index 49c38fee15a..9f832e69433 100644 --- a/chain/consensus/common.go +++ b/chain/consensus/common.go @@ -24,6 +24,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/build/buildconstants" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/stmgr" @@ -225,7 +226,7 @@ func checkBlockMessages(ctx context.Context, sm *stmgr.StateManager, cs *store.C // ValidForBlockInclusion checks if any single message does not exceed BlockGasLimit // So below is overflow safe sumGasLimit += m.GasLimit - if sumGasLimit > build.BlockGasLimit { + if sumGasLimit > buildconstants.BlockGasLimit { return xerrors.Errorf("block gas limit exceeded") } diff --git a/chain/consensus/compute_state.go b/chain/consensus/compute_state.go index a5e82a57ffe..b8fec248aca 100644 --- a/chain/consensus/compute_state.go +++ b/chain/consensus/compute_state.go @@ -27,6 +27,7 @@ import ( "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" "github.com/filecoin-project/lotus/chain/actors/builtin/reward" @@ -129,7 +130,7 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, Value: types.NewInt(0), GasFeeCap: types.NewInt(0), GasPremium: types.NewInt(0), - GasLimit: build.BlockGasLimit * 10000, // Make super sure this is never too little + GasLimit: buildconstants.BlockGasLimit * 10000, // Make super sure this is never too little Method: cron.Methods.EpochTick, Params: nil, } diff --git a/chain/lf3/manifest.go b/chain/lf3/manifest.go index f610778533e..da09173d687 100644 --- a/chain/lf3/manifest.go +++ b/chain/lf3/manifest.go @@ -10,6 +10,7 @@ import ( "github.com/filecoin-project/go-f3/manifest" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/node/modules/dtypes" @@ -20,7 +21,7 @@ func NewManifestProvider(nn dtypes.NetworkName, cs *store.ChainStore, sm *stmgr. m.NetworkName = gpbft.NetworkName(nn) m.ECDelayMultiplier = 2. m.ECPeriod = time.Duration(build.BlockDelaySecs) * time.Second - m.BootstrapEpoch = int64(build.F3BootstrapEpoch) + m.BootstrapEpoch = int64(buildconstants.F3BootstrapEpoch) m.ECFinality = int64(build.Finality) m.CommiteeLookback = 5 @@ -29,7 +30,7 @@ func NewManifestProvider(nn dtypes.NetworkName, cs *store.ChainStore, sm *stmgr. StateManager: sm, } - switch manifestServerID, err := peer.Decode(build.ManifestServerID); { + switch manifestServerID, err := peer.Decode(buildconstants.ManifestServerID); { case err != nil: log.Warnw("Cannot decode F3 manifest sever identity; falling back on static manifest provider", "err", err) return manifest.NewStaticManifestProvider(m) diff --git a/chain/messagepool/repub.go b/chain/messagepool/repub.go index a87d5e08a84..04f83f42300 100644 --- a/chain/messagepool/repub.go +++ b/chain/messagepool/repub.go @@ -11,6 +11,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/chain/messagepool/gasguess" "github.com/filecoin-project/lotus/chain/types" ) @@ -81,7 +82,7 @@ func (mp *MessagePool) republishPendingMessages(ctx context.Context) error { return chains[i].Before(chains[j]) }) - gasLimit := build.BlockGasLimit + gasLimit := buildconstants.BlockGasLimit minGas := int64(gasguess.MinGas) var msgs []*types.SignedMessage loop: diff --git a/chain/messagepool/selection.go b/chain/messagepool/selection.go index 0d0ed3cbab2..cfe68ed63ba 100644 --- a/chain/messagepool/selection.go +++ b/chain/messagepool/selection.go @@ -15,12 +15,13 @@ import ( "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/chain/messagepool/gasguess" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/vm" ) -var bigBlockGasLimit = big.NewInt(build.BlockGasLimit) +var bigBlockGasLimit = big.NewInt(buildconstants.BlockGasLimit) const MaxBlocks = 15 @@ -268,7 +269,7 @@ func (mp *MessagePool) selectMessagesOptimal(ctx context.Context, curTs, ts *typ nextChain := 0 partitions := make([][]*msgChain, MaxBlocks) for i := 0; i < MaxBlocks && nextChain < len(chains); i++ { - gasLimit := build.BlockGasLimit + gasLimit := buildconstants.BlockGasLimit msgLimit := build.BlockMessageLimit for nextChain < len(chains) { chain := chains[nextChain] @@ -600,7 +601,7 @@ func (mp *MessagePool) selectPriorityMessages(ctx context.Context, pending map[a mpCfg := mp.getConfig() result := &selectedMessages{ msgs: make([]*types.SignedMessage, 0, mpCfg.SizeLimitLow), - gasLimit: build.BlockGasLimit, + gasLimit: buildconstants.BlockGasLimit, blsLimit: cbg.MaxLength, secpLimit: cbg.MaxLength, } @@ -762,7 +763,7 @@ func (*MessagePool) getGasReward(msg *types.SignedMessage, baseFee types.BigInt) } func (*MessagePool) getGasPerf(gasReward *big.Int, gasLimit int64) float64 { - // gasPerf = gasReward * build.BlockGasLimit / gasLimit + // gasPerf = gasReward * buildconstants.BlockGasLimit / gasLimit a := new(big.Rat).SetInt(new(big.Int).Mul(gasReward, bigBlockGasLimit)) b := big.NewRat(1, gasLimit) c := new(big.Rat).Mul(a, b) @@ -822,7 +823,7 @@ func (mp *MessagePool) createMessageChains(actor address.Address, mset map[uint6 } gasLimit += m.Message.GasLimit - if gasLimit > build.BlockGasLimit { + if gasLimit > buildconstants.BlockGasLimit { break } diff --git a/chain/messagepool/selection_test.go b/chain/messagepool/selection_test.go index 5b46fadfbc6..9379675a672 100644 --- a/chain/messagepool/selection_test.go +++ b/chain/messagepool/selection_test.go @@ -26,6 +26,7 @@ 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/consensus/filcns" "github.com/filecoin-project/lotus/chain/messagepool/gasguess" "github.com/filecoin-project/lotus/chain/types" @@ -267,7 +268,7 @@ func TestMessageChains(t *testing.T) { // test6: one more message than what can fit in a block according to gas limit, with increasing // gasPerf; it should create a single chain with the max messages - maxMessages := int(build.BlockGasLimit / gasLimit) + maxMessages := int(buildconstants.BlockGasLimit / gasLimit) nMessages := maxMessages + 1 mset = make(map[uint64]*types.SignedMessage) @@ -571,7 +572,7 @@ func TestMessageSelectionTrimmingGas(t *testing.T) { tma.setBalance(a2, 1) // in FIL // make many small chains for the two actors - nMessages := int((build.BlockGasLimit / gasLimit) + 1) + nMessages := int((buildconstants.BlockGasLimit / gasLimit) + 1) for i := 0; i < nMessages; i++ { bias := (nMessages - i) / 3 m := makeTestMessage(w1, a1, a2, uint64(i), gasLimit, uint64(1+i%3+bias)) @@ -585,7 +586,7 @@ func TestMessageSelectionTrimmingGas(t *testing.T) { t.Fatal(err) } - expected := int(build.BlockGasLimit / gasLimit) + expected := int(buildconstants.BlockGasLimit / gasLimit) if len(msgs) != expected { t.Fatalf("expected %d messages, but got %d", expected, len(msgs)) } @@ -594,7 +595,7 @@ func TestMessageSelectionTrimmingGas(t *testing.T) { for _, m := range msgs { mGasLimit += m.Message.GasLimit } - if mGasLimit > build.BlockGasLimit { + if mGasLimit > buildconstants.BlockGasLimit { t.Fatal("selected messages gas limit exceeds block gas limit!") } @@ -641,7 +642,7 @@ func TestMessageSelectionTrimmingMsgsBasic(t *testing.T) { for _, m := range msgs { mGasLimit += m.Message.GasLimit } - if mGasLimit > build.BlockGasLimit { + if mGasLimit > buildconstants.BlockGasLimit { t.Fatal("selected messages gas limit exceeds block gas limit!") } @@ -700,7 +701,7 @@ func TestMessageSelectionTrimmingMsgsTwoSendersBasic(t *testing.T) { counts[m.Signature.Type]++ } - if mGasLimit > build.BlockGasLimit { + if mGasLimit > buildconstants.BlockGasLimit { t.Fatal("selected messages gas limit exceeds block gas limit!") } @@ -781,7 +782,7 @@ func TestMessageSelectionTrimmingMsgsTwoSendersAdvanced(t *testing.T) { counts[m.Signature.Type]++ } - if mGasLimit > build.BlockGasLimit { + if mGasLimit > buildconstants.BlockGasLimit { t.Fatal("selected messages gas limit exceeds block gas limit!") } @@ -912,7 +913,7 @@ func TestPriorityMessageSelection2(t *testing.T) { mp.cfg.PriorityAddrs = []address.Address{a1} - nMessages := int(2 * build.BlockGasLimit / gasLimit) + nMessages := int(2 * buildconstants.BlockGasLimit / gasLimit) for i := 0; i < nMessages; i++ { bias := (nMessages - i) / 3 m := makeTestMessage(w1, a1, a2, uint64(i), gasLimit, uint64(1+i%3+bias)) @@ -926,7 +927,7 @@ func TestPriorityMessageSelection2(t *testing.T) { t.Fatal(err) } - expectedMsgs := int(build.BlockGasLimit / gasLimit) + expectedMsgs := int(buildconstants.BlockGasLimit / gasLimit) if len(msgs) != expectedMsgs { t.Fatalf("expected %d messages but got %d", expectedMsgs, len(msgs)) } @@ -1077,7 +1078,7 @@ func TestOptimalMessageSelection1(t *testing.T) { tma.setBalance(a1, 1) // in FIL tma.setBalance(a2, 1) // in FIL - nMessages := int(10 * build.BlockGasLimit / gasLimit) + nMessages := int(10 * buildconstants.BlockGasLimit / gasLimit) for i := 0; i < nMessages; i++ { bias := (nMessages - i) / 3 m := makeTestMessage(w1, a1, a2, uint64(i), gasLimit, uint64(1+i%3+bias)) @@ -1089,7 +1090,7 @@ func TestOptimalMessageSelection1(t *testing.T) { t.Fatal(err) } - expectedMsgs := int(build.BlockGasLimit / gasLimit) + expectedMsgs := int(buildconstants.BlockGasLimit / gasLimit) if len(msgs) != expectedMsgs { t.Fatalf("expected %d messages, but got %d", expectedMsgs, len(msgs)) } @@ -1146,7 +1147,7 @@ func TestOptimalMessageSelection2(t *testing.T) { tma.setBalance(a1, 1) // in FIL tma.setBalance(a2, 1) // in FIL - nMessages := int(5 * build.BlockGasLimit / gasLimit) + nMessages := int(5 * buildconstants.BlockGasLimit / gasLimit) for i := 0; i < nMessages; i++ { bias := (nMessages - i) / 3 m := makeTestMessage(w1, a1, a2, uint64(i), gasLimit, uint64(200000+i%3+bias)) @@ -1160,7 +1161,7 @@ func TestOptimalMessageSelection2(t *testing.T) { t.Fatal(err) } - expectedMsgs := int(build.BlockGasLimit / gasLimit) + expectedMsgs := int(buildconstants.BlockGasLimit / gasLimit) if len(msgs) != expectedMsgs { t.Fatalf("expected %d messages, but got %d", expectedMsgs, len(msgs)) } @@ -1227,7 +1228,7 @@ func TestOptimalMessageSelection3(t *testing.T) { tma.setBalance(a, 1) // in FIL } - nMessages := int(build.BlockGasLimit/gasLimit) + 1 + nMessages := int(buildconstants.BlockGasLimit/gasLimit) + 1 for i := 0; i < nMessages; i++ { for j := 0; j < nActors; j++ { premium := 500000 + 10000*(nActors-j) + (nMessages+2-i)/(30*nActors) + i%3 @@ -1241,7 +1242,7 @@ func TestOptimalMessageSelection3(t *testing.T) { t.Fatal(err) } - expectedMsgs := int(build.BlockGasLimit / gasLimit) + expectedMsgs := int(buildconstants.BlockGasLimit / gasLimit) if len(msgs) != expectedMsgs { t.Fatalf("expected %d messages, but got %d", expectedMsgs, len(msgs)) } @@ -1308,7 +1309,7 @@ func testCompetitiveMessageSelection(t *testing.T, rng *rand.Rand, getPremium fu tma.setBalance(a, 1) // in FIL } - nMessages := 10 * int(build.BlockGasLimit/gasLimit) + nMessages := 10 * int(buildconstants.BlockGasLimit/gasLimit) t.Log("nMessages", nMessages) nonces := make([]uint64, nActors) for i := 0; i < nMessages; i++ { @@ -1598,7 +1599,7 @@ readLoop: mp, tma := makeTestMpool() - block := tma.nextBlockWithHeight(build.UpgradeBreezeHeight + 10) + block := tma.nextBlockWithHeight(uint64(build.UpgradeBreezeHeight + 10)) ts := mock.TipSet(block) tma.applyBlock(t, block) @@ -1618,7 +1619,7 @@ readLoop: } // do message selection and check block packing - minGasLimit := int64(0.9 * float64(build.BlockGasLimit)) + minGasLimit := int64(0.9 * float64(buildconstants.BlockGasLimit)) // greedy first selected, err := mp.SelectMessages(context.Background(), ts, 1.0) @@ -1794,7 +1795,7 @@ readLoop: } // do message selection and check block packing - minGasLimit := int64(0.9 * float64(build.BlockGasLimit)) + minGasLimit := int64(0.9 * float64(buildconstants.BlockGasLimit)) // greedy first start := time.Now() diff --git a/chain/stmgr/call.go b/chain/stmgr/call.go index 7f2a57a6112..fe88630e55a 100644 --- a/chain/stmgr/call.go +++ b/chain/stmgr/call.go @@ -18,7 +18,7 @@ import ( "github.com/filecoin-project/lotus/api" "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/rand" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" @@ -44,7 +44,7 @@ func (sm *StateManager) Call(ctx context.Context, msg *types.Message, ts *types. msg = &msgCopy if msg.GasLimit == 0 { - msg.GasLimit = build.BlockGasLimit + msg.GasLimit = buildconstants.BlockGasLimit } if msg.GasFeeCap == types.EmptyInt { msg.GasFeeCap = types.NewInt(0) diff --git a/chain/store/basefee.go b/chain/store/basefee.go index 3b6af5c0716..e5c8049efa0 100644 --- a/chain/store/basefee.go +++ b/chain/store/basefee.go @@ -10,11 +10,12 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/chain/types" ) func ComputeNextBaseFee(baseFee types.BigInt, gasLimitUsed int64, noOfBlocks int, epoch abi.ChainEpoch) types.BigInt { - // deta := gasLimitUsed/noOfBlocks - build.BlockGasTarget + // deta := gasLimitUsed/noOfBlocks - buildconstants.BlockGasTarget // change := baseFee * deta / BlockGasTarget // nextBaseFee = baseFee + change // nextBaseFee = max(nextBaseFee, build.MinimumBaseFee) @@ -22,22 +23,22 @@ func ComputeNextBaseFee(baseFee types.BigInt, gasLimitUsed int64, noOfBlocks int var delta int64 if epoch > build.UpgradeSmokeHeight { delta = gasLimitUsed / int64(noOfBlocks) - delta -= build.BlockGasTarget + delta -= buildconstants.BlockGasTarget } else { delta = build.PackingEfficiencyDenom * gasLimitUsed / (int64(noOfBlocks) * build.PackingEfficiencyNum) - delta -= build.BlockGasTarget + delta -= buildconstants.BlockGasTarget } // cap change at 12.5% (BaseFeeMaxChangeDenom) by capping delta - if delta > build.BlockGasTarget { - delta = build.BlockGasTarget + if delta > buildconstants.BlockGasTarget { + delta = buildconstants.BlockGasTarget } - if delta < -build.BlockGasTarget { - delta = -build.BlockGasTarget + if delta < -buildconstants.BlockGasTarget { + delta = -buildconstants.BlockGasTarget } change := big.Mul(baseFee, big.NewInt(delta)) - change = big.Div(change, big.NewInt(build.BlockGasTarget)) + change = big.Div(change, big.NewInt(buildconstants.BlockGasTarget)) change = big.Div(change, big.NewInt(build.BaseFeeMaxChangeDenom)) nextBaseFee := big.Add(baseFee, change) diff --git a/chain/store/basefee_test.go b/chain/store/basefee_test.go index 8dd61f709e0..fa22f7d042c 100644 --- a/chain/store/basefee_test.go +++ b/chain/store/basefee_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/chain/types" ) @@ -22,10 +23,10 @@ func TestBaseFee(t *testing.T) { }{ {100e6, 0, 1, 87.5e6, 87.5e6}, {100e6, 0, 5, 87.5e6, 87.5e6}, - {100e6, build.BlockGasTarget, 1, 103.125e6, 100e6}, - {100e6, build.BlockGasTarget * 2, 2, 103.125e6, 100e6}, - {100e6, build.BlockGasLimit * 2, 2, 112.5e6, 112.5e6}, - {100e6, (build.BlockGasLimit * 15) / 10, 2, 110937500, 106.250e6}, + {100e6, buildconstants.BlockGasTarget, 1, 103.125e6, 100e6}, + {100e6, buildconstants.BlockGasTarget * 2, 2, 103.125e6, 100e6}, + {100e6, buildconstants.BlockGasLimit * 2, 2, 112.5e6, 112.5e6}, + {100e6, (buildconstants.BlockGasLimit * 15) / 10, 2, 110937500, 106.250e6}, } for _, test := range tests { diff --git a/chain/types/bigint.go b/chain/types/bigint.go index 72ef5212862..ca274b7e11f 100644 --- a/chain/types/bigint.go +++ b/chain/types/bigint.go @@ -6,12 +6,12 @@ import ( big2 "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" ) const BigIntMaxSerializedLen = 128 // is this big enough? or too big? -var TotalFilecoinInt = FromFil(build.FilBase) +var TotalFilecoinInt = FromFil(buildconstants.FilBase) var EmptyInt = BigInt{} @@ -22,7 +22,7 @@ func NewInt(i uint64) BigInt { } func FromFil(i uint64) BigInt { - return BigMul(NewInt(i), NewInt(build.FilecoinPrecision)) + return BigMul(NewInt(i), NewInt(buildconstants.FilecoinPrecision)) } func BigFromBytes(b []byte) BigInt { diff --git a/chain/types/electionproof.go b/chain/types/electionproof.go index f3168becb8f..1d447e4cfcf 100644 --- a/chain/types/electionproof.go +++ b/chain/types/electionproof.go @@ -5,7 +5,7 @@ import ( "github.com/minio/blake2b-simd" - "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" ) type ElectionProof struct { @@ -100,14 +100,14 @@ func polyval(p []*big.Int, x *big.Int) *big.Int { // computes lambda in Q.256 func lambda(power, totalPower *big.Int) *big.Int { - blocksPerEpoch := NewInt(build.BlocksPerEpoch) + blocksPerEpoch := NewInt(buildconstants.BlocksPerEpoch) lam := new(big.Int).Mul(power, blocksPerEpoch.Int) // Q.0 lam = lam.Lsh(lam, precision) // Q.256 lam = lam.Div(lam /* Q.256 */, totalPower /* Q.0 */) // Q.256 return lam } -var MaxWinCount = 3 * int64(build.BlocksPerEpoch) +var MaxWinCount = 3 * int64(buildconstants.BlocksPerEpoch) type poiss struct { lam *big.Int diff --git a/chain/types/ethtypes/eth_types.go b/chain/types/ethtypes/eth_types.go index 29fe5d9e3e6..c0e1f98d721 100644 --- a/chain/types/ethtypes/eth_types.go +++ b/chain/types/ethtypes/eth_types.go @@ -22,7 +22,7 @@ import ( "github.com/filecoin-project/go-state-types/big" builtintypes "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/lib/must" ) @@ -219,7 +219,7 @@ func NewEthBlock(hasTransactions bool, tipsetLen int) EthBlock { Extradata: []byte{}, MixHash: EmptyEthHash, Nonce: EmptyEthNonce, - GasLimit: EthUint64(build.BlockGasLimit * int64(tipsetLen)), + GasLimit: EthUint64(buildconstants.BlockGasLimit * int64(tipsetLen)), Uncles: []EthHash{}, Transactions: []interface{}{}, } diff --git a/chain/types/fil.go b/chain/types/fil.go index 227e9442fbd..3d87545ef6c 100644 --- a/chain/types/fil.go +++ b/chain/types/fil.go @@ -8,7 +8,7 @@ import ( "github.com/invopop/jsonschema" - "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" ) type FIL BigInt @@ -21,7 +21,7 @@ func (f FIL) String() string { } func (f FIL) Unitless() string { - r := new(big.Rat).SetFrac(f.Int, big.NewInt(int64(build.FilecoinPrecision))) + r := new(big.Rat).SetFrac(f.Int, big.NewInt(int64(buildconstants.FilecoinPrecision))) if r.Sign() == 0 { return "0" } @@ -117,7 +117,7 @@ func ParseFIL(s string) (FIL, error) { } if !attofil { - r = r.Mul(r, big.NewRat(int64(build.FilecoinPrecision), 1)) + r = r.Mul(r, big.NewRat(int64(buildconstants.FilecoinPrecision), 1)) } if !r.IsInt() { diff --git a/chain/types/message.go b/chain/types/message.go index 473289ead45..2f3606dbe47 100644 --- a/chain/types/message.go +++ b/chain/types/message.go @@ -14,7 +14,7 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" ) const MessageVersion = 0 @@ -155,7 +155,7 @@ func (m *Message) ValidForBlockInclusion(minGas int64, version network.Version) return xerrors.New("'To' address cannot be empty") } - if m.To == build.ZeroAddress && version >= network.Version7 { + if m.To == buildconstants.ZeroAddress && version >= network.Version7 { return xerrors.New("invalid 'To' address") } @@ -203,8 +203,8 @@ func (m *Message) ValidForBlockInclusion(minGas int64, version network.Version) return xerrors.New("'GasFeeCap' less than 'GasPremium'") } - if m.GasLimit > build.BlockGasLimit { - return xerrors.Errorf("'GasLimit' field cannot be greater than a block's gas limit (%d > %d)", m.GasLimit, build.BlockGasLimit) + if m.GasLimit > buildconstants.BlockGasLimit { + return xerrors.Errorf("'GasLimit' field cannot be greater than a block's gas limit (%d > %d)", m.GasLimit, buildconstants.BlockGasLimit) } if m.GasLimit <= 0 { diff --git a/chain/types/mock/chain.go b/chain/types/mock/chain.go index dcbcd85362c..e4e80890bce 100644 --- a/chain/types/mock/chain.go +++ b/chain/types/mock/chain.go @@ -12,7 +12,7 @@ import ( "github.com/filecoin-project/go-state-types/crypto" "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/types" "github.com/filecoin-project/lotus/chain/wallet" ) @@ -58,7 +58,7 @@ func MkBlock(parents *types.TipSet, weightInc uint64, ticketNonce uint64) *types if parents != nil { pcids = parents.Cids() height = parents.Height() + 1 - timestamp = parents.MinTimestamp() + build.BlockDelaySecs + timestamp = parents.MinTimestamp() + buildconstants.BlockDelaySecs weight = types.BigAdd(parents.Blocks()[0].ParentWeight, weight) } @@ -79,7 +79,7 @@ func MkBlock(parents *types.TipSet, weightInc uint64, ticketNonce uint64) *types Timestamp: timestamp, ParentStateRoot: pstateRoot, BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("boo! im a signature")}, - ParentBaseFee: types.NewInt(uint64(build.MinimumBaseFee)), + ParentBaseFee: types.NewInt(uint64(buildconstants.MinimumBaseFee)), } } diff --git a/chain/types_test.go b/chain/types_test.go index 0fb3992146e..692c932a575 100644 --- a/chain/types_test.go +++ b/chain/types_test.go @@ -8,7 +8,7 @@ import ( "github.com/filecoin-project/go-address" - "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/chain/types" ) @@ -43,7 +43,7 @@ func TestSignedMessageJsonRoundtrip(t *testing.T) { func TestAddressType(t *testing.T) { //stm: @CHAIN_TYPES_ADDRESS_PREFIX_001 - build.SetAddressNetwork(address.Testnet) + buildconstants.SetAddressNetwork(address.Testnet) addr, err := makeRandomAddress() if err != nil { t.Fatal(err) @@ -53,7 +53,7 @@ func TestAddressType(t *testing.T) { t.Fatalf("address should start with %s", address.TestnetPrefix) } - build.SetAddressNetwork(address.Mainnet) + buildconstants.SetAddressNetwork(address.Mainnet) addr, err = makeRandomAddress() if err != nil { t.Fatal(err) diff --git a/chain/vm/gas.go b/chain/vm/gas.go index cb0c5def94d..4bd63bf9c08 100644 --- a/chain/vm/gas.go +++ b/chain/vm/gas.go @@ -135,7 +135,7 @@ var Prices = map[abi.ChainEpoch]Pricelist{ verifyPostDiscount: true, verifyConsensusFault: 495422, }, - abi.ChainEpoch(build.UpgradeCalicoHeight): &pricelistV0{ + build.UpgradeCalicoHeight: &pricelistV0{ computeGasMulti: 1, storageGasMulti: 1300, diff --git a/cli/chain.go b/cli/chain.go index c0d54fd6382..d9f6dc0bd96 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -37,6 +37,7 @@ import ( lapi "github.com/filecoin-project/lotus/api" "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" "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/types" @@ -631,7 +632,7 @@ var ChainListCmd = &cli.Command{ tss = otss for i, ts := range tss { pbf := ts.Blocks()[0].ParentBaseFee - afmt.Printf("%d: %d blocks (baseFee: %s -> maxFee: %s)\n", ts.Height(), len(ts.Blocks()), ts.Blocks()[0].ParentBaseFee, types.FIL(types.BigMul(pbf, types.NewInt(uint64(build.BlockGasLimit))))) + afmt.Printf("%d: %d blocks (baseFee: %s -> maxFee: %s)\n", ts.Height(), len(ts.Blocks()), ts.Blocks()[0].ParentBaseFee, types.FIL(types.BigMul(pbf, types.NewInt(uint64(buildconstants.BlockGasLimit))))) for _, b := range ts.Blocks() { msgs, err := api.ChainGetBlockMessages(ctx, b.Cid()) @@ -657,7 +658,7 @@ var ChainListCmd = &cli.Command{ avgpremium = big.Div(psum, big.NewInt(int64(lenmsgs))) } - afmt.Printf("\t%s: \t%d msgs, gasLimit: %d / %d (%0.2f%%), avgPremium: %s\n", b.Miner, len(msgs.BlsMessages)+len(msgs.SecpkMessages), limitSum, build.BlockGasLimit, 100*float64(limitSum)/float64(build.BlockGasLimit), avgpremium) + afmt.Printf("\t%s: \t%d msgs, gasLimit: %d / %d (%0.2f%%), avgPremium: %s\n", b.Miner, len(msgs.BlsMessages)+len(msgs.SecpkMessages), limitSum, buildconstants.BlockGasLimit, 100*float64(limitSum)/float64(buildconstants.BlockGasLimit), avgpremium) } if i < len(tss)-1 { msgs, err := api.ChainGetParentMessages(ctx, tss[i+1].Blocks()[0].Cid()) @@ -680,7 +681,7 @@ var ChainListCmd = &cli.Command{ } gasEfficiency := 100 * float64(gasUsed) / float64(limitSum) - gasCapacity := 100 * float64(limitSum) / float64(build.BlockGasLimit) + gasCapacity := 100 * float64(limitSum) / float64(buildconstants.BlockGasLimit) afmt.Printf("\ttipset: \t%d msgs, %d (%0.2f%%) / %d (%0.2f%%)\n", len(msgs), gasUsed, gasEfficiency, limitSum, gasCapacity) } diff --git a/cli/mpool.go b/cli/mpool.go index f38a900fb7b..eb05e3e81e5 100644 --- a/cli/mpool.go +++ b/cli/mpool.go @@ -16,7 +16,7 @@ import ( "github.com/filecoin-project/go-state-types/big" lapi "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/messagepool" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/config" @@ -712,7 +712,7 @@ var MpoolGasPerfCmd = &cli.Command{ baseFee := ts.Blocks()[0].ParentBaseFee - bigBlockGasLimit := big.NewInt(build.BlockGasLimit) + bigBlockGasLimit := big.NewInt(buildconstants.BlockGasLimit) getGasReward := func(msg *types.SignedMessage) big.Int { maxPremium := types.BigSub(msg.Message.GasFeeCap, baseFee) @@ -723,7 +723,7 @@ var MpoolGasPerfCmd = &cli.Command{ } getGasPerf := func(gasReward big.Int, gasLimit int64) float64 { - // gasPerf = gasReward * build.BlockGasLimit / gasLimit + // gasPerf = gasReward * buildconstants.BlockGasLimit / gasLimit a := new(stdbig.Rat).SetInt(new(stdbig.Int).Mul(gasReward.Int, bigBlockGasLimit.Int)) b := stdbig.NewRat(1, gasLimit) c := new(stdbig.Rat).Mul(a, b) diff --git a/cli/spcli/actor.go b/cli/spcli/actor.go index d8d35543814..0ff59d6e0a4 100644 --- a/cli/spcli/actor.go +++ b/cli/spcli/actor.go @@ -2,7 +2,6 @@ package spcli import ( "bytes" - "context" "fmt" "strconv" @@ -21,19 +20,16 @@ import ( "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/network" - power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power" - power6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/power" lapi "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/api/v1api" "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" - "github.com/filecoin-project/lotus/chain/actors/builtin/power" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" + "github.com/filecoin-project/lotus/cli/spcli/createminer" cliutil "github.com/filecoin-project/lotus/cli/util" "github.com/filecoin-project/lotus/node/impl" ) @@ -1320,119 +1316,10 @@ var ActorNewMinerCmd = &cli.Command{ } ssize := abi.SectorSize(sectorSizeInt) - _, err = CreateStorageMiner(ctx, full, owner, worker, sender, ssize, cctx.Uint64("confidence")) + _, err = createminer.CreateStorageMiner(ctx, full, owner, worker, sender, ssize, cctx.Uint64("confidence")) if err != nil { return err } return nil }, } - -func CreateStorageMiner(ctx context.Context, fullNode v1api.FullNode, owner, worker, sender address.Address, ssize abi.SectorSize, confidence uint64) (address.Address, error) { - // make sure the sender account exists on chain - _, err := fullNode.StateLookupID(ctx, owner, types.EmptyTSK) - if err != nil { - return address.Undef, xerrors.Errorf("sender must exist on chain: %w", err) - } - - // make sure the worker account exists on chain - _, err = fullNode.StateLookupID(ctx, worker, types.EmptyTSK) - if err != nil { - signed, err := fullNode.MpoolPushMessage(ctx, &types.Message{ - From: sender, - To: worker, - Value: types.NewInt(0), - }, nil) - if err != nil { - return address.Undef, xerrors.Errorf("push worker init: %w", err) - } - - fmt.Printf("Initializing worker account %s, message: %s\n", worker, signed.Cid()) - fmt.Println("Waiting for confirmation") - - mw, err := fullNode.StateWaitMsg(ctx, signed.Cid(), confidence, 2000, true) - if err != nil { - return address.Undef, xerrors.Errorf("waiting for worker init: %w", err) - } - if mw.Receipt.ExitCode != 0 { - return address.Undef, xerrors.Errorf("initializing worker account failed: exit code %d", mw.Receipt.ExitCode) - } - } - - // make sure the owner account exists on chain - _, err = fullNode.StateLookupID(ctx, owner, types.EmptyTSK) - if err != nil { - signed, err := fullNode.MpoolPushMessage(ctx, &types.Message{ - From: sender, - To: owner, - Value: types.NewInt(0), - }, nil) - if err != nil { - return address.Undef, xerrors.Errorf("push owner init: %w", err) - } - - fmt.Printf("Initializing owner account %s, message: %s\n", worker, signed.Cid()) - fmt.Println("Waiting for confirmation") - - mw, err := fullNode.StateWaitMsg(ctx, signed.Cid(), confidence, 2000, true) - if err != nil { - return address.Undef, xerrors.Errorf("waiting for owner init: %w", err) - } - if mw.Receipt.ExitCode != 0 { - return address.Undef, xerrors.Errorf("initializing owner account failed: exit code %d", mw.Receipt.ExitCode) - } - } - - // Note: the correct thing to do would be to call SealProofTypeFromSectorSize if actors version is v3 or later, but this still works - nv, err := fullNode.StateNetworkVersion(ctx, types.EmptyTSK) - if err != nil { - return address.Undef, xerrors.Errorf("failed to get network version: %w", err) - } - spt, err := lminer.WindowPoStProofTypeFromSectorSize(ssize, nv) - if err != nil { - return address.Undef, xerrors.Errorf("getting post proof type: %w", err) - } - - params, err := actors.SerializeParams(&power6.CreateMinerParams{ - Owner: owner, - Worker: worker, - WindowPoStProofType: spt, - }) - if err != nil { - return address.Undef, err - } - - createStorageMinerMsg := &types.Message{ - To: power.Address, - From: sender, - Value: big.Zero(), - - Method: power.Methods.CreateMiner, - Params: params, - } - - signed, err := fullNode.MpoolPushMessage(ctx, createStorageMinerMsg, nil) - if err != nil { - return address.Undef, xerrors.Errorf("pushing createMiner message: %w", err) - } - - fmt.Printf("Pushed CreateMiner message: %s\n", signed.Cid()) - fmt.Println("Waiting for confirmation") - - mw, err := fullNode.StateWaitMsg(ctx, signed.Cid(), confidence, 2000, true) - if err != nil { - return address.Undef, xerrors.Errorf("waiting for createMiner message: %w", err) - } - - if mw.Receipt.ExitCode != 0 { - return address.Undef, xerrors.Errorf("create miner failed: exit code %d", mw.Receipt.ExitCode) - } - - var retval power2.CreateMinerReturn - if err := retval.UnmarshalCBOR(bytes.NewReader(mw.Receipt.Return)); err != nil { - return address.Undef, err - } - - fmt.Printf("New miners address is: %s (%s)\n", retval.IDAddress, retval.RobustAddress) - return retval.IDAddress, nil -} diff --git a/cli/spcli/createminer/create_miner.go b/cli/spcli/createminer/create_miner.go new file mode 100644 index 00000000000..f92369a832e --- /dev/null +++ b/cli/spcli/createminer/create_miner.go @@ -0,0 +1,130 @@ +package createminer + +import ( + "bytes" + "context" + "fmt" + + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/big" + power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power" + power6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/power" + + "github.com/filecoin-project/lotus/api/v1api" + "github.com/filecoin-project/lotus/chain/actors" + lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/lotus/chain/actors/builtin/power" + "github.com/filecoin-project/lotus/chain/types" +) + +func CreateStorageMiner(ctx context.Context, fullNode v1api.FullNode, owner, worker, sender address.Address, ssize abi.SectorSize, confidence uint64) (address.Address, error) { + // make sure the sender account exists on chain + _, err := fullNode.StateLookupID(ctx, owner, types.EmptyTSK) + if err != nil { + return address.Undef, xerrors.Errorf("sender must exist on chain: %w", err) + } + + // make sure the worker account exists on chain + _, err = fullNode.StateLookupID(ctx, worker, types.EmptyTSK) + if err != nil { + signed, err := fullNode.MpoolPushMessage(ctx, &types.Message{ + From: sender, + To: worker, + Value: types.NewInt(0), + }, nil) + if err != nil { + return address.Undef, xerrors.Errorf("push worker init: %w", err) + } + + fmt.Printf("Initializing worker account %s, message: %s\n", worker, signed.Cid()) + fmt.Println("Waiting for confirmation") + + mw, err := fullNode.StateWaitMsg(ctx, signed.Cid(), confidence, 2000, true) + if err != nil { + return address.Undef, xerrors.Errorf("waiting for worker init: %w", err) + } + if mw.Receipt.ExitCode != 0 { + return address.Undef, xerrors.Errorf("initializing worker account failed: exit code %d", mw.Receipt.ExitCode) + } + } + + // make sure the owner account exists on chain + _, err = fullNode.StateLookupID(ctx, owner, types.EmptyTSK) + if err != nil { + signed, err := fullNode.MpoolPushMessage(ctx, &types.Message{ + From: sender, + To: owner, + Value: types.NewInt(0), + }, nil) + if err != nil { + return address.Undef, xerrors.Errorf("push owner init: %w", err) + } + + fmt.Printf("Initializing owner account %s, message: %s\n", worker, signed.Cid()) + fmt.Println("Waiting for confirmation") + + mw, err := fullNode.StateWaitMsg(ctx, signed.Cid(), confidence, 2000, true) + if err != nil { + return address.Undef, xerrors.Errorf("waiting for owner init: %w", err) + } + if mw.Receipt.ExitCode != 0 { + return address.Undef, xerrors.Errorf("initializing owner account failed: exit code %d", mw.Receipt.ExitCode) + } + } + + // Note: the correct thing to do would be to call SealProofTypeFromSectorSize if actors version is v3 or later, but this still works + nv, err := fullNode.StateNetworkVersion(ctx, types.EmptyTSK) + if err != nil { + return address.Undef, xerrors.Errorf("failed to get network version: %w", err) + } + spt, err := lminer.WindowPoStProofTypeFromSectorSize(ssize, nv) + if err != nil { + return address.Undef, xerrors.Errorf("getting post proof type: %w", err) + } + + params, err := actors.SerializeParams(&power6.CreateMinerParams{ + Owner: owner, + Worker: worker, + WindowPoStProofType: spt, + }) + if err != nil { + return address.Undef, err + } + + createStorageMinerMsg := &types.Message{ + To: power.Address, + From: sender, + Value: big.Zero(), + + Method: power.Methods.CreateMiner, + Params: params, + } + + signed, err := fullNode.MpoolPushMessage(ctx, createStorageMinerMsg, nil) + if err != nil { + return address.Undef, xerrors.Errorf("pushing createMiner message: %w", err) + } + + fmt.Printf("Pushed CreateMiner message: %s\n", signed.Cid()) + fmt.Println("Waiting for confirmation") + + mw, err := fullNode.StateWaitMsg(ctx, signed.Cid(), confidence, 2000, true) + if err != nil { + return address.Undef, xerrors.Errorf("waiting for createMiner message: %w", err) + } + + if mw.Receipt.ExitCode != 0 { + return address.Undef, xerrors.Errorf("create miner failed: exit code %d", mw.Receipt.ExitCode) + } + + var retval power2.CreateMinerReturn + if err := retval.UnmarshalCBOR(bytes.NewReader(mw.Receipt.Return)); err != nil { + return address.Undef, err + } + + fmt.Printf("New miners address is: %s (%s)\n", retval.IDAddress, retval.RobustAddress) + return retval.IDAddress, nil +} diff --git a/cli/util/epoch.go b/cli/util/epoch.go index 81c92a7e3ed..55d385c8a52 100644 --- a/cli/util/epoch.go +++ b/cli/util/epoch.go @@ -8,18 +8,18 @@ import ( "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/chain/types" ) func EpochTime(curr, e abi.ChainEpoch) string { switch { case curr > e: - return fmt.Sprintf("%d (%s ago)", e, durafmt.Parse(time.Second*time.Duration(int64(build.BlockDelaySecs)*int64(curr-e))).LimitFirstN(2)) + return fmt.Sprintf("%d (%s ago)", e, durafmt.Parse(time.Second*time.Duration(int64(buildconstants.BlockDelaySecs)*int64(curr-e))).LimitFirstN(2)) case curr == e: return fmt.Sprintf("%d (now)", e) case curr < e: - return fmt.Sprintf("%d (in %s)", e, durafmt.Parse(time.Second*time.Duration(int64(build.BlockDelaySecs)*int64(e-curr))).LimitFirstN(2)) + return fmt.Sprintf("%d (in %s)", e, durafmt.Parse(time.Second*time.Duration(int64(buildconstants.BlockDelaySecs)*int64(e-curr))).LimitFirstN(2)) } panic("math broke") @@ -31,15 +31,15 @@ func EpochTime(curr, e abi.ChainEpoch) string { // // Example output: `1944975 (01 Jul 22 08:07 CEST, 10 hours 29 minutes ago)` func EpochTimeTs(curr, e abi.ChainEpoch, ts *types.TipSet) string { - timeStr := time.Unix(int64(ts.MinTimestamp()+(uint64(e-ts.Height())*build.BlockDelaySecs)), 0).Format(time.RFC822) + timeStr := time.Unix(int64(ts.MinTimestamp()+(uint64(e-ts.Height())*buildconstants.BlockDelaySecs)), 0).Format(time.RFC822) switch { case curr > e: - return fmt.Sprintf("%d (%s, %s ago)", e, timeStr, durafmt.Parse(time.Second*time.Duration(int64(build.BlockDelaySecs)*int64(curr-e))).LimitFirstN(2)) + return fmt.Sprintf("%d (%s, %s ago)", e, timeStr, durafmt.Parse(time.Second*time.Duration(int64(buildconstants.BlockDelaySecs)*int64(curr-e))).LimitFirstN(2)) case curr == e: return fmt.Sprintf("%d (%s, now)", e, timeStr) case curr < e: - return fmt.Sprintf("%d (%s, in %s)", e, timeStr, durafmt.Parse(time.Second*time.Duration(int64(build.BlockDelaySecs)*int64(e-curr))).LimitFirstN(2)) + return fmt.Sprintf("%d (%s, in %s)", e, timeStr, durafmt.Parse(time.Second*time.Duration(int64(buildconstants.BlockDelaySecs)*int64(e-curr))).LimitFirstN(2)) } panic("math broke") diff --git a/cmd/lotus-shed/gas-estimation.go b/cmd/lotus-shed/gas-estimation.go index 5dc048f562c..31b5384d5ce 100644 --- a/cmd/lotus-shed/gas-estimation.go +++ b/cmd/lotus-shed/gas-estimation.go @@ -16,6 +16,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/drand" "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" @@ -118,7 +119,7 @@ var gasTraceCmd = &cli.Command{ } // Set to block limit so message will not run out of gas - msg.GasLimit = build.BlockGasLimit + msg.GasLimit = buildconstants.BlockGasLimit err = cs.Load(ctx) if err != nil { diff --git a/cmd/lotus-shed/mpool.go b/cmd/lotus-shed/mpool.go index 6b210bbc10e..0e24392ae5d 100644 --- a/cmd/lotus-shed/mpool.go +++ b/cmd/lotus-shed/mpool.go @@ -6,7 +6,7 @@ import ( "github.com/urfave/cli/v2" - "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" ) @@ -79,7 +79,7 @@ var minerSelectMsgsCmd = &cli.Command{ fmt.Printf("Message selection took %s\n", duration) fmt.Printf("Size of the mempool: %d\n", mpoolSize) fmt.Println("selected messages: ", len(msgs)) - fmt.Printf("total gas limit of selected messages: %d / %d (%0.2f%%)\n", totalGas, build.BlockGasLimit, 100*float64(totalGas)/float64(build.BlockGasLimit)) + fmt.Printf("total gas limit of selected messages: %d / %d (%0.2f%%)\n", totalGas, buildconstants.BlockGasLimit, 100*float64(totalGas)/float64(buildconstants.BlockGasLimit)) return nil }, } diff --git a/cmd/lotus-sim/simulation/blockbuilder/blockbuilder.go b/cmd/lotus-sim/simulation/blockbuilder/blockbuilder.go index 273ab337c1b..58468533a57 100644 --- a/cmd/lotus-sim/simulation/blockbuilder/blockbuilder.go +++ b/cmd/lotus-sim/simulation/blockbuilder/blockbuilder.go @@ -12,7 +12,7 @@ import ( actorstypes "github.com/filecoin-project/go-state-types/actors" "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/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin/account" @@ -36,7 +36,7 @@ const ( // TODO: This will produce invalid blocks but it will accurately model the amount of gas // we're willing to use per-tipset. // A more correct approach would be to produce 5 blocks. We can do that later. -var targetGas = build.BlockGasTarget * expectedBlocks +var targetGas = buildconstants.BlockGasTarget * expectedBlocks type BlockBuilder struct { ctx context.Context @@ -150,7 +150,7 @@ func (bb *BlockBuilder) PushMessage(msg *types.Message) (*types.MessageReceipt, } msg.GasPremium = abi.NewTokenAmount(0) msg.GasFeeCap = abi.NewTokenAmount(0) - msg.GasLimit = build.BlockGasTarget + msg.GasLimit = buildconstants.BlockGasTarget // We manually snapshot so we can revert nonce changes, etc. on failure. err = st.Snapshot(bb.ctx) diff --git a/cmd/tvx/codenames_test.go b/cmd/tvx/codenames_test.go index 46d8466ecb2..e7476b1243a 100644 --- a/cmd/tvx/codenames_test.go +++ b/cmd/tvx/codenames_test.go @@ -16,11 +16,11 @@ func TestProtocolCodenames(t *testing.T) { t.Fatal("expected genesis codename") } - if height := abi.ChainEpoch(build.UpgradeBreezeHeight + 1); GetProtocolCodename(height) != "breeze" { + if height := build.UpgradeBreezeHeight + 1; GetProtocolCodename(height) != "breeze" { t.Fatal("expected breeze codename") } - if height := build.UpgradeAssemblyHeight + 1; GetProtocolCodename(abi.ChainEpoch(height)) != "actorsv2" { + if height := build.UpgradeAssemblyHeight + 1; GetProtocolCodename(height) != "actorsv2" { t.Fatal("expected actorsv2 codename") } diff --git a/itests/api_test.go b/itests/api_test.go index e3a41256e34..5d26a12a2e4 100644 --- a/itests/api_test.go +++ b/itests/api_test.go @@ -18,6 +18,7 @@ import ( lapi "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/types" "github.com/filecoin-project/lotus/itests/kit" ) @@ -166,10 +167,10 @@ func (ts *apiSuite) testOutOfGasError(t *testing.T) { // the gas estimator API executes the message with gasLimit = BlockGasLimit // Lowering it to 2 will cause it to run out of gas, testing the failure case we want - originalLimit := build.BlockGasLimit - build.BlockGasLimit = 2 + originalLimit := buildconstants.BlockGasLimit + buildconstants.BlockGasLimit = 2 defer func() { - build.BlockGasLimit = originalLimit + buildconstants.BlockGasLimit = originalLimit }() msg := &types.Message{ diff --git a/itests/eth_block_hash_test.go b/itests/eth_block_hash_test.go index e7da435bad6..2e30fe0e641 100644 --- a/itests/eth_block_hash_test.go +++ b/itests/eth_block_hash_test.go @@ -11,7 +11,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/chain/types/ethtypes" "github.com/filecoin-project/lotus/itests/kit" ) @@ -79,7 +79,7 @@ func TestEthBlockHashesCorrect_MultiBlockTipset(t *testing.T) { require.Equal(t, ethBlockA, ethBlockB) numBlocks := len(ts.Blocks()) - expGasLimit := ethtypes.EthUint64(int64(numBlocks) * build.BlockGasLimit) + expGasLimit := ethtypes.EthUint64(int64(numBlocks) * buildconstants.BlockGasLimit) require.Equal(t, expGasLimit, ethBlockB.GasLimit) } } diff --git a/itests/eth_hash_lookup_test.go b/itests/eth_hash_lookup_test.go index 1610e245826..4f56e05320b 100644 --- a/itests/eth_hash_lookup_test.go +++ b/itests/eth_hash_lookup_test.go @@ -14,6 +14,7 @@ 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/types" "github.com/filecoin-project/lotus/chain/types/ethtypes" "github.com/filecoin-project/lotus/itests/kit" @@ -311,7 +312,7 @@ func TestTransactionHashLookupNonexistentMessage(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() - cid := build.MustParseCid("bafk2bzacecapjnxnyw4talwqv5ajbtbkzmzqiosztj5cb3sortyp73ndjl76e") + cid := buildconstants.MustParseCid("bafk2bzacecapjnxnyw4talwqv5ajbtbkzmzqiosztj5cb3sortyp73ndjl76e") // We shouldn't be able to return a hash for this fake cid chainHash, err := client.EthGetTransactionHashByCid(ctx, cid) diff --git a/itests/fevm_test.go b/itests/fevm_test.go index 68071fff51a..778461effdc 100644 --- a/itests/fevm_test.go +++ b/itests/fevm_test.go @@ -21,6 +21,7 @@ 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/types" "github.com/filecoin-project/lotus/chain/types/ethtypes" "github.com/filecoin-project/lotus/itests/kit" @@ -667,7 +668,7 @@ func TestFEVMRecursiveActorCallEstimate(t *testing.T) { gaslimit, err := client.EthEstimateGas(ctx, gasParams) require.NoError(t, err) - require.LessOrEqual(t, int64(gaslimit), build.BlockGasLimit) + require.LessOrEqual(t, int64(gaslimit), buildconstants.BlockGasLimit) t.Logf("EthEstimateGas GasLimit=%d", gaslimit) diff --git a/itests/kit/ensemble.go b/itests/kit/ensemble.go index 5e36c77a069..84036deb623 100644 --- a/itests/kit/ensemble.go +++ b/itests/kit/ensemble.go @@ -35,6 +35,7 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api/v1api" "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/miner" @@ -120,15 +121,15 @@ type Ensemble struct { inactive struct { fullnodes []*TestFullNode miners []*TestMiner - unmanagedMiners []*TestUnmanagedMiner workers []*TestWorker + unmanagedMiners []*TestUnmanagedMiner } active struct { fullnodes []*TestFullNode miners []*TestMiner - unmanagedMiners []*TestUnmanagedMiner workers []*TestWorker bms map[*TestMiner]*BlockMiner + unmanagedMiners []*TestUnmanagedMiner } genesis struct { version network.Version @@ -171,7 +172,7 @@ func NewEnsemble(t *testing.T, opts ...EnsembleOpt) *Ensemble { require.NoError(t, build.UseNetworkBundle("testing")) } - build.EquivocationDelaySecs = 0 + buildconstants.EquivocationDelaySecs = 0 return n } diff --git a/itests/kit/evm.go b/itests/kit/evm.go index 84a8ead1d3f..f0db5877ee0 100644 --- a/itests/kit/evm.go +++ b/itests/kit/evm.go @@ -29,7 +29,7 @@ import ( "github.com/filecoin-project/go-state-types/exitcode" "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/actors" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types/ethtypes" @@ -165,7 +165,7 @@ func (e *EVM) InvokeSolidityWithValue(ctx context.Context, sender address.Addres From: sender, Value: value, Method: builtintypes.MethodsEVM.InvokeContract, - GasLimit: build.BlockGasLimit, // note: we hardcode block gas limit due to slightly broken gas estimation - https://github.com/filecoin-project/lotus/issues/10041 + GasLimit: buildconstants.BlockGasLimit, // note: we hardcode block gas limit due to slightly broken gas estimation - https://github.com/filecoin-project/lotus/issues/10041 Params: params, } diff --git a/lib/ulimit/ulimit.go b/lib/ulimit/ulimit.go index e900f12136e..739802dbf5d 100644 --- a/lib/ulimit/ulimit.go +++ b/lib/ulimit/ulimit.go @@ -11,7 +11,7 @@ import ( logging "github.com/ipfs/go-log/v2" - "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" ) var log = logging.Logger("ulimit") @@ -65,7 +65,7 @@ func ManageFdLimit() (changed bool, newLimit uint64, err error) { return false, 0, nil } - targetLimit := build.DefaultFDLimit + targetLimit := buildconstants.DefaultFDLimit userLimit := userMaxFDs() if userLimit > 0 { targetLimit = userLimit diff --git a/lib/ulimit/ulimit_test.go b/lib/ulimit/ulimit_test.go index ad20feb1de9..4b3cf73dfae 100644 --- a/lib/ulimit/ulimit_test.go +++ b/lib/ulimit/ulimit_test.go @@ -13,7 +13,7 @@ import ( "syscall" "testing" - "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" ) func TestManageFdLimit(t *testing.T) { @@ -22,7 +22,7 @@ func TestManageFdLimit(t *testing.T) { t.Errorf("Cannot manage file descriptors") } - if build.DefaultFDLimit != uint64(16<<10) { + if buildconstants.DefaultFDLimit != uint64(16<<10) { t.Errorf("Maximum file descriptors default value changed") } } diff --git a/miner/miner.go b/miner/miner.go index 4f27c53dbcd..b18e027a28b 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -25,6 +25,7 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api/v1api" "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/policy" "github.com/filecoin-project/lotus/chain/gen" @@ -588,7 +589,7 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (minedBlock *type // To safeguard against this, we make sure it's been EquivocationDelaySecs since our base was calculated, // then re-calculate it. // If the daemon detected equivocated blocks, those blocks will no longer be in the new base. - m.niceSleep(time.Until(base.ComputeTime.Add(time.Duration(build.EquivocationDelaySecs) * time.Second))) + m.niceSleep(time.Until(base.ComputeTime.Add(time.Duration(buildconstants.EquivocationDelaySecs) * time.Second))) newBase, err := m.GetBestMiningCandidate(ctx) if err != nil { err = xerrors.Errorf("failed to refresh best mining candidate: %w", err) diff --git a/node/builder.go b/node/builder.go index 8fb29c249fa..0bdb1fab223 100644 --- a/node/builder.go +++ b/node/builder.go @@ -23,6 +23,7 @@ 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/beacon" "github.com/filecoin-project/lotus/chain/index" "github.com/filecoin-project/lotus/chain/types" @@ -162,7 +163,7 @@ func defaults() []Option { Override(new(*alerting.Alerting), alerting.NewAlertingSystem), Override(new(dtypes.NodeStartTime), FromVal(dtypes.NodeStartTime(time.Now()))), - Override(CheckFDLimit, modules.CheckFdLimit(build.DefaultFDLimit)), + Override(CheckFDLimit, modules.CheckFdLimit(buildconstants.DefaultFDLimit)), Override(CheckFvmConcurrency, modules.CheckFvmConcurrency()), Override(CheckUDPBufferSize, modules.CheckUDPBufferSize(2048*1024)), diff --git a/node/impl/full/eth.go b/node/impl/full/eth.go index a7c1975f5ff..a1a6bec6f9c 100644 --- a/node/impl/full/eth.go +++ b/node/impl/full/eth.go @@ -27,6 +27,7 @@ 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/actors" builtinactors "github.com/filecoin-project/lotus/chain/actors/builtin" builtinevm "github.com/filecoin-project/lotus/chain/actors/builtin/evm" @@ -484,7 +485,7 @@ func (a *EthModule) EthGetCode(ctx context.Context, ethAddr ethtypes.EthAddress, Value: big.Zero(), Method: builtintypes.MethodsEVM.GetBytecode, Params: nil, - GasLimit: build.BlockGasLimit, + GasLimit: buildconstants.BlockGasLimit, GasFeeCap: big.Zero(), GasPremium: big.Zero(), } @@ -582,7 +583,7 @@ func (a *EthModule) EthGetStorageAt(ctx context.Context, ethAddr ethtypes.EthAdd Value: big.Zero(), Method: builtintypes.MethodsEVM.GetStorageAt, Params: params, - GasLimit: build.BlockGasLimit, + GasLimit: buildconstants.BlockGasLimit, GasFeeCap: big.Zero(), GasPremium: big.Zero(), } @@ -650,7 +651,7 @@ func (a *EthModule) EthGetBalance(ctx context.Context, address ethtypes.EthAddre } func (a *EthModule) EthChainId(ctx context.Context) (ethtypes.EthUint64, error) { - return ethtypes.EthUint64(build.Eip155ChainId), nil + return ethtypes.EthUint64(buildconstants.Eip155ChainId), nil } func (a *EthModule) EthSyncing(ctx context.Context) (ethtypes.EthSyncingResult, error) { @@ -749,7 +750,7 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (eth } rewards, totalGasUsed := calculateRewardsAndGasUsed(rewardPercentiles, txGasRewards) - maxGas := build.BlockGasLimit * int64(len(ts.Blocks())) + maxGas := buildconstants.BlockGasLimit * int64(len(ts.Blocks())) // arrays should be reversed at the end baseFeeArray = append(baseFeeArray, ethtypes.EthBigInt(basefee)) @@ -788,7 +789,7 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (eth } func (a *EthModule) NetVersion(_ context.Context) (string, error) { - return strconv.FormatInt(build.Eip155ChainId, 10), nil + return strconv.FormatInt(buildconstants.Eip155ChainId, 10), nil } func (a *EthModule) NetListening(ctx context.Context) (bool, error) { @@ -1093,7 +1094,7 @@ func (a *EthModule) EthEstimateGas(ctx context.Context, p jsonrpc.RawParams) (et // So we re-execute the message with EthCall (well, applyMessage which contains the // guts of EthCall). This will give us an ethereum specific error with revert // information. - msg.GasLimit = build.BlockGasLimit + msg.GasLimit = buildconstants.BlockGasLimit if _, err2 := a.applyMessage(ctx, msg, ts.Key()); err2 != nil { err = err2 } @@ -1156,8 +1157,8 @@ func gasSearch( low = high high = high * 2 - if high > build.BlockGasLimit { - high = build.BlockGasLimit + if high > buildconstants.BlockGasLimit { + high = buildconstants.BlockGasLimit break } } diff --git a/node/impl/full/eth_utils.go b/node/impl/full/eth_utils.go index 9e7d88dfa7f..d67bb26fb44 100644 --- a/node/impl/full/eth_utils.go +++ b/node/impl/full/eth_utils.go @@ -21,6 +21,7 @@ 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/actors" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/state" @@ -202,7 +203,7 @@ func ethCallToFilecoinMessage(ctx context.Context, tx ethtypes.EthCall) (*types. Value: big.Int(tx.Value), Method: method, Params: params, - GasLimit: build.BlockGasLimit, + GasLimit: buildconstants.BlockGasLimit, GasFeeCap: big.Zero(), GasPremium: big.Zero(), }, nil @@ -558,7 +559,7 @@ func ethTxFromNativeMessage(msg *types.Message, st *state.StateTree) (ethtypes.E From: from, Input: encodeFilecoinParamsAsABI(msg.Method, codec, msg.Params), Nonce: ethtypes.EthUint64(msg.Nonce), - ChainID: ethtypes.EthUint64(build.Eip155ChainId), + ChainID: ethtypes.EthUint64(buildconstants.Eip155ChainId), Value: ethtypes.EthBigInt(msg.Value), Type: ethtypes.EIP1559TxType, Gas: ethtypes.EthUint64(msg.GasLimit), diff --git a/node/impl/full/gas.go b/node/impl/full/gas.go index c5b22354a52..3f105e63753 100644 --- a/node/impl/full/gas.go +++ b/node/impl/full/gas.go @@ -19,6 +19,7 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" lbuiltin "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/messagepool" "github.com/filecoin-project/lotus/chain/stmgr" @@ -128,7 +129,7 @@ func gasEstimateFeeCap(cstore *store.ChainStore, msg *types.Message, maxqueueblk ts := cstore.GetHeaviestTipSet() parentBaseFee := ts.Blocks()[0].ParentBaseFee - increaseFactor := math.Pow(1.+1./float64(build.BaseFeeMaxChangeDenom), float64(maxqueueblks)) + increaseFactor := math.Pow(1.+1./float64(buildconstants.BaseFeeMaxChangeDenom), float64(maxqueueblks)) feeInFuture := types.BigMul(parentBaseFee, types.NewInt(uint64(increaseFactor*(1<<8)))) out := types.BigDiv(feeInFuture, types.NewInt(1<<8)) @@ -147,8 +148,8 @@ func medianGasPremium(prices []GasMeta, blocks int) abi.TokenAmount { return prices[i].Price.GreaterThan(prices[j].Price) }) - at := build.BlockGasTarget * int64(blocks) / 2 // 50th - at += build.BlockGasTarget * int64(blocks) / (2 * 20) // move 5% further + at := buildconstants.BlockGasTarget * int64(blocks) / 2 // 50th + at += buildconstants.BlockGasTarget * int64(blocks) / (2 * 20) // move 5% further prev1, prev2 := big.Zero(), big.Zero() for _, price := range prices { prev1, prev2 = price.Price, prev1 @@ -310,7 +311,7 @@ func gasEstimateGasLimit( currTs *types.TipSet, ) (int64, error) { msg := *msgIn - msg.GasLimit = build.BlockGasLimit + msg.GasLimit = buildconstants.BlockGasLimit msg.GasFeeCap = big.Zero() msg.GasPremium = big.Zero() @@ -390,8 +391,8 @@ func (m *GasModule) GasEstimateMessageGas(ctx context.Context, msg *types.Messag msg.GasLimit = int64(float64(gasLimit) * m.Mpool.GetConfig().GasLimitOverestimation) // Gas overestimation can cause us to exceed the block gas limit, cap it. - if msg.GasLimit > build.BlockGasLimit { - msg.GasLimit = build.BlockGasLimit + if msg.GasLimit > buildconstants.BlockGasLimit { + msg.GasLimit = buildconstants.BlockGasLimit } } diff --git a/node/impl/full/gas_test.go b/node/impl/full/gas_test.go index 8fc585bd544..ee4ca3b9850 100644 --- a/node/impl/full/gas_test.go +++ b/node/impl/full/gas_test.go @@ -8,35 +8,35 @@ import ( "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/build/buildconstants" "github.com/filecoin-project/lotus/chain/types" ) func TestMedian(t *testing.T) { //stm: @MARKET_GAS_GET_MEDIAN_PREMIUM_001 require.Equal(t, types.NewInt(5), medianGasPremium([]GasMeta{ - {big.NewInt(5), build.BlockGasTarget}, + {big.NewInt(5), buildconstants.BlockGasTarget}, }, 1)) require.Equal(t, types.NewInt(10), medianGasPremium([]GasMeta{ - {big.NewInt(5), build.BlockGasTarget}, - {big.NewInt(10), build.BlockGasTarget}, + {big.NewInt(5), buildconstants.BlockGasTarget}, + {big.NewInt(10), buildconstants.BlockGasTarget}, }, 1)) require.Equal(t, types.NewInt(15), medianGasPremium([]GasMeta{ - {big.NewInt(10), build.BlockGasTarget / 2}, - {big.NewInt(20), build.BlockGasTarget / 2}, + {big.NewInt(10), buildconstants.BlockGasTarget / 2}, + {big.NewInt(20), buildconstants.BlockGasTarget / 2}, }, 1)) require.Equal(t, types.NewInt(25), medianGasPremium([]GasMeta{ - {big.NewInt(10), build.BlockGasTarget / 2}, - {big.NewInt(20), build.BlockGasTarget / 2}, - {big.NewInt(30), build.BlockGasTarget / 2}, + {big.NewInt(10), buildconstants.BlockGasTarget / 2}, + {big.NewInt(20), buildconstants.BlockGasTarget / 2}, + {big.NewInt(30), buildconstants.BlockGasTarget / 2}, }, 1)) require.Equal(t, types.NewInt(15), medianGasPremium([]GasMeta{ - {big.NewInt(10), build.BlockGasTarget / 2}, - {big.NewInt(20), build.BlockGasTarget / 2}, - {big.NewInt(30), build.BlockGasTarget / 2}, + {big.NewInt(10), buildconstants.BlockGasTarget / 2}, + {big.NewInt(20), buildconstants.BlockGasTarget / 2}, + {big.NewInt(30), buildconstants.BlockGasTarget / 2}, }, 2)) } diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 312d30ee315..332ba00720f 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -30,6 +30,7 @@ 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/actors" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin/datacap" @@ -1929,11 +1930,11 @@ func (a *StateAPI) StateGetNetworkParams(ctx context.Context) (*api.NetworkParam return &api.NetworkParams{ NetworkName: networkName, - BlockDelaySecs: build.BlockDelaySecs, - ConsensusMinerMinPower: build.ConsensusMinerMinPower, - SupportedProofTypes: build.SupportedProofTypes, - PreCommitChallengeDelay: build.PreCommitChallengeDelay, - Eip155ChainID: build.Eip155ChainId, + BlockDelaySecs: buildconstants.BlockDelaySecs, + ConsensusMinerMinPower: buildconstants.ConsensusMinerMinPower, + SupportedProofTypes: buildconstants.SupportedProofTypes, + PreCommitChallengeDelay: buildconstants.PreCommitChallengeDelay, + Eip155ChainID: buildconstants.Eip155ChainId, ForkUpgradeParams: api.ForkUpgradeParams{ UpgradeSmokeHeight: build.UpgradeSmokeHeight, UpgradeBreezeHeight: build.UpgradeBreezeHeight, @@ -1943,7 +1944,7 @@ func (a *StateAPI) StateGetNetworkParams(ctx context.Context) (*api.NetworkParam UpgradeRefuelHeight: build.UpgradeRefuelHeight, UpgradeTapeHeight: build.UpgradeTapeHeight, UpgradeKumquatHeight: build.UpgradeKumquatHeight, - BreezeGasTampingDuration: build.BreezeGasTampingDuration, + BreezeGasTampingDuration: buildconstants.BreezeGasTampingDuration, UpgradeCalicoHeight: build.UpgradeCalicoHeight, UpgradePersianHeight: build.UpgradePersianHeight, UpgradeOrangeHeight: build.UpgradeOrangeHeight, diff --git a/tools/stats/points/collect.go b/tools/stats/points/collect.go index 8b86695742e..24be14a6a96 100644 --- a/tools/stats/points/collect.go +++ b/tools/stats/points/collect.go @@ -18,6 +18,7 @@ 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/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin/power" @@ -203,11 +204,11 @@ func (c *ChainPointCollector) collectBlockheaderPoints(ctx context.Context, pl * } { blks := int64(len(cids)) - p = influx.NewPoint("chain.gas_fill_ratio", float64(totalGasLimit)/float64(blks*build.BlockGasTarget)) + p = influx.NewPoint("chain.gas_fill_ratio", float64(totalGasLimit)/float64(blks*buildconstants.BlockGasTarget)) pl.AddPoint(p) - p = influx.NewPoint("chain.gas_capacity_ratio", float64(totalUniqGasLimit)/float64(blks*build.BlockGasTarget)) + p = influx.NewPoint("chain.gas_capacity_ratio", float64(totalUniqGasLimit)/float64(blks*buildconstants.BlockGasTarget)) pl.AddPoint(p) - p = influx.NewPoint("chain.gas_waste_ratio", float64(totalGasLimit-totalUniqGasLimit)/float64(blks*build.BlockGasTarget)) + p = influx.NewPoint("chain.gas_waste_ratio", float64(totalGasLimit-totalUniqGasLimit)/float64(blks*buildconstants.BlockGasTarget)) pl.AddPoint(p) }