Dynamic validators for ethereum parity

Follow

The following instructions add the OwnedSet contract from Parity https://github.com/parity-contracts/kovan-validator-set to the chain genesis. 

Important Note! The following will delete previous chain data.

Uploading new genesis json

WAIT until your node is synced. You can check the block height in Dashboard → Overview in app.blockdaemon.

For this you will need the following:

  • ${CONTRACT_OWNER} A public and private key pair that you can use as the validator set contract owner, aka admin.
  • ${NODE_JSON_RPC_ENDPOINT} You can get this from Dashboard → Connect
  • ${INITIAL_VALIDATOR} This can be gotten using the following JSON RPC call. (Please remove the 0x from the start for our needs here)

curl --data '{"method":"parity_accountsInfo","params":[],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST ${NODE_JSON_RPC_ENDPOINT}
Use the following genesis json, replacing:
  • ${CONTRACT_OWNER_without_0x} with the address you created above, remember to remove the 0x prefix
  • ${SEALER_ACCOUNT_without_0x} with the address you got from the curl request above, also remove the 0x prefix
{
"accounts": {
"0x0000000000000000000000000000000000000001": {
"balance": "1",
"builtin": {
"name": "ecrecover",
"pricing": {
"linear": {
"base": 3000,
"word": 0
}
}
}
},
"0x0000000000000000000000000000000000000002": {
"balance": "1",
"builtin": {
"name": "sha256",
"pricing": {
"linear": {
"base": 60,
"word": 12
}
}
}
},
"0x0000000000000000000000000000000000000003": {
"balance": "1",
"builtin": {
"name": "ripemd160",
"pricing": {
"linear": {
"base": 600,
"word": 120
}
}
}
},
"0x0000000000000000000000000000000000000004": {
"balance": "1",
"builtin": {
"name": "identity",
"pricing": {
"linear": {
"base": 15,
"word": 3
}
}
}
},
"0x0000000000000000000000000000000000000105": {
"code":"0x6080604052600436106100c5576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630c857805146100ca57806311ae9ed2146100f557806313af40351461016157806340a141ff146101a45780634d238c8e146101e7578063752862111461022a5780638c90ac07146102415780638da5cb5b1461026e578063b3f05b97146102c5578063b7ab4db5146102f4578063c476dd4014610360578063d3e848f1146103c5578063d69f13bb1461041c575b600080fd5b3480156100d657600080fd5b506100df610469565b6040518082815260200191505060405180910390f35b34801561010157600080fd5b5061010a61046f565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561014d578082015181840152602081019050610132565b505050509050019250505060405180910390f35b34801561016d57600080fd5b506101a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506104fd565b005b3480156101b057600080fd5b506101e5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610616565b005b3480156101f357600080fd5b50610228600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109bf565b005b34801561023657600080fd5b5061023f610b90565b005b34801561024d57600080fd5b5061026c60048036038101908080359060200190929190505050610bf6565b005b34801561027a57600080fd5b50610283610c5b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102d157600080fd5b506102da610c80565b604051808215151515815260200191505060405180910390f35b34801561030057600080fd5b50610309610c93565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561034c578082015181840152602081019050610331565b505050509050019250505060405180910390f35b34801561036c57600080fd5b506103c3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001919091929391929390505050610d21565b005b3480156103d157600080fd5b506103da610d65565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561042857600080fd5b50610467600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d8b565b005b60015481565b606060038054806020026020016040519081016040528092919081815260200182805480156104f357602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116104a9575b5050505050905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561055857600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b236460405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561067357600080fd5b81600080600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900460ff169150600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154905081801561071f575060028054905081105b801561078f57508273ffffffffffffffffffffffffffffffffffffffff1660028281548110151561074c57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b151561079a57600080fd5b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154935060036001600380549050038154811015156107f657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660038581548110151561083057fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550836004600060038781548110151561088c57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550600360016003805490500381548110151561090f57fe5b9060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560038054809190600190036109519190611537565b50600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600080820160006101000a81549060ff0219169055600182016000905550506109b8610d9a565b5050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610a1a57600080fd5b80600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900460ff16151515610a7757600080fd5b6001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160006101000a81548160ff021916908315150217905550600380549050600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001018190555060038290806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610b8c610d9a565b5050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610bec57600080fd5b610bf4610dd9565b565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c5157600080fd5b8060018190555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060149054906101000a900460ff1681565b60606002805480602002602001604051908101604052809291908181526020018280548015610d1757602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610ccd575b5050505050905090565b610d5f33858585858080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050610ed1565b50505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610d963383836111a9565b5050565b600060149054906101000a900460ff161515610db557600080fd5b60008060146101000a81548160ff021916908315150217905550610dd7611480565b565b600060149054906101000a900460ff16151515610df557600080fd5b60036002908054610e07929190611563565b506001600060146101000a81548160ff0219169083151502179055507f8564cd629b15f47dc310d45bcbfc9bcf5420b0d51bf0659a16c67f91d2763253600260405180806020018281038252838181548152602001915080548015610ec157602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610e77575b50509250505060405180910390a1565b83600080600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900460ff169150600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101549050818015610f7d575060028054905081105b8015610fed57508273ffffffffffffffffffffffffffffffffffffffff16600282815481101515610faa57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b1515610ff857600080fd5b85600080600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900460ff169150600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015490508180156110a4575060028054905081105b801561111457508273ffffffffffffffffffffffffffffffffffffffff166002828154811015156110d157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b151561111f57600080fd5b876001548101431115801561113357504381105b151561113e57600080fd5b600115158a73ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff167f32c78b6140c46745a46e88cd883707d70dbd2f06d13dd76fe5f499c01290da4f60405160405180910390a45050505050505050505050565b82600080600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900460ff169150600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101549050818015611255575060028054905081105b80156112c557508273ffffffffffffffffffffffffffffffffffffffff1660028281548110151561128257fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b15156112d057600080fd5b84600080600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900460ff169150600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154905081801561137c575060028054905081105b80156113ec57508273ffffffffffffffffffffffffffffffffffffffff166002828154811015156113a957fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b15156113f757600080fd5b866001548101431115801561140b57504381105b151561141657600080fd5b600015158973ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff167f32c78b6140c46745a46e88cd883707d70dbd2f06d13dd76fe5f499c01290da4f60405160405180910390a450505050505050505050565b6001430340600019167f55252fa6eee4741b4e24a74a70e9c11fd2c2281df8d6ea13126ff845f7825c8960036040518080602001828103825283818154815260200191508054801561152757602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116114dd575b50509250505060405180910390a2565b81548183558181111561155e5781836000526020600020918201910161155d91906115b5565b5b505050565b8280548282559060005260206000209081019282156115a45760005260206000209182015b828111156115a3578254825591600101919060010190611588565b5b5090506115b191906115da565b5090565b6115d791905b808211156115d35760008160009055506001016115bb565b5090565b90565b61161a91905b8082111561161657600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016115e0565b5090565b905600a165627a7a72305820924c479a47c18db6f7583f25341574a2cacfd582f441a4ff018f3ce280831a7e0029",
"storage": {
"0": "0x000000000000000000000000${CONTRACT_OWNER_without_0x}",
"1": "0x0000000000000000000000000000000000000000000000000000000000000014",
"2": "0x0000000000000000000000000000000000000000000000000000000000000001",
"3": "0x0000000000000000000000000000000000000000000000000000000000000001",
"4": "0x0000000000000000000000000000000000000000000000000000000000000000",
"5": "0x000000000000000000000000fffffffffffffffffffffffffffffffffffffffe",
"0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": "0x000000000000000000000000${INITIAL_VALIDATOR_without_0x}",
"0x9bee794c694cbdc60e862fcee0abf05f28dee9ff833fba6d799b8c567619e8b1": "0x0000000000000000000000000000000000000000000000000000000000000001",
"0xc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b": "0x000000000000000000000000${INITIAL_VALIDATOR_without_0x}"
}
},
"0x401ccDde01bced0D0D2Fb029b9d6E3B9Ef0823e2": {
"balance": "100000000000000000000"
}
},
"engine": {
"authorityRound": {
"params": {
"stepDuration": "5",
"validators": {
"contract": "0x0000000000000000000000000000000000000105"
}
}
}
},
"genesis": {
"difficulty": "0x20000",
"gasLimit": "0x7A1200",
"seal": {
"authorityRound": {
"signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"step": "0x0"
}
}
},
"name": "DemoPoA",
"params": {
"eip140Transition": 0,
"eip155Transition": 0,
"eip211Transition": 0,
"eip214Transition": 0,
"eip658Transition": 0,
"gasLimitBoundDivisor": "0x400",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x7A1200",
"networkID": "0x2323",
"validateChainIdTransition": 0
}
}

