diff --git a/acceptance-tests/dsl/build.gradle b/acceptance-tests/dsl/build.gradle index 04732c2c4bc..2b8e68df150 100644 --- a/acceptance-tests/dsl/build.gradle +++ b/acceptance-tests/dsl/build.gradle @@ -46,9 +46,6 @@ dependencies { implementation 'org.web3j:abi' implementation 'org.web3j:besu' implementation 'org.web3j:crypto' - implementation 'tech.pegasys.ethsigner.internal:ethsigner-core' - implementation 'tech.pegasys.signers.internal:signing-secp256k1-api' - implementation 'tech.pegasys.signers.internal:signing-secp256k1-impl' implementation 'org.testcontainers:testcontainers' } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/EthSignerClient.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/EthSignerClient.java deleted file mode 100644 index f202a874b1a..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/EthSignerClient.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.tests.acceptance.dsl.ethsigner; - -import java.io.IOException; -import java.math.BigInteger; -import java.net.URI; -import java.util.Collections; -import java.util.List; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.web3j.protocol.Web3jService; -import org.web3j.protocol.core.Request; -import org.web3j.protocol.core.methods.request.Transaction; -import org.web3j.protocol.core.methods.response.EthSendTransaction; -import org.web3j.protocol.eea.Eea; -import org.web3j.protocol.http.HttpService; - -public class EthSignerClient { - private static final Logger LOG = LogManager.getLogger(); - private final Web3jService web3jService; - private final Eea web3j; - private final String from; - - public EthSignerClient(final URI ethSignerUri) throws IOException { - this.web3jService = new HttpService(ethSignerUri.toString()); - this.web3j = Eea.build(web3jService); - this.from = resolveFrom(ethSignerUri); - } - - private String resolveFrom(final URI ethSignerUri) throws IOException { - final List accounts; - try { - accounts = ethAccounts(); - return accounts.get(0); - } catch (IOException e) { - LOG.info("Failed to connect to EthSigner at {}", ethSignerUri); - throw e; - } catch (Exception e) { - LOG.info("Falling back to signing with node key"); - } - return null; - } - - public List ethAccounts() throws IOException { - return web3j.ethAccounts().send().getAccounts(); - } - - public String ethSendTransaction( - final String to, - final BigInteger gas, - final BigInteger gasPrice, - final BigInteger value, - final String data, - final BigInteger nonce) - throws IOException { - return web3j - .ethSendTransaction(new Transaction(from, nonce, gasPrice, gas, to, value, data)) - .send() - .getTransactionHash(); - } - - public String eeaSendTransaction( - final String to, - final BigInteger gas, - final BigInteger gasPrice, - final String data, - final String privateFrom, - final String privacyGroupId, - final String restriction) - throws IOException { - return eeaSendTransaction( - to, gas, gasPrice, data, null, privateFrom, privacyGroupId, restriction); - } - - public String eeaSendTransaction( - final String to, - final BigInteger gas, - final BigInteger gasPrice, - final String data, - final BigInteger nonce, - final String privateFrom, - final String privacyGroupId, - final String restriction) - throws IOException { - final PrivateTransactionRequest transaction = - new PrivateTransactionRequest( - from, - nonce, - gasPrice, - gas, - to, - BigInteger.ZERO, - data, - privateFrom, - privacyGroupId, - restriction); - - return eeaSendTransaction(transaction); - } - - public String eeaSendTransaction( - final String to, - final BigInteger gas, - final BigInteger gasPrice, - final String data, - final String privateFrom, - final List privateFor, - final String restriction) - throws IOException { - return eeaSendTransaction(to, gas, gasPrice, data, null, privateFrom, privateFor, restriction); - } - - public String eeaSendTransaction( - final String to, - final BigInteger gas, - final BigInteger gasPrice, - final String data, - final BigInteger nonce, - final String privateFrom, - final List privateFor, - final String restriction) - throws IOException { - - final PrivateTransactionRequest transaction = - new PrivateTransactionRequest( - from, - nonce, - gasPrice, - gas, - to, - BigInteger.ZERO, - data, - privateFrom, - privateFor, - restriction); - - return eeaSendTransaction(transaction); - } - - private String eeaSendTransaction(final PrivateTransactionRequest transaction) - throws IOException { - // temporary until implemented in web3j - return new Request<>( - "eea_sendTransaction", - Collections.singletonList(transaction), - web3jService, - EthSendTransaction.class) - .send() - .getTransactionHash(); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/EthSignerClientTest.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/EthSignerClientTest.java deleted file mode 100644 index 853f48f9bf8..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/EthSignerClientTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.tests.acceptance.dsl.ethsigner; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.ethsigner.testutil.EthSignerTestHarness; -import org.hyperledger.besu.tests.acceptance.dsl.ethsigner.testutil.EthSignerTestHarnessFactory; - -import java.io.IOException; -import java.math.BigInteger; -import java.util.Collections; -import java.util.List; - -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; - -public class EthSignerClientTest { - @ClassRule public static final TemporaryFolder folder = new TemporaryFolder(); - - @ClassRule - public static final WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - private static final String MOCK_RESPONSE = "mock_transaction_hash"; - private static final String MOCK_SEND_TRANSACTION_RESPONSE = - "{\n" - + " \"id\":67,\n" - + " \"jsonrpc\":\"2.0\",\n" - + " \"result\": \"" - + MOCK_RESPONSE - + "\"\n" - + "}"; - private static final String ENCLAVE_PUBLIC_KEY = "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; - - private static EthSignerClient ethSignerClient; - - private static EthSignerTestHarness testHarness; - - @BeforeClass - public static void setUpOnce() throws Exception { - stubFor(post("/").willReturn(aResponse().withBody(MOCK_SEND_TRANSACTION_RESPONSE))); - - folder.create(); - - testHarness = - EthSignerTestHarnessFactory.create( - folder.newFolder().toPath(), - "ethSignerKey--fe3b557e8fb62b89f4916b721be55ceb828dbd73.json", - wireMockRule.port(), - 1337); - - ethSignerClient = new EthSignerClient(testHarness.getHttpListeningUrl()); - } - - @Test - public void testEthAccounts() throws IOException { - final List accounts = ethSignerClient.ethAccounts(); - assertThat(accounts).hasSize(1); - assertThat(accounts.get(0)).isEqualTo("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"); - } - - @Test - public void testEthSendTransaction() throws IOException { - final String response = - ethSignerClient.ethSendTransaction( - "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", - BigInteger.ZERO, - BigInteger.ZERO, - BigInteger.ZERO, - "", - BigInteger.ZERO); - - assertThat(response).isEqualTo(MOCK_RESPONSE); - } - - @Test - public void testEeaSendTransaction() throws IOException { - final String response = - ethSignerClient.eeaSendTransaction( - "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", - BigInteger.ZERO, - BigInteger.ZERO, - "", - BigInteger.ZERO, - ENCLAVE_PUBLIC_KEY, - Collections.emptyList(), - "restricted"); - - assertThat(response).isEqualTo(MOCK_RESPONSE); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/PrivateTransactionRequest.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/PrivateTransactionRequest.java deleted file mode 100644 index b9b21a49f27..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/PrivateTransactionRequest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.tests.acceptance.dsl.ethsigner; - -import java.math.BigInteger; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonInclude; -import org.web3j.utils.Numeric; - -@JsonInclude(JsonInclude.Include.NON_NULL) -public class PrivateTransactionRequest { - - private final String from; - private final BigInteger nonce; - private final BigInteger gasPrice; - private final BigInteger gas; - private final String to; - private final BigInteger value; - private final String data; - private final String privateFrom; - private List privateFor; - private String privacyGroupId; - private final String restriction; - - public PrivateTransactionRequest( - final String from, - final BigInteger nonce, - final BigInteger gasPrice, - final BigInteger gasLimit, - final String to, - final BigInteger value, - final String data, - final String privateFrom, - final List privateFor, - final String restriction) { - this.from = from; - this.to = to; - this.gas = gasLimit; - this.gasPrice = gasPrice; - this.value = value; - this.data = data == null ? null : Numeric.prependHexPrefix(data); - this.nonce = nonce; - this.privateFrom = privateFrom; - this.privateFor = privateFor; - this.restriction = restriction; - } - - public PrivateTransactionRequest( - final String from, - final BigInteger nonce, - final BigInteger gasPrice, - final BigInteger gasLimit, - final String to, - final BigInteger value, - final String data, - final String privateFrom, - final String privacyGroupId, - final String restriction) { - this.from = from; - this.to = to; - this.gas = gasLimit; - this.gasPrice = gasPrice; - this.value = value; - this.data = data == null ? null : Numeric.prependHexPrefix(data); - this.nonce = nonce; - this.privateFrom = privateFrom; - this.privacyGroupId = privacyGroupId; - this.restriction = restriction; - } - - public String getFrom() { - return from; - } - - public String getTo() { - return to; - } - - public String getGas() { - return convert(gas); - } - - public String getGasPrice() { - return convert(gasPrice); - } - - public String getValue() { - return convert(value); - } - - public String getData() { - return data; - } - - public String getNonce() { - return convert(nonce); - } - - private String convert(final BigInteger value) { - return value == null ? null : Numeric.encodeQuantity(value); - } - - public String getPrivateFrom() { - return privateFrom; - } - - public List getPrivateFor() { - return privateFor; - } - - public String getPrivacyGroupId() { - return privacyGroupId; - } - - public String getRestriction() { - return restriction; - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/testutil/EthSignerConfig.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/testutil/EthSignerConfig.java deleted file mode 100644 index ccfd0fdfbb7..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/testutil/EthSignerConfig.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.tests.acceptance.dsl.ethsigner.testutil; - -import org.hyperledger.besu.plugin.services.metrics.MetricCategory; - -import java.nio.file.Path; -import java.time.Duration; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.Set; - -import org.apache.logging.log4j.Level; -import tech.pegasys.ethsigner.core.config.Config; -import tech.pegasys.ethsigner.core.config.TlsOptions; -import tech.pegasys.ethsigner.core.config.tls.client.ClientTlsOptions; -import tech.pegasys.ethsigner.core.signing.ChainIdProvider; - -public class EthSignerConfig implements Config { - private final Level logLevel; - private final String downstreamHttpHost; - private final Integer downStreamHttpPort; - private final Duration downstreamHttpRequestTimeout; - private final String httpListenHost; - private final Integer httpListenPort; - private final ChainIdProvider chainId; - private final Path dataDirectory; - - public EthSignerConfig( - final Level logLevel, - final String downstreamHttpHost, - final Integer downStreamHttpPort, - final Duration downstreamHttpRequestTimeout, - final String httpListenHost, - final Integer httpListenPort, - final ChainIdProvider chainId, - final Path dataDirectory) { - - this.logLevel = logLevel; - this.downstreamHttpHost = downstreamHttpHost; - this.downStreamHttpPort = downStreamHttpPort; - this.downstreamHttpRequestTimeout = downstreamHttpRequestTimeout; - this.httpListenHost = httpListenHost; - this.httpListenPort = httpListenPort; - this.chainId = chainId; - this.dataDirectory = dataDirectory; - } - - @Override - public Level getLogLevel() { - return logLevel; - } - - @Override - public String getDownstreamHttpHost() { - return downstreamHttpHost; - } - - @Override - public Integer getDownstreamHttpPort() { - return downStreamHttpPort; - } - - @Override - public String getDownstreamHttpPath() { - return "/"; - } - - @Override - public Duration getDownstreamHttpRequestTimeout() { - return downstreamHttpRequestTimeout; - } - - @Override - public String getHttpListenHost() { - return httpListenHost; - } - - @Override - public Integer getHttpListenPort() { - return httpListenPort; - } - - @Override - public ChainIdProvider getChainId() { - return chainId; - } - - @Override - public Path getDataPath() { - return dataDirectory; - } - - @Override - public Optional getTlsOptions() { - return Optional.empty(); - } - - @Override - public Optional getClientTlsOptions() { - return Optional.empty(); - } - - @Override - public Collection getCorsAllowedOrigins() { - return List.of("*"); - } - - @Override - public Boolean isMetricsEnabled() { - return Boolean.FALSE; - } - - @Override - public Integer getMetricsPort() { - return -1; - } - - @Override - public String getMetricsHost() { - return "localhost"; - } - - @Override - public Set getMetricCategories() { - return Collections.emptySet(); - } - - @Override - public List getMetricsHostAllowList() { - return List.of("localhost", "127.0.0.1"); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/testutil/EthSignerTestHarness.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/testutil/EthSignerTestHarness.java deleted file mode 100644 index e4c13b7f7bc..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/testutil/EthSignerTestHarness.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.tests.acceptance.dsl.ethsigner.testutil; - -import java.net.URI; -import java.util.Properties; - -public class EthSignerTestHarness { - private final EthSignerConfig config; - private final Properties portsProperties; - - public EthSignerTestHarness(final EthSignerConfig config, final Properties properties) { - this.config = config; - this.portsProperties = properties; - } - - public URI getHttpListeningUrl() { - return URI.create( - "http://" + config.getHttpListenHost() + ":" + portsProperties.getProperty("http-jsonrpc")); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/testutil/EthSignerTestHarnessFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/testutil/EthSignerTestHarnessFactory.java deleted file mode 100644 index d40ad8dbe5a..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/testutil/EthSignerTestHarnessFactory.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.tests.acceptance.dsl.ethsigner.testutil; - -import static org.apache.tuweni.io.file.Files.copyResource; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.time.Duration; -import java.util.Properties; -import java.util.concurrent.TimeUnit; -import java.util.stream.Stream; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.awaitility.Awaitility; -import org.web3j.crypto.CipherException; -import org.web3j.crypto.WalletUtils; -import tech.pegasys.ethsigner.core.EthSigner; -import tech.pegasys.ethsigner.core.signing.ConfigurationChainId; -import tech.pegasys.signers.secp256k1.api.SingleSignerProvider; -import tech.pegasys.signers.secp256k1.filebased.CredentialSigner; - -public class EthSignerTestHarnessFactory { - - private static final Logger LOG = LogManager.getLogger(); - private static final String HOST = "127.0.0.1"; - - public static EthSignerTestHarness create( - final Path tempDir, final String keyPath, final Integer besuPort, final long chainId) - throws IOException, CipherException { - - final Path keyFilePath = copyResource(keyPath, tempDir.resolve(keyPath)); - - final EthSignerConfig config = - new EthSignerConfig( - Level.DEBUG, - HOST, - besuPort, - Duration.ofSeconds(10), - HOST, - 0, - new ConfigurationChainId(chainId), - tempDir); - - final EthSigner ethSigner = - new EthSigner( - config, - new SingleSignerProvider( - new CredentialSigner( - WalletUtils.loadCredentials("", keyFilePath.toAbsolutePath().toFile())))); - ethSigner.run(); - - waitForPortFile(tempDir); - - LOG.info("EthSigner port: {}", config.getHttpListenPort()); - - return new EthSignerTestHarness(config, loadPortsFile(tempDir)); - } - - private static Properties loadPortsFile(final Path tempDir) { - final Properties portsProperties = new Properties(); - try (final FileInputStream fis = - new FileInputStream(new File(tempDir.toFile(), "ethsigner.ports"))) { - portsProperties.load(fis); - LOG.info("Ports for ethsigner {}", portsProperties); - } catch (final IOException e) { - throw new RuntimeException("Error reading EthSigner ports file", e); - } - return portsProperties; - } - - private static void waitForPortFile(final Path tempDir) { - final File file = new File(tempDir.toFile(), "ethsigner.ports"); - Awaitility.waitAtMost(30, TimeUnit.SECONDS) - .until( - () -> { - if (file.exists()) { - try (final Stream s = Files.lines(file.toPath())) { - return s.count() > 0; - } - } else { - return false; - } - }); - } -} diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/EthSignerAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/EthSignerAcceptanceTest.java deleted file mode 100644 index 3ebf9a2c899..00000000000 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/EthSignerAcceptanceTest.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.tests.acceptance.privacy; - -import static org.web3j.utils.Restriction.UNRESTRICTED; - -import org.hyperledger.besu.tests.acceptance.dsl.ethsigner.EthSignerClient; -import org.hyperledger.besu.tests.acceptance.dsl.ethsigner.testutil.EthSignerTestHarness; -import org.hyperledger.besu.tests.acceptance.dsl.ethsigner.testutil.EthSignerTestHarnessFactory; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.ParameterizedEnclaveTestBase; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.web3j.generated.EventEmitter; -import org.hyperledger.enclave.testutil.EnclaveType; - -import java.io.IOException; -import java.math.BigInteger; -import java.util.Collections; -import java.util.Optional; - -import org.junit.Ignore; -import org.junit.Test; -import org.web3j.crypto.CipherException; -import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; -import org.web3j.utils.Restriction; - -public class EthSignerAcceptanceTest extends ParameterizedEnclaveTestBase { - private final PrivacyNode minerNode; - private final EthSignerTestHarness ethSigner; - - private final EthSignerClient ethSignerClient; - - public EthSignerAcceptanceTest(final Restriction restriction, final EnclaveType enclaveType) - throws IOException, CipherException { - super(restriction, enclaveType); - - minerNode = - privacyBesu.createPrivateTransactionEnabledMinerNode( - "miner-node", - privacyAccountResolver.resolve(0), - enclaveType, - Optional.empty(), - false, - false, - restriction == UNRESTRICTED); - privacyCluster.start(minerNode); - - ethSigner = - EthSignerTestHarnessFactory.create( - privacy.newFolder().toPath(), - "ethSignerKey--fe3b557e8fb62b89f4916b721be55ceb828dbd73.json", - minerNode.getBesu().getJsonRpcSocketPort().orElseThrow(), - 1337); - - ethSignerClient = new EthSignerClient(ethSigner.getHttpListeningUrl()); - } - - @Test - public void privateSmartContractMustDeploy() throws IOException { - final String transactionHash = - ethSignerClient.eeaSendTransaction( - null, - BigInteger.valueOf(3000000L), - BigInteger.valueOf(1000), - EventEmitter.BINARY, - BigInteger.valueOf(0), - minerNode.getEnclaveKey(), - Collections.emptyList(), - restriction.toString().toLowerCase()); - - final PrivateTransactionReceipt receipt = - minerNode.execute(privacyTransactions.getPrivateTransactionReceipt(transactionHash)); - - minerNode.verify( - privateTransactionVerifier.validPrivateTransactionReceipt(transactionHash, receipt)); - } - - // requires ethsigner jar > 0.3.0 - // https://cloudsmith.io/~consensys/repos/ethsigner/packages/ - @Test - @Ignore - public void privateSmartContractMustDeployNoNonce() throws IOException { - final String transactionHash = - ethSignerClient.eeaSendTransaction( - null, - BigInteger.valueOf(3000000L), - BigInteger.valueOf(1000), - EventEmitter.BINARY, - minerNode.getEnclaveKey(), - Collections.emptyList(), - restriction.toString().toLowerCase()); - - final PrivateTransactionReceipt receipt = - minerNode.execute(privacyTransactions.getPrivateTransactionReceipt(transactionHash)); - - minerNode.verify( - privateTransactionVerifier.validPrivateTransactionReceipt(transactionHash, receipt)); - } - - @Test - public void privateSmartContractMustDeployWithPrivacyGroup() throws IOException { - final String privacyGroupId = minerNode.execute(createPrivacyGroup(null, null, minerNode)); - - final String transactionHash = - ethSignerClient.eeaSendTransaction( - null, - BigInteger.valueOf(3000000L), - BigInteger.valueOf(1000), - EventEmitter.BINARY, - BigInteger.valueOf(0), - minerNode.getEnclaveKey(), - privacyGroupId, - restriction.toString().toLowerCase()); - - final PrivateTransactionReceipt receipt = - minerNode.execute(privacyTransactions.getPrivateTransactionReceipt(transactionHash)); - - minerNode.verify( - privateTransactionVerifier.validPrivateTransactionReceipt(transactionHash, receipt)); - } - - @Test - public void privateSmartContractMustDeployWithPrivacyGroupNoNonce() throws IOException { - final String privacyGroupId = minerNode.execute(createPrivacyGroup(null, null, minerNode)); - - final String transactionHash = - ethSignerClient.eeaSendTransaction( - null, - BigInteger.valueOf(3000000L), - BigInteger.valueOf(1000), - EventEmitter.BINARY, - minerNode.getEnclaveKey(), - privacyGroupId, - restriction.toString().toLowerCase()); - - final PrivateTransactionReceipt receipt = - minerNode.execute(privacyTransactions.getPrivateTransactionReceipt(transactionHash)); - - minerNode.verify( - privateTransactionVerifier.validPrivateTransactionReceipt(transactionHash, receipt)); - } -} diff --git a/gradle/versions.gradle b/gradle/versions.gradle index 856fc9a7c4e..917ef6f6932 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -167,12 +167,5 @@ dependencyManagement { dependency 'org.yaml:snakeyaml:1.26' dependency 'tech.pegasys.discovery:discovery:21.10.0' - - dependency 'tech.pegasys.ethsigner.internal:ethsigner-core:21.3.2' - dependencySet(group: 'tech.pegasys.signers.internal', version: '1.0.17') { - entry 'signing-secp256k1-api' - entry 'signing-secp256k1-impl' - } - } }