Skip to content

Commit

Permalink
calldata better
Browse files Browse the repository at this point in the history
  • Loading branch information
invocamanman committed Jan 24, 2023
1 parent 4854cef commit bae5045
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 42 deletions.
4 changes: 2 additions & 2 deletions compiled-contracts/PolygonZkEVM.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled-contracts/PolygonZkEVMBridge.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled-contracts/PolygonZkEVMBridgeMock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled-contracts/PolygonZkEVMMock.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions contracts/PolygonZkEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ contract PolygonZkEVM is OwnableUpgradeable, EmergencyManager {
* @param batches Struct array which the necessary data to append new batces ot the sequence
*/
function sequenceBatches(
BatchData[] memory batches
BatchData[] calldata batches
) external ifNotEmergencyState onlyTrustedSequencer {
uint256 batchesNum = batches.length;
require(
Expand Down Expand Up @@ -914,11 +914,14 @@ contract PolygonZkEVM is OwnableUpgradeable, EmergencyManager {
/**
* @notice Allows a sequencer/user to force a batch of L2 transactions.
* This should be used only in extreme cases where the trusted sequencer does not work as expected
* Note The sequencer has certain degree of control on how non-forced and forced batches are ordered
* In order to assure that users force transactions will be processed properly, user must not sign any other transaction
* with the same nonce
* @param transactions L2 ethereum transactions EIP-155 or pre-EIP-155 with signature:
* @param maticAmount Max amount of MATIC tokens that the sender is willing to pay
*/
function forceBatch(
bytes memory transactions,
bytes calldata transactions,
uint256 maticAmount
) external ifNotEmergencyState isForceBatchAllowed {
// Calculate matic collateral
Expand Down Expand Up @@ -970,7 +973,7 @@ contract PolygonZkEVM is OwnableUpgradeable, EmergencyManager {
* @param batches Struct array which the necessary data to append new batces ot the sequence
*/
function sequenceForceBatches(
ForcedBatchData[] memory batches
ForcedBatchData[] calldata batches
) external ifNotEmergencyState isForceBatchAllowed {
uint256 batchesNum = batches.length;

Expand Down
14 changes: 7 additions & 7 deletions contracts/PolygonZkEVMBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ contract PolygonZkEVMBridge is
function bridgeMessage(
uint32 destinationNetwork,
address destinationAddress,
bytes memory metadata
bytes calldata metadata
) external payable ifNotEmergencyState {
require(
destinationNetwork != networkID,
Expand Down Expand Up @@ -280,7 +280,7 @@ contract PolygonZkEVMBridge is
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes memory metadata
bytes calldata metadata
) external ifNotEmergencyState {
// Verify leaf exist and it does not have been claimed
_verifyLeaf(
Expand Down Expand Up @@ -394,7 +394,7 @@ contract PolygonZkEVMBridge is
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes memory metadata
bytes calldata metadata
) external ifNotEmergencyState {
// Verify leaf exist and it does not have been claimed
_verifyLeaf(
Expand Down Expand Up @@ -445,7 +445,7 @@ contract PolygonZkEVMBridge is
string calldata name,
string calldata symbol,
uint8 decimals
) public view returns (address) {
) external view returns (address) {
bytes32 salt = keccak256(
abi.encodePacked(originNetwork, originTokenAddress)
);
Expand Down Expand Up @@ -476,7 +476,7 @@ contract PolygonZkEVMBridge is
function getTokenWrappedAddress(
uint32 originNetwork,
address originTokenAddress
) public view returns (address) {
) external view returns (address) {
return
tokenInfoToWrappedToken[
keccak256(abi.encodePacked(originNetwork, originTokenAddress))
Expand Down Expand Up @@ -523,7 +523,7 @@ contract PolygonZkEVMBridge is
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes memory metadata,
bytes calldata metadata,
uint8 leafType
) internal {
// Set and check nullifier
Expand Down Expand Up @@ -577,7 +577,7 @@ contract PolygonZkEVMBridge is
* @notice Function to check if an index is claimed or not
* @param index Index
*/
function isClaimed(uint256 index) public view returns (bool) {
function isClaimed(uint256 index) external view returns (bool) {
(uint256 wordPos, uint256 bitPos) = _bitmapPositions(index);
uint256 mask = (1 << bitPos);
return (claimedBitMap[wordPos] & mask) == mask;
Expand Down
10 changes: 5 additions & 5 deletions contracts/interfaces/IPolygonZkEVMBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ interface IPolygonZkEVMBridge {
function bridgeMessage(
uint32 destinationNetwork,
address destinationAddress,
bytes memory metadata
bytes calldata metadata
) external payable;

function claimAsset(
bytes32[32] memory smtProof,
bytes32[32] calldata smtProof,
uint32 index,
bytes32 mainnetExitRoot,
bytes32 rollupExitRoot,
Expand All @@ -27,11 +27,11 @@ interface IPolygonZkEVMBridge {
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes memory metadata
bytes calldata metadata
) external;

function claimMessage(
bytes32[32] memory smtProof,
bytes32[32] calldata smtProof,
uint32 index,
bytes32 mainnetExitRoot,
bytes32 rollupExitRoot,
Expand All @@ -40,7 +40,7 @@ interface IPolygonZkEVMBridge {
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes memory metadata
bytes calldata metadata
) external;

function activateEmergencyState() external;
Expand Down
3 changes: 3 additions & 0 deletions docs/PolygonZkEVM.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ The batch fee will not be updated when the trusted aggregator verify batches
```
Allows a sequencer/user to force a batch of L2 transactions.
This should be used only in extreme cases where the trusted sequencer does not work as expected
Note The sequencer has certain degree of control on how non-forced and forced batches are ordered
In order to assure that users force transactions will be processed properly, user must not sign any other transaction
with the same nonce


#### Parameters:
Expand Down
6 changes: 3 additions & 3 deletions docs/PolygonZkEVMBridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Verify merkle proof and execute message
string name,
string symbol,
uint8 decimals
) public returns (address)
) external returns (address)
```
Returns the precalculated address of a wrapper using the token information

Expand All @@ -151,7 +151,7 @@ Returns the precalculated address of a wrapper using the token information
function getTokenWrappedAddress(
uint32 originNetwork,
address originTokenAddress
) public returns (address)
) external returns (address)
```
Returns the address of a wrapper using the token information if already exist

Expand Down Expand Up @@ -220,7 +220,7 @@ Verify leaf and checks that it has not been claimed
```solidity
function isClaimed(
uint256 index
) public returns (bool)
) external returns (bool)
```
Function to check if an index is claimed or not

Expand Down
Loading

0 comments on commit bae5045

Please sign in to comment.