support multiple messages /1 (#185)

* support multiple messages

* update corpus/schema.json

* fix required
This commit is contained in:
Anton Evangelatov 2020-08-05 17:00:14 +02:00 committed by GitHub
parent 163721651a
commit 17f0b4a2e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 19 deletions

View File

@ -95,10 +95,16 @@
} }
} }
}, },
"apply_message": { "apply_messages": {
"title": "message to apply, hex-encoded", "title": "messages to apply, hex-encoded",
"type": "array",
"items": [
{
"type": "string",
"$ref": "#/definitions/hex" "$ref": "#/definitions/hex"
} }
]
}
}, },
"required": [ "required": [
"class" "class"
@ -146,11 +152,11 @@
}, },
"then": { "then": {
"required": [ "required": [
"apply_message" "apply_messages"
], ],
"properties": { "properties": {
"apply_message": { "apply_messages": {
"$ref": "#/definitions/apply_message" "$ref": "#/definitions/apply_messages"
} }
} }
} }

View File

@ -10,6 +10,7 @@ import (
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
"github.com/filecoin-project/lotus/lib/blockstore" "github.com/filecoin-project/lotus/lib/blockstore"
"github.com/ipld/go-car" "github.com/ipld/go-car"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
@ -78,16 +79,23 @@ func runExecLotus(_ *cli.Context) error {
fmt.Println("roots: ", header.Roots) fmt.Println("roots: ", header.Roots)
fmt.Println("decoding message") driver := lotus.NewDriver(ctx)
msg, err := types.DecodeMessage(tv.ApplyMessage)
for i, m := range tv.ApplyMessages {
fmt.Printf("decoding message %v\n", i)
msg, err := types.DecodeMessage(m)
if err != nil { if err != nil {
return err return err
} }
driver := lotus.NewDriver(ctx) fmt.Printf("executing message %v\n", i)
var applyRet *vm.ApplyRet
fmt.Println("executing message") applyRet, preroot, err = driver.ExecuteMessage(msg, preroot, bs, epoch)
spew.Dump(driver.ExecuteMessage(msg, preroot, bs, epoch)) if err != nil {
return err
}
spew.Dump(applyRet)
}
return nil return nil

View File

@ -167,7 +167,7 @@ func runExtractMsg(c *cli.Context) error {
RootCID: preroot, RootCID: preroot,
}, },
}, },
ApplyMessage: msgBytes, ApplyMessages: []HexEncodedBytes{msgBytes},
Post: &Postconditions{ Post: &Postconditions{
StateTree: &StateTree{ StateTree: &StateTree{
RootCID: postroot, RootCID: postroot,

View File

@ -91,6 +91,6 @@ type TestVector struct {
CAR HexEncodedBytes `json:"car_hex"` CAR HexEncodedBytes `json:"car_hex"`
Pre *Preconditions `json:"preconditions"` Pre *Preconditions `json:"preconditions"`
ApplyMessage HexEncodedBytes `json:"apply_message"` ApplyMessages []HexEncodedBytes `json:"apply_messages"`
Post *Postconditions `json:"postconditions"` Post *Postconditions `json:"postconditions"`
} }