ChainSafe / ChainSafe/forest

Message execution regression tests

Open
#2,997 1 comment 2 reactions 0 assignees View on GitHub
Priority: 4 - Low Type: Enhancement
Dominant language
Rust
Stars
697
Forks
200
Avg merge
1d 5h
Merged PRs (30d)
65

Description

**Issue summary**

At its core, Forest is a program that takes transactions (aka `messages`) from the Filecoin blockchain, sets up an environment, executes the transactions, and then compares the result against Lotus. By definition, any deviation from Lotus is a bug.

We recently had an issue where a [message](https://calibration.filscan.io/tipset/message-detail?cid=bafy2bzacecbq5fphrcnto4ltwovfphvbiuryx5irtwish5geu7ftcr2ef4uto) was executed incorrectly at epoch 643,585 in calibnet. As of writing, verifying that this message runs correctly requires downloading a [snapshot](https://forest-snapshots.fra1.cdn.digitaloceanspaces.com/debug/forest_snapshot_calibnet_2023-06-05_height_621698.car.zst) (1.3GiB). These snapshots contain enough information to set up a valid execution environment but are overkill if we only want to execute a single transaction.

The transaction execution environment contains the following:

- FVM Externs: These serve as a source of randomness, a way to handle block faults, and a way to query the blockchain.
- An IPLD key-value database. Each key is the hash of the IPLD value. IPLD is like JSON with links.
- Parameters such as `Base Fee` and `Circulating Supply.`

```mermaid
flowchart TB
subgraph input
direction RL
db[(Database)] ~~~ ext[Externs]
fee{{Base Fee}} ~~~ circ{{Circulating Supply}}
nv(Version) ~~~ stamp(Timestamp)
end
input --> B[FVM Execution Engine] --> output
subgraph output
new_root[(State Root)] ~~~ receipt[Receipt]
gas{{Gas fees}} ~~~ trace[Execution trace]
end
```

Computing the smallest environment sufficient to execute a single transaction should be feasible. If we could extract messages with their environment and expected output, regression testing would be faster and require less disk space.

Acceptance Criteria:

- [ ] Define the format for capturing messages and their execution context. This likely means: Chain randomness, a minimal set of IPLD key-value pairs, parameters such as `base fee` and `circulating supply,` etc.
- [ ] Implement command for extracting a message and its execution environment.
- [ ] Implement command for executing a message given a specific environment.
- [ ] (Optionally) Implement Lotus command for extracting a message and its execution environment.
- [ ] Add regression tests to CI for the `InvokeContract` messages in epochs 632281 and 643586.

**Other information and links**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.