Initia 백서

Initia

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 38쪽 중 36쪽

"Checking Validator Active Status"> Finally, to check whether your validator is active, you can run the following command: ```sh theme={null} initiad query tendermint-validator-set | grep "$(initiad tendermint show-validator)" ``` If the command returns a result, your validator is active and is proposing and signing blocks. <Note> Only the top 100 validators in voting power are included in the active validator set. This means that even if your `CreateValidator` transaction passes, your validator might not be active until it has sufficient token delegations. </Note> </Step> <Step title="Running the Connect Oracle Sidecar"> Initia validators are also required to run the Connect Oracle Sidecar. For more information on how to run the sidecar, please refer to the [Skip Connect documentation](https://docs.skip.build/connect/validators/quickstart). </Step> </Steps> ## Secure Your Validator Keys Protecting your keys and having a contingency backup plan will help mitigate catastrophic hardware or software failures of the node. It is a good practice to test your backup plan on a testnet node in case of node failure. Also, always back up your validator node's mnemonic and `priv_validator_key.json` somewhere safe and secure in case you ever need to recover your validator node on a new machine. # Running L1 Nodes with Initiad Source: https://docs.initia.xyz/nodes-and-rollups/running-nodes/running-l1-nodes/l1-nodes-initiad ## Overview This guide provides step-by-step instructions for setting up and running an Initia L1 node. It covers everything from system requirements to connecting to the Initia network. ## System Requirements Before proceeding, ensure your system meets the following requirements: | Tier | CPU | Memory | Storage | Network | | ----------- | ------- | -------- | ------------------------------------------------ | ------------------ | | Minimum | 4 cores | 8GB RAM | 2 TB NVMe/SSD with write throughput > 1000 MiBps | 100 Mbps bandwidth | | Recommended | 6 cores | 16GB RAM | 2 TB NVMe/SSD with write throughput > 1000 MiBps | 100 Mbps bandwidth | | High | 8 cores | 32GB RAM | 2 TB NVMe/SSD with write throughput > 1000 MiBps | 100 Mbps bandwidth | <Note> We strongly recommend running Initia nodes on a Linux-based operating system. While it may be possible to run on other operating systems, we have not tested them and cannot guarantee the same environment settings and running conditions. </Note> ## Installation There are two ways to install the `initiad` CLI: ### Option 1: Building from Source <Steps> <Step title="Install Prerequisites"> Install the required packages: ```bash theme={null} sudo apt install -y build-essential ``` Also, install the latest version of Go: ```bash theme={null} sudo apt install -y golang ``` Verify the installed versions: ```bash theme={null} make --version # Must be 3.8 or later go version # Must be 1.22 or later ``` </Step> <Step title="Build the Daemon"> Clone and build the Initia node: ```bash theme={null} git clone git@github.com:initia-labs/initia.git cd initia git checkout $TAG # Replace with desired version make install ``` Verify the installation: ```bash theme={null} initiad version ``` <Warning> If `initiad` is not found, check your `$PATH` environment variable to ensure it includes `$GOBIN` or `$GOPATH/bin`. </Warning> </Step> </Steps> ### Option 2: Using Pre-Built Binaries Download pre-built `initiad` binaries from the [releases page](https://github.com/initia-labs/initia/releases). Select the appropriate version for your operating system. ## System Configuration ### File Descriptor Limits Initia requires a higher number of file descriptors than the default Linux limit. Adjust the system limits by adding the following to `/etc/security/limits.conf`: ```bash theme={null} * soft nofile 65535 * hard nofile 65535 ``` ## Node Setup ### Initialization Initialize your node with a moniker (a human-readable name): ```bash theme={null} initiad init <moniker> ``` Note that: * Moniker must contain only ASCII characters * Maximum length is 70 characters * The default home directory is `${HOME}/.initia` * To use a different directory, add `--home <YOUR_INITIA_HOME>` to commands <Warning> Your private key is generated during initialization and stored in `${HOME} /.initia/config/priv_validator_key.json`. **IMPORTANT**: Always back up your private key, especially for validator nodes. Loss of the private key may result in permanent node inaccessibility. </Warning> ### Network Configuration #### Endpoints An Initia node provides multiple endpoints that you can enable or disable. | Endpoint | Description | Configuration File | | ------------- | ----------------------- | ------------------------------ | | REST | RESTful HTTP API | `~/.initia/config/app.toml` | | gRPC/gRPC-WEB | gRPC API | `~/.initia/config/app.toml` | | RPC | Tendermint/CometBFT API | `~/.initia/config/config.toml` | | P2P | Gossip P2P Network | `~/.initia/config/config.toml` | <Info> Validator nodes are not recommended to expose these endpoints publicly. </Info> #### Configuration Examples 1. **API Configuration** (`~/.initia/config/app.toml`): ```toml theme={null} [api] enable = true swagger = true address = "tcp://0.0.0.0:1317" [grpc] enable = true address = "0.0.0.0:9090" [grpc-web] enable = true address = "0.0.0.0:9091" ``` 2. **RPC and P2P Configuration** (`~/.initia/config/config.toml`): ```toml theme={null} [rpc] laddr = "tcp://0.0.0.0:26657" [p2p] laddr = "tcp://0.0.0.0:26656" ``` ### External Address Configuration To allow external nodes to connect to your node, configure the external address in `config.toml`: ```toml theme={null} [p2p] laddr = "tcp://0.0.0.0:26656" external_address = "YOUR_PUBLIC_IP:26656" ``` You can automatically set your public IP using: ```bash theme={null} sed -i -e 's/external_address = \"\"/external_address = \"'$(curl httpbin.org/ip | jq -r .origin)':26656\"/g' ~/.initia/config/config.toml ``` ## Connecting to Initia Network To fully connect to the network, you first need to download the genesis file, configure your peers, and sync the node. <Note> You can find information on the genesis file, peers, and state sync for the network you want to join on the [networks page](/resources/developer/initia-l1). </Note> ### Genesis File To start syncing the node, you first need to download the genesis file. ```bash theme={null} wget $GENESIS_FILE_URL -O $HOME/.initia/config/genesis.json ``` ### Network Configuration Once the genesis file is downloaded, you can configure the persistent peers in `~/.initia/config/config.toml`: ```bash theme={null} persistent_peers = "peer1@ip1:port1,peer2@ip2:port2" ``` Replace `peer1@ip1:port1,peer2@ip2:port2` with the list of peers for the network you want to join. ### State Sync & Snapshots To sync the node, you can use the [state sync](https://github.com/tendermint/tendermint/blob/v0.34.x/spec/p2p/messages/state-sync.md) feature. ## Running as a Service (Optional) To run Initia as a system service, create an `initiad.service` file in `/etc/systemd/system`: ```ini theme={null} [Unit] Description=initiad [Service] Type=simple User=ubuntu ExecStart=/usr/bin/initiad start Restart=on-abort StandardOutput=syslog StandardError=syslog SyslogIdentifier=initiad LimitNOFILE=65535 [Install] WantedBy=multi-user.target ``` Once the service file is created, you can enable and start the service: ```bash theme={null} systemctl enable initiad systemctl start initiad ``` To see the logs, you can use the following commands: ```bash theme={null} journalctl -t initiad # View current logs journalctl -t initiad -f # Follow logs in real-time journalctl -t initiad -n <number> # View last N lines ``` ## Cosmovisor (Optional) If you want automatic binary upgrades, set up Cosmovisor after completing all steps above. In the Cosmovisor setup, the `<path-to-executable>` refers to your `initiad` binary path. Follow the [Cosmovisor guide](/nodes-and-rollups/running-nodes/manual-setup/cosmovisor). # Running L1 Nodes with Weave Source: https://docs.initia.xyz/nodes-and-rollups/running-nodes/running-l1-nodes/l1-nodes-weave ## System Requirements Before proceeding, ensure your system meets the following requirements: | Tier | CPU | Memory | Storage | Network | | ----------- | ------- | -------- | ------------------------------------------------ | ------------------ | | Minimum | 4 cores | 8GB RAM | 2 TB NVMe/SSD with write throughput > 1000 MiBps | 100 Mbps bandwidth | | Recommended | 6 cores | 16GB RAM | 2 TB NVMe/SSD with write throughput > 1000 MiBps | 100 Mbps bandwidth | | High | 8 cores | 32GB RAM | 2 TB NVMe/SSD with write throughput > 1000 MiBps | 100 Mbps bandwidth | <Note> We strongly recommend running Initia nodes on a Linux-based operating system. While it may be possible to run on other operating systems, we have not tested them and cannot guarantee the same environment settings and running conditions. </Note> <Steps> <Step title="Install Weave"> First, you need to install the [Weave CLI](https://github.com/initia-labs/weave): <CodeGroup> ```sh macOS theme={null} brew install initia-labs/tap/weave ``` ```sh Linux theme={null} curl -s https://api.github.com/repos/initia-labs/weave/releases/latest | \ grep "browser_download_url.*linux-arm64.tar.gz" | \ sed -E 's/.*"([^"]+)".*/\1/' | \ xargs curl -L | tar xz ``` </CodeGroup> </Step> <Step title="Initialize the L1 Node"> Once Weave is installed, you can initialize the L1 node. To do so, you need to run the following command: ```sh theme={null} weave initia init ``` This will guide you through the process of initializing the L1 node. You will need to provide the following information: * The Initia L1 network your node will connect to * Whether to enable gRPC and/or REST endpoints * Pruning strategy * Whether to enable automatic chain upgrade handling via Cosmovisor * Node syncing method (Snapshot, State Sync) and more. ```sh theme={null} ✓ Which network will your node participate in? > Testnet (initiation-2) ✓ Existing /Users/tansawit/.initia/config/app.toml and /Users/tansawit/.initia/config/config.toml detected. Would you like to use the current files or replace them > Replace ✓ Specify node's moniker ... node ✓ Would you like to enable the following options? (Press space to select/unselect) > REST, gRPC ✓ Specify seeds ... 3715cdb41efb45714eb534c3943c5947f4894787@34.143.179.242:26656 ✓ Specify persistent peers ... 89ff3df47beacbdc06585392cdbeaabe92cba960@47.236.109.113:26656,4e347f918e42fe8883b2c62bc695ae172d8fa8d2@207.180.207.61:26656, 4881cf2252da11c64f8dd6b7a492ebe3f61f1acb@152.53.134.160:26656,c258517ce775e9eefc0731632764c07c7be73b8f@146.190.108.47:26656,13a78fa3ed19a85a258cc8cca2505004d661d309@84.32.71.25:26656 ✓ Select pruning strategy > Default (recommended) ✓ Would you like to enable automatic upgrades via Cosmovisor? > Yes ✓ Initialization successful. ✓ Select a sync option > Snapshot ✓ Existing /Users/tansawit/.initia/data detected. By syncing, the existing data will be replaced. Would you want to proceed ? > Yes ✓ Specify the snapshot endpoint to download ... https://snapshots.polkachu.com/testnet-snapshots/initia/initia_5311531.tar.lz4 ✓ Snapshot download completed. ✓ Snapshot extracted to /Users/tansawit/.initia/data successfully. ✓ Initia node setup successfully. Config files are saved at /Users/tansawit/.initia/config/config.toml and /Users/tansawit/.initia/config/app.toml. Feel free to modify them as needed. ✓ You can start the node by running `weave initia start` ``` </Step> <Step title="Start the L1 Node"> Once the L1 node is initialized, you can start it by running the following command: ```sh theme={null} weave initia start ``` If everything is successful, you should see an output similar to the following: ```sh theme={null} Streaming logs from launchd com.cosmovisor.daemon 6:07PM INF running app args=["start"] module=cosmovisor path=/Users/tansawit/.initia/cosmovisor/genesis/bin/initiad 6:07PM INF starting the batch watcher loop module=cosmovisor 6:07PM INF mempool max txs max_txs=2000 module=server 6:07PM INF query gas limit gas_limit=3000000 module=server 6:07PM INF starting node with ABCI CometBFT in-process module=server 6:07PM INF service start impl=multiAppConn module=proxy msg="Starting multiAppConn service" 6:07PM INF service start connection=query impl=localClient module=abci-client msg="Starting localClient service" 6:07PM INF service start connection=snapshot impl=localClient module=abci-client msg="Starting localClient service" 6:07PM INF service start connection=mempool impl=localClient module=abci-client msg="Starting localClient service" 6:07PM INF service start connection=consensus impl=localClient module=abci-client msg="Starting localClient service" 6:07PM INF service start impl=EventBus module=events msg="Starting EventBus service" 6:07PM INF service start impl=PubSub module=pubsub msg="Starting PubSub service" 6:07PM INF service start impl=IndexerService module=txindex msg="Starting IndexerService service" 6:07PM INF ABCI Handshake App Info hash=38D7B1C2574882732E7D65520AF9C56336280E72861DD09A7B25F40C56339DFF height=5311532 module=consensus protocol-version=0 software-version=v0.7.0 ``` </Step> </Steps> # ConnectOracle Source: https://docs.initia.xyz/resources/developer/contract-references/evm/connect GitHub: [ConnectOracle](https://github.com/initia-labs/minievm/blob/main/x/evm/contracts/connect_oracle/ConnectOracle.sol) ## Overview The `ConnectOracle` contract interacts with the Cosmos blockchain to fetch and process price data for various currency pairs from the Connect Oracle. ## Imports | Import File | Description | | ---------------- | ----------------------------------------------------------- | | `ICosmos.sol` | Interface for interacting with the Cosmos blockchain. | | `JsmnSolLib.sol` | Library for JSON parsing. | | `IsoToUnix.sol` | Library for converting ISO date strings to Unix timestamps. | ## Structs ### Price A struct to hold price information. * `uint256 price`: The price value. * `uint256 timestamp`: The timestamp of the price. * `uint64 height`: The block height at which the price was recorded. * `uint64 nonce`: A unique identifier for the price record. * `uint64 decimal`: The decimal precision of the price. * `uint64 id`: The ID of the price record. ## Constructor ```solidity theme={null} constructor() {} ``` The constructor initializes the contract. It does not take any parameters or perform any actions upon deployment. ## Functions ### get\_price Fetches the price for a specific currency pair from the Cosmos blockchain. ```solidity theme={null} function get_price(string memory base, string memory quote) external returns (Price memory) ``` #### Parameters | Name | Type | Description | | ------- | --------------- | ------------------------------- | | `base` | `string memory` | The base currency of the pair. | | `quote` | `string memory` | The quote currency of the pair. | #### Returns | Type | Description | | -------------- | ------------------------------------------ | | `Price memory` | A struct containing the price information. | ### get\_prices Fetches prices for multiple currency pairs from the Cosmos blockchain. ```solidity theme={null} function get_prices(string[] memory pair_ids) external returns (Price[] memory) ``` #### Parameters | Name | Type | Description | | ---------- | ----------------- | ------------------------------ | | `pair_ids` | `string[] memory` | An array of currency pair IDs. | #### Returns | Type | Description | | ---------------- | --------------------------------------------------------------------------- | | `Price[] memory` | An array of `Price` structs containing the price information for each pair. | ### join Concatenates an array of strings with a specified separator. ```solidity theme={null} function join(string[] memory strs, string memory separator) internal pure returns (string memory) ``` #### Parameters | Name | Type | Description | | ----------- | ----------------- | ------------------------------------------- | | `strs` | `string[] memory` | An array of strings to be concatenated. | | `separator` | `string memory` | A separator to be used between the strings. | #### Returns | Type | Description | | --------------- | ------------------------ | | `string memory` | The concatenated string. | ### get\_price\_from\_tokens Parses a JSON string to extract price information and populate a `Price` struct. ```solidity theme={null} function get_price_from_tokens( string memory json, JsmnSolLib.Token[] memory tokens, uint256 priceObjectIndex ) internal pure returns (Price memory) ``` #### Parameters | Name | Type | Description | | ------------------ | --------------------------- | ----------------------------------------------------------- | | `json` | `string memory` | The JSON string containing the price information. | | `tokens` | `JsmnSolLib.Token[] memory` | An array of JSON tokens. | | `priceObjectIndex` | `uint256` | The starting index of the price object in the tokens array. | #### Returns | Type | Description | | -------------- | ------------------------------------------------- | | `Price memory` | A struct containing the parsed price information. | # Cosmos Source: https://docs.initia.xyz/resources/developer/contract-references/evm/cosmos GitHub: [ICosmos](https://github.com/initia-labs/initia-evm-contracts/blob/main/src/interfaces/ICosmos.sol) ## Overview The `ICosmos` interface defines a set of functions for interacting with the Cosmos blockchain from an Ethereum Virtual Machine (EVM) environment. It includes functions for address conversion, querying, and executing Cosmos messages. ## Constants ### `COSMOS_ADDRESS` The address of the `Cosmos` precompile contract. ```solidity theme={null} address constant COSMOS_ADDRESS = 0x00000000000000000000000000000000000000f1; ``` ### `COSMOS_CONTRACT` The instance of the `ICosmos` contract. ```solidity theme={null} ICosmos constant COSMOS_CONTRACT = ICosmos(COSMOS_ADDRESS); ``` ## Functions ### `is_blocked_address` Checks if an address is blocked by the Cosmos SDK bank module. ```solidity theme={null} function is_blocked_address(address account) external view returns (bool blocked); ``` #### Parameters | Name | Type | Description | | --------- | --------- | -------------------- | | `account` | `address` | The address to check | #### Returns | Type | Description | | ------ | --------------------------------------------------- | | `bool` | `true` if the address is blocked, `false` otherwise | ### `is_module_address` Checks if an address is a Cosmos SDK module account. ```solidity theme={null} function is_module_address(address account) external view returns (bool module); ``` #### Parameters | Name | Type | Description | | --------- | --------- | -------------------- | | `account` | `address` | The address to check | #### Returns | Type | Description | | ------ | ------------------------------------------------------------ | | `bool` | `true` if the address is a module account, `false` otherwise | ### `to_cosmos_address` Converts an EVM hex format address to a Cosmos bech32 format address. ```solidity theme={null} function to_cosmos_address(address evm_address) external returns (string memory cosmos_address); ``` #### Parameters | Name | Type | Description | | ------------- | --------- | -------------------------- | | `evm_address` | `address` | The EVM address to convert | #### Returns | Type | Description | | --------------- | -------------------------------- | | `string memory` | The corresponding Cosmos address | ### `to_evm_address` Converts a Cosmos bech32 format address to an EVM hex format address. ```solidity theme={null} function to_evm_address(string memory cosmos_address) external retu
프로젝트로 돌아가기