<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dmitry Zakharov</title>
    <description>The latest articles on DEV Community by Dmitry Zakharov (@dzahar0v).</description>
    <link>https://dev.to/dzahar0v</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1165336%2Fb6a030ad-c8c3-4c0b-b25d-d3037eaa67b3.jpeg</url>
      <title>DEV Community: Dmitry Zakharov</title>
      <link>https://dev.to/dzahar0v</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dzahar0v"/>
    <language>en</language>
    <item>
      <title>How to Add a New Pool to Uniswap V3</title>
      <dc:creator>Dmitry Zakharov</dc:creator>
      <pubDate>Sat, 23 Sep 2023 13:36:31 +0000</pubDate>
      <link>https://dev.to/dzahar0v/how-to-add-a-new-pool-to-uniswap-v3-19ck</link>
      <guid>https://dev.to/dzahar0v/how-to-add-a-new-pool-to-uniswap-v3-19ck</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Many existing projects use the third version of a well-known Uniswap protocol as Oracle to get the current price for many assets. Uniswap V3 can also be used in one of the strategies like yearn or harvest strategies as a pool of liquidity, which can create profits for your deposit through time. Some projects also add integration with Uniswap V3 to increase user experience and make users' lives a little bit easier. In all of these scenarios, it is crucial to check how the poisoned pool, which can be added by a hacker to uniswap can affect the protocol. To check this scenario, we create a test in the hardhat environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding liquidity pool to UniswapV3
&lt;/h2&gt;

&lt;p&gt;The code snippet in the hardhat testing environment is presented below. All necessary notes to the code are given as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const tokenFactory = await ethers.getContractFactory("EvilToken");
const evilToken = await tokenFactory.connect(deployer).deploy();
const positionManager = await ethers.getContractAt('INonfungiblePositionManager', "0xC36442b4a4522E871399CD717aBDD847Ab11FE88");
const WETH = await ethers.getContractAt('IWETH', addresses.tokens.WETH);
// call approve for tokens before adding a new pool
call approveawait WETH.connect(deployer).approve(positionManager.address, ethers.utils.parseEther('0.1'), {gasPrice: 0});
await evilToken.connect(deployer).approve(positionManager.address, ethers.utils.parseEther('100'), {gasPrice: 0});
let multiCallParams = [
// first call
"0x13ead562" + // encoded function signature ( createAndInitializePoolIfNecessary(address, address, uint24, uint160) )
"000000000000000000000000" + evilToken.address.toLowerCase().substring(2) + // token1 address
"000000000000000000000000" +  WETH.address.toLowerCase().substring(2) + // token2 address
"00000000000000000000000000000000000000000000000000000000000001f4" + // fee
"000000000000000000000000000000000000000005b96aabfac7cdc4b3b58fc2", // sqrtPriceX96
// second call
"0x88316456" + // encoded function signature ( mint((address,address,uint24,int24,int24,uint256,uint256,uint256,uint256,address,uint256)) )
"000000000000000000000000" + evilToken.address.toLowerCase().substring(2) + // token1 address
"000000000000000000000000" +  WETH.address.toLowerCase().substring(2) + // token2 address
"00000000000000000000000000000000000000000000000000000000000001f4" + // fee
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89f0e" + // tick lower
"0000000000000000000000000000000000000000000000000000000000010dd8" + // tick upper
"00000000000000000000000000000000000000000000000ad5a4b6712c4647c3" + // amount 1 desired
"000000000000000000000000000000000000000000000000016345785d8a0000" + // amount 2 desired
"00000000000000000000000000000000000000000000000acebaf563cd50439c" + // min amount 1 expected
"000000000000000000000000000000000000000000000000016261cfc3291456" + // min amount 2 expected 
"000000000000000000000000" + signer3.address.toLowerCase().substring(2) + // deployer address "00000000000000000000000000000000000000000000000000000000610bb8b6" // deadline
];
// adding a new liquidity pool through the position manager
await positionManager.connect(deployer).multicall(multiCallParams, {gasPrice: 0});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this test, &lt;code&gt;EvilToken&lt;/code&gt; is a standard ERC20 token that can be minted or burned by the deployer, &lt;code&gt;positionManager&lt;/code&gt; is one of Uniswap V3 ecosystem's smart contracts which gives access to adding new pools of liquidity, &lt;code&gt;WETH&lt;/code&gt; is a token representing wrapped ether. &lt;code&gt;multiCallParams&lt;/code&gt; is an array of bytes which contains all necessary parameters to deploy a new liquidity pool. It is worth saying that some of the parameters used in &lt;code&gt;multiCallParams&lt;/code&gt; cannot be easily calculated, like &lt;code&gt;sqrtPriceX96&lt;/code&gt; or &lt;code&gt;tick_lower&lt;/code&gt;. To calculate these parameters, you can use a Uniswap V3 dApp in the ropsten network. It is very easy to calculate these parameters through dApp. First, you create a new liquidity pool in dApp with parameters that you want to use, and then you just decompile your transaction in ropsten etherscan and get values of the necessary parameters in byte representation.&lt;/p&gt;

