[Deployment] Error on executing a create2 tx #978
-
Team or ProjectRFX ZK chainSophon EnvironmentMainnet L2 block numberNo response zkSolc Version1.5.3 zksync-ethers Version5.7.2 Minimal Reproducible Code or Repo LinkScript: const marketType = DEFAULT_MARKET_TYPE;
log("creating market %s:%s:%s:%s", indexToken, longToken, shortToken, marketType);
await execute(
"MarketFactory",
{ from: deployer, log: true, customData: getSophonPaymasterParams(), gasLimit: 20000000 },
"createMarket",
indexToken,
longToken,
shortToken,
marketType
); Note: the contract was deployed with Example calls that errors (the sender needs to be whitelisted) cast send 0x03318F2FC24216300AD20DE97eca0dA31EC71853 "createMarket(address,address,address,bytes32)" 0xA36651B38198dE1154a813BCf2D0d71F859ebD0B 0xC1AA99c3881B26901aF70738A7C217dc32536d36 0xC1AA99c3881B26901aF70738A7C217dc32536d36 0x4bd5869a01440a9ac6d7bf7aa7004f402b52b845f20e2cec925101e13d84d075 --rpc-url https://rpc.sophon.xyz/
// @dev creates a market
// @param indexToken address of the index token for the market
// @param longToken address of the long token for the market
// @param shortToken address of the short token for the market
// @param marketType the type of the market
function createMarket(
address indexToken,
address longToken,
address shortToken,
bytes32 marketType
) external onlyMarketKeeper returns (Market.Props memory) {
bytes32 salt = keccak256(abi.encode(
"RFX_MARKET",
indexToken,
longToken,
shortToken,
marketType
));
address existingMarketAddress = dataStore.getAddress(MarketStoreUtils.getMarketSaltHash(salt));
if (existingMarketAddress != address(0)) {
revert Errors.MarketAlreadyExists(salt, existingMarketAddress);
}
MarketToken marketToken = new MarketToken{salt: salt}(roleStore, dataStore);
// the marketType is not stored with the market, it is mainly used to ensure
// markets with the same indexToken, longToken and shortToken can be created if needed
Market.Props memory market = Market.Props(
address(marketToken),
indexToken,
longToken,
shortToken
);
MarketStoreUtils.set(dataStore, address(marketToken), salt, market);
emitMarketCreated(address(marketToken), salt, indexToken, longToken, shortToken);
return market;
}
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "../bank/Bank.sol";
contract MarketToken is ERC20, Bank {
constructor(RoleStore _roleStore, DataStore _dataStore) ERC20("RFX Pool", "RP") Bank(_roleStore, _dataStore) {
}
function mint(address account, uint256 amount) external onlyController {
_mint(account, amount);
}
function burn(address account, uint256 amount) external onlyController {
_burn(account, amount);
}
} Does this work on other EVMs? (If yes, please list at least 1 of them)zkSync Description of What Your Contract DoesI am trying to call Here is an example tx on tenderly ( but it's bugged in itself, wouldn't focus on that): https://dashboard.tenderly.co/akshatcx/testspace/tx/0x6375731dd0056effb24347d2359f7a627c393da2652252521a08dad6081c5db2 This is the log when replaying a tx locally: https://gist.github.com/lutr0/a33067bc9c3b87dfc49d90a8d5e202ee Deployed Context/things we tried:
Additional DetailsReopening #968 as we weren't able to fix it by deployign a standalone version of cc @zjesko |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Hi @lutr0 I went through the transaction traces generated by anvil-zksync 0.4.0 Click to reveal output
anvil-zksync -vvv replay_tx --fork-url 'https://rpc.sophon.xyz' 0x94d9659d251f4b5c63e21cd7ddf0fa4f9493b399ef059a6a6ac66e8c30498c74
I verified that the contract you're trying to deploy is indeed in the KnownCodeStorage, so factory deps is not the issue:
But this line stood out to me:
Is it possible that the revert is occurring in the constructor of |
Beta Was this translation helpful? Give feedback.
Hi, we found that the issue was due to the contracts having been compiled and deployed on Sophon with the non-inlinable libraries addresses for zkSync.
The call was failing as it was trying to call a non-existing library, it being a
CREATE2
tx was a red herring.Deploying the libraries on Sophon and redeploying the contracts fixed the issue.
Thank you so much for your support, it's super appreciated.
Btw, I saw there was a PR matter-labs/hardhat-zksync#1531 to allow setting the libraries per network on hardhat, it would greatly help in these scenarios.