1

I am running private ethereum blockchain using geth and I am using web3j to send transactions. Since yesterday I am not able to deploy my contract, In my java console I am getting "transaction receipt was not generated after 600 seconds for transaction" while I can see using block explorer that the contract is created in my blockchain.

String contractAddress = myContract.deploy(web3j, credentials, DefaultGasProvider.GAS_PRICE, DefaultGasProvider.GAS_LIMIT, BigInteger.valueOf(campaign.getId()),
                        campaign.getName(), startDateTime, endDateTime).send().getContractAddress();

Here is my genesis file code

{
"config": {  
        "chainId": 987, 
        "homesteadBlock": 0,
        "eip150Block": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "nonce": "0x0000000000000042",
    "timestamp": "0x0",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x00",
    "gasLimit": "0x8000000",
    "difficulty": "0x400",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0x3333333333333333333333333333333333333333",
    "alloc": {
    }
}

I am using following command to run blockchain

geth --datadir ~/chaindata/ --networkid 12345 --verbosity 3 --rpc --port 30304 --rpcport 8545 --rpcaddr "<private IP>" --rpccorsdomain "http://<private IP>:8080,  http://<private IP>:8000" --rpcapi "web3,eth,personal,net"  --preload "/home/ubuntu/scripts/mineWhenNeeded.js" --nodiscover  --gcmode archive  --allow-insecure-unlock > ~/myLogs/bcLogs.out 2>&1 &

Also, my miner was creating so many blank blocks so I have used following script to mine the blocks when only needed


var minimum_confirmations = 3;
var mining_threads = 1
var txBlock = 0
function checkWork() {
    if (eth.getBlock("pending").transactions.length > 0) {
        txBlock = eth.getBlock("pending").number
        if (eth.mining) return;
        console.log("  Transactions pending. Mining...");
        miner.start(mining_threads)
        interval = setInterval(function () {
            if (eth.getBlock("latest").number < txBlock + minimum_confirmations) {
                if (eth.getBlock("pending").transactions.length > 0) txBlock = eth.getBlock("pending").number;
            } else {
                console.log(minimum_confirmations + " confirmations achieved; mining stopped.");
                miner.stop()
                clearInterval(interval);
            }
        }, 600)
    }
}

eth.filter("latest", function (err, block) { checkWork(); });
eth.filter("pending", function (err, block) { checkWork(); });

checkWork();

Also, my average blocktime is getting too higher its 38.9 minute now. How to reduce the average blocktime?

0

Set gasPrice and gas for your transaction by hand. Do not trust gas price estimators wallets and nodes are using. Check ethgasstation.info/ for the current network status.

Also, I am not expert on web3j but on web3.js you can tune various timeouts used by the library.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.