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

feat(f3): manifest retrieval from smart contract #5321

Merged
merged 24 commits into from
Mar 3, 2025

Conversation

hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented Feb 21, 2025

Summary of changes

Changes introduced in this pull request:

  • implement F3 manifest contract polling flow

Manually tested the polling flow on mainnet and it worked as expected. To be tested on testnets once the contract is deployed.

Reference issue to close (if applicable)

Closes #5307

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@hanabi1224 hanabi1224 marked this pull request as ready for review February 24, 2025 12:21
@hanabi1224 hanabi1224 requested a review from a team as a code owner February 24, 2025 12:21
@hanabi1224 hanabi1224 requested review from LesnyRumcajs and sudo-shashank and removed request for a team February 24, 2025 12:21
.parse()
.expect("Invalid PeerId"),
f3_contract_address: Some(
EthAddress::from_str("0x476AC9256b9921C9C6a0fC237B7fE05fe9874F50")
Copy link
Member

Choose a reason for hiding this comment

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

The poll interval is managed via an environment variable. Would it make sense to expose the same functionality for the contract address?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@@ -43,6 +45,7 @@ pub const NEWEST_NETWORK_VERSION: NetworkVersion = NetworkVersion::V17;
const ENV_FOREST_BLOCK_DELAY_SECS: &str = "FOREST_BLOCK_DELAY_SECS";
const ENV_FOREST_PROPAGATION_DELAY_SECS: &str = "FOREST_PROPAGATION_DELAY_SECS";
const ENV_PLEDGE_RULE_RAMP: &str = "FOREST_PLEDGE_RULE_RAMP";
const DEFAULT_F3_CONTRACT_POLL_INTERVAL: Duration = Duration::from_secs(15 * 60);
Copy link
Member

Choose a reason for hiding this comment

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

Is it the same as in Lotus?

Copy link
Contributor Author

@hanabi1224 hanabi1224 Feb 25, 2025

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what are the best practices in Go, but would it make sense to check all pointer parameters in methods that they are not nil? There was recently a nil derefeence in go-f3.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In our case, the parameters are passed from Rust code which are not nil, the signature types that are generated by rust2go are pointers to avoid lifetime issues

Copy link
Member

Choose a reason for hiding this comment

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

It might be helpful to comment on this somewhere, given it's not obvious (at least for me).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

pub fn create_eth_call_message(contract: EthAddress) -> EthCallMessage {
// method ID of activationInformation()
static METHOD_ID: Lazy<EthBytes> =
Lazy::new(|| EthBytes::from_str("0x2587660d").expect("Infallible"));
Copy link
Member

Choose a reason for hiding this comment

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

We already have this elsewhere. It'd be great to make it a constant and document it, e.g., with a link to the FRC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you point to me where a similar method id lives?
BTW, added a link to where the constant is defined

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay, I thought you're duplicating the shed one.

Copy link
Member

Choose a reason for hiding this comment

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

It'd be great to add the original solidity contract as well for reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did not find the solidity contract in the original commit, need to ask around.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Co-authored-by: Hubert <hubert@chainsafe.io>
Ok(eth_return)
}

#[allow(clippy::indexing_slicing)]
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be safer to use get? Especially if the data structure changes, we don't want Forest to crash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Co-authored-by: Hubert <hubert@chainsafe.io>
@hanabi1224 hanabi1224 added this pull request to the merge queue Mar 3, 2025
Merged via the queue into main with commit fc2ef1e Mar 3, 2025
45 checks passed
@hanabi1224 hanabi1224 deleted the hm/f3-contract-manifest-integration branch March 3, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

F3 activation smart contract integration
3 participants