Skip to content

Commit

Permalink
Merge pull request #69 from uprendis/feature/improve-redirection
Browse files Browse the repository at this point in the history
Improve redirection
  • Loading branch information
uprendis authored Mar 6, 2024
2 parents e868f86 + 8f999b0 commit 6a4b836
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
16 changes: 14 additions & 2 deletions contracts/sfc/SFC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,20 @@ contract SFC is SFCBase, Version {
_syncValidator(validatorID, true);
}

function initiateRedirection(address from, address to) onlyOwner external {
require(getRedirection[from] != to, "already compelte");
function setRedirectionAuthorizer(address v) onlyOwner external {
require(redirectionAuthorizer != v, "same");
redirectionAuthorizer = v;
}

event AnnouncedRedirection(address indexed from, address indexed to);

function announceRedirection(address to) external {
emit AnnouncedRedirection(msg.sender, to);
}

function initiateRedirection(address from, address to) external {
require(msg.sender == redirectionAuthorizer, "not authorized");
require(getRedirection[from] != to, "already complete");
require(from != to, "same address");
getRedirectionRequest[from] = to;
}
Expand Down
5 changes: 5 additions & 0 deletions contracts/sfc/SFCI.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface SFCI {

event DeactivatedValidator(uint256 indexed validatorID, uint256 deactivatedEpoch, uint256 deactivatedTime);
event ChangedValidatorStatus(uint256 indexed validatorID, uint256 status);
event AnnouncedRedirection(address indexed from, address indexed to);

function currentSealedEpoch() external view returns (uint256);

Expand Down Expand Up @@ -154,6 +155,10 @@ interface SFCI {

function migrateValidatorPubkeyUniquenessFlag(uint256 start, uint256 end) external;

function setRedirectionAuthorizer(address v) external;

function announceRedirection(address to) external;

function initiateRedirection(address from, address to) external;

function redirect(address to) external;
Expand Down
2 changes: 2 additions & 0 deletions contracts/sfc/SFCState.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ contract SFCState is Initializable, Ownable {

mapping(bytes32 => uint256) internal pubkeyHashToValidatorID;

address public redirectionAuthorizer;

mapping(address => address) public getRedirectionRequest;

mapping(address => address) public getRedirection;
Expand Down
2 changes: 1 addition & 1 deletion test/SFC.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ contract('SFC', async ([firstValidator, secondValidator, thirdValidator]) => {
});

it('Returns the version of the current implementation', async () => {
expect((await this.sfc.version()).toString()).to.equals('0x333034');
expect((await this.sfc.version()).toString()).to.equals('0x333035');
});

it('Reverts on transfers', async () => {
Expand Down

0 comments on commit 6a4b836

Please sign in to comment.