Skip to content

Description of Conduit, World ID, and Pyth #50

@Kourin1996

Description

@Kourin1996

Conduit

Reason for Use

We used Conduit to construct a private rollup that handles gas payments for users across many chains. Thanks to features like fully managed, simple configuration, and simultaneous deployment of tools like Bridge and Explorer, Conduit enabled us to swiftly deploy the rollup and start development. Conduit was also the best solution for this project because of its smooth interface with the current L1 blockchain.

How It Was Used

We selected OP Stack for the Rollup tech stack and Celestia for the data availability layer. We deployed a GasDepositManager contract in the private rollup, allowing any user to deposit tokens into it. When a user initiates a transaction on another chain, the fee is deducted from the private rollup rather than being collected on the target chain. In addition, we used a World ID verification to prevent Sybil attacks and a Pyth oracle contract to handle token conversions between native tokens in the private rollup and the target chain.

References

Rollup Name: conduit:superhack-test-v4369l32sl
Block Explorer: https://explorer-superhack-test-v4369l32sl.t.conduit.xyz/
Source code of GasDepositManager contract: https://github.com/Heterod0x/EthDrive/blob/main/contracts/contracts/GasDepositManager.sol
Address of GasDepositManager: 0x51c920fd32a964FAC71AB9627FEBe7176422654a (https://explorer-superhack-test-v4369l32sl.t.conduit.xyz/address/0x51c920fd32a964FAC71AB9627FEBe7176422654a)

World ID

Reason for Use

World ID was included to ensure that only confirmed users may utilize the gas payment option in the private rollup. This feature allows users authenticated by World ID to pay gas fees for any chain via the private rollup. The application ensures that only authorized users can perform transactions by utilizing World ID's authentication features, hence maintaining an elevated degree of security and trust.

How It Was Used

The OpWorldID contract was deployed in the private rollup, and Merkle roots are bridged from the Identity Manager in the Ethereum mainnet. Users can scan a QR code in our UI with the World ID app, and the proof is then confirmed in the GasDepositManager in the private rollup by the OpWorldID contract. Once authenticated, users can pay gas fees through the GasDepositManager in the private Rollup. For authenticated users, we buy transaction fees using Alchemy Gas Manager. However, the current Alchemy Gas Manager cannot dynamically update the list of permitted accounts for gas sponsors. As a result, we replaced traditional authentication with World ID. This authentication protects against Sybil attacks while also allowing for greater flexibility in selecting qualified users for sponsorship.

References

Source code of GasDepositManager contract: https://github.com/Heterod0x/EthDrive/blob/main/contracts/contracts/GasDepositManager.sol
Address of GasDepositManager: 0x51c920fd32a964FAC71AB9627FEBe7176422654a (https://explorer-superhack-test-v4369l32sl.t.conduit.xyz/address/0x51c920fd32a964FAC71AB9627FEBe7176422654a)
Address of OPWorldID: 0xbA9ff1dA3e326b1B625b8a460e0818405982a907 (https://explorer-superhack-test-v4369l32sl.t.conduit.xyz/address/0xbA9ff1dA3e326b1B625b8a460e0818405982a907)
UI component using IDKitWidget: https://github.com/Heterod0x/EthDrive/blob/main/app/src/components/WorldIDProver.tsx

Pyth

Reason for Use

We used Pyth pull oracle to convert between various chains' gas tokens. Pyth was chosen because of its capacity to offer consistent and accurate real-time data on asset prices across several blockchain platforms. Because the program needed to handle gas payments in the native tokens of several chains, precise price feeds were required to assure fair and consistent transaction processing. Furthermore, Pyth pull oracle allows for easy on-chain pricing feed integration.

How It Was Used

The WormholeReceiver and Pyth contracts were deployed in the private rollup in addition to GasDepositManager. When paying gas costs for user transactions in a chain, we retrieve the most recent pricing from Hermes and submit it to the GasDepositManager contract in the private Rollup. GasDepositManager then submits price data into the Pyth contract and uses the submitted price to convert the number of native tokens between the target chain and the private rollup. The sample application retrieves the ETH/USD pricing because Alchemy Gas Manager accepts payments in USD. Pyth's pricing feeds ensure that users are charged the proper amount based on current market rates, allowing for seamless and accurate transactions in the private rollup.

References

Source code to fetch prices:

const pythPriceService = new EvmPriceServiceConnection(
"https://hermes.pyth.network"
);
const priceFeedUpdateData = await pythPriceService.getPriceFeedsUpdateData([
// ETH/USD
"0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
]);
console.log('got price feed data for ETH/USD from pyth', priceFeedUpdateData);
const tx = await contract.getFunction("withdrawFeeInUsd")(account!, BigInt(fee), priceFeedUpdateData);
console.log(`sending withdraw tx, hash => ${tx.hash}`);

Source code to store and use fetched price:
function _updateEthUsdPrice(bytes[] calldata pythUpdateData) internal returns (uint256) {
uint256 updateFee = pyth.getUpdateFee(pythUpdateData);
pyth.updatePriceFeeds{value: updateFee}(pythUpdateData);
return updateFee;
}
function _convertUsdToEth(uint256 usdAmount) internal returns (uint256) {
PythStructs.Price memory currentPrice = pyth.getPriceNoOlderThan(
ethUsdPriceId,
60
);
uint256 uintPrice = PythUtils.convertToUint(
currentPrice.price,
currentPrice.expo,
18
);
uint256 powUsdAmount = usdAmount * 10 ** 18;
uint256 ethAmount = powUsdAmount / uintPrice;
if (powUsdAmount % uintPrice > 0) {
ethAmount += 1;
}
if (uintPrice != lastEthUsdRate) {
lastEthUsdRate = uintPrice;
emit EthUsdRateUpdated(uintPrice);
}
return ethAmount;
}

Address of GasDepositManager: 0x51c920fd32a964FAC71AB9627FEBe7176422654a (https://explorer-superhack-test-v4369l32sl.t.conduit.xyz/address/0x51c920fd32a964FAC71AB9627FEBe7176422654a)
Address of PythUpgradable contract: 0x98a4A62900b88b3E9c3b6ebc717D8b38100fdF9E (https://explorer-superhack-test-v4369l32sl.t.conduit.xyz/address/0x98a4A62900b88b3E9c3b6ebc717D8b38100fdF9E)
Address of WormholeReceiver: 0x07A1bB0F39C8EA69af7A9F2623fd0E1571c663F1 (https://explorer-superhack-test-v4369l32sl.t.conduit.xyz/address/0x07A1bB0F39C8EA69af7A9F2623fd0E1571c663F1)

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions