Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.2.0 #19

Merged
merged 42 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ee9ceb1
feat: add rlpreader from node_modules
ethyla Aug 22, 2024
1fc2707
fix: check for totalItem length in toList
ethyla Aug 22, 2024
89bf185
forge install: forge-std
ethyla Aug 22, 2024
9002af0
feat: add foundry
ethyla Aug 24, 2024
7067806
feat: use fixed lib
ethyla Aug 24, 2024
c41844d
feat: add deploy script
ethyla Aug 24, 2024
e142aed
chore: gitignore
ethyla Aug 24, 2024
52b4363
fix: don't deplot mintableerc721predicate
ethyla Aug 25, 2024
843ca55
fix: clean up
ethyla Sep 16, 2024
2974248
Merge pull request #16 from 0xPolygon/fix/rlpfix
simonDos Oct 14, 2024
80e08f5
chore: update checkpointReward
simonDos Oct 10, 2024
e5e26ad
fix: e18
simonDos Oct 11, 2024
845990d
fix: fork test at block before upgrade
simonDos Oct 14, 2024
fb853b6
chore: new reward for script
simonDos Oct 16, 2024
c9121e9
fix: delay
simonDos Oct 16, 2024
466986f
chore: use payloads better
simonDos Oct 16, 2024
b02544f
feat: remove unneeded deps
ethyla Sep 24, 2024
5b7e40e
feat: remove draining from stakemanager
ethyla Sep 24, 2024
679c736
feat: fix mpt
ethyla Oct 3, 2024
47e8738
fix: remove rlp dep
ethyla Oct 3, 2024
643def4
feat: add fork test
ethyla Oct 6, 2024
6df8d23
feat: add more testing data
ethyla Oct 9, 2024
0688679
feat: add deploy script
ethyla Nov 5, 2024
ddad751
fix: remove alt2
ethyla Nov 5, 2024
5c1cfad
feat(mrc20): use call over transfer
DhairyaSethi May 6, 2024
42a70e5
revert: MRC20.transfer
DhairyaSethi May 6, 2024
8b6e7ac
chore: reduce duplication
DhairyaSethi May 6, 2024
0e0f8e3
chore: export util method
DhairyaSethi May 6, 2024
d7ad62d
fix: run ci on PRs to main
DhairyaSethi May 6, 2024
760e274
fix: run ci on dev
DhairyaSethi May 7, 2024
32bdf7a
fix: skip forge tests if none
DhairyaSethi May 7, 2024
84983d5
feat: indulging paranoia
DhairyaSethi May 9, 2024
ceb1dd0
nit: use _nativeTransfer for all transfers
DhairyaSethi May 10, 2024
33eb53b
feat: make _nativeTransfer nonReentrant
DhairyaSethi May 20, 2024
c0a3fd7
feat: rename MRC20 to POL
simonDos Jul 22, 2024
62fc865
feat: rename MRC20 and EIP712
simonDos Jul 22, 2024
39e006f
feat: bump EIP712 version
simonDos Jul 22, 2024
b506428
fix: reentrency guard
DhairyaSethi Aug 27, 2024
f753713
Merge branch 'feat/useCallOverTransfer' into dev
ethyla Nov 14, 2024
58a95f3
Merge branch 'feat/adjustRewards' into dev
ethyla Nov 14, 2024
1d97de6
Merge branch 'fix/mpt' into dev
ethyla Nov 14, 2024
0ed1c7c
fix: disable test
ethyla Nov 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ test-bor-docker/data
coverage/

coverage.json

scripts/helpers/interfaces
cache
50 changes: 35 additions & 15 deletions contracts/child/MRC20.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pragma solidity ^0.5.11;
pragma solidity 0.5.17;

import "./BaseERC20NoSig.sol";

