besu
besu copied to clipboard
Reduce the number of runtime exceptions (SecurityModuleException)
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.
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

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
- [x] I thought about the changelog and included a changelog update if required.