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: contribute contracts stack #33

Merged
merged 27 commits into from
Oct 24, 2024
Merged

feat: contribute contracts stack #33

merged 27 commits into from
Oct 24, 2024

Conversation

kupermind
Copy link
Collaborator

  • Contribute contracts stack.

/// @return nonces Set of a single service multisig nonce.
function getMultisigNonces(address multisig) external view virtual returns (uint256[] memory nonces) {
nonces = new uint256[](1);
// The nonces are equal to the social off-chain activity corresponding multisig activity
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the main idea of contributors activity checking. This can be then modified / extended.

/// @author Andrey Lebedev - <[email protected]>
/// @author Tatiana Priemova - <[email protected]>
/// @author David Vilela - <[email protected]>
contract Contributors {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Storage contract for contributors. For now just a basic functionality, as it's proxy-implementation based.

/// @author Andrey Lebedev - <[email protected]>
/// @author Tatiana Priemova - <[email protected]>
/// @author David Vilela - <[email protected]>
contract ContributorsProxy {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Full analogy with recent Karma contracts.

Comment on lines 63 to 66
// Contribute agent Id
uint256 public constant AGENT_ID = 6;
// Contributor service config hash mock
bytes32 public constant CONFIG_HASH = 0x0000000000000000000000000000000000000000000000000000000000000006;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These values don't really matter, but we have to use something.

Copy link
Contributor

Choose a reason for hiding this comment

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

They do matter. We should upload a relevant config file and then take it's hash.

Copy link
Contributor

@DavidMinarsch DavidMinarsch left a comment

Choose a reason for hiding this comment

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

Nice start - let's make sure we add a graphic with the entities / contracts and ownership requirements. All ownership should reside with the Timelock representative on the target chain so Ethereum Olas Governance controls it

Comment on lines 28 to 37
struct ServiceInfo {
// Service Id
uint256 serviceId;
// Corresponding service multisig
address multisig;
// Staking instance address
address stakingInstance;
// Service owner address
address serviceOwner;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we duplicating all this info here when we can retrieve it from service registry etc?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is better for faster access. The read from other contracts would take more gas. Also, there's no backward correspondence between multisig and serviceId, or between serviceId and stakingInstance.


/// @dev Contributors initializer.
/// @param _manager Manager address.
function initialize(address _manager) external{
Copy link
Contributor

Choose a reason for hiding this comment

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

What was the idea behind doing another periphery<>core design here? Isn't it overengineered and a single contract would suffice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The activity management logic might change in the future or become multi-dimensional. This way we update implementation without changing current contributors activity storage.

}

/// @dev Sets service info for the social id.
/// @param socialId Social id.
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the social id?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this case it's unique X handle id.

/// @dev Sets contribute agent statues.
/// @param contributeAgents Contribute agent addresses.
/// @param statuses Corresponding whitelisting statues.
function setMechMarketplaceStatuses(address[] memory contributeAgents, bool[] memory statuses) external {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why mech marketplace is connected to this.. what's the puprose?

Copy link
Contributor

Choose a reason for hiding this comment

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

The entity which will report the activity is the contribute service. That should be different from the owner.

And what's the manager?

I need a graphic showing the intended design

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Typo related to copy-pasting :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will work on the graphics.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines 63 to 66
// Contribute agent Id
uint256 public constant AGENT_ID = 6;
// Contributor service config hash mock
bytes32 public constant CONFIG_HASH = 0x0000000000000000000000000000000000000000000000000000000000000006;
Copy link
Contributor

Choose a reason for hiding this comment

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

They do matter. We should upload a relevant config file and then take it's hash.

address indexed multisig, address stakingInstance);

// Contribute agent Id
uint256 public constant AGENT_ID = 6;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should deploy a meaningful agent id and then use it here

// Prepare Safe multisig data
uint256 localNonce = nonce;
bytes memory data = abi.encodePacked(address(0), fallbackHandler, address(0), address(0), uint256(0),
localNonce, "0x");
Copy link
Contributor

Choose a reason for hiding this comment

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

check if localNonce is safe as implemented

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

modified


/// @dev Creates and deploys a service for the contributor, and stakes it with a specified staking contract.
/// @notice The service cannot be registered again if it is currently staked.
/// @param socialId Contributor social Id.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we ensure uniqueness somehow?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Working on it now, what's more concerning is that we need to have a proof the msg.sender is the actual socialId holder from the Ceramic somehow. This info is off-chain only for now.

(serviceId, multisig) = _createAndDeploy(token, minStakingDeposit, numAgentInstances, threshold);

// Stake the service
_stake(socialId, serviceId, multisig, stakingInstance);
Copy link
Contributor

Choose a reason for hiding this comment

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

on the staking contract side we should ensure the configs are tight so that any wrong staking contract instance usage reverts here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point, let's use the verifier

function getMultisigNonces(address multisig) external view virtual returns (uint256[] memory nonces) {
nonces = new uint256[](1);
// The nonces are equal to the social off-chain activity corresponding multisig activity
nonces[0] = IContributors(contributorsProxy).mapMutisigActivities(multisig);
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

@kupermind kupermind merged commit e752848 into refactor Oct 24, 2024
1 check passed
@kupermind kupermind deleted the contribute branch October 24, 2024 12:28
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.

2 participants