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,9 +95,15 @@
} }
} }
}, },
"apply_message": { "apply_messages": {
"title": "message to apply, hex-encoded", "title": "messages to apply, hex-encoded",
"$ref": "#/definitions/hex" "type": "array",
"items": [
{
"type": "string",
"$ref": "#/definitions/hex"
}
]
} }
}, },
"required": [ "required": [
@ -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")
msg, err := types.DecodeMessage(tv.ApplyMessage)
if err != nil {
return err
}
driver := lotus.NewDriver(ctx) driver := lotus.NewDriver(ctx)
fmt.Println("executing message") for i, m := range tv.ApplyMessages {
spew.Dump(driver.ExecuteMessage(msg, preroot, bs, epoch)) fmt.Printf("decoding message %v\n", i)
msg, err := types.DecodeMessage(m)
if err != nil {
return err
}
fmt.Printf("executing message %v\n", i)
var applyRet *vm.ApplyRet
applyRet, preroot, err = 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

@ -90,7 +90,7 @@ type TestVector struct {
// objects. // objects.
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"`
} }