You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lotus uses runtime reflection for IPLD serialization in RPC API json responses, it's ignored in forest for now. More investigation is needed to implement it in forest.
Related lotus code
typeMsgLookupstruct {
Message cid.Cid// Can be different than requested, in case it was replaced, but only gas values changedReceipt types.MessageReceiptReturnDecinterface{}
TipSet types.TipSetKeyHeight abi.ChainEpoch
}
varreturndecinterface{}
ifrecpt.ExitCode==0&&len(recpt.Return) >0 {
cmsg, err:=m.Chain.GetCMessage(ctx, msg)
iferr!=nil {
returnnil, xerrors.Errorf("failed to load message after successful receipt search: %w", err)
}
vmsg:=cmsg.VMMessage()
switcht, err:=stmgr.GetReturnType(ctx, m.StateManager, vmsg.To, vmsg.Method, ts); {
caseerrors.Is(err, stmgr.ErrMetadataNotFound):
// This is not necessarily an error -- EVM methods (and in the future native actors) may// return just bytes, and in the not so distant future we'll have native wasm actors// that are by definition not in the registry.// So in this case, log a debug message and retun the raw bytes.log.Debugf("failed to get return type: %s", err)
returndec=recpt.Returncaseerr!=nil:
returnnil, xerrors.Errorf("failed to get return type: %w", err)
default:
iferr:=t.UnmarshalCBOR(bytes.NewReader(recpt.Return)); err!=nil {
returnnil, err
}
returndec=t
}
}
return&api.MsgLookup{
Message: found,
Receipt: *recpt,
ReturnDec: returndec,
TipSet: ts.Key(),
Height: ts.Height(),
}, nilfuncGetReturnType(ctx context.Context, sm*StateManager, to address.Address, method abi.MethodNum, ts*types.TipSet) (cbg.CBORUnmarshaler, error) {
act, err:=sm.LoadActor(ctx, to, ts)
iferr!=nil {
returnnil, xerrors.Errorf("(get sset) failed to load actor: %w", err)
}
m, found:=sm.tsExec.NewActorRegistry().Methods[act.Code][method]
if!found {
returnnil, fmt.Errorf("unknown method %d for actor %s: %w", method, act.Code, ErrMetadataNotFound)
}
returnreflect.New(m.Ret.Elem()).Interface().(cbg.CBORUnmarshaler), nil
}
@aatifsyed I've added related lotus code to the description. Basically lotus uses any type (interface{}) for this field and use runtime reflection to serialize it with different concrete types
Issue summary
Lotus uses runtime reflection for IPLD serialization in RPC API json responses, it's ignored in forest for now. More investigation is needed to implement it in forest.
Related lotus code
example lotus API call:
request:
response:
Other information and links
#3783
#3769
The text was updated successfully, but these errors were encountered: