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

TACo Threshold Application #99

Merged
merged 12 commits into from
Aug 1, 2023
Merged

TACo Threshold Application #99

merged 12 commits into from
Aug 1, 2023

Conversation

KPrasch
Copy link
Member

@KPrasch KPrasch commented Jul 12, 2023

This PR introduces the contracts for installation of CBD+PRE as a threshold network application (Includes "Full PRE Application").

@vzotova vzotova changed the base branch from main to development July 14, 2023 21:06
def encode_function_data(initializer=None, *args):
"""Encodes the function call so we can work with an initializer.
Args:
initializer ([brownie.network.contract.ContractTx], optional):
Copy link
Member

Choose a reason for hiding this comment

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

brownie?

Copy link
Member

Choose a reason for hiding this comment

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

✔️

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin-upgradeable/contracts/access/OwnableUpgradeable.sol";
import "../threshold/IApplication.sol";
import "../threshold/IStaking.sol";
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 wondering if we could import these interfaces directly from the Threshold repo. See https://docs.apeworx.io/ape/stable/userguides/dependencies.html#github

Not necessarily a change we want to introduce now, but worth exploring

Copy link
Member

Choose a reason for hiding this comment

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

definitely, I planned do that (or at least try to) but forgot

Copy link
Member

Choose a reason for hiding this comment

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

✔️


StakingProviderInfo storage info = stakingProviderInfo[_stakingProvider];
require(info.tReward > 0, "No reward to withdraw");
uint96 value = info.tReward;
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it slightly more efficient to do the require after this line using value?

Copy link
Member

Choose a reason for hiding this comment

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

✔️

if (info.authorized == 0) {
_stakingProviderFromOperator[info.operator] = address(0);
info.operator = address(0);
info.operatorConfirmed == false;
Copy link
Member

Choose a reason for hiding this comment

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

Do you mean = here? Same in line 457 and 483. Although, before that, see my comment in confirmOperatorAddress()

Copy link
Member

Choose a reason for hiding this comment

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

yeah, I fixed this bug in #98, and added proper tests

/**
* @notice Make a confirmation by operator
*/
function confirmOperatorAddress() external {
Copy link
Member

Choose a reason for hiding this comment

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

Let's take a step back here. Can we work without the operator confirmation? Making the operator node transact in both Ethereum mainnet (even if it's only for 1 TX) and Polygon (for rituals in the Coordinator) seems a hurdle for operators.

Copy link
Member

Choose a reason for hiding this comment

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

in that case I'd do confirmation on Polygon but it increases complexity to do that properly
and I'm not in favor of removing it, same reason as before: helps to exclude people who does nothing

Copy link
Member

Choose a reason for hiding this comment

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

helps to exclude people who does nothing

Given that for the moment we will be using the Merkle rewards approach, the operator confirmation (regardless if it's on mainnet or Polygon) is something we can drop. But let's leave this for further discussion, and not this PR.

@vzotova vzotova changed the title [WIP] TACo Threshold Application TACo Threshold Application Jul 24, 2023
@vzotova vzotova marked this pull request as ready for review July 24, 2023 14:10
Copy link
Member

@derekpierre derekpierre left a comment

Choose a reason for hiding this comment

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

🎸 Skimmed the tests but looks good.

contracts/contracts/Adjudicator.sol Outdated Show resolved Hide resolved
scripts/deploy_taco_application.py Outdated Show resolved Hide resolved
scripts/deploy_taco_application.py Outdated Show resolved Hide resolved
Copy link
Member

@manumonti manumonti left a comment

Choose a reason for hiding this comment

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

LGTM!

I found some typos and TODO's which I suspect are easy to solve. But nothing relevant. Great job!

contracts/contracts/TACoApplication.sol Show resolved Hide resolved
contracts/contracts/TACoApplication.sol Outdated Show resolved Hide resolved
contracts/contracts/TACoApplication.sol Outdated Show resolved Hide resolved
contracts/contracts/TACoApplication.sol Outdated Show resolved Hide resolved
contracts/contracts/TACoApplication.sol Show resolved Hide resolved
contracts/contracts/TACoApplication.sol Show resolved Hide resolved
contracts/contracts/TACoApplication.sol Outdated Show resolved Hide resolved

mapping (address => uint256) public penaltyHistory;
mapping (bytes32 => bool) public evaluatedCFrags;

uint256[50] private reservedSlots;
Copy link
Member

Choose a reason for hiding this comment

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

Weren't we going to remove it and re-introduce it if we make Adjudicator upgradeable? For reference: #100

Copy link
Member

Choose a reason for hiding this comment

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

✔️

* @title PRE Application
* @notice Contract handles PRE configuration
*/
contract SimplePREApplication {
Copy link
Member

Choose a reason for hiding this comment

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

👋

/**
* @notice Make a confirmation by operator
*/
function confirmOperatorAddress() external {
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR, but I'd get rid of operator confirmation. See #103

* @param _penalty Penalty
* @param _investigator Investigator
*/
function slash(
Copy link
Member

Choose a reason for hiding this comment

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

Let's discuss (not for this PR) if we should not launch with slashing (or alternatively, deactivate slashing by tuning the parameters). See #104

@@ -6,7 +6,7 @@ pragma solidity ^0.8.0;
* @title StakeInfo
* @notice StakeInfo
Copy link
Member

Choose a reason for hiding this comment

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

We should change the docstrings here

Copy link
Member

Choose a reason for hiding this comment

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

✔️


simple_pre = project.SimplePREApplication.deploy(
# TODO deploy proxy
Copy link
Member

Choose a reason for hiding this comment

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

Opened an issue to track this: #105

/**
* @notice Bond operator
* @param _stakingProvider Staking provider address
* @param _operator Operator address. Must be a EOA, not a contract address
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param _operator Operator address. Must be a EOA, not a contract address
* @param _operator Operator address. Must be an EOA, not a contract address

Copy link
Member

Choose a reason for hiding this comment

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

✔️

Co-authored-by: Manuel Montenegro <manuel@nucypher.com>
Co-authored-by: David Núñez <david@nucypher.com>
Co-authored-by: Derek Pierre <derek.pierre@gmail.com>
@cygnusv cygnusv merged commit 5251e07 into development Aug 1, 2023
4 checks passed
@KPrasch KPrasch deleted the threshold-app branch September 15, 2023 14:21
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.

6 participants