Skip to content

Commit

Permalink
fix: Don't call WalletExport in msg signing flows
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Feb 9, 2023
1 parent 038686b commit 4a328dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
13 changes: 3 additions & 10 deletions chain/messagesigner/messagesigner.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ import (
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/crypto"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/messagepool"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
"github.com/filecoin-project/lotus/chain/wallet/key"
"github.com/filecoin-project/lotus/node/modules/dtypes"
)

Expand Down Expand Up @@ -69,11 +66,7 @@ func (ms *MessageSigner) SignMessage(ctx context.Context, msg *types.Message, sp
// Sign the message with the nonce
msg.Nonce = nonce

keyInfo, err := ms.wallet.WalletExport(ctx, msg.From)
if err != nil {
return nil, err
}
sb, err := SigningBytes(msg, key.ActSigType(keyInfo.Type))
sb, err := SigningBytes(msg, msg.From.Protocol())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -200,8 +193,8 @@ func (ms *MessageSigner) dstoreKey(addr address.Address) datastore.Key {
return datastore.KeyWithNamespaces([]string{dsKeyActorNonce, addr.String()})
}

func SigningBytes(msg *types.Message, sigType crypto.SigType) ([]byte, error) {
if sigType == crypto.SigTypeDelegated {
func SigningBytes(msg *types.Message, sigType address.Protocol) ([]byte, error) {
if sigType == address.Delegated {
txArgs, err := ethtypes.EthTxArgsFromUnsignedEthMessage(msg)
if err != nil {
return nil, xerrors.Errorf("failed to reconstruct eth transaction: %w", err)
Expand Down
7 changes: 1 addition & 6 deletions node/impl/full/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet"
"github.com/filecoin-project/lotus/chain/wallet/key"
"github.com/filecoin-project/lotus/lib/sigs"
)

Expand Down Expand Up @@ -53,11 +52,7 @@ func (a *WalletAPI) WalletSignMessage(ctx context.Context, k address.Address, ms
return nil, xerrors.Errorf("failed to resolve ID address: %w", keyAddr)
}

keyInfo, err := a.Wallet.WalletExport(ctx, k)
if err != nil {
return nil, err
}
sb, err := messagesigner.SigningBytes(msg, key.ActSigType(keyInfo.Type))
sb, err := messagesigner.SigningBytes(msg, keyAddr.Protocol())
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 4a328dd

Please sign in to comment.