SCENARIO:
I have the following code:
final String hostUrl = this.deployerProperties.getProperty("quorum.host.url");
final String hostPort = this.deployerProperties.getProperty("quorum.host.port");
final String host = hostUrl + ":" + hostPort;
final HttpService httpService = new HttpService(host);
this.admin = Admin.build(httpService);
this.quorum = Quorum.build(httpService);
final EthAccounts ethAccounts = this.quorum.ethAccounts().send();
final String ethFirstAccount = ethAccounts.getAccounts().get(0);
final PersonalUnlockAccount personalUnlockAccount = this.admin.personalUnlockAccount(ethFirstAccount, "").send();
if (!personalUnlockAccount.accountUnlocked()) {
throw new IllegalStateException("Account " + ethFirstAccount + " can not be unlocked!");
}
final List<String> privateFor = null;
int sleepDuration = 2 * 1000;
int attempts =50;
final ClientTransactionManager clientTransactionManager = new ClientTransactionManager(this.quorum, ethFirstAccount, ethFirstAccount, privateFor);
//final ContractGasProvider contractGasProvider = new DefaultGasProvider();
final ContractGasProvider contractGasProvider = new PersonalGasProvider();
final Tokens tokens = Tokens.deploy(this.quorum, clientTransactionManager, contractGasProvider).send();
public class PersonalGasProvider extends StaticGasProvider {
public static final BigInteger GAS_LIMIT = DefaultGasProvider.GAS_LIMIT;
public static final BigInteger GAS_PRICE = BigInteger.ZERO;
public PersonalGasProvider() {
super(GAS_PRICE, GAS_LIMIT);
}
}
When I execute the code. I get the following error:
Exception in thread "main" org.web3j.protocol.exceptions.TransactionException: Transaction receipt was not generated after 100 seconds for transaction: 0xbb0792515b9b84bb6d41956925027db0d8b4636470c475987b882993a257f974 at org.web3j.tx.response.PollingTransactionReceiptProcessor.getTransactionReceipt(PollingTransactionReceiptProcessor.java:51) at org.web3j.tx.response.PollingTransactionReceiptProcessor.waitForTransactionReceipt(PollingTransactionReceiptProcessor.java:29) at org.web3j.tx.TransactionManager.processResponse(TransactionManager.java:72) at org.web3j.tx.TransactionManager.executeTransaction(TransactionManager.java:51) at org.web3j.tx.ManagedTransaction.send(ManagedTransaction.java:87) at org.web3j.tx.Contract.executeTransaction(Contract.java:291) at org.web3j.tx.Contract.create(Contract.java:333) at org.web3j.tx.Contract.deploy(Contract.java:387) at org.web3j.tx.Contract.lambda$deployRemoteCall$10(Contract.java:496) at org.web3j.protocol.core.RemoteCall.send(RemoteCall.java:30)
This java code works randomly because 10% of the executions the code finish the execution succesfully. But The other 90% of the executions appear the error.
The flow is the following:
- Quorum 7nodes example deployed into a remote server
- Smart-contract wrappers packaged into a JAR
- A simple code execute the wrappers deploy method
Any idea about what happend?
EDIT
With this chages the error persist and the IDE warn me about that deploy constructor is deprecated
final ClientTransactionManager clientTransactionManager = new ClientTransactionManager(this.quorum, ethFirstAccount, /* ethFirstAccount */null, privateFor, attempts, sleepDuration);
final Users users = Users.deploy(this.quorum, clientTransactionManager, BigInteger.valueOf(0), BigInteger.valueOf(30000000) /* contractGasProvider */).send();