diff --git a/README.md b/README.md index 57a59f70c89..c944d41e6a0 100644 --- a/README.md +++ b/README.md @@ -71,10 +71,10 @@ For other distributions you can find the required dependencies [here.](https://l #### Go -To build Lotus, you need a working installation of [Go 1.19.12 or higher](https://golang.org/dl/): +To build Lotus, you need a working installation of [Go 1.20.10 or higher](https://golang.org/dl/): ```bash -wget -c https://golang.org/dl/go1.19.12.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local +wget -c https://golang.org/dl/go1.20.10.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local ``` **TIP:** diff --git a/blockstore/idstore.go b/blockstore/idstore.go index fb575dca72f..a10aee57553 100644 --- a/blockstore/idstore.go +++ b/blockstore/idstore.go @@ -183,3 +183,17 @@ func (b *idstore) Close() error { func (b *idstore) Flush(ctx context.Context) error { return b.bs.Flush(ctx) } + +func (b *idstore) CollectGarbage(ctx context.Context, options ...BlockstoreGCOption) error { + if bs, ok := b.bs.(BlockstoreGC); ok { + return bs.CollectGarbage(ctx, options...) + } + return xerrors.Errorf("not supported") +} + +func (b *idstore) GCOnce(ctx context.Context, options ...BlockstoreGCOption) error { + if bs, ok := b.bs.(BlockstoreGCOnce); ok { + return bs.GCOnce(ctx, options...) + } + return xerrors.Errorf("not supported") +} diff --git a/build/actors/v12.tar.zst b/build/actors/v12.tar.zst index 38cb8516038..859431b58d6 100644 Binary files a/build/actors/v12.tar.zst and b/build/actors/v12.tar.zst differ diff --git a/build/builtin_actors.go b/build/builtin_actors.go index 50aecde40af..2cf40a754d6 100644 --- a/build/builtin_actors.go +++ b/build/builtin_actors.go @@ -42,6 +42,12 @@ func init() { if err := loadManifests(NetworkBundle); err != nil { panic(err) } + + // The following code cid existed temporarily on the calibnet testnet, as a "buggy" storage miner actor implementation. + // We include it in our builtin bundle, but intentionally omit from metadata. + if NetworkBundle == "calibrationnet" { + actors.AddActorMeta("storageminer", cid.MustParse("bafk2bzacecnh2ouohmonvebq7uughh4h3ppmg4cjsk74dzxlbbtlcij4xbzxq"), actorstypes.Version12) + } } // UseNetworkBundle switches to a different network bundle, by name. @@ -183,6 +189,12 @@ func readEmbeddedBuiltinActorsMetadata(bundle string) ([]*BuiltinActorsMetadata, if err != nil { return nil, xerrors.Errorf("error loading builtin actors bundle: %w", err) } + + // The following manifest cid existed temporarily on the calibnet testnet + // We include it in our builtin bundle, but intentionally omit from metadata + if root == cid.MustParse("bafy2bzacedrunxfqta5skb7q7x32lnp4efz2oq7fn226ffm7fu5iqs62jkmvs") { + continue + } bundles = append(bundles, &BuiltinActorsMetadata{ Network: name, Version: actorstypes.Version(version), @@ -232,7 +244,7 @@ func readBundleManifest(r io.Reader) (cid.Cid, map[string]cid.Cid, error) { } // GetEmbeddedBuiltinActorsBundle returns the builtin-actors bundle for the given actors version. -func GetEmbeddedBuiltinActorsBundle(version actorstypes.Version) ([]byte, bool) { +func GetEmbeddedBuiltinActorsBundle(version actorstypes.Version, networkBundleName string) ([]byte, bool) { fi, err := embeddedBuiltinActorReleases.Open(fmt.Sprintf("actors/v%d.tar.zst", version)) if err != nil { return nil, false @@ -243,7 +255,7 @@ func GetEmbeddedBuiltinActorsBundle(version actorstypes.Version) ([]byte, bool) defer uncompressed.Close() //nolint tarReader := tar.NewReader(uncompressed) - targetFileName := fmt.Sprintf("builtin-actors-%s.car", NetworkBundle) + targetFileName := fmt.Sprintf("builtin-actors-%s.car", networkBundleName) for { header, err := tarReader.Next() switch err { diff --git a/build/builtin_actors_gen.go b/build/builtin_actors_gen.go index 0e1f4fe203a..8d67bba2da5 100644 --- a/build/builtin_actors_gen.go +++ b/build/builtin_actors_gen.go @@ -97,8 +97,8 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet }, { Network: "butterflynet", Version: 12, - BundleGitTag: "v12.0.0-rc.1", - ManifestCid: MustParseCid("bafy2bzaceb7s3k6zyuubqil7s2rwdcdyslqqx2fn2cj536yh3hexlyi4syyk6"), + BundleGitTag: "v12.0.0-rc.2", + ManifestCid: MustParseCid("bafy2bzaceabeegs5mhrxwqodyt7u2ulxr2jg6eh5g3545ganqzkncnxzserue"), Actors: map[string]cid.Cid{ "account": MustParseCid("bafk2bzacebp7anjdtg2sohyt6lromx4xs7nujtwdfcsffnptphaayabx7ysxs"), "cron": MustParseCid("bafk2bzacecu2y3awtemmglpkroiglulc2fj3gpdn6eazdqr6avcautiaighrg"), @@ -112,7 +112,7 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), "reward": MustParseCid("bafk2bzacedebvitdsztwebi44t5es4ls3p3hor252igzawr3s6uznmbvzh2ou"), "storagemarket": MustParseCid("bafk2bzaceb2tdeqtt2eqpzeb3gezuchb7g7uzbd52bgvcdt6bg3ckq7oisb74"), - "storageminer": MustParseCid("bafk2bzaceaaztuglvw6pw5xohwfekbw47iyugbyftxrp6hwygsaiu6rebtcty"), + "storageminer": MustParseCid("bafk2bzacea2jzzulmz6ktj6vndjheybz2io3vznnhsb32zberpaqeo7s7xa56"), "storagepower": MustParseCid("bafk2bzacedxvlj5xmhytdjrjqyonz37duvxb2ioyzk75c27yypkqalxuh3xh6"), "system": MustParseCid("bafk2bzacec3vwj2chzaram3iqupkbfiein5h2l5qiltlrngbju2vg5umelclm"), "verifiedregistry": MustParseCid("bafk2bzacedv2irkql7nil3w5v3ohqq3e54w62pxeoppjmaktzokolaaoh5ksu"), @@ -203,8 +203,8 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet }, { Network: "calibrationnet", Version: 12, - BundleGitTag: "v12.0.0-rc.1", - ManifestCid: MustParseCid("bafy2bzacedrunxfqta5skb7q7x32lnp4efz2oq7fn226ffm7fu5iqs62jkmvs"), + BundleGitTag: "v12.0.0-rc.2", + ManifestCid: MustParseCid("bafy2bzacebl4w5ptfvuw6746w7ev562idkbf5ppq72e6zub22435ws2rukzru"), Actors: map[string]cid.Cid{ "account": MustParseCid("bafk2bzacechwwxdqvggkdylm37zldjsra2ivkdzwp7fee56bzxbzs544wv6u6"), "cron": MustParseCid("bafk2bzacec4gdxxkqwxqqodsv6ug5dmdbqdfqwyqfek3yhxc2wweh5psxaeq6"), @@ -218,7 +218,7 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), "reward": MustParseCid("bafk2bzacedra77pcglf7vdca2itcaa4vd6xrxynxmgfgdjdxqxfwqyhtoxehy"), "storagemarket": MustParseCid("bafk2bzacea7g46y7xxu2zjq2h75x6mmx3utz2uxnlvnwi6tzpsvulna3bmiva"), - "storageminer": MustParseCid("bafk2bzacecnh2ouohmonvebq7uughh4h3ppmg4cjsk74dzxlbbtlcij4xbzxq"), + "storageminer": MustParseCid("bafk2bzaced7emkbbnrewv5uvrokxpf5tlm4jslu2jsv77ofw2yqdglg657uie"), "storagepower": MustParseCid("bafk2bzacedd3ka44k7d46ckbinjhv3diyuu2epgbyvhqqyjkc64qlrg3wlgzi"), "system": MustParseCid("bafk2bzacecioupndtcnyw6iq2hbrxag3aufvczlv5nobnfbkbywqzcyfaa376"), "verifiedregistry": MustParseCid("bafk2bzaceavldupmf7bimeeacs67z5xdfdlfca6p7sn6bev3mt5ggepfqvhqo"), @@ -318,8 +318,8 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet }, { Network: "caterpillarnet", Version: 12, - BundleGitTag: "v12.0.0-rc.1", - ManifestCid: MustParseCid("bafy2bzacedrimdbavexkdqldjwczbhlx4k5byshl363z62rrt6vkt7mbvnulu"), + BundleGitTag: "v12.0.0-rc.2", + ManifestCid: MustParseCid("bafy2bzacechvmc3iy6qrsbb6xwjhjibqpznqnkajowjsdmrq42ie5hysqemqa"), Actors: map[string]cid.Cid{ "account": MustParseCid("bafk2bzacecereuhejfvodut5357cai4lmhsyr7uenhcxvmw6jpmhe6auuly32"), "cron": MustParseCid("bafk2bzacebo2whgy6jla4jsf5j4ovlqm2e4eepedlpw5wadas33yxmunis4b4"), @@ -333,7 +333,7 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), "reward": MustParseCid("bafk2bzaceb2x5zgkrho373l3ippp6krs7brugssg6hj2tib22xmqjzdm2o25a"), "storagemarket": MustParseCid("bafk2bzaced5j6drzmsebpxbf2dtptrc5tyidlbftdljqxavxqb57s2qpbvdek"), - "storageminer": MustParseCid("bafk2bzacedozwxc3c6nqqajafs3hsjviyijhthysd5two5ptm5fcdbwh224ag"), + "storageminer": MustParseCid("bafk2bzacec7al5izu3ynnb7wg6fxxck3hebtkvlgynufjwcio57jd3n4ke2ue"), "storagepower": MustParseCid("bafk2bzaceagp6ilkltsltwii66nz6a4zen4qtfk7rdkvdv3gzq7fbv4ivox3u"), "system": MustParseCid("bafk2bzacedye5j5uxox7knb6zlnhseaadztyav76mjbyk5qslhhbpiy5cdtt2"), "verifiedregistry": MustParseCid("bafk2bzacecduww5pirr7dvaijjijw4gf6ygf7vipgxh4scvv6vseo46gueb46"), @@ -424,8 +424,8 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet }, { Network: "devnet", Version: 12, - BundleGitTag: "v12.0.0-rc.1", - ManifestCid: MustParseCid("bafy2bzacebk6yiirh4ennphzyka7b6g6jzn3lt4lr5ht7rjwulnrcthjihapo"), + BundleGitTag: "v12.0.0-rc.2", + ManifestCid: MustParseCid("bafy2bzaceau5i7eanhvss22z5ixmyrihilfniqn22tvkecjj56akz4xj7fvku"), Actors: map[string]cid.Cid{ "account": MustParseCid("bafk2bzacedki4apynvdxxuoigmqkgaktgy2erjftoxqxqaklnelgveyaqknfu"), "cron": MustParseCid("bafk2bzacebjpczf7qtcisy3zdp3sqoohxe75tgupmdo5dr26vh7orzrsjn3b2"), @@ -439,7 +439,7 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), "reward": MustParseCid("bafk2bzacebzso6xkjxdscbpncw7el2d4hap6lfkgwqzrbc76lzp33vkwk6obc"), "storagemarket": MustParseCid("bafk2bzacebzg74vyk3gzbhnz4zviwvxblyar574mtd6ayognmsvlkriejmunu"), - "storageminer": MustParseCid("bafk2bzaceajgt523lr2sf6cacvzo3goyalljlkaoeehyhxlv57wevkljw2cps"), + "storageminer": MustParseCid("bafk2bzaceckqrzomdnfb35byrhabrmmapxplj66cv3efw7u62qswjaqsuxah4"), "storagepower": MustParseCid("bafk2bzacebbtj2m2ajawfuzxqz5nmdep7xevjo2qfjqa5tx3vr5m6qojolya4"), "system": MustParseCid("bafk2bzacecnau5wddulbsvwn75tc3w75jrlvkybgrlxs4ngonqab6xq3eowvg"), "verifiedregistry": MustParseCid("bafk2bzacec37mddea65nvh4htsagtryfa3sq6i67utcupslyhzbhjhoy6hopa"), @@ -553,8 +553,8 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet }, { Network: "mainnet", Version: 12, - BundleGitTag: "v12.0.0-rc.1", - ManifestCid: MustParseCid("bafy2bzacebxmnxdgt2usdrcrpotgodr75culawwv4eklaun4lu6vlxecql6h2"), + BundleGitTag: "v12.0.0-rc.2", + ManifestCid: MustParseCid("bafy2bzacecooh5cjxkmraawn7wvmrx7k5hwdmbvqdteujr33mnaeclsazyb6a"), Actors: map[string]cid.Cid{ "account": MustParseCid("bafk2bzaceboftg75mdiba7xbo2i3uvgtca4brhnr3u5ptihonixgpnrvhpxoa"), "cron": MustParseCid("bafk2bzacechxjkfe2cehx4s7skj3wzfpzf7zolds64khrrrs66bhazsemktls"), @@ -568,7 +568,7 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), "reward": MustParseCid("bafk2bzacealqnxn5lwzwexd6reav4dppypquklx2ujlnvaxiqk2tzstyvkp5u"), "storagemarket": MustParseCid("bafk2bzacedylkg5am446lcuih4voyzdn4yjeqfsxfzh5b6mcuhx4mok5ph5c4"), - "storageminer": MustParseCid("bafk2bzacea56yi2khvvorofkf2t4rb5fbmltahrjtauszirdjz4jbunt55xsk"), + "storageminer": MustParseCid("bafk2bzacedio7wfaqutc4w6gl2dwqkgpcatz2r223ms74zxiovbjrfxmzeiou"), "storagepower": MustParseCid("bafk2bzacecsij5tpfzjpfuckxvccv2p3bdqjklkrfyyoei6lx5dyj5j4fvjm6"), "system": MustParseCid("bafk2bzacebfqrja2hip7esf4eafxjmu6xcogoqu5xxtgdg7xa5szgvvdguchu"), "verifiedregistry": MustParseCid("bafk2bzacedudgflxc75c77c6zkmfyq4u2xuk7k6xw6dfdccarjrvxx453b77q"), @@ -659,8 +659,8 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet }, { Network: "testing", Version: 12, - BundleGitTag: "v12.0.0-rc.1", - ManifestCid: MustParseCid("bafy2bzacebzcqzzlb5iwrledyuyy7pvob3xwzoxqsrvrbrnpaiejb52na5eza"), + BundleGitTag: "v12.0.0-rc.2", + ManifestCid: MustParseCid("bafy2bzacec7artlmtdmfuhurd2i7dgturiveblruub5xh3yizjtp5qzye3dly"), Actors: map[string]cid.Cid{ "account": MustParseCid("bafk2bzacea74qqkfvacykmq5emzqblh4f4nmxdkiyixxpzs7kkcfnbfa7cb6m"), "cron": MustParseCid("bafk2bzacecotbu7k6awdzfzakf7g5iaas6gswtunjnnb2xm2klqoshjgb4imy"), @@ -674,7 +674,7 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), "reward": MustParseCid("bafk2bzaceaajyncjxcrl7wbb6ukzkueyqz4uyekxpmtn4mpndkf7ksmggopzq"), "storagemarket": MustParseCid("bafk2bzaced6cexdcinwjhtfvuxgkxukiejp3goylaxtvhqfd24rs5z7g2z7dm"), - "storageminer": MustParseCid("bafk2bzacecw6jvvfu62jkwsa4vzmn262cjrrxh6wza6nvjsyg5aeix7rzgmbe"), + "storageminer": MustParseCid("bafk2bzaceclcbtu6edh73cn7ga7kzkmxcfnjt7jnxolkc5id6l6f7sztevm24"), "storagepower": MustParseCid("bafk2bzacedexrf5qplrrl5xzijfrthjdqwodfs5e6zj5kpztc7qnywbqdyiii"), "system": MustParseCid("bafk2bzacecp4roanbxq3bflftlkipsoqqxio5etjjnzxus5pcu7lq43fnxb34"), "verifiedregistry": MustParseCid("bafk2bzaceandytrgcnuvizfi47sijbqh6c243vjtzlzumexm6kjv7s7hye45g"), @@ -765,8 +765,8 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet }, { Network: "testing-fake-proofs", Version: 12, - BundleGitTag: "v12.0.0-rc.1", - ManifestCid: MustParseCid("bafy2bzacedtskkmrkkzairdi66syrmvfpydg63ro4dlmmqeta5krnur4hcp3a"), + BundleGitTag: "v12.0.0-rc.2", + ManifestCid: MustParseCid("bafy2bzaceand7owcb3omq7zjwir2q3lqapprl2eyiwpzv6oqs5bok4vzzqjbu"), Actors: map[string]cid.Cid{ "account": MustParseCid("bafk2bzacea74qqkfvacykmq5emzqblh4f4nmxdkiyixxpzs7kkcfnbfa7cb6m"), "cron": MustParseCid("bafk2bzacecotbu7k6awdzfzakf7g5iaas6gswtunjnnb2xm2klqoshjgb4imy"), @@ -780,7 +780,7 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), "reward": MustParseCid("bafk2bzaceaajyncjxcrl7wbb6ukzkueyqz4uyekxpmtn4mpndkf7ksmggopzq"), "storagemarket": MustParseCid("bafk2bzaced6cexdcinwjhtfvuxgkxukiejp3goylaxtvhqfd24rs5z7g2z7dm"), - "storageminer": MustParseCid("bafk2bzacea54x727xteh3tl46mitigy6cldqusqjxiwni65wrpofidh62k2ds"), + "storageminer": MustParseCid("bafk2bzacebbusvtnyhi7mimbnx2tw2uyvrr3fbmncbf6frx6e4kvjvoqllu36"), "storagepower": MustParseCid("bafk2bzacecdwijcbbryinjtm27pdinqqkyzoskri24pwsvsadwcq2alkkjpnc"), "system": MustParseCid("bafk2bzacecp4roanbxq3bflftlkipsoqqxio5etjjnzxus5pcu7lq43fnxb34"), "verifiedregistry": MustParseCid("bafk2bzaceandytrgcnuvizfi47sijbqh6c243vjtzlzumexm6kjv7s7hye45g"), diff --git a/build/params_2k.go b/build/params_2k.go index 5e0f5c60d46..df4f3dececd 100644 --- a/build/params_2k.go +++ b/build/params_2k.go @@ -67,6 +67,9 @@ var UpgradeThunderHeight = abi.ChainEpoch(-23) var UpgradeWatermelonHeight = abi.ChainEpoch(200) +// This fix upgrade only ran on calibrationnet +const UpgradeWatermelonFixHeight = -100 + var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, } diff --git a/build/params_butterfly.go b/build/params_butterfly.go index 96b71d3c073..371c99d5f59 100644 --- a/build/params_butterfly.go +++ b/build/params_butterfly.go @@ -57,6 +57,9 @@ const UpgradeThunderHeight = -23 const UpgradeWatermelonHeight = 400 +// This fix upgrade only ran on calibrationnet +const UpgradeWatermelonFixHeight = -100 + var SupportedProofTypes = []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg512MiBV1, abi.RegisteredSealProof_StackedDrg32GiBV1, diff --git a/build/params_calibnet.go b/build/params_calibnet.go index 5831d30bba6..2cc53925cd1 100644 --- a/build/params_calibnet.go +++ b/build/params_calibnet.go @@ -82,6 +82,9 @@ const UpgradeThunderHeight = UpgradeLightningHeight + 3120 // 2023-10-19T13:00:00Z const UpgradeWatermelonHeight = 1013134 +// 2023-11-07T13:00:00Z +const UpgradeWatermelonFixHeight = 1070494 + var SupportedProofTypes = []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg32GiBV1, abi.RegisteredSealProof_StackedDrg64GiBV1, diff --git a/build/params_interop.go b/build/params_interop.go index 2b2f3616049..104ae83c81c 100644 --- a/build/params_interop.go +++ b/build/params_interop.go @@ -56,6 +56,9 @@ var UpgradeThunderHeight = abi.ChainEpoch(-23) const UpgradeWatermelonHeight = 50 +// This fix upgrade only ran on calibrationnet +const UpgradeWatermelonFixHeight = -1 + var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, } diff --git a/build/params_mainnet.go b/build/params_mainnet.go index f35ac45efbf..c607bcdd0d7 100644 --- a/build/params_mainnet.go +++ b/build/params_mainnet.go @@ -95,8 +95,11 @@ const UpgradeLightningHeight = 2809800 // 2023-05-18T13:00:00Z const UpgradeThunderHeight = UpgradeLightningHeight + 2880*21 -// ??????? -var UpgradeWatermelonHeight = abi.ChainEpoch(9999999999) +// 2023-11-29T13:30:00Z +var UpgradeWatermelonHeight = abi.ChainEpoch(3431940) + +// This fix upgrade only ran on calibrationnet +const UpgradeWatermelonFixHeight = -1 var SupportedProofTypes = []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg32GiBV1, diff --git a/build/params_testground.go b/build/params_testground.go index 46d2e16de99..8073b0c6e7d 100644 --- a/build/params_testground.go +++ b/build/params_testground.go @@ -87,29 +87,30 @@ var ( UpgradeBreezeHeight abi.ChainEpoch = -1 BreezeGasTampingDuration abi.ChainEpoch = 0 - UpgradeSmokeHeight abi.ChainEpoch = -1 - UpgradeIgnitionHeight abi.ChainEpoch = -2 - UpgradeRefuelHeight abi.ChainEpoch = -3 - UpgradeTapeHeight abi.ChainEpoch = -4 - UpgradeAssemblyHeight abi.ChainEpoch = 10 - UpgradeLiftoffHeight abi.ChainEpoch = -5 - UpgradeKumquatHeight abi.ChainEpoch = -6 - UpgradeCalicoHeight abi.ChainEpoch = -8 - UpgradePersianHeight abi.ChainEpoch = -9 - UpgradeOrangeHeight abi.ChainEpoch = -10 - UpgradeClausHeight abi.ChainEpoch = -11 - UpgradeTrustHeight abi.ChainEpoch = -12 - UpgradeNorwegianHeight abi.ChainEpoch = -13 - UpgradeTurboHeight abi.ChainEpoch = -14 - UpgradeHyperdriveHeight abi.ChainEpoch = -15 - UpgradeChocolateHeight abi.ChainEpoch = -16 - UpgradeOhSnapHeight abi.ChainEpoch = -17 - UpgradeSkyrHeight abi.ChainEpoch = -18 - UpgradeSharkHeight abi.ChainEpoch = -19 - UpgradeHyggeHeight abi.ChainEpoch = -20 - UpgradeLightningHeight abi.ChainEpoch = -21 - UpgradeThunderHeight abi.ChainEpoch = -22 - UpgradeWatermelonHeight abi.ChainEpoch = -23 + UpgradeSmokeHeight abi.ChainEpoch = -1 + UpgradeIgnitionHeight abi.ChainEpoch = -2 + UpgradeRefuelHeight abi.ChainEpoch = -3 + UpgradeTapeHeight abi.ChainEpoch = -4 + UpgradeAssemblyHeight abi.ChainEpoch = 10 + UpgradeLiftoffHeight abi.ChainEpoch = -5 + UpgradeKumquatHeight abi.ChainEpoch = -6 + UpgradeCalicoHeight abi.ChainEpoch = -8 + UpgradePersianHeight abi.ChainEpoch = -9 + UpgradeOrangeHeight abi.ChainEpoch = -10 + UpgradeClausHeight abi.ChainEpoch = -11 + UpgradeTrustHeight abi.ChainEpoch = -12 + UpgradeNorwegianHeight abi.ChainEpoch = -13 + UpgradeTurboHeight abi.ChainEpoch = -14 + UpgradeHyperdriveHeight abi.ChainEpoch = -15 + UpgradeChocolateHeight abi.ChainEpoch = -16 + UpgradeOhSnapHeight abi.ChainEpoch = -17 + UpgradeSkyrHeight abi.ChainEpoch = -18 + UpgradeSharkHeight abi.ChainEpoch = -19 + UpgradeHyggeHeight abi.ChainEpoch = -20 + UpgradeLightningHeight abi.ChainEpoch = -21 + UpgradeThunderHeight abi.ChainEpoch = -22 + UpgradeWatermelonHeight abi.ChainEpoch = -23 + UpgradeWatermelonFixHeight abi.ChainEpoch = -24 DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, diff --git a/chain/actors/builtin/builtin.go b/chain/actors/builtin/builtin.go index 414a11e72e2..4516683a85c 100644 --- a/chain/actors/builtin/builtin.go +++ b/chain/actors/builtin/builtin.go @@ -23,6 +23,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors" ) +var InitActorAddr = builtin.InitActorAddr var SystemActorAddr = builtin.SystemActorAddr var BurntFundsActorAddr = builtin.BurntFundsActorAddr var CronActorAddr = builtin.CronActorAddr diff --git a/chain/actors/builtin/builtin.go.template b/chain/actors/builtin/builtin.go.template index 3b737c47e29..3d08a12bfbd 100644 --- a/chain/actors/builtin/builtin.go.template +++ b/chain/actors/builtin/builtin.go.template @@ -23,6 +23,7 @@ import ( smoothingtypes "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing" ) +var InitActorAddr = builtin.InitActorAddr var SystemActorAddr = builtin.SystemActorAddr var BurntFundsActorAddr = builtin.BurntFundsActorAddr var CronActorAddr = builtin.CronActorAddr diff --git a/chain/actors/builtin/miner/state.go.template b/chain/actors/builtin/miner/state.go.template index b322b2283c3..3c7f05d9af5 100644 --- a/chain/actors/builtin/miner/state.go.template +++ b/chain/actors/builtin/miner/state.go.template @@ -72,7 +72,7 @@ func (s *state{{.v}}) AvailableBalance(bal abi.TokenAmount) (available abi.Token available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available{{if (ge .v 2)}}, err{{end}} = s.GetAvailableBalance(bal) return available, err } diff --git a/chain/actors/builtin/miner/v0.go b/chain/actors/builtin/miner/v0.go index 7d5eaf8e0a9..5301ed1cbca 100644 --- a/chain/actors/builtin/miner/v0.go +++ b/chain/actors/builtin/miner/v0.go @@ -62,7 +62,7 @@ func (s *state0) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available = s.GetAvailableBalance(bal) return available, err } diff --git a/chain/actors/builtin/miner/v10.go b/chain/actors/builtin/miner/v10.go index 4d47ba396c1..53dc90b4560 100644 --- a/chain/actors/builtin/miner/v10.go +++ b/chain/actors/builtin/miner/v10.go @@ -62,7 +62,7 @@ func (s *state10) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmou available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/chain/actors/builtin/miner/v11.go b/chain/actors/builtin/miner/v11.go index a3ffd606f87..11a91c26b23 100644 --- a/chain/actors/builtin/miner/v11.go +++ b/chain/actors/builtin/miner/v11.go @@ -62,7 +62,7 @@ func (s *state11) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmou available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/chain/actors/builtin/miner/v12.go b/chain/actors/builtin/miner/v12.go index 787da7d0f45..90ecc97fd3d 100644 --- a/chain/actors/builtin/miner/v12.go +++ b/chain/actors/builtin/miner/v12.go @@ -62,7 +62,7 @@ func (s *state12) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmou available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/chain/actors/builtin/miner/v2.go b/chain/actors/builtin/miner/v2.go index 14341ae3832..5a81ad31f95 100644 --- a/chain/actors/builtin/miner/v2.go +++ b/chain/actors/builtin/miner/v2.go @@ -61,7 +61,7 @@ func (s *state2) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/chain/actors/builtin/miner/v3.go b/chain/actors/builtin/miner/v3.go index 52808da8ca6..aa1574cf47d 100644 --- a/chain/actors/builtin/miner/v3.go +++ b/chain/actors/builtin/miner/v3.go @@ -62,7 +62,7 @@ func (s *state3) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/chain/actors/builtin/miner/v4.go b/chain/actors/builtin/miner/v4.go index 5980ef769be..1faf30c0982 100644 --- a/chain/actors/builtin/miner/v4.go +++ b/chain/actors/builtin/miner/v4.go @@ -62,7 +62,7 @@ func (s *state4) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/chain/actors/builtin/miner/v5.go b/chain/actors/builtin/miner/v5.go index 886300ea3d5..be4b5e0b2e9 100644 --- a/chain/actors/builtin/miner/v5.go +++ b/chain/actors/builtin/miner/v5.go @@ -62,7 +62,7 @@ func (s *state5) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/chain/actors/builtin/miner/v6.go b/chain/actors/builtin/miner/v6.go index 4737b0ee2fa..fa8c30e4070 100644 --- a/chain/actors/builtin/miner/v6.go +++ b/chain/actors/builtin/miner/v6.go @@ -62,7 +62,7 @@ func (s *state6) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/chain/actors/builtin/miner/v7.go b/chain/actors/builtin/miner/v7.go index 72803eb750d..d6bb0e16eae 100644 --- a/chain/actors/builtin/miner/v7.go +++ b/chain/actors/builtin/miner/v7.go @@ -62,7 +62,7 @@ func (s *state7) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/chain/actors/builtin/miner/v8.go b/chain/actors/builtin/miner/v8.go index 3e3739591f7..06a205e7626 100644 --- a/chain/actors/builtin/miner/v8.go +++ b/chain/actors/builtin/miner/v8.go @@ -62,7 +62,7 @@ func (s *state8) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/chain/actors/builtin/miner/v9.go b/chain/actors/builtin/miner/v9.go index 72d9dbd59f5..6cbbd509ec3 100644 --- a/chain/actors/builtin/miner/v9.go +++ b/chain/actors/builtin/miner/v9.go @@ -62,7 +62,7 @@ func (s *state9) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmoun available = abi.NewTokenAmount(0) } }() - // this panics if the miner doesnt have enough funds to cover their locked pledge + // this panics if the miner doesn't have enough funds to cover their locked pledge available, err = s.GetAvailableBalance(bal) return available, err } diff --git a/chain/actors/builtin/paych/actor.go.template b/chain/actors/builtin/paych/actor.go.template index e19ac5e2937..3498a7a49fa 100644 --- a/chain/actors/builtin/paych/actor.go.template +++ b/chain/actors/builtin/paych/actor.go.template @@ -29,7 +29,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -// Load returns an abstract copy of payment channel state, irregardless of actor version +// Load returns an abstract copy of payment channel state, regardless of actor version func Load(store adt.Store, act *types.Actor) (State, error) { if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { if name != manifest.PaychKey { diff --git a/chain/actors/builtin/paych/paych.go b/chain/actors/builtin/paych/paych.go index 8a7979e95f7..fc8908cb4e1 100644 --- a/chain/actors/builtin/paych/paych.go +++ b/chain/actors/builtin/paych/paych.go @@ -29,7 +29,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -// Load returns an abstract copy of payment channel state, irregardless of actor version +// Load returns an abstract copy of payment channel state, regardless of actor version func Load(store adt.Store, act *types.Actor) (State, error) { if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { if name != manifest.PaychKey { diff --git a/chain/actors/manifest.go b/chain/actors/manifest.go index f58768ca24b..62c17193a57 100644 --- a/chain/actors/manifest.go +++ b/chain/actors/manifest.go @@ -51,6 +51,12 @@ func RegisterManifest(av actorstypes.Version, manifestCid cid.Cid, entries map[s } } +func AddActorMeta(name string, codeId cid.Cid, av actorstypes.Version) { + manifestMx.Lock() + defer manifestMx.Unlock() + actorMeta[codeId] = actorEntry{name: name, version: av} +} + // GetManifest gets a loaded manifest. func GetManifest(av actorstypes.Version) (cid.Cid, bool) { manifestMx.RLock() diff --git a/chain/actors/params.go b/chain/actors/params.go index f09b0be55a9..866c72b99df 100644 --- a/chain/actors/params.go +++ b/chain/actors/params.go @@ -13,7 +13,7 @@ import ( func SerializeParams(i cbg.CBORMarshaler) ([]byte, aerrors.ActorError) { buf := new(bytes.Buffer) if err := i.MarshalCBOR(buf); err != nil { - // TODO: shouldnt this be a fatal error? + // TODO: shouldn't this be a fatal error? return nil, aerrors.Absorb(err, exitcode.ErrSerialization, "failed to encode parameter") } return buf.Bytes(), nil diff --git a/chain/beacon/drand/drand_test.go b/chain/beacon/drand/drand_test.go index 7269139ca74..7434241a53a 100644 --- a/chain/beacon/drand/drand_test.go +++ b/chain/beacon/drand/drand_test.go @@ -17,7 +17,7 @@ import ( ) func TestPrintGroupInfo(t *testing.T) { - server := build.DrandConfigs[build.DrandDevnet].Servers[0] + server := build.DrandConfigs[build.DrandTestnet].Servers[0] c, err := hclient.New(server, nil, nil) assert.NoError(t, err) cg := c.(interface { @@ -31,7 +31,7 @@ func TestPrintGroupInfo(t *testing.T) { func TestMaxBeaconRoundForEpoch(t *testing.T) { todayTs := uint64(1652222222) - db, err := NewDrandBeacon(todayTs, build.BlockDelaySecs, nil, build.DrandConfigs[build.DrandDevnet]) + db, err := NewDrandBeacon(todayTs, build.BlockDelaySecs, nil, build.DrandConfigs[build.DrandTestnet]) assert.NoError(t, err) mbr15 := db.MaxBeaconRoundForEpoch(network.Version15, 100) mbr16 := db.MaxBeaconRoundForEpoch(network.Version16, 100) diff --git a/chain/consensus/filcns/upgrades.go b/chain/consensus/filcns/upgrades.go index 16abec6a84d..c1f594a9207 100644 --- a/chain/consensus/filcns/upgrades.go +++ b/chain/consensus/filcns/upgrades.go @@ -1,6 +1,7 @@ package filcns import ( + "bytes" "context" _ "embed" "fmt" @@ -19,7 +20,9 @@ import ( actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" nv18 "github.com/filecoin-project/go-state-types/builtin/v10/migration" + init11 "github.com/filecoin-project/go-state-types/builtin/v11/init" nv19 "github.com/filecoin-project/go-state-types/builtin/v11/migration" + system11 "github.com/filecoin-project/go-state-types/builtin/v11/system" nv21 "github.com/filecoin-project/go-state-types/builtin/v12/migration" nv17 "github.com/filecoin-project/go-state-types/builtin/v9/migration" "github.com/filecoin-project/go-state-types/manifest" @@ -273,6 +276,10 @@ func DefaultUpgradeSchedule() stmgr.UpgradeSchedule { StopWithin: 10, }}, Expensive: true, + }, { + Height: build.UpgradeWatermelonFixHeight, + Network: network.Version21, + Migration: upgradeActorsV12Fix, }, } @@ -1869,6 +1876,8 @@ func UpgradeActorsV12(ctx context.Context, sm *stmgr.StateManager, cache stmgr.M return newRoot, nil } +var calibnetv12BuggyBundle = cid.MustParse("bafy2bzacedrunxfqta5skb7q7x32lnp4efz2oq7fn226ffm7fu5iqs62jkmvs") + func upgradeActorsV12Common( ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet, @@ -1894,13 +1903,50 @@ func upgradeActorsV12Common( ) } - manifest, ok := actors.GetManifest(actorstypes.Version12) - if !ok { - return cid.Undef, xerrors.Errorf("no manifest CID for v12 upgrade") + // check whether or not this is a calibnet upgrade + // we do this because calibnet upgraded to a "wrong" actors bundle, which was then corrected + // we thus upgrade to calibrationnet-buggy in this upgrade + actorsIn, err := state.LoadStateTree(adtStore, root) + if err != nil { + return cid.Undef, xerrors.Errorf("loading state tree: %w", err) + } + + initActor, err := actorsIn.GetActor(builtin.InitActorAddr) + if err != nil { + return cid.Undef, xerrors.Errorf("failed to get system actor: %w", err) + } + + var initState init11.State + if err := adtStore.Get(ctx, initActor.Head, &initState); err != nil { + return cid.Undef, xerrors.Errorf("failed to get system actor state: %w", err) + } + + var manifestCid cid.Cid + if initState.NetworkName == "calibrationnet" { + embedded, ok := build.GetEmbeddedBuiltinActorsBundle(actorstypes.Version12, "calibrationnet-buggy") + if !ok { + return cid.Undef, xerrors.Errorf("didn't find buggy calibrationnet bundle") + } + + var err error + manifestCid, err = bundle.LoadBundle(ctx, writeStore, bytes.NewReader(embedded)) + if err != nil { + return cid.Undef, xerrors.Errorf("failed to load buggy calibnet bundle: %w", err) + } + + if manifestCid != calibnetv12BuggyBundle { + return cid.Undef, xerrors.Errorf("didn't find expected buggy calibnet bundle manifest: %s != %s", manifestCid, calibnetv12BuggyBundle) + } + } else { + ok := false + manifestCid, ok = actors.GetManifest(actorstypes.Version12) + if !ok { + return cid.Undef, xerrors.Errorf("no manifest CID for v12 upgrade") + } } // Perform the migration - newHamtRoot, err := nv21.MigrateStateTree(ctx, adtStore, manifest, stateRoot.Actors, epoch, config, + newHamtRoot, err := nv21.MigrateStateTree(ctx, adtStore, manifestCid, stateRoot.Actors, epoch, config, migrationLogger{}, cache) if err != nil { return cid.Undef, xerrors.Errorf("upgrading to actors v12: %w", err) @@ -1928,6 +1974,139 @@ func upgradeActorsV12Common( return newRoot, nil } +////////////////////// + +var calibnetv12BuggyMinerCID = cid.MustParse("bafk2bzacecnh2ouohmonvebq7uughh4h3ppmg4cjsk74dzxlbbtlcij4xbzxq") + +func upgradeActorsV12Fix(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, cb stmgr.ExecMonitor, + root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) { + stateStore := sm.ChainStore().StateBlockstore() + adtStore := store.ActorStore(ctx, stateStore) + + // ensure that the manifest is loaded in the blockstore + if err := bundle.LoadBundles(ctx, stateStore, actorstypes.Version12); err != nil { + return cid.Undef, xerrors.Errorf("failed to load manifest bundle: %w", err) + } + + // Load input state tree + actorsIn, err := state.LoadStateTree(adtStore, root) + if err != nil { + return cid.Undef, xerrors.Errorf("loading state tree: %w", err) + } + + // load old manifest data + systemActor, err := actorsIn.GetActor(builtin.SystemActorAddr) + if err != nil { + return cid.Undef, xerrors.Errorf("failed to get system actor: %w", err) + } + + var systemState system11.State + if err := adtStore.Get(ctx, systemActor.Head, &systemState); err != nil { + return cid.Undef, xerrors.Errorf("failed to get system actor state: %w", err) + } + + var oldManifestData manifest.ManifestData + if err := adtStore.Get(ctx, systemState.BuiltinActors, &oldManifestData); err != nil { + return cid.Undef, xerrors.Errorf("failed to get old manifest data: %w", err) + } + + newManifestCID, ok := actors.GetManifest(actorstypes.Version12) + if !ok { + return cid.Undef, xerrors.Errorf("no manifest CID for v12 upgrade") + } + + // load new manifest + var newManifest manifest.Manifest + if err := adtStore.Get(ctx, newManifestCID, &newManifest); err != nil { + return cid.Undef, xerrors.Errorf("error reading actor manifest: %w", err) + } + + if err := newManifest.Load(ctx, adtStore); err != nil { + return cid.Undef, xerrors.Errorf("error loading actor manifest: %w", err) + } + + // build the CID mapping + codeMapping := make(map[cid.Cid]cid.Cid, len(oldManifestData.Entries)) + for _, oldEntry := range oldManifestData.Entries { + newCID, ok := newManifest.Get(oldEntry.Name) + if !ok { + return cid.Undef, xerrors.Errorf("missing manifest entry for %s", oldEntry.Name) + } + + // Note: we expect newCID to be the same as oldEntry.Code for all actors except the miner actor + codeMapping[oldEntry.Code] = newCID + } + + // Create empty actorsOut + + actorsOut, err := state.NewStateTree(adtStore, actorsIn.Version()) + if err != nil { + return cid.Undef, xerrors.Errorf("failed to create new tree: %w", err) + } + + // Perform the migration + err = actorsIn.ForEach(func(a address.Address, actor *types.Actor) error { + newCid, ok := codeMapping[actor.Code] + if !ok { + return xerrors.Errorf("didn't find mapping for %s", actor.Code) + } + + return actorsOut.SetActor(a, &types.ActorV5{ + Code: newCid, + Head: actor.Head, + Nonce: actor.Nonce, + Balance: actor.Balance, + Address: actor.Address, + }) + }) + if err != nil { + return cid.Undef, xerrors.Errorf("failed to perform migration: %w", err) + } + + err = actorsIn.ForEach(func(a address.Address, inActor *types.Actor) error { + outActor, err := actorsOut.GetActor(a) + if err != nil { + return xerrors.Errorf("failed to get actor in outTree: %w", err) + } + + if inActor.Nonce != outActor.Nonce { + return xerrors.Errorf("mismatched nonce for actor %s", a) + } + + if !inActor.Balance.Equals(outActor.Balance) { + return xerrors.Errorf("mismatched balance for actor %s: %d != %d", a, inActor.Balance, outActor.Balance) + } + + if inActor.Address != outActor.Address && inActor.Address.String() != outActor.Address.String() { + return xerrors.Errorf("mismatched address for actor %s: %s != %s", a, inActor.Address, outActor.Address) + } + + if inActor.Head != outActor.Head { + return xerrors.Errorf("mismatched head for actor %s", a) + } + + // This is the hard-coded "buggy" miner actor Code ID + if inActor.Code != calibnetv12BuggyMinerCID && inActor.Code != outActor.Code { + return xerrors.Errorf("unexpected change in code for actor %s", a) + } + + return nil + }) + if err != nil { + return cid.Undef, xerrors.Errorf("failed to sanity check migration: %w", err) + } + + // Persist the result. + newRoot, err := actorsOut.Flush(ctx) + if err != nil { + return cid.Undef, xerrors.Errorf("failed to persist new state root: %w", err) + } + + return newRoot, nil +} + +//////////////////// + // Example upgrade function if upgrade requires only code changes //func UpgradeActorsV9(ctx context.Context, sm *stmgr.StateManager, _ stmgr.MigrationCache, _ stmgr.ExecMonitor, root cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) (cid.Cid, error) { // buf := blockstore.NewTieredBstore(sm.ChainStore().StateBlockstore(), blockstore.NewMemorySync()) diff --git a/chain/events/events_height.go b/chain/events/events_height.go index 457933fc6d3..5789be753a9 100644 --- a/chain/events/events_height.go +++ b/chain/events/events_height.go @@ -180,7 +180,7 @@ func (e *heightEventsObserver) Revert(ctx context.Context, from, to *types.TipSe // Update the head first so we don't accidental skip reverting a concurrent call to ChainAt. e.updateHead(to) - // Call revert on all hights between the two tipsets, handling empty tipsets. + // Call revert on all heights between the two tipsets, handling empty tipsets. for h := from.Height(); h > to.Height(); h-- { e.lk.Lock() triggers := e.tsHeights[h] diff --git a/chain/events/events_test.go b/chain/events/events_test.go index e2450909c6f..f16434355ee 100644 --- a/chain/events/events_test.go +++ b/chain/events/events_test.go @@ -673,7 +673,7 @@ func TestCalled(t *testing.T) { }, 3, 20, matchAddrMethod(t0123, 5)) require.NoError(t, err) - // create few blocks to make sure nothing get's randomly called + // create few blocks to make sure nothing gets randomly called fcs.advance(0, 4, 0, nil) // H=5 require.Equal(t, false, applied) @@ -991,7 +991,7 @@ func TestCalledNull(t *testing.T) { }, 3, 20, matchAddrMethod(t0123, 5)) require.NoError(t, err) - // create few blocks to make sure nothing get's randomly called + // create few blocks to make sure nothing gets randomly called fcs.advance(0, 4, 0, nil) // H=5 require.Equal(t, false, applied) @@ -1050,7 +1050,7 @@ func TestRemoveTriggersOnMessage(t *testing.T) { }, 3, 20, matchAddrMethod(t0123, 5)) require.NoError(t, err) - // create few blocks to make sure nothing get's randomly called + // create few blocks to make sure nothing gets randomly called fcs.advance(0, 4, 0, nil) // H=5 require.Equal(t, false, applied) @@ -1155,7 +1155,7 @@ func TestStateChanged(t *testing.T) { }) require.NoError(t, err) - // create few blocks to make sure nothing get's randomly called + // create few blocks to make sure nothing gets randomly called fcs.advance(0, 4, 0, nil) // H=5 require.Equal(t, false, applied) diff --git a/chain/exchange/client.go b/chain/exchange/client.go index 4c1763f619c..120b554a11f 100644 --- a/chain/exchange/client.go +++ b/chain/exchange/client.go @@ -242,7 +242,7 @@ func (c *client) processResponse(req *Request, res *Response, tipsets []*types.T // If we didn't request the headers they should have been provided // by the caller. if len(tipsets) < len(res.Chain) { - return nil, xerrors.Errorf("not enought tipsets provided for message response validation, needed %d, have %d", len(res.Chain), len(tipsets)) + return nil, xerrors.Errorf("not enough tipsets provided for message response validation, needed %d, have %d", len(res.Chain), len(tipsets)) } chain := make([]*BSTipSet, 0, resLength) for i, resChain := range res.Chain { diff --git a/chain/index/msgindex.go b/chain/index/msgindex.go index 27eeea73e1d..e9e81ae2cf5 100644 --- a/chain/index/msgindex.go +++ b/chain/index/msgindex.go @@ -131,7 +131,7 @@ func NewMsgIndex(lctx context.Context, basePath string, cs ChainStore) (MsgIndex db, err := sql.Open("sqlite3", dbPath) if err != nil { - // TODO [nice to have]: automaticaly delete corrupt databases + // TODO [nice to have]: automatically delete corrupt databases // but for now we can just error and let the operator delete. return nil, xerrors.Errorf("error opening msgindex database: %w", err) } diff --git a/chain/state/statetree.go b/chain/state/statetree.go index c71473e8fa0..a0356f44cdf 100644 --- a/chain/state/statetree.go +++ b/chain/state/statetree.go @@ -570,7 +570,7 @@ func (st *StateTree) ForEach(f func(address.Address, *types.Actor) error) error } // no need to record anything here, there are no duplicates in the actors HAMT - // iself. + // itself. if _, ok := seen[addr]; ok { return nil } @@ -588,7 +588,7 @@ func (st *StateTree) ForEach(f func(address.Address, *types.Actor) error) error } // no need to record anything here, there are no duplicates in the actors HAMT - // iself. + // itself. if _, ok := seen[addr]; ok { return nil } diff --git a/chain/store/snapshot.go b/chain/store/snapshot.go index f1bc800e09c..301a5f87bfd 100644 --- a/chain/store/snapshot.go +++ b/chain/store/snapshot.go @@ -167,7 +167,7 @@ func (t walkSchedTaskType) String() string { case dagTask: return "dag" } - panic(fmt.Sprintf("unknow task %d", t)) + panic(fmt.Sprintf("unknown task %d", t)) } type walkTask struct { diff --git a/chain/sub/incoming.go b/chain/sub/incoming.go index 3a11f7c9888..b50ddc46779 100644 --- a/chain/sub/incoming.go +++ b/chain/sub/incoming.go @@ -516,7 +516,7 @@ func (v *IndexerMessageValidator) Validate(ctx context.Context, pid peer.ID, msg return pubsub.ValidationReject } if len(idxrMsg.ExtraData) == 0 { - log.Debugw("ignoring messsage missing miner id", "peer", originPeer) + log.Debugw("ignoring message missing miner id", "peer", originPeer) return pubsub.ValidationIgnore } @@ -552,7 +552,7 @@ func (v *IndexerMessageValidator) Validate(ctx context.Context, pid peer.ID, msg // Check that the miner ID maps to the peer that sent the message. err = v.authenticateMessage(ctx, minerAddr, originPeer) if err != nil { - log.Warnw("cannot authenticate messsage", "err", err, "peer", originPeer, "minerID", minerAddr) + log.Warnw("cannot authenticate message", "err", err, "peer", originPeer, "minerID", minerAddr) stats.Record(ctx, metrics.IndexerMessageValidationFailure.M(1)) return pubsub.ValidationReject } diff --git a/chain/sync.go b/chain/sync.go index 6341deeeb49..1b9a302f75d 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -844,7 +844,7 @@ loop: return nil, xerrors.Errorf("failed to load next local tipset: %w", err) } if base.IsChildOf(knownParent) { - // common case: receiving a block thats potentially part of the same tipset as our best block + // common case: receiving a block that's potentially part of the same tipset as our best block return blockSet, nil } @@ -1094,8 +1094,8 @@ func (syncer *Syncer) fetchMessages(ctx context.Context, headers []*types.TipSet requestErr = multierror.Append(requestErr, err) } else { isGood := true - for index, ts := range headers[nextI:lastI] { - cm := result[index] + for index, cm := range result { + ts := headers[nextI+index] if err := checkMsgMeta(ts, cm.Bls, cm.Secpk, cm.BlsIncludes, cm.SecpkIncludes); err != nil { log.Errorf("fetched messages not as expected: %s", err) isGood = false diff --git a/chain/types/message_receipt_cbor.go b/chain/types/message_receipt_cbor.go index e1364e654d8..955ca4d8533 100644 --- a/chain/types/message_receipt_cbor.go +++ b/chain/types/message_receipt_cbor.go @@ -140,7 +140,7 @@ func (t *messageReceiptV0) UnmarshalCBOR(r io.Reader) (err error) { case cbg.MajNegativeInt: extraI = int64(extra) if extraI < 0 { - return fmt.Errorf("int64 negative oveflow") + return fmt.Errorf("int64 negative overflow") } extraI = -1 - extraI default: @@ -186,7 +186,7 @@ func (t *messageReceiptV0) UnmarshalCBOR(r io.Reader) (err error) { case cbg.MajNegativeInt: extraI = int64(extra) if extraI < 0 { - return fmt.Errorf("int64 negative oveflow") + return fmt.Errorf("int64 negative overflow") } extraI = -1 - extraI default: @@ -278,7 +278,7 @@ func (t *messageReceiptV1) UnmarshalCBOR(r io.Reader) (err error) { case cbg.MajNegativeInt: extraI = int64(extra) if extraI < 0 { - return fmt.Errorf("int64 negative oveflow") + return fmt.Errorf("int64 negative overflow") } extraI = -1 - extraI default: @@ -324,7 +324,7 @@ func (t *messageReceiptV1) UnmarshalCBOR(r io.Reader) (err error) { case cbg.MajNegativeInt: extraI = int64(extra) if extraI < 0 { - return fmt.Errorf("int64 negative oveflow") + return fmt.Errorf("int64 negative overflow") } extraI = -1 - extraI default: diff --git a/cmd/lotus-gateway/main.go b/cmd/lotus-gateway/main.go index 2023551ef80..35a43e18b1e 100644 --- a/cmd/lotus-gateway/main.go +++ b/cmd/lotus-gateway/main.go @@ -143,7 +143,7 @@ var runCmd = &cli.Command{ }, &cli.DurationFlag{ Name: "rate-limit-timeout", - Usage: "the maximum time to wait for the rate limter before returning an error to clients", + Usage: "the maximum time to wait for the rate limiter before returning an error to clients", Value: gateway.DefaultRateLimitTimeout, }, &cli.Int64Flag{ diff --git a/cmd/lotus-shed/invariants.go b/cmd/lotus-shed/invariants.go index 51d746f79d0..e74a0dd24c2 100644 --- a/cmd/lotus-shed/invariants.go +++ b/cmd/lotus-shed/invariants.go @@ -16,6 +16,7 @@ import ( "github.com/filecoin-project/go-state-types/builtin" v10 "github.com/filecoin-project/go-state-types/builtin/v10" v11 "github.com/filecoin-project/go-state-types/builtin/v11" + v12 "github.com/filecoin-project/go-state-types/builtin/v12" v8 "github.com/filecoin-project/go-state-types/builtin/v8" v9 "github.com/filecoin-project/go-state-types/builtin/v9" @@ -149,6 +150,13 @@ var invariantsCmd = &cli.Command{ if err != nil { return xerrors.Errorf("checking state invariants: %w", err) } + case actorstypes.Version12: + messages, err = v12.CheckStateInvariants(actorTree, abi.ChainEpoch(epoch), actorCodeCids) + if err != nil { + return xerrors.Errorf("checking state invariants: %w", err) + } + default: + return xerrors.Errorf("unsupported actor version: %v", av) } fmt.Println("completed, took ", time.Since(startTime)) diff --git a/cmd/lotus-shed/pruning.go b/cmd/lotus-shed/pruning.go index 275f3bc0a8c..c0bd453b145 100644 --- a/cmd/lotus-shed/pruning.go +++ b/cmd/lotus-shed/pruning.go @@ -12,7 +12,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" - badgerbs "github.com/filecoin-project/lotus/blockstore/badger" + "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/node/repo" @@ -144,13 +144,6 @@ var stateTreePruneCmd = &cli.Command{ } }() - // After migrating to native blockstores, this has been made - // database-specific. - badgbs, ok := bs.(*badgerbs.Blockstore) - if !ok { - return fmt.Errorf("only badger blockstores are supported") - } - mds, err := lkrepo.Datastore(context.Background(), "/metadata") if err != nil { return err @@ -160,8 +153,12 @@ var stateTreePruneCmd = &cli.Command{ const DiscardRatio = 0.2 if cctx.Bool("only-ds-gc") { fmt.Println("running datastore gc....") + gbs, ok := bs.(blockstore.BlockstoreGCOnce) + if !ok { + return xerrors.Errorf("blockstore %T does not support GC", bs) + } for i := 0; i < cctx.Int("gc-count"); i++ { - if err := badgbs.DB().RunValueLogGC(DiscardRatio); err != nil { + if err := gbs.GCOnce(ctx, blockstore.WithThreshold(DiscardRatio)); err != nil { return xerrors.Errorf("datastore GC failed: %w", err) } } @@ -208,13 +205,6 @@ var stateTreePruneCmd = &cli.Command{ return nil } - b := badgbs.DB().NewWriteBatch() - defer b.Cancel() - - markForRemoval := func(c cid.Cid) error { - return b.Delete(badgbs.StorageKey(nil, c)) - } - keys, err := bs.AllKeysChan(context.Background()) if err != nil { return xerrors.Errorf("failed to query blockstore: %w", err) @@ -225,12 +215,12 @@ var stateTreePruneCmd = &cli.Command{ var deleteCount int var goodHits int for k := range keys { - if goodSet.HasRaw(k.Bytes()) { + if goodSet.Has(k) { goodHits++ continue } - if err := markForRemoval(k); err != nil { + if err := bs.DeleteBlock(ctx, k); err != nil { return fmt.Errorf("failed to remove cid %s: %w", k, err) } @@ -243,13 +233,15 @@ var stateTreePruneCmd = &cli.Command{ } } - if err := b.Flush(); err != nil { - return xerrors.Errorf("failed to flush final batch delete: %w", err) + fmt.Println("running datastore gc....") + gbs, ok := bs.(blockstore.BlockstoreGCOnce) + if !ok { + fmt.Println("gc not supported...") + return nil } - fmt.Println("running datastore gc....") for i := 0; i < cctx.Int("gc-count"); i++ { - if err := badgbs.DB().RunValueLogGC(DiscardRatio); err != nil { + if err := gbs.GCOnce(ctx, blockstore.WithThreshold(DiscardRatio)); err != nil { return xerrors.Errorf("datastore GC failed: %w", err) } } diff --git a/documentation/en/block-validation.md b/documentation/en/block-validation.md index d178a0667d5..ac711c6bf2b 100644 --- a/documentation/en/block-validation.md +++ b/documentation/en/block-validation.md @@ -104,9 +104,9 @@ domain separation tag. ### Winning PoSt proof Draw randomness for current epoch with `WinningPoSt` domain separation tag. -Get list of sectors challanged in this epoch for this miner, based on the randomness drawn. +Get list of sectors challenged in this epoch for this miner, based on the randomness drawn. -`V`: Use filecoin proofs system to verify that miner prooved access to sealed versions of these sectors. +`V`: Use filecoin proofs system to verify that miner proved access to sealed versions of these sectors. ## `(*StateManager).TipSetState()` diff --git a/documentation/misc/RELEASE_ISSUE_TEMPLATE.md b/documentation/misc/RELEASE_ISSUE_TEMPLATE.md index 116c615d379..42f44b95576 100644 --- a/documentation/misc/RELEASE_ISSUE_TEMPLATE.md +++ b/documentation/misc/RELEASE_ISSUE_TEMPLATE.md @@ -14,11 +14,13 @@ **Note for whoever is owning the release:** please capture notes as comments in this issue for anything you noticed that could be improved for future releases. There is a *Post Release* step below for incorporating changes back into the [RELEASE_ISSUE_TEMPLATE](https://github.com/filecoin-project/lotus/blob/master/documentation/misc/RELEASE_ISSUE_TEMPLATE.md), and this is easier done by collecting notes from along the way rather than just thinking about it at the end. First steps: - - [ ] FFI: Fork a new branch (`release/lotus-vX.Y.Z`) from the filecoin-ffi `master` branch - - [ ] FFI: Tag the head of `release/lotus-vX.Y.Z` as `vX.Y.Z-pre1` + - [ ] Set shell variables vX.Y.Z `export X=1 && export Y=24 && export Z=3` + - [ ] FFI: Fork a new branch (`release/lotus-vX.Y.Z`) from the filecoin-ffi `master` branch: `git checkout master && git checkout -b release/lotus-v$X.$Y.$Z` + - [ ] FFI: Tag the head of `release/lotus-vX.Y.Z` as `vX.Y.Z-pre1`: `git tag -a v$X.$Y.$Z-pre1 -m"release"` - [ ] Open and land a PR in lotus `master` that updates the FFI dependency to `vX.Y.Z-pre1` as cut in the previous step - [ ] Fork a new branch (`release/vX.Y.Z`) from `master` and make any further release related changes to this branch. If any "non-trivial" changes get added to the release, uncheck all the checkboxes and return to this stage. - - [ ] Bump the version in `build/version.go` in the `master` branch to `vX.Y.(Z+1)-dev` (bump from feature release) or `vX.(Y+1).0-dev` (bump from mandatory release). Run make gen and make docsgen-cli before committing changes + - [ ] Bump the version in `build/version.go` in the `master` branch to `vX.Y.(Z+1)-dev` (bump from feature release) or `vX.(Y+1).0-dev` (bump from mandatory release). + - [ ] Run `make gen && make docsgen-cli` before committing changes **Prepping an RC**: @@ -26,6 +28,7 @@ First steps: - [ ] run `make gen && make docsgen-cli` - [ ] Generate changelog using the script at scripts/mkreleaselog - [ ] Add contents of generated text to lotus/CHANGELOG.md in addition to other details +- [ ] Commit using PR - [ ] tag commit with `vX.Y.Z-rcN` - [ ] cut a pre-release [here](https://github.com/filecoin-project/lotus/releases/new?prerelease=true) diff --git a/itests/eth_transactions_test.go b/itests/eth_transactions_test.go index b3963279571..6d60f678636 100644 --- a/itests/eth_transactions_test.go +++ b/itests/eth_transactions_test.go @@ -81,12 +81,16 @@ func TestValueTransferValidSignature(t *testing.T) { receipt, err := waitForEthTxReceipt(ctx, client, hash) require.NoError(t, err) require.NotNil(t, receipt) + require.EqualValues(t, ethAddr, receipt.From) + require.EqualValues(t, ethAddr2, *receipt.To) + require.EqualValues(t, hash, receipt.TransactionHash) // Success. require.EqualValues(t, ethtypes.EthUint64(0x1), receipt.Status) + // Validate that we sent the expected transaction. ethTx, err := client.EthGetTransactionByHash(ctx, &hash) - require.Nil(t, err) + require.NoError(t, err) require.EqualValues(t, ethAddr, ethTx.From) require.EqualValues(t, ethAddr2, *ethTx.To) require.EqualValues(t, tx.ChainID, ethTx.ChainID) @@ -269,6 +273,17 @@ func TestContractInvocation(t *testing.T) { // Success. require.EqualValues(t, ethtypes.EthUint64(0x1), receipt.Status) + + // Validate that we correctly computed the gas outputs. + mCid, err := client.EthGetMessageCidByTransactionHash(ctx, &hash) + require.NoError(t, err) + require.NotNil(t, mCid) + + invokResult, err := client.StateReplay(ctx, types.EmptyTSK, *mCid) + require.NoError(t, err) + require.EqualValues(t, invokResult.GasCost.GasUsed, big.NewInt(int64(receipt.GasUsed))) + effectiveGasPrice := big.Div(invokResult.GasCost.TotalCost, invokResult.GasCost.GasUsed) + require.EqualValues(t, effectiveGasPrice, big.Int(receipt.EffectiveGasPrice)) } func TestGetBlockByNumber(t *testing.T) { diff --git a/node/builder.go b/node/builder.go index f1a825be922..128a99f8714 100644 --- a/node/builder.go +++ b/node/builder.go @@ -90,6 +90,7 @@ const ( // health checks CheckFDLimit CheckFvmConcurrency + CheckUDPBufferSize LegacyMarketsEOL // libp2p @@ -169,6 +170,7 @@ func defaults() []Option { Override(CheckFDLimit, modules.CheckFdLimit(build.DefaultFDLimit)), Override(CheckFvmConcurrency, modules.CheckFvmConcurrency()), + Override(CheckUDPBufferSize, modules.CheckUDPBufferSize(2048*1024)), Override(new(system.MemoryConstraints), modules.MemoryConstraints), Override(InitMemoryWatchdog, modules.MemoryWatchdog), diff --git a/node/bundle/bundle.go b/node/bundle/bundle.go index a55cad9f124..716c9043bb6 100644 --- a/node/bundle/bundle.go +++ b/node/bundle/bundle.go @@ -69,7 +69,7 @@ func LoadBundles(ctx context.Context, bs blockstore.Blockstore, versions ...acto ) if path, ok := build.BundleOverrides[av]; ok { root, err = LoadBundleFromFile(ctx, bs, path) - } else if embedded, ok := build.GetEmbeddedBuiltinActorsBundle(av); ok { + } else if embedded, ok := build.GetEmbeddedBuiltinActorsBundle(av, build.NetworkBundle); ok { root, err = LoadBundle(ctx, bs, bytes.NewReader(embedded)) } else { err = xerrors.Errorf("bundle for actors version v%d not found", av) diff --git a/node/impl/full/eth.go b/node/impl/full/eth.go index eb786d52dde..3b9b6d6ab86 100644 --- a/node/impl/full/eth.go +++ b/node/impl/full/eth.go @@ -733,10 +733,11 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (eth } rewards, totalGasUsed := calculateRewardsAndGasUsed(rewardPercentiles, txGasRewards) + maxGas := build.BlockGasLimit * int64(len(ts.Blocks())) // arrays should be reversed at the end baseFeeArray = append(baseFeeArray, ethtypes.EthBigInt(basefee)) - gasUsedRatioArray = append(gasUsedRatioArray, float64(totalGasUsed)/float64(build.BlockGasLimit)) + gasUsedRatioArray = append(gasUsedRatioArray, float64(totalGasUsed)/float64(maxGas)) rewardsArray = append(rewardsArray, rewards) oldestBlkHeight = uint64(ts.Height()) blocksIncluded++ diff --git a/node/impl/full/eth_utils.go b/node/impl/full/eth_utils.go index f553c68b4c8..d1e8b7dd207 100644 --- a/node/impl/full/eth_utils.go +++ b/node/impl/full/eth_utils.go @@ -627,7 +627,13 @@ func newEthTxReceipt(ctx context.Context, tx ethtypes.EthTx, lookup *api.MsgLook return api.EthTxReceipt{}, xerrors.Errorf("failed to lookup tipset %s when constructing the eth txn receipt: %w", lookup.TipSet, err) } - baseFee := ts.Blocks()[0].ParentBaseFee + // The tx is located in the parent tipset + parentTs, err := cs.LoadTipSet(ctx, ts.Parents()) + if err != nil { + return api.EthTxReceipt{}, xerrors.Errorf("failed to lookup tipset %s when constructing the eth txn receipt: %w", ts.Parents(), err) + } + + baseFee := parentTs.Blocks()[0].ParentBaseFee gasOutputs := vm.ComputeGasOutputs(lookup.Receipt.GasUsed, int64(tx.Gas), baseFee, big.Int(tx.MaxFeePerGas), big.Int(tx.MaxPriorityFeePerGas), true) totalSpent := big.Sum(gasOutputs.BaseFeeBurn, gasOutputs.MinerTip, gasOutputs.OverEstimationBurn) diff --git a/node/modules/alerts.go b/node/modules/alerts.go index 724761e3c6c..9976c6d0e42 100644 --- a/node/modules/alerts.go +++ b/node/modules/alerts.go @@ -1,8 +1,10 @@ package modules import ( + "net" "os" "strconv" + "syscall" "github.com/filecoin-project/lotus/journal/alerting" "github.com/filecoin-project/lotus/lib/ulimit" @@ -35,6 +37,69 @@ func CheckFdLimit(min uint64) func(al *alerting.Alerting) { } } +func CheckUDPBufferSize(wanted int) func(al *alerting.Alerting) { + return func(al *alerting.Alerting) { + conn, err := net.Dial("udp", "localhost:0") + if err != nil { + alert := al.AddAlertType("process", "udp-buffer-size") + al.Raise(alert, map[string]string{ + "message": "Failed to create UDP connection", + "error": err.Error(), + }) + return + } + defer func() { + if err := conn.Close(); err != nil { + log.Warnf("Failed to close connection: %s", err) + } + }() + + udpConn, ok := conn.(*net.UDPConn) + if !ok { + alert := al.AddAlertType("process", "udp-buffer-size") + al.Raise(alert, map[string]string{ + "message": "Failed to cast connection to UDPConn", + }) + return + } + + file, err := udpConn.File() + if err != nil { + alert := al.AddAlertType("process", "udp-buffer-size") + al.Raise(alert, map[string]string{ + "message": "Failed to get file descriptor from UDPConn", + "error": err.Error(), + }) + return + } + defer func() { + if err := file.Close(); err != nil { + log.Warnf("Failed to close file: %s", err) + } + }() + + size, err := syscall.GetsockoptInt(int(file.Fd()), syscall.SOL_SOCKET, syscall.SO_RCVBUF) + if err != nil { + alert := al.AddAlertType("process", "udp-buffer-size") + al.Raise(alert, map[string]string{ + "message": "Failed to get UDP buffer size", + "error": err.Error(), + }) + return + } + + if size < wanted { + alert := al.AddAlertType("process", "udp-buffer-size") + al.Raise(alert, map[string]interface{}{ + "message": "UDP buffer size is low", + "current_size": size, + "wanted_size": wanted, + "help": "See https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes for details.", + }) + } + } +} + func LegacyMarketsEOL(al *alerting.Alerting) { // Add alert if lotus-miner legacy markets subsystem is still in use alert := al.AddAlertType("system", "EOL") diff --git a/paychmgr/paych.go b/paychmgr/paych.go index 1eb496dba2a..2729513ce88 100644 --- a/paychmgr/paych.go +++ b/paychmgr/paych.go @@ -482,7 +482,7 @@ func (ca *channelAccessor) listVouchers(ctx context.Context, ch address.Address) // the data store over the chain state func (ca *channelAccessor) laneState(ctx context.Context, state lpaych.State, ch address.Address) (map[uint64]lpaych.LaneState, error) { // TODO: we probably want to call UpdateChannelState with all vouchers to be fully correct - // (but technically dont't need to) + // (but technically don't need to) laneCount, err := state.LaneCount() if err != nil { diff --git a/storage/sealer/ffiwrapper/sealer_cgo.go b/storage/sealer/ffiwrapper/sealer_cgo.go index fec12f231e4..8e970adaaa4 100644 --- a/storage/sealer/ffiwrapper/sealer_cgo.go +++ b/storage/sealer/ffiwrapper/sealer_cgo.go @@ -928,7 +928,7 @@ func (sb *Sealer) SealPreCommit2(ctx context.Context, sector storiface.SectorRef return storiface.SectorCids{}, xerrors.Errorf("generate synth proofs: %w", err) } - if err = ffi.ClearLayerData(ssize, paths.Cache); err != nil { + if err = ffi.ClearCache(uint64(ssize), paths.Cache); err != nil { log.Warn("failed to GenerateSynthProofs(): ", err) log.Warnf("num:%d tkt:%v, sealedCID:%v, unsealedCID:%v", sector.ID.Number, ticket, sealedCID, unsealedCID) return storiface.SectorCids{