Skip to content

Commit

Permalink
chore: types: buildconstants split post-cleanup (filecoin-project#12245)
Browse files Browse the repository at this point in the history
* chore: s/CidMustParse/cid.MustParse/g
* chore: fix sloppy init duplication
* chore: move the policy init() to the core namespace
* chore: remove unused proxies for policy.DealDurationBounds
  • Loading branch information
ribasushi committed Jul 24, 2024
1 parent 7b792e5 commit 493d132
Show file tree
Hide file tree
Showing 9 changed files with 837 additions and 871 deletions.
4 changes: 3 additions & 1 deletion build/buildconstants/params_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"os"
"strconv"

"github.com/ipfs/go-cid"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
Expand Down Expand Up @@ -163,7 +165,7 @@ const BootstrapPeerThreshold = 4
const Eip155ChainId = 314

// WhitelistedBlock skips checks on message validity in this block to sidestep the zero-bls signature
var WhitelistedBlock = MustParseCid("bafy2bzaceapyg2uyzk7vueh3xccxkuwbz3nxewjyguoxvhx77malc2lzn2ybi")
var WhitelistedBlock = cid.MustParse("bafy2bzaceapyg2uyzk7vueh3xccxkuwbz3nxewjyguoxvhx77malc2lzn2ybi")

const F3Enabled = false
const ManifestServerID = "12D3KooWENMwUF9YxvQxar7uBWJtZkA6amvK4xWmKXfSiHUo2Qq7"
Expand Down
11 changes: 6 additions & 5 deletions build/buildconstants/params_shared_vals.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import (
// /////
// Consensus / Network

func init() {
policy.SetSupportedProofTypes(SupportedProofTypes...)
policy.SetConsensusMinerMinPower(ConsensusMinerMinPower)
policy.SetPreCommitChallengeDelay(PreCommitChallengeDelay)
}

const AllowableClockDriftSecs = uint64(1)

// Blocks (e)
Expand Down Expand Up @@ -96,8 +102,3 @@ 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)
4 changes: 0 additions & 4 deletions build/buildconstants/params_testground.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
"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/chain/actors/policy"
)

var (
Expand Down Expand Up @@ -138,5 +136,3 @@ 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)
10 changes: 0 additions & 10 deletions build/buildconstants/shared_funcs.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package buildconstants

import (
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"

"github.com/filecoin-project/go-address"
Expand All @@ -22,12 +21,3 @@ func MustParseAddress(addr string) address.Address {

return ret
}

func MustParseCid(c string) cid.Cid {
ret, err := cid.Decode(c)
if err != nil {
panic(err)
}

return ret
}
1,644 changes: 822 additions & 822 deletions build/builtin_actors_gen.go

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions build/params_shared_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ var SetAddressNetwork = buildconstants.SetAddressNetwork
// Deprecated: Use buildconstants.MustParseAddress instead.
var MustParseAddress = buildconstants.MustParseAddress

// Deprecated: Use buildconstants.MustParseCid instead.
var MustParseCid = buildconstants.MustParseCid

func IsF3Enabled() bool {
const F3DisableEnvKey = "LOTUS_DISABLE_F3"
return buildconstants.F3Enabled && len(os.Getenv(F3DisableEnvKey)) == 0
Expand Down
24 changes: 2 additions & 22 deletions build/params_shared_vals.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package build

import (
"math/big"

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

// /////
Expand Down Expand Up @@ -43,16 +40,8 @@ var FilAllocStorageMining = buildconstants.FilAllocStorageMining // Deprecated:
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

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)))
}
var InitialRewardBalance = buildconstants.InitialRewardBalance // Deprecated: Use buildconstants.InitialRewardBalance instead
var InitialFilReserved = buildconstants.InitialFilReserved // Deprecated: Use buildconstants.InitialFilReserved instead

// Sync
var BadBlockCacheSize = buildconstants.BadBlockCacheSize // Deprecated: Use buildconstants.BadBlockCacheSize instead
Expand All @@ -75,13 +64,4 @@ var MinimumBaseFee int64 = buildconstants.MinimumBaseFee // Depr
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.SetPreCommitChallengeDelay(buildconstants.PreCommitChallengeDelay)
}
4 changes: 2 additions & 2 deletions gen/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ var EmbeddedBuiltinActorsMetadata = []*BuiltinActorsMetadata{
Network: {{printf "%q" .Network}},
Version: {{.Version}},
{{if .BundleGitTag}} BundleGitTag: {{printf "%q" .BundleGitTag}}, {{end}}
ManifestCid: MustParseCid({{printf "%q" .ManifestCid}}),
ManifestCid: cid.MustParse({{printf "%q" .ManifestCid}}),
Actors: map[string]cid.Cid {
{{- range $name, $cid := .Actors }}
{{printf "%q" $name}}: MustParseCid({{printf "%q" $cid}}),
{{printf "%q" $name}}: cid.MustParse({{printf "%q" $cid}}),
{{- end }}
},
},
Expand Down
4 changes: 2 additions & 2 deletions itests/eth_hash_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
"testing"
"time"

"github.com/ipfs/go-cid"
"github.com/stretchr/testify/require"

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

"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"
Expand Down Expand Up @@ -312,7 +312,7 @@ func TestTransactionHashLookupNonexistentMessage(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

cid := buildconstants.MustParseCid("bafk2bzacecapjnxnyw4talwqv5ajbtbkzmzqiosztj5cb3sortyp73ndjl76e")
cid := cid.MustParse("bafk2bzacecapjnxnyw4talwqv5ajbtbkzmzqiosztj5cb3sortyp73ndjl76e")

// We shouldn't be able to return a hash for this fake cid
chainHash, err := client.EthGetTransactionHashByCid(ctx, cid)
Expand Down

0 comments on commit 493d132

Please sign in to comment.