Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frrist/parse vm message codec #1150

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

frrist
Copy link
Member

@frrist frrist commented Mar 2, 2023

No description provided.

@frrist frrist changed the base branch from master to frrist/nv18-rc1 March 2, 2023 01:50
@frrist frrist self-assigned this Mar 2, 2023
@frrist frrist added the P1 P1: Must be resolved label Mar 2, 2023
@frrist frrist force-pushed the frrist/parse-vm-message-codec branch 2 times, most recently from 58258ec to ecff81c Compare March 2, 2023 03:17
@frrist frrist force-pushed the frrist/parse-vm-message-codec branch from ecff81c to f2645a7 Compare March 2, 2023 03:39
@frrist frrist marked this pull request as ready for review March 2, 2023 03:39
Comment on lines +38 to +81
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)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Special handling for vm message params and returns please review this section, other changes are mechanical

Copy link
Contributor

@birdychang birdychang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@birdychang birdychang merged this pull request into frrist/nv18-rc1 Mar 2, 2023
@birdychang birdychang deleted the frrist/parse-vm-message-codec branch March 2, 2023 20:47
birdychang pushed a commit that referenced this pull request Mar 8, 2023
* deps: update to lotus 1.20.0-rc2

* chore: update actor gen

- clean up types, remove lily actors types, replace with go-state-types

* Frrist/receipt events schema (#1132)

* feat: implement actor event task and schema

- track the value of EventRoots contained in message receipts.

* feat: implement message param schema and task

- create a table that records raw message parameters

* feat: track raw receipt return value

* fix schema index's after rebase on master

* fix: use builtin lotus method to get events

- it handles the case of legacy events

* fixup! Frrist/receipt events schema (#1132)

* deps: replace deprecated blocks package

- use github.com/ipfs/go-libipfs/blocks instead

* deps: update to v1.20.0 release

* feat: track verifreg actor claim HAMT changes (#1141)

* feat: track verified registry actor claim HAMT changes

- addresses request made here: https://github.com/protocol/pldw/issues/177#issuecomment-1372920524

* fix: correctly diff new actor version (#1145)

* fix: correctly diff new actor version

- closes #1144

* chore: remove unused metrics

* metric: track GettActorStateChanges duration

* feat: update lotus deps to support vm para/ret marshal (#1150)

- use lotus deps from filecoin-project/lotus#10372

* fix: resolve the duplication issue of db migration version

---------

Co-authored-by: Terry <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 P1: Must be resolved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants