diff --git a/commands/util/import.go b/commands/util/import.go index 2838ce5af..2a94352a7 100644 --- a/commands/util/import.go +++ b/commands/util/import.go @@ -10,6 +10,7 @@ import ( "os" "strings" + "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" @@ -69,7 +70,7 @@ func ImportFromFsFile(ctx context.Context, r repo.Repo, fs fs.File, snapshot boo return err } - stm, err := stmgr.NewStateManager(cst, filcns.NewTipSetExecutor(), vm.Syscalls(ffiwrapper.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil) + stm, err := stmgr.NewStateManager(cst, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(ffiwrapper.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil) if err != nil { return err } @@ -183,7 +184,7 @@ func ImportChain(ctx context.Context, r repo.Repo, fname string, snapshot bool) return err } - stm, err := stmgr.NewStateManager(cst, filcns.NewTipSetExecutor(), vm.Syscalls(ffiwrapper.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil) + stm, err := stmgr.NewStateManager(cst, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(ffiwrapper.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil) if err != nil { return err } diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index 7efaa7b47..88dc4c4ce 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit 7efaa7b47fe9d4bdb4ba0b2a0fafa4e573864ee5 +Subproject commit 88dc4c4ceb322337818b6508c8e9c23948f36cb1 diff --git a/go.mod b/go.mod index 745e32d24..e2898b27d 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/filecoin-project/go-jsonrpc v0.2.1 github.com/filecoin-project/go-paramfetch v0.0.4 github.com/filecoin-project/go-state-types v0.10.0 - github.com/filecoin-project/lotus v1.20.0 + github.com/filecoin-project/lotus v1.20.1-0.20230302000218-dbbcf4b2ee96 github.com/filecoin-project/specs-actors v0.9.15 github.com/filecoin-project/specs-actors/v2 v2.3.6 github.com/filecoin-project/specs-actors/v3 v3.1.2 @@ -130,7 +130,7 @@ require ( github.com/filecoin-project/go-ds-versioning v0.1.2 // indirect github.com/filecoin-project/go-fil-commcid v0.1.0 // indirect github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 // indirect - github.com/filecoin-project/go-fil-markets v1.25.2 // indirect + github.com/filecoin-project/go-fil-markets v1.26.0 // indirect github.com/filecoin-project/go-hamt-ipld v0.1.5 // indirect github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 // indirect github.com/filecoin-project/go-legs v0.4.4 // indirect @@ -138,10 +138,8 @@ require ( github.com/filecoin-project/go-statemachine v1.0.2 // indirect github.com/filecoin-project/go-statestore v0.2.0 // indirect github.com/filecoin-project/go-storedcounter v0.1.0 // indirect - github.com/filecoin-project/index-provider v0.9.1 // indirect github.com/filecoin-project/pubsub v1.0.0 // indirect github.com/filecoin-project/specs-actors/v8 v8.0.1 // indirect - github.com/filecoin-project/storetheindex v0.4.30-0.20221114113647-683091f8e893 // indirect github.com/flynn/noise v1.0.0 // indirect github.com/francoispqt/gojay v1.2.13 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect @@ -220,6 +218,8 @@ require ( github.com/ipld/go-ipld-adl-hamt v0.0.0-20220616142416-9004dbd839e0 // indirect github.com/ipld/go-ipld-prime v0.20.0 // indirect github.com/ipld/go-ipld-selector-text-lite v0.0.1 // indirect + github.com/ipni/index-provider v0.10.0 // indirect + github.com/ipni/storetheindex v0.5.3-0.20221203123030-16745cb63f15 // indirect github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c // indirect diff --git a/go.sum b/go.sum index 4c3d829c0..879c94def 100644 --- a/go.sum +++ b/go.sum @@ -320,8 +320,8 @@ github.com/filecoin-project/go-fil-commcid v0.1.0 h1:3R4ds1A9r6cr8mvZBfMYxTS88Oq github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 h1:imrrpZWEHRnNqqv0tN7LXep5bFEVOVmQWHJvl2mgsGo= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0/go.mod h1:73S8WSEWh9vr0fDJVnKADhfIv/d6dCbAGaAGWbdJEI8= -github.com/filecoin-project/go-fil-markets v1.25.2 h1:kVfgaamTC7dkn8KwS5zRJBNEBSNvVqdG3BCoDaUYuCI= -github.com/filecoin-project/go-fil-markets v1.25.2/go.mod h1:dc2oTPU6GH3Qk1nA+Er+hSX64rg+NVykkPIWFBYxcZU= +github.com/filecoin-project/go-fil-markets v1.26.0 h1:uNtt1UAxX2C/Q8tlWD00oF2Zma3CVGxhZmBc2ljYhkk= +github.com/filecoin-project/go-fil-markets v1.26.0/go.mod h1:eOIYHfPwyqc64O1HiapvcelfnrTfU7gLQgBf55IYleQ= github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3LPEk0OrS/ytIBM= github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CWaXZc0Hdb/JeX+EQCQzX24= github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxlWi3xVvbQP0IT38fvM= @@ -356,10 +356,8 @@ github.com/filecoin-project/go-statestore v0.2.0 h1:cRRO0aPLrxKQCZ2UOQbzFGn4WDNd github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lIXjLlYyPor80aU7t7a/Kspo= github.com/filecoin-project/go-storedcounter v0.1.0 h1:Mui6wSUBC+cQGHbDUBcO7rfh5zQkWJM/CpAZa/uOuus= github.com/filecoin-project/go-storedcounter v0.1.0/go.mod h1:4ceukaXi4vFURIoxYMfKzaRF5Xv/Pinh2oTnoxpv+z8= -github.com/filecoin-project/index-provider v0.9.1 h1:Jnh9dviIHvQxZ2baNoYu3n8z6F9O62ksnVlyREgPyyM= -github.com/filecoin-project/index-provider v0.9.1/go.mod h1:NlHxQcy2iMGfUoUGUzrRxntcpiC50QSnvp68u2VTT40= -github.com/filecoin-project/lotus v1.20.0 h1:Jm08hHbqjXFieNluVQL/SXWrqXnW2RP6b9bxKJ/GQig= -github.com/filecoin-project/lotus v1.20.0/go.mod h1:dprpVaiQezI8Jl4tWcPNIYGGAAo31feZlGAOk8D7bJU= +github.com/filecoin-project/lotus v1.20.1-0.20230302000218-dbbcf4b2ee96 h1:qtyxiKpJcsktp2EeL/OscVNbw1fRy8C5j9yeguA8AZY= +github.com/filecoin-project/lotus v1.20.1-0.20230302000218-dbbcf4b2ee96/go.mod h1:IgwxSgrL1HgkSexOjTHOIdaTUIvPOetuAjAqFQgHkSc= github.com/filecoin-project/pubsub v1.0.0 h1:ZTmT27U07e54qV1mMiQo4HDr0buo8I1LDHBYLXlsNXM= github.com/filecoin-project/pubsub v1.0.0/go.mod h1:GkpB33CcUtUNrLPhJgfdy4FDx4OMNR9k+46DHx/Lqrg= github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= @@ -380,8 +378,6 @@ github.com/filecoin-project/specs-actors/v7 v7.0.1 h1:w72xCxijK7xs1qzmJiw+WYJaVt github.com/filecoin-project/specs-actors/v7 v7.0.1/go.mod h1:tPLEYXoXhcpyLh69Ccq91SOuLXsPWjHiY27CzawjUEk= github.com/filecoin-project/specs-actors/v8 v8.0.1 h1:4u0tIRJeT5G7F05lwLRIsDnsrN+bJ5Ixj6h49Q7uE2Y= github.com/filecoin-project/specs-actors/v8 v8.0.1/go.mod h1:UYIPg65iPWoFw5NEftREdJwv9b/5yaLKdCgTvNI/2FA= -github.com/filecoin-project/storetheindex v0.4.30-0.20221114113647-683091f8e893 h1:6GCuzxLVHBzlz7y+FkbHh6n0UyoEGWqDwJKQPJoz7bE= -github.com/filecoin-project/storetheindex v0.4.30-0.20221114113647-683091f8e893/go.mod h1:S7590oDimBvXMUtzWsBXoshu9HtYKwtXl47zAK9rcP8= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ= github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ= @@ -882,6 +878,10 @@ github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd73/go.mod h1:2PJ0JgxyB08t0b2WKrcuqI3di0V+5n6RS/LTUJhkoxY= github.com/ipld/go-ipld-selector-text-lite v0.0.1 h1:lNqFsQpBHc3p5xHob2KvEg/iM5dIFn6iw4L/Hh+kS1Y= github.com/ipld/go-ipld-selector-text-lite v0.0.1/go.mod h1:U2CQmFb+uWzfIEF3I1arrDa5rwtj00PrpiwwCO+k1RM= +github.com/ipni/index-provider v0.10.0 h1:nu8YBxzRopdjwZHsgCUuC4AHpq88VVHJYrbkqUDx7eg= +github.com/ipni/index-provider v0.10.0/go.mod h1:InSXbZp2p/ZhAwiDElG/wzjnA1ea1iJ3hhyiAHrD+Vo= +github.com/ipni/storetheindex v0.5.3-0.20221203123030-16745cb63f15 h1:qJq6QtLk+9nQi3CDBhNfJ1cjZ4pghjCHcQUZ1mWbF0k= +github.com/ipni/storetheindex v0.5.3-0.20221203123030-16745cb63f15/go.mod h1:c/NS640Iu2NrCCIErnUhsUM5KVEyeXymgtNnx6eDwMU= github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52 h1:QG4CGBqCeuBo6aZlGAamSkxWdgWfZGeE49eUOWJPA4c= github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52/go.mod h1:fdg+/X9Gg4AsAIzWpEHwnqd+QY3b7lajxyjE1m4hkq4= github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA= diff --git a/lens/lily/impl.go b/lens/lily/impl.go index 8393fb21c..771c80cb7 100644 --- a/lens/lily/impl.go +++ b/lens/lily/impl.go @@ -10,7 +10,7 @@ import ( "github.com/filecoin-project/go-state-types/exitcode" network2 "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/consensus/filcns" + "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/events" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/stmgr" @@ -701,7 +701,7 @@ func (m *LilyNodeAPI) BurnFundsFn(ctx context.Context, ts *types.TipSet) (lens.S StateBase: ts.ParentState(), Epoch: ts.Height(), Bstore: m.ChainAPI.Chain.StateBlockstore(), - Actors: filcns.NewActorRegistry(), + Actors: consensus.NewActorRegistry(), Syscalls: m.StateManager.Syscalls, CircSupplyCalc: m.StateManager.GetVMCirculatingSupply, NetworkVersion: util.DefaultNetwork.Version(ctx, ts.Height()), diff --git a/lens/util/repo.go b/lens/util/repo.go index 5e2e3903e..46e4177dd 100644 --- a/lens/util/repo.go +++ b/lens/util/repo.go @@ -8,9 +8,9 @@ import ( "fmt" "reflect" "strings" - "time" "github.com/filecoin-project/go-bitfield" + "github.com/filecoin-project/lotus/chain/consensus" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" cbg "github.com/whyrusleeping/cbor-gen" @@ -19,7 +19,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" builtin "github.com/filecoin-project/lotus/chain/actors/builtin" - "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/vm" @@ -31,11 +30,55 @@ import ( var ActorRegistry *vm.ActorRegistry func init() { - ActorRegistry = filcns.NewActorRegistry() + ActorRegistry = consensus.NewActorRegistry() } var log = logging.Logger("lily/lens") +func ParseVmMessageParams(params []byte, paramsCodec uint64, method abi.MethodNum, actCode cid.Cid) (string, string, error) { + m, found := ActorRegistry.Methods[actCode][method] + if !found { + // if the method wasn't found it is likely the case the method was one of: + // https://github.com/filecoin-project/builtin-actors/blob/f5311fe735df4d9baf5f82d4b3db10f3c51688c4/actors/docs/README.md?plain=1#L31 + // so we just marshal the raw value to json and bail with a warning + paramj, err := json.Marshal(params) + if err != nil { + return "", "", err + } + err = fmt.Errorf("unknown method %d with codec %d for actorCode %s name %s", method, paramsCodec, actCode, builtin.ActorNameByCode(actCode)) + log.Warnw("parsing vm message params", "error", err) + return string(paramj), builtin.ActorNameByCode(actCode), nil + } + // If the codec is 0, the parameters/return value are "empty". + // If the codec is 0x55, it's bytes. + if paramsCodec == 0 || paramsCodec == 0x55 { + return string(params), m.Name, nil + } + return ParseParams(params, method, actCode) +} + +func ParseVmMessageReturn(ret []byte, retCodec uint64, method abi.MethodNum, actCode cid.Cid) (string, string, error) { + m, found := ActorRegistry.Methods[actCode][method] + if !found { + // if the method wasn't found it is likely the case the method was one of: + // https://github.com/filecoin-project/builtin-actors/blob/f5311fe735df4d9baf5f82d4b3db10f3c51688c4/actors/docs/README.md?plain=1#L31 + // so we just marshal the raw value to json and bail with a warning + retJ, err := json.Marshal(ret) + if err != nil { + return "", "", err + } + err = fmt.Errorf("unknown method %d with codec %d for actorCode %s name %s", method, retCodec, actCode, builtin.ActorNameByCode(actCode)) + log.Warnw("parsing vm message return", "error", err) + return string(retJ), builtin.ActorNameByCode(actCode), nil + } + // If the codec is 0, the parameters/return value are "empty". + // If the codec is 0x55, it's bytes. + if retCodec == 0 || retCodec == 0x55 { + return string(ret), m.Name, nil + } + return ParseReturn(ret, method, actCode) +} + func ParseParams(params []byte, method abi.MethodNum, actCode cid.Cid) (_ string, _ string, err error) { m, found := ActorRegistry.Methods[actCode][method] if !found { @@ -141,10 +184,8 @@ type MessageParamsReturn struct { } type MessageTrace struct { - Message *types.Message - Receipt *types.MessageReceipt - Error string - Duration time.Duration + Message types.MessageTrace + Receipt types.ReturnTrace GasCharge []*types.GasTrace Index uint64 } @@ -161,8 +202,6 @@ func walkExecutionTrace(et *types.ExecutionTrace, trace *[]*MessageTrace, index *trace = append(*trace, &MessageTrace{ Message: sub.Msg, Receipt: sub.MsgRct, - Error: sub.Error, - Duration: sub.Duration, GasCharge: sub.GasCharges, Index: *index, }) diff --git a/tasks/messageexecutions/vm/task.go b/tasks/messageexecutions/vm/task.go index 95c295f7a..bc53d82b1 100644 --- a/tasks/messageexecutions/vm/task.go +++ b/tasks/messageexecutions/vm/task.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/lotus/chain/types" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" @@ -98,7 +99,20 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut // NB: the getActorCode method is the expensive call since it resolves addresses and may load the statetree. for _, child := range util.GetChildMessagesOf(parentMsg) { // Cid() computes a CID, so only call it once - childCid := child.Message.Cid() + childMsg := &types.Message{ + To: child.Message.To, + From: child.Message.From, + Value: child.Message.Value, + Method: child.Message.Method, + Params: child.Message.Params, + // these fields were deprecated in https://github.com/filecoin-project/lotus/commit/dbbcf4b2ee9626796e23a096c66e67ff350810e4 + Version: 0, + GasLimit: 0, + Nonce: 0, + GasFeeCap: abi.NewTokenAmount(0), + GasPremium: abi.NewTokenAmount(0), + } + childCid := childMsg.Cid() toCode, found := getActorCode(ctx, child.Message.To) if !found && child.Receipt.ExitCode == 0 { @@ -129,7 +143,7 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut From: child.Message.From.String(), To: child.Message.To.String(), Value: child.Message.Value.String(), - GasUsed: child.Receipt.GasUsed, + GasUsed: 0, ExitCode: int64(child.Receipt.ExitCode), ActorCode: toActorCode, Method: uint64(child.Message.Method), @@ -142,7 +156,7 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut // As an example: a message may return ErrForbidden, it will have valid params, but will not contain a // parsable return value in its receipt. if child.Receipt.ExitCode.IsSuccess() { - params, _, err := util.ParseParams(child.Message.Params, child.Message.Method, toCode) + params, _, err := util.ParseVmMessageParams(child.Message.Params, child.Message.ParamsCodec, child.Message.Method, toCode) if err != nil { // a failure here indicates an error in message param parsing, or in exitcode checks above. errorsDetected = append(errorsDetected, &messages.MessageError{ @@ -156,7 +170,7 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut vmMsg.Params = params } - ret, _, err := util.ParseReturn(child.Receipt.Return, child.Message.Method, toCode) + ret, _, err := util.ParseVmMessageReturn(child.Receipt.Return, child.Receipt.ReturnCodec, child.Message.Method, toCode) if err != nil { errorsDetected = append(errorsDetected, &messages.MessageError{ Cid: parentMsg.Cid,