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

Found processing completed slower than mining completed (mining done = 30ms vs. web3j done processing= 10s++) #70

Closed
mindraker opened this issue Mar 15, 2017 · 4 comments

Comments

@mindraker
Copy link

Are there any part of the code holding the response even the mining already done? (the block is created, and the value is already updated, somehow the response not received, and keep processing for 10s)

We created our own Ethereum custom network and tune it to be pretty fast in mining.
What we found during the poc & comparison between web3.js & web3.j is:

  1. Submit request by both method (modify a value in the hashmap and print out the value get directly from the hashmap)
  2. The mining done less than a sec > the block has been created successfully
  3. The mining stopped

web3.js = the value is modified, response received, and printed to the console less than a sec. it can handled quite some concurrent since it processed quite fast even sometimes the printed value operation faster than the mining

web3.j = once the transaction submitted, it seems like the response is hold (the value already changed, somehow it doesn't stop processing). At some point of concurrent, the memory consumption is very high and out of mem.

I think I might do something wrong at some point. Please suggest. Thanks in advance.

This is some part of t he code:

public void addCoin(long who, long value) throws Exception{
try {
TransactionReceipt result = wowClient.addCoin(new Uint256(BigInteger.valueOf(who)), new Uint256(BigInteger.valueOf(value))).get();
EventValues event = wowClient.processPrint2Event(result);
System.out.println(event.getNonIndexedValues().get(0).getValue());
} catch (InterruptedException | ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

@conor10
Copy link
Contributor

conor10 commented Mar 16, 2017

By default web3j polls every 15 seconds for a transaction response. You can modify this value in your transaction manager:

// Using RawTransactionManager
TransactionManager transactionManager = new org.web3j.tx.RawTransactionManager(web3j, <credentials>, 40, 500);

// Or using ClientTransactionManager
TransactionManager transactionManager = new org.web3j.tx.ClientTransactionManager(web3j, "0x<fromAddress>", 40, 500);

// Now we'll poll every 500 ms for a transaction response
YourContract contract = YourContract.deploy("0x<contracAddress>", web3j,
        transactionManager, ManagedTransaction.GAS_PRICE, Contract.GAS_LIMIT,
        <initialValue>, <constructorParam1>,...);

Note - make sure you're using web3j 2.1.0 as prior to this version, the smart contract initial deployment was fixed at 15 seconds.

If you want this to be as fast as possible, I'd recommend using IPC, as it's a lot faster than HTTP for communicating with the clients. See here for details.

@conor10
Copy link
Contributor

conor10 commented Mar 20, 2017

@mindraker is this still an issue?

@mindraker
Copy link
Author

@conor10 Sorry for late reply. Thanks! It's work!

@conor10
Copy link
Contributor

conor10 commented Mar 24, 2017

Great, then I'll close this.

@conor10 conor10 closed this as completed Mar 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants