Deploy uniswap v1 and addLiquidity encounter InvalidJump #11
Open
Description
Reproduce issue in local node
Prepare local chain: https://github.com/ParaState/frontier/
- Add default accounts with balance into chain spec for testing (used to deploy uniswap contract, erc20 token contract ...etc)
Modify frontier/template/node/src/chain_spec.rs
fn testnet_genesis(
(...)
// Alice
vm_genesis.insert(H160::from_str(&"0x1BbE5edc5Caabf4517e40b766D64c3DEd86822Df").unwrap(), ETHAccount {
nonce: U256::zero(),
balance: "0x115eec47f6cf7e35000000".into(), // 21M Ether
storage: BTreeMap::new(),
code: [].into(),
});
// Bob
vm_genesis.insert(H160::from_str(&"0x987652e1C2B3B953354A43171063499DCE16dC8f").unwrap(), ETHAccount {
nonce: U256::zero(),
balance: "0x115eec47f6cf7e35000000".into(), // 21M Ether
storage: BTreeMap::new(),
code: [].into(),
});
// Charlie
vm_genesis.insert(H160::from_str(&"0x9f0764D2027c25aC68F341CA568BC3D51aab57A6").unwrap(), ETHAccount {
nonce: U256::zero(),
balance: "0x115eec47f6cf7e35000000".into(), // 21M Ether
storage: BTreeMap::new(),
code: [].into(),
});
(...)
}
- Run node
cargo run --release --bin frontier-template-node -- \
--dev \
--validator \
--execution=Native \
--tmp \
--unsafe-ws-external \
--unsafe-rpc-external \
--rpc-port=8545 \
--rpc-methods=Unsafe
Test steps
-
Deploy ERC20 token: https://github.com/second-state/how_to_deploy_uniswap
因為完整 script 我實際測試在 link token 跟 factory 的時候會有問題, 所以這邊只會用到 deploy erc20 token 的部分- Setup test env
Follow README.md in how_to_deploy_uniswap - Setup accounts first
https://github.com/second-state/how_to_deploy_uniswap/blob/master/installation_data.json#L2-L11
"private_key": { "alice": "86dad071ad5057c81c0e4f72e760270089c7574a8f2fa6d3cad02151325dadee", "bob": "e013cda6acc291988162c9052ba90e95440305b90773f589e4714b92a6f989b6", "charlie": "4da28e165f32e308ef6cff23fec79af9fde09842ec4c553dfa0205df8d113453" }, "public_key": { "alice": "045d014e9250fa70129ec80b12fed3e216a8a3a9aafe76ec54b50d5755d2c9f748f63139065b7e2b7f1f20dc9d37a10499bd142fdc9734d5624abe93cb51b29e7b", "bob": "04d2b5dc59c1832aa2a5d3bc1287dfd009d3fa365de1783cc9fa84cc306cbd35f61d079422bf995a17e1230b391fa840cf859be08dac55d0d6a9ea4c9e80a1f592", "charlie": "042f3dc073009a7eeaf54851e85bdde83241973dabae80488060d3e3ac1b599bcf654bedadae7ac9379c15d909e0a84c29583b8ce2d5b1b9264f0e4fcd33c922c5" },
- Deploy Alice & Bob token
https://github.com/second-state/how_to_deploy_uniswap/blob/master/uniswap_v1/deploy_uniswap_v1.js#L31-L92
將這之後關於 uniswap 的部分註解掉, 只做到 deploy Alice and Bob 這兩種 ERC20 token
cd how_to_deploy_uniswap/uniswap_v1 node deploy_uniswap_v1.js
- Setup test env
-
Deploy uniswap v1: https://github.com/second-state/parastate-setup
透過 Browser 點開 parastate-setup/html/index.html, 直接在 UI 上操作 deploy uniswap, 到 Instantiate ERC20 Token 即可 -
Test addLiquidity by script: https://github.com/second-state/parastate-setup/blob/main/js/diagnose_invalid_jump_error.js#L3-L22
將以上測試 code 貼到 browser 開發人員工具中的 console (記得替換 uniswap_exchange_address 成透過 UI 操作過程中得到的), Enter 送出即可確認到錯誤訊息
使用 official frontier: https://github.com/paritytech/frontier
使用官方最新的 frontier 961e992, 也有相同的錯誤訊息, 要可以驗證的話除了以上流程, 有以下 4 點要注意
- ae1f911 chan id 要配合目前的環境改成
123
- c5ddafa block 相關的修正要跟
- chain_spec.rs 設定 account 是原來的
pallet_evm::GenesisAccount
而非我們 rename 的ETHAccount
- frontier/frame/ethereum/src/lib.rs, 有擋 gas >= gaslimit, parastate-setup 網頁裡面是直接帶入 gas = gaslimit, 看是要改 UI 或是在這邊判斷式拿掉等於的 case
if transaction.gas_limit >= T::BlockGasLimit::get()