besu icon indicating copy to clipboard operation
besu copied to clipboard

Reduce the number of runtime exceptions (SecurityModuleException)

Open ahamlat opened this issue 2 years ago • 0 comments

Signed-off-by: Ameziane H [email protected]

PR description

During handshake, flip the encrypted message decryption by starting with the new format (EIP-8), and if there is an exception, try the old format. This will reduce the number of exceptions and unnecessary executions.

I noticed by adding some debug logs that on 4400 calls to ECIESHandshaker.handleMessage, there're only 7 cases where the encrypted message has the old format. image

By changing the order of execution, starting by decoding the new format (eip8) and without resetting the logs, we can notice there're no more exceptions

image

There is one case I'm not sure about it : if (buf.writerIndex() < size), do we need to try to decode with the old format or we should just throw HandshakeException. With the current PR, HandshakeException will be caught and the old format decryption will be executed.

Fixed Issue(s)

Documentation

  • [ ] I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

ahamlat avatar Oct 10 '22 11:10 ahamlat