Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Feature: Checkpoint refactor and cross-net message execution #67

Merged
merged 28 commits into from
Apr 10, 2023

Conversation

cryptoAtwill
Copy link
Collaborator

@cryptoAtwill cryptoAtwill commented Mar 16, 2023

Update 04/2023: This PR has become the feature branch for all the checkpoints refactor. At a high-level this PR includes:

  • A simplification of bottom-up messages removing the need for CrossMsgMeta and including in checkpoints the raw messages to allow the immediate execution of bottom-up messages without the need for off-chain message resolution that, while more performant, it could introduce some unexpected attacks. The design will be improved in the future.
  • The use of cron_checkpoints as a top-down checkpoint used by subnet validators to report their perceived finality from the parent allowing the sync execution of top-down messages.
  • Generalization and improvement of the voting system for checkpoints so cron and bottom-up checkpoints use the same voting scheme where checkpoints are committed and executed in order, and their commitment trigger directly the execution of the included cross-net messages.

Changes

Submit a new cron checkpoint.

It only accepts submission at multiples of cron_period since genesis_epoch, which are set during construction. Each checkpoint will have its number of submissions tracked. The same address cannot submit twice. Once the number of submissions is more than or equal to 2/3 of the total number of validators, the messages will be applied.

Each cron checkpoint will check its uniqueness against each other using blake hashing. To do that, we need to make sure the validators and top_down_msgs in CronCheckpoint are the same. However, the top_down_msgs and validators are vec, they may contain the same content, but their orders are different. In this case, we need to ensure the same order is maintained in the cron checkpoint submission. To ensure we have the same consistent output for different submissions, we require:

  • validators are sorted by net_addr in string ascending order, assuming net_addr are unique for the validators
  • top down messages are sorted by (from, to, nonce) in ascending order.

Actor will not perform sorting to save gas. Client should do it, actor just check.

A side note @adlrocha, what execution order do we have to enforce when the messages are applied? Currently it's enforced as the above top down message sorting order.

Update 20/03/2023:

  • Add abort epoch functionality.

Tests

Not implemented yet, implementing

Issues to be ported to Lotus and go-ipc-types

willeslau and others added 7 commits March 15, 2023 18:22
Co-authored-by: adlrocha <adlrocha@tutamail.com>
Co-authored-by: adlrocha <adlrocha@tutamail.com>
* update cron

* fix lint

---------

Co-authored-by: willesxm <willeslau@gmail.com>
Copy link
Contributor

@adlrocha adlrocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing job, Will. We are close. I think we can simplify the logic a bit (we can go without a lot of the linked HAMTs, I think they add unnecessary complexity). Let me know if my comments are clear enough, if not we can have a quick sync.

Next up:

Thanks.

#[derive(Clone, Debug, Serialize_tuple, Deserialize_tuple, PartialEq, Eq)]
pub struct CronCheckpoint {
pub epoch: ChainEpoch,
pub validators: ValidatorSet,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end you can remove validators from here, we will get the validator set from the new data structure introduced here: #68. Thanks!

gateway/src/cron.rs Outdated Show resolved Hide resolved
gateway/src/cron.rs Show resolved Hide resolved
gateway/src/lib.rs Outdated Show resolved Hide resolved
gateway/src/lib.rs Outdated Show resolved Hide resolved
gateway/src/cron.rs Outdated Show resolved Hide resolved
gateway/src/cron.rs Outdated Show resolved Hide resolved
gateway/src/cron.rs Outdated Show resolved Hide resolved
gateway/src/cron.rs Outdated Show resolved Hide resolved
rt.validate_immediate_caller_type(CALLER_TYPES_SIGNABLE.iter())?;

let msgs = rt.transaction(|st: &mut State, rt| {
// first we check the epoch is the correct one
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assignment is redundant, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it returns the messages to be executed, should not be redundant?

@cryptoAtwill cryptoAtwill changed the title [Implementation Only] Submit cron implementation Submit cron implementation Mar 20, 2023
gateway/src/cron.rs Outdated Show resolved Hide resolved
gateway/src/cron.rs Outdated Show resolved Hide resolved
gateway/src/cron.rs Outdated Show resolved Hide resolved
gateway/src/cron.rs Outdated Show resolved Hide resolved
gateway/src/cron.rs Outdated Show resolved Hide resolved
gateway/src/lib.rs Outdated Show resolved Hide resolved
gateway/src/lib.rs Outdated Show resolved Hide resolved
gateway/src/lib.rs Outdated Show resolved Hide resolved
cryptoAtwill and others added 5 commits March 20, 2023 17:22
* track validators

* add validator check to submit cron

* update impl
* track validators

* add validator check to submit cron

* update impl

* weighted vote

* Update gateway/src/cron.rs

Co-authored-by: adlrocha <adlrocha@tutamail.com>

* update method name

---------

Co-authored-by: adlrocha <adlrocha@tutamail.com>
* track validators

* add validator check to submit cron

* update impl

* weighted vote

* Update gateway/src/cron.rs

Co-authored-by: adlrocha <adlrocha@tutamail.com>

* update method name

* add tests

* refactor pending epoches

* fix clippy

* add more tests

---------

Co-authored-by: adlrocha <adlrocha@tutamail.com>
* track validators

* add validator check to submit cron

* update impl

* weighted vote

* Update gateway/src/cron.rs

Co-authored-by: adlrocha <adlrocha@tutamail.com>

* update method name

* add tests

* refactor pending epoches

* fix clippy

* add more tests

* initial commit

* Cross execution (#75)

* update bottom up execution

* update cross message execution

* fix fmt

* update review and clean up

* check message ordering

* Cross execution tests (#76)

* fix clippy

* fmt code

---------

Co-authored-by: adlrocha <adlrocha@tutamail.com>
@adlrocha adlrocha changed the title Submit cron implementation Feature: Checkpoint refactor and cross-net message execution Apr 4, 2023
@adlrocha adlrocha changed the base branch from cron to main April 4, 2023 08:29
cryptoAtwill and others added 6 commits April 5, 2023 08:52
* track validators

* add validator check to submit cron

* update impl

* weighted vote

* Update gateway/src/cron.rs

Co-authored-by: adlrocha <adlrocha@tutamail.com>

* update method name

* add tests

* refactor pending epoches

* fix clippy

* add more tests

* initial commit

* Cross execution (#75)

* update bottom up execution

* update cross message execution

* fix fmt

* update review and clean up

* check message ordering

* Cross execution tests (#76)

* fix clippy

* fmt code

* generics for cron submission

* migrate to sdk

* format code

* remove wip field

* work in progress

* local changes

* reorg code

* update comment

* update tests

* format code and clippy

* fix error

---------

Co-authored-by: adlrocha <adlrocha@tutamail.com>
* update queue serialization

* remove println

* fix fmt
Copy link
Contributor

@adlrocha adlrocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally merging this one 🥳 Future changes and bug fixes will be done in follow-up PRs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants