From 2de3d5a031e18b390be19e347547ca8446479feb Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 24 Aug 2023 22:26:32 -0400 Subject: [PATCH] FIX: V-WBT-VUL-005 + V-WBT-VUL-022 --- packages/contracts/contracts/SignatureBridge.sol | 6 +++--- packages/contracts/contracts/hashers/PoseidonHasher.sol | 2 +- packages/contracts/contracts/trees/MerkleForest.sol | 2 +- .../contracts/contracts/trees/MerkleTreeWithHistory.sol | 2 +- packages/contracts/contracts/utils/ChainIdWithType.sol | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/contracts/contracts/SignatureBridge.sol b/packages/contracts/contracts/SignatureBridge.sol index 6299704f4..5e2fa975b 100644 --- a/packages/contracts/contracts/SignatureBridge.sol +++ b/packages/contracts/contracts/SignatureBridge.sol @@ -156,7 +156,7 @@ contract SignatureBridge is Governable, ChainIdWithType, ProposalNonceTracker { // Parse resourceID from the data bytes32 resourceID = bytes32(data[0:32]); require( - this.isCorrectExecutionChain(resourceID), + isCorrectExecutionChain(resourceID), "SignatureBridge: Batch Executing on wrong chain" ); address handler = _resourceIdToHandlerAddress[resourceID]; @@ -171,11 +171,11 @@ contract SignatureBridge is Governable, ChainIdWithType, ProposalNonceTracker { address handlerAddress ) internal { require( - this.isCorrectExecutionChain(resourceID), + isCorrectExecutionChain(resourceID), "SignatureBridge::adminSetResourceWithSignature: Executing on wrong chain" ); require( - this.isCorrectExecutionChain(newResourceID), + isCorrectExecutionChain(newResourceID), "SignatureBridge::adminSetResourceWithSignature: Executing on wrong chain" ); require( diff --git a/packages/contracts/contracts/hashers/PoseidonHasher.sol b/packages/contracts/contracts/hashers/PoseidonHasher.sol index a1c15ec60..94829acd9 100644 --- a/packages/contracts/contracts/hashers/PoseidonHasher.sol +++ b/packages/contracts/contracts/hashers/PoseidonHasher.sol @@ -14,7 +14,7 @@ import { SnarkConstants } from "./SnarkConstants.sol"; /// @notice This contract is meant to be used for poseidon merkle trees and other poseidon based hashing. contract PoseidonHasher is SnarkConstants, IHasher { function hash1(uint256 value) public pure returns (uint256) { - require(array[i] < SNARK_SCALAR_FIELD, "Value not in field"); + require(value < SNARK_SCALAR_FIELD, "Value not in field"); uint256[1] memory input; input[0] = value; return PoseidonT2.poseidon(input); diff --git a/packages/contracts/contracts/trees/MerkleForest.sol b/packages/contracts/contracts/trees/MerkleForest.sol index ea01fbae3..8923038e4 100644 --- a/packages/contracts/contracts/trees/MerkleForest.sol +++ b/packages/contracts/contracts/trees/MerkleForest.sol @@ -106,7 +106,7 @@ contract MerkleForest is MerkleSystem { } /// @inheritdoc IMerkleSystem - function getZeroHash(uint32 index) external pure override returns (uint256) { + function getZeroHash(uint32 index) public pure override returns (uint256) { return LinkableIncrementalBinaryTree.zeros(index); } diff --git a/packages/contracts/contracts/trees/MerkleTreeWithHistory.sol b/packages/contracts/contracts/trees/MerkleTreeWithHistory.sol index 1effcaa1a..f15bf1957 100644 --- a/packages/contracts/contracts/trees/MerkleTreeWithHistory.sol +++ b/packages/contracts/contracts/trees/MerkleTreeWithHistory.sol @@ -24,7 +24,7 @@ abstract contract MerkleTreeWithHistory is MerkleSystem { } /// @inheritdoc IMerkleSystem - function getZeroHash(uint32 index) external view override returns (uint256) { + function getZeroHash(uint32 index) public view override returns (uint256) { return uint256(hasher.zeros(index)); } diff --git a/packages/contracts/contracts/utils/ChainIdWithType.sol b/packages/contracts/contracts/utils/ChainIdWithType.sol index 73a274541..33c8f7c54 100644 --- a/packages/contracts/contracts/utils/ChainIdWithType.sol +++ b/packages/contracts/contracts/utils/ChainIdWithType.sol @@ -39,7 +39,7 @@ abstract contract ChainIdWithType { /// @notice Verifies that the current chain matches the chain ID from the resource ID /// @param resourceID The resource ID to verify - function isCorrectExecutionChain(bytes32 resourceID) external view returns (bool) { + function isCorrectExecutionChain(bytes32 resourceID) public view returns (bool) { uint64 executionChainId = parseChainIdFromResourceId(resourceID); // Verify current chain matches chain ID from resource ID return uint256(getChainIdType()) == uint256(executionChainId);