From aef741ae19c20146ceeec9bc9f49f915a8839cb9 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Wed, 8 Sep 2021 12:21:36 -0400 Subject: [PATCH] Mempool: reduce size of sigValCache --- chain/messagepool/messagepool.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index f2ab998d4b7..06343e9c978 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -11,6 +11,10 @@ import ( "sync" "time" + ffi "github.com/filecoin-project/filecoin-ffi" + + "github.com/minio/blake2b-simd" + "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/crypto" @@ -751,11 +755,13 @@ func (mp *MessagePool) Add(ctx context.Context, m *types.SignedMessage) error { func sigCacheKey(m *types.SignedMessage) (string, error) { switch m.Signature.Type { case crypto.SigTypeBLS: - if len(m.Signature.Data) < 90 { - return "", fmt.Errorf("bls signature too short") + if len(m.Signature.Data) != ffi.SignatureBytes { + return "", fmt.Errorf("bls signature incorrectly sized") } - return string(m.Cid().Bytes()) + string(m.Signature.Data[64:]), nil + hashCache := blake2b.Sum256(append(m.Cid().Bytes(), m.Signature.Data...)) + + return string(hashCache[:]), nil case crypto.SigTypeSecp256k1: return string(m.Cid().Bytes()), nil default: