Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastRawTransactionManager is not able to deploy smartcontract #688

Closed
flefevre opened this issue Aug 29, 2018 · 5 comments
Closed

FastRawTransactionManager is not able to deploy smartcontract #688

flefevre opened this issue Aug 29, 2018 · 5 comments
Labels
fixed-awaiting-pr-approval issue is fixed, PR that needs-approval stale no activity for 21 days

Comments

@flefevre
Copy link
Contributor

flefevre commented Aug 29, 2018

When creating a FastRawTransactionManager with the web3j SimpleStorage.sol, I am not able to deploy it.

Small github repository to display the error

git clone https://github.com/flefevre/web3jmultipletx.git
cd web3jmultipletx
mvn clean install -f web3jmultipletxsmartcontract/pom.xml 

And run the web3jmultipletxsmartcontract/MultipleCreationFastTransactionManager.java

Any idea?

Error:

1948 [main] INFO org.github.web3j.web3jmultipletxsmartcontract.MultipleCreationFastTransactionManager - 1535464950175	Deploy first time with send: 
fastRawTxMgr.getCurrentNonce()=-1
java.lang.RuntimeException: java.lang.NoSuchMethodException: org.github.web3j.web3jmultipletxsmartcontract.SimpleStorage.<init>(java.lang.String, org.web3j.protocol.Web3j, org.web3j.tx.TransactionManager, org.web3j.tx.gas.ContractGasProvider)
	at org.web3j.tx.Contract.deploy(Contract.java:375)
	at org.web3j.tx.Contract.lambda$deployRemoteCall$6(Contract.java:404)
	at org.web3j.protocol.core.RemoteCall.send(RemoteCall.java:30)
	at org.github.web3j.web3jmultipletxsmartcontract.MultipleCreationFastTransactionManager.main(MultipleCreationFastTransactionManager.java:61)
Caused by: java.lang.NoSuchMethodException: org.github.web3j.web3jmultipletxsmartcontract.SimpleStorage.<init>(java.lang.String, org.web3j.protocol.Web3j, org.web3j.tx.TransactionManager, org.web3j.tx.gas.ContractGasProvider)
	at java.lang.Class.getConstructor0(Class.java:3082)
	at java.lang.Class.getDeclaredConstructor(Class.java:2178)
	at org.web3j.tx.Contract.deploy(Contract.java:362)
	... 3 more
Contract is null

@flefevre
Copy link
Contributor Author

A new analysis of the problem shows thazt the problem is linked to web3j-maven-plugin
See: hyperledger/web3j-maven-plugin#34

@flefevre
Copy link
Contributor Author

In the web3j-maven-plugin, Heinz M. analysis shows it is not in web3j-maven-plugin since it is a helper plugin. So the error has to be address here in web3j generator.
I will copy/paste my small analysis here:

Initially I was thinking the error comes from FastRawTransactionManager, in fact after a deeper analysis it is due to the fact the generated code from web3j-Maven-plugin is not compliant with latest changes in web3j plugin.

protected SimpleStorage(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    protected SimpleStorage(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

Badly default constructor with super are deprecated in Contract class

By adding manually the following one, I was able to solve the error

protected SimpleStorage(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
    }

So I would like to propose a PR where the generator is upgraded with a new constructor with transactionManager, contractGasProvider parameters

@MykolaMarkov
Copy link

Hi, you can follow similar way as in this pull request #657

flefevre added a commit to flefevre/web3j that referenced this issue Sep 14, 2018
…dger#688

### What does this PR do?

- remove deprecated constructor method in generator
- change load method in generator

both of these changes introduce the ContractGasProvider in the generated
code

 ### Where should the reviewer start?

have a look to SolidityFunctionWrapper

 ### Why is it needed?

test the generated code in the linked project web3j-maven-plugin
@flefevre
Copy link
Contributor Author

Hello, I have made of PR based on the one you show me
Could you have a look to it?
Do not hesitate to ask me modifications in order to improve the work
#709
Thanks

flefevre added a commit to flefevre/web3j that referenced this issue Sep 17, 2018
…dger#688

### What does this PR do?

- remove deprecated constructor method in generator
- change load method in generator

both of these changes introduce the ContractGasProvider in the generated
code

 ### Where should the reviewer start?

have a look to SolidityFunctionWrapper

 ### Why is it needed?

test the generated code in the linked project web3j-maven-plugin
@iikirilov iikirilov added the fixed-awaiting-pr-approval issue is fixed, PR that needs-approval label Nov 14, 2018
@stale
Copy link

stale bot commented Aug 19, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale no activity for 21 days label Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed-awaiting-pr-approval issue is fixed, PR that needs-approval stale no activity for 21 days
Projects
None yet
Development

No branches or pull requests

4 participants