Zpoken 成功在 Neon EVM 上部署 Compound 协议(Zpoken Successfully Deploys the Compound Protocol on Neon EVM)


Over the last few months, Neon Labs has partnered with several organizations to test and deploy various protocols and projects on Neon EVM. Neon Labs’ most recent partnership with Zpoken has resulted in the successful deployment of the Compound protocol on Neon EVM. The deployment of Compound on Neon EVM serves to further test the readiness of Neon EVM for production and the onboarding of complex dApps to its ecosystem.

在过去几个月中,Neon Labs 与多家组织合作,在 Neon EVM 上测试和部署各种协议和项目。 Neon Labs 与 Zpoken 的最新合作,就是在 Neon EVM 上成功部署 Compound 协议。在 Neon EVM 上部署 Compound 有助于进一步测试 Neon EVM 的生产准备情况以及复杂 dApp 加入其生态系统的情况。

Compound is a DeFi dApp that first launched in September, 2018 on Ethereum. The protocol allows users to lend and borrow cryptocurrencies without an intermediary

Compound 是一个 DeFi dApp,于 2018 年 9 月在以太坊上首次推出。该协议允许用户在没有中介的情况下借出和借入加密货币。

Zpoken是谁? (Who is Zpoken?)

Zpoken is a full-stack Web3 development firm. The company has shipped more than 50 projects and has 30 active builders across 10+ blockchain networks. Zpoken’s specializations include high-end web3 development, cryptography, capital markets, token design, and liquidity.

Zpoken是一家全栈 Web3 开发公司。该公司已经交付了 50 多个项目,并在 10 多个区块链网络中拥有 30 名活跃的建设者。 Zpoken 的专长包括高端 web3 开发、密码学、资本市场、代币设计和流动性。

我们的目标 (Our Objective)

The main objective of the exercise with Zpoken was to test Neon EVM’s performance and functionality during the deployment of the Compound protocol contracts to Neon Devnet.

Zpoken练习的主要目的,是在将 Compound 协议合约部署到 Neon Devnet 期间测试 Neon EVM 的性能和功能。

Following the successful deployment, Zpoken conducted unit tests on the protocol. The goal was to ensure the appropriate performance and workflow of the protocol contracts as well as the correctness of the contract calculations and logic.

成功部署后,Zpoken 对该协议进行了单元测试。目标是确保协议合约的适当性能,工作流程以及合约计算和逻辑的正确性。

测试方法 (Testing Methodology)

Zpoken tested the following smart contract functions to verify the performance of Compound on Neon EVM:

