Open 3Mohammed2013 opened 6 years ago
@3Mohammed2013 Have you finished fast sync? What's your best block currently?
No, I do not how can I make fast sync, if you have time can you guide me for the best way to run sync or link that help, the current state I run the Ethereum-harmony with gradlew run private if you do not mind let me ask you a couple of the question 1- is the ethereum harmony need to run the JSON-RPC or Ethereumj or it works independently sorry about the question but to make a clear picture to me because I work individual https://github.com/ethereum/wiki/wiki/JSON-RPC 2- when I add the peer on the terminal of the Ethereum-harmony by using adminAddPeer and the enode of the device, but in my project, I use a raspberry pi which cannot run Ethereum-harmony because of the capacity of it so I use geth.admin to get the enode of my raspbain so for the adminAddPeer show true, but when I go to the option in Ethereum-harmony which is Ethereum peer does not show to me that is continued
I would really thank you for you're a great time that you answer my question I really appreciate that
Sincerely
You don't need fast sync for private network, I guess.
1- is the ethereum harmony need to run the JSON-RPC
Yes, no JSON-RPC in EthereumJ, only in Harmony.
2- when I add the peer on the terminal ...
Probably some conflict of peers, you should check logs on both nodes. Maybe genesis mismatch (they must be the same on both peers) or networkId mismatch.
great but on the private is a show to me disable sync, Do you me that I totally do not need any sync it ok if it disables
1-so how can I run the JSON-RPC in Harmony is there any probable way to run it because on the
on this page, there are only how to run the harmony but it shows to me the JSON-RPC port 8080 and on the JSON-RPC in the ethereumj it with a different client and each client has own port like Go it port 8545 and so on
https://github.com/ether-camp/ethereum-harmony
2- when I add peer do you mean that should I configure it like "Custom config file format"
if it yes how can I call it on the terminal
there are no peer connected to make any conflict
Thank you Sincerely
Only 2 nodes in your private network? Harmony locally and geth on rapsberry pi? Who is miner?
1 - JSON-RPC is enabled by default. It runs on the same port with http, 8080 by default. Or you could override it with local.server.port
. We are thinking about separate ports for http and rpc (so, move it to default rpc port) but no final decision yet.
2 - It should be configured before startup. You should modify private.conf
, so you will have the same settings in Harmony and Geth.
Check our guide https://github.com/ether-camp/ethereum-harmony/wiki/Setting-up-a-private-network#integration-with-geth for more info
I would really thank you for your a great time and really appreciate it and I will follow the steps as you suggested to me, the picture know it clear to me after I had a discussion with you https://github.com/ether-camp/ethereum-harmony/wiki/Setting-up-a-private-network#genesis-for-private-network If you don't mind, if I face any problem in the future can I talk with you if I do not bother you
last things the miner is my pc that I was run the harmony on it. Can my pc it appear node and miner at the same time? or should I separate that it
if I face any problem in the future can I talk with you
Sure, continue in this thread
Can my pc it appear node and miner at the same time?
Sure!
hi i have the same problem, i read the comments but don't found the solution. i have a Miner and EventListenerSample for test the contract in Harmony. i verified the networkId, nodeId , i can see the bestblock in Harmony and i have the configuration of https://github.com/ether-camp/ethereum-harmony/wiki/Setting-up-a-private-network#genesis-for-private-network but continue the message "hasn't any code. Please ensure blockchain is fully synced."
@1jose234 Are you sure you've deployed your contract, you've verified by rpc/terminal that transaction was successful?
@zilm13 i think that tx is correct because i can see in the log when the contract is compile, call the function inc and return the value of get this is the configuration in Harmony
# Peer discovery is supposed to be disabled
peer.discovery.enabled = false
#List of nodes the peer should connect to
peer.active = [
{
ip = 192.168.6.72
port = 30340
nodeId = 26ba1aadaf59d7607ad7f437146927d79e80312f026cfa635c6b2ccf2c5d3521f5812ca2beb3b295b14f97110e6448c1c7ff68f14c5328d43a3c62b44143e9b1
}
]
#Network id
peer.networkId = 556
#Network genesis file
#No need to change it because we will use -DgenesisFile
genesis = sample-genesis.json
#Consensus algorithm
blockchain.config.name = null
blockchain.config.class = "org.ethereum.config.blockchain.FrontierConfig"
@1jose234 I will try to reproduce it and ping back
@zilm13 Hi do you have any notice for this ?
@1jose234 Sorry, forgot. Ok, I've tried and everything runs ok. Steps that I did: 1) Start Harmony
cd ethereum-harmony
./gradlew runPrivate -Xmx3500M -Dethereumj.conf.res=private.conf -Ddatabase.name=database-private -Dmine.fullDataSet=true
2) Start EthereumJ sample
/*
* Copyright (c) [2016] [ <ether.camp> ]
* This file is part of the ethereumJ library.
*
* The ethereumJ library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The ethereumJ library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.
*/
package org.ethereum.samples;
import org.ethereum.core.Block;
import org.ethereum.core.CallTransaction;
import org.ethereum.core.PendingStateImpl;
import org.ethereum.core.Transaction;
import org.ethereum.core.TransactionReceipt;
import org.ethereum.crypto.ECKey;
import org.ethereum.db.BlockStore;
import org.ethereum.db.ByteArrayWrapper;
import org.ethereum.db.TransactionStore;
import org.ethereum.facade.EthereumFactory;
import org.ethereum.listener.BlockReplay;
import org.ethereum.listener.EthereumListener;
import org.ethereum.listener.EthereumListenerAdapter;
import org.ethereum.listener.EventListener;
import org.ethereum.listener.TxStatus;
import org.ethereum.solidity.compiler.CompilationResult;
import org.ethereum.solidity.compiler.SolidityCompiler;
import org.ethereum.util.ByteUtil;
import org.ethereum.vm.program.ProgramResult;
import org.spongycastle.util.encoders.Hex;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import static org.ethereum.crypto.HashUtil.sha3;
/**
* Sample usage of events listener API.
* {@link EventListener} Contract events listener
* {@link BlockReplay} Listener wrapper for pushing old blocks to any listener in addition to live data
*
* - getting free Ether assuming we are running in test network
* - deploying contract with event, which we are going to track
* - calling contract and catching corresponding events
* - alternatively you could provide address of already deployed contract and
* replay any number of blocks in the past to process old events
*/
public class EventListenerSample extends TestNetSample {
@Autowired
SolidityCompiler compiler;
@Autowired
BlockStore blockStore;
@Autowired
TransactionStore transactionStore;
@Autowired
PendingStateImpl pendingState;
// Change seed phrases
protected final byte[] senderPrivateKey = sha3("cow".getBytes());
// protected final byte[] sender2PrivateKey = sha3("goat".getBytes());
// If no contractAddress provided, deploys new contract, otherwise
// replays events from already deployed contract
String contractAddress = null;
// String contractAddress = "cedf27de170a05cf1d1736f21e1f5ffc1cf22eef";
String contract =
"contract Sample {\n" +
" int i;\n" +
" event Inc(\n" +
" address _from,\n" +
" int _inc,\n" +
" int _total\n" +
" ); \n" +
" \n" +
" function inc(int n) {\n" +
" i = i + n;\n" +
" Inc(msg.sender, n, i); \n" +
" } \n" +
" \n" +
" function get() returns (int) {\n" +
" return i; \n" +
" }\n" +
"} ";
private Map<ByteArrayWrapper, TransactionReceipt> txWaiters =
Collections.synchronizedMap(new HashMap<ByteArrayWrapper, TransactionReceipt>());
class IncEvent {
IncEvent(String address, Long inc, Long total) {
this.address = address;
this.inc = inc;
this.total = total;
}
String address;
Long inc;
Long total;
@Override
public String toString() {
return "IncEvent{" +
"address='" + address + '\'' +
", inc=" + inc +
", total=" + total +
'}';
}
}
class IncEventListener extends EventListener<IncEvent> {
/**
* Minimum required Tx block confirmations for the events
* from this Tx to be confirmed
* After this number of confirmations, event will fire {@link #processConfirmed(PendingEvent, IncEvent)}
* on each confirmation
*/
protected int blocksToConfirm = 32;
/**
* Minimum required Tx block confirmations for this Tx to be purged
* from the tracking list
* After this number of confirmations, event will not fire {@link #processConfirmed(PendingEvent, IncEvent)}
*/
protected int purgeFromPendingsConfirmations = 40;
public IncEventListener(PendingStateImpl pendingState) {
super(pendingState);
}
public IncEventListener(PendingStateImpl pendingState, String contractABI, byte[] contractAddress) {
super(pendingState);
initContractAddress(contractABI, contractAddress);
// Instead you can init with topic search,
// so you could get events from all contracts with the same code
// You could init listener only once
// initContractTopic(contractABI, sha3("Inc(address,int256,int256)".getBytes()));
}
@Override
protected IncEvent onEvent(CallTransaction.Invocation event, Block block, TransactionReceipt receipt, int txCount, EthereumListener.PendingTransactionState state) {
// Processing raw event data to fill our model IncEvent
if ("Inc".equals(event.function.name)) {
String address = Hex.toHexString((byte[]) event.args[0]);
Long inc = ((BigInteger) event.args[1]).longValue();
Long total = ((BigInteger) event.args[2]).longValue();
IncEvent incEvent = new IncEvent(address, inc, total);
logger.info("Pending event: {}", incEvent);
return incEvent;
} else {
logger.error("Unknown event: " + event);
}
return null;
}
@Override
protected void pendingTransactionsUpdated() {
}
/**
* Events are fired here on every block since blocksToConfirm to purgeFromPendingsConfirmations
*/
void processConfirmed(PendingEvent evt, IncEvent event) {
// +1 because on included block we have 1 confirmation
long numberOfConfirmations = evt.bestConfirmingBlock.getNumber() - evt.includedTo.getNumber() + 1;
logger.info("Confirmed event: {}, confirmations: {}", event, numberOfConfirmations);
}
@Override
protected boolean pendingTransactionUpdated(PendingEvent evt) {
if (evt.txStatus == TxStatus.REJECTED || evt.txStatus.confirmed >= blocksToConfirm) {
evt.eventData.forEach(d -> processConfirmed(evt, d));
}
return evt.txStatus == TxStatus.REJECTED || evt.txStatus.confirmed >= purgeFromPendingsConfirmations;
}
}
/**
* Sample logic starts here when sync is done
*/
@Override
public void onSyncDone() throws Exception {
ethereum.addListener(new EthereumListenerAdapter() {
@Override
public void onPendingTransactionUpdate(TransactionReceipt txReceipt, PendingTransactionState state, Block block) {
ByteArrayWrapper txHashW = new ByteArrayWrapper(txReceipt.getTransaction().getHash());
// Catching transaction errors
if (txWaiters.containsKey(txHashW) && !txReceipt.isSuccessful()) {
txWaiters.put(txHashW, txReceipt);
}
}
});
// requestFreeEther(ECKey.fromPrivate(senderPrivateKey).getAddress());
// requestFreeEther(ECKey.fromPrivate(sender2PrivateKey).getAddress());
if (contractAddress == null) {
deployContractAndTest();
} else {
replayOnly();
}
}
public void requestFreeEther(byte[] addressBytes) {
String address = "0x" + Hex.toHexString(addressBytes);
logger.info("Checking address {} for available ether.", address);
BigInteger balance = ethereum.getRepository().getBalance(addressBytes);
logger.info("Address {} balance: {} wei", address, balance);
BigInteger requiredBalance = BigInteger.valueOf(3_000_000 * ethereum.getGasPrice());
if (balance.compareTo(requiredBalance) < 0) {
logger.info("Insufficient funds for address {}, requesting free ether", address);
try {
String result = postQuery("https://ropsten.faucet.b9lab.com/tap", "{\"toWhom\":\"" + address + "\"}");
logger.info("Answer from free Ether API: {}", result);
waitForEther(addressBytes, requiredBalance);
} catch (Exception ex) {
logger.error("Error during request of free Ether,", ex);
}
}
}
private String postQuery(String endPoint, String json) throws IOException {
URL url = new URL(endPoint);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(5000);
conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
OutputStream os = conn.getOutputStream();
os.write(json.getBytes("UTF-8"));
os.close();
// read the response
InputStream in = new BufferedInputStream(conn.getInputStream());
String result = null;
try (Scanner scanner = new Scanner(in, "UTF-8")) {
result = scanner.useDelimiter("\\A").next();
}
in.close();
conn.disconnect();
return result;
}
private void waitForEther(byte[] address, BigInteger requiredBalance) throws InterruptedException {
while(true) {
BigInteger balance = ethereum.getRepository().getBalance(address);
if (balance.compareTo(requiredBalance) > 0) {
logger.info("Address {} successfully funded. Balance: {} wei", "0x" + Hex.toHexString(address), balance);
break;
}
synchronized (this) {
wait(20000);
}
}
}
/**
* - Deploys contract
* - Adds events listener
* - Calls contract from 2 different addresses
*/
private void deployContractAndTest() throws Exception {
ethereum.addListener(new EthereumListenerAdapter() {
// when block arrives look for our included transactions
@Override
public void onBlock(Block block, List<TransactionReceipt> receipts) {
EventListenerSample.this.onBlock(block, receipts);
}
});
CompilationResult.ContractMetadata metadata = compileContract();
logger.info("Sending contract to net and waiting for inclusion");
TransactionReceipt receipt = sendTxAndWait(new byte[0], Hex.decode(metadata.bin), senderPrivateKey);
if (!receipt.isSuccessful()) {
logger.error("Some troubles creating a contract: " + receipt.getError());
return;
}
byte[] address = receipt.getTransaction().getContractAddress();
logger.info("Contract created: " + Hex.toHexString(address));
IncEventListener eventListener = new IncEventListener(pendingState, metadata.abi, address);
ethereum.addListener(eventListener.listener);
CallTransaction.Contract contract = new CallTransaction.Contract(metadata.abi);
contractIncCall(senderPrivateKey, 777, metadata.abi, address);
// contractIncCall(sender2PrivateKey, 555, metadata.abi, address);
ProgramResult r = ethereum.callConstantFunction(Hex.toHexString(address),
contract.getByName("get"));
Object[] ret = contract.getByName("get").decodeResult(r.getHReturn());
logger.info("Current contract data member value: " + ret[0]);
}
/**
* Replays contract events for old blocks
* using {@link BlockReplay} with {@link EventListener}
*/
private void replayOnly() throws Exception {
logger.info("Contract already deployed to address 0x{}, using it", contractAddress);
CompilationResult.ContractMetadata metadata = compileContract();
byte[] address = Hex.decode(contractAddress);
IncEventListener eventListener = new IncEventListener(pendingState, metadata.abi, address);
BlockReplay blockReplay = new BlockReplay(blockStore, transactionStore, eventListener.listener,
blockStore.getMaxNumber() - 5000);
ethereum.addListener(blockReplay);
blockReplay.replayAsync();
}
private CompilationResult.ContractMetadata compileContract() throws IOException {
logger.info("Compiling contract...");
SolidityCompiler.Result result = compiler.compileSrc(contract.getBytes(), true, true,
SolidityCompiler.Options.ABI, SolidityCompiler.Options.BIN);
if (result.isFailed()) {
throw new RuntimeException("Contract compilation failed:\n" + result.errors);
}
CompilationResult res = CompilationResult.parse(result.output);
if (res.getContracts().isEmpty()) {
throw new RuntimeException("Compilation failed, no contracts returned:\n" + result.errors);
}
CompilationResult.ContractMetadata metadata = res.getContracts().iterator().next();
if (metadata.bin == null || metadata.bin.isEmpty()) {
throw new RuntimeException("Compilation failed, no binary returned:\n" + result.errors);
}
return metadata;
}
private void contractIncCall(byte[] privateKey, int incAmount,
String contractABI, byte[] contractAddress) throws InterruptedException {
logger.info("Calling the contract function 'inc'");
CallTransaction.Contract contract = new CallTransaction.Contract(contractABI);
CallTransaction.Function inc = contract.getByName("inc");
byte[] functionCallBytes = inc.encode(incAmount);
TransactionReceipt receipt = sendTxAndWait(contractAddress, functionCallBytes, privateKey);
if (!receipt.isSuccessful()) {
logger.error("Some troubles invoking the contract: " + receipt.getError());
return;
}
logger.info("Contract modified!");
}
protected TransactionReceipt sendTxAndWait(byte[] receiveAddress,
byte[] data, byte[] privateKey) throws InterruptedException {
BigInteger nonce = ethereum.getRepository().getNonce(ECKey.fromPrivate(privateKey).getAddress());
Transaction tx = new Transaction(
ByteUtil.bigIntegerToBytes(nonce),
ByteUtil.longToBytesNoLeadZeroes(ethereum.getGasPrice()),
ByteUtil.longToBytesNoLeadZeroes(3_000_000),
receiveAddress,
ByteUtil.longToBytesNoLeadZeroes(0),
data,
ethereum.getChainIdForNextBlock());
tx.sign(ECKey.fromPrivate(privateKey));
logger.info("<=== Sending transaction: " + tx);
ByteArrayWrapper txHashW = new ByteArrayWrapper(tx.getHash());
txWaiters.put(txHashW, null);
ethereum.submitTransaction(tx);
return waitForTx(txHashW);
}
private void onBlock(Block block, List<TransactionReceipt> receipts) {
for (TransactionReceipt receipt : receipts) {
ByteArrayWrapper txHashW = new ByteArrayWrapper(receipt.getTransaction().getHash());
if (txWaiters.containsKey(txHashW)) {
txWaiters.put(txHashW, receipt);
synchronized (this) {
notifyAll();
}
}
}
}
protected TransactionReceipt waitForTx(ByteArrayWrapper txHashW) throws InterruptedException {
long startBlock = ethereum.getBlockchain().getBestBlock().getNumber();
while(true) {
TransactionReceipt receipt = txWaiters.get(txHashW);
if (receipt != null) {
return receipt;
} else {
long curBlock = ethereum.getBlockchain().getBestBlock().getNumber();
if (curBlock > startBlock + 16) {
throw new RuntimeException("The transaction was not included during last 16 blocks: " + txHashW.toString().substring(0,8));
} else {
logger.info("Waiting for block with transaction 0x" + txHashW.toString().substring(0,8) +
" included (" + (curBlock - startBlock) + " blocks received so far) ...");
}
}
synchronized (this) {
wait(20000);
}
}
}
public static void main(String[] args) throws Exception {
sLogger.info("Starting EthereumJ!");
class Config extends TestNetConfig{
@Override
@Bean
public TestNetSample sampleBean() {
return new EventListenerSample();
}
}
// Based on Config class the BasicSample would be created by Spring
// and its springInit() method would be called as an entry point
EthereumFactory.createEthereum(Config.class);
}
}
Run with
./gradlew run -PmainClass=org.ethereum.samples.EventListenerSample --info
Also put genesis from Harmony and modified config in TestNetSample to following:
private final String config =
// Ropsten revive network configuration
"peer.discovery.enabled = false \n" +
"peer.listen.port = 30312 \n" +
"peer.networkId = 111 \n" +
"peer.active = [ {url = 'enode://997a56662c90e855d244d02ca436014a811619b4cf61e8388df6abc5c65ddd5ccbf8437f8f1a9421d12f8032f9872ba80c4875984e5efc8a0f6a9b060fbfbd9b@127.0.0.1:30303'}] \n" +
"sync.enabled = true \n" +
"genesis = genesis-private.json\n" +
"blockchain.config.name = null\n" +
"blockchain.config.class = 'org.ethereum.config.blockchain.FrontierConfig' \n" +
"database.dir = privateSampleDb \n" +
"cache.flush.memory = 0";
3) After sample deployed contract and I got an address
01:01:14.814 INFO [sample] <=== Sending transaction: TransactionData [hash= nonce=00, gasPrice=104c533c00, gas=2dc6c0, receiveAddress=, sendAddress=cd2a3d9f938e13cd947ec05abc7fe734df8dd826, value=, data=6060604052341561000f57600080fd5b6101428061001e6000396000f30060606040526004361061004b5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663623845d881146100505780636d4ce63c14610068575b600080fd5b341561005b57600080fd5b61006660043561008d565b005b341561007357600080fd5b61007b610110565b60405190815260200160405180910390f35b80600054016000819055507f8331cbe38d5b89d6d7562501fd6d1d592e4d82f850ab04b10ec7496ef117b5913382600054604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390a150565b600054905600a165627a7a723058209a8f75f8851125cb85ead611108c70eada0f3da0a7afb9c908ce947319e0ac130029, signatureV=27, signatureR=694db869fea530fec3cdab8c721cbd3157eebd3ba41735ef192eb1803e6b7761, signatureS=4802e9e321cb0c2e055e0d3f685eb00ffea3ab24973f059ba696b5e7c4bb9cc8]
01:01:14.940 INFO [sample] Waiting for block with transaction 0x2050b8af included (0 blocks received so far) ...
01:01:14.980 INFO [sample] New block: #422 (cdbc99 <~ 9376f0) Txs:0, Unc: 0
01:01:21.463 INFO [sample] New block: #423 (5aaa20 <~ cdbc99) Txs:1, Unc: 0
01:01:21.464 INFO [sample] Contract created: 77045e71a7a2c50903d88e564cd72fab11e82051
01:01:21.485 INFO [sample] Calling the contract function 'inc'
tried to add it in Harmony in both ways - via pasting its code and from file. Both worked fine:
@zilm13 Hi, I have the problem running a custom network...
first i used the miner config
private final String config =
"peer.discovery.enabled = false \n" +
"peer.listen.port = 30340 \n" +
"peer.privateKey = 6ef8da380c27cea8fdf7448340ea99e8e2268fc2950d79ed47cbf6f85dc977ec \n" +
"peer.networkId = 556 \n" +
"sync.enabled = false \n" +
"genesis = sample-genesis.json \n" +
"database.dir = mineroContrato \n" +
"mine.extraDataHex = cccccccccccccccccccc \n" +
"mine.cpuMineThreads = 2 \n" +
"cache.flush.blocks = 1";
second, the config in TestNetConfig
private final String config =
"peer.discovery.enabled = false \n" +
"peer.listen.port = 30341 \n" +
"peer.networkId = 556 \n" +
"peer.active = [" +
" { url = 'enode://26ba1aadaf59d7607ad7f437146927d79e80312f026cfa635c6b2ccf2c5d3521f5812ca2beb3b295b14f97110e6448c1c7ff68f14c5328d43a3c62b44143e9b1@localhost:30340' }" +
"] \n" +
"sync.enabled = true \n" +
"genesis = sample-genesis.json \n" +
"database.dir = confConecionPrivada \n" +
"blockchain.config.name = null\n" +
"blockchain.config.class = 'org.ethereum.config.blockchain.FrontierConfig' \n" +
"cache.flush.memory = 0";
third i used the class EventListenerSamplePrivate for deploy the contract
<=== Sending transaction: TransactionData [hash= nonce=04, gasPrice=104c533c00, gas=2dc6c0...
14:23:10.217 INFO [sample] New block: #244 (9e37e8 <~ 2c9bdf) Txs:1, Unc: 0
14:23:10.218 INFO [sample] Contract created: d5885ecad461a90cfff84d26cd976ab97040ca21
14:23:10.276 INFO [sample] Calling the contract function 'inc'
so in the log of the miner i can see
Txs [
TransactionData [hash=68dfc3e2dc088cb7e32bb41cff94deeea5c7afe1f643d4288b6e62878db29466 nonce=06, gasPrice=104c533c00, gas=2dc6c0, receiveAddress=d5885ecad461a90cfff84d26cd976ab97040ca21, sendAddress=31e2e1ed11951c7091dfba62cd4b7145e947219c, value=, data=623845d8000000000000000000000000000000000000000000000000000000000000022b, signatureV=28, signatureR=bb884b5c796972170fccbe0d504d736ed7bbcbbdef375fcd206930e80230a6f5, signatureS=66c4f57090a661d8ef563b7b5a21d60354f8b5295cd773b15cf70bd83fdc59e2]
]
Start Harmony
./gradlew runCustom -Dpeer.networkId=556 -DgenesisFscovery.enabled=false -Ddatabase.dir=database -Dpeer.active.0.url=enode://26ba1aadaf59d7607ad7f437146927d79e80312f026cfa635c6b2ccf2c5d3521f5812ca2beb3b295b14f97110e6448c1c7ff68f14c5328d43a3c62b44143e9b1@localhost:30340
the file private.conf
# Peer discovery is supposed to be disabled
peer.discovery.enabled = false
database.dir = database-private
#List of nodes the peer should connect to
peer.active = [
{
ip = localhost
port = 30340
nodeId =26ba1aadaf59d7607ad7f437146927d79e80312f026cfa635c6b2ccf2c5d3521f5812ca2beb3b295b14f97110e6448c1c7ff68f14c5328d43a3c62b44143e9b1
}
]
#Network id
peer.networkId = 556
#Network genesis file
#No need to change it because we will use -DgenesisFile
genesis = sample-genesis.json
#Consensus algorithm
blockchain.config.name = null
blockchain.config.class = "org.ethereum.config.blockchain.FrontierConfig"
if you do not mind can you explain those steps , I was stop here "Also put genesis from Harmony and modified config in TestNetSample to following" I do not know how can i put the genesis from harmony how can be if you are still run the harmony in the begin what do you mean by put how can please
cd ethereum-harmony ./gradlew runPrivate -Xmx3500M -Dethereumj.conf.res=private.conf -Ddatabase.name=database-private -Dmine.fullDataSet=true
here also error occurred i was modify to be stable with me own genesisFile but not work there are file suitable fill should i put on it or it find if there are on desktop
@3Mohammed2013 1) > Start Harmony
I don't see from your screenshot have you reached short sync. Have you kept your miner running? You should to switch to to short sync. 2) > I do not know how can i put the genesis from harmony
I've just copied it from Harmony to ethereumj resources folder, so I could use it in private final String config = ...
3) you should provide path to it, if you use ethereumj.conf.res
, file should be located in resources folder src/main/resources
, you could also use ethereumj.conf.file
and provide some path anywhere on your file system
@zilm13
I don't see from your screenshot have you reached short sync. Have you kept your miner running? You should to switch to to short sync.
yes i have the miner running.. and mining blocks all time.
about of switch to short sync. i dont know how do this, could you helpme, how can i do this modification ?
@1jose234 it's shown on Home
screen, whether you are in short
sync or long
sync, you cannot switch it manually. You will be switched to short
automatically after reaching head of your chain.
Ahh look, same Harmony is miner, yeah? And you set it to mine from the config, not from the Terminal, yeah?
@zilm13
Ahh look, same Harmony is miner, yeah? And you set it to mine from the config, not from the Terminal, yeah?
i hope understand fine the question... i can see with runPrivate that can enabled a miner, but i done from ethereumj code, with a class and running this. i want config a miner because in the net, i will use pc to miner and in other compile contract, i want use harmony to monitoring the contract, tx and use JSON-RPC to a DAPP that i want build in Android.
@1jose234 ahhh, you are in fast sync mode and not synced yet. Pull latest Harmony, it's fixed and everything should work fine.
@zilm13 thanks, i can connect to the miner fine. watching the contract in Harmony, I have the question, How could I send values and get values from a dapp... could be web3?
@3Mohammed2013 sorry for not answering, if can help you with pleasure
@zilm13 , @1jose234 May I ask you to help me if you do not mind that it, I would like to explain to you what I did it first I run the ethereumj.starter by using those instruction git clone https://github.com/ether-camp/ethereumj.starter ./gradlew run check how your local blockchain being sync: curl -w "\n" -X GET http://localhost:8080/bestBlock and then I run the ethereumJ within the following those instruction git clone https://github.com/ethereum/ethereumj cd ethereumj cp ethereumj-core/src/main/resources/ethereumj.conf ethereumj-core/src/main/resources/user.conf vim ethereumj-core/src/main/resources/user.conf # adjust user.conf to your needs ./gradlew clean shadowJar java -jar ethereumj-core/build/libs/ethereumj-core-*-all.jar
“ this command do not work with me I don know why ./gradlew clean shadowJar”
cd ethereumj ./gradlew run -PmainClass=org.ethereum.samples.PrivateMinerSample
Importing project to IntelliJ IDEA: git clone https://github.com/ethereum/ethereumj cd ethereumj gradlew build
So after that I move to the ethereum-harrmory
I run the harmory as private
gradlew runPrivate
even that I followed those instrucation
https://github.com/ether-camp/ethereum-harmony/wiki/Setting-up-a-private-network#genesis-for-private-network
in the Common node configuration
I was change in only the ethereumj.conf
Running your network
./gradlew bootRun -Dethereumj.conf.file=ABS_PATH_TO/private-configuration.conf -DgenesisFile=ABS_PATH_TO/private-genesis.json
does not work with me
do I missing something if yes please let me know , it my pleasure to help me guys
this command do not work with me I don know why ./gradlew clean shadowJar
We've replaced it with ./gradlew clean fatJar
with help of our contributor recently. You could try it on latest develop version.
Running your network ./gradlew bootRun -Dethereumj.conf.file=ABS_PATH_TO/private-configuration.conf -DgenesisFile=ABS_PATH_TO/private-genesis.json does not work with me
could you show your log output?
@3Mohammed2013
Use runPrivate
or add something like -Ddatabase.name=database-private -Ddatabase.dir=database-private
to your command line.
Did it help?
it work but, the peer not connected or maybe I miss understanding
private.conf
@3Mohammed2013 you are running you own private network you should either start mining or have another peer in network - designated miner
how should I start mining or designated miner AND HOW I have another peer connected with me can you please guide me in that it
Check this:
https://github.com/ether-camp/ethereum-harmony/wiki/Setting-up-a-private-network#minimal-configuration
and use runPrivate
command, it will preoccupy memory enough for miner
Should I change it from Ethereumj.conf and make suitable Or where Warm regards MFarhan
From: Dmitry S. notifications@github.com Sent: Wednesday, May 23, 2018 6:08:12 PM To: ether-camp/ethereum-harmony Cc: 3Mohammed2013; Mention Subject: Re: [ether-camp/ethereum-harmony] solidity contract er (#76)
Check this: https://github.com/ether-camp/ethereum-harmony/wiki/Setting-up-a-private-network#minimal-configuration and use runPrivate command, it will preoccupy memory enough for miner
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ether-camp/ethereum-harmony/issues/76#issuecomment-391382650, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AgzTLwfsFAi8TMxbPgCiCr88YShBG1ILks5t1XtcgaJpZM4TtUdn.
I see you already using ./gradlew runPrivate
you could either change any config, overriding everything needed in user.conf
looks most clean, or pass variables via command line
sir just allowed to me one day let me try that , I would like to try that again https://github.com/ether-camp/ethereum-harmony/wiki/Setting-up-a-private-network#minimal-configuration I will coming bake to you if you do not mind that it
@3Mohammed2013 you are welcome! If anything is not clear from our guide, it's better to enhance it so we could help others too.
@3Mohammed2013 i can't understand your problem, but i can tell you what i done so far.
1.- In ethereumj from code source in Eclipse, using the example of miner, run this miner that send tx each 5 minutes (if for you is not necesary use the source code, could run a private net from Hermony, i tested that and is simple)
2.- From Harmony with private.conf connect to the miner, harmony is running as custom "gradlew runCustom".
3.- Using the example to deploy a contract in ethereumj, i send the contract and can see in harmony that is deployed success.
my next step is, send data and get this data, maybe i will use web3js for do a dapp. all this is only to do a first POC about the world of block chain. in the end, i will share my experience in a tutorial or a similar thing for help to other people.
@zilm13 i was change in the user.conf but does not work "ethereum-harmony, src, main,resources " could explain how to connected the peer to peer between two device what should i need only the ip and the enode or nodeid what i exactly a stuff that i needed to make peer work or what should i modify to be suitable to my environment @1jose234 the problem i d not know how i connected the peer and run the minor
sincerely,
@3Mohammed2013 So you have started 2 peers, one is miner, and you want to connect second peer to it? Miner is creating new blocks normally?
Yes I want to connect second peer how?
Warm regards MFarhan
From: Dmitry S. notifications@github.com Sent: Friday, May 25, 2018 12:43:08 AM To: ether-camp/ethereum-harmony Cc: 3Mohammed2013; Mention Subject: Re: [ether-camp/ethereum-harmony] solidity contract er (#76)
@3Mohammed2013https://github.com/3Mohammed2013 So you have started 2 peers, one is miner, and you want to connect second peer to it? Miner is creating new blocks normally?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ether-camp/ethereum-harmony/issues/76#issuecomment-391873442, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AgzTL0WIaIhLIpEFa9Iz7LwPwxL4Gm_sks5t1ylsgaJpZM4TtUdn.
@3Mohammed2013 when any of your peer is starting you should see line like this:
00:52:07.688 INFO [general] EthereumJ node started: enode://46ff5be4911ebb78d392f3f165f6c8bf867ede8be39b0edc0b152149140269d86145b376e306cde7b3d20b212f4d40c46fd7dd00ff95dd0e08a1379f29a474b2@164.143.120.19:30303
It contains nodeId and host:port. If you remove your db and peer.privateKey
is not defined in your config, it will be regenerated. Until this you could be sure that it will not change with time.
So you have this line, next you need to connect other peer to this one. You could either add it to active peers section of config:
peer.active = [
{
ip = 164.143.120.19
port = 30303
nodeId = 46ff5be4911ebb78d392f3f165f6c8bf867ede8be39b0edc0b152149140269d86145b376e306cde7b3d20b212f4d40c46fd7dd00ff95dd0e08a1379f29a474b2
nodeName = "my poc-9-peer-1"
},
]
or use Harmony terminal/ RPC:
Ethereum
node> admin_addPeer enode://46ff5be4911ebb78d392f3f165f6c8bf867ede8be39b0edc0b152149140269d86145b376e306cde7b3d20b212f4
d40c46fd7dd00ff95dd0e08a1379f29a474b2@164.143.120.19:30303
true
node>
same way you could add it via RPC
Please note that if you are connecting two peers locally, both on localhost and you are behind firewall/router, you may need to change bounded host to localhost
or 127.0.0.1
as you may have difficulties in accessing one peer from another using its external host
done
Dear Demitry, i am able to connected to peer to peer after your explanation really so much thannnkk you but, I just need guidance from you after that how can i develop smart contract
Thank you
@3Mohammed2013 start from Solidity documentation http://solidity.readthedocs.io/en/v0.4.24/ there are several examples there too
Hello @zilm13
I followed the all the instructions, and the peer is working fine with me in the private mode with single miner. You mentioned before that in private mode; it's not important for the Blockchain to be synchronized. But every time i try to publish a contract by following the instructions of this video: https://www.youtube.com/watch?v=leaAMTgjvxg
This error is shown to me:
Although i did modify the privite.conf file in this part:
sync.enabled = true
// it was false before; but i tried it in both true and false and it didn't worked.
So I tried to run the harmony in main and custom mode so the Blockchain can be synchronized, I waited more than hour and half for the full synchronization of the Blockchain:
and yet it didn't synchronized yet:
Could you please guide me for solidity smart contract publishing in harmony?
Because i'm struggling in these to errors:
Contract validation error: Account with address '96f041b96708813b1d789606926c524e78543664' hasn't any code. Please ensure blockchain is fully synced.
* Sync is not finished. Contract block may not exist yet.
Thank you Khalid
You mentioned before that in private mode; it's not important for the Blockchain to be synchronized
Where? I don't understand this
This error is shown to me:
Are you sure you've deployed this contract to this address before? You could see contract storage only for already deployed contract
Plus from your screens on Mainnet it's clearly visible that you are not synchronized completely. You are on block that is 2 years ago. If you are on Regular sync, full synchronization of Mainnet takes several days. On fastsync with history skip which is default for Harmony it takes ~5 hours, but from your screen you are on regular sync, so you've changed something.
If I run private blockchain in Ethereum harmony , do I need to be sync in order to fulfill the requirements or it not requirements for publish the smart contract
Warm regards MFarhan
From: Dmitry S. notifications@github.com Sent: Friday, June 1, 2018 11:35:16 AM To: ether-camp/ethereum-harmony Cc: 3Mohammed2013; Mention Subject: Re: [ether-camp/ethereum-harmony] solidity contract er (#76)
You mentioned before that in private mode; it's not important for the Blockchain to be synchronized
Where? I don't understand this
This error is shown to me:
Are you sure you've deployed this contract to this address before? You could see contract storage only for already deployed contract
Plus from your screens on Mainnet it's clearly visible that you are not synchronized completely. You are on block that is 2 years ago. If you are on Regular sync, full synchronization of Mainnet takes several days. On fastsync with history skip which is default for Harmony it takes ~5 hours, but from your screen you are on regular sync, so you've changed something.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ether-camp/ethereum-harmony/issues/76#issuecomment-393810118, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AgzTL69Qk94ZjqknGzXOLegmTDes0nQgks5t4PzEgaJpZM4TtUdn.
Therefore it show to me the same error that appears to @kaljm3y in the Ethereum Harmony when I want to publish smart contract, although I run the private Blockchain Could you please guide us how figure out solutions of publish smart contract in Ethereum Harmony
Warm regards MFarhan
From: Mohammed ALanzie. cw-@hotmail.com Sent: Friday, June 1, 2018 5:12:24 PM To: ether-camp/ethereum-harmony; ether-camp/ethereum-harmony Cc: Mention Subject: Re: [ether-camp/ethereum-harmony] solidity contract er (#76)
If I run private blockchain in Ethereum harmony , do I need to be sync in order to fulfill the requirements or it not requirements for publish the smart contract
Warm regards MFarhan
From: Dmitry S. notifications@github.com Sent: Friday, June 1, 2018 11:35:16 AM To: ether-camp/ethereum-harmony Cc: 3Mohammed2013; Mention Subject: Re: [ether-camp/ethereum-harmony] solidity contract er (#76)
You mentioned before that in private mode; it's not important for the Blockchain to be synchronized
Where? I don't understand this
This error is shown to me:
Are you sure you've deployed this contract to this address before? You could see contract storage only for already deployed contract
Plus from your screens on Mainnet it's clearly visible that you are not synchronized completely. You are on block that is 2 years ago. If you are on Regular sync, full synchronization of Mainnet takes several days. On fastsync with history skip which is default for Harmony it takes ~5 hours, but from your screen you are on regular sync, so you've changed something.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ether-camp/ethereum-harmony/issues/76#issuecomment-393810118, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AgzTL69Qk94ZjqknGzXOLegmTDes0nQgks5t4PzEgaJpZM4TtUdn.
@3Mohammed2013
If I run private blockchain in Ethereum harmony , do I need to be sync in order to fulfill the requirements or it not requirements for publish the smart contract
You need to be fully synced. If you have only one miner in network and execute something on it you are fully synced too as noone else could produce blocks in this network.
Therefore it show to me the same error that appears
Are you sure, you've sent correct tx with contract deployment to the network and this transaction was included in some block?
@3Mohammed2013 , @kaljm3y hi , how do you do the compilation of the Smart Contract?, because this is important to be sure that the contract exist in the blockchain but MORE important is have a complet SYNC
sorry for my enghlis, i speak spanish.
@1jose234 @Dmitry How I have complete sync or fully sync Yes I have only miner The text i am not sure about it , I get some tx from internet for testing Please could you guide us for fully sync
Warm regards MFarhan
From: 1jose234 notifications@github.com Sent: Friday, June 1, 2018 7:37:16 PM To: ether-camp/ethereum-harmony Cc: 3Mohammed2013; Mention Subject: Re: [ether-camp/ethereum-harmony] solidity contract er (#76)
@3Mohammed2013https://github.com/3Mohammed2013 , @kaljm3yhttps://github.com/kaljm3y hi , how do you do the compilation of the Smart Contract?, because this is important to be sure that the contract exist in the blockchain but MORE important is have a complet SYNC
sorry for my enghlis, i speak spanish.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ether-camp/ethereum-harmony/issues/76#issuecomment-393937595, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AgzTL7QVNDXEHeZiEGetK-dml4ZsLPZ4ks5t4W28gaJpZM4TtUdn.
Contract validation error: Account with address '91923993c4dc3e089bbb1fc9d4a5a765a479b68f' hasn't any code. Please ensure blockchain is fully synced.