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": {
"title": "message to apply, hex-encoded",
"$ref": "#/definitions/hex"
"apply_messages": {
"title": "messages to apply, hex-encoded",
"type": "array",
"items": [
{
"type": "string",
"$ref": "#/definitions/hex"
}
]
}
},
"required": [
@ -146,11 +152,11 @@
},
"then": {
"required": [
"apply_message"
"apply_messages"
],
"properties": {
"apply_message": {
"$ref": "#/definitions/apply_message"
"apply_messages": {
"$ref": "#/definitions/apply_messages"
}
}
}

View File

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

View File

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

View File

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