</description>
      <category>uniswapv3</category>
      <category>hardhat</category>
      <category>testing</category>
      <category>solidity</category>
    </item>
    <item>
      <title>How to Change the Bytecode of an Already Deployed Smart Contract</title>
      <dc:creator>Dmitry Zakharov</dc:creator>
      <pubDate>Sat, 23 Sep 2023 13:25:09 +0000</pubDate>
      <link>https://dev.to/dzahar0v/how-to-change-the-bytecode-of-an-already-deployed-smart-contract-b77</link>
      <guid>https://dev.to/dzahar0v/how-to-change-the-bytecode-of-an-already-deployed-smart-contract-b77</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Developing smart contracts with the Solidity or Vyper programming language always leads to creating some tests in a special environment. Currently, in order to deploy newly created smart contracts in testnet several tools exist, the most popular of which are hardhat, Ape, Boa, and foundry. In this note, we will discuss how you can change the bytecode of a smart contract already deployed on mainnet and, therefore in testnet. This can be useful if you want to change some logic for test purposes or if you want to change prices in oracles, as in a case that will be discussed below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Updating bytecode of an already deployed smart contract
&lt;/h2&gt;

&lt;p&gt;To prepare these tests, we used &lt;a href="https://kndrck.co/posts/local_erc20_bal_mani_w_hh/"&gt;this article&lt;/a&gt; as an example. First of all, you need to install hardhat &amp;gt; 2.4.0 via npm or yarn. Next, you must add a copy of the smart contract code you want to change in your project repo. A little tip before we start discussing the code: if you use &lt;code&gt;blockGasLimit&lt;/code&gt; in hardhat config, you must tune it right so that tests would execute (in our case, we simply removed this parameter from config). Add all necessary changes to this code and deploy it to testnet via &lt;code&gt;ethers.getContractFactory()&lt;/code&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oracles = await ethers.getContractFactory("AaveOracle");
const oracle = await oracles.deploy(
      ["0x6B175474E89094C44Da98b954EedeAC495271d0F"], 
      ["0x773616E4d11A78F511299002da57A0a94577F1f4"], 
      "0x5B09E578cfEAa23F1b11127A658855434e4F3e09", 
      WETH.address,
    );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the code above, we have &lt;code&gt;AaveOracle&lt;/code&gt;, which contains all code from Aave Oracle with small additions, and &lt;code&gt;WETH.address&lt;/code&gt;, which is simply a string with wrapped ETH in Ethereum mainnet (&lt;code&gt;0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&lt;/code&gt;). The first parameter in the deploy function is an array of assets, which is used in oracle (in our case, it is an array of 1 asset == DAI address &lt;code&gt;0x6B175474E89094C44Da98b954EedeAC495271d0F&lt;/code&gt;). The second parameter is an array of data feeds (in our case, it is chainlink's data feed for DAI/ETH &lt;code&gt;0x773616E4d11A78F511299002da57A0a94577F1f4&lt;/code&gt;). The third parameter is a fallback oracle (in our case, it is simply Aave fallback oracle &lt;code&gt;0x5B09E578cfEAa23F1b11127A658855434e4F3e09&lt;/code&gt;). After all these steps are taken, you can use the hardhat function &lt;code&gt;eth_getCode()&lt;/code&gt; to get the bytecode of your newly deployed smart contract, and after that, you must use &lt;code&gt;eth_setCode()&lt;/code&gt; to add this code to the contract address in testnet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const code = await hre.network.provider.send("eth_getCode", [
        oracle.address,
    ]);
