From dfdafa3c157466ab4867ea62420d7bf938c60724 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 7 Jun 2021 21:14:57 -0700 Subject: [PATCH] fix(lotus-sim): pretend all messages are BLS It doesn't really matter, and it ensures they all get executed in-order. --- cmd/lotus-sim/simulation/messages.go | 47 ++++++---------------------- 1 file changed, 10 insertions(+), 37 deletions(-) diff --git a/cmd/lotus-sim/simulation/messages.go b/cmd/lotus-sim/simulation/messages.go index 3f1c55179..8c12cac1a 100644 --- a/cmd/lotus-sim/simulation/messages.go +++ b/cmd/lotus-sim/simulation/messages.go @@ -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 }