Skip to content

Commit

Permalink
conformance: tipset-class driver: allow actor msgs, dummy-sign secp m…
Browse files Browse the repository at this point in the history
…sgs.
  • Loading branch information
raulk committed Sep 3, 2020
1 parent b774563 commit 8e7a8d8
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions conformance/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package conformance

import (
"context"
"fmt"

"github.com/filecoin-project/specs-actors/actors/crypto"

"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store"
Expand Down Expand Up @@ -80,11 +81,14 @@ func (d *Driver) ExecuteTipset(bs blockstore.Blockstore, ds ds.Batching, preroot
}
switch msg.From.Protocol() {
case address.SECP256K1:
sb.SecpkMessages = append(sb.SecpkMessages, msg)
sb.SecpkMessages = append(sb.SecpkMessages, toChainMsg(msg))
case address.BLS:
sb.BlsMessages = append(sb.BlsMessages, msg)
sb.BlsMessages = append(sb.BlsMessages, toChainMsg(msg))
default:
return nil, fmt.Errorf("from account is not secpk nor bls: %s", msg.From)
// sneak in messages originating from other addresses as both kinds.
// these should fail, as they are actually invalid senders.
sb.SecpkMessages = append(sb.SecpkMessages, msg)
sb.BlsMessages = append(sb.BlsMessages, msg)
}
}
blocks = append(blocks, sb)
Expand Down Expand Up @@ -143,11 +147,30 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, preroot cid.Cid, epoch

lvm.SetInvoker(invoker)

ret, err := lvm.ApplyMessage(d.ctx, msg)
ret, err := lvm.ApplyMessage(d.ctx, toChainMsg(msg))
if err != nil {
return nil, cid.Undef, err
}

root, err := lvm.Flush(d.ctx)
return ret, root, err
}

// toChainMsg injects a synthetic 0-filled signature of the right length to
// messages that originate from secp256k senders, leaving all
// others untouched.
// TODO: generate a signature in the DSL so that it's encoded in
// the test vector.
func toChainMsg(msg *types.Message) (ret types.ChainMsg) {
ret = msg
if msg.From.Protocol() == address.SECP256K1 {
ret = &types.SignedMessage{
Message: *msg,
Signature: crypto.Signature{
Type: crypto.SigTypeSecp256k1,
Data: make([]byte, 65),
},
}
}
return ret
}

0 comments on commit 8e7a8d8

Please sign in to comment.