Go to your Network Dashboard -> Settings, and paste in your edited genesis to the json editor. Click Save Configuration, then Save and Relaunch. Reminder: this will erase all previous chain data.

mceclip0.png

Your new blockchain will take a few minutes to sync. Check on the Blockdaemon app dashboard overview page for increasing block height.

Adding a validator to your set with truffle

In the Blockdaemon App:

Add a new node to your network by select "New Node"- upper right on the Overview pane.

Make note of the INITIAL_VALIDATOR for this new node
You can get this by calling the parity_accountsInfo JSON RPC method:

curl --data '{"method":"parity_accountsInfo","params":[],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST ${NODE_JSON_RPC_ENDPOINT}

Watch the block height of the new node and wait for it to sync before continuing (you can get block height in the Blockdaemon app overview pane.)

Outside the Blockdaemon App:

Install truffle

Clone the validator set repository: https://github.com/parity-contracts/kovan-validator-set

Edit truffle-config.js from within the kovan-validator-set repository and add your POA network

"use strict"; 
const HDWalletProvider = require("truffle-hdwallet-provider");

module.exports = {
compilers: {
solc: {
version: "0.4.22"
}
},
networks: {
myNode: {
provider: function(){
return new HDWalletProvider(${PRIVATE_KEY}, ${CONNECT_RPC_ENDPOINT});
},
gasPrice: 0,
port: 8545,
network_id: "*",
},
}
}

Compile the contracts, run:

truffle compile

then, run:

truffle console --network myNode 
> contract = await OwnedSet.at('0x0000000000000000000000000000000000000105')
> contract.addValidator(${INITIAL_VALIDATOR})

Done!

 

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.