Zpoken测试了以下智能合约函数来验证 Compound 在 Neon EVM 上的性能:

  • Deploy compound contracts to Neon Devnet network;
    将compound合约部署到 Neon Devnet 网络;

  • Test cToken contract functions 测试cToken合约函数:
    (constructor, mint, mintFresh, redeem, redeemFreshTokens, redeemFreshAmount, liquidateBorrow, liquidateBorrowFresh, seize, _setComptroller, transfer, balanceOfUnderlying, borrow, borrowRatePerBlock, supplyRatePerBlock, borrowBalanceCurrent, borrowBalanceStored, exchangeRateStored, getCash, borrowFresh, repayBorrowFresh, repayBorrow, repayBorrowBehalf, accrueInterest, _setInterestRateModel, _setInterestRateModelFresh, _setReserveFactor, _setReserveFactorFresh, _reduceReserves, _reduceReservesFresh, admin, pendingAdmin, _setPendingAdmin, _acceptAdmin);

  • Test CEther contract functions 测试 CEther 合约函数:
    (getCashPrior, doTransferIn, doTransferOut, mintExplicit, mintFallback, redeemCTokens, redeemUnderlying, borrow, borrowFresh, repayBorrow, repayBorrowFresh, repayBorrowBehalf, addReserves);

  • Test Comptroller contract functions 测试Comptroller合约函数:
    (constructor, _setLiquidationIncentive, _setPriceOracle, _setCloseFactor, _setCollateralFactor, _supportMarket, liquidateBorrowAllowed, redeemVerify, liquidateCalculateAmountSeize, _setPauseGuardian, setting paused, liquidity, getAccountLiquidity, getHypotheticalAccountLiquidity, admin, pendingAdmin, _setPendingAdmin, _acceptAdmin);

  • Test CompoundLens contract functions 测试 CompoundLens 合约函数:
    (cTokenMetadata, cTokenMetadataAll, cTokenBalances, cTokenBalancesAll, cTokenUnderlyingPrice, cTokenUnderlyingPriceAll, getAccountLimits, governance, comp);

  • Test PriceOracleProxy contract functions 测试 PriceOracleProxy 合约函数:
    (constructor, getUnderlyingPrice);

  • Test Timelock contract functions 测试Timelock合约函数:
    (constructor, setDelay, setPendingAdmin, acceptAdmin, queueTransaction, cancelTransaction, executeTransaction, executeTransaction, queue and cancel empty);

  • Test InterestRateModel contract functions 测试 InterestRateModel 合约函数:
    (baseP025-slopeP20, jump rate tests, baseP05-slopeP45, isInterestRateModel, calculates correct borrow value, jump-rate);

  • Test CCompLikeDelegate contract functions 测试 CCompLikeDelegate 合约函数:
    (_delegateCompLikeTo);

  • Test Maximillion contract functions 测试Maximillion合约函数:
    (constructor, repayBehalf);

  • Test DAIInterestRateModelV3 contract functions 测试 DAIInterestRateModelV3 合约函数:
    (constructor, getBorrowRate, getSupplyRate);

  • Test Flywheel contract functions 测试飞轮合约函数:
    (_grantComp, getCompMarkets, _setCompSpeeds, updateCompBorrowIndex, updateCompSupplyIndex, distributeBorrowerComp, distributeSupplierComp, transferComp, claimComp, claimComp batch, harnessRefreshCompSpeeds, harnessSetCompSpeeds, harnessAddCompMarkets, updateContributorRewards, _setContributorCompSpeed).

测试范围 (Testing Scope)

The scope of testing focused on the following deployed contracts:
测试范围集中在以下已部署的合约上:

测试执行 (Testing Execution)

Prior to deployment and testing, Zpoken made two primary changes to the Compound protocol smart contracts:
在部署和测试之前,Zpoken 对 Compound 协议智能合约进行了两项主要更改:

  • The first change was made to the GRACE_PERIOD and MINIMUM_DELAY constants in Timelock.sol. The constants influence time limits for function execution in contracts. The changes were required as the Zpoken team conducted tests on live Neon network nodes and were not able to manipulate time and block numbers.
    Timelock.sol 中的 GRACE_PERIOD 和 MINIMUM_DELAY 常量进行了第一次更改。常量影响合约中函数执行的时间限制。由于 Zpoken 团队在实时 Neon 网络节点上进行了测试,并且无法操纵时间和块数,因此需要进行这些更改。

  • The second change adjusted the address of the external Comp contract in the Comptroller.sol contract (via the function getCompAddress()).
    第二个改动调整了Comptroller.sol中外部Comp合约的地址合约(通过函数 getCompAddress())。

Once the contract adjustments were made, the Zpoken team deployed to Neon Devnet from the repository neon-smart-contract-dev/compound-finance using the yarn deploy -n neon command.

合约调整完成后,Zpoken 团队从存储库 neon-smart-contract-dev/compound-finance 部署到 Neon Devnet ) 使用 yarn deploy -n neon 命令。

Following the deployment, tests were run from the repository neon-smart-contract-dev/compound-finance. To run the tests, the local Neon environment first needed to be configured and the private keys added to ~/.neon/neon. The command to run the tests was . start.sh

部署之后,从存储库 neon-smart-contract-dev/compound-finance 运行测试。要运行测试,首先需要配置本地 Neon 环境并将私钥添加到 ~/.neon/neon。运行测试的命令是 。开始.sh

