Skip to content

Commit

Permalink
Merge branch 'master' into frc-retrieval-checking-requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
bajtos committed Dec 18, 2024
2 parents e58fadf + ed13e3c commit 859745d
Show file tree
Hide file tree
Showing 4 changed files with 354 additions and 0 deletions.
104 changes: 104 additions & 0 deletions FIPS/fip-0096.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
fip: "0096"
title: Convert fundraising remainder address(es) to keyless account actor(s)
author: Fatman13 (@fatman13)
discussions-to: https://github.com/filecoin-project/FIPs/discussions/1033
status: Draft
type: Technical
category: Core
created: 2024-07-10
---

# Convert fundraising remainder address(es) to keyless account actor(s)

## Simple Summary

Similar to [#901](https://github.com/filecoin-project/FIPs/discussions/901), covert fundraising remainder address [f0122](https://filfox.io/en/address/f0122) type from a multisig to account that is keyless (like f099).


## Abstract

At the moment, the actor holding the fundraising remainder is a _multisig_ actor. All signers are account actors, secured by corresponding wallet keys. This setup leaves the ownership and control over the fundraising remainder to signers of the _multisig_ actor, which undermines the decentralized governance principle over network funds, and creates potential security leaks. Although the amount in the fundraising remainder account is feable to institute any meaningful Sybil attack, breaching of spec still greatly undermines the security of a decentralized network by dimishing the network's credibility and unevenly favoring one party of the network participants, which both inflict profound long-term damage to the network.

This FIP proposes to alter the type of the fundraising remainder actor from the aforementioned multisig to a keyless account actor, and further transfer the ownership, control and governance of the funds reserved from the signers of the multisig back to the network's participants via community governance.


## Change Motivation

Like how mining reserve is made into a keyless account and ready to be [potentially burned](https://github.com/filecoin-project/FIPs/discussions/1030), fundraising remainder address(es) is also in the linger troubled by similar dilemma described in motivation section of [#901](https://github.com/filecoin-project/FIPs/discussions/901). We compiled the following 4 motivations for the proposal...

### 1. follow the spec

Mining reserve in the Filecoin spec is described as the following...

> It will be up to the community to determine in the future how to distribute those tokens, through Filecoin improvement proposals (FIPs) or similar decentralized decision-making processes.
> -- excerpts from #901
[fundraising remainder](https://spec.filecoin.io/#section-systems.filecoin_token.token_allocation) in the Filecoin spec is described as the following...

> Of the Filecoin genesis block allocation, 10% of FIL_BASE were allocated for fundraising, of which 7.5% were sold in the 2017 token sale, and the 2.5% remaining were allocated for ecosystem development and potential future fundraising.
Though paragraph about fundraising remainder didn't specifically articulate "up to the community to determine" as in mining reserve, by virtue of us being a crypto / blockchain community it can be assumed **by default** it is up to the community, ie FIP process, when no governance body was mentioned to oversight the distribution.

### 2. governance

> It is worth noting that when the spec was written and when the network was first launched, the FIP process was not yet well-designed or matured to support network governance, and significant improvements have been made since then.
> -- excerpts from #901
Similar to the point #901 made, this proposal is to amend the inadequacy that network in its early days has neglected.

### 3. security

> This also creates a security black hole in the network where if 2 out of the 3 signer keys of f090 are compromised by malicious actors, they may cause serious economic damage to the Filecoin network.
> -- excerpts from #901
Although the amount remaining in the fundraising remainder address(es) would not likely to cause serious economic damage as mining reserve would, there are still security concerns over whether governance could amend its mistake made in the past.

### 4. operation

> In addition, having the reserve holds in a multisig also means changes toward the mining reserve..., may need to be managed by the msig signers via signed transactions which is a huge operational overhead (and again against the principle).
> -- excerpts from #901
fundraising remainder address(es) face identical operation challenges as mining reserve too. One thing to note is that through investigation by one of the community contributors some (most) of the funds originally allocated to this address have already been moved, and this FIP doesn't propose to do anything about them.

## Specification

Convert fundraising remainder actor type from a _multisig_ to _account_ type. The new account actor should be keyless, like `f099`.

```rust
pub struct State {
pub address: Address,
}
```

The new fundraising remainder actor will contain a self-reference to its ID address in the `address` field.

## Design Rationale

The choice of making fundraising remainder actor to be a keyless account type is to ensure that no single actor/entity owns the control over fundraising remainder. The use of fundraising remainder will be proposed and governed by the FIP process, and further adopted by the network via network upgrades.

## Backwards Compatibility

This change is not backwards compatible. Upon the activation of this FIP in a network upgrade:
- the actor type of fundraising remainder will be migrated from _multisig_ to _account_.
- the existing signers of the fundraising remainder multisig will no longer be able to perform operations on the actor

## Test Cases

- Get actor cid of fundraising remainder should return actor code cid of an `account`

## Security Considerations

This proposal improves the network security by removing the ownership and control of whatever it is the remaining of the 2.5% of the total network token supply in `f0122` from individuals and putting it under the control of network participants via the appropriate governance processes. Again, the proposal acknowledges that the security threats from Sybil attack perspective is slim, but not following spec is considered a much bigger threat as attackers don't really need to buy out the network, just the governance.


## Product Considerations

This proposal places governance of the fundraising remainder funds entirely in hands of the network participants rather than key owners, thus providing greater transparency and assurance of community consultation and deliberation in appropriate future disbursement of the funds. And thus, the proposal sends out a strong signal that this is a network where spec is respected by words and by code, and restores some of the credibility lossed for failing to comply with the spec.

## Implementation

TODO

## Copyright
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
104 changes: 104 additions & 0 deletions FIPS/fip-0097.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
fip: "0097"
title: Add Support for EIP-1153 (Transient Storage) in the FEVM
author: Michael Seiler (@snissn), Steven Allen (@stebalien)
discussions-to: https://github.com/filecoin-project/FIPs/discussions/855
status: Draft
type: Technical
category: Core
created: 2024-11-19
---

# FIP-0097: Add Support for EIP-1153 (Transient Storage) in the FEVM

## Simple Summary
This proposal introduces support for **[EIP-1153: Transient Storage](https://eips.ethereum.org/EIPS/eip-1153)** in the Filecoin Ethereum Virtual Machine (FEVM). Transient storage provides data storage during transaction execution, scoped strictly to the transaction and the contract utilizing it. To maintain compatibility with Ethereum contracts utilizing this feature, the FEVM will implement transient storage with lifecycle validation and isolation.

## Abstract
EIP-1153 defines transient storage as temporary data accessible only during the originating transaction, cleared automatically at the end of the transaction. This FIP adapts transient storage to the FEVM using `TLOAD` and `TSTORE` opcodes, ensuring compatibility with Ethereum contracts and libraries that rely on this feature. Transient storage is scoped to the specific contract and transaction, ensuring that each contract’s transient storage is isolated. Nested contract calls cannot access the transient storage of other contracts, but reentrant calls to the same contract within a transaction will access the same transient storage space. Lifecycle validation mechanisms enforce this behavior, achieving functional equivalence with Ethereum’s implementation while maintaining seamless integration with Filecoin’s architecture.

## Change Motivation
Transient storage offers developers temporary, transaction-scoped storage for managing intermediate states. One key benefit of this feature is its ability to improve the implementation of reentrancy locks, enhancing security by mitigating risks associated with multiple calls to a function within sub-transactions. This feature was introduced on Ethereum mainnet in March 2024 as part of the Cancun (Dencun) upgrade, making adopting this FIP important to align the FEVM with Ethereum’s evolving tooling and Solidity’s modern features. By implementing transient storage, the FEVM ensures a seamless developer experience while supporting advanced contract use cases and secure computing.

While the FEVM implementation utilizes permanent storage for practical reasons, its lifecycle validation ensures it functionally replicates Ethereum’s transient storage. This enables compatibility with contracts and libraries that rely on `TLOAD` and `TSTORE` while supporting transaction-scoped data handling.

## Specification

### Opcode Descriptions

#### `TLOAD`
- **Opcode Hex:** `0x5C`
- **Stack Input:**
- `key`: Location of the transient storage value to load
- **Stack Output:**
- `value`: Stored value or zero if no value exists
- **Description:** Retrieves the value associated with `key` in the transient storage for the current transaction.

#### `TSTORE`
- **Opcode Hex:** `0x5D`
- **Stack Input:**
- `key`: Location to store the value
- `value`: Value to store
- **Output:** None
- **Description:** Stores `value` at the specified `key` in the transient storage for the current transaction.

### Lifecycle Management
Transient storage is valid only within the context of a single transaction. A lifecycle mechanism tracks transaction metadata (`origin` and `nonce`) to enforce lifecycle validation.

### Implementation Details
The FEVM implements transient storage using a lifecycle validation mechanism to ensure data remains accessible only during the originating transaction. This validation enforces the same behavior as Ethereum’s transient storage. Internally, transient storage relies on permanent storage to manage lifecycle data and state while ensuring functional adherence to Ethereum’s behavior.

---

## Design Rationale

The design adheres to the intent of EIP-1153 while adapting to Filecoin's architecture. The use of lifecycle validation ensures transient storage behaves as expected within the scope of a single transaction. This approach balances compatibility with Ethereum contracts and simplifies implementation within the existing FEVM architecture.

Alternative designs, such as purely in-memory storage, were considered but deemed impractical due to technical implementation difficulties.

## Backwards Compatibility
The addition of transient storage is fully backward-compatible. Existing contracts remain unaffected unless they utilize `TLOAD` and `TSTORE`. Contracts compiled with older Solidity versions will continue to execute without changes.

At the time of writing, support for `TLOAD` and `TSTORE` in current versions of Solidity is only available using inline-assembly. Thus, it is an explicitly opt-in feature, rather than a feature that contract authors may unknowngly be enabling when bumping compiler version and EVM target.

## Test Cases

### Essential Tests
1. **Basic Functionality:**
- Verify `TLOAD` retrieves the correct value.
- Verify `TSTORE` writes data to the transient storage correctly.
- Verify `TLOAD` from an unitialized location returns the zero value.

2. **Lifecycle Validation:**
- Verify that transient storage is automatically cleared and becomes inaccessible after the transaction ends.
- Verify that transient storage is properly cleared at the end of each transaction and any out-of-lifecycle data does not interfere with subsequent transaction operations.
- Verify that nested contracts have independent transient storage spaces can read and write independently.
- Verify that memory remains accessible and stable after contract reentry.

---

## Security Considerations
Transient storage introduces minimal additional risk compared to existing state storage. Lifecycle validation ensures storage is inaccessible outside the originating transaction. Security measures include:
- Preventing out-of-bounds memory access.
- Ensuring transient storage clears properly after a transaction ends.
- Ensuring nested contracts do not have access to each other's memory spaces.

---

## Incentive Considerations
By adding support for transient storage, this FIP improves the FEVM's compatibility with Ethereum and provides developers with useful functionality for transaction-scoped data handling. This feature enables capabilities outlined in EIP-1153, such as reentrancy locks, temporary approvals, on-chain address computation, and enhanced proxy call metadata handling. These improvements align with Filecoin's goal of enabling scalable and reliable decentralized applications. However, transient storage does not introduce or impact economic incentives within the network.

---

## Product Considerations
Adding transient storage ensures compatibility with modern Ethereum tooling, attracting developers to Filecoin’s ecosystem. This feature supports the development of advanced smart contracts and storage-related services. This addition further solidifies Filecoin’s position as a robust EVM-compatible chain, enhancing its attractiveness to Ethereum developers and expanding its ecosystem of decentralized applications.

---

## Implementation
The reference implementation, including `TLOAD` and `TSTORE`, is available in the following pull request: [filecoin-project/builtin-actors#1588](https://github.com/filecoin-project/builtin-actors/pull/1588). The implementation includes lifecycle validation and persistent backing for ease of use.

---

## Copyright
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
Loading

0 comments on commit 859745d

Please sign in to comment.