enhanced error message - smart contract permissioning config check (#1709)

* enhanced error message when smart contract validation fails interface version check

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>

Co-authored-by: mark-terry <36909937+mark-terry@users.noreply.github.com>
pull/1719/head
Sally MacFarlane 4 years ago committed by GitHub
parent f30a208723
commit ef5b1e0dfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodePermissioningControllerFactory.java
  2. 3
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java

@ -104,7 +104,9 @@ public class NodePermissioningControllerFactory {
.ifPresent(
config -> {
if (config.isSmartContractNodeAllowlistEnabled()) {
validatePermissioningContract(nodePermissioningController);
validatePermissioningContract(
nodePermissioningController,
permissioningConfiguration.getSmartContractConfig().get());
}
});
@ -145,7 +147,8 @@ public class NodePermissioningControllerFactory {
}
private void validatePermissioningContract(
final NodePermissioningController nodePermissioningController) {
final NodePermissioningController nodePermissioningController,
final SmartContractPermissioningConfiguration smartContractPermissioningConfig) {
LOG.debug("Validating onchain node permissioning smart contract configuration");
try {
@ -156,8 +159,11 @@ public class NodePermissioningControllerFactory {
EnodeURL.fromString(
"enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@10.3.58.6:30303"));
} catch (Exception e) {
final String msg = "Error validating onchain node permissioning smart contract configuration";
LOG.error(msg + ":", e);
final String msg =
String.format(
"Error: node permissioning contract at address %s does not match the expected interface version %s.",
smartContractPermissioningConfig.getNodeSmartContractAddress(),
smartContractPermissioningConfig.getNodeSmartContractInterfaceVersion());
throw new IllegalStateException(msg, e);
}
}

@ -275,6 +275,7 @@ public class NodePermissioningControllerFactoryTest {
assertThat(thrown)
.isInstanceOf(IllegalStateException.class)
.hasMessage("Error validating onchain node permissioning smart contract configuration");
.hasMessage(
"Error: node permissioning contract at address 0x0000000000000000000000000000000000001234 does not match the expected interface version 1.");
}
}

Loading…
Cancel
Save