Skip to content

Commit

Permalink
Set FxChildTunnel on PolygonRoot constructor
Browse files Browse the repository at this point in the history
Instead of setting the child tunnel with setFxChildTunnel(), which could be prone to front-running.
  • Loading branch information
cygnusv committed Jul 25, 2023
1 parent 7b4a2f8 commit ee08414
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions contracts/xchain/PolygonRoot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ contract PolygonRoot is FxBaseRootTunnel, IUpdatableStakeInfo {
constructor(
address _checkpointManager,
address _fxRoot,
address _source
address _source,
address _fxChildTunnel
)
FxBaseRootTunnel(_checkpointManager, _fxRoot)
{
require(_source != address(0), "Wrong input parameters");
source = _source;
fxChildTunnel = _fxChildTunnel;
}

/**
Expand All @@ -35,17 +37,28 @@ contract PolygonRoot is FxBaseRootTunnel, IUpdatableStakeInfo {
function _processMessageFromChild(bytes memory data) internal override {}

function updateOperator(address stakingProvider, address operator) external override onlySource {
bytes memory message = abi.encodeWithSelector(IUpdatableStakeInfo.updateOperator.selector, stakingProvider, operator);
bytes memory message = abi.encodeWithSelector(
IUpdatableStakeInfo.updateOperator.selector,
stakingProvider,
operator
);
_sendMessageToChild(message);
}

function updateAmount(address stakingProvider, uint96 amount) external override onlySource {
bytes memory message = abi.encodeWithSelector(IUpdatableStakeInfo.updateAmount.selector, stakingProvider, amount);
bytes memory message = abi.encodeWithSelector(
IUpdatableStakeInfo.updateAmount.selector,
stakingProvider,
amount
);
_sendMessageToChild(message);
}

function batchUpdate(bytes32[] calldata updateInfo) external override onlySource {
bytes memory message = abi.encodeWithSelector(IUpdatableStakeInfo.batchUpdate.selector, updateInfo);
bytes memory message = abi.encodeWithSelector(
IUpdatableStakeInfo.batchUpdate.selector,
updateInfo
);
_sendMessageToChild(message);
}
}

0 comments on commit ee08414

Please sign in to comment.