filecoin-project / go-state-types

Primitive and low level types used in chain state and actor method parameters
Other
27 stars 37 forks source link

V13 calibration actor manifest mismatch #293

Closed Schwartz10 closed 3 months ago

Schwartz10 commented 3 months ago

I have a go program that relies on Lotus and go-state-types to determine if a specific address is a storageminer actor. The program looks up the actor code associated with the address, and compares it to the same actor version manifests from go-state-types/build package

The following code works on mainnet, but not on calibration:

        build.UseNetworkBundle("calibrationnet")
        addr, _ := address.NewFromString("f0134489")
        actor, _ := lapi.StateGetActor(context.TODO(), addr, types.EmptyTSK)
                version := actorstypes.Version(13)
        actorCode, _ := actors.GetActorCodeID(version, manifest.MinerKey)
        str, version, ok := actors.GetActorMetaByCode(actor.Code)

        // DO NOT MATCH ON CALIBNET
        fmt.Println(str, version, ok)
        fmt.Println(actorCode)
        fmt.Println(actor.Code)
    github.com/filecoin-project/go-state-types v0.14.0-dev
    github.com/filecoin-project/lotus v1.27.2

I've tried various other versions of go-state-types and lotus with the same end result:

 -1 false
bafk2bzaceckzw3v7wqliyggvjvihz4wywchnnsie4frfvkm3fm5znb64mofri
bafk2bzacecr7ozkdz7l2pq3ig5qxae2ysivbnojhsn4gw3o57ov4mhksma7me

Does anyone know how I can get:

        actorCode, _ := actors.GetActorCodeID(version, manifest.MinerKey)

To match the correct actorCode returned by (live) calibrationnet for a storageminer? Am i using a wrong version of something? Loading the wrong manifests somehow?

Stebalien commented 3 months ago

Calibrationnet is on version 14 now. That is:

                version := actorstypes.Version(14) // 13 -> 14
Schwartz10 commented 3 months ago

Hey thanks for responding so quickly @Stebalien ! That makes much more sense.. tho i'm confused why (without changing the lotus version in my go.mod) changing the version from 13->14 doesn't change the code CID i get back from actors.GetActorCodeID. My guess is that i need to upgrade my filecoin-project/lotus dep to somewhere in the 1.28 range... but doing so breaks my code haha. I may just hardcode the right CID for now :see_no_evil:

Stebalien commented 3 months ago

Well, if you'll need to do that if you want to interact with calibrationnet anyways, right? Or are you using lotus as a library?

Schwartz10 commented 3 months ago

Using lotus as a library for a backend service. We like to run a calibnet version and a mainnet version side by side - and normally we had been using LatestVersion() to derive the right "live version" number for each actor type. So the LatestVersion when using 1.26.. is correct for mainnet, but incorrect for calibnet. Then if you upgrade, the flip side occurs haha. I can probably patch this on my side for now tho by upgrading lotus and manually using actor version 13 for mainnet and actor version 14 for calibration

Stebalien commented 3 months ago

Ah, so, the issue is that you need to get the current version for the network. I.e. Epoch->NetworkVersion -> ActorVersion.

Alternatively, you can always call https://github.com/filecoin-project/lotus/blob/43b7a78a587d27c763a9bb2afb102410b873b39f/chain/actors/builtin/builtin.go#L168. That'll always work for the latest version (as long as you're on the right network).

Stebalien commented 3 months ago

(closing because there isn't really anything we can do here)