-
Notifications
You must be signed in to change notification settings - Fork 11
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 application refinements #145
Changes from all commits
bfdacd0
eef00b2
f04b3b4
326dd53
1f22f06
ac23df5
f7d3972
073062f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -24,6 +24,8 @@ contract TACoChildApplication is ITACoRootToChild, ITACoChildApplication, Initia | |||||
ITACoChildToRoot public immutable rootApplication; | ||||||
address public coordinator; | ||||||
|
||||||
uint96 public immutable minimumAuthorization; | ||||||
|
||||||
mapping(address => StakingProviderInfo) public stakingProviderInfo; | ||||||
mapping(address => address) public stakingProviderFromOperator; | ||||||
|
||||||
|
@@ -35,12 +37,14 @@ contract TACoChildApplication is ITACoRootToChild, ITACoChildApplication, Initia | |||||
_; | ||||||
} | ||||||
|
||||||
constructor(ITACoChildToRoot _rootApplication) { | ||||||
constructor(ITACoChildToRoot _rootApplication, uint96 _minimumAuthorization) { | ||||||
require( | ||||||
address(_rootApplication) != address(0), | ||||||
"Address for root application must be specified" | ||||||
); | ||||||
require(_minimumAuthorization > 0, "Minimum authorization must be specified"); | ||||||
rootApplication = _rootApplication; | ||||||
minimumAuthorization = _minimumAuthorization; | ||||||
_disableInitializers(); | ||||||
} | ||||||
|
||||||
|
@@ -79,16 +83,20 @@ contract TACoChildApplication is ITACoRootToChild, ITACoChildApplication, Initia | |||||
StakingProviderInfo storage info = stakingProviderInfo[stakingProvider]; | ||||||
address oldOperator = info.operator; | ||||||
|
||||||
if (stakingProvider != address(0) && operator != oldOperator) { | ||||||
info.operator = operator; | ||||||
// Update operator to provider mapping | ||||||
stakingProviderFromOperator[oldOperator] = address(0); | ||||||
stakingProviderFromOperator[operator] = stakingProvider; | ||||||
info.operatorConfirmed = false; | ||||||
// TODO placeholder to notify Coordinator | ||||||
if (stakingProvider == address(0) || operator == oldOperator) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry if it's a dumb question, but why not manage this with a
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not dumb question. Because there is no real point to fail in xchain txs, it will be just skipped and that's it. But some sanity check to decrease gas consumption we want to do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it, thanks! |
||||||
return; | ||||||
} | ||||||
|
||||||
emit OperatorUpdated(stakingProvider, operator); | ||||||
info.operator = operator; | ||||||
// Update operator to provider mapping | ||||||
stakingProviderFromOperator[oldOperator] = address(0); | ||||||
if (operator != address(0)) { | ||||||
stakingProviderFromOperator[operator] = stakingProvider; | ||||||
} | ||||||
info.operatorConfirmed = false; | ||||||
// TODO placeholder to notify Coordinator | ||||||
|
||||||
emit OperatorUpdated(stakingProvider, operator); | ||||||
} | ||||||
|
||||||
function _updateAuthorization(address stakingProvider, uint96 amount) internal { | ||||||
|
@@ -105,7 +113,10 @@ contract TACoChildApplication is ITACoRootToChild, ITACoChildApplication, Initia | |||||
require(msg.sender == coordinator, "Only Coordinator allowed to confirm operator"); | ||||||
address stakingProvider = stakingProviderFromOperator[_operator]; | ||||||
StakingProviderInfo storage info = stakingProviderInfo[stakingProvider]; | ||||||
require(info.authorized > 0, "No stake associated with the operator"); | ||||||
require( | ||||||
info.authorized >= minimumAuthorization, | ||||||
"Authorization must be greater than minimum" | ||||||
); | ||||||
// TODO maybe allow second confirmation, just do not send root call? | ||||||
require(!info.operatorConfirmed, "Can't confirm same operator twice"); | ||||||
info.operatorConfirmed = true; | ||||||
|
@@ -117,7 +128,10 @@ contract TACoChildApplication is ITACoRootToChild, ITACoChildApplication, Initia | |||||
contract TestnetTACoChildApplication is AccessControlUpgradeable, TACoChildApplication { | ||||||
bytes32 public constant UPDATE_ROLE = keccak256("UPDATE_ROLE"); | ||||||
|
||||||
constructor(ITACoChildToRoot _rootApplication) TACoChildApplication(_rootApplication) {} | ||||||
constructor( | ||||||
ITACoChildToRoot _rootApplication, | ||||||
uint96 _minimumAuthorization | ||||||
) TACoChildApplication(_rootApplication, _minimumAuthorization) {} | ||||||
|
||||||
function initialize(address _coordinator, address[] memory updaters) external initializer { | ||||||
coordinator = _coordinator; | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,27 +3,28 @@ deployment: | |
chain_id: 80001 | ||
|
||
artifacts: | ||
dir: ./deployment/artifacts/ | ||
filename: lynx.json | ||
dir: ./deployment/artifacts/ | ||
filename: lynx.json | ||
|
||
contracts: | ||
- MockPolygonChild | ||
- ProxyAdmin | ||
- LynxTACoChildApplication: | ||
_rootApplication: $MockPolygonChild | ||
- TransparentUpgradeableProxy: | ||
_logic: $LynxTACoChildApplication | ||
admin_: $ProxyAdmin | ||
_data: $bytes:0x | ||
- LynxRitualToken: | ||
_totalSupplyOfTokens: 10000000000000000000000000 | ||
- Coordinator: | ||
_application: $TransparentUpgradeableProxy:LynxTACoChildApplication | ||
_timeout: 3600 | ||
_maxDkgSize: 4 | ||
_admin: $deployer | ||
_currency: $LynxRitualToken | ||
_feeRatePerSecond: 1 | ||
- GlobalAllowList: | ||
_coordinator: $Coordinator | ||
_admin: $deployer | ||
- MockPolygonChild | ||
- ProxyAdmin | ||
- LynxTACoChildApplication: | ||
_rootApplication: $MockPolygonChild | ||
_minimumAuthorization: 40000000000000000000000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something to think about here is that the value used in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's why we need a separate constants section or file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed. Now that it is a yml file, perhaps we can specify a dependent constants.yml file ... that allows for a dictionary of variables/values to be specified. I'm less familiar with yml spec. |
||
- TransparentUpgradeableProxy: | ||
_logic: $LynxTACoChildApplication | ||
admin_: $ProxyAdmin | ||
_data: $bytes:0x | ||
- LynxRitualToken: | ||
_totalSupplyOfTokens: 10000000000000000000000000 | ||
- Coordinator: | ||
_application: $TransparentUpgradeableProxy:LynxTACoChildApplication | ||
_timeout: 3600 | ||
_maxDkgSize: 4 | ||
_admin: $deployer | ||
_currency: $LynxRitualToken | ||
_feeRatePerSecond: 1 | ||
- GlobalAllowList: | ||
_coordinator: $Coordinator | ||
_admin: $deployer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this constant represent? What's the multiplier? Is this something for precision?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, name is not perfect. Thing is we have variable called
rewardPerToken
. With increase of precision now it's actually not per token but per 10000 tokens (that multiplier).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REWARD_CALCULATION_MULTIPLIER
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, this name suits better for
FLOATING_POINT_DIVISOR