Ethereum private testnet failing due to peers not connecting - ethereum

The problem
I want to create a private Ethereum network, however my two peers refuse to connect. They always fail with the following error: Snapshot extension registration failed peer=af5dfeb7 err="peer connected on snap without compatible eth support".
My attempted fixes
Setting --snapshot=false produces the same error
Changing the --syncmode to full, fast or light made no difference
Adding the peers manually with admin.addPeer(${peer1.admin.nodeInfo.enode}) returns true, however net.peerCount and admin.peers.length return 0
Changing the chainId did not produce any different results
Waiting did not help
My setup proccess
Creating the peers:
geth init --datadir "peer1" genesis.json
geth init --datadir "peer2" genesis.json
Starting the peers and opening the console:
geth --datadir "peer1" --networkid 1111 --port 30401 console 2>peer1.log
geth --datadir "peer2" --networkid 1111 --port 30402 console 2>peer2.log
The genesis file (Created by puppeth)
{
"config": {
"chainId": 1111,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"ethash": {}
},
"nonce": "0x0",
"timestamp": "0x61af5dd9",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"baseFeePerGas": null
}
Geth version info
Geth
Version: 1.10.13-stable
Git Commit: 7a0c19f813e285516f4b525305fd73b625d2dec8
Architecture: amd64
Go Version: go1.17.2
Operating System: linux
GOPATH=
GOROOT=go

Related

geth event newPendingTransactions does not occur