await hre.network.provider.send("hardhat_setCode", [
      "0xA50ba011c48153De246E5192C8f9258A2ba79Ca9",
      code,
    ]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the code above, we get the bytecode of our deployed contract and set it to Aave Oracle, which has the address &lt;code&gt;0xA50ba011c48153De246E5192C8f9258A2ba79Ca9&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>solidity</category>
      <category>hardhat</category>
      <category>testing</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to Fork Mainnet for Testing</title>
      <dc:creator>Dmitry Zakharov</dc:creator>
      <pubDate>Sat, 23 Sep 2023 13:09:24 +0000</pubDate>
      <link>https://dev.to/dzahar0v/how-to-fork-mainnet-for-testing-2lhh</link>
      <guid>https://dev.to/dzahar0v/how-to-fork-mainnet-for-testing-2lhh</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;One of the most exciting features of DeFi is interoperability, which allows constructing protocols using deployed smart contracts as base blocks for your protocol (e.g., Yearn Strategies). As a matter of fact, interoperability is one of the reasons why DeFi protocols are referred to as legos. Just like Lego blocks, you have to find the right way to fit two DeFi protocols together for specific use cases.&lt;br&gt;
Developers have two options for testing smart contracts that integrate with at least one existing protocol: creating a mock that implements all necessary functions of an already deployed smart contract or using mainnet forking for tests. Mocks can mask very dangerous problems because they usually copy only the needed function from real contracts, which can lead to incorrect mock work. That's why we strongly recommend using mocks only if it is crucial. In all other cases, you can use mainnet forking.&lt;/p&gt;
&lt;h2&gt;
  
  
  Mainnet forking in hardhat
&lt;/h2&gt;

&lt;p&gt;In this article, we will discuss how to set up your hardhat project for mainnet forking. First of all, you must have an Infura or Alchemy API key to use a RPC node to fork the state of the specific block. After getting an API key from one of the RPC providers, you need to change your config file like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const CHAIN_IDS = {
  hardhat: 31337, // chain ID for hardhat testing
};
module.exports = {
  networks: {
    hardhat: {
      chainId: CHAIN_IDS.hardhat,
      forking: {
        // Using Alchemy
        url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`, // url to RPC node, ${ALCHEMY_KEY} - must be your API key
        // Using Infura
        // url: `https://mainnet.infura.io/v3/${INFURA_KEY}`, // ${INFURA_KEY} - must be your API key
        blockNumber: 12821000, // a specific block number with which you want to work
      },
    },
    ... // you can also add more necessary information to your config
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After adding this to your &lt;code&gt;hardhat.config.js&lt;/code&gt; file, you can use all necessary information from the specific block. For example, you can impersonate an address and use some tokens from a random address to test your function (it is very useful when you need a rare NFT to test one of your functions), or you can call any function from any contract only by adding a needed interface to your project. Some tips for working with a mainnet fork in a hardhat test are presented in the example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Function which allows to convert any address to the signer, which can sign transactions in a test
const impersonateAddress = async (address) =&amp;gt; {
  const hre = require('hardhat');
  await hre.network.provider.request({
    method: 'hardhat_impersonateAccount',
    params: [address],
  });
  const signer = await ethers.provider.getSigner(address);
  signer.address = signer._address;
  return signer;
};
// Function to increase time in mainnet fork
async function increaseTime(value) {
  if (!ethers.BigNumber.isBigNumber(value)) {
    value = ethers.BigNumber.from(value);
  }
  await ethers.provider.send('evm_increaseTime', [value.toNumber()]);
  await ethers.provider.send('evm_mine');
}
// Construction to get any contract as an object by its interface and address in blockchain
// It is necessary to note that you must add an interface to your project
const WETH = await ethers.getContractAt('IWETH', wethAddress);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>solidity</category>
      <category>ethereum</category>
      <category>hardhat</category>
      <category>testing</category>
    </item>
    <item>
      <title>Account Abstraction. Auditor's View</title>
      <dc:creator>Dmitry Zakharov</dc:creator>
      <pubDate>Sat, 23 Sep 2023 12:42:46 +0000</pubDate>
      <link>https://dev.to/dzahar0v/account-abstraction-auditors-view-1k41</link>
      <guid>https://dev.to/dzahar0v/account-abstraction-auditors-view-1k41</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;EIP-4337 offers a unique approach to Account Abstraction, effectively bypassing the need for alterations to the consensus layer. The architecture of EIP-4337 mirrors the transactions mempool functionality within a high-level system, giving the way for a more flexible and dynamic processing model. The central actors in this system are the users and the &lt;code&gt;Bundlers&lt;/code&gt; that operate through a specialized p2p network of &lt;code&gt;clients&lt;/code&gt; with implemented &lt;code&gt;UserOperationPool&lt;/code&gt;.&lt;br&gt;
In this setup, users send &lt;code&gt;UserOperation&lt;/code&gt; objects to &lt;code&gt;UserOperationPool&lt;/code&gt;. Acting as transaction builders, &lt;code&gt;Bundlers&lt;/code&gt; listen in this mempool and combine &lt;code&gt;UserOperation&lt;/code&gt; objects into a single &lt;code&gt;bundle&lt;/code&gt; transaction, which is then sent to the &lt;code&gt;EntryPoint&lt;/code&gt; smart contract. This &lt;code&gt;EntryPoint&lt;/code&gt; smart contract serves as a processing hub, executing the &lt;code&gt;UserOperation&lt;/code&gt; objects and deploying custom &lt;code&gt;Account&lt;/code&gt; smart contracts implementing a specified interface.&lt;br&gt;
The deployed &lt;code&gt;Account&lt;/code&gt; smart contracts have a role that extends beyond merely the storage of assets. They handle nonces and signature validation, presenting opportunities for using custom logic in the operations process and the utilization of assets. Further enhancing the versatility of EIP-4337, the protocol enables the use of specific &lt;code&gt;Paymaster&lt;/code&gt; actors to handle gas payments in inner transaction execution. This addition allows for customizing gas payment methods based on various conditions, such as payment in ERC-20 tokens to the &lt;code&gt;Paymaster&lt;/code&gt;.&lt;br&gt;
The overall architecture and logic of EIP-4337 have been detailed in the proposal by &lt;a href="https://eips.ethereum.org/EIPS/eip-4337"&gt;Vitalik Buterin et al.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Possible Ways of Integration
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Integration of paymasters
&lt;/h3&gt;

&lt;p&gt;The first and main part of ERC-4337 that can be used in some DeFi projects is the integrated paymaster taking care of a gas cost. It can use another way to cover gas costs (like ERC-20 tokens) or just sponsor gas prices to make the protocol more attractive.&lt;br&gt;
All protocols trying to integrate a paymaster should consider DOS. If someone finds a way to sponsor their transaction without fair compensation, they can drain the paymaster’s stake. Let's assume some new ERC-20 token compensates the gas cost for any transfer. This can be exploited by an attacker transferring tokens back and forth: the paymaster will be quickly left without funds.&lt;br&gt;
The paymaster can be used by DEXes (like Uniswap) to exchange ERC-20 tokens without having native tokens. If token A is exchanged for token B, the amount of A for the exchange can be decreased to the gas cost equivalent. Furthermore, ERC-20 tokens can be exchanged for wrapped native tokens immediately unwrapped and sent to the user’s account.&lt;br&gt;
The important moment of such a use case is slippage. The minimum amount of B should be calculated considering gas price compensation. Incorrectly modified slippage will lead to a constant revert or can be used by MEV-bots to steal some of a user's funds.&lt;br&gt;
NTF markets (like OpenSea) can give the ability to artists to mint NFTs without having native tokens. An artist or institution can pay with a bank card officially to a marketplace. After that, the protocol whitelists users in paymaster, allowing them to deploy a collection without diving into crypto, just through UI. Markets can even sponsor gas payments to help some cultural institutions or to attract more well-known artists.&lt;/p&gt;

&lt;h3&gt;
  
  
  Regular operations
&lt;/h3&gt;

&lt;p&gt;Recurrent operations and subscriptions are other features of ERC-4337 that can add new functionalities to a DeFi project. Of course, such ability should be supported by an abstract account realization: wallet contracts should be able to validate such kind of &lt;code&gt;UserOperations&lt;/code&gt;.&lt;br&gt;
Regular investments can be used in Aave, Compound, and other lending platforms. Users may set some monthly transfer of funds to the protocol. Tokens will be constantly lent, giving profit and improving the health factor of users' debt. It’s also possible to auto-approve some money if the health factor becomes lower than some value.&lt;br&gt;
It’s also possible to add a setting of orders in DEXes or other trading platforms without a preliminary funds transfer from the user's balance. Users can set some conditions when approval for some ERC-20 token is given. So, the order will be executed by trading protocol only if these conditions are met, and the user has enough balance.&lt;br&gt;
It’s important to pay maximum attention to details of such regular or triggered approvals (approved amount, who can transfer tokens, and periodicity of auto-approval). It’s both the responsibility of a protocol owner and a user. &lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations
&lt;/h2&gt;

&lt;p&gt;Despite its revolutionary approach to Ethereum account management, EIP-4337 still encounters several inherent limitations. These constraints stem from various factors such as potential griefing and DoS attacks, the necessity for an isolated validation process of &lt;code&gt;UserOperations&lt;/code&gt;, and the decentralized nature of the overall system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gas Constraints in Validation Process&lt;/strong&gt;: The design of EIP-4337 imposes limitations on the validation process. To safeguard against excessive gas consumption and potential griefing, high-cost validation algorithms cannot be implemented into &lt;code&gt;Account&lt;/code&gt; smart contracts. &lt;code&gt;Bundlers&lt;/code&gt; are allowed to exclude &lt;code&gt;UserOperation&lt;/code&gt; objects from a &lt;code&gt;bundle&lt;/code&gt; if the gas limit parameter for the validation process is set too high.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Independence of the Validation Process&lt;/strong&gt;: The validation process for &lt;code&gt;Accounts&lt;/code&gt; and &lt;code&gt;Paymasters&lt;/code&gt; grouped into a single &lt;code&gt;bundle&lt;/code&gt; must remain independent, implying that they cannot call &lt;code&gt;Accounts&lt;/code&gt; associated with other &lt;code&gt;UserOperations&lt;/code&gt; or access the same storage slots. This restriction ensures that the consistency of validation does not depend on the order of &lt;code&gt;UserOperation&lt;/code&gt; objects within the &lt;code&gt;bundle&lt;/code&gt; transaction. Consequently, the usage of &lt;code&gt;BeaconProxy&lt;/code&gt; is limited, and &lt;code&gt;Accounts&lt;/code&gt; linked to the same &lt;code&gt;Beacon&lt;/code&gt; cannot be included in one &lt;code&gt;bundle&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Restrictions on Storage Access&lt;/strong&gt;: &lt;code&gt;Accounts&lt;/code&gt; and &lt;code&gt;Paymasters&lt;/code&gt; can only read the storage slots &lt;a href="https://eips.ethereum.org/EIPS/eip-4337#storage-associated-with-an-address"&gt;associated with their address&lt;/a&gt;. To reduce the possibility of DoS and griefing attacks, a staking mechanism has been introduced. If the &lt;code&gt;Paymaster&lt;/code&gt; validation process accesses storage associated with other addresses, it must stake a specified amount of assets. This stake can be unstaked anytime after a fixed delay. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Whitelisting of the Paymasters&lt;/strong&gt;: The &lt;code&gt;client&lt;/code&gt; implements a &lt;code&gt;Throttle&lt;/code&gt; and &lt;code&gt;Ban&lt;/code&gt; mechanism to determine &lt;code&gt;Paymasters&lt;/code&gt; whose validation processes fail after being included into the &lt;code&gt;bundle&lt;/code&gt;. In simpler terms, this targets &lt;code&gt;Paymasters&lt;/code&gt; with inconsistent validation functions. If a &lt;code&gt;Paymaster&lt;/code&gt; repeatedly fails after being included in the &lt;code&gt;bundle&lt;/code&gt; (more frequently than a predefined parameter of &lt;code&gt;client&lt;/code&gt; or &lt;code&gt;Bundler&lt;/code&gt;), the &lt;code&gt;Bundler&lt;/code&gt; may decrease the priority of operation or even ban operations that employ this &lt;code&gt;Paymaster&lt;/code&gt; for a period of time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delay between UserOperationPool and Chain Mempool&lt;/strong&gt;: The &lt;code&gt;UserOperation&lt;/code&gt; object is included in &lt;code&gt;UserOperationPool&lt;/code&gt; before it's added within the &lt;code&gt;bundle&lt;/code&gt; transaction to the chain mempool. It means that between sending the operation to the mempool and including the related &lt;code&gt;bundle&lt;/code&gt; transaction in the block, a significant amount of time can pass. To mitigate late operation processing, the &lt;code&gt;Account&lt;/code&gt; validation function returns a &lt;code&gt;validUntil&lt;/code&gt; parameter, enabling &lt;code&gt;Bundlers&lt;/code&gt; to avoid using outdated &lt;code&gt;UserOperation&lt;/code&gt; objects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Opcode Restrictions&lt;/strong&gt;: EIP-4337 requires the validation processes to be independent of block and transaction states to maintain consistency between validation simulation and execution of the &lt;code&gt;bundle&lt;/code&gt; transaction. This restriction mandates &lt;code&gt;Bundlers&lt;/code&gt; to ensure that &lt;code&gt;validateUserOp&lt;/code&gt; method of &lt;code&gt;Accounts&lt;/code&gt; and &lt;code&gt;validatePaymasterUserOp&lt;/code&gt; of &lt;code&gt;Paymasters&lt;/code&gt; don't use specific opcodes (&lt;code&gt;GASPRICE&lt;/code&gt;, &lt;code&gt;GASLIMIT&lt;/code&gt;, &lt;code&gt;DIFFICULTY&lt;/code&gt;, &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;BASEFEE&lt;/code&gt;, &lt;code&gt;BLOCKHASH&lt;/code&gt;, &lt;code&gt;NUMBER&lt;/code&gt;, &lt;code&gt;SELFBALANCE&lt;/code&gt;, &lt;code&gt;BALANCE&lt;/code&gt;, &lt;code&gt;ORIGIN&lt;/code&gt;, &lt;code&gt;GAS&lt;/code&gt;, &lt;code&gt;CREATE&lt;/code&gt;, &lt;code&gt;CREATE2&lt;/code&gt;, &lt;code&gt;COINBASE&lt;/code&gt;, &lt;code&gt;SELFDESTRUCT&lt;/code&gt;). Exceptions are made for &lt;code&gt;GAS&lt;/code&gt; if followed by one of the call opcodes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deployment Costs&lt;/strong&gt;: Every &lt;code&gt;Account&lt;/code&gt; smart contract must be deployed before utilization. If extrapolated to millions of &lt;code&gt;Accounts&lt;/code&gt;, the deployment costs could be significant. However, these costs can be mitigated through &lt;a href="https://eips.ethereum.org/EIPS/eip-1167"&gt;EIP-1167 (minimal proxy contract)&lt;/a&gt;, which facilitates cheaper contract creation costs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replication Attack Defense&lt;/strong&gt;: To defend from replication attacks, EIP-4337 requires that &lt;code&gt;UserOperation&lt;/code&gt; validation depend on &lt;code&gt;chainId&lt;/code&gt;, &lt;code&gt;nonce&lt;/code&gt;, and &lt;code&gt;msg.sender&lt;/code&gt; (which is the &lt;code&gt;EntryPoint&lt;/code&gt; smart contract).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Security Risks
&lt;/h2&gt;

&lt;p&gt;The implementation of EIP-4337 brings several risks to the forefront. These risks relate to the potential vulnerabilities in custom signature verification methods in &lt;code&gt;Account&lt;/code&gt; smart contracts, the potential of griefing, constraints on integration with certain projects, and the crucial need for comprehensive auditing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Custom Signature Verification Risks&lt;/strong&gt;: The ability for &lt;code&gt;Account&lt;/code&gt; smart contracts under EIP-4337 to employ custom signature verification can potentially introduce security vulnerabilities. These custom verification methods may be less secure than the standard ECDSA algorithm on the secp256k1 curve used for transaction signatures in Ethereum, leading to increased vulnerability risks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Griefing&lt;/strong&gt;: Despite precautions, the potential griefing persists in EIP-4337. For instance, a malicious actor could frontrun the &lt;code&gt;bundle&lt;/code&gt; transaction, changing the state of multiple &lt;code&gt;Accounts&lt;/code&gt; and causing the validation process to fail after consuming a significant amount of gas.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Project Integration Constraints&lt;/strong&gt;: The structure of EIP-4337, where each &lt;code&gt;Account&lt;/code&gt; is a smart contract, imposes integration constraints with projects using the &lt;code&gt;isContract()&lt;/code&gt; modifier. This restriction essentially prohibits anything other than EOA message senders from using these projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Necessity for Auditing&lt;/strong&gt;: Given potential security vulnerabilities in the &lt;code&gt;Account&lt;/code&gt; and the &lt;code&gt;Paymaster&lt;/code&gt;, it's imperative that they are rigorously audited to ensure the overall system's security.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bundler's Extracted Value&lt;/strong&gt;: &lt;code&gt;Bundlers&lt;/code&gt; can replay the operations of users included in the &lt;code&gt;UserOperationPool&lt;/code&gt;, potentially frontrunning arbitrage opportunities. This risk can be mitigated by implementing the &lt;code&gt;client&lt;/code&gt; as a trusted third party, much like the FlashBots project does, thereby guaranteeing the security of operations for both users and &lt;code&gt;Bundlers&lt;/code&gt; or direct block producers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;EIP-4337 offers a groundbreaking approach to Ethereum transaction management, offering flexibility in handling assets and gas payments. Some applications of ERC-4337 can make existing DeFi protocols more convenient and flexible. However, its implementation must be considered with a clear understanding of the inherent limitations and risks. A thoughtful balance between taking advantage of this innovative protocol and ensuring comprehensive security measures can make EIP-4337 a significant milestone in the Ethereum ecosystem.&lt;/p&gt;

</description>
      <category>solidity</category>
      <category>audit</category>
      <category>account</category>
      <category>abstraction</category>
    </item>
  </channel>
</rss>
