diff --git a/cmd/clef/tests/testsigner.js b/cmd/clef/tests/testsigner.js index 1295ba5b7a..ad33594951 100644 --- a/cmd/clef/tests/testsigner.js +++ b/cmd/clef/tests/testsigner.js @@ -44,6 +44,9 @@ function testClique(){ var a = accts[0] var r = debug.testSignCliqueBlock(a, 0); // Sign genesis console.log("signing response", r) + if( a != r){ + throw new Error("Requested signing by "+a+ " but got sealer "+r) + } } } diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 95976e06cd..4562b34cf6 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1490,11 +1490,9 @@ func (api *PublicDebugAPI) TestSignCliqueBlock(ctx context.Context, address comm return common.Address{}, fmt.Errorf("block #%d not found", number) } header := block.Header() - header.Extra = make([]byte, 65) - encoded, err := rlp.EncodeToBytes(header) - if err != nil { - return common.Address{}, err - } + header.Extra = make([]byte, 32+65) + encoded := clique.CliqueRLP(header) + // Look up the wallet containing the requested signer account := accounts.Account{Address: address} wallet, err := api.b.AccountManager().Find(account) diff --git a/signer/core/signed_data.go b/signer/core/signed_data.go index 0fe0d8afb0..0118951fb5 100644 --- a/signer/core/signed_data.go +++ b/signer/core/signed_data.go @@ -140,7 +140,7 @@ func (api *SignerAPI) sign(addr common.MixedcaseAddress, req *SignDataRequest, l return nil, err } // Sign the data with the wallet - signature, err := wallet.SignDataWithPassphrase(account, res.Password, req.ContentType, req.Hash) + signature, err := wallet.SignDataWithPassphrase(account, res.Password, req.ContentType, req.Rawdata) if err != nil { return nil, err } @@ -214,6 +214,13 @@ func (api *SignerAPI) determineSignatureFormat(ctx context.Context, contentType if err := rlp.DecodeBytes(cliqueData, header); err != nil { return nil, useLegacyV, err } + // The incoming clique header is already truncated, sent to us with a extradata already shortened + if len(header.Extra) < 65 { + // Need to add it back, to get a suitable length for hashing + newExtra := make([]byte, len(header.Extra)+65) + copy(newExtra, header.Extra) + header.Extra = newExtra + } // Get back the rlp data, encoded by us sighash, cliqueRlp, err := cliqueHeaderHashAndRlp(header) if err != nil {