Tests were also run in the local Neon environment via Docker in the repository neon-smart-contract-dev/compound-finance. The steps to conduct the test are as follows:

测试还通过存储库中的 Docker 在本地 Neon 环境中运行 neon-smart-contract-dev/compound-finance。进行测试的步骤如下:

  1. Run a local Neon node using proxy-model.py
    使用 proxy-model.py 运行本地 Neon 节点

  2. Build the docker image using sudo docker build -t compound-protocol
    使用 sudo docker build -t Compound-protocol 构建 docker 镜像

  3. Run the container using sudo docker run -it — net=host compound-protocol
    使用 sudo docker run -it --net=host Compound-protocol 运行容器

Project deliverables include deployment and test scripts, as well as integration and unit tests. Deployment and test scripts can be accessed via the repository. The integration and unit tests performed are available in a GitHub repository and can be run in a Docker container to re-play the testing scenarios.

项目可交付成果包括部署和测试脚本,以及集成和单元测试。可以点击 repository 访问部署和测试脚本。执行的集成和单元测试可在 GitHub 存储库 中获得,并且可以在 Docker 容器中运行重现测试场景。

发现 (Findings)

Zpoken successfully deployed and tested the Compound protocol base contracts as well as swap pool. The deployment and associated tests indicated that Neon EVM is running correctly and is fully compatible with Ethereum with regards to running complex dApps like Compound. All integration and unit tests were passed. The contract deployment, logic, math, and functionality are working as expected by the Compound developer team. The only thing that could not be tested was the Compound Web Application due to the lack of the Compound API in public GitHub repositories.

Zpoken 成功部署并测试了 Compound 协议基础合约以及交换池。部署和相关测试表明,Neon EVM 运行正常,并且在运行 Compound 等复杂 dApp 方面与以太坊完全兼容。所有的集成和单元测试都通过了。合约部署、逻辑、数学和功能都按照 Compound 开发团队的预期工作。由于公共 GitHub 存储库中缺少 Compound API,唯一无法测试的是 Compound Web 应用。

Zpoken also identified two issues with the Neon platform:

Zpoken 还发现了 Neon 平台的两个问题:

  1. Deploying and testing the Compound contracts required support for RPC eth_accounts. The method has been implemented but there are errors that Neon Labs is currently addressing.
    部署和测试 Compound 合约需要支持 RPC eth_accounts。该方法已实施,但 Neon Labs 目前正在解决一些错误。

  2. The multi-threaded execution of test scripts implemented in the original Compound tests is not supported by the Neon network. The tests were created for Ganache, a personal Ethereum blockchain simulator, rather than a live node. Attempting to use multiple threads results in “nonce too low” errors. To avoid the error, each script should be run from a different deployer address. However, in tests that use multiple threads within a single test, the error cannot be avoided. The tests could not be run in these scenarios and were skipped.
    Neon 网络不支持多线程执行原 Compound 测试中实现的测试脚本。这些测试是为个人以太坊区块链模拟器 Ganache 而不是实时节点创建的。尝试使用多个线程会导致“nonce too low”错误。为避免该错误,应从不同部署者地址运行每个脚本。但是,在单个测试中使用多个线程的测试中,错误是无法避免的。测试无法在这些场景中运行并被跳过。

结论 (Conclusion)

It’s time for YOU to deploy your own smart contracts to Neon EVM. Make sure to share your Neon EVM feedback with us throughout the process. If you have any issues or need additional guidance, check out our Neon Docs or reach out to a team member on Discord. We know that you’ll create something great!

现在是 将您自己的智能合约部署到 Neon EVM 的时候了。确保在整个过程中与我们分享您对 Neon EVM 的反馈。如果您有任何问题或需要额外指导,请查看我们的 Neon Docs 或通过 Discord 联系团队。我们知道你会创造出伟大的东西!

赞赏