Filecoin 백서

Filecoin

원문

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

eated and stored* a unique copy of some piece of data. * [Proof of Spacetime (PoST)](#proof-of-spacetime-post): a procedure to validate that an SP is *continuing to store* a unique copy of some piece of data. ## Proof-of-Replication (PoRep) In the Filecoin storage lifecycle process, *Proof-of-Replication (PoRep)* is used when an SP agrees to store data on behalf of a client and receives a piece of client data. In this process: 1. The data is placed into a [sector](/reference/general/glossary#sector). 2. The sector is sealed by the SP. 3. A unique encoding, which serves as proof that the SP has replicated a copy of the data they agreed to store, is generated (described in [Sealing as proof](#sealing-as-proof)). 4. The proof is compressed. 5. The result of the compression is submitted to the network as certification of storage. ### Sealing as proof The unique encoding created during the sealing process is generated using the following pieces of information: * The data is sealed. * The storage provider who seals the data. * The time at which the data was sealed. Because of the principles of cryptographic hashing, a new encoding will be generated if the data changes, the storage provider sealing the data changes, or the time of sealing changes. This encoding is unique and can be used to verify that a specific storage provider did, in fact, store a particular piece of client data at a specific time. ## Proof-of-Spacetime (PoSt) After a storage provider has proved that they have replicated a copy of the data that they agreed to store, the SP must continue to prove to the network that: * They are still storing the requested data. * The data is available. * The data is still sealed. Because this method is concerned with proving that data is being stored in a particular *space* for a particular period or at a particular *time*, it is called *Proof-of-Spacetime (PoSt)*. In Filecoin, the PoSt process is handled using two different sub-methods, each of which serves a different purpose: * [WinningPoSt](#winningpost) is used to prove that an SP selected using an election process has a replica of the data at the specific time that they were asked and is used in the block consensus process. * [WindowPoSt](#windowpost) is used to prove that, for any and all SPs in the network, a copy of the data that was agreed to be stored is being continuously maintained over time and is used to audit SPs continuously. ### WinningPoSt *WinningPoSt* is used to prove that an SP selected via election has a replica of the data at the specific time that they were asked and is specifically used in Filecoin to determine which SPs may add blocks to the Filecoin blockchain. At the beginning of each [epoch](/reference/general/glossary#epoch), a small number of SPs are elected to mine new blocks using the [Expected Consensus algorithm](https://spec.filecoin.io/algorithms/expected_consensus/), which guarantees that validators will be chosen based on a probability proportional to their [storage power](/reference/general/glossary#storage-power). Each of the SPs selected must submit a WinningPoSt, proof that they have a sealed copy of the data that they have included in their proposed block. The deadline to submit this proof is the end of the current epoch and was intentionally designed to be short, making it impossible for the SP to fabricate the proof. Successful submission grants the SP: * The [block reward](/provide-storage/filecoin-economics/block-rewards). * The opportunity to charge other nodes fees in order to include their messages in the block. If an SP misses the submission deadline, no penalty is incurred, but the SP misses the opportunity to mine a block and receive the block reward. ### WindowPoSt *WindowPoSt* is used to prove that, for any and all SPs in the network, a copy of the data that was agreed to be stored is being continuously maintained over time and is used to audit SPs continuously. In WindowPoSt, all SPs must demonstrate the availability of all sectors claimed every [proving period](/provide-storage/filecoin-economics/storage-proving#proving-deadlines). Sector availability is not proved individually; rather, SPs must prove a whole [partition](/provide-storage/filecoin-economics/storage-proving#proving-deadlines) at once, and that sector must be proved by the deadline assigned (a 30-minute interval in the proving period). The more sectors an SP has pledged to store, the more the partitions of sectors that the SP will need to prove per deadline. As this requires that the SP has access to sealed copies of each of the requested sectors, it makes it irrational for the SP to seal data every time they need to provide a WindowPoSt proof, thus ensuring that SPs on the network are continuously maintaining the data agreed to. Additionally, failure to submit WindowPoSt for a sector will result in the SPs’ pledge collateral being forfeited and their storage power being reduced. [Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/core-concepts/filecoin-virtual-machine/proofs) # Filecoin EVM runtime This page details what exactly EVM compatibility means for the FVM, and any other information that Ethereum developers may need to build applications on Filecoin. The Ethereum Virtual Machine is an execution environment initially designed, built for, and run on the Ethereum blockchain. The EVM was revolutionary because, for the first time, any arbitrary code could be deployed to and run on a blockchain. This code inherited all the decentralized properties of the Ethereum blockchain. Before the EVM, a new blockchain had to be created with custom logic and then bootstrapped with validators every time a new type of decentralized application needed to be built. Code deployed to EVM is typically written in the high-level language Solidity, although other languages, such as Vyper, exist. The high-level Solidity code is compiled to EVM bytecode which is what is actually deployed to and run on the EVM. Due to it being the first virtual machine to run on top of a blockchain, the EVM has developed one of the strongest developer ecosystems in Web3 to date. Today, many different blockchains run their own instance of the EVM to allow developers to easily port their existing applications into the new blockchain’s ecosystem. ## Ethereum Virtual Machine The Filecoin EVM, often just referred to as *FEVM*, is the Ethereum virtual machine virtualized as a runtime on top of the Filecoin virtual machine. It allows developers to port any existing EVM-based smart contracts straight onto the FVM. The Filecoin EVM runtime is completely compatible with any EVM development tools, such as Hardhat, Brownie, and MetaMask, making deploying and interacting with EVM-based actors easy! This is because Filecoin nodes offer the Ethereum JSON-RPC API. ## Deep dive For a deeper dive into the concepts discussed on this page, see this presentation Ethereum compatibility of FVM, see: {% embed url="<https://www.youtube.com/watch?v=lgUMVhM3FIM>" %} [Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/architecture/filecoin-evm-runtime) # Actors In the Filecoin network, an address is a unique identifier that refers to an actor in the Filecoin state. All actors in Filecoin have a corresponding address which varies from the different usages. The Filecoin EVM runtime introduces three new actor types: 1. [Placeholder actors](#placeholder). 2. [Ethereum-style accounts](#ethereum-style-account), also called `EthAccount`. 3. [EVM smart contracts](#evm-smart-contract). ## Placeholder A *placeholder* is a particular type of pseudo-actor that holds funds until an actual actor is deployed at a specific address. When funds are sent to an address starting with `f410f` that doesn’t belong to any existing actor, a *placeholder* is created to hold the said funds until either an account or smart contract is deployed to that address. A placeholder can become a *real* actor in one of two ways: 1. A message is sent from the account that would exist at that placeholder’s address. If this happens, the placeholder is automatically upgraded into an account. 2. An EVM smart contract is deployed to the address. ## Ethereum-style account An Ethereum-style account is the Filecoin EVM runtime equivalent of an account with an `f1` or `f3` address, also known as native accounts. However, there are a few key differences: 1. These accounts have `0x`-style addresses and an equivalent `f`-style address starting with `f410f`. 2. Messages from these accounts can be sent with Ethereum wallets like MetaMask by connecting the wallet to a Filecoin client. 3. These accounts can be used to transfer funds to native or Ethereum-style. 4. They can be used to call EVM smart contracts and can be used to deploy EVM smart contracts. However, they cannot be used to call native actors such as multisig or miner actors. ## EVM smart contract An EVM smart contract actor hosts a single EVM smart contract. Every EVM smart contract will have a `0x`-style address. ### Deploying An EVM smart contract can be deployed in one of three ways: 1. An existing EVM smart contract can use the EVM’s `CREATE`/`CREATE2` opcode. 2. Ethereum-native tooling can be used in conjunction with an Ethereum-style account such as [Remix](/build-on-filecoin/development-frameworks/remix) or [Hardhat](/build-on-filecoin/development-frameworks/hardhat). 3. A native account can call method `4` on the Ethereum account manager `f010`, passing the EVM init code as a CBOR-encoded byte-string (major type 2) in the message parameters. ### Calling An EVM smart contract may be called in one of three ways: 1. An EVM smart contract can use the EVM’s `CALL` opcode. 2. Ethereum-native tooling, like [MetaMask](/networks-and-tools/assets/metamask-setup), can be used in conjunction with an Ethereum-style account. 3. Finally, a native account can call method `3844450837` (`FRC42(InvokeEVM)`): 1. The input data should either be empty or encoded as a CBOR byte string. 2. The return data will either be empty or encoded as a CBOR byte string. [Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/architecture/filecoin-evm-runtime/actor-types) # Address types In the Filecoin network, an address is a unique identifier that refers to an actor in the Filecoin state. All actors in Filecoin have a corresponding address which varies from the different usages. Filecoin has five address classes, and actors tend to have *multiple* addresses. Furthermore, each address class has its own rules for converting between binary and text. The goal of using different types of addresses is to provide a robust address format that is scalable, easy to use, and reliable. These addresses encode information including: * Network prefix: indicates the network the actor belongs to. * Protocol indicator: identify the type and version of this address. * Payload: identify the actor according to the protocol. * Checksum: validate the address. Filecoin addresses can be represented either as raw bytes or a string. Raw bytes format will always be used on-chain. An address can also be encoded to a string, including a checksum and network prefix. The string format will never appear on-chain and is only for human-readable purposes. Filecoin address can be broken down like this: | Network prefix | Protocol indicator | Payload | Checksum | | -------------- | ----------------------------------- | --------- | -------- | | `f` / `t` | 1 byte: `0` / `1` / `2` / `3` / `4` | *n* bytes | 4 bytes | The network prefix is prepended to an address when encoding to a string. The network prefix indicates which network an address belongs to. Network prefixes never appear on-chain and are only used when encoding an address to a human-readable format. * `f` - addresses on the Filecoin mainnet. * `t` - addresses used on any Filecoin testnet. The protocol indicator identifies the address type, which describes how a method should interpret the information in the `payload` field of an address. * `0`: An ID address. * `1`: A wallet address generated from a secp256k public key. * `2`: An actor address. * `3`: A wallet address generated from BLS public key. * `4`: A delegated address for user-defined foreign actors: * `410`: Ethereum-compatible address space managed by the Ethereum address manager (EAM). Each 410 address is equivalent to an 0x address. Each address type is described below. ## ID addresses All addresses have a short integer assigned to them by `InitActor` sequentially, a unique actor that can create *new* actors. The integer that gets assigned is the ID of that actor. An *ID address* is an actor’s ID prefixed with the network identifier and the protocol indicator. Therefore, any address in the Filecoin network has a unique ID address assigned to it. The mainnet burn account ID address is `f099` and is structured as follows: ```plaintext Protocol Indicator | f 0 9 9 | | | Actor ID | Network identifier ``` ## Actor addresses Addressed representing an actor deployed through the init actor in the Filecoin network. It provides a way to create robust addresses for actors not associated with a public key. They are generated by taking a `sha256` hash of the output of the account creation. Actor addresses are often referred to by their shorthand, `2`. ## Wallet addresses Addresses managed directly by users, like accounts, are derived from a public-private key pair. If you have access to a private key, you can sign messages sent from that wallet address. The public key is used to derive an address for the actor. Public key addresses are referred to as *robust addresses* as they do not depend on the Filecoin chain state. Public key addresses allow devices, like hardware wallets, to derive a valid Filecoin address for your account using just the public key. The device doesn’t need to ask a remote node what your ID address is. Public key addresses provide a concise, safe, human-readable way to reference actors before the chain state is final. ID addresses are a space-efficient way to identify actors in the Filecoin chain state, where every byte matters. Filecoin supports two types of public key addresses: * [secp256k1 addresses](https://en.wikipedia.org/wiki/Secp256k1) that begin with the protocol indicator as `1`. * [BLS addresses](https://en.wikipedia.org/wiki/BLS_digital_signature) that begin with the protocol indicator as `3`. `t1iandfn6d...ddboqxbhoeva` - a testnet wallet address generated using secp256k1. `t3vxj34sbdr3...road7cbygq` - a testnet wallet address generated using BLS. ## Delegated addresses Filecoin supports extensible, user-defined actor addresses through the `4` address class, introduced in [Filecoin Improvement Proposal (FIP) 0048](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0048.md). The `4` address class provides the following benefits to the network: * Implement foreign addressing systems in Filecoin. * A predictable addressing scheme to support interactions with addresses that do not yet exist on-chain. * User-defined, programmable addressing systems without extensive changes and network upgrades. For example, a testnet delegated address using the Ethereum Addressing System is structured as follows: ```plaintext Address manager actor ID | t 410 iandfn6d... | | | New actor ID | Network identifier ``` The *address manager actor ID* is the actor ID of the address manager actor, which creates new actors and assigns a `4` address to the new actor. This leverages the extensible feature of the `f4` address class. The *new actor ID* is the arbitrary actor ID chosen by that actor. ### Restrictions Currently, per [FIP 0048](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0048.md), `f4` addresses may only be assigned by and in association with specific, built-in actors called *address managers*. This restriction will likely be relaxed once users are able to deploy custom WebAssembly actors. This address type plays an essential role in supporting the FEVM. It allows the Filecoin network to be able to recognize the foreign address and validate and execute the transactions sent and signed by the supported foreign addresses. The supported foreign addresses can be cast as `f4/t4` addresses, and vice-versa. But not with `f1/t1` or `f3/t3` addresses. ### Ethereum Address Manager Ethereum Address Manager (EAM) is a built-in actor that manages the Ethereum address space, anchored at the `410` address namespace. It acts like an EVM smart contract factory, offering methods to create and assign the `f410/t410` Filecoin address to Ethereum address. The subaddress of an `f410/t410` address is the original Ethereum address. Ethereum addresses can be cast as `f410` addresses, and vice-versa. The `f410/t410` address will be used for the Ethereum-compatible FVM (FEVM) development tools and applications built on FEVM. **Example** ```plaintext # An Ethereum wallet address. 0xd388ab098ed3e84c0d808776440b48f685198498 # The corresponding Filecoin address on Calibration. t410f2oekwcmo2pueydmaq53eic2i62crtbeyuzx2gmy ``` If you have an Ethereum wallet address starting with `0x`, then the Ethereum Address Manager (EAM) will assign a corresponding `t410` Filecoin address to it. If you send 10 tFIL to `0xd388ab098ed3e84c0d808776440b48f685198498` using a wallet like MetaMask, you will receive 10 tFIL to your `t410f2oekwcmo2pueydmaq53eic2i62crtbeyuzx2gmy` address on Filecoin Calibration testnet. ```plaintext # A Filecoin smart contract address. t410fl5qeigmkcytz7b6sqoojtcetqwf37dm4zv4aijq # The corresponding Ethereum smart contract address. 0x5f6044198a16279f87d2839c998893858bbf8d9c ``` Again, assume you have deployed a solidity smart contract on Filecoin Calibration. Then you will receive a smart contract address starting with `t410`. EAM will also assign a corresponding `0x` Ethereum address to it. When you try to invoke this smart contract on Filecoin using Ethereum tooling, you need to use your `0x5f6044198a16279f87d2839c998893858bbf8d9c` smart contract address. ### Converting to a 0x-style Address The Filecoin EVM runtime introduces support for `0x` Ethereum-style addresses. Filecoin addresses starting with either `f0` or `f410f` can be converted to the `0x` format as follows: ![Filecoin to Ethereum Address Conversion](https://3376433986-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxNWFG7bQkjLkl5BBGjbD%2Fuploads%2Fgit-blob-9e2c7ba214b5dd660be4a623d7d1e9f3809efe9a%2Fethereum-address-conversion.png?alt=media) Addresses starting with `f0` can be converted to the `0x` format by: * Extracting the `actor_id` (e.g., the `1234` in `f01234`). * Hex encode with a `0xff` prefix: `sprintf("0xff0000000000000000000000%016x", actor_id)`. Addresses starting with `f410f` address can be converted to the `0x` format by: * Removing the `f410f` prefix. * Decoding the remainder as base 32 (RFC 4648 without padding). * Trim off the last 4 bytes. This is a *checksum* that can optionally be verified, but that’s beyond the scope of this documentation. * Assert that the remaining address is 20 bytes long. * Hex-encode: `sprintf(0x%040x", actor_id)`. {% hint style="danger" %} `f0` addresses are **not** re-org stable and should not be used until the chain has settled. {% endhint %} ### Converting to a Filecoin Address On the flip side, Ethereum-style addresses can be converted to a Filecoin address as follows: Addresses starting with `0xff0000000000000000000000` can be converted to a Filecoin address by: * Decoding the last 16 hex digits into a uint64 * Format the address as `f0${decimal(id)}` where decimal(id) is the decimal representation of the decoded actor ID. Otherwise, it maps to f410f… [Wa
프로젝트로 돌아가기