Skip to content

Commit 0c4f5db

Browse files
authored
feat: relaxed constraints on setViewContract (#310)
issue #303 demands relaxation before mainnet. To be rescinded later prior to mainnet deployment
1 parent d58232d commit 0c4f5db

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

service_contracts/abi/FilecoinWarmStorageService.abi.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,17 +1449,6 @@
14491449
],
14501450
"anonymous": false
14511451
},
1452-
{
1453-
"type": "error",
1454-
"name": "AddressAlreadySet",
1455-
"inputs": [
1456-
{
1457-
"name": "field",
1458-
"type": "uint8",
1459-
"internalType": "enum Errors.AddressField"
1460-
}
1461-
]
1462-
},
14631452
{
14641453
"type": "error",
14651454
"name": "AddressEmptyCode",

service_contracts/src/FilecoinWarmStorageService.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,16 @@ contract FilecoinWarmStorageService is
431431
* @param _viewContract Address of the view contract
432432
*/
433433
function setViewContract(address _viewContract) external onlyOwner {
434+
// Ensure the view contract address is not the zero address
434435
require(_viewContract != address(0), Errors.ZeroAddress(Errors.AddressField.View));
435-
require(viewContractAddress == address(0), Errors.AddressAlreadySet(Errors.AddressField.View));
436+
437+
// Require that the existing set address is still zero (one-time setup only)
438+
// NOTE: This check is commented out to allow setting the view contract easily during migrations prior to GA
439+
// GH ISSUE: https://github.com/FilOzone/filecoin-services/issues/303
440+
// This check needs to be re-enabled before mainnet deployment to prevent changing the view contract later.
441+
442+
// require(viewContractAddress == address(0), Errors.AddressAlreadySet(Errors.AddressField.View));
443+
436444
viewContractAddress = _viewContract;
437445
emit ViewContractSet(_viewContract);
438446
}

service_contracts/test/FilecoinWarmStorageService.t.sol

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4114,10 +4114,14 @@ contract FilecoinWarmStorageServiceUpgradeTest is Test {
41144114
warmStorageService.setViewContract(address(0x456));
41154115

41164116
// Test that it cannot be set again (one-time only)
4117-
FilecoinWarmStorageServiceStateView newViewContract =
4118-
new FilecoinWarmStorageServiceStateView(warmStorageService);
4119-
vm.expectRevert(abi.encodeWithSelector(Errors.AddressAlreadySet.selector, Errors.AddressField.View));
4120-
warmStorageService.setViewContract(address(newViewContract));
4117+
// NOTE: This check is commented out to allow setting the view contract easily during migrations prior to GA
4118+
// GH ISSUE: https://github.com/FilOzone/filecoin-services/issues/303
4119+
// This check needs to be re-enabled before mainnet deployment to prevent changing the view contract later.
4120+
4121+
// FilecoinWarmStorageServiceStateView newViewContract =
4122+
// new FilecoinWarmStorageServiceStateView(warmStorageService);
4123+
// vm.expectRevert(abi.encodeWithSelector(Errors.AddressAlreadySet.selector, Errors.AddressField.View));
4124+
// warmStorageService.setViewContract(address(newViewContract));
41214125

41224126
// Test that zero address is rejected (would need a new contract to test this properly)
41234127
// This is now unreachable in this test since view contract is already set

0 commit comments

Comments
 (0)