Customizing with EIF and event configuration
This topic provides a detailed explanation of the EIF configuration in chromia.yml
, which defines chain-specific
parameters for tracking events and contracts. Before diving into the configurations below, we strongly recommend
reviewing the
EVM Event Receiver Configuration
section to become more familiar with the topic.
Chain configuration
The chains
section specifies blockchain-related parameters, including network IDs, contract addresses, and event
tracking.
Binance Smart Chain (BSC) Testnet configuration
blockchains:
<event_receiver_name>:
module: <module_name>
config:
eif:
chains:
bsc:
network_id: 97
contracts:
- "0x753218363422002DF74F3D0D8d67f6CB38bE32D0" # Testnet BSC TwoWeeksNotice contract (staking)
- "0x8A2279d4A90B6fe1C4B30fa660cC9f926797bAA2" # Testnet BSC CHR token contract (tCHR)
skip_to_height: 26282055
events: !include ./config/events.yaml
network_id
: Identifies the Binance Smart Chain (BSC) Testnet (ID: 97).contracts
:0x753218363422002DF74F3D0D8d67f6CB38bE32D0
: Represents theTwoWeeksNotice
staking contract on the BSC Testnet.0x8A2279d4A90B6fe1C4B30fa660cC9f926797bAA2
: Represents the Testnet CHR token (tCHR
).
skip_to_height
: Specifies the block height from which to start tracking events.events
: References an external configuration file (events.yaml
) that defines event tracking rules.
Events configuration for Chromia EVM governance dapp
This section provides an overview of the EVM events configured in the events.yaml
file. These events are monitored and
processed within the Chromia EVM governance dapp.
Events overview
The events.yaml
file defines EVM events that are crucial for tracking governance-related activities. Each event
includes attributes such as indexed parameters, types, and event names. The current configuration supports the following
events:
Transfer
event
The Transfer
event is a standard event in EVM-based blockchains, commonly used to track token transfers. It captures
details about token movements from one address to another.
Event definition
Transfer:
parameters:
- name: from
type: address
indexed: true
- name: to
type: address
indexed: true
- name: value
type: uint256
Parameters
- from (
address
, indexed): The sender's address. - to (
address
, indexed): The recipient's address. - value (
uint256
): The amount transferred.
Processing in governance dapp
- This event is monitored to track token transfers relevant to governance transactions.
- It helps identify governance token movements, ensuring correct allocation and participation tracking.
StakeUpdate
event
The StakeUpdate
event is used to track changes in staking balances, which are essential for governance participation
and voting power.
Event definition
StakeUpdate:
parameters:
- name: from
type: address
indexed: true
- name: balance
type: uint64
Parameters
- from (
address
, indexed): The address whose stake is updated. - balance (
uint64
): The new stake balance.
Processing in governance dapp
- This event is monitored to update governance staking records.
- Changes in stake balance influence voting power and governance participation.
Integration with Chromia EVM governance dapp
- The dapp listens for these events using an event listener integrated with the EVM-compatible smart contract.
- When an event is emitted, the dapp processes the data and updates governance-related records accordingly.
- The
Transfer
event helps track token ownership, whileStakeUpdate
ensures accurate staking records for voting mechanisms.
Configuration elements
This section outlines the configuration elements from the YAML-like structure provided in the repository:
EIF test configuration (&eif_test):
chains
:- bsc: Configuration for the Binance Smart Chain (BSC):
network_id
: BSC Testnet network ID.
- bsc: Configuration for the Binance Smart Chain (BSC):
contracts
: Addresses of two Testnet contracts for staking and CHR tokens.skip_to_height
: Block height to start processing from.events
: External event configuration from./config/events.yaml
.
Common arguments (&common_args):
lib.ft4.core.accounts
: Configuration for account rate limits.lib.ft4.core.admin
: Admin public key.- lib.governance:
admin_pubkey
,admin_evm_wallet
economy_chain_bridge
required_total_evm_chr_staked_balance_for_registration
,required_total_evm_chr_balance_for_registration
- lib.governance.citizens: Configurations related to citizen cooldowns, proposal rejections, and vetoes:
- Settings such as
citizen_cooldown_days_on_draft_proposal
andcitizen_cooldown_days_on_proposal_rejection
are defined with specific cooldown periods.
- Settings such as
- lib.governance.proposals: Configuration for proposals:
proposal_configs
:option_item_limit
: 10max_duration
: 2592000000000min_duration
: 3600000title_min_length
: 3title_max_length
: 100category_min_length
: 3category_max_length
: 30option_min_length
: 3option_max_length
: 30description_max_length
: 10000
- lib.governance.extensions.eif: Sync transfers within the dapp:
sync_transfers_inside_dapp
: true (This is true by default; there's no need to define it here. However, if set to false, stake and balance handling will be disabled.)
- lib.governance.votes: Configuration for veto periods:
veto_config
:veto_period
: 43200000 (Set to 72 hours in milliseconds)
- lib.governance.auth: Optional configuration for authorization public key for governance, if using a centralized auth server.
Compile version:
rellVersion
: Compilation version (0.14.9).
Activate EIF extension
To activate the EIF extension, import the eif extension into your dapp's module, similar to how you would import ft4 library modules:
import lib.governance.extensions.eif;
EIF libraries overview
The libraries used in the governance project form part of the Ethereum Interoperability Framework (EIF) and serve distinct purposes for enabling cross-chain communication between EVM and Postchain nodes.
For detailed information about EIF libraries, refer to the EIF documentation.
Libraries
eif
- Registry: GitLab Repository
- Path:
postchain-eif-rell/rell/src/eif
- Version:
0.9.0
- Resource ID (RID):
x"D9FAA2AA88DEE0D1EAAFDFE8E28C1BAD89284CE4B6E75C1DBA9272DD8C3D944E"
- Insecure:
false
- Description: The core EIF library that manages the main framework for interoperability.
eif_event_receiver
- Registry: GitLab Repository
- Path:
postchain-eif-rell/rell/src/eif_event_receiver
- Version:
0.9.0
- Resource ID (RID):
x"BDEB142851437327590715FF0912258D5435D294A59857B545BF69D27A0ADBB0"
- Insecure:
false
- Description: A sub-library for receiving and processing events emitted by EVM nodes or other components.
eif_event_connector
- Registry: GitLab Repository
- Path:
postchain-eif-rell/rell/src/eif_event_connector
- Version:
0.9.0
- Resource ID (RID):
x"4A669C5F98AEE970FECD5B77116E737196C7D3C7C6217DFD7EAC2F9317FC9461"
- Insecure:
false
- Description: Handles the integration and connection of event data into the EIF workflow, enabling seamless data transfer between systems.
These libraries work together to form the backbone of the EIF framework:
- The
eif
library manages the core interoperability features. - The
eif_event_receiver
library ensures efficient event listening and processing. - The
eif_event_connector
library integrates event data into the framework.
Dynamic configuration operations in EIF
We introduce three dynamic configuration operations that enhance adaptability by allowing real-time updates to event and contract tracking capabilities:
Operations
add_new_eif_events
- Purpose: Enables administrators to dynamically add new events to be tracked by the framework.
- Input: A list of event configurations (
eif_dynamic_config.event_config
). - Benefit: Provides flexibility for monitoring evolving blockchain activity.
add_new_eif_contracts
- Purpose: Allows administrators to register new contracts within EIF.
- Input: A list of contract configurations (
eif_dynamic_config.contract_config
). - Benefit: Facilitates seamless integration of additional contract systems.
add_new_evm_erc20_and_eif_contract
- Purpose: This function simplifies the process of adding new ERC20 tokens and their corresponding contracts to the EIF.
- Input parameters:
- Network ID
- Token Address
- Token Name
- Token Symbol
- Decimals
- Functionality: It automatically registers the token on the specified EVM chain and links it as a contract in the EIF.
Key advantages
These operations significantly enhance the modularity of the EIF by:
- Allowing dynamic onboarding of tokens, contracts, and event tracking.
- Minimizing the need for manual intervention.
- Improving scalability in multi-chain environments.
Additionally, you can update the configuration in the chromia.yml
file and redeploy the dapp to add new events or
contracts.