Skip to content

Commit 0880dc6

Browse files
committed
Audit fixes
1 parent 183770f commit 0880dc6

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

synd-contracts/src/staking/GasAggregator.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ contract GasAggregator is Ownable(msg.sender), Pausable, EpochTracker {
146146
/// @param maxAppchainsToQuery The new maximum number of appchains to query
147147
event UpdateMaxAppchainsToQuery(uint256 indexed epoch, uint256 maxAppchainsToQuery);
148148

149+
/// @notice Emitted when the factory address and bytecode is set
150+
/// @param factoryAddress The address of the factory contract
151+
/// @param bytecodeHash The bytecode hash of the proxy that the factory deploys
152+
event FactorySet(address indexed factoryAddress, bytes32 bytecodeHash);
153+
149154
/*//////////////////////////////////////////////////////////////
150155
CONSTRUCTOR
151156
//////////////////////////////////////////////////////////////*/
@@ -384,6 +389,7 @@ contract GasAggregator is Ownable(msg.sender), Pausable, EpochTracker {
384389
require(bytecodeHash != 0, InvalidDataHash());
385390
factory = newFactory;
386391
syndicateProxyBytecodeHash = bytecodeHash;
392+
emit FactorySet(newFactory, bytecodeHash);
387393
}
388394

389395
/**

synd-contracts/src/staking/GasArchive.sol

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -291,18 +291,18 @@ contract GasArchive is Initializable, OwnableUpgradeable, IGasDataProvider, UUPS
291291
/// @dev Verifies the proof data of the sequencing chain's proof against the confirmed seq chain block hash
292292
/// @param seqChainID The sequencing chain ID
293293
/// @param sendRoot The send root stored in the the Arbitrum Outbox contract that the eth proof was generated for, unused if seqChainID == settlementChainID
294-
/// @param ethBlockHeader RLP-encoded Ethereum block header, unused if seqChainID == settlementChainID
295-
/// @param ethAccountProof Merkle proof of the bridge contract account, unused if seqChainID == settlementChainID
296-
/// @param ethStorageProof Merkle proof of the storage slot containing the block hash, unused if seqChainID == settlementChainID
294+
/// @param seqParentBlockHeader RLP-encoded block header of the parent chain of the sequencing chain, unused if seqChainID == settlementChainID
295+
/// @param seqParentAccountProof Merkle proof of the bridge contract account, unused if seqChainID == settlementChainID
296+
/// @param seqParentStorageProof Merkle proof of the storage slot containing the block hash, unused if seqChainID == settlementChainID
297297
/// @param seqBlockHeader RLP-encoded sequencing chain block header
298298
/// @param seqAccountProof Merkle proof of the GasAggregator account
299299
/// @param seqStorageProof Merkle proof of the epoch data storage slot
300300
function confirmEpochDataHash(
301301
uint256 seqChainID,
302302
bytes32 sendRoot,
303-
bytes calldata ethBlockHeader,
304-
bytes[] calldata ethAccountProof,
305-
bytes[] calldata ethStorageProof,
303+
bytes calldata seqParentBlockHeader,
304+
bytes[] calldata seqParentAccountProof,
305+
bytes[] calldata seqParentStorageProof,
306306
bytes calldata seqBlockHeader,
307307
bytes[] calldata seqAccountProof,
308308
bytes[] calldata seqStorageProof
@@ -315,15 +315,15 @@ contract GasArchive is Initializable, OwnableUpgradeable, IGasDataProvider, UUPS
315315
}
316316

317317
if ($.seqChainSettlesToBase[seqChainID]) {
318-
require($.setBlockHashes[keccak256(ethBlockHeader)], InvalidSetBlockHeader());
318+
require($.setBlockHashes[keccak256(seqParentBlockHeader)], InvalidSetBlockHeader());
319319
} else {
320-
require($.ethBlockHashes[keccak256(ethBlockHeader)], InvalidEthBlockHeader());
320+
require($.ethBlockHashes[keccak256(seqParentBlockHeader)], InvalidEthBlockHeader());
321321
}
322322

323323
bytes32 verifiedSeqChainBlockHash = _getSlotValueFromProof({
324-
blockHeader: ethBlockHeader,
325-
accountProof: ethAccountProof,
326-
storageProof: ethStorageProof,
324+
blockHeader: seqParentBlockHeader,
325+
accountProof: seqParentAccountProof,
326+
storageProof: seqParentStorageProof,
327327
account: $.seqChainOutbox[seqChainID],
328328
storageSlot: keccak256(abi.encode(sendRoot, SEND_ROOT_STORAGE_SLOT))
329329
});
@@ -427,7 +427,7 @@ contract GasArchive is Initializable, OwnableUpgradeable, IGasDataProvider, UUPS
427427
stack: _RLPItemsFromProofBytes(accountProof)
428428
}).toRlpItem();
429429

430-
// If the account does not exist, return the hash of an empty trie.
430+
// If the account does not exist in the proof, revert with AccountDoesNotExistInProof error.
431431
require(accountRlp.len > 0, AccountDoesNotExistInProof());
432432

433433
RLPReader.RLPItem memory slotContents = MerklePatriciaProofVerifier.extractProofValue({

synd-contracts/src/staking/STAKING_EMISSIONS_AUDIT_GUIDE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ bytes32 public syndicateProxyBytecodeHash;
190190

191191
#### Key Functions:
192192

193-
##### `addChain(uint256 chainId, uint256 addChainFee)`
193+
##### `addChain(uint256 chainId) external payable`
194194
- Registers an appchain for gas tracking
195-
- Requires fee payment in SYND tokens
196-
- Only called by authorized appchain contracts
195+
- Permissionless: anyone can call by paying the required fee (owner pays no fee)
196+
- Chain must exist at deterministic CREATE2 address (verified via factory + bytecode hash)
197197

198198
##### `aggregateTokensUsed(uint256 epochIndex, uint256[] calldata chainIds, uint256[] calldata tokensUsed)`
199199
- Aggregates gas usage for completed epochs
@@ -634,8 +634,8 @@ deposit(epochIndex) with 1001 ETH:
634634
- **Anyone**: Can submit proofs and epoch data (permissionless validation)
635635

636636
#### GasAggregator:
637-
- **Owner**: Can pause, set factory, manage parameters
638-
- **Appchains**: Can add themselves (with fee payment)
637+
- **Owner**: Can pause, set factory, manage parameters, add/remove chains without fee
638+
- **Anyone**: Can register chains by paying the `addChainFee` (chain must exist at deterministic address)
639639
- **Anyone**: Can aggregate completed epoch data
640640

641641
#### Reward Pools:

0 commit comments

Comments
 (0)