@@ -33,7 +33,7 @@ contract DataProcessorModule is IDataProcessorModule, AccessController {
3333 }
3434 }
3535
36- // ========================= Owner-only Functions ========================= //
36+ // ========================= Setup Functions ========================= //
3737
3838 /// @inheritdoc IDataProcessorModule
3939 function setDataProcessorProgramHash (bytes32 programHash ) external onlyOwner {
@@ -52,6 +52,12 @@ contract DataProcessorModule is IDataProcessorModule, AccessController {
5252 emit ProgramHashesDisabled (programHashes);
5353 }
5454
55+ /// @inheritdoc IDataProcessorModule
56+ function isProgramHashAuthorized (bytes32 programHash ) public view returns (bool ) {
57+ DataProcessorModuleStorage storage ms = moduleStorage ();
58+ return ms.authorizedProgramHashes[programHash];
59+ }
60+
5561 // ========================= Core Functions ========================= //
5662
5763 /// @inheritdoc IDataProcessorModule
@@ -78,6 +84,8 @@ contract DataProcessorModule is IDataProcessorModule, AccessController {
7884 function authenticateDataProcessorTaskExecution (TaskData calldata taskData ) external {
7985 DataProcessorModuleStorage storage ms = moduleStorage ();
8086
87+ require (taskData.taskHashLow >> 128 == 0 , "INVALID taskHashLow " );
88+ require (taskData.taskHashHigh >> 128 == 0 , "INVALID taskHashHigh " );
8189 bytes32 taskHash = bytes32 ((taskData.taskHashHigh << 128 ) | taskData.taskHashLow);
8290
8391 if (ms.cachedTasksResult[taskHash].status == TaskStatus.FINALIZED) {
@@ -101,7 +109,7 @@ contract DataProcessorModule is IDataProcessorModule, AccessController {
101109
102110 for (uint8 i = 0 ; i < taskData.mmrData.length ; i++ ) {
103111 MmrData memory mmr = taskData.mmrData[i];
104- bytes32 usedMmrRoot = loadMmrRoot ( mmr.mmrId, mmr.mmrSize, mmr.chainId) ;
112+ bytes32 usedMmrRoot = LibSatellite. satelliteStorage ().mmrs[ mmr.chainId][ mmr.mmrId][POSEIDON_HASHING_FUNCTION].mmrSizeToRoot[ mmr.mmrSize] ;
105113 if (usedMmrRoot == bytes32 (0 )) {
106114 revert InvalidMmrRoot ();
107115 }
@@ -122,14 +130,20 @@ contract DataProcessorModule is IDataProcessorModule, AccessController {
122130 revert InvalidFact ();
123131 }
124132
133+ require (taskData.taskResultHigh >> 128 == 0 , "INVALID taskResultHigh " );
134+ require (taskData.taskResultLow >> 128 == 0 , "INVALID taskResultLow " );
125135 bytes32 taskResult = bytes32 ((taskData.taskResultHigh << 128 ) | taskData.taskResultLow);
126136
127137 // Store the task result
128138 ms.cachedTasksResult[taskHash] = TaskResult ({status: TaskStatus.FINALIZED, result: taskResult});
129139 emit TaskFinalized (taskHash, taskResult);
130140 }
131141
132- // ========================= View Functions ========================= //
142+ /// @inheritdoc IDataProcessorModule
143+ function getDataProcessorTaskStatus (bytes32 taskCommitment ) external view returns (TaskStatus) {
144+ DataProcessorModuleStorage storage ms = moduleStorage ();
145+ return ms.cachedTasksResult[taskCommitment].status;
146+ }
133147
134148 /// @inheritdoc IDataProcessorModule
135149 function getDataProcessorFinalizedTaskResult (bytes32 taskCommitment ) external view returns (bytes32 ) {
@@ -140,31 +154,4 @@ contract DataProcessorModule is IDataProcessorModule, AccessController {
140154 }
141155 return ms.cachedTasksResult[taskCommitment].result;
142156 }
143-
144- /// @inheritdoc IDataProcessorModule
145- function getDataProcessorTaskStatus (bytes32 taskCommitment ) external view returns (TaskStatus) {
146- DataProcessorModuleStorage storage ms = moduleStorage ();
147- return ms.cachedTasksResult[taskCommitment].status;
148- }
149-
150- /// @inheritdoc IDataProcessorModule
151- function isProgramHashAuthorized (bytes32 programHash ) public view returns (bool ) {
152- DataProcessorModuleStorage storage ms = moduleStorage ();
153- return ms.authorizedProgramHashes[programHash];
154- }
155-
156- // ========================= Internal Functions ========================= //
157-
158- /// @notice Load MMR root from cache with given mmrId and mmrSize
159- function loadMmrRoot (uint256 mmrId , uint256 mmrSize , uint256 chainId ) internal view returns (bytes32 ) {
160- ISatellite.SatelliteStorage storage s = LibSatellite.satelliteStorage ();
161- return s.mmrs[chainId][mmrId][POSEIDON_HASHING_FUNCTION].mmrSizeToRoot[mmrSize];
162- }
163-
164- /// @notice Returns the leaf of standard merkle tree
165- function standardEvmHDPLeafHash (bytes32 value ) internal pure returns (bytes32 ) {
166- bytes32 firstHash = keccak256 (abi.encode (value));
167- bytes32 leaf = keccak256 (abi.encode (firstHash));
168- return leaf;
169- }
170157}
0 commit comments