Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contract redesign #931

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Contract redesign #931

wants to merge 6 commits into from

Conversation

cryptoAtwill
Copy link
Contributor

@cryptoAtwill cryptoAtwill commented May 15, 2024

Initial POC for contract redesign. Refer to contract-redesign.md for the high level idea and please comment.

This PR partially implements the ideas:

  • Simplify LibStaking to LibPowerChange that use power to replace collateral and federatedPower. The caller facet can decide what power is
  • Break federated power and collateral based power allocation mode, federated power is implemented
  • Generalize genesis
  • Topdown and bottomup simplification

@cryptoAtwill cryptoAtwill marked this pull request as draft May 15, 2024 08:25
Comment on lines +12 to +13
/// @notice Checks if the component is bootstrapped
function bootstrapped() external view returns(bool);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is better placed in a Lifecycle facet and generalized as a stage() method that returns the lifecycle stage of a subnet.

Comment on lines 4 to 8
/// @title Subnet interface
interface ISubnet {
/// @notice Checks if the subnet is now bootstrapped
function bootstrapped() external view returns(bool);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you elaborate on what responsibility/scope this interface would hold going forward?

Comment on lines +19 to +20
/// @notice Deposit into the genesis balance of the address
function deposit(SubnetGenesis storage self, address addr, uint256 amount) internal {
Copy link
Contributor

Choose a reason for hiding this comment

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

This OOP-style pattern is nice, since LibSubnetGenesis can be associated with the SubnetGenesis type via using to write code like this:

using LibSubnetGenesis for SubnetGenesis;

genesis.deposit(addr, amount);

Comment on lines +23 to +29
if (exists) {
self.balances.set(addr, existingAmount + amount);
} else {
self.balances.set(addr, amount);
}

self.circSupply += amount;
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be simplified by doing the addition to circSupply sooner, and using an early return in the if. But it's probably clearer this way.

@@ -6,3 +6,7 @@ pragma solidity ^0.8.23;
enum ConsensusType {
Fendermint
}

enum Consensus {
ProofOfPower
Copy link
Contributor

Choose a reason for hiding this comment

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

What exactly is ProofOfPower?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

2 participants