Skip to content

Commit

Permalink
Merge pull request #247 from 0xPolygonHermez/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
invocamanman authored Jun 18, 2024
2 parents 1ad7089 + 9cfe119 commit 7375833
Show file tree
Hide file tree
Showing 26 changed files with 2,708 additions and 232 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion contracts/mocks/DaiMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

// hevm: flattened sources of /nix/store/8xb41r4qd0cjb63wcrxf1qmfg88p0961-dss-6fd7de0/src/dai.sol
pragma solidity =0.5.12;
pragma solidity <=0.5.12;

// Copeid DAi for testing porpuses. The notes are removed from this contract as it does not work correctly woith the
// coverage solidity compiler
Expand Down
49 changes: 27 additions & 22 deletions contracts/v2/lib/PolygonRollupBaseEtrog.sol
Original file line number Diff line number Diff line change
Expand Up @@ -302,29 +302,8 @@ abstract contract PolygonRollupBaseEtrog is
string memory sequencerURL,
string memory _networkName
) external virtual onlyRollupManager initializer {
bytes memory gasTokenMetadata;
bytes memory gasTokenMetadata = _verifyOrigin(_gasTokenAddress);

if (_gasTokenAddress != address(0)) {
// Ask for token metadata, the same way is enconded in the bridge
// Note that this function will revert if the token is not in this network
// Note that this could be a possible reentrant call, but cannot make changes on the state since are static call
gasTokenMetadata = bridgeAddress.getTokenMetadata(_gasTokenAddress);

// Check gas token address on the bridge
(
uint32 originWrappedNetwork,
address originWrappedAddress
) = bridgeAddress.wrappedTokenToTokenInfo(_gasTokenAddress);

if (originWrappedNetwork != 0) {
// It's a wrapped token, get the wrapped parameters
gasTokenAddress = originWrappedAddress;
gasTokenNetwork = originWrappedNetwork;
} else {
// gasTokenNetwork will be mainnet, for instance 0
gasTokenAddress = _gasTokenAddress;
}
}
// Sequence transaction to initilize the bridge

// Calculate transaction to initialize the bridge
Expand Down Expand Up @@ -948,4 +927,30 @@ abstract contract PolygonRollupBaseEtrog is

return transaction;
}

function _verifyOrigin(
address _gasTokenAddress
) internal virtual returns (bytes memory gasTokenMetadata) {
if (_gasTokenAddress != address(0)) {
// Ask for token metadata, the same way is enconded in the bridge
// Note that this function will revert if the token is not in this network
// Note that this could be a possible reentrant call, but cannot make changes on the state since are static call
gasTokenMetadata = bridgeAddress.getTokenMetadata(_gasTokenAddress);

// Check gas token address on the bridge
(
uint32 originWrappedNetwork,
address originWrappedAddress
) = bridgeAddress.wrappedTokenToTokenInfo(_gasTokenAddress);

if (originWrappedNetwork != 0) {
// It's a wrapped token, get the wrapped parameters
gasTokenAddress = originWrappedAddress;
gasTokenNetwork = originWrappedNetwork;
} else {
// gasTokenNetwork will be mainnet, for instance 0
gasTokenAddress = _gasTokenAddress;
}
}
}
}
6 changes: 5 additions & 1 deletion contracts/v2/utils/ClaimCompressor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,13 @@ contract ClaimCompressor {
add(metadataLen, mod(sub(32, mod(metadataLen, 32)), 32))
)

if lt(gas(), 2500000) {
revert(0, 0)
}

// SHould i limit the gas TODO of the call
let success := call(
gas(), // gas
2000000, // gas // TODO gas Limited to 2M, could be better to check if it's created the token or not and limit later
bridgeAddress, // address
0, // value
0, // args offset
Expand Down
4 changes: 2 additions & 2 deletions contracts/verifiers/FflonkVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ contract FflonkVerifier {
uint256 constant w8_7 = 8613538655231327379234925296132678673308827349856085326283699237864372525723;

// Verifier preprocessed input C_0(x)·[1]_1
uint256 constant C0x = 21160666715172434637225720476256763871501363117729999199262494595796582644427;
uint256 constant C0y = 15161784655278302587190494591488856640885304569426835678458555890947087546457;
uint256 constant C0x = 19531210301294568511992648735135291982401633864004026433715722115099857739632;
uint256 constant C0y = 16913517370715546973488219367119174715262034757907912789481968159710930517904;

// Verifier preprocessed input x·[1]_2
uint256 constant X2x1 = 21831381940315734285607113342023901060522397560371972897001948545212302161822;
Expand Down
Loading

0 comments on commit 7375833

Please sign in to comment.