Skip to content

Commit c4732ca

Browse files
committed
consistent behavior for granting and revoking dao write permission to storage
1 parent 352f4f6 commit c4732ca

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

script/automata/ConfigAutomataDao.s.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ contract ConfigAutomataDao is Script {
2323
address enclaveIdentityHelper = vm.envAddress("ENCLAVE_IDENTITY_HELPER");
2424
address fmspcTcbHelper = vm.envAddress("FMSPC_TCB_HELPER");
2525

26-
function updateStorageDao() public {
26+
function grantDao(address dao) public {
2727
vm.broadcast(privateKey);
2828

2929
AutomataDaoStorage pccsStorage = AutomataDaoStorage(pccsStorageAddr);
30-
pccsStorage.updateDao(pcsDaoAddr, pckDaoAddr, fmspcTcbDaoAddr, enclaveIdDaoAddr);
30+
pccsStorage.grantDao(dao);
3131
}
3232

3333
function revokeDao(address dao) public {

script/automata/DeployAutomataDao.s.sol

+5-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ contract DeployAutomataDao is P256Configuration {
5353
new AutomataFmspcTcbDao(address(pccsStorage), simulateVerify(), address(pcsDao), fmspcTcbHelper, x509);
5454
console.log("AutomataFmspcTcbDao deployed at: ", address(fmspcTcbDao));
5555

56-
pccsStorage.updateDao(address(pcsDao), address(pckDao), address(fmspcTcbDao), address(enclaveIdDao));
56+
// grants the DAOs permission to write to storage
57+
pccsStorage.grantDao(address(pcsDao));
58+
pccsStorage.grantDao(address(pckDao));
59+
pccsStorage.grantDao(address(enclaveIdDao));
60+
pccsStorage.grantDao(address(fmspcTcbDao));
5761
}
5862

5963
function deployStorage() public broadcastKey(privateKey) {

src/automata_pccs/shared/AutomataDaoStorage.sol

+2-12
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,8 @@ contract AutomataDaoStorage is AutomataTCBManager, IDaoAttestationResolver, Paus
4545
_unpause();
4646
}
4747

48-
function updateDao(address _pcsDao, address _pckDao, address _fmspcTcbDao, address _enclaveIdDao)
49-
external
50-
onlyOwner
51-
{
52-
_updateDao(_pcsDao, _pckDao, _fmspcTcbDao, _enclaveIdDao);
48+
function grantDao(address granted) external onlyOwner {
49+
_authorized_writers[granted] = true;
5350
}
5451

5552
function revokeDao(address revoked) external onlyOwner {
@@ -93,13 +90,6 @@ contract AutomataDaoStorage is AutomataTCBManager, IDaoAttestationResolver, Paus
9390
}
9491
}
9592

96-
function _updateDao(address _pcsDao, address _pckDao, address _fmspcTcbDao, address _enclaveIdDao) private {
97-
_authorized_writers[_pcsDao] = true;
98-
_authorized_writers[_pckDao] = true;
99-
_authorized_writers[_fmspcTcbDao] = true;
100-
_authorized_writers[_enclaveIdDao] = true;
101-
}
102-
10393
/// Attestation ID Computation
10494
bytes4 constant DATA_ATTESTATION_MAGIC = 0x54a09e9a;
10595
bytes4 constant HASH_ATTESTATION_MAGIC = 0x628ab4d2;

test/TestSetupBase.t.sol

+5-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ abstract contract TestSetupBase is Test {
6666
pck =
6767
new AutomataPckDao(address(pccsStorage), P256_VERIFIER, address(pcs), address(x509Lib), address(x509CrlLib));
6868

69-
pccsStorage.updateDao(address(pcs), address(pck), address(fmspcTcbDao), address(enclaveIdDao));
69+
// grants dao permissions to write to the storage
70+
pccsStorage.grantDao(address(pcs));
71+
pccsStorage.grantDao(address(pck));
72+
pccsStorage.grantDao(address(fmspcTcbDao));
73+
pccsStorage.grantDao(address(enclaveIdDao));
7074

7175
// grants admin address permission to read collaterals
7276
pccsStorage.setCallerAuthorization(admin, true);

test/tcb/TCBMockTest.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ contract TcbMockTest is PCSSetupBase, TCBConstants {
2020
);
2121

2222
vm.prank(admin);
23-
pccsStorage.updateDao(address(pcs), address(pck), address(tcb), address(enclaveIdDao));
23+
pccsStorage.grantDao(address(tcb));
2424
}
2525

2626
function testMockFmspcTcbTdxV3() public {

0 commit comments

Comments
 (0)