Skip to content

Commit

Permalink
Add single network configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
russanto committed May 6, 2019
1 parent 4421070 commit 8120b1d
Show file tree
Hide file tree
Showing 16 changed files with 171 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ test:
monitor:
type:
- process
- docker
process:
- command: node
arguments: local-client.js
multiOutput: avg
docker:
name:
- all
interval: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ethereum/client-go:stable
COPY ./data/ /root/
VOLUME [ "/root/.ethereum/keystore/" ]
RUN geth init /root/genesis.json && geth import /root/bc.dat
ENTRYPOINT [ "geth" ]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"config": {
"chainId": 48122,
"homesteadBlock": 1,
"eip150Block": 2,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 3,
"eip158Block": 3,
"byzantiumBlock": 4,
"constantinopleBlock": 5,
"clique": {
"period": 5,
"epoch": 30000
}
},
"nonce": "0x0",
"timestamp": "0x5ca916c6",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000c0A8e4D217eB85b812aeb1226fAb6F588943C2C20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0xc0A8e4D217eB85b812aeb1226fAb6F588943C2C2",
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"alloc": {
"0xc0A8e4D217eB85b812aeb1226fAb6F588943C2C2": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3"
services:
node:
build: .
image: caliper-ethereum-clique
container_name: ethereum_clique
volumes:
- ./keys:/root/.ethereum/keystore
ports:
- 8545:8545
command: --unlock 0xc0A8e4D217eB85b812aeb1226fAb6F588943C2C2 --password /root/.ethereum/keystore/password --mine --minerthreads 2 --etherbase 0xc0A8e4D217eB85b812aeb1226fAb6F588943C2C2 --rpc --rpcaddr 0.0.0.0 --rpcvhosts=* --rpcapi admin,eth,miner,personal,web3 --nodiscover --gasprice 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"caliper": {
"blockchain": "ethereum",
"command" : {
"start": "docker-compose -f network/ethereum/1node-clique/docker-compose.yml up -d && sleep 3",
"end" : "docker-compose -f network/ethereum/1node-clique/docker-compose.yml down"
}
},
"ethereum": {
"url": "http://localhost:8545",
"contractDeployerAddress": "0xc0A8e4D217eB85b812aeb1226fAb6F588943C2C2",
"contractDeployerAddressPassword": "password",
"fromAddress": "0xc0A8e4D217eB85b812aeb1226fAb6F588943C2C2",
"fromAddressPassword": "password",
"transactionConfirmationBlocks": 2,
"registry": {
"address": "0x91496eafe3C54C48D1Add5c1Fb30655d6b76e56b",
"path": "src/contract/ethereum/registry/registry.json"
},
"contracts": {
"simple": {
"path": "src/contract/ethereum/simple/simple.json"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"address":"c0a8e4d217eb85b812aeb1226fab6f588943c2c2","crypto":{"cipher":"aes-128-ctr","ciphertext":"521588833e66d0e052120c30080e37e847ae7877eb09dc6760eb10382c2e6d4f","cipherparams":{"iv":"cee02dbf21538798041c99f49bef9afa"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"916a08841725aba0bf2a2d39f489f0d5d3f2b5032067e44655b8ff542c492f03"},"mac":"f90667ea4de3e977b1cdd23ed722ddffc3f6888b21ea68cc7d5ef77463022e94"},"id":"7543fa05-dac5-4ae9-856d-e96ddea28c41","version":3}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
password
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ethereum/client-go:stable
COPY ./data/ /root/
VOLUME [ "/root/.ethereum/keystore/" ]
RUN geth init /root/genesis.json && geth import /root/bc.dat && geth makedag 0 /root/.ethash && geth makedag 30000 /root/.ethash
ENTRYPOINT [ "geth" ]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"config": {
"chainId": 21194,
"homesteadBlock": 1,
"eip150Block": 2,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 3,
"eip158Block": 3,
"byzantiumBlock": 4,
"constantinopleBlock": 5,
"ethash": {}
},
"nonce": "0x0",
"timestamp": "0x5cd09c57",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x80000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"c0a8e4d217eb85b812aeb1226fab6f588943c2c2": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3"
services:
node:
build: .
image: caliper-ethereum
container_name: ethereum
volumes:
- ./keys:/root/.ethereum/keystore
ports:
- 8545:8545
command: --unlock 0xc0A8e4D217eB85b812aeb1226fAb6F588943C2C2 --password /root/.ethereum/keystore/password --mine --minerthreads 2 --etherbase 0xc0A8e4D217eB85b812aeb1226fAb6F588943C2C2 --rpc --rpcaddr 0.0.0.0 --rpcvhosts=* --rpcapi admin,eth,miner,personal,web3 --nodiscover --gasprice 1
26 changes: 26 additions & 0 deletions packages/caliper-application/network/ethereum/1node/ethereum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"caliper": {
"blockchain": "ethereum",
"command" : {
"start": "docker-compose -f network/ethereum/1node/docker-compose.yml up -d && sleep 3",
"end" : "docker-compose -f network/ethereum/1node/docker-compose.yml down"
}
},
"ethereum": {
"url": "http://localhost:8545",
"contractDeployerAddress": "0xc0A8e4D217eB85b812aeb1226fAb6F588943C2C2",
"contractDeployerAddressPassword": "password",
"fromAddress": "0xc0A8e4D217eB85b812aeb1226fAb6F588943C2C2",
"fromAddressPassword": "password",
"transactionConfirmationBlocks": 2,
"registry": {
"address": "0xB1B0e1Fd4c456146A808fDF668aCC2FaF16Ee2ab",
"path": "src/contract/ethereum/registry/registry.json"
},
"contracts": {
"simple": {
"path": "src/contract/ethereum/simple/simple.json"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"address":"c0a8e4d217eb85b812aeb1226fab6f588943c2c2","crypto":{"cipher":"aes-128-ctr","ciphertext":"521588833e66d0e052120c30080e37e847ae7877eb09dc6760eb10382c2e6d4f","cipherparams":{"iv":"cee02dbf21538798041c99f49bef9afa"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"916a08841725aba0bf2a2d39f489f0d5d3f2b5032067e44655b8ff542c492f03"},"mac":"f90667ea4de3e977b1cdd23ed722ddffc3f6888b21ea68cc7d5ef77463022e94"},"id":"7543fa05-dac5-4ae9-856d-e96ddea28c41","version":3}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
password
30 changes: 20 additions & 10 deletions packages/caliper-ethereum/lib/ethereum.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Ethereum extends BlockchainInterface {
for (const key of Object.keys(this.ethereumConfig.contracts)) {
let contractData = require(CaliperUtils.resolvePath(this.ethereumConfig.contracts[key].path, this.workspaceRoot)); // TODO remove path property
promises.push(new Promise(function(resolve, reject) {
self.deployContract(self.web3, contractData).then((contractInstance) => {
self.deployContract(contractData).then((contractInstance) => {
self.bindContract(key, contractInstance.address).then((receipt) => {
resolve()
})
Expand Down Expand Up @@ -110,7 +110,7 @@ class Ethereum extends BlockchainInterface {
}

/**
* Submit a transaction to the geth context.
* Submit a transaction to the ethereum context.
* @param {Object} context Context object.
* @param {String} contractID Identity of the contract.
* @param {String} contractVer Version of the contract.
Expand Down Expand Up @@ -139,7 +139,7 @@ class Ethereum extends BlockchainInterface {

/**
* Query the given smart contract according to the specified options.
* @param {object} context The Burrow context returned by {getContext}.
* @param {object} context The Ethereum context returned by {getContext}.
* @param {string} contractID The name of the contract.
* @param {string} contractVer The version of the contract.
* @param {string} key The argument to pass to the smart contract query.
Expand Down Expand Up @@ -175,22 +175,32 @@ class Ethereum extends BlockchainInterface {
// empty
}

lookupContract(contract_id) {
return this.registry.methods.lookup(contract_id).call();
/**
* Fetch the address for the contract with the given label from the registry
* @param {string} contract_id
* @return {string} The contract address
*/
lookupContract(label) {
return this.registry.methods.lookup(label).call();
}

bindContract(contract_id, address) {
return this.registry.methods.bind(contract_id, address).send({from: this.ethereumConfig.contractDeployerAddress});
/**
* Binds the address to the label registering on the registry
* @param {string} label label to bind address to
* @param {string} address deployed contract address
*/
bindContract(label, address) {
return this.registry.methods.bind(label, address).send({from: this.ethereumConfig.contractDeployerAddress});
}

/**
* Deploys a new contract using the given web3 instance
* @param {Object} web3 The Web3 object
* @param {JSON} contractData Contract data with abi and bytecode properties
* @returns {Promise<web3.eth.Contract>} The deployed contract instance
*/
deployContract(web3, contractData) {
var contractDeployerAddress = this.ethereumConfig.contractDeployerAddress
deployContract(contractData) {
let web3 = this.web3
let contractDeployerAddress = this.ethereumConfig.contractDeployerAddress
return new Promise(function(resolve, reject) {
let contract = new web3.eth.Contract(contractData.abi);
let contractDeploy = contract.deploy({
Expand Down

0 comments on commit 8120b1d

Please sign in to comment.