/**
* @title Matic token contract
* @notice This contract is an ECR20 like wrapper over native ether (matic token) transfers on the matic chain
* @dev ERC20 methods have been made payable while keeping their method signature same as other ChildERC20s on Matic
* @title Polygon Ecosystem Token contract
* @notice This contract is an ECR20 like wrapper over native gas token transfers on the Polygon PoS chain
* @dev ERC20 methods have been made payable while keeping their method signature same as other ChildERC20s on PoS
*/
contract MRC20 is BaseERC20NoSig {
event Transfer(address indexed from, address indexed to, uint256 value);
Expand All @@ -14,11 +14,17 @@ contract MRC20 is BaseERC20NoSig {
uint8 private constant DECIMALS = 18;
bool isInitialized;

uint256 locked = 0; // append to storage layout
modifier nonReentrant() {
require(locked == 0, "reentrancy");
locked = 1;
_;
locked = 0;
}

constructor() public {}

function initialize(address _childChain, address _token) public {
// Todo: once BorValidator(@0x1000) contract added uncomment me
// require(msg.sender == address(0x1000));
require(!isInitialized, "The contract is already initialized");
isInitialized = true;
token = _token;
Expand All @@ -38,12 +44,11 @@ contract MRC20 is BaseERC20NoSig {

// input balance
uint256 input1 = balanceOf(user);
currentSupply = currentSupply.add(amount);

// transfer amount to user
address payable _user = address(uint160(user));
_user.transfer(amount);

currentSupply = currentSupply.add(amount);
// not reenterant since this method is only called by commitState on StateReceiver which is onlySystem
_nativeTransfer(user, amount);

// deposit events
emit Deposit(token, user, amount, input1, balanceOf(user));
Expand All @@ -66,18 +71,18 @@ contract MRC20 is BaseERC20NoSig {
}

function name() public pure returns (string memory) {
return "Matic Token";
return "Polygon Ecosystem Token";
}

function symbol() public pure returns (string memory) {
return "MATIC";
return "POL";
}

function decimals() public pure returns (uint8) {
return DECIMALS;
}

function totalSupply() public view returns (uint256) {
function totalSupply() public pure returns (uint256) {
return 10000000000 * 10**uint256(DECIMALS);
}

Expand All @@ -98,13 +103,28 @@ contract MRC20 is BaseERC20NoSig {

/**
* @dev _transfer is invoked by _transferFrom method that is inherited from BaseERC20.
* This enables us to transfer MaticEth between users while keeping the interface same as that of an ERC20 Token.
* This enables us to transfer Polygon ETH between users while keeping the interface same as that of an ERC20 Token.
*/
function _transfer(address sender, address recipient, uint256 amount)
internal
{
require(recipient != address(this), "can't send to MRC20");
address(uint160(recipient)).transfer(amount);
_nativeTransfer(recipient, amount);
emit Transfer(sender, recipient, amount);
}

// @notice method to transfer native asset to receiver (nonReentrant)
// @dev 5000 gas is forwarded in the call to receiver
// @dev msg.value checks (if req), emitting logs are handled seperately
// @param receiver address to transfer native token to
// @param amount amount of native token to transfer
function _nativeTransfer(address receiver, uint256 amount) internal nonReentrant {
uint256 txGasLimit = 5000;
(bool success, bytes memory ret) = receiver.call.value(amount).gas(txGasLimit)("");
if (!success) {
assembly {
revert(add(ret, 0x20), mload(ret)) // bubble up revert
}
}
}
}
4 changes: 2 additions & 2 deletions contracts/child/misc/EIP712.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ contract LibEIP712Domain is ChainIdMixin {
abi.encodePacked(EIP712_DOMAIN_SCHEMA)
);

string internal constant EIP712_DOMAIN_NAME = "Matic Network";
string internal constant EIP712_DOMAIN_VERSION = "1";
string internal constant EIP712_DOMAIN_NAME = "Polygon Ecosystem Token";
string internal constant EIP712_DOMAIN_VERSION = "2";
uint256 internal constant EIP712_DOMAIN_CHAINID = CHAINID;

bytes32 public EIP712_DOMAIN_HASH;
Expand Down
2 changes: 1 addition & 1 deletion contracts/common/lib/ExitPayloadReader.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity 0.5.17;

import {RLPReader} from "solidity-rlp/contracts/RLPReader.sol";
import {RLPReader} from "./RLPReader.sol";
import {BytesLib} from "./BytesLib.sol";

library ExitPayloadReader {
Expand Down
15 changes: 9 additions & 6 deletions contracts/common/lib/MerklePatriciaProof.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
pragma solidity ^0.5.2;

import {RLPReader} from "solidity-rlp/contracts/RLPReader.sol";
import {RLPReader} from "./RLPReader.sol";

library MerklePatriciaProof {
/*
Expand Down Expand Up @@ -69,30 +69,33 @@ library MerklePatriciaProof {
);
pathPtr += 1;
} else if (currentNodeList.length == 2) {
bytes memory nodeValue = RLPReader.toBytes(currentNodeList[0]);
uint256 traversed = _nibblesToTraverse(
RLPReader.toBytes(currentNodeList[0]),
nodeValue,
path,
pathPtr
);
//enforce correct nibble
bytes1 prefix = _getNthNibbleOfBytes(0, nodeValue);
if (pathPtr + traversed == path.length) {
//leaf node
if (
keccak256(RLPReader.toBytes(currentNodeList[1])) ==
keccak256(value)
keccak256(RLPReader.toBytes(currentNodeList[1])) == keccak256(value) &&
(prefix == bytes1(uint8(2)) || prefix == bytes1(uint8(3)))
) {
return true;
} else {
return false;
}
}

//extension node
if (traversed == 0) {
if (traversed == 0 || (prefix != bytes1(uint8(0)) && prefix != bytes1(uint8(1)))) {
return false;
}

pathPtr += traversed;
nodeKey = bytes32(RLPReader.toUintStrict(currentNodeList[1]));

} else {
return false;
}
Expand Down
Loading