fix: signature validation cache for messages with Delegated signatures. (#9916)

This commit is contained in:
raulk 2022-12-20 22:49:53 +00:00 committed by GitHub
parent 28e61691d8
commit d9c13f19b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 31 deletions

View File

@ -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)
}

View File

@ -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 {