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

Metadata with confirmation #230

Merged
merged 42 commits into from
Oct 9, 2023
Merged

Metadata with confirmation #230

merged 42 commits into from
Oct 9, 2023

Conversation

cryptoAtwill
Copy link
Collaborator

Update the metadata through confirmation.

cryptoAtwill and others added 12 commits October 6, 2023 09:47
Base automatically changed from store-validator-changes to dev October 6, 2023 09:59
@@ -211,6 +211,7 @@ pub mod gateway_diamond {
pub static GATEWAYDIAMOND_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> =
::ethers::contract::Lazy::new(__abi);
#[rustfmt::skip]
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

Merge conflict.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

resolved

@@ -227,11 +227,15 @@ pub mod subnet_actor_diamond {
pub static SUBNETACTORDIAMOND_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> =
::ethers::contract::Lazy::new(__abi);
#[rustfmt::skip]
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

Merge conflict.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

resolved

@@ -56,8 +57,13 @@ contract SubnetActorDiamond {
s.majorityPercentage = params.majorityPercentage;
s.currentSubnetHash = s.parentId.createSubnetId(address(this)).toHash();

// We hardcode the current limit for active validators to 100 per Tendermint consensus
// We hardcode the current limit for active validators to 100 per Tendermint consensus
s.validatorSet.activeLimit = 100;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we make this into a constructor argument?

uint64 configurationNumber = recordChange({
changes: changes,
validator: validator,
op: StakingOperation.Withdraw,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this Withdraw on purpose?

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's a bug, I fixed it already.


// confirm validators deposit immediately
LibStaking.depositWithConfirm(msg.sender, msg.value);
LibStaking.setMetadataWithConfirm(msg.sender, metadata);
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 where we discussed that we'll have to do https://github.com/consensus-shipyard/fendermint/issues/305 and that it will be as simple as checking that the address(metadata) == msg.sender.

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's added

@cryptoAtwill
Copy link
Collaborator Author

@aakoshh The check of metadata is added, please take a look again.

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.

LGTM. Just a few outstanding comments.

I see that this PR conflicts with a few of the things I wanted to address next on my PR #228, mainly:

  • Remove the f4 for validators.
  • Have public key explicitly in the validator struct instead of as part of the metadata

I would suggest merging this one so I can merge this one and continue in #228?

src/SubnetActorDiamond.sol Outdated Show resolved Hide resolved
src/SubnetActorDiamond.sol Outdated Show resolved Hide resolved

/// @notice Perform upsert operation to the withdraw changes, return total value to withdraw
/// @notice of the validator.
/// Each insert will increment the configuration number by 1, update will not.
function withdrawRequest(StakingChangeLog storage changes, address validator, uint256 amount) internal {
bytes memory payload = abi.encode(amount);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need to abi.encode the amount?

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed sync, we are encoding all changes inside the payload to be more flexible with future changes. If we use this approach we need to have the encoding well-documented for users to be able to interpret what is happening easily.

function _join(address validatorAddress) internal {
vm.prank(validatorAddress);
vm.deal(validatorAddress, DEFAULT_COLLATERAL_AMOUNT + 1);
// function _join(address validatorAddress) internal {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove this test or uncomment it?

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed sync, we will keep them commented until we come back to writing a better test coverage for the gateway.

s.changeSet.nextConfigurationNumber = LibStaking.INITIAL_CONFIGURATION_NUMBER;
// The startConfiguration number is also 1 to match with nextConfigurationNumber, indicating we have
// empty validator change logs
s.changeSet.startConfigurationNumber = LibStaking.INITIAL_CONFIGURATION_NUMBER;
Copy link
Contributor

Choose a reason for hiding this comment

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

So startConfigurationNumber is the "first unapplied configuration"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah...

Copy link
Contributor

@aakoshh aakoshh left a comment

Choose a reason for hiding this comment

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

Thanks, looking good 👍

@adlrocha adlrocha merged commit f23c2b9 into dev Oct 9, 2023
@adlrocha adlrocha deleted the validator-metadata-change branch October 9, 2023 08:55
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.

4 participants