Starknet 백서

Starknet

원문

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

rknet.io/secure/quickstart/becoming-a-validator ## Overview Welcome to the second installment of the *Help secure Starknet* guide! 🛡️ After running your own full node, you can take an additional step to help secure Starknet by becoming a validator. While running a node already contributes to the network's decentralization, becoming a validator allows you to earn rewards while taking on [additional responsibilities](/secure/quickstart/attesting-to-blocks). This installment of the series will therefore walk you through the validator onboarding process, including [staking STRK tokens](#staking-strk), [setting your commission](#setting-commission), [opening a delegation pool](#opening-a-delegation-pool), and [verifying that the procedure was successful](#verifying-stakes). <Note> The steps in this installment are demonstrated on Sepolia. For the equivalent addresses on Mainnet, see [Chain information](/learn/cheatsheets/chain-info#important-addresses). </Note> ## Prerequisites Besides [the prerequisites for running a full node](/secure/quickstart/running-a-node#prerequisites), becoming a Starknet validator requires three accounts deployed on either Sepolia or Mainnet. To follow this guide, these account should be configured as follows: <Note> To understand the role of the each account, read more about [validator addresses in the staking protocol](/learn/protocol/staking#addresses). </Note> * An account with its address exported using: ```shell theme={null} export OPERATIONAL_ADDRESS=<YOUR_OPERATOR_ADDRESS> ``` * An account with its address exported using: ```shell theme={null} export REWARDS_ADDRESS=<YOUR_REWARDEE_ACCOUNT_ADDRESS> ``` * An `sncast` account named `staker` holding at least [the minimum required amount of STRK tokens](/learn/protocol/staking#protocol) with its address exported using: ```shell theme={null} export STAKING_ADDRESS=<YOUR_STAKER_ACCOUNT_ADDRESS> ``` <Tip> For deploying and funding an `sncast` account on Sepolia, see [Deploying a new Sepolia account](/build/quickstart/sepolia#deploying-a-new-sepolia-account). </Tip> ## Staking STRK To become a validator, you must stake least [the minimum required amount of STRK tokens](/learn/protocol/staking#protocol) by locking them into Starknet's Staking contract. ### Approving STRK transfer To stake your STRK tokens, you first need to approve the transfer of STRK tokens from your staking address to the Staking contract. To do so, use your staking address to invoke the STRK token contract's `approve` function with the following parameters: 1. The Staking contract's address 2. The number of STRK tokens to stake For example, the following can be used to approve the transfer of 1 STRK to the Staking contract on Sepolia: ```shell theme={null} sncast --account=staker invoke \ --contract-address=0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d \ (1) --function=approve \ --arguments=0x03745ab04a431fc02871a139be6b93d9260b0ff3e779ad9c8b377183b23109f1,1000000000000000000 \ (2) --network=sepolia ``` 1. The STRK contract's address on Sepolia 2. The Staking contract's address on Sepolia and 1 STRK (STRK has 18 decimals) ### Locking STRK Once the transfer is approved, you can lock your STRK tokens into the Staking contract by using your staking address to invoke the Staking contract's `stake` function with the following parameters: 1. The address to set as your rewards address 2. The address to set as your operational address 3. The number of STRK tokens to stake <Note> The number of STRK tokens to stake must match the number specified in the `approve` function. </Note> For example, the following can be used to stake 1 STRK with delegation pooling enabled and 1% commission on Sepolia: ```shell theme={null} sncast --account=staker invoke \ --contract-address=0x03745ab04a431fc02871a139be6b93d9260b0ff3e779ad9c8b377183b23109f1 \ (1) --function=stake \ --arguments=$REWARDS_ADDRESS,$OPERATIONAL_ADDRESS,1000000000000000000 \ (2) --network=sepolia ``` 1. The Staking contract's address on Sepolia 2. 1 staked STRK (STRK has 18 decimals), delegation pooling enabled, and 100/10,000 = 1% commission ## Setting commission Once your STRK tokens are locked, you can initialize your commission by using your staking address to invoke the Staking contract's `set_commission` function with the following parameters: 1. The commission rate to set for your delegation pool, as a percentage with precision where 10,000 represents 100% For example, the following can be used to initialize a 1% commission on Sepolia: ```terminal theme={null} sncast --account=staker invoke \ --contract-address=0x03745ab04a431fc02871a139be6b93d9260b0ff3e779ad9c8b377183b23109f1 \ (1) --function=set_commission \ --arguments=100 \ (2) --network=sepolia ``` 1. The Staking contract's address on Sepolia 2. 100/10,000 = 1% commission ## Opening delegation pools Once your commission is initialized, you can open a delegation pool by using your staking address to invoke the Staking contract's `set_open_for_delegation` function with the following parameters: 1. The token address to set for your delegation pool <Tip> To review the addresses of all BTC tokenizations ("BTC wrappers"), use the staking contract's [`get_active_tokens`](https://github.com/starkware-libs/starknet-staking/blob/main/docs/spec.md#get_active_tokens) function. </Tip> For example, the following can be used to open an STRK delegation pool on Sepolia: ```terminal theme={null} sncast --account=staker invoke \ --contract-address=0x03745ab04a431fc02871a139be6b93d9260b0ff3e779ad9c8b377183b23109f1 \ (1) --function=set_open_for_delegation \ --arguments=0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d \ (2) --network=sepolia ``` 1. The Staking contract's address on Sepolia 2. The STRK contract's address on Sepolia ## Getting information To verify that the staking procedure has been successful, you can call the Staking contract's `get_staker_info_v1` function with your staking address as parameter. For example, the following can be used to verify your staking on Sepolia: ```shell theme={null} sncast call \ --contract-address=0x03745ab04a431fc02871a139be6b93d9260b0ff3e779ad9c8b377183b23109f1 \ (1) --function=get_staker_info_v1 \ --arguments=$STAKING_ADDRESS \ --network=sepolia ``` 1. The Staking contract's address on Sepolia If all goes well, the result should be similar to the following: ```shell theme={null} response: [ 0x0, (1) 0xdeadbeef1, (2) 0xdeadbeef2, (3) 0x1, (4) 0xde0b6b3a7640000, (5) 0x0, (6) 0x0, (7) 0x5aa0ca4c068a87f894e8d3918e16ea616df631c28f9c39eae040abfb4966881, (8) 0x0, (9) 0x64 (10) ] ``` 1. Indicates successfully getting the staker's info 2. The validator's rewards address 3. The validator's operational address 4. The validator's stake 5. The validator's index 6. The validator's unclaimed rewards 7. Indicates successfully getting the delegation pool's info 8. The delegation pool's stake 9. The delegation pool's unclaimed rewards 10. The delegation pool's commission ($64_{16} = 100$) # Recommended next steps after helping secure Starknet Source: https://docs.starknet.io/secure/quickstart/next-steps # Introduction Welcome to the fourth and final installment of the *Help secure Starknet* guide! 🛡️ By now you've successfully set up your own Starknet full node and possibly even became a validator (way to go!). This last installment of the series will therefore list the various resources you dive into next. ## Essential learning materials * [Node API specifications](https://github.com/starkware-libs/starknet-specs/blob/master/api/starknet_api_openrpc.json) * [Staking protocol specifications](/learn/protocol/staking) * [Starknet cheatsheets](/learn/cheatsheets/chain-info) ## Full nodes documentations * [Pathfinder Documentation](https://docs.swmansion.com/pathfinder) * [Juno Documentation](https://www.nethermind.io/juno) ## Community and support * [Starknet Staking Telegram](https://t.me/+CLZl_F_Nj2RlNjU0) * [Starknet Discord Community](https://discord.gg/starknet-community) * [Starknet Community Forum](https://community.starknet.io/) # Summary Good luck and welcome aboard! We're incredibly grateful for your contribution to strengthening and safeguarding Starknet 💪 # Help secure Starknet guide overview Source: https://docs.starknet.io/secure/quickstart/overview ## Introduction Welcome to the official *Help secure Starknet* guide! 🛡️ This comprehensive tutorial will walk you through the entire process of becoming a Starknet validator, from meeting the prerequisites to successfully running your validator node. While Starknet is currently still centralized, it is gradually moving towards employing a staking protocol, handing over the responsibilities of producing, attesting, and proving blocks to validators. By the end of this guide, you'll have hands-on experience with the core tools and processes needed to participate in Starknet's decentralized validation network. ## What you'll learn This guide is structured as a series of interconnected tutorials that build upon each other: * [Running a full node](/secure/quickstart/running-a-node) - Setting up and maintaining your validator node * [Becoming a validator](/secure/quickstart/becoming-a-validator) - How to stake your tokens to become eligible for validation * [Attesting to blocks](/secure/quickstart/attesting-to-blocks) - Learn how to participate in block attestation as a validator * [Recommended next steps](/secure/quickstart/next-steps) - Advanced topics and ongoing maintenance ## Prerequisites Before starting this tutorial, you should have: * Basic familiarity with command-line interfaces and server administration * A computer or server running Linux (Ubuntu 20.04+ recommended) * Sufficient STRK tokens for staking (minimum requirements vary) * A reliable internet connection for node synchronization * Understanding of blockchain concepts and validation mechanisms Some experience with running blockchain nodes is helpful but not required - this guide covers the essentials! ## Getting help If you encounter any issues while following this guide: 1. Review the [Starknet staking specifications](/learn/protocol/staking) for technical details 2. Join our [Telegram support channel](https://t.me/+CLZl_F_Nj2RlNjU0) for validator-specific questions 3. Ask for help in the [Starknet Discord community](https://discord.gg/starknet-community) 4. Browse the [Starknet community forum](https://community.starknet.io/) for additional resources # Running a full node Source: https://docs.starknet.io/secure/quickstart/running-a-node ## Overview Welcome to the first installment of the *Help secure Starknet* guide! 🛡️ By operating your own full node, you become part of the distributed network that validates transactions, preserves blockchain history, and ensures Starknet remains decentralized and censorship-resistant. This guide will walk you through running your own full node using either [Juno](https://github.com/NethermindEth/juno) or [Pathfinder](https://docs.swmansion.com/pathfinder). ## Prerequisites ### Installing docker The easiest option to run a Starknet full node is using Docker. To install Docker, simply visit [docs.docker.com/get-started/get-docker](https://docs.docker.com/get-started/get-docker/) and choose whatever OS you're using. ### Exporting an Ethereum URL Running a Starknet full node requires an Ethereum websocket RPC URL. You can get your free Ethereum websocket RPC URL by creating an account with [Alchemy](https://www.alchemy.com/), [Infura](https://www.infura.io/), or [Quicknode](https://www.quicknode.com/). Afterwhich, you can export it by running: ```shell theme={null} export ETHEREUM_URL=<YOUR_URL> ``` # Running Juno You can run a Juno node using several methods: * [Docker container](#docker-container) * [Standalone binary](#standalone-binary) * [Building from source](#building-from-source) <Note> You can use a snapshot to quickly synchronise your node with the network. Check out the [Database Snapshots](#downloading-a-snapshot) guide to get started. </Note> ## Docker container ### 1. Get the Docker image Juno Docker images can be found at the [nethermind/juno](https://hub.docker.com/r/nethermind/juno) repository on Docker Hub. Download the latest image: ```bash theme={null} docker pull nethermind/juno ``` You can also build the image locally: ```bash theme={null} # Clone the Juno repository git clone https://github.com/NethermindEth/juno cd juno # Build the Docker image docker build -t nethermind/juno:latest . ``` ### 2. Run the Docker container ```bash theme={null} # Prepare the snapshots directory mkdir -p $HOME/snapshots # Run the container docker run -d \ --name juno \ -p 6060:6060 \ -v $HOME/snapshots/juno_mainnet:/snapshots/juno_mainnet \ nethermind/juno \ --http \ --http-port 6060 \ --http-host 0.0.0.0 \ --eth-node <YOUR-ETH-NODE> \ --db-path /snapshots/juno_mainnet ``` You can view logs from the Docker container using the following command: ```bash theme={null} docker logs -f juno ``` ## Standalone binary Download standalone binaries from [Juno's GitHub Releases](https://github.com/NethermindEth/juno/releases/latest) as ZIP archives for Linux (amd64 and arm64) and macOS (amd64). For macOS (arm64) or Windows users, consider [running Juno using Docker](#docker-container). ```bash theme={null} # Prepare the snapshots directory mkdir -p $HOME/snapshots # Run the binary ./juno \ --http \ --http-port 6060 \ --http-host 0.0.0.0 \ --eth-node <YOUR-ETH-NODE> \ --db-path $HOME/snapshots/juno_mainnet ``` You should replace `<YOUR-ETH-NODE>` with your actual Ethereum node address. If you're using Infura, your Ethereum node address might look something like: `wss://mainnet.infura.io/ws/v3/your-infura-project-id`. Make sure you are using the WebSockets URL `ws`/`wss` and not the http URL `http`/`https`. To view logs from the Docker container, use the following command: ```shell theme={null} docker logs -f juno ``` ## Building from source You can build the Juno binary or Docker image from the source code to access the latest updates or specific versions. ### Prerequisites * [Golang 1.25](https://go.dev/doc/install) or later * [Rust](https://www.rust-lang.org/tools/install) 1.87.0 or higher. * C compiler: `gcc` or `clang` * [jemalloc](https://github.com/jemalloc/jemalloc) ```mdx-code-block theme={null} import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; ``` <Tabs> <TabItem label="Ubuntu"> ```bash theme={null} sudo apt-get install -y build-essential make libjemalloc-dev libjemalloc2 pkg-config libbz2-dev ``` </TabItem> <TabItem label="MacOS (Homebrew)"> ```bash theme={null} brew install jemalloc pkg-config ``` </TabItem> </Tabs> ### 1. Clone the repository Clone Juno's source code from our [GitHub repository](https://github.com/NethermindEth/juno): ```bash theme={null} git clone https://github.com/NethermindEth/juno cd juno ``` <Note> You can use `git tag -l` to view specific version tags. </Note> ### 2. Build the binary or Docker image ```bash theme={null} # Install juno dependencies make install-deps # Build the binary make juno # Build the Docker image docker build -t nethermind/juno:latest . ``` ### 3. Run the binary Locate the standalone binary in the `./build/` directory: ```bash theme={null} # Prepare the snapshots directory mkdir -p $HOME/snapshots # Run the binary ./build/juno \ --http \ --http-port 6060 \ --http-host 0.0.0.0 \ --db-path $HOME/snapshots/juno_mainnet \ --eth-node <YOUR-ETH-NODE> ``` # Running Pathfinder Running a full node involves using your local machine's storage to maintain a full database of the blockchain, all the way from the genesis block. Database snapshots let you quickly start your node without having to download all blocks from the very beginning, and instead use a pre-made version of the database that's already in sync up to a certain block. ## Downloading a snapshot To download Pathfinder's snapshot, you first need to download the [rclone](https://rclone.org/) file manager by running: ```shell theme={null} sudo -v ; curl https://rclone.org/install.sh | sudo bash ``` <Note> This installation script can be used to install rclone on Linux/macOS/BSD systems. For other installation methods, see [rclone.org/install](https://rclone.org/install/). </Note> Once rclone is downloaded, create a new rclone configuration file: ```shell theme={null} touch $HOME/.config/rclone/rclone.conf ``` and add the following content: ```shell theme={null} [pathfinder-snapshots] type = s3 provider = Cloudflare env_auth = false access_key_id = 7635ce5752c94f802d97a28186e0c96d secret_access_key = 529f8db483aae4df4e2a781b9db0c8a3a7c75c82ff70787ba2620310791c7821 endpoint = https://cbf011119e7864a873158d83f3304e27.r2.cloudflarestorage.com acl = private ``` Next, create a new `$HOME/pathfinder` directory, navigate into it, and use rclone to copy [Pathfinder's latest database snapshot](https://rpc.pathfinder.swmansion.com/snapshots/latest) to your local directory by running: ```shell theme={null} mkdir $HOME/pathfinder cd $HOME/pathfinder rclone copy -P pathfinder-snapshots:pathfinder-snapshots/<FILENAME> snapshot.sqlite.zst ``` Once the database snapshot is downloaded, compare the file's checksum value with the one shown at [rpc.pathfinder.swmansion.com/snapshots/latest](https://rpc.pathfinder.swmansion.com/snapshots/latest) by running: ```shell theme={null} sha256sum snapshot.sqlite.zst ``` If the checksum values match, extract the downloaded database snapshot by running: ```shell theme={null} zstd -T0 -d snapshot.sqlite.zst -o snapshot.sqlite ``` ## Using the snapshot Now that the database snapshot is extracted, you can start your node by running: ```shell theme={null} docker run \ --name pathfinder \ --restart unless-stopped \ --detach \ -p 9545:9545 \ --user "$(id -u):$(id -g)" \ -e RUST_LOG=info \ -e PATHFINDER_ETHEREUM_API_URL=$ETHEREUM_URL \ -v $HOME/pathfinder:/usr/share/pathfinder/data \ swmansion/pathfinder ``` Once the docker container is up and running, you can check the docker image's logs by running: ```shell theme={null} docker logs -f pathfinder ``` If successful, the result should resemble the following: ```shell theme={null} 2025-05-12T18:29:45 INFO Downloading block 766533 2025-05-12T18:30:36 INFO Updated Starknet state with block 766534 2025-05-12T18:31:07 INFO Updated Starknet state with block 766535 2025-05-12T18:31:35 INFO Updated Starknet state with block 766536 2025-05-12T18:32:12 INFO Downloading block 766537 ``` <Note> To stop the node's execution, run: ```shell theme={null} docker stop pathfinder ``` </Note>
프로젝트로 돌아가기