Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
The Energy Web Chain is comprised of different components that provide the functionalities determined by the blockchain’s protocol.
Broadly speaking, protocols are defined rules and standards. Internet protocols, like HTTP protocol for example, define standard procedures for the transfer of data over the internet.
A blockchain network is no different. In a decentralized and self-executing system like a public blockchain, protocols are of significant importance in establishing how the system works, and then ensuring that the system continues to self-execute as designed.
Protocols exist to determine specific aspects of blockchain behavior, such as:
How transactions are validated
Who gets to validate transactions and when
How validators are compensated
How peer nodes interact with each other
The system components below ensure that the Energy Web blockchain adheres to Ethereum's protocols, and the protocols established by OpenEthereum's Proof-of-Authority consensus engine. (OpenEthereum is the Ethereum client that is used by the Energy Web Chain.
System Contracts are smart contracts that implement the Authority Roundtable Proof-of-Authority consensus engine protocols. Read more about Energy Web's system contracts here.
The validator node architecture monitors validator behavior to ensure consistent and secure blockchain operation. Read more about the validator node architecture here.
Energy Web has deployed OpenEthereum's Name Registry contract. This contract is identical to OpenEthereum's original contract, with the exception that it was made Ownable by Energy Web Foundation. Only Energy Web can reserve a name or drain funds from this contract.
There are two reasons for making this contract Ownable:
OpenEthereum's name registry might be needed for other OpenEthereum related system contracts later: e.g. service transaction checker, or auto updater.
We will have the official Ethereum Name Service system set up on the chain, so this contract is only needed for internal purposes and will not be used publicly.
The name registry is a placeholder for now. The contract can be found in our repo: https://github.com/energywebfoundation/ewc-system-contracts/tree/master/contracts/registry
Contract
Address
JSON ABI
SimpleRegistry
0x1204700000000000000000000000000000000006
Function
Description
entries(bytes32)
Returns an entry based on the sha3 hash of the name registered.
reverse(address)
Reverse resolution of an address.
fee()
Returns the fee for reserving a name (not really relevant to public).
getData(bytes32,string)
Returns a string data value from an entry, given its key.
getAddress(bytes32,string)
Returns an address data value from an entry, given its key.
getUint(bytes32,string)
Returns an unsigned integer data value from an entry, given its key.
getOwner(bytes32)
Returns the owner of an entry.
hasReverse(bytes32)
Returns true if entry has a reverse address registered.
getReverse(bytes32)
Returns reverse address of an entry.
canReverse(address)
Returns true if address can have a reverse.
reverse(address)
Returns the reverse value of an address.
reserved(bytes32)
Returns true if the name (its sha3 hash) is already reserved.
In a centralized system, such as a bank or a broker, a designated authority or central operating system would be in charge of adding transactions or information to the system, making sure that each transaction is trustworthy, up to date with the whole system, and does not duplicate previous transactions.
In contrast, public blockchains are decentralized, peer-to-peer systems that have no central authority or oversight like this. Designated actors are responsible for processing transactions, creating new blocks and maintaining the integrity and history of previous blocks.
The system for determining these actors and how they are selected is called a . These mechanisms determine the process of who can confirm transactions and create new blocks on the blockchain and the protocol for how they do so. Because there is no central oversight, consensus needs to be designed in a way that prevents or disincentivizes malicious or uninformed actors from corrupting the integrity of the chain.
There are many consensus algorithms. You may have heard of some widely used ones like or . Each mechanism has its own way of determining who is eligible to process transactions and create new blocks, and how how actors are selected to do so.
The Energy Web Chain uses the Proof-of-Authority (PoA) consensus mechanism.
All consensus mechanisms have disadvantages and advantages and are chosen based on the purpose and use case of the blockchain it will be serving.
Components for running a validator node and monitoring validator behavior
The system architecture of a validator node on the Energy Web Chain is made up of two components:
Together these two components allow validators to run a local node of the chain, validate transactions, seal blocks, and monitor validator behavior and metrics.
A client is software that allows you to run a local node on your machine and interact directly with the blockchain. Every validator must run a full node in order to participate in validation.
Remember that the Energy Web Chain is derived from the Ethereum blockchain. Because of this we use an Ethereum client to connect with the chain called . Anyone can create a client, as long as it implements the protocols laid out in , and there are a number of Ethereum clients to choose from.
Energy Web uses the OpenEthereum client because it supports the , which is a consensus algorithm specifically for Proof-ofAuthority blockchains. OpenEthereum allows validators to connect to the chain, collect transactions and seal blocks according the AuRa consensus algorithm.
To read more about OpenEthereum, you can
To read more about Ethereum clients, see the
The monitoring system collects comprehensive, real-time data and metrics on validator performance and provides a user interface for viewing the data. It is important to gather as much data about the validator nodes as possible in order to ensure a secure and performant blockchain. To do so, we rely on well established industry solutions to transfer these metrics off the validator node to protect the sensitive nature of the data.
The use of the telemetry monitoring system is opt-in. Validators can disable it if they have their own monitoring system in place that allows for real time tracking of all relevant metrics.
There are four components involved in the data collection process:
The OpenEthereum client collects data on the validator node. Collected data includes:
CPU usage
Memory usage
Disk usage
Number of connected peers
List of visible P2P peers
Current block
Network latency to 3 different and major locations (e.g. cloudflare, google, amazon)
Network throughput
Network error rate
Number of SSH keys
Service status for SSH, docker and the parity container
SHA256 hashes of key system components/binaries
Current chain specification file (or hash)
Telegraf collects relevant metrics from the host machine and the custom-built OpenEthereum metrics collector. The metrics collector allows Telegraf to receive the metrics from the OpenEthereum client
The collected metrics are stored in an InfluxDB database and can be visualized using Grafana
client - monitors validator node behavior
: open-source server agent that collects data from the OpenEthereum client
- open source database that stores the data collected from Telegraf
- data visualization tool that queries the InfluxDB for data and provides graphical interface for data visualization
All components are run in separate docker containers managed by docker compose. For additional information on docker visit: and .
The Holding Contract holds tokens for initial investors. These tokens are "pre-mined", and do not enter the pool through block validation. Tokens are held for affiliates until a specific point of time that is specified in the contract, at which point they can be released to the specified address. The constructor of the holding contract and its initial balance is part of the chainspec file. This allows the investors' tokens to be locked at the first block.
The mapping between the account address and the token amount is hard coded into the contract and cannot be changed after deployment. After a block that has a later timestamp than the holding timestamp of an address is created, the tokens for that address can be transferred to the address by calling the realeaseFunds method. This method can be called by anyone, not only by the address that holds that balance.
If you're an investor and want to see your balance, you can use the Balance Viewer interface: http://balance.energyweb.org/.
You will need MetaMask pointed to a local or a remote node
To learn how to connect via remote RPC, go here
To learn how to run a local node go here
Enter your address in the lookup field to see your holding balance
If the release period has ended, press the "Withdraw" button to release the funds to the address it belongs to. Make sure you trigger the withdraw function with an account that has some ethers to cover transaction costs
The mapping between addresses and tokens/release timestamp is kept in the storage of this contract. This mapping data structure was filled at the deploy time of the contract and cannot be changed.
Contract
Address
JSON ABI
Holding
0x1204700000000000000000000000000000000004
Function Name
Description
releaseFunds(address)
Releases funds for a holding address if it is present in the contract and the holding period is over
holders(address)
Returns the holding data for an address, the available amount and the holding-period-end blocktimestamp
TARGET_AMOUNT()
Returns the total amount initially held by the contract
System contracts are the Energy Web Chain's smart contracts that implement OpenEthereum's protocols for Aura Proof-of-Authority consensus mechanism.
Energy Web's smart contracts are open-sourced, and you can see them on github here.
Validator Set Contracts - manage validator permissioning and behavior
Reward Contract - manages validator block rewards
Holding Contract - manages the initial disbursement of pre-mined energy web tokens
System contracts are the Energy Web Chain’s smart contracts that implement OpenEthereum’s permissioning protocols. These protocols determine what actions can be taken on the network.
In order to adhere to the expected protocol, the Energy Web Chain’s system contracts must implement the interfaces that are expected by the AuRa consensus engine, so that it can conform to the client’s protocols.
Let’s take OpenEthereum's Validator-Set contract as an example.
The OpenEthereum documentation specifies that “A simple validator contract has to have the following interface”
Now let’s look at Energy Web’s ValidatorSetRelay smart contract.
You can see that this smart contract implements all of the functions of the Validator-Set protocol interface that was specified above.
Validator Set Contracts - manage validator behavior
Reward Contract - manages validator block rewards
Holding Contract - manages the initial disbursement of pre-mined energy web tokens to a group of initial supporting affiliates
Validator Set contracts provide information on current validators and private functionality to add and remove validators.
For upgradeability purposes, the contracts are divided into 2 parts. See below Fig. 1.
This contract implements the required reporting ValidatorSet interface expected by the engine and it is the contract defined in the chainspec seen by the engine. It relays most of the function calls to the RelayedSet contract, which holds the actual logic. The logic contract can be replaced (upgraded), so it is possible to change the behavior of validator management without conducting a hard fork.
This contract implements the logic and manages the validator list. The owner of the validator set interacts with this contract for managing the validators. This contract maintains two validator sets:
The current validator set (the validators who are actively sealing)
The migration validator set, which is the new set we migrate to in case of a change (validator addition or removal).
Validators and potential validators have four states in these contracts:
Active validator: Validator is in the active validator set, sealing new blocks
Not a validator: The address nothing has to do with validation.
Pending To Be Added Validator: Validator is already added by the owner and their acceptance is pending, but not active yet until it is finalized. This implies that the validator cannot report, be reported, or produce blocks yet.
Pending To Be Removed Validator: Validator is pending to be removed (removed by the owner), but it is not finalized, and so is still active as a validator. This implies that as long as the removal is not finalized, the validator is actively producing blocks, can report and can be reported on.
The RelayedSet contract logs malicious or benign reports by emitting corresponding log events that can be seen by anyone. Reporting can only be on and about active sealing validators.
The events contain the reporter- and reported address, and the block number which the validator was reported on.
The Block Reward contract manages block reward payouts to validators. Block rewards are issued as native Energy Web tokens that are minted by the engine.
Two entities are rewarded by each created block:
The block author (validator)
Block authors are rewarded each time they seal a block. The amount issued to block authors decreases over time, as depicted by the Discreet S Curve.
A portion of block rewards goes to the Community Fund. Unlike the amount awarded to block authors, the amount that goes to the Community Fund remains constant over time.
The amount is chosen to add up to roughly 37.9 million tokens over a 10 year period. The community fund can change its own address and set a payout address too.
With 5 second step size: Payout-per-block = 600900558100000000 wei
Visual representation of the community reward distribution is depicted below in Fig. 3.
Calculator:
Name
Address
JSON ABI
ValidatorSetRelayed
0x1204700000000000000000000000000000000001
Function
Description
finalized()
Returns true if there are ongoing changes to the active set, false otherwise. If true, implies that current validators list equals migration validators list.
addressStatus(address)
Returns the state of an address, two integers: an integer representing the validator state, and an index value. The index is the position of the validator address in the currentValidators array. It is only relevant if the address is an active validator, should be ignored otherwise.
The validator state mappings are:
NonValidator: 0
Finalized: 1
PendingToBeAdded: 2
PendingToBeRemoved: 3
getValidators()
Returns currently active block producing validators
getMigrationValidators()
Returns the migration validator set. If there are no changes, it returns the same list as getValidators().
getUnion()
Returns the union of current and migration sets. Useful for tracking the statuses of all affected validators in case of an ongoing change
getValidatorsNum()
Returns the number of currently active validators
isPendingToBeAdded(address)
Returns true if address is pending to be added to the active list.
isPendingToBeRemoved(address)
Returns true if address is pending to be removed from the active list.
isPending(address)
Returns true if address is pending to be added or removed.
isActiveValidator(address)
Returns true if address is an active validator, meaning it partakes in producing new blocks. Note that a validator who is pending to be removed is still active.
isFinalizedValidator(address)
Returns true if address is a finalized validator, meaning it is active and NOT pending to be removed either.
Function Name
Description
getSystemAddress()
Returns the system address
getValidators()
Same as RelayedSet getValidators()
relayedSet()
Returns the address of the Relayed contract
Function Name | Description |
mintedTotally() | Returns the token amount that was minted totally in wei |
mintedForCommunity() | Return the token amount that was totally minted for the community fund in wei |
mintedForCommunityForAccount(address) | Returns the total token amount that was minted for a certain address for the community so far in wei |
mintedForAccount(address) | Return how much was minted for an account so far in wei |
mintedInBlock(uint256) | Returns how much was minted in certain block in wei |
mintedForAccountInBlock(address, uint256) | Returns how much was minted for a certain account in a certain block in wei |
communityFundAmount() | Returns the constant payout for the community per block in wei |
communityFund() | Returns community fund address |
payoutAddresses(address) | Returns an address' payout address |
setPayoutAddress(address) | Sets payout address for sender |
resetPayoutAddress() | Resets payout address for sender |
getBlockReward(uint256) | Returns blockreward amount for a certain block number |
checkRewardPeriodEnded() | Returns true if blockreward period has ended (based on blocknumber), false otherwise. The blockreward period right now ends after 10 years. After that no blockrewards or community fund payouts are minted. |
Name | Address | JSON ABI |
RewardContract | 0x1204700000000000000000000000000000000002 |