fix(lotus-sim): pretend all messages are BLS
It doesn't really matter, and it ensures they all get executed in-order.
This commit is contained in:
parent
5b31ae39ea
commit
dfdafa3c15
@ -3,15 +3,10 @@ package simulation
|
||||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/crypto"
|
||||
blockadt "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||
"github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
|
||||
@ -30,45 +25,23 @@ func toArray(store blockadt.Store, cids []cid.Cid) (cid.Cid, error) {
|
||||
// storeMessages packs a set of messages into a types.MsgMeta and returns the resulting CID. The
|
||||
// resulting CID is valid for the BlocKHeader's Messages field.
|
||||
func (nd *Node) storeMessages(ctx context.Context, messages []*types.Message) (cid.Cid, error) {
|
||||
var blsMessages, sekpMessages []cid.Cid
|
||||
fakeSig := make([]byte, 32)
|
||||
// We store all messages as "bls" messages so they're executed in-order. This ensures
|
||||
// accurate gas accounting. It also ensures we don't, e.g., try to fund a miner after we
|
||||
// fail a pre-commit...
|
||||
var msgCids []cid.Cid
|
||||
for _, msg := range messages {
|
||||
protocol := msg.From.Protocol()
|
||||
|
||||
// It's just a very convenient way to fill up accounts.
|
||||
if msg.From == builtin.BurntFundsActorAddr {
|
||||
protocol = address.SECP256K1
|
||||
}
|
||||
switch protocol {
|
||||
case address.SECP256K1:
|
||||
chainMsg := &types.SignedMessage{
|
||||
Message: *msg,
|
||||
Signature: crypto.Signature{
|
||||
Type: crypto.SigTypeSecp256k1,
|
||||
Data: fakeSig,
|
||||
},
|
||||
}
|
||||
c, err := nd.Chainstore.PutMessage(chainMsg)
|
||||
if err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
sekpMessages = append(sekpMessages, c)
|
||||
case address.BLS:
|
||||
c, err := nd.Chainstore.PutMessage(msg)
|
||||
if err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
blsMessages = append(blsMessages, c)
|
||||
default:
|
||||
return cid.Undef, xerrors.Errorf("unexpected from address %q of type %d", msg.From, msg.From.Protocol())
|
||||
c, err := nd.Chainstore.PutMessage(msg)
|
||||
if err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
msgCids = append(msgCids, c)
|
||||
}
|
||||
adtStore := nd.Chainstore.ActorStore(ctx)
|
||||
blsMsgArr, err := toArray(adtStore, blsMessages)
|
||||
blsMsgArr, err := toArray(adtStore, msgCids)
|
||||
if err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
sekpMsgArr, err := toArray(adtStore, sekpMessages)
|
||||
sekpMsgArr, err := toArray(adtStore, nil)
|
||||
if err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user