I've got running geth with next command:
$ geth --testnet --networkid 3 --verbosity 3 --syncmode light --ipcdisable --ws --wsapi "db,eth,net,web3,personal,txpool,admin,miner" --wsorigins '*'
In second console I connect to geth jsonrpc with wscat.
Subscribing to an event "newHeads" works fine:
$ wscat -c ws://localhost:8546
> {"id": 2, "method": "eth_subscribe", "params": ["newHeads"]}
< {"jsonrpc":"2.0","id":2,"result":"0x660135584e36a9edb0c55f89c389848"}
< {"jsonrpc":"2.0","method":"eth_subscription","params":{"subscription":"0x660135584e36a9edb0c55f89c389848","result":{"parentHash":"0xe7d0...","hash":"0x1dcc...
But subscribing to an event "newPendingTransactions" not works:
$ wscat -c ws://localhost:8546
> {"id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions"]}
< {"jsonrpc":"2.0","id":1,"result":"0x511b3274aa5dec44bb79d178c238e7fe"}
And it's all: I do not get new pending transactions.
Subscribing to an event "newPendingTransactions" on ropsten.infura.io works fine:
$ wscat -c wss://ropsten.infura.io/ws
> {"id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions"]}
< {"jsonrpc":"2.0","id":1,"result":"0x18fda7bf20ee9c5b5f1f08edf5c3e482"}
< {"jsonrpc":"2.0","method":"eth_subscription","params":{"subscription":"0x18fda7bf20ee9c5b5f1f08edf5c3e482","result":"0xc1e00266ab9f2c512d6c1967c300fc00381586e868611b7dff6fd94f230dd707"}}
Info:
$ geth version
Geth
Version: 1.8.22-stable
Git Commit: 7fa3509e2eaf1a4ebc12344590e5699406690f15
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.10.4
Operating System: linux
GOPATH=
GOROOT=/usr/lib/go-1.10
I have two questions:
1. Why subscribing to event "newPendingTransactions" not works?
2. What am I doing wrong?
The problem was that I did not wait for the end of synchronization.
I started from scratch (this time i used Rinkeby network):
geth --rinkeby --verbosity 3 --syncmode fast --ipcdisable --ws --wsapi "db,eth,net,web3,personal,txpool,admin" --wsorigins '*'
For the Rinkeby network, this took about 20 hours and the size of the blockchain is about 25 gigabytes on my SSD.
And now the subscribing for newPendingTransactions event works fine!
Thanks all!

Exceeds block gas limit while deploying the contract in latest ethereum

I am trying to execute the steps from https://medium.com/#mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2.
However, the difference is I am running geth on AWS server instead of truffle or testnet as specified in the link. I need to get deployed contract address to try on UI. I am using the following geth command: geth --networkid 12312423 --port 30303 -rpc -rpcaddr "0.0.0.0" -rpcport 8080 --rpcapi "web3,db,net,personal,eth" --rpccorsdomain "*" --preload mining.js --nodiscover --maxpeers 0 --datadir=~/eth/data231 init genesis.json console
I have run Node commands on another screen in the same machine. I have gone till the end of the steps and I am receiving Error: exceeds block gas limit while deploying the contract. Is there any error in the genesis.json that I am using.
Any suggestions will help thanks...
genesis.json
{
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"difficulty": "200000000",
"gasLimit": "2100000",
"alloc": {
"7df9a875a174b3bc565e6424a0050ebc1b2d1d82": { "balance": "300000" },
"f41c74c9ae680c1aa78f42e5647a62f353b7bdde": { "balance": "400000" }
}
}
The problem is solved. There are 2 learnings from the solution:
The gasLimit in the genesis.json should be higher like "gasLimit": "3141592000000".
We should first start geth without init. Create account, unlock. Then allocate the balance for the account as below and do git init.
i.e.
Once you’ve generated your account, quit geth with and remove every folder except keystore/ from your datatir:
$ cd
$ rm -rf ls | grep -v keystore
update your genesis block json, adding the following to the alloc key:
"alloc": {
"": {
"balance": "10000000000000000000"
}
}

I can not put a contract on to ethereum via Remix-Solidity by error - Invalid sender

I tried to run the following contract on to the ethereum blockchain,though,
I got a error of "callback contain no result Error: Invalid sender".
pragma solidity ^0.4.0;
contract SingleNumRegister {
uint storedData;
function set(uint x) {
storedData = x;
}
function get() constant returns (uint retVal) {
return storedData;
}
}
The accounts[0] already has enough Gas and it is unlocked.
I have no idea of why this message occurs. Please give me some advice to solve the issue.
//////Data of environment///////
IDE :
Browser-Only Solidity IDE and Runtime Environment
remix-4a2c813.zip.
Web3 Provider
geth :
geth --datadir "/home/yuichi/ethe-prj/dprvnet" --port 30304 --networkid 1234 --rpc --rpcport "8545" --nodiscover --rpccorsdomain "*" console 2>./console.log
instance: Geth/v1.6.1-stable-021c3c28/linux-amd64/go1.8.1
coinbase: 0x91be0471171c5ddfe94cf5b3b81d1d1d5e9cab26
at block: 9466 (Fri, 02 Jun 2017 05:35:45 JST)
datadir: /home/yuichi/ethe-prj/dprvnet
modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
I found out the cause why this happened. genesis.json was incorrect.
Actually config section was wrong. I corrected like this:
"config": {
"chainID": 10,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
And I started again with "geth init" command again like:
geth --datadir AAA init genesis.json
And I created a node and started mining. The error was fixed!

Ethereum truffle MetaCoin fails with 'intrinsic gas too low'

Pretty much as stated in the title, after running truffle test I get this:
TestMetacoin
1) "before all" hook: prepare suite
Contract: MetaCoin
✓ should put 10000 MetaCoin in the first account
2) should call a function that depends on a linked library
> No events were emitted
✓ should send coin correctly (6078ms)
2 passing (6s)
2 failing
1) TestMetacoin "before all" hook: prepare suite:
Error: Intrinsic gas too low
at Object.InvalidResponse (/usr/lib/node_modules/truffle/node_modules/truffle-contract/node_modules/web3/lib/web3/errors.js:35:16)
at /usr/lib/node_modules/truffle/node_modules/truffle-contract/node_modules/web3/lib/web3/requestmanager.js:86:36
at XMLHttpRequest.request.onreadystatechange (/usr/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:119:13)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:64:18)
at XMLHttpRequest._setReadyState (/usr/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:354:12)
at XMLHttpRequest._onHttpResponseEnd (/usr/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:509:12)
at IncomingMessage.<anonymous> (/usr/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:469:24)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
2) Contract: MetaCoin should call a function that depends on a linked library:
AssertionError: Library function returned unexpected function, linkage may be broken: expected 0 to equal 20000
at test/metacoin.js:25:14
at process._tickDomainCallback (internal/process/next_tick.js:129:7)
My genesis block is as follows:
{
"nonce": "0x0000000000000042",
"difficulty": "0x4000",
"alloc": {
"0xfd0ceb7965a0e4c3146c1f901fbab9668653af6b": {
"balance": "325406000000000"
}
},
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0xfd0ceb7965a0e4c3146c1f901fbab9668653af6b",
"etherbase" : "0xfd0ceb7965a0e4c3146c1f901fbab9668653af6b",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x3d0900"
}
And my truffle.js is like this:
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*", // Match any network id
gas: 1000000
}
}
};
I fail to understand what is wrong with gas at these settings. Even if noone has the exact answer, some additional explanation of the gas limits (not the gas itself) would be helpful.
I ended up changing genesis block gasLimit to
"gasLimit": "0x2FEFD800",
config for homestead block to 10 (apparently otherwise there are issues when working with geth):
"config": {
"homesteadBlock": 10
},
and truffle.js gas setting to 5000000.
Tests pass.

JSON-RPC Message error when starting geth node or testrpc

I am trying to create a private network so that I can start testing my Solidity code. However, when starting the a geth private network with geth --rpc but I then run into an error for an invalid response. {"jsonrpc":"2.0","error":{"code":-32600,"message":"EOF"}} when checking localhost:8545.
I don't think it matters, but my genesis.json file is
{
"nonce": "0x0000000000000042", "timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0", "gasLimit": "0x8000000", "difficulty": "0x400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333", "alloc": { }}
I have also tried creating a test network with testrpc with just the command testrpc but here the localhost:8545 returns a parsing error {"jsonrpc": "2.0", "id": null, "error": {"message": "Parse error", "code": -32700}}.
What is the JSON that I am sending because it seems to be incorrectly written?
Thanks
It's hard to tell what exactly you are trying, but the JSON RPC endpoint of geth requires a JSON command, for instance try to query the web3 version with the following request:
{
"method": "web3_clientVersion",
"params": []
}
It complains because you do not provide any request, i.e., running a plain testrpc command.
But inbetween the lines I read that you are testing your solidity code. Have you had a look at the wonderful browser solidity?