fix: signature validation cache for messages with Delegated signatures. (#9916)
This commit is contained in:
parent
28e61691d8
commit
d9c13f19b0
@ -3,7 +3,6 @@ package messagepool
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
@ -771,22 +770,10 @@ func sigCacheKey(m *types.SignedMessage) (string, error) {
|
||||
if len(m.Signature.Data) != ffi.SignatureBytes {
|
||||
return "", fmt.Errorf("bls signature incorrectly sized")
|
||||
}
|
||||
|
||||
hashCache := blake2b.Sum256(append(m.Cid().Bytes(), m.Signature.Data...))
|
||||
|
||||
return string(hashCache[:]), nil
|
||||
case crypto.SigTypeSecp256k1:
|
||||
case crypto.SigTypeSecp256k1, crypto.SigTypeDelegated:
|
||||
return string(m.Cid().Bytes()), nil
|
||||
case crypto.SigTypeDelegated:
|
||||
txArgs, err := ethtypes.NewEthTxArgsFromMessage(&m.Message)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
msg, err := txArgs.HashedOriginalRlpMsg()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return hex.EncodeToString(msg), nil
|
||||
default:
|
||||
return "", xerrors.Errorf("unrecognized signature type: %d", m.Signature.Type)
|
||||
}
|
||||
|
@ -183,18 +183,6 @@ func (tx *EthTxArgs) ToSignedMessage() (*types.SignedMessage, error) {
|
||||
|
||||
}
|
||||
|
||||
func (tx *EthTxArgs) HashedOriginalRlpMsg() ([]byte, error) {
|
||||
msg, err := tx.OriginalRlpMsg()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hasher := sha3.NewLegacyKeccak256()
|
||||
hasher.Write(msg)
|
||||
hash := hasher.Sum(nil)
|
||||
return hash, nil
|
||||
}
|
||||
|
||||
func (tx *EthTxArgs) OriginalRlpMsg() ([]byte, error) {
|
||||
chainId, err := formatInt(tx.ChainID)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user