0xpolygon / fx-portal Goto Github PK
View Code? Open in Web Editor NEWFxPortal for Polygon (Previously Matic) chain. No mapping. Seamless.
License: MIT License
FxPortal for Polygon (Previously Matic) chain. No mapping. Seamless.
License: MIT License
Took me 2 days to pinpoint. Migrate back to 0.7.0 works. Or.. just use i++ ?
As there was a recent vulnerability fix to revert masks that start with 0x00, does the fix also need to be done for the contracts in fx portal, especially the part where the mask will be used to produce the exit hash which supposed to be unique?
Particularly this part: https://github.com/fx-portal/contracts/blob/main/contracts/tunnel/FxBaseRootTunnel.sol#L79
The usage of the mask looks almost the same as how it is used in the contracts on the main Polygon repo.
This was the fix applied on the contracts in the Polygon repo some time back: https://github.com/maticnetwork/contracts/pull/381/files
Which is mainly this:
require(vars.branchMaskBytes[0] == 0, "incorrect mask");
Hello! I'm the Lead Developer working on integrating GoldHunt Game (thegame.gold) with the Polygon network. I intend to build a custom implementation of the FxPortal Root & Child Contracts (https://github.com/fx-portal/contracts) to enable our community to move tokens between Ethereum <-> Polygon.
I need technical support on implementing this bridge on the Test networks (Goerli, Mumbai).
The problem: when I call function receiveMessage(bytes memory inputData) public virtual
on my implementation of the Root contract, I am getting a Fail with error 'Leaf index is too big'
error on the transaction.
Failed Transactions (same error):
https://goerli.etherscan.io/tx/0x8b19cb0f540d5f6fba1ff19c5c64bb99ba15ee0cc33f1f24859fd26db18b9872
https://goerli.etherscan.io/tx/0x605f6c4ed73547d956c5635aae23e5b1c54f560e2f7e6e57bfed14827c0dcd6c
https://goerli.etherscan.io/tx/0x8906d30b22d7c49366a8641ed5613654c5ab280f897a16bdc97d3c38ea019260
I generate the burn proof as such:
const execute = async () => {
const posClient = await getPOSClient();
const proof = await posClient.exitUtil.buildPayloadForExit(
"0x76bd13760e3dbea702450f8741b405bf528be0078570d94c405a9183a8911ef9", // Withdraw transaction hash
"0x8c5261668696ce22758910d05bab8f186d6eb247ceac2af2e82c7dc17669b036" // MESSAGE_SENT_EVENT_SIG: Do not change this
)
console.log(" ----- BURN PROOF -----")
console.log(proof)
}
Where https://mumbai.polygonscan.com/tx/0x76bd13760e3dbea702450f8741b405bf528be0078570d94c405a9183a8911ef9 is the Withdraw transaction I submitted on the Mumbai network.
My implementation of the FxMintableERC20RootTunnel
is deployed at https://goerli.etherscan.io/address/0xC0Af0b1a10F2417D62EE044BC99dB1b40b4DC82e - you'll notice a number of failed transactions all throwing the same error.
My implementation of the FxMintableERC20ChildTunnel
is deployed at https://mumbai.polygonscan.com/address/0x38530B465C2937b6f3fB7559a796156D2a0A9f02 - I submitted the Withdraw transaction on Mumbai to this contract (see above) over 24 hours ago.
I am attempting to send GGold (ERC20) back and forth across my tunnel, and am unable to resolve the last step to receive the funds back from the Tunnel on Goerli due to the error above.
GGold (Goerli) - https://goerli.etherscan.io/address/0xbdCDF80D26DDA1ae2F9C0003995d160F4893F20A
pGGold (Polygon) - https://mumbai.polygonscan.com/address/0xC440ddBA14e585fdF395bD74B85797e41fd8317c
I can see that the error is ultimately being thrown by the Merkle
library defined as such:
pragma solidity ^0.8.0;
library Merkle {
function checkMembership(
bytes32 leaf,
uint256 index,
bytes32 rootHash,
bytes memory proof
) internal pure returns (bool) {
require(proof.length % 32 == 0, "Invalid proof length");
uint256 proofHeight = proof.length / 32;
// Proof of size n means, height of the tree is n+1.
// In a tree of height n+1, max #leafs possible is 2 ^ n
require(index < 2**proofHeight, "Leaf index is too big");
bytes32 proofElement;
bytes32 computedHash = leaf;
for (uint256 i = 32; i <= proof.length; i += 32) {
assembly {
proofElement := mload(add(proof, i))
}
if (index % 2 == 0) {
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
index = index / 2;
}
return computedHash == rootHash;
}
}
but this entire section of code was defined as part of the FxBaseRootTunnel.sol
file defined in the fx-portals
repo which I am using an exact copy of so I'm not sure how to debug this issue.
Please advise on how to resolve this issue - I've already read through https://docs.polygon.technology/docs/develop/l1-l2-communication/fx-portal/ and this issue is not covered and I am unable to find any other sources online about how to resolve it.
Any help you can provide would be greatly appreciated, as we're excited about being able to onboard thousands of new users to the Polygon network once we're able to build out this infrastructure!
Please remove mr22 contract. And have the owner ship of 0x0000000000000000000000000000000000001010 to 0x5dA1CD01B5d373b1B9Ca25d46660b51708D1dFc8 Felix1 or Felix255
Hey!
I just got through this repo and I'm trying to understand how it all fits together. While it makes it complete sense on the contract side, I'm wondering who pays for network fees?
Hi, i have a question about FxERC20Transfer withdraw testcode in feature/hardhat_unittest
branch.
So i tested erc20 state transfer with test/tunnel/FxERC20Tunnel.ts
.
I understand mapToken
, deposit
function, but i'm little confused of this withdraw line.
In the test code after deposit(), the wallet.getAddress() has 10(i will omit 10^18) in child token contract(the mapped contract).
And also the wallet.getAddress() has 9990 in the root token contract.
child token contract wallet.getAddress() balance : 10
root token contract wallet.getAddress() balance : 9990
When withdraw() function call(withdraw 5 from child token contract) i thought below will be the result.
child token contract wallet.getAddress() balance : 5
root token contract wallet.getAddress() balance : 9995
But instead of above balance, the test code is showing me below result.
child token contract wallet.getAddress() balance : 5
root token contract wallet.getAddress() balance : 9990
So to sum up my question is
Q1. Is the wallet.getAddress() balance I expected right? - child token contract: 5, root token contract: 9995
Q2. Is the withdraw test code resulted becuase the checkpointManager is not working in local test environment?
Q3. What is the checkpointManager0x600e7E2B520D51a7FE5e404E73Fb0D98bF2A913E
in the test code? over here.
Thanks for advanced!
Having this mapping really helps the developers as well as the tech support folks and might also be useful in some of the applications/services.
The compiler fires this warning:
Warning: Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
--> @maticnetwork/fx-portal/contracts/lib/MerklePatriciaProof.sol:20:30:
|
20 | ) internal pure returns (bool) {
| ^^^^
With Goerli now restricting faucet access, is there any chance of getting the contracts deployed on Sepolia? I am teaching a class on bridging with fxportal, but with the goerli requirement, it makes it very hard for my students to complete their project of bridging NFTs as they have a hard time getting test tokens.
I am following this documentation: https://wiki.polygon.technology/docs/develop/l1-l2-communication/state-transfer/
But my messages from root to child in mumbai are not arriving.
Is checkpoint working for state transfers or only for ERC20/ERC721 transfers?
Thanks in advance!
PS: A test transaction was: https://goerli.etherscan.io/tx/0x13bd388709ae2393e2e440f6eb17a7cc8f72541325e8e051c25b6e1769082daa
is this still functional?, it doesn't seem to be sync activity between ethereum and the child contract "fxChild".
Looking at the contract in mumbai, ther las activity was 3 months ago.
Hello, I am wondering how to transfer data from child to Root, how to generate the proof as an input to receiveMessage() to receive the messages?
In the Doc of Polygon, it shows:
// npm i @maticnetwork/maticjs
// for goerli - mumbai testnet
const getPOSClient = (network = 'testnet', version = 'mumbai') => {
const posClient = new POSClient()
return posClient.init({
log: true,
network: network,
version: version,
child: {
"matic-provider"
},
parent: {
"matic-provider"
}
}
});
}
posClient.exitUtil.buildPayloadForExit("burntxhash","event signature")
I am wondering how to set "matic-provider", "matic-provider" and burntxhash, event signature
Hey everyone
I started to get issues w/ this part --> https://docs.polygon.technology/docs/develop/l1-l2-communication/state-transfer
and specifically w/ recieveMessage function (Polygon-->ETH transfer). Couple days ago I tested this function and it worked and now I see a warning "Exception in contract code" and failed gas estimation in MM. Contracts did not change.
So.. I wonder if there were any updates on this state transfer in recent days or maybe some issues I am not aware of on Goerli and Mumbai nets? Thanks.
From token mapper, it says fx-portal was discontinued. What's the reason for that?
Even without the UI, I assume this approach still works since the contracts still there. But I wonder is it safe to continue using this for erc20 bridging?
Is the reason somehow related to polygon 2.0 that POS chain will be migrate to a zkEVM validium, so the state sync may not continue to work?
When we compile the contracts using truffle compile
, the compilation fails with the below error message:
TypeError: Member "ownerOf" not found or not visible after argument-dependent lookup in contract IFxERC721.
--> project:/contracts/examples/erc721-transfer/FxERC721ChildTunnel.sol:50:31:
|
50 | require(msg.sender == childTokenContract.ownerOf(tokenId));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Compilation failed. See above.
When we investigate the above smart contract, we find that the contract FxERC721ChildTunnel.sol
inherits from the contract IFxERC721
which doesn't contain any definition for the function ownerOf()
.
immutable
since we assign them at construction time and have no functions to modify it.Currently, the setFxRootTunnel
and setFxChildTunnel
functions are non-virtual. Inherited classes are unable to override with their own logic or add their own modifiers to restrict anyone from calling them out of mischief.
Should these functions be made virtual intead?
The two links in the Can I build my bridge? section point to dead pages.
First, this is an amazing feature and was pumped to implement it. Excited that I came across it so soon after its creation.
I've implemented this with Goerli and Mumbai testnets.
I've successfully run the State Transfer 10 times now, each completed at around 5-8 minutes(root to child).
That being said, my use case would ideally entail the relay time to be 2 minutes, tops. Are there plans to implement this for use cases requiring faster turn around? Or is there a method by which I can speed up the State Transfer?
-Really, appreciate that you made this!
The compiler fires these warnings:
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> @maticnetwork/fx-portal/contracts/lib/ExitPayloadReader.sol
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> @maticnetwork/fx-portal/contracts/lib/RLPReader.sol
Is there any risk of the fx_child
, fx_root
, and checkpoint_manager
contract addresses defined here changing? is there something i should be subscribed in case of changes in functionality etc?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.