From 2ff18bb458c829d6fb2b9e412c7af92713012afc Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Tue, 30 Mar 2021 11:31:33 +0300 Subject: [PATCH] Import contracts (#18) * feat: add contracts * fix: configure tsconfig and replace build => dist * chore: remove CI files * chore: use monorepo tslint / prettier --- .gitignore | 10 +- packages/contracts/.gitattributes | 1 + packages/contracts/CHANGELOG.md | 82 + packages/contracts/LICENSE.txt | 22 + packages/contracts/README.md | 76 + packages/contracts/bin/deploy.js | 120 + .../bin/gen_safety_checker_constants.py | 65 + packages/contracts/bin/serve_dump.sh | 37 + packages/contracts/bin/take-dump.ts | 25 + .../OVM/accounts/OVM_ECDSAContractAccount.sol | 140 + .../OVM/accounts/OVM_ProxyEOA.sol | 121 + .../Abs_BaseCrossDomainMessenger.sol | 126 + .../messaging/OVM_L1CrossDomainMessenger.sol | 294 + .../messaging/OVM_L1MultiMessageRelayer.sol | 70 + .../messaging/OVM_L2CrossDomainMessenger.sol | 136 + .../OVM/bridge/tokens/Abs_L1TokenGateway.sol | 209 + .../bridge/tokens/Abs_L2DepositedToken.sol | 230 + .../OVM/bridge/tokens/OVM_L1ERC20Gateway.sol | 100 + .../OVM/bridge/tokens/OVM_L1ETHGateway.sol | 164 + .../bridge/tokens/OVM_L2DepositedERC20.sol | 67 + .../chain/OVM_CanonicalTransactionChain.sol | 1230 +++ .../OVM/chain/OVM_ChainStorageContainer.sol | 205 + .../OVM/chain/OVM_StateCommitmentChain.sol | 414 + .../OVM/execution/OVM_ExecutionManager.sol | 1866 ++++ .../OVM/execution/OVM_SafetyChecker.sol | 148 + .../OVM/execution/OVM_StateManager.sol | 738 ++ .../OVM/execution/OVM_StateManagerFactory.sol | 41 + .../OVM/predeploys/ERC1820Registry.sol | 199 + .../OVM/predeploys/OVM_DeployerWhitelist.sol | 212 + .../OVM/predeploys/OVM_ETH.sol | 34 + .../OVM/predeploys/OVM_L1MessageSender.sol | 43 + .../predeploys/OVM_L2ToL1MessagePasser.sol | 50 + .../OVM_ProxySequencerEntrypoint.sol | 116 + .../predeploys/OVM_SequencerEntrypoint.sol | 127 + .../OVM/verification/Abs_FraudContributor.sol | 18 + .../OVM/verification/OVM_BondManager.sol | 208 + .../OVM/verification/OVM_FraudVerifier.sol | 296 + .../verification/OVM_StateTransitioner.sol | 473 + .../OVM_StateTransitionerFactory.sol | 67 + .../accounts/iOVM_ECDSAContractAccount.sol | 24 + .../iAbs_BaseCrossDomainMessenger.sol | 36 + .../messaging/iOVM_L1CrossDomainMessenger.sol | 64 + .../messaging/iOVM_L1MultiMessageRelayer.sol | 18 + .../messaging/iOVM_L2CrossDomainMessenger.sol | 30 + .../iOVM/bridge/tokens/iOVM_L1ETHGateway.sol | 55 + .../bridge/tokens/iOVM_L1TokenGateway.sol | 51 + .../bridge/tokens/iOVM_L2DepositedToken.sol | 51 + .../chain/iOVM_CanonicalTransactionChain.sol | 239 + .../iOVM/chain/iOVM_ChainStorageContainer.sol | 111 + .../iOVM/chain/iOVM_StateCommitmentChain.sol | 118 + .../iOVM/execution/iOVM_ExecutionManager.sol | 156 + .../iOVM/execution/iOVM_SafetyChecker.sol | 14 + .../iOVM/execution/iOVM_StateManager.sol | 77 + .../execution/iOVM_StateManagerFactory.sol | 23 + .../predeploys/iOVM_DeployerWhitelist.sol | 20 + .../iOVM/predeploys/iOVM_ERC20.sol | 53 + .../iOVM/predeploys/iOVM_L1MessageSender.sol | 14 + .../predeploys/iOVM_L2ToL1MessagePasser.sol | 25 + .../iOVM/verification/iOVM_BondManager.sol | 108 + .../iOVM/verification/iOVM_FraudVerifier.sol | 65 + .../verification/iOVM_StateTransitioner.sol | 83 + .../iOVM_StateTransitionerFactory.sol | 26 + .../bridge/OVM_CrossDomainEnabled.sol | 81 + .../libraries/codec/Lib_OVMCodec.sol | 371 + .../libraries/resolver/Lib_AddressManager.sol | 69 + .../resolver/Lib_AddressResolver.sol | 48 + .../libraries/resolver/Lib_Ownable.sol | 76 + .../resolver/Lib_ResolvedDelegateProxy.sol | 72 + .../libraries/rlp/Lib_RLPReader.sol | 625 ++ .../libraries/rlp/Lib_RLPWriter.sol | 283 + .../libraries/standards/IUniswapV2ERC20.sol | 24 + .../libraries/standards/UniSafeMath.sol | 18 + .../libraries/standards/UniswapV2ERC20.sol | 98 + .../libraries/trie/Lib_MerkleTrie.sol | 960 ++ .../libraries/trie/Lib_SecureMerkleTrie.sol | 162 + .../libraries/utils/Lib_Bytes32Utils.sol | 117 + .../libraries/utils/Lib_BytesUtils.sol | 221 + .../libraries/utils/Lib_ECDSAUtils.sol | 98 + .../libraries/utils/Lib_ErrorUtils.sol | 35 + .../libraries/utils/Lib_EthUtils.sol | 188 + .../libraries/utils/Lib_Math.sol | 35 + .../libraries/utils/Lib_MerkleTree.sol | 220 + .../libraries/utils/Lib_ReentrancyGuard.sol | 61 + .../libraries/utils/Lib_RingBuffer.sol | 376 + .../Lib_SafeExecutionManagerWrapper.sol | 376 + .../wrappers/Lib_SafeMathWrapper.sol | 168 + .../accounts/mockOVM_ECDSAContractAccount.sol | 95 + .../bridge/mockOVM_CrossDomainMessenger.sol | 145 + .../mockOVM_GenericCrossDomainMessenger.sol | 47 + .../verification/mockOVM_BondManager.sol | 88 + .../test-helpers/Helper_GasMeasurer.sol | 33 + .../test-helpers/Helper_ModifiableStorage.sol | 56 + .../test-helpers/Helper_PrecompileCaller.sol | 53 + .../test-helpers/Helper_SimpleProxy.sol | 49 + .../test-helpers/Helper_TestRunner.sol | 194 + .../test-helpers/Mock_FraudVerifier.sol | 35 + .../contracts/test-helpers/TestERC20.sol | 68 + .../test-libraries/codec/TestLib_OVMCodec.sol | 60 + .../test-libraries/rlp/TestLib_RLPReader.sol | 101 + .../test-libraries/rlp/TestLib_RLPWriter.sol | 97 + .../trie/TestLib_MerkleTrie.sol | 104 + .../trie/TestLib_SecureMerkleTrie.sol | 105 + .../utils/TestLib_Bytes32Utils.sol | 59 + .../utils/TestLib_BytesUtils.sol | 121 + .../utils/TestLib_ECDSAUtils.sol | 33 + .../test-libraries/utils/TestLib_EthUtils.sol | 118 + .../utils/TestLib_MerkleTree.sol | 48 + .../utils/TestLib_RingBuffer.sol | 71 + packages/contracts/hardhat.config.ts | 41 + packages/contracts/package.json | 73 + packages/contracts/prettier-config.json | 1 + packages/contracts/src/contract-defs.ts | 35 + .../src/contract-deployment/config.ts | 245 + .../src/contract-deployment/deploy.ts | 94 + .../src/contract-deployment/index.ts | 2 + packages/contracts/src/contract-dumps.ts | 262 + packages/contracts/src/index.ts | 3 + .../accounts/OVM_ECDSAContractAccount.spec.ts | 294 + .../OVM/accounts/OVM_ProxyEOA.spec.ts | 149 + .../bridge/assets/OVM_L1ERC20Gateway.spec.ts | 237 + .../bridge/assets/OVM_L1ETHGateway.spec.ts | 235 + .../assets/OVM_L2DepositedERC20.spec.ts | 207 + .../base/OVM_L1CrossDomainMessenger.spec.ts | 378 + .../bridge/base/OVM_L1MultiMessageRelayer.ts | 136 + .../base/OVM_L2CrossDomainMessenger.spec.ts | 161 + .../OVM_CanonicalTransactionChain.gas.spec.ts | 219 + .../OVM_CanonicalTransactionChain.spec.ts | 1469 +++ .../chain/OVM_StateCommitmentChain.spec.ts | 372 + .../OVM_ExecutionManager.gas-spec.ts | 121 + .../context-opcodes.spec.ts | 128 + .../OVM_ExecutionManager/nuisance-gas.spec.ts | 229 + .../OVM_ExecutionManager/ovmCALL.spec.ts | 268 + .../OVM_ExecutionManager/ovmCREATE.spec.ts | 967 ++ .../OVM_ExecutionManager/ovmCREATEEOA.spec.ts | 135 + .../ovmDELEGATECALL.spec.ts | 362 + .../OVM_ExecutionManager/ovmREVERT.spec.ts | 101 + .../OVM_ExecutionManager/ovmSLOAD.spec.ts | 75 + .../ovmSTATICCALL.spec.ts | 337 + .../OVM_ExecutionManager/run.spec.ts | 131 + .../OVM/execution/OVM_SafetyChecker.spec.ts | 30 + .../execution/OVM_StateManager.gas-spec.ts | 441 + .../OVM/execution/OVM_StateManager.spec.ts | 981 ++ .../precompiles/OVM_L1MessageSender.spec.ts | 67 + .../OVM_L2ToL1MessagePasser.spec.ts | 84 + .../OVM_ProxySequencerEntrypoint.spec.ts | 164 + .../OVM_SequencerEntrypoint.spec.ts | 182 + .../OVM/verification/OVM_BondManager.spec.ts | 410 + .../verification/OVM_FraudVerifier.spec.ts | 575 ++ .../OVM_StateTransitioner.spec.ts | 594 ++ .../OVM_StateTransitionerFactory.spec.ts | 59 + .../libraries/codec/Lib_OVMCodec.spec.ts | 12 + .../libraries/rlp/Lib_RLPReader.spec.ts | 9 + .../libraries/rlp/Lib_RLPWriter.spec.ts | 54 + .../libraries/trie/Lib_MerkleTrie.spec.ts | 169 + .../trie/Lib_SecureMerkleTrie.spec.ts | 119 + .../libraries/utils/Lib_Bytes32Utils.spec.ts | 9 + .../libraries/utils/Lib_BytesUtils.spec.ts | 32 + .../libraries/utils/Lib_ECDSAUtils.spec.ts | 9 + .../libraries/utils/Lib_EthUtils.spec.ts | 362 + .../libraries/utils/Lib_MerkleTree.spec.ts | 200 + .../verification/mockOVM_BondManager.spec.ts | 46 + packages/contracts/test/data/index.ts | 9 + .../test/data/json/create2.test.json | 61 + .../libraries/codec/Lib_OVMCodec.test.json | 22 + .../libraries/rlp/Lib_RLPReader.test.json | 316 + .../libraries/rlp/Lib_RLPWriter.test.json | 151 + .../libraries/trie/Lib_MerkleTrie.test.json | 340 + .../utils/Lib_Bytes32Utils.test.json | 48 + .../libraries/utils/Lib_BytesUtils.test.json | 108 + .../libraries/utils/Lib_ECDSAUtils.test.json | 126 + .../test/data/json/safety-checker.test.json | 1112 +++ .../contracts/test/helpers/codec/bridge.ts | 12 + .../contracts/test/helpers/codec/encoding.ts | 151 + .../contracts/test/helpers/codec/index.ts | 3 + .../test/helpers/codec/revert-flags.ts | 45 + packages/contracts/test/helpers/constants.ts | 50 + .../contracts/test/helpers/dummy/accounts.ts | 33 + .../contracts/test/helpers/dummy/batches.ts | 36 + .../contracts/test/helpers/dummy/bytecode.ts | 7 + .../contracts/test/helpers/dummy/bytes32.ts | 11 + .../contracts/test/helpers/dummy/context.ts | 20 + .../contracts/test/helpers/dummy/index.ts | 6 + .../test/helpers/dummy/transactions.ts | 48 + packages/contracts/test/helpers/gas/gas.ts | 25 + packages/contracts/test/helpers/gas/index.ts | 1 + packages/contracts/test/helpers/index.ts | 9 + .../test/helpers/resolver/address-manager.ts | 20 + .../contracts/test/helpers/resolver/index.ts | 1 + .../test/helpers/test-runner/index.ts | 3 + .../helpers/test-runner/json-test-runner.ts | 41 + .../test/helpers/test-runner/test-runner.ts | 517 + .../test/helpers/test-runner/test.types.ts | 310 + packages/contracts/test/helpers/trie/index.ts | 1 + .../test/helpers/trie/trie-test-generator.ts | 261 + .../contracts/test/helpers/types/index.ts | 1 + .../contracts/test/helpers/types/ovm-types.ts | 10 + .../test/helpers/utils/custom-deployer.ts | 23 + .../contracts/test/helpers/utils/eth-time.ts | 40 + .../contracts/test/helpers/utils/index.ts | 3 + .../contracts/test/helpers/utils/sol-utils.ts | 22 + packages/contracts/test/setup.ts | 10 + packages/contracts/tsconfig.build.json | 12 + packages/contracts/tsconfig.json | 8 + packages/contracts/tslint.json | 7 + packages/contracts/yarn.lock | 8594 +++++++++++++++++ .../src/utils/contracts.ts | 2 +- yarn.lock | 187 +- 207 files changed, 41472 insertions(+), 29 deletions(-) create mode 100644 packages/contracts/.gitattributes create mode 100644 packages/contracts/CHANGELOG.md create mode 100644 packages/contracts/LICENSE.txt create mode 100644 packages/contracts/README.md create mode 100755 packages/contracts/bin/deploy.js create mode 100755 packages/contracts/bin/gen_safety_checker_constants.py create mode 100755 packages/contracts/bin/serve_dump.sh create mode 100644 packages/contracts/bin/take-dump.ts create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ECDSAContractAccount.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ProxyEOA.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/Abs_BaseCrossDomainMessenger.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L1CrossDomainMessenger.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L1MultiMessageRelayer.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L2CrossDomainMessenger.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/Abs_L1TokenGateway.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/Abs_L2DepositedToken.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L1ERC20Gateway.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L1ETHGateway.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L2DepositedERC20.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/chain/OVM_CanonicalTransactionChain.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/chain/OVM_ChainStorageContainer.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/chain/OVM_StateCommitmentChain.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_SafetyChecker.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_StateManager.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_StateManagerFactory.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/ERC1820Registry.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_DeployerWhitelist.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_ETH.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_L1MessageSender.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_L2ToL1MessagePasser.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_ProxySequencerEntrypoint.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerEntrypoint.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/verification/Abs_FraudContributor.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_BondManager.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_FraudVerifier.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_StateTransitioner.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_StateTransitionerFactory.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/accounts/iOVM_ECDSAContractAccount.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iAbs_BaseCrossDomainMessenger.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_L1CrossDomainMessenger.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_L1MultiMessageRelayer.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_L2CrossDomainMessenger.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/tokens/iOVM_L1ETHGateway.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/tokens/iOVM_L1TokenGateway.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/tokens/iOVM_L2DepositedToken.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/chain/iOVM_CanonicalTransactionChain.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/chain/iOVM_ChainStorageContainer.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/chain/iOVM_StateCommitmentChain.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_ExecutionManager.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_SafetyChecker.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_StateManager.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_StateManagerFactory.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_DeployerWhitelist.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_ERC20.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_L1MessageSender.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_L2ToL1MessagePasser.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_BondManager.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_FraudVerifier.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_StateTransitioner.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_StateTransitionerFactory.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/bridge/OVM_CrossDomainEnabled.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/codec/Lib_OVMCodec.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_AddressManager.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_AddressResolver.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_Ownable.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_ResolvedDelegateProxy.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/rlp/Lib_RLPReader.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/rlp/Lib_RLPWriter.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/standards/IUniswapV2ERC20.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/standards/UniSafeMath.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/standards/UniswapV2ERC20.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/trie/Lib_MerkleTrie.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/trie/Lib_SecureMerkleTrie.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_Bytes32Utils.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_BytesUtils.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_ECDSAUtils.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_ErrorUtils.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_EthUtils.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_Math.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_MerkleTree.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_ReentrancyGuard.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_RingBuffer.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/libraries/wrappers/Lib_SafeMathWrapper.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/mockOVM/accounts/mockOVM_ECDSAContractAccount.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/mockOVM/bridge/mockOVM_CrossDomainMessenger.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/mockOVM/bridge/mockOVM_GenericCrossDomainMessenger.sol create mode 100644 packages/contracts/contracts/optimistic-ethereum/mockOVM/verification/mockOVM_BondManager.sol create mode 100644 packages/contracts/contracts/test-helpers/Helper_GasMeasurer.sol create mode 100644 packages/contracts/contracts/test-helpers/Helper_ModifiableStorage.sol create mode 100644 packages/contracts/contracts/test-helpers/Helper_PrecompileCaller.sol create mode 100644 packages/contracts/contracts/test-helpers/Helper_SimpleProxy.sol create mode 100644 packages/contracts/contracts/test-helpers/Helper_TestRunner.sol create mode 100644 packages/contracts/contracts/test-helpers/Mock_FraudVerifier.sol create mode 100644 packages/contracts/contracts/test-helpers/TestERC20.sol create mode 100644 packages/contracts/contracts/test-libraries/codec/TestLib_OVMCodec.sol create mode 100644 packages/contracts/contracts/test-libraries/rlp/TestLib_RLPReader.sol create mode 100644 packages/contracts/contracts/test-libraries/rlp/TestLib_RLPWriter.sol create mode 100644 packages/contracts/contracts/test-libraries/trie/TestLib_MerkleTrie.sol create mode 100644 packages/contracts/contracts/test-libraries/trie/TestLib_SecureMerkleTrie.sol create mode 100644 packages/contracts/contracts/test-libraries/utils/TestLib_Bytes32Utils.sol create mode 100644 packages/contracts/contracts/test-libraries/utils/TestLib_BytesUtils.sol create mode 100644 packages/contracts/contracts/test-libraries/utils/TestLib_ECDSAUtils.sol create mode 100644 packages/contracts/contracts/test-libraries/utils/TestLib_EthUtils.sol create mode 100644 packages/contracts/contracts/test-libraries/utils/TestLib_MerkleTree.sol create mode 100644 packages/contracts/contracts/test-libraries/utils/TestLib_RingBuffer.sol create mode 100644 packages/contracts/hardhat.config.ts create mode 100644 packages/contracts/package.json create mode 120000 packages/contracts/prettier-config.json create mode 100644 packages/contracts/src/contract-defs.ts create mode 100644 packages/contracts/src/contract-deployment/config.ts create mode 100644 packages/contracts/src/contract-deployment/deploy.ts create mode 100644 packages/contracts/src/contract-deployment/index.ts create mode 100644 packages/contracts/src/contract-dumps.ts create mode 100644 packages/contracts/src/index.ts create mode 100644 packages/contracts/test/contracts/OVM/accounts/OVM_ECDSAContractAccount.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/accounts/OVM_ProxyEOA.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/bridge/assets/OVM_L1ERC20Gateway.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/bridge/assets/OVM_L1ETHGateway.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/bridge/assets/OVM_L2DepositedERC20.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/bridge/base/OVM_L1CrossDomainMessenger.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/bridge/base/OVM_L1MultiMessageRelayer.ts create mode 100644 packages/contracts/test/contracts/OVM/bridge/base/OVM_L2CrossDomainMessenger.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/chain/OVM_CanonicalTransactionChain.gas.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/chain/OVM_CanonicalTransactionChain.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/chain/OVM_StateCommitmentChain.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager.gas-spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/context-opcodes.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/nuisance-gas.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmCALL.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmCREATE.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmCREATEEOA.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmDELEGATECALL.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmREVERT.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmSLOAD.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmSTATICCALL.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/run.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_SafetyChecker.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_StateManager.gas-spec.ts create mode 100644 packages/contracts/test/contracts/OVM/execution/OVM_StateManager.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/precompiles/OVM_L1MessageSender.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/precompiles/OVM_L2ToL1MessagePasser.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/precompiles/OVM_ProxySequencerEntrypoint.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/precompiles/OVM_SequencerEntrypoint.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/verification/OVM_BondManager.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/verification/OVM_FraudVerifier.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/verification/OVM_StateTransitioner.spec.ts create mode 100644 packages/contracts/test/contracts/OVM/verification/OVM_StateTransitionerFactory.spec.ts create mode 100644 packages/contracts/test/contracts/libraries/codec/Lib_OVMCodec.spec.ts create mode 100644 packages/contracts/test/contracts/libraries/rlp/Lib_RLPReader.spec.ts create mode 100644 packages/contracts/test/contracts/libraries/rlp/Lib_RLPWriter.spec.ts create mode 100644 packages/contracts/test/contracts/libraries/trie/Lib_MerkleTrie.spec.ts create mode 100644 packages/contracts/test/contracts/libraries/trie/Lib_SecureMerkleTrie.spec.ts create mode 100644 packages/contracts/test/contracts/libraries/utils/Lib_Bytes32Utils.spec.ts create mode 100644 packages/contracts/test/contracts/libraries/utils/Lib_BytesUtils.spec.ts create mode 100644 packages/contracts/test/contracts/libraries/utils/Lib_ECDSAUtils.spec.ts create mode 100644 packages/contracts/test/contracts/libraries/utils/Lib_EthUtils.spec.ts create mode 100644 packages/contracts/test/contracts/libraries/utils/Lib_MerkleTree.spec.ts create mode 100644 packages/contracts/test/contracts/mockOVM/verification/mockOVM_BondManager.spec.ts create mode 100644 packages/contracts/test/data/index.ts create mode 100644 packages/contracts/test/data/json/create2.test.json create mode 100644 packages/contracts/test/data/json/libraries/codec/Lib_OVMCodec.test.json create mode 100644 packages/contracts/test/data/json/libraries/rlp/Lib_RLPReader.test.json create mode 100644 packages/contracts/test/data/json/libraries/rlp/Lib_RLPWriter.test.json create mode 100644 packages/contracts/test/data/json/libraries/trie/Lib_MerkleTrie.test.json create mode 100644 packages/contracts/test/data/json/libraries/utils/Lib_Bytes32Utils.test.json create mode 100644 packages/contracts/test/data/json/libraries/utils/Lib_BytesUtils.test.json create mode 100644 packages/contracts/test/data/json/libraries/utils/Lib_ECDSAUtils.test.json create mode 100644 packages/contracts/test/data/json/safety-checker.test.json create mode 100644 packages/contracts/test/helpers/codec/bridge.ts create mode 100644 packages/contracts/test/helpers/codec/encoding.ts create mode 100644 packages/contracts/test/helpers/codec/index.ts create mode 100644 packages/contracts/test/helpers/codec/revert-flags.ts create mode 100644 packages/contracts/test/helpers/constants.ts create mode 100644 packages/contracts/test/helpers/dummy/accounts.ts create mode 100644 packages/contracts/test/helpers/dummy/batches.ts create mode 100644 packages/contracts/test/helpers/dummy/bytecode.ts create mode 100644 packages/contracts/test/helpers/dummy/bytes32.ts create mode 100644 packages/contracts/test/helpers/dummy/context.ts create mode 100644 packages/contracts/test/helpers/dummy/index.ts create mode 100644 packages/contracts/test/helpers/dummy/transactions.ts create mode 100644 packages/contracts/test/helpers/gas/gas.ts create mode 100644 packages/contracts/test/helpers/gas/index.ts create mode 100644 packages/contracts/test/helpers/index.ts create mode 100644 packages/contracts/test/helpers/resolver/address-manager.ts create mode 100644 packages/contracts/test/helpers/resolver/index.ts create mode 100644 packages/contracts/test/helpers/test-runner/index.ts create mode 100644 packages/contracts/test/helpers/test-runner/json-test-runner.ts create mode 100644 packages/contracts/test/helpers/test-runner/test-runner.ts create mode 100644 packages/contracts/test/helpers/test-runner/test.types.ts create mode 100644 packages/contracts/test/helpers/trie/index.ts create mode 100644 packages/contracts/test/helpers/trie/trie-test-generator.ts create mode 100644 packages/contracts/test/helpers/types/index.ts create mode 100644 packages/contracts/test/helpers/types/ovm-types.ts create mode 100644 packages/contracts/test/helpers/utils/custom-deployer.ts create mode 100644 packages/contracts/test/helpers/utils/eth-time.ts create mode 100644 packages/contracts/test/helpers/utils/index.ts create mode 100644 packages/contracts/test/helpers/utils/sol-utils.ts create mode 100644 packages/contracts/test/setup.ts create mode 100644 packages/contracts/tsconfig.build.json create mode 100644 packages/contracts/tsconfig.json create mode 100644 packages/contracts/tslint.json create mode 100644 packages/contracts/yarn.lock diff --git a/.gitignore b/.gitignore index 08b080178e1f..0a9428ee7726 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,14 @@ node_modules -**/dist results temp .nyc_output *.tsbuildinfo + +build +dist + +artifacts +artifacts-ovm +cache +cache-ovm + diff --git a/packages/contracts/.gitattributes b/packages/contracts/.gitattributes new file mode 100644 index 000000000000..52031de51c4c --- /dev/null +++ b/packages/contracts/.gitattributes @@ -0,0 +1 @@ +*.sol linguist-language=Solidity diff --git a/packages/contracts/CHANGELOG.md b/packages/contracts/CHANGELOG.md new file mode 100644 index 000000000000..84dd4d483ca3 --- /dev/null +++ b/packages/contracts/CHANGELOG.md @@ -0,0 +1,82 @@ +# Changelog + +## v0.1.11 +- cleanup: ECDSAContractAccount +- cleanup: Proxy_EOA +- cleanup: StateManagerFactory +- cleanup: Bytes32Utils +- cleanup: Minor cleanup to state manager +- cleanup: SafetyChecker +- Remove gas estimators from gateway interface +- Add ERC1820 Registry as a precompile +- dev: Remove usage of custom concat function in Solidity +- Fix revert string generated by EM wrapper +- Update OVM_L1ERC20Gateway.sol +- Move OVM_BondManager test into the right location + +## v0.1.10 +Adds extensible ERC20Gateway and Improve CI. + +- dev: Apply linting to all test files +- Test gas consumption of EM.run() +- Extensible deposit withdraw +- Update OVM_L2DepositedERC20.sol +- Commit state dumps to regenesis repo for new tags +- Update OVM_ChainStorageContainer.sol +- Update OVM_ECDSAContractAccount.sol +- Update OVM_CanonicalTransactionChain.sol +- Reset Context on invalid gaslimit +- [Fix] CI on merge +- [Fix] Run integration tests in forked context + +## v0.1.9 + +Standardized ETH and ERC20 Gateways. + +- Add ETH deposit contract. +- Add standard deposit/withdrawal interfaces. + +## v0.1.5 + +Various cleanup and maintenance tasks. + +- Improving comments and some names (#211) +- Add descriptive comments above the contract declaration for all 'non-abstract contracts' (#200) +- Add generic mock xdomain messenger (#209) +- Move everything over to hardhat (#208) +- Add comment to document v argument (#199) +- Add security related comments (#191) + +## v0.1.4 + +Fix single contract redeployment & state dump script for +mainnet. + +## v0.1.3 + +Add events to fraud proof initialization and finalization. + +## v0.1.2 + +Npm publish integrity. + +## v0.1.1 + +Audit fixes, deployment fixes & final parameterization. + +- Add build mainnet command to package.json (#186) +- revert chain ID 422 -> 420 (#185) +- add `AddressSet` event (#184) +- Add mint & burn to L2 ETH (#178) +- Wait for deploy transactions (#180) +- Final Parameterization of Constants (#176) +- re-enable monotonicity tests (#177) +- make ovmSETNONCE notStatic (#179) +- Add reentry protection to ExecutionManager.run() (#175) +- Add nonReentrant to `relayMessage()` (#172) +- ctc: public getters, remove dead variable (#174) +- fix tainted memory bug in `Lib_BytesUtils.slice` (#171) + +## v0.1.0 + +Initial Release diff --git a/packages/contracts/LICENSE.txt b/packages/contracts/LICENSE.txt new file mode 100644 index 000000000000..6389df6bc15c --- /dev/null +++ b/packages/contracts/LICENSE.txt @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright 2020 Optimism + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/packages/contracts/README.md b/packages/contracts/README.md new file mode 100644 index 000000000000..e8445641fb4d --- /dev/null +++ b/packages/contracts/README.md @@ -0,0 +1,76 @@ +# Optimistic Ethereum Smart Contracts + +`@eth-optimism/contracts` contains the various Solidity smart contracts used within the Optimistic Ethereum system. +Some of these contracts are deployed on Ethereum ("Layer 1"), while others are meant to be deployed to Optimistic Ethereum ("Layer 2"). + +Within each contract file you'll find a comment that lists: +1. The compiler with which a contract is intended to be compiled, `solc` or `optimistic-solc`. +2. The network upon to which the contract will be deployed, `OVM` or `EVM`. + +A more detailed overview of these contracts can be found on the [community hub](http://community.optimism.io/docs/protocol/protocol.html#system-overview). + + + +## Usage (npm) +If your development stack is based on Node/npm: + +```shell +npm install @eth-optimism/contracts +``` + +Within your contracts: + +```solidity +import { SomeContract } from "@eth-optimism/contracts/SomeContract.sol"; +``` + +## Guide for Developers +### Setup +Install the following: +- [`Node.js` (14+)](https://nodejs.org/en/) +- [`npm`](https://www.npmjs.com/get-npm) +- [`yarn`](https://classic.yarnpkg.com/en/docs/install/) + +Clone the repo: + +```shell +git clone https://github.com/ethereum-optimism/contracts.git +cd contracts +``` + +Install `npm` packages: +```shell +yarn install +``` + +### Running Tests +Tests are executed via `yarn`: +```shell +yarn test +``` + +Run specific tests by giving a path to the file you want to run: +```shell +yarn test ./test/path/to/my/test.spec.ts +``` + +### Compiling and Building +Easiest way is to run the primary build script: +```shell +yarn build +``` + +Running the full build command will perform the following actions: +1. `build:contracts` - Compile all Solidity contracts with both the EVM and OVM compilers. +2. `build:typescript` - Builds the typescript files that are used to export utilities into js. +3. `build:copy` - Copies various other files into the dist folder. +4. `build:dump` - Generates a genesis state from the contracts that L2 geth will use. +5. `build:typechain` - Generates [TypeChain](https://github.com/ethereum-ts/TypeChain) artifacts. + +You can also build specific components as follows: +```shell +yarn build:contracts +``` + +## Security +Please refer to our [Security Policy](https://github.com/ethereum-optimism/.github/security/policy) for information about how to disclose security issues with this code. diff --git a/packages/contracts/bin/deploy.js b/packages/contracts/bin/deploy.js new file mode 100755 index 000000000000..ece3ec7150d9 --- /dev/null +++ b/packages/contracts/bin/deploy.js @@ -0,0 +1,120 @@ +#!/usr/bin/env node + +const contracts = require('../dist/src/contract-deployment/deploy'); +const { providers, Wallet, utils, ethers } = require('ethers'); +const { LedgerSigner } = require('@ethersproject/hardware-wallets'); +const { JsonRpcProvider } = providers; + +const env = process.env; +const key = env.DEPLOYER_PRIVATE_KEY; +const sequencerKey = env.SEQUENCER_PRIVATE_KEY; +let SEQUENCER_ADDRESS = env.SEQUENCER_ADDRESS; +const web3Url = env.L1_NODE_WEB3_URL || 'http://127.0.0.1:8545'; +const DEPLOY_TX_GAS_LIMIT = env.DEPLOY_TX_GAS_LIMIT || 5000000; +const MIN_TRANSACTION_GAS_LIMIT = env.MIN_TRANSACTION_GAS_LIMIT || 50000; +const MAX_TRANSACTION_GAS_LIMIT = env.MAX_TRANSACTION_GAS_LIMIT || 9000000; +const MAX_GAS_PER_QUEUE_PER_EPOCH = env.MAX_GAS_PER_QUEUE_PER_EPOCH || 250000000; +const SECONDS_PER_EPOCH = env.SECONDS_PER_EPOCH || 0; +const WAIT_FOR_RECEIPTS = env.WAIT_FOR_RECEIPTS === 'true'; +let WHITELIST_OWNER = env.WHITELIST_OWNER; +const WHITELIST_ALLOW_ARBITRARY_CONTRACT_DEPLOYMENT = env.WHITELIST_ALLOW_ARBITRARY_CONTRACT_DEPLOYMENT || true; +const FORCE_INCLUSION_PERIOD_SECONDS = env.FORCE_INCLUSION_PERIOD_SECONDS || 2592000; // 30 days +const FRAUD_PROOF_WINDOW_SECONDS = env.FRAUD_PROOF_WINDOW_SECONDS || (60 * 60 * 24 * 7); // 7 days +const SEQUENCER_PUBLISH_WINDOW_SECONDS = env.SEQUENCER_PUBLISH_WINDOW_SECONDS || (60 * 30); // 30 min +const CHAIN_ID = env.CHAIN_ID || 420; // layer 2 chainid +const USE_LEDGER = env.USE_LEDGER || false; +const ADDRESS_MANAGER_ADDRESS = env.ADDRESS_MANAGER_ADDRESS || undefined; +const HD_PATH = env.HD_PATH || utils.defaultPath; +const BLOCK_TIME_SECONDS = env.BLOCK_TIME_SECONDS || 15; +const L2_CROSS_DOMAIN_MESSENGER_ADDRESS = + env.L2_CROSS_DOMAIN_MESSENGER_ADDRESS || '0x4200000000000000000000000000000000000007'; +let RELAYER_ADDRESS = env.RELAYER_ADDRESS || '0x0000000000000000000000000000000000000000'; +const RELAYER_PRIVATE_KEY = env.RELAYER_PRIVATE_KEY; + +(async () => { + const provider = new JsonRpcProvider(web3Url); + let signer; + + // Use the ledger for the deployer + if (USE_LEDGER) { + signer = new LedgerSigner(provider, 'default', HD_PATH); + } else { + if (typeof key === 'undefined') + throw new Error('Must pass deployer key as DEPLOYER_PRIVATE_KEY'); + signer = new Wallet(key, provider); + } + + if (SEQUENCER_ADDRESS) { + if (!utils.isAddress(SEQUENCER_ADDRESS)) + throw new Error(`Invalid Sequencer Address: ${SEQUENCER_ADDRESS}`); + } else { + if (!sequencerKey) + throw new Error('Must pass sequencer key as SEQUENCER_PRIVATE_KEY'); + const sequencer = new Wallet(sequencerKey, provider); + SEQUENCER_ADDRESS = await sequencer.getAddress(); + } + + if (typeof WHITELIST_OWNER === 'undefined') + WHITELIST_OWNER = signer; + + // Use the address derived from RELAYER_PRIVATE_KEY if a private key + // is passed. Using the zero address as the relayer address will mean + // there is no relayer authentication. + if (RELAYER_PRIVATE_KEY) { + if (!utils.isAddress(RELAYER_ADDRESS)) + throw new Error(`Invalid Relayer Address: ${RELAYER_ADDRESS}`); + const relayer = new Wallet(RELAYER_PRIVATE_KEY, provider); + RELAYER_ADDRESS = await relayer.getAddress(); + } + + const result = await contracts.deploy({ + deploymentSigner: signer, + transactionChainConfig: { + forceInclusionPeriodSeconds: FORCE_INCLUSION_PERIOD_SECONDS, + sequencer: SEQUENCER_ADDRESS, + forceInclusionPeriodBlocks: Math.ceil(FORCE_INCLUSION_PERIOD_SECONDS/BLOCK_TIME_SECONDS), + }, + stateChainConfig: { + fraudProofWindowSeconds: FRAUD_PROOF_WINDOW_SECONDS, + sequencerPublishWindowSeconds: SEQUENCER_PUBLISH_WINDOW_SECONDS, + }, + ovmGlobalContext: { + ovmCHAINID: CHAIN_ID, + L2CrossDomainMessengerAddress: L2_CROSS_DOMAIN_MESSENGER_ADDRESS + }, + l1CrossDomainMessengerConfig: { + relayerAddress: RELAYER_ADDRESS, + }, + ovmGasMeteringConfig: { + minTransactionGasLimit: MIN_TRANSACTION_GAS_LIMIT, + maxTransactionGasLimit: MAX_TRANSACTION_GAS_LIMIT, + maxGasPerQueuePerEpoch: MAX_GAS_PER_QUEUE_PER_EPOCH, + secondsPerEpoch: SECONDS_PER_EPOCH + }, + whitelistConfig: { + owner: WHITELIST_OWNER, + allowArbitraryContractDeployment: WHITELIST_ALLOW_ARBITRARY_CONTRACT_DEPLOYMENT + }, + deployOverrides: { + gasLimit: DEPLOY_TX_GAS_LIMIT + }, + waitForReceipts: WAIT_FOR_RECEIPTS, + addressManager: ADDRESS_MANAGER_ADDRESS, + }); + + const { failedDeployments, AddressManager } = result; + if (failedDeployments.length !== 0) + throw new Error(`Contract deployment failed: ${failedDeployments.join(',')}`); + + const out = {}; + out.AddressManager = AddressManager.address; + out.OVM_Sequencer = SEQUENCER_ADDRESS; + out.Deployer = await signer.getAddress() + for (const [name, contract] of Object.entries(result.contracts)) { + out[name] = contract.address; + } + console.log(JSON.stringify(out, null, 2)); +})().catch(err => { + console.log(JSON.stringify({error: err.message, stack: err.stack}, null, 2)); + process.exit(1); +}); diff --git a/packages/contracts/bin/gen_safety_checker_constants.py b/packages/contracts/bin/gen_safety_checker_constants.py new file mode 100755 index 000000000000..9d1d150aa562 --- /dev/null +++ b/packages/contracts/bin/gen_safety_checker_constants.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +# pip3 install pyevmasm +from pyevmasm import instruction_tables + +#print(instruction_tables.keys()) + +def asm(x): + return [instruction_tables['istanbul'][i].opcode for i in x] + +push_opcodes = asm(["PUSH%d" % i for i in range(1,33)]) +stop_opcodes = asm(["STOP", "JUMP", "RETURN", "INVALID"]) +caller_opcodes = asm(["CALLER"]) +blacklist_ops = set([ + "ADDRESS", "BALANCE", "BLOCKHASH", + "CALL", "CALLCODE", "CHAINID", "COINBASE", + "CREATE", "CREATE2", "DELEGATECALL", "DIFFICULTY", + "EXTCODESIZE", "EXTCODECOPY", "EXTCODEHASH", + "GASLIMIT", "GASPRICE", "NUMBER", + "ORIGIN", "REVERT", "SELFBALANCE", "SELFDESTRUCT", + "SLOAD", "SSTORE", "STATICCALL", "TIMESTAMP"]) +whitelist_opcodes = [] +for x in instruction_tables['istanbul']: + if x.name not in blacklist_ops: + whitelist_opcodes.append(x.opcode) + +pushmask = 0 +for x in push_opcodes: + pushmask |= 1 << x + +stopmask = 0 +for x in stop_opcodes: + stopmask |= 1 << x + +stoplist = [0]*256 +procmask = 0 +for i in range(256): + if i in whitelist_opcodes and \ + i not in push_opcodes and \ + i not in stop_opcodes and \ + i not in caller_opcodes: + # can skip this opcode + stoplist[i] = 1 + else: + procmask |= 1 << i + +# PUSH1 through PUSH4, can't skip in slow +for i in range(0x60, 0x64): + stoplist[i] = i-0x5e +rr = "uint256[8] memory opcodeSkippableBytes = [\n" +for i in range(0, 0x100, 0x20): + ret = "uint256(0x" + for j in range(i, i+0x20, 1): + ret += ("%02X" % stoplist[j]) + rr += ret+"),\n" + +rr = rr[:-2] + "];" + +print(rr) +print("// Mask to gate opcode specific cases") +print("uint256 opcodeGateMask = ~uint256(0x%x);" % procmask) +print("// Halting opcodes") +print("uint256 opcodeHaltingMask = ~uint256(0x%x);" % stopmask) +print("// PUSH opcodes") +print("uint256 opcodePushMask = ~uint256(0x%x);" % pushmask) + diff --git a/packages/contracts/bin/serve_dump.sh b/packages/contracts/bin/serve_dump.sh new file mode 100755 index 000000000000..ad97bccbf7b4 --- /dev/null +++ b/packages/contracts/bin/serve_dump.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Run this script to serve the latest state dump from +# an http server. This is useful to serve the state dump +# to a local instance of the sequencer/verifier during +# development. The state dump can be found at +# `GET /state-dump.latest.json` + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )" + +PYTHON=${PYTHON:-python} +HOST=${HOST:-0.0.0.0} +PORT=${PORT:-8081} +DIRECTORY=$DIR/../dist/dumps + +if [ ! command -v $PYTHON&>/dev/null ]; then + echo "Please install python" + exit 1 +fi + +VERSION=$($PYTHON --version 2>&1 \ + | cut -d ' ' -f2 \ + | sed -Ee's#([^/]).([^/]).([^/])#\1#') + + +if [[ $VERSION == 3 ]]; then + $PYTHON -m http.server \ + --bind $HOST $PORT \ + --directory $DIRECTORY +else + ( + echo "Serving HTTP on $HOST port $PORT" + cd $DIRECTORY + $PYTHON -c \ + 'import BaseHTTPServer as bhs, SimpleHTTPServer as shs; bhs.HTTPServer(("'$HOST'", '"$PORT"'), shs.SimpleHTTPRequestHandler).serve_forever()' + ) +fi diff --git a/packages/contracts/bin/take-dump.ts b/packages/contracts/bin/take-dump.ts new file mode 100644 index 000000000000..1cd997b86607 --- /dev/null +++ b/packages/contracts/bin/take-dump.ts @@ -0,0 +1,25 @@ +/* External Imports */ +import * as fs from 'fs' +import * as path from 'path' +import * as mkdirp from 'mkdirp' + +const env = process.env +const CHAIN_ID = env.CHAIN_ID || '420' + +/* Internal Imports */ +import { makeStateDump } from '../src/contract-dumps' +import { RollupDeployConfig } from '../src/contract-deployment' +;(async () => { + const outdir = path.resolve(__dirname, '../dist/dumps') + const outfile = path.join(outdir, 'state-dump.latest.json') + mkdirp.sync(outdir) + + const config = { + ovmGlobalContext: { + ovmCHAINID: parseInt(CHAIN_ID, 10), + }, + } + + const dump = await makeStateDump(config as RollupDeployConfig) + fs.writeFileSync(outfile, JSON.stringify(dump, null, 4)) +})() diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ECDSAContractAccount.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ECDSAContractAccount.sol new file mode 100644 index 000000000000..b3fd2c869ade --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ECDSAContractAccount.sol @@ -0,0 +1,140 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Interface Imports */ +import { iOVM_ECDSAContractAccount } from "../../iOVM/accounts/iOVM_ECDSAContractAccount.sol"; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; +import { Lib_ECDSAUtils } from "../../libraries/utils/Lib_ECDSAUtils.sol"; +import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol"; +import { Lib_SafeMathWrapper } from "../../libraries/wrappers/Lib_SafeMathWrapper.sol"; + +/** + * @title OVM_ECDSAContractAccount + * @dev The ECDSA Contract Account can be used as the implementation for a ProxyEOA deployed by the + * ovmCREATEEOA operation. It enables backwards compatibility with Ethereum's Layer 1, by + * providing eth_sign and EIP155 formatted transaction encodings. + * + * Compiler used: solc + * Runtime target: OVM + */ +contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount { + + /************* + * Constants * + *************/ + + // TODO: should be the amount sufficient to cover the gas costs of all of the transactions up + // to and including the CALL/CREATE which forms the entrypoint of the transaction. + uint256 constant EXECUTION_VALIDATION_GAS_OVERHEAD = 25000; + address constant ETH_ERC20_ADDRESS = 0x4200000000000000000000000000000000000006; + + + /******************** + * Public Functions * + ********************/ + + /** + * Executes a signed transaction. + * @param _transaction Signed EOA transaction. + * @param _signatureType Hashing scheme used for the transaction (e.g., ETH signed message). + * @param _v Signature `v` parameter. + * @param _r Signature `r` parameter. + * @param _s Signature `s` parameter. + * @return Whether or not the call returned (rather than reverted). + * @return Data returned by the call. + */ + function execute( + bytes memory _transaction, + Lib_OVMCodec.EOASignatureType _signatureType, + uint8 _v, + bytes32 _r, + bytes32 _s + ) + override + public + returns ( + bool, + bytes memory + ) + { + bool isEthSign = _signatureType == Lib_OVMCodec.EOASignatureType.ETH_SIGNED_MESSAGE; + + // Address of this contract within the ovm (ovmADDRESS) should be the same as the + // recovered address of the user who signed this message. This is how we manage to shim + // account abstraction even though the user isn't a contract. + // Need to make sure that the transaction nonce is right and bump it if so. + Lib_SafeExecutionManagerWrapper.safeREQUIRE( + Lib_ECDSAUtils.recover( + _transaction, + isEthSign, + _v, + _r, + _s + ) == Lib_SafeExecutionManagerWrapper.safeADDRESS(), + "Signature provided for EOA transaction execution is invalid." + ); + + Lib_OVMCodec.EIP155Transaction memory decodedTx = Lib_OVMCodec.decodeEIP155Transaction(_transaction, isEthSign); + + // Need to make sure that the transaction chainId is correct. + Lib_SafeExecutionManagerWrapper.safeREQUIRE( + decodedTx.chainId == Lib_SafeExecutionManagerWrapper.safeCHAINID(), + "Transaction chainId does not match expected OVM chainId." + ); + + // Need to make sure that the transaction nonce is right. + Lib_SafeExecutionManagerWrapper.safeREQUIRE( + decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(), + "Transaction nonce does not match the expected nonce." + ); + + // TEMPORARY: Disable gas checks for mainnet. + // // Need to make sure that the gas is sufficient to execute the transaction. + // Lib_SafeExecutionManagerWrapper.safeREQUIRE( + // gasleft() >= Lib_SafeMathWrapper.add(decodedTx.gasLimit, EXECUTION_VALIDATION_GAS_OVERHEAD), + // "Gas is not sufficient to execute the transaction." + // ); + + // Transfer fee to relayer. + address relayer = Lib_SafeExecutionManagerWrapper.safeCALLER(); + uint256 fee = Lib_SafeMathWrapper.mul(decodedTx.gasLimit, decodedTx.gasPrice); + (bool success, ) = Lib_SafeExecutionManagerWrapper.safeCALL( + gasleft(), + ETH_ERC20_ADDRESS, + abi.encodeWithSignature("transfer(address,uint256)", relayer, fee) + ); + Lib_SafeExecutionManagerWrapper.safeREQUIRE( + success == true, + "Fee was not transferred to relayer." + ); + + // Contract creations are signalled by sending a transaction to the zero address. + if (decodedTx.to == address(0)) { + (address created, bytes memory revertData) = Lib_SafeExecutionManagerWrapper.safeCREATE( + decodedTx.gasLimit, + decodedTx.data + ); + + // Return true if the contract creation succeeded, false w/ revertData otherwise. + if (created != address(0)) { + return (true, abi.encode(created)); + } else { + return (false, revertData); + } + } else { + // We only want to bump the nonce for `ovmCALL` because `ovmCREATE` automatically bumps + // the nonce of the calling account. Normally an EOA would bump the nonce for both + // cases, but since this is a contract we'd end up bumping the nonce twice. + Lib_SafeExecutionManagerWrapper.safeINCREMENTNONCE(); + + return Lib_SafeExecutionManagerWrapper.safeCALL( + decodedTx.gasLimit, + decodedTx.to, + decodedTx.data + ); + } + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ProxyEOA.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ProxyEOA.sol new file mode 100644 index 000000000000..0f376f821fee --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ProxyEOA.sol @@ -0,0 +1,121 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_Bytes32Utils } from "../../libraries/utils/Lib_Bytes32Utils.sol"; +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; +import { Lib_ECDSAUtils } from "../../libraries/utils/Lib_ECDSAUtils.sol"; +import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol"; + +/** + * @title OVM_ProxyEOA + * @dev The Proxy EOA contract uses a delegate call to execute the logic in an implementation contract. + * In combination with the logic implemented in the ECDSA Contract Account, this enables a form of upgradable + * 'account abstraction' on layer 2. + * + * Compiler used: solc + * Runtime target: OVM + */ +contract OVM_ProxyEOA { + + /************* + * Constants * + *************/ + + bytes32 constant IMPLEMENTATION_KEY = 0xdeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead; + + + /*************** + * Constructor * + ***************/ + + /** + * @param _implementation Address of the initial implementation contract. + */ + constructor( + address _implementation + ) + { + _setImplementation(_implementation); + } + + + /********************* + * Fallback Function * + *********************/ + + fallback() + external + { + (bool success, bytes memory returndata) = Lib_SafeExecutionManagerWrapper.safeDELEGATECALL( + gasleft(), + getImplementation(), + msg.data + ); + + if (success) { + assembly { + return(add(returndata, 0x20), mload(returndata)) + } + } else { + Lib_SafeExecutionManagerWrapper.safeREVERT( + string(returndata) + ); + } + } + + + /******************** + * Public Functions * + ********************/ + + /** + * Changes the implementation address. + * @param _implementation New implementation address. + */ + function upgrade( + address _implementation + ) + external + { + Lib_SafeExecutionManagerWrapper.safeREQUIRE( + Lib_SafeExecutionManagerWrapper.safeADDRESS() == Lib_SafeExecutionManagerWrapper.safeCALLER(), + "EOAs can only upgrade their own EOA implementation" + ); + + _setImplementation(_implementation); + } + + /** + * Gets the address of the current implementation. + * @return Current implementation address. + */ + function getImplementation() + public + returns ( + address + ) + { + return Lib_Bytes32Utils.toAddress( + Lib_SafeExecutionManagerWrapper.safeSLOAD( + IMPLEMENTATION_KEY + ) + ); + } + + + /********************** + * Internal Functions * + **********************/ + + function _setImplementation( + address _implementation + ) + internal + { + Lib_SafeExecutionManagerWrapper.safeSSTORE( + IMPLEMENTATION_KEY, + Lib_Bytes32Utils.fromAddress(_implementation) + ); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/Abs_BaseCrossDomainMessenger.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/Abs_BaseCrossDomainMessenger.sol new file mode 100644 index 000000000000..d4aa9ae404de --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/Abs_BaseCrossDomainMessenger.sol @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Interface Imports */ +import { iAbs_BaseCrossDomainMessenger } from "../../../iOVM/bridge/messaging/iAbs_BaseCrossDomainMessenger.sol"; + +/* Library Imports */ +import { Lib_ReentrancyGuard } from "../../../libraries/utils/Lib_ReentrancyGuard.sol"; + +/** + * @title Abs_BaseCrossDomainMessenger + * @dev The Base Cross Domain Messenger is an abstract contract providing the interface and common functionality used in the + * L1 and L2 Cross Domain Messengers. It can also serve as a template for developers wishing to implement a custom bridge + * contract to suit their needs. + * + * Compiler used: defined by child contract + * Runtime target: defined by child contract + */ +abstract contract Abs_BaseCrossDomainMessenger is iAbs_BaseCrossDomainMessenger, Lib_ReentrancyGuard { + /************** + * Constants * + **************/ + + // The default x-domain message sender being set to a non-zero value makes + // deployment a bit more expensive, but in exchange the refund on every call to + // `relayMessage` by the L1 and L2 messengers will be higher. + address internal constant DEFAULT_XDOMAIN_SENDER = 0x000000000000000000000000000000000000dEaD; + + /********************** + * Contract Variables * + **********************/ + + mapping (bytes32 => bool) public relayedMessages; + mapping (bytes32 => bool) public successfulMessages; + mapping (bytes32 => bool) public sentMessages; + uint256 public messageNonce; + address internal xDomainMsgSender = DEFAULT_XDOMAIN_SENDER; + + /******************** + * Public Functions * + ********************/ + + constructor() Lib_ReentrancyGuard() {} + + function xDomainMessageSender() public override view returns (address) { + require(xDomainMsgSender != DEFAULT_XDOMAIN_SENDER, "xDomainMessageSender is not set"); + return xDomainMsgSender; + } + + /** + * Sends a cross domain message to the target messenger. + * @param _target Target contract address. + * @param _message Message to send to the target. + * @param _gasLimit Gas limit for the provided message. + */ + function sendMessage( + address _target, + bytes memory _message, + uint32 _gasLimit + ) + override + public + { + bytes memory xDomainCalldata = _getXDomainCalldata( + _target, + msg.sender, + _message, + messageNonce + ); + + messageNonce += 1; + sentMessages[keccak256(xDomainCalldata)] = true; + + _sendXDomainMessage(xDomainCalldata, _gasLimit); + emit SentMessage(xDomainCalldata); + } + + /********************** + * Internal Functions * + **********************/ + + /** + * Generates the correct cross domain calldata for a message. + * @param _target Target contract address. + * @param _sender Message sender address. + * @param _message Message to send to the target. + * @param _messageNonce Nonce for the provided message. + * @return ABI encoded cross domain calldata. + */ + function _getXDomainCalldata( + address _target, + address _sender, + bytes memory _message, + uint256 _messageNonce + ) + internal + pure + returns ( + bytes memory + ) + { + return abi.encodeWithSignature( + "relayMessage(address,address,bytes,uint256)", + _target, + _sender, + _message, + _messageNonce + ); + } + + /** + * Sends a cross domain message. + * param // Message to send. + * param // Gas limit for the provided message. + */ + function _sendXDomainMessage( + bytes memory, // _message, + uint256 // _gasLimit + ) + virtual + internal + { + revert("Implement me in child contracts!"); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L1CrossDomainMessenger.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L1CrossDomainMessenger.sol new file mode 100644 index 000000000000..8060749ad906 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L1CrossDomainMessenger.sol @@ -0,0 +1,294 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../../libraries/codec/Lib_OVMCodec.sol"; +import { Lib_AddressResolver } from "../../../libraries/resolver/Lib_AddressResolver.sol"; +import { Lib_AddressManager } from "../../../libraries/resolver/Lib_AddressManager.sol"; +import { Lib_SecureMerkleTrie } from "../../../libraries/trie/Lib_SecureMerkleTrie.sol"; +import { Lib_ReentrancyGuard } from "../../../libraries/utils/Lib_ReentrancyGuard.sol"; + +/* Interface Imports */ +import { iOVM_L1CrossDomainMessenger } from "../../../iOVM/bridge/messaging/iOVM_L1CrossDomainMessenger.sol"; +import { iOVM_CanonicalTransactionChain } from "../../../iOVM/chain/iOVM_CanonicalTransactionChain.sol"; +import { iOVM_StateCommitmentChain } from "../../../iOVM/chain/iOVM_StateCommitmentChain.sol"; + +/* Contract Imports */ +import { Abs_BaseCrossDomainMessenger } from "./Abs_BaseCrossDomainMessenger.sol"; + +/** + * @title OVM_L1CrossDomainMessenger + * @dev The L1 Cross Domain Messenger contract sends messages from L1 to L2, and relays messages from L2 onto L1. + * In the event that a message sent from L1 to L2 is rejected for exceeding the L2 epoch gas limit, it can be resubmitted + * via this contract's replay function. + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, Abs_BaseCrossDomainMessenger, Lib_AddressResolver { + + /*************** + * Constructor * + ***************/ + + /** + * Pass a default zero address to the address resolver. This will be updated when initialized. + */ + constructor() + Lib_AddressResolver(address(0)) + {} + + /** + * @param _libAddressManager Address of the Address Manager. + */ + function initialize( + address _libAddressManager + ) + public + { + require(address(libAddressManager) == address(0), "L1CrossDomainMessenger already intialized."); + libAddressManager = Lib_AddressManager(_libAddressManager); + xDomainMsgSender = DEFAULT_XDOMAIN_SENDER; + } + + + /********************** + * Function Modifiers * + **********************/ + + /** + * Modifier to enforce that, if configured, only the OVM_L2MessageRelayer contract may successfully call a method. + */ + modifier onlyRelayer() { + address relayer = resolve("OVM_L2MessageRelayer"); + if (relayer != address(0)) { + require( + msg.sender == relayer, + "Only OVM_L2MessageRelayer can relay L2-to-L1 messages." + ); + } + _; + } + + + /******************** + * Public Functions * + ********************/ + + /** + * Relays a cross domain message to a contract. + * @inheritdoc iOVM_L1CrossDomainMessenger + */ + function relayMessage( + address _target, + address _sender, + bytes memory _message, + uint256 _messageNonce, + L2MessageInclusionProof memory _proof + ) + override + public + nonReentrant + onlyRelayer() + { + bytes memory xDomainCalldata = _getXDomainCalldata( + _target, + _sender, + _message, + _messageNonce + ); + + require( + _verifyXDomainMessage( + xDomainCalldata, + _proof + ) == true, + "Provided message could not be verified." + ); + + bytes32 xDomainCalldataHash = keccak256(xDomainCalldata); + + require( + successfulMessages[xDomainCalldataHash] == false, + "Provided message has already been received." + ); + + xDomainMsgSender = _sender; + (bool success, ) = _target.call(_message); + xDomainMsgSender = DEFAULT_XDOMAIN_SENDER; + + // Mark the message as received if the call was successful. Ensures that a message can be + // relayed multiple times in the case that the call reverted. + if (success == true) { + successfulMessages[xDomainCalldataHash] = true; + emit RelayedMessage(xDomainCalldataHash); + } + + // Store an identifier that can be used to prove that the given message was relayed by some + // user. Gives us an easy way to pay relayers for their work. + bytes32 relayId = keccak256( + abi.encodePacked( + xDomainCalldata, + msg.sender, + block.number + ) + ); + relayedMessages[relayId] = true; + } + + /** + * Replays a cross domain message to the target messenger. + * @inheritdoc iOVM_L1CrossDomainMessenger + */ + function replayMessage( + address _target, + address _sender, + bytes memory _message, + uint256 _messageNonce, + uint32 _gasLimit + ) + override + public + { + bytes memory xDomainCalldata = _getXDomainCalldata( + _target, + _sender, + _message, + _messageNonce + ); + + require( + sentMessages[keccak256(xDomainCalldata)] == true, + "Provided message has not already been sent." + ); + + _sendXDomainMessage(xDomainCalldata, _gasLimit); + } + + + /********************** + * Internal Functions * + **********************/ + + /** + * Verifies that the given message is valid. + * @param _xDomainCalldata Calldata to verify. + * @param _proof Inclusion proof for the message. + * @return Whether or not the provided message is valid. + */ + function _verifyXDomainMessage( + bytes memory _xDomainCalldata, + L2MessageInclusionProof memory _proof + ) + internal + view + returns ( + bool + ) + { + return ( + _verifyStateRootProof(_proof) + && _verifyStorageProof(_xDomainCalldata, _proof) + ); + } + + /** + * Verifies that the state root within an inclusion proof is valid. + * @param _proof Message inclusion proof. + * @return Whether or not the provided proof is valid. + */ + function _verifyStateRootProof( + L2MessageInclusionProof memory _proof + ) + internal + view + returns ( + bool + ) + { + iOVM_StateCommitmentChain ovmStateCommitmentChain = iOVM_StateCommitmentChain(resolve("OVM_StateCommitmentChain")); + + return ( + ovmStateCommitmentChain.insideFraudProofWindow(_proof.stateRootBatchHeader) == false + && ovmStateCommitmentChain.verifyStateCommitment( + _proof.stateRoot, + _proof.stateRootBatchHeader, + _proof.stateRootProof + ) + ); + } + + /** + * Verifies that the storage proof within an inclusion proof is valid. + * @param _xDomainCalldata Encoded message calldata. + * @param _proof Message inclusion proof. + * @return Whether or not the provided proof is valid. + */ + function _verifyStorageProof( + bytes memory _xDomainCalldata, + L2MessageInclusionProof memory _proof + ) + internal + view + returns ( + bool + ) + { + bytes32 storageKey = keccak256( + abi.encodePacked( + keccak256( + abi.encodePacked( + _xDomainCalldata, + resolve("OVM_L2CrossDomainMessenger") + ) + ), + uint256(0) + ) + ); + + ( + bool exists, + bytes memory encodedMessagePassingAccount + ) = Lib_SecureMerkleTrie.get( + abi.encodePacked(0x4200000000000000000000000000000000000000), + _proof.stateTrieWitness, + _proof.stateRoot + ); + + require( + exists == true, + "Message passing predeploy has not been initialized or invalid proof provided." + ); + + Lib_OVMCodec.EVMAccount memory account = Lib_OVMCodec.decodeEVMAccount( + encodedMessagePassingAccount + ); + + return Lib_SecureMerkleTrie.verifyInclusionProof( + abi.encodePacked(storageKey), + abi.encodePacked(uint8(1)), + _proof.storageTrieWitness, + account.storageRoot + ); + } + + /** + * Sends a cross domain message. + * @param _message Message to send. + * @param _gasLimit OVM gas limit for the message. + */ + function _sendXDomainMessage( + bytes memory _message, + uint256 _gasLimit + ) + override + internal + { + iOVM_CanonicalTransactionChain(resolve("OVM_CanonicalTransactionChain")).enqueue( + resolve("OVM_L2CrossDomainMessenger"), + _gasLimit, + _message + ); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L1MultiMessageRelayer.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L1MultiMessageRelayer.sol new file mode 100644 index 000000000000..921ca5d09c0a --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L1MultiMessageRelayer.sol @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: MIT +// @unsupported: ovm +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; +/* Interface Imports */ +import { iOVM_L1CrossDomainMessenger } from "../../../iOVM/bridge/messaging/iOVM_L1CrossDomainMessenger.sol"; +import { iOVM_L1MultiMessageRelayer } from "../../../iOVM/bridge/messaging/iOVM_L1MultiMessageRelayer.sol"; + +/* Contract Imports */ +import { Lib_AddressResolver } from "../../../libraries/resolver/Lib_AddressResolver.sol"; + + +/** + * @title OVM_L1MultiMessageRelayer + * @dev The L1 Multi-Message Relayer contract is a gas efficiency optimization which enables the + * relayer to submit multiple messages in a single transaction to be relayed by the L1 Cross Domain + * Message Sender. + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_L1MultiMessageRelayer is iOVM_L1MultiMessageRelayer, Lib_AddressResolver { + + /*************** + * Constructor * + ***************/ + constructor( + address _libAddressManager + ) + Lib_AddressResolver(_libAddressManager) + {} + + /********************** + * Function Modifiers * + **********************/ + + modifier onlyBatchRelayer() { + require( + msg.sender == resolve("OVM_L2BatchMessageRelayer"), + "OVM_L1MultiMessageRelayer: Function can only be called by the OVM_L2BatchMessageRelayer" + ); + _; + } + + /******************** + * Public Functions * + ********************/ + + /** + * @notice Forwards multiple cross domain messages to the L1 Cross Domain Messenger for relaying + * @param _messages An array of L2 to L1 messages + */ + function batchRelayMessages(L2ToL1Message[] calldata _messages) + override + external + onlyBatchRelayer + { + iOVM_L1CrossDomainMessenger messenger = iOVM_L1CrossDomainMessenger(resolve("Proxy__OVM_L1CrossDomainMessenger")); + for (uint256 i = 0; i < _messages.length; i++) { + L2ToL1Message memory message = _messages[i]; + messenger.relayMessage( + message.target, + message.sender, + message.message, + message.messageNonce, + message.proof + ); + } + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L2CrossDomainMessenger.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L2CrossDomainMessenger.sol new file mode 100644 index 000000000000..2a1cf6082f41 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L2CrossDomainMessenger.sol @@ -0,0 +1,136 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_AddressResolver } from "../../../libraries/resolver/Lib_AddressResolver.sol"; +import { Lib_ReentrancyGuard } from "../../../libraries/utils/Lib_ReentrancyGuard.sol"; + +/* Interface Imports */ +import { iOVM_L2CrossDomainMessenger } from "../../../iOVM/bridge/messaging/iOVM_L2CrossDomainMessenger.sol"; +import { iOVM_L1MessageSender } from "../../../iOVM/predeploys/iOVM_L1MessageSender.sol"; +import { iOVM_L2ToL1MessagePasser } from "../../../iOVM/predeploys/iOVM_L2ToL1MessagePasser.sol"; + +/* Contract Imports */ +import { Abs_BaseCrossDomainMessenger } from "./Abs_BaseCrossDomainMessenger.sol"; + +/** + * @title OVM_L2CrossDomainMessenger + * @dev The L2 Cross Domain Messenger contract sends messages from L2 to L1, and is the entry point + * for L2 messages sent via the L1 Cross Domain Messenger. + * + * Compiler used: optimistic-solc + * Runtime target: OVM + */ +contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, Abs_BaseCrossDomainMessenger, Lib_AddressResolver { + + /*************** + * Constructor * + ***************/ + + /** + * @param _libAddressManager Address of the Address Manager. + */ + constructor( + address _libAddressManager + ) + Lib_AddressResolver(_libAddressManager) + {} + + + /******************** + * Public Functions * + ********************/ + + /** + * Relays a cross domain message to a contract. + * @inheritdoc iOVM_L2CrossDomainMessenger + */ + function relayMessage( + address _target, + address _sender, + bytes memory _message, + uint256 _messageNonce + ) + override + nonReentrant + public + { + require( + _verifyXDomainMessage() == true, + "Provided message could not be verified." + ); + + bytes memory xDomainCalldata = _getXDomainCalldata( + _target, + _sender, + _message, + _messageNonce + ); + + bytes32 xDomainCalldataHash = keccak256(xDomainCalldata); + + require( + successfulMessages[xDomainCalldataHash] == false, + "Provided message has already been received." + ); + + xDomainMsgSender = _sender; + (bool success, ) = _target.call(_message); + xDomainMsgSender = DEFAULT_XDOMAIN_SENDER; + + // Mark the message as received if the call was successful. Ensures that a message can be + // relayed multiple times in the case that the call reverted. + if (success == true) { + successfulMessages[xDomainCalldataHash] = true; + emit RelayedMessage(xDomainCalldataHash); + } + + // Store an identifier that can be used to prove that the given message was relayed by some + // user. Gives us an easy way to pay relayers for their work. + bytes32 relayId = keccak256( + abi.encodePacked( + xDomainCalldata, + msg.sender, + block.number + ) + ); + relayedMessages[relayId] = true; + } + + + /********************** + * Internal Functions * + **********************/ + + /** + * Verifies that a received cross domain message is valid. + * @return _valid Whether or not the message is valid. + */ + function _verifyXDomainMessage() + view + internal + returns ( + bool _valid + ) + { + return ( + iOVM_L1MessageSender(resolve("OVM_L1MessageSender")).getL1MessageSender() == resolve("OVM_L1CrossDomainMessenger") + ); + } + + /** + * Sends a cross domain message. + * @param _message Message to send. + * param _gasLimit Gas limit for the provided message. + */ + function _sendXDomainMessage( + bytes memory _message, + uint256 // _gasLimit + ) + override + internal + { + iOVM_L2ToL1MessagePasser(resolve("OVM_L2ToL1MessagePasser")).passMessageToL1(_message); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/Abs_L1TokenGateway.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/Abs_L1TokenGateway.sol new file mode 100644 index 000000000000..0ea573f763ea --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/Abs_L1TokenGateway.sol @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: MIT +// @unsupported: ovm +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Interface Imports */ +import { iOVM_L1TokenGateway } from "../../../iOVM/bridge/tokens/iOVM_L1TokenGateway.sol"; +import { iOVM_L2DepositedToken } from "../../../iOVM/bridge/tokens/iOVM_L2DepositedToken.sol"; + +/* Library Imports */ +import { OVM_CrossDomainEnabled } from "../../../libraries/bridge/OVM_CrossDomainEnabled.sol"; + +/** + * @title Abs_L1TokenGateway + * @dev An L1 Token Gateway is a contract which stores deposited L1 funds that are in use on L2. + * It synchronizes a corresponding L2 representation of the "deposited token", informing it + * of new deposits and releasing L1 funds when there are newly finalized withdrawals. + * + * NOTE: This abstract contract gives all the core functionality of an L1 token gateway, + * but provides easy hooks in case developers need extensions in child contracts. + * In many cases, the default OVM_L1ERC20Gateway will suffice. + * + * Compiler used: solc + * Runtime target: EVM + */ +abstract contract Abs_L1TokenGateway is iOVM_L1TokenGateway, OVM_CrossDomainEnabled { + + /******************************** + * External Contract References * + ********************************/ + + address public l2DepositedToken; + + /*************** + * Constructor * + ***************/ + + /** + * @param _l2DepositedToken iOVM_L2DepositedToken-compatible address on the chain being deposited into. + * @param _l1messenger L1 Messenger address being used for cross-chain communications. + */ + constructor( + address _l2DepositedToken, + address _l1messenger + ) + OVM_CrossDomainEnabled(_l1messenger) + { + l2DepositedToken = _l2DepositedToken; + } + + /******************************** + * Overridable Accounting logic * + ********************************/ + + // Default gas value which can be overridden if more complex logic runs on L2. + uint32 public DEFAULT_FINALIZE_DEPOSIT_L2_GAS = 1200000; + + /** + * @dev Core logic to be performed when a withdrawal is finalized on L1. + * In most cases, this will simply send locked funds to the withdrawer. + * + * param _to Address being withdrawn to. + * param _amount Amount being withdrawn. + */ + function _handleFinalizeWithdrawal( + address, // _to, + uint256 // _amount + ) + internal + virtual + { + revert("Implement me in child contracts"); + } + + /** + * @dev Core logic to be performed when a deposit is initiated on L1. + * In most cases, this will simply send locked funds to the withdrawer. + * + * param _from Address being deposited from on L1. + * param _to Address being deposited into on L2. + * param _amount Amount being deposited. + */ + function _handleInitiateDeposit( + address, // _from, + address, // _to, + uint256 // _amount + ) + internal + virtual + { + revert("Implement me in child contracts"); + } + + /** + * @dev Overridable getter for the L2 gas limit, in the case it may be + * dynamic, and the above public constant does not suffice. + * + */ + + function getFinalizeDepositL2Gas() + public + view + returns( + uint32 + ) + { + return DEFAULT_FINALIZE_DEPOSIT_L2_GAS; + } + + /************** + * Depositing * + **************/ + + /** + * @dev deposit an amount of the ERC20 to the caller's balance on L2 + * @param _amount Amount of the ERC20 to deposit + */ + function deposit( + uint _amount + ) + public + override + { + _initiateDeposit(msg.sender, msg.sender, _amount); + } + + /** + * @dev deposit an amount of ERC20 to a recipients's balance on L2 + * @param _to L2 address to credit the withdrawal to + * @param _amount Amount of the ERC20 to deposit + */ + function depositTo( + address _to, + uint _amount + ) + public + override + { + _initiateDeposit(msg.sender, _to, _amount); + } + + /** + * @dev Performs the logic for deposits by informing the L2 Deposited Token + * contract of the deposit and calling a handler to lock the L1 funds. (e.g. transferFrom) + * + * @param _from Account to pull the deposit from on L1 + * @param _to Account to give the deposit to on L2 + * @param _amount Amount of the ERC20 to deposit. + */ + function _initiateDeposit( + address _from, + address _to, + uint _amount + ) + internal + { + // Call our deposit accounting handler implemented by child contracts. + _handleInitiateDeposit( + _from, + _to, + _amount + ); + + // Construct calldata for l2DepositedToken.finalizeDeposit(_to, _amount) + bytes memory data = abi.encodeWithSelector( + iOVM_L2DepositedToken.finalizeDeposit.selector, + _to, + _amount + ); + + // Send calldata into L2 + sendCrossDomainMessage( + l2DepositedToken, + data, + getFinalizeDepositL2Gas() + ); + + emit DepositInitiated(_from, _to, _amount); + } + + /************************* + * Cross-chain Functions * + *************************/ + + /** + * @dev Complete a withdrawal from L2 to L1, and credit funds to the recipient's balance of the + * L1 ERC20 token. + * This call will fail if the initialized withdrawal from L2 has not been finalized. + * + * @param _to L1 address to credit the withdrawal to + * @param _amount Amount of the ERC20 to withdraw + */ + function finalizeWithdrawal( + address _to, + uint _amount + ) + external + override + onlyFromCrossDomainAccount(l2DepositedToken) + { + // Call our withdrawal accounting handler implemented by child contracts. + _handleFinalizeWithdrawal( + _to, + _amount + ); + + emit WithdrawalFinalized(_to, _amount); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/Abs_L2DepositedToken.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/Abs_L2DepositedToken.sol new file mode 100644 index 000000000000..c0245a881b70 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/Abs_L2DepositedToken.sol @@ -0,0 +1,230 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Interface Imports */ +import { iOVM_L2DepositedToken } from "../../../iOVM/bridge/tokens/iOVM_L2DepositedToken.sol"; +import { iOVM_L1TokenGateway } from "../../../iOVM/bridge/tokens/iOVM_L1TokenGateway.sol"; + +/* Library Imports */ +import { OVM_CrossDomainEnabled } from "../../../libraries/bridge/OVM_CrossDomainEnabled.sol"; + +/** + * @title Abs_L2DepositedToken + * @dev An L2 Deposited Token is an L2 representation of funds which were deposited from L1. + * Usually contract mints new tokens when it hears about deposits into the L1 ERC20 gateway. + * This contract also burns the tokens intended for withdrawal, informing the L1 gateway to release L1 funds. + * + * NOTE: This abstract contract gives all the core functionality of a deposited token implementation except for the + * token's internal accounting itself. This gives developers an easy way to implement children with their own token code. + * + * Compiler used: optimistic-solc + * Runtime target: OVM + */ +abstract contract Abs_L2DepositedToken is iOVM_L2DepositedToken, OVM_CrossDomainEnabled { + + /******************* + * Contract Events * + *******************/ + + event Initialized(iOVM_L1TokenGateway _l1TokenGateway); + + /******************************** + * External Contract References * + ********************************/ + + iOVM_L1TokenGateway public l1TokenGateway; + + /******************************** + * Constructor & Initialization * + ********************************/ + + /** + * @param _l2CrossDomainMessenger L1 Messenger address being used for cross-chain communications. + */ + constructor( + address _l2CrossDomainMessenger + ) + OVM_CrossDomainEnabled(_l2CrossDomainMessenger) + {} + + /** + * @dev Initialize this contract with the L1 token gateway address. + * The flow: 1) this contract gets deployed on L2, 2) the L1 + * gateway is deployed with addr from (1), 3) L1 gateway address passed here. + * + * @param _l1TokenGateway Address of the corresponding L1 gateway deployed to the main chain + */ + + function init( + iOVM_L1TokenGateway _l1TokenGateway + ) + public + { + require(address(l1TokenGateway) == address(0), "Contract has already been initialized"); + + l1TokenGateway = _l1TokenGateway; + + emit Initialized(l1TokenGateway); + } + + /********************** + * Function Modifiers * + **********************/ + + modifier onlyInitialized() { + require(address(l1TokenGateway) != address(0), "Contract has not yet been initialized"); + _; + } + + /******************************** + * Overridable Accounting logic * + ********************************/ + + // Default gas value which can be overridden if more complex logic runs on L2. + uint32 constant DEFAULT_FINALIZE_WITHDRAWAL_L1_GAS = 100000; + + /** + * @dev Core logic to be performed when a withdrawal from L2 is initialized. + * In most cases, this will simply burn the withdrawn L2 funds. + * + * param _to Address being withdrawn to + * param _amount Amount being withdrawn + */ + + function _handleInitiateWithdrawal( + address, // _to, + uint // _amount + ) + internal + virtual + { + revert("Accounting must be implemented by child contract."); + } + + /** + * @dev Core logic to be performed when a deposit from L2 is finalized on L2. + * In most cases, this will simply _mint() to credit L2 funds to the recipient. + * + * param _to Address being deposited to on L2 + * param _amount Amount which was deposited on L1 + */ + function _handleFinalizeDeposit( + address, // _to + uint // _amount + ) + internal + virtual + { + revert("Accounting must be implemented by child contract."); + } + + /** + * @dev Overridable getter for the *L1* gas limit of settling the withdrawal, in the case it may be + * dynamic, and the above public constant does not suffice. + * + */ + + function getFinalizeWithdrawalL1Gas() + public + view + virtual + returns( + uint32 + ) + { + return DEFAULT_FINALIZE_WITHDRAWAL_L1_GAS; + } + + + /*************** + * Withdrawing * + ***************/ + + /** + * @dev initiate a withdraw of some tokens to the caller's account on L1 + * @param _amount Amount of the token to withdraw + */ + function withdraw( + uint _amount + ) + external + override + onlyInitialized() + { + _initiateWithdrawal(msg.sender, _amount); + } + + /** + * @dev initiate a withdraw of some token to a recipient's account on L1 + * @param _to L1 adress to credit the withdrawal to + * @param _amount Amount of the token to withdraw + */ + function withdrawTo( + address _to, + uint _amount + ) + external + override + onlyInitialized() + { + _initiateWithdrawal(_to, _amount); + } + + /** + * @dev Performs the logic for deposits by storing the token and informing the L2 token Gateway of the deposit. + * + * @param _to Account to give the withdrawal to on L1 + * @param _amount Amount of the token to withdraw + */ + function _initiateWithdrawal( + address _to, + uint _amount + ) + internal + { + // Call our withdrawal accounting handler implemented by child contracts (usually a _burn) + _handleInitiateWithdrawal(_to, _amount); + + // Construct calldata for l1TokenGateway.finalizeWithdrawal(_to, _amount) + bytes memory data = abi.encodeWithSelector( + iOVM_L1TokenGateway.finalizeWithdrawal.selector, + _to, + _amount + ); + + // Send message up to L1 gateway + sendCrossDomainMessage( + address(l1TokenGateway), + data, + getFinalizeWithdrawalL1Gas() + ); + + emit WithdrawalInitiated(msg.sender, _to, _amount); + } + + /************************************ + * Cross-chain Function: Depositing * + ************************************/ + + /** + * @dev Complete a deposit from L1 to L2, and credits funds to the recipient's balance of this + * L2 token. + * This call will fail if it did not originate from a corresponding deposit in OVM_l1TokenGateway. + * + * @param _to Address to receive the withdrawal at + * @param _amount Amount of the token to withdraw + */ + function finalizeDeposit( + address _to, + uint _amount + ) + external + override + onlyInitialized() + onlyFromCrossDomainAccount(address(l1TokenGateway)) + { + _handleFinalizeDeposit(_to, _amount); + emit DepositFinalized(_to, _amount); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L1ERC20Gateway.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L1ERC20Gateway.sol new file mode 100644 index 000000000000..f439a12359aa --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L1ERC20Gateway.sol @@ -0,0 +1,100 @@ +// SPDX-License-Identifier: MIT +// @unsupported: ovm +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Interface Imports */ +import { iOVM_L1TokenGateway } from "../../../iOVM/bridge/tokens/iOVM_L1TokenGateway.sol"; +import { Abs_L1TokenGateway } from "./Abs_L1TokenGateway.sol"; +import { iOVM_ERC20 } from "../../../iOVM/predeploys/iOVM_ERC20.sol"; + +/** + * @title OVM_L1ERC20Gateway + * @dev The L1 ERC20 Gateway is a contract which stores deposited L1 funds that are in use on L2. + * It synchronizes a corresponding L2 ERC20 Gateway, informing it of deposits, and listening to it + * for newly finalized withdrawals. + * + * NOTE: This contract extends Abs_L1TokenGateway, which is where we + * takes care of most of the initialization and the cross-chain logic. + * If you are looking to implement your own deposit/withdrawal contracts, you + * may also want to extend the abstract contract in a similar manner. + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_L1ERC20Gateway is Abs_L1TokenGateway { + + /******************************** + * External Contract References * + ********************************/ + + iOVM_ERC20 public l1ERC20; + + /*************** + * Constructor * + ***************/ + + /** + * @param _l1ERC20 L1 ERC20 address this contract stores deposits for + * @param _l2DepositedERC20 L2 Gateway address on the chain being deposited into + */ + constructor( + iOVM_ERC20 _l1ERC20, + address _l2DepositedERC20, + address _l1messenger + ) + Abs_L1TokenGateway( + _l2DepositedERC20, + _l1messenger + ) + { + l1ERC20 = _l1ERC20; + } + + + /************** + * Accounting * + **************/ + + /** + * @dev When a deposit is initiated on L1, the L1 Gateway + * transfers the funds to itself for future withdrawals + * + * @param _from L1 address ETH is being deposited from + * param _to L2 address that the ETH is being deposited to + * @param _amount Amount of ERC20 to send + */ + function _handleInitiateDeposit( + address _from, + address, // _to, + uint256 _amount + ) + internal + override + { + // Hold on to the newly deposited funds + l1ERC20.transferFrom( + _from, + address(this), + _amount + ); + } + + /** + * @dev When a withdrawal is finalized on L1, the L1 Gateway + * transfers the funds to the withdrawer + * + * @param _to L1 address that the ERC20 is being withdrawn to + * @param _amount Amount of ERC20 to send + */ + function _handleFinalizeWithdrawal( + address _to, + uint _amount + ) + internal + override + { + // Transfer withdrawn funds out to withdrawer + l1ERC20.transfer(_to, _amount); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L1ETHGateway.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L1ETHGateway.sol new file mode 100644 index 000000000000..ad740d4c9e0e --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L1ETHGateway.sol @@ -0,0 +1,164 @@ +// SPDX-License-Identifier: MIT +// @unsupported: ovm +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Interface Imports */ +import { iOVM_L1ETHGateway } from "../../../iOVM/bridge/tokens/iOVM_L1ETHGateway.sol"; +import { iOVM_L2DepositedToken } from "../../../iOVM/bridge/tokens/iOVM_L2DepositedToken.sol"; + +/* Library Imports */ +import { OVM_CrossDomainEnabled } from "../../../libraries/bridge/OVM_CrossDomainEnabled.sol"; +import { Lib_AddressResolver } from "../../../libraries/resolver/Lib_AddressResolver.sol"; + +/** + * @title OVM_L1ETHGateway + * @dev The L1 ETH Gateway is a contract which stores deposited ETH that is in use on L2. + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_L1ETHGateway is iOVM_L1ETHGateway, OVM_CrossDomainEnabled, Lib_AddressResolver { + + /******************** + * Public Constants * + ********************/ + + uint32 public constant override getFinalizeDepositL2Gas = 1200000; + + /******************************** + * External Contract References * + ********************************/ + + address public ovmEth; + + /*************** + * Constructor * + ***************/ + + /** + * @param _libAddressManager Address manager for this OE deployment + * @param _ovmEth L2 OVM_ETH implementation of iOVM_DepositedToken + */ + constructor( + address _libAddressManager, + address _ovmEth + ) + OVM_CrossDomainEnabled(address(0)) // overridden in constructor code + Lib_AddressResolver(_libAddressManager) + { + ovmEth = _ovmEth; + messenger = resolve("Proxy__OVM_L1CrossDomainMessenger"); // overrides OVM_CrossDomainEnabled constructor setting because resolve() is not yet accessible + } + + /************** + * Depositing * + **************/ + + receive() + external + payable + { + _initiateDeposit(msg.sender, msg.sender); + } + + /** + * @dev deposit an amount of the ETH to the caller's balance on L2 + */ + function deposit() + external + override + payable + { + _initiateDeposit(msg.sender, msg.sender); + } + + /** + * @dev deposit an amount of ETH to a recipients's balance on L2 + * @param _to L2 address to credit the withdrawal to + */ + function depositTo( + address _to + ) + external + override + payable + { + _initiateDeposit(msg.sender, _to); + } + + /** + * @dev Performs the logic for deposits by storing the ETH and informing the L2 ETH Gateway of the deposit. + * + * @param _from Account to pull the deposit from on L1 + * @param _to Account to give the deposit to on L2 + */ + function _initiateDeposit( + address _from, + address _to + ) + internal + { + // Construct calldata for l2ETHGateway.finalizeDeposit(_to, _amount) + bytes memory data = + abi.encodeWithSelector( + iOVM_L2DepositedToken.finalizeDeposit.selector, + _to, + msg.value + ); + + // Send calldata into L2 + sendCrossDomainMessage( + ovmEth, + data, + getFinalizeDepositL2Gas + ); + + emit DepositInitiated(_from, _to, msg.value); + } + + /************************* + * Cross-chain Functions * + *************************/ + + /** + * @dev Complete a withdrawal from L2 to L1, and credit funds to the recipient's balance of the + * L1 ETH token. + * Since only the xDomainMessenger can call this function, it will never be called before the withdrawal is finalized. + * + * @param _to L1 address to credit the withdrawal to + * @param _amount Amount of the ETH to withdraw + */ + function finalizeWithdrawal( + address _to, + uint256 _amount + ) + external + override + onlyFromCrossDomainAccount(ovmEth) + { + _safeTransferETH(_to, _amount); + + emit WithdrawalFinalized(_to, _amount); + } + + /********************************** + * Internal Functions: Accounting * + **********************************/ + + /** + * @dev Internal accounting function for moving around L1 ETH. + * + * @param _to L1 address to transfer ETH to + * @param _value Amount of ETH to send to + */ + function _safeTransferETH( + address _to, + uint256 _value + ) + internal + { + (bool success, ) = _to.call{value: _value}(new bytes(0)); + require(success, 'TransferHelper::safeTransferETH: ETH transfer failed'); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L2DepositedERC20.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L2DepositedERC20.sol new file mode 100644 index 000000000000..e1fd3112493b --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L2DepositedERC20.sol @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Interface Imports */ +import { iOVM_L1TokenGateway } from "../../../iOVM/bridge/tokens/iOVM_L1TokenGateway.sol"; + +/* Contract Imports */ +import { UniswapV2ERC20 } from "../../../libraries/standards/UniswapV2ERC20.sol"; + +/* Library Imports */ +import { Abs_L2DepositedToken } from "./Abs_L2DepositedToken.sol"; + +/** + * @title OVM_L2DepositedERC20 + * @dev The L2 Deposited ERC20 is an ERC20 implementation which represents L1 assets deposited into L2. + * This contract mints new tokens when it hears about deposits into the L1 ERC20 gateway. + * This contract also burns the tokens intended for withdrawal, informing the L1 gateway to release L1 funds. + * + * NOTE: This contract implements the Abs_L2DepositedToken contract using Uniswap's ERC20 as the implementation. + * Alternative implementations can be used in this similar manner. + * + * Compiler used: optimistic-solc + * Runtime target: OVM + */ +contract OVM_L2DepositedERC20 is Abs_L2DepositedToken, UniswapV2ERC20 { + + /*************** + * Constructor * + ***************/ + + /** + * @param _l2CrossDomainMessenger Cross-domain messenger used by this contract. + * @param _name ERC20 name + * @param _symbol ERC20 symbol + */ + constructor( + address _l2CrossDomainMessenger, + string memory _name, + string memory _symbol + ) + Abs_L2DepositedToken(_l2CrossDomainMessenger) + UniswapV2ERC20(_name, _symbol) + {} + + // When a withdrawal is initiated, we burn the withdrawer's funds to prevent subsequent L2 usage. + function _handleInitiateWithdrawal( + address, // _to, + uint _amount + ) + internal + override + { + _burn(msg.sender, _amount); + } + + // When a deposit is finalized, we credit the account on L2 with the same amount of tokens. + function _handleFinalizeDeposit( + address _to, + uint _amount + ) + internal + override + { + _mint(_to, _amount); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/chain/OVM_CanonicalTransactionChain.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/chain/OVM_CanonicalTransactionChain.sol new file mode 100644 index 000000000000..6873801f32d2 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/chain/OVM_CanonicalTransactionChain.sol @@ -0,0 +1,1230 @@ +// SPDX-License-Identifier: MIT +// @unsupported: ovm +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; +import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; +import { Lib_MerkleTree } from "../../libraries/utils/Lib_MerkleTree.sol"; +import { Lib_Math } from "../../libraries/utils/Lib_Math.sol"; + +/* Interface Imports */ +import { iOVM_CanonicalTransactionChain } from "../../iOVM/chain/iOVM_CanonicalTransactionChain.sol"; +import { iOVM_ChainStorageContainer } from "../../iOVM/chain/iOVM_ChainStorageContainer.sol"; + +/* Contract Imports */ +import { OVM_ExecutionManager } from "../execution/OVM_ExecutionManager.sol"; + + +/** + * @title OVM_CanonicalTransactionChain + * @dev The Canonical Transaction Chain (CTC) contract is an append-only log of transactions + * which must be applied to the rollup state. It defines the ordering of rollup transactions by + * writing them to the 'CTC:batches' instance of the Chain Storage Container. + * The CTC also allows any account to 'enqueue' an L2 transaction, which will require that the Sequencer + * will eventually append it to the rollup state. + * If the Sequencer does not include an enqueued transaction within the 'force inclusion period', + * then any account may force it to be included by calling appendQueueBatch(). + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_AddressResolver { + + /************* + * Constants * + *************/ + + // L2 tx gas-related + uint256 constant public MIN_ROLLUP_TX_GAS = 100000; + uint256 constant public MAX_ROLLUP_TX_SIZE = 10000; + uint256 constant public L2_GAS_DISCOUNT_DIVISOR = 32; + + // Encoding-related (all in bytes) + uint256 constant internal BATCH_CONTEXT_SIZE = 16; + uint256 constant internal BATCH_CONTEXT_LENGTH_POS = 12; + uint256 constant internal BATCH_CONTEXT_START_POS = 15; + uint256 constant internal TX_DATA_HEADER_SIZE = 3; + uint256 constant internal BYTES_TILL_TX_DATA = 65; + + + /************* + * Variables * + *************/ + + uint256 public forceInclusionPeriodSeconds; + uint256 public forceInclusionPeriodBlocks; + uint256 public maxTransactionGasLimit; + + + /*************** + * Constructor * + ***************/ + + constructor( + address _libAddressManager, + uint256 _forceInclusionPeriodSeconds, + uint256 _forceInclusionPeriodBlocks, + uint256 _maxTransactionGasLimit + ) + Lib_AddressResolver(_libAddressManager) + { + forceInclusionPeriodSeconds = _forceInclusionPeriodSeconds; + forceInclusionPeriodBlocks = _forceInclusionPeriodBlocks; + maxTransactionGasLimit = _maxTransactionGasLimit; + } + + + /******************** + * Public Functions * + ********************/ + + /** + * Accesses the batch storage container. + * @return Reference to the batch storage container. + */ + function batches() + override + public + view + returns ( + iOVM_ChainStorageContainer + ) + { + return iOVM_ChainStorageContainer( + resolve("OVM_ChainStorageContainer:CTC:batches") + ); + } + + /** + * Accesses the queue storage container. + * @return Reference to the queue storage container. + */ + function queue() + override + public + view + returns ( + iOVM_ChainStorageContainer + ) + { + return iOVM_ChainStorageContainer( + resolve("OVM_ChainStorageContainer:CTC:queue") + ); + } + + /** + * Retrieves the total number of elements submitted. + * @return _totalElements Total submitted elements. + */ + function getTotalElements() + override + public + view + returns ( + uint256 _totalElements + ) + { + (uint40 totalElements,,,) = _getBatchExtraData(); + return uint256(totalElements); + } + + /** + * Retrieves the total number of batches submitted. + * @return _totalBatches Total submitted batches. + */ + function getTotalBatches() + override + public + view + returns ( + uint256 _totalBatches + ) + { + return batches().length(); + } + + /** + * Returns the index of the next element to be enqueued. + * @return Index for the next queue element. + */ + function getNextQueueIndex() + override + public + view + returns ( + uint40 + ) + { + (,uint40 nextQueueIndex,,) = _getBatchExtraData(); + return nextQueueIndex; + } + + /** + * Returns the timestamp of the last transaction. + * @return Timestamp for the last transaction. + */ + function getLastTimestamp() + override + public + view + returns ( + uint40 + ) + { + (,,uint40 lastTimestamp,) = _getBatchExtraData(); + return lastTimestamp; + } + + /** + * Returns the blocknumber of the last transaction. + * @return Blocknumber for the last transaction. + */ + function getLastBlockNumber() + override + public + view + returns ( + uint40 + ) + { + (,,,uint40 lastBlockNumber) = _getBatchExtraData(); + return lastBlockNumber; + } + + /** + * Gets the queue element at a particular index. + * @param _index Index of the queue element to access. + * @return _element Queue element at the given index. + */ + function getQueueElement( + uint256 _index + ) + override + public + view + returns ( + Lib_OVMCodec.QueueElement memory _element + ) + { + return _getQueueElement( + _index, + queue() + ); + } + + /** + * Get the number of queue elements which have not yet been included. + * @return Number of pending queue elements. + */ + function getNumPendingQueueElements() + override + public + view + returns ( + uint40 + ) + { + return getQueueLength() - getNextQueueIndex(); + } + + /** + * Retrieves the length of the queue, including + * both pending and canonical transactions. + * @return Length of the queue. + */ + function getQueueLength() + override + public + view + returns ( + uint40 + ) + { + return _getQueueLength( + queue() + ); + } + + /** + * Adds a transaction to the queue. + * @param _target Target L2 contract to send the transaction to. + * @param _gasLimit Gas limit for the enqueued L2 transaction. + * @param _data Transaction data. + */ + function enqueue( + address _target, + uint256 _gasLimit, + bytes memory _data + ) + override + public + { + require( + _data.length <= MAX_ROLLUP_TX_SIZE, + "Transaction data size exceeds maximum for rollup transaction." + ); + + require( + _gasLimit <= maxTransactionGasLimit, + "Transaction gas limit exceeds maximum for rollup transaction." + ); + + require( + _gasLimit >= MIN_ROLLUP_TX_GAS, + "Transaction gas limit too low to enqueue." + ); + + // We need to consume some amount of L1 gas in order to rate limit transactions going into + // L2. However, L2 is cheaper than L1 so we only need to burn some small proportion of the + // provided L1 gas. + uint256 gasToConsume = _gasLimit/L2_GAS_DISCOUNT_DIVISOR; + uint256 startingGas = gasleft(); + + // Although this check is not necessary (burn below will run out of gas if not true), it + // gives the user an explicit reason as to why the enqueue attempt failed. + require( + startingGas > gasToConsume, + "Insufficient gas for L2 rate limiting burn." + ); + + // Here we do some "dumb" work in order to burn gas, although we should probably replace + // this with something like minting gas token later on. + uint256 i; + while(startingGas - gasleft() < gasToConsume) { + i++; + } + + bytes32 transactionHash = keccak256( + abi.encode( + msg.sender, + _target, + _gasLimit, + _data + ) + ); + + bytes32 timestampAndBlockNumber; + assembly { + timestampAndBlockNumber := timestamp() + timestampAndBlockNumber := or(timestampAndBlockNumber, shl(40, number())) + } + + iOVM_ChainStorageContainer queueRef = queue(); + + queueRef.push(transactionHash); + queueRef.push(timestampAndBlockNumber); + + // The underlying queue data structure stores 2 elements + // per insertion, so to get the real queue length we need + // to divide by 2 and subtract 1. + uint256 queueIndex = queueRef.length() / 2 - 1; + emit TransactionEnqueued( + msg.sender, + _target, + _gasLimit, + _data, + queueIndex, + block.timestamp + ); + } + + /** + * Appends a given number of queued transactions as a single batch. + * param _numQueuedTransactions Number of transactions to append. + */ + function appendQueueBatch( + uint256 // _numQueuedTransactions + ) + override + public + pure + { + // TEMPORARY: Disable `appendQueueBatch` for minnet + revert("appendQueueBatch is currently disabled."); + + // _numQueuedTransactions = Lib_Math.min(_numQueuedTransactions, getNumPendingQueueElements()); + // require( + // _numQueuedTransactions > 0, + // "Must append more than zero transactions." + // ); + + // bytes32[] memory leaves = new bytes32[](_numQueuedTransactions); + // uint40 nextQueueIndex = getNextQueueIndex(); + + // for (uint256 i = 0; i < _numQueuedTransactions; i++) { + // if (msg.sender != resolve("OVM_Sequencer")) { + // Lib_OVMCodec.QueueElement memory el = getQueueElement(nextQueueIndex); + // require( + // el.timestamp + forceInclusionPeriodSeconds < block.timestamp, + // "Queue transactions cannot be submitted during the sequencer inclusion period." + // ); + // } + // leaves[i] = _getQueueLeafHash(nextQueueIndex); + // nextQueueIndex++; + // } + + // Lib_OVMCodec.QueueElement memory lastElement = getQueueElement(nextQueueIndex - 1); + + // _appendBatch( + // Lib_MerkleTree.getMerkleRoot(leaves), + // _numQueuedTransactions, + // _numQueuedTransactions, + // lastElement.timestamp, + // lastElement.blockNumber + // ); + + // emit QueueBatchAppended( + // nextQueueIndex - _numQueuedTransactions, + // _numQueuedTransactions, + // getTotalElements() + // ); + } + + /** + * Allows the sequencer to append a batch of transactions. + * @dev This function uses a custom encoding scheme for efficiency reasons. + * .param _shouldStartAtElement Specific batch we expect to start appending to. + * .param _totalElementsToAppend Total number of batch elements we expect to append. + * .param _contexts Array of batch contexts. + * .param _transactionDataFields Array of raw transaction data. + */ + function appendSequencerBatch() + override + public + { + uint40 shouldStartAtElement; + uint24 totalElementsToAppend; + uint24 numContexts; + assembly { + shouldStartAtElement := shr(216, calldataload(4)) + totalElementsToAppend := shr(232, calldataload(9)) + numContexts := shr(232, calldataload(12)) + } + + require( + shouldStartAtElement == getTotalElements(), + "Actual batch start index does not match expected start index." + ); + + require( + msg.sender == resolve("OVM_Sequencer"), + "Function can only be called by the Sequencer." + ); + + require( + numContexts > 0, + "Must provide at least one batch context." + ); + + require( + totalElementsToAppend > 0, + "Must append at least one element." + ); + + uint40 nextTransactionPtr = uint40(BATCH_CONTEXT_START_POS + BATCH_CONTEXT_SIZE * numContexts); + + require( + msg.data.length >= nextTransactionPtr, + "Not enough BatchContexts provided." + ); + + // Take a reference to the queue and its length so we don't have to keep resolving it. + // Length isn't going to change during the course of execution, so it's fine to simply + // resolve this once at the start. Saves gas. + iOVM_ChainStorageContainer queueRef = queue(); + uint40 queueLength = _getQueueLength(queueRef); + + // Reserve some memory to save gas on hashing later on. This is a relatively safe estimate + // for the average transaction size that will prevent having to resize this chunk of memory + // later on. Saves gas. + bytes memory hashMemory = new bytes((msg.data.length / totalElementsToAppend) * 2); + + // Initialize the array of canonical chain leaves that we will append. + bytes32[] memory leaves = new bytes32[](totalElementsToAppend); + + // Each leaf index corresponds to a tx, either sequenced or enqueued. + uint32 leafIndex = 0; + + // Counter for number of sequencer transactions appended so far. + uint32 numSequencerTransactions = 0; + + // We will sequentially append leaves which are pointers to the queue. + // The initial queue index is what is currently in storage. + uint40 nextQueueIndex = getNextQueueIndex(); + + BatchContext memory curContext; + for (uint32 i = 0; i < numContexts; i++) { + BatchContext memory nextContext = _getBatchContext(i); + + if (i == 0) { + // Execute a special check for the first batch. + _validateFirstBatchContext(nextContext); + } + + // Execute this check on every single batch, including the first one. + _validateNextBatchContext( + curContext, + nextContext, + nextQueueIndex, + queueRef + ); + + // Now we can update our current context. + curContext = nextContext; + + // Process sequencer transactions first. + for (uint32 j = 0; j < curContext.numSequencedTransactions; j++) { + uint256 txDataLength; + assembly { + txDataLength := shr(232, calldataload(nextTransactionPtr)) + } + + leaves[leafIndex] = _getSequencerLeafHash( + curContext, + nextTransactionPtr, + txDataLength, + hashMemory + ); + + nextTransactionPtr += uint40(TX_DATA_HEADER_SIZE + txDataLength); + numSequencerTransactions++; + leafIndex++; + } + + // Now process any subsequent queue transactions. + for (uint32 j = 0; j < curContext.numSubsequentQueueTransactions; j++) { + require( + nextQueueIndex < queueLength, + "Not enough queued transactions to append." + ); + + leaves[leafIndex] = _getQueueLeafHash(nextQueueIndex); + nextQueueIndex++; + leafIndex++; + } + } + + _validateFinalBatchContext( + curContext, + nextQueueIndex, + queueLength, + queueRef + ); + + require( + msg.data.length == nextTransactionPtr, + "Not all sequencer transactions were processed." + ); + + require( + leafIndex == totalElementsToAppend, + "Actual transaction index does not match expected total elements to append." + ); + + // Generate the required metadata that we need to append this batch + uint40 numQueuedTransactions = totalElementsToAppend - numSequencerTransactions; + uint40 blockTimestamp; + uint40 blockNumber; + if (curContext.numSubsequentQueueTransactions == 0) { + // The last element is a sequencer tx, therefore pull timestamp and block number from the last context. + blockTimestamp = uint40(curContext.timestamp); + blockNumber = uint40(curContext.blockNumber); + } else { + // The last element is a queue tx, therefore pull timestamp and block number from the queue element. + // curContext.numSubsequentQueueTransactions > 0 which means that we've processed at least one queue element. + // We increment nextQueueIndex after processing each queue element, + // so the index of the last element we processed is nextQueueIndex - 1. + Lib_OVMCodec.QueueElement memory lastElement = _getQueueElement( + nextQueueIndex - 1, + queueRef + ); + + blockTimestamp = lastElement.timestamp; + blockNumber = lastElement.blockNumber; + } + + // For efficiency reasons getMerkleRoot modifies the `leaves` argument in place + // while calculating the root hash therefore any arguments passed to it must not + // be used again afterwards + _appendBatch( + Lib_MerkleTree.getMerkleRoot(leaves), + totalElementsToAppend, + numQueuedTransactions, + blockTimestamp, + blockNumber + ); + + emit SequencerBatchAppended( + nextQueueIndex - numQueuedTransactions, + numQueuedTransactions, + getTotalElements() + ); + } + + /** + * Verifies whether a transaction is included in the chain. + * @param _transaction Transaction to verify. + * @param _txChainElement Transaction chain element corresponding to the transaction. + * @param _batchHeader Header of the batch the transaction was included in. + * @param _inclusionProof Inclusion proof for the provided transaction chain element. + * @return True if the transaction exists in the CTC, false if not. + */ + function verifyTransaction( + Lib_OVMCodec.Transaction memory _transaction, + Lib_OVMCodec.TransactionChainElement memory _txChainElement, + Lib_OVMCodec.ChainBatchHeader memory _batchHeader, + Lib_OVMCodec.ChainInclusionProof memory _inclusionProof + ) + override + public + view + returns ( + bool + ) + { + if (_txChainElement.isSequenced == true) { + return _verifySequencerTransaction( + _transaction, + _txChainElement, + _batchHeader, + _inclusionProof + ); + } else { + return _verifyQueueTransaction( + _transaction, + _txChainElement.queueIndex, + _batchHeader, + _inclusionProof + ); + } + } + + + /********************** + * Internal Functions * + **********************/ + + /** + * Returns the BatchContext located at a particular index. + * @param _index The index of the BatchContext + * @return The BatchContext at the specified index. + */ + function _getBatchContext( + uint256 _index + ) + internal + pure + returns ( + BatchContext memory + ) + { + uint256 contextPtr = 15 + _index * BATCH_CONTEXT_SIZE; + uint256 numSequencedTransactions; + uint256 numSubsequentQueueTransactions; + uint256 ctxTimestamp; + uint256 ctxBlockNumber; + + assembly { + numSequencedTransactions := shr(232, calldataload(contextPtr)) + numSubsequentQueueTransactions := shr(232, calldataload(add(contextPtr, 3))) + ctxTimestamp := shr(216, calldataload(add(contextPtr, 6))) + ctxBlockNumber := shr(216, calldataload(add(contextPtr, 11))) + } + + return BatchContext({ + numSequencedTransactions: numSequencedTransactions, + numSubsequentQueueTransactions: numSubsequentQueueTransactions, + timestamp: ctxTimestamp, + blockNumber: ctxBlockNumber + }); + } + + /** + * Parses the batch context from the extra data. + * @return Total number of elements submitted. + * @return Index of the next queue element. + */ + function _getBatchExtraData() + internal + view + returns ( + uint40, + uint40, + uint40, + uint40 + ) + { + bytes27 extraData = batches().getGlobalMetadata(); + + uint40 totalElements; + uint40 nextQueueIndex; + uint40 lastTimestamp; + uint40 lastBlockNumber; + assembly { + extraData := shr(40, extraData) + totalElements := and(extraData, 0x000000000000000000000000000000000000000000000000000000FFFFFFFFFF) + nextQueueIndex := shr(40, and(extraData, 0x00000000000000000000000000000000000000000000FFFFFFFFFF0000000000)) + lastTimestamp := shr(80, and(extraData, 0x0000000000000000000000000000000000FFFFFFFFFF00000000000000000000)) + lastBlockNumber := shr(120, and(extraData, 0x000000000000000000000000FFFFFFFFFF000000000000000000000000000000)) + } + + return ( + totalElements, + nextQueueIndex, + lastTimestamp, + lastBlockNumber + ); + } + + /** + * Encodes the batch context for the extra data. + * @param _totalElements Total number of elements submitted. + * @param _nextQueueIndex Index of the next queue element. + * @param _timestamp Timestamp for the last batch. + * @param _blockNumber Block number of the last batch. + * @return Encoded batch context. + */ + function _makeBatchExtraData( + uint40 _totalElements, + uint40 _nextQueueIndex, + uint40 _timestamp, + uint40 _blockNumber + ) + internal + pure + returns ( + bytes27 + ) + { + bytes27 extraData; + assembly { + extraData := _totalElements + extraData := or(extraData, shl(40, _nextQueueIndex)) + extraData := or(extraData, shl(80, _timestamp)) + extraData := or(extraData, shl(120, _blockNumber)) + extraData := shl(40, extraData) + } + + return extraData; + } + + /** + * Retrieves the hash of a queue element. + * @param _index Index of the queue element to retrieve a hash for. + * @return Hash of the queue element. + */ + function _getQueueLeafHash( + uint256 _index + ) + internal + pure + returns ( + bytes32 + ) + { + return _hashTransactionChainElement( + Lib_OVMCodec.TransactionChainElement({ + isSequenced: false, + queueIndex: _index, + timestamp: 0, + blockNumber: 0, + txData: hex"" + }) + ); + } + + /** + * Gets the queue element at a particular index. + * @param _index Index of the queue element to access. + * @return _element Queue element at the given index. + */ + function _getQueueElement( + uint256 _index, + iOVM_ChainStorageContainer _queueRef + ) + internal + view + returns ( + Lib_OVMCodec.QueueElement memory _element + ) + { + // The underlying queue data structure stores 2 elements + // per insertion, so to get the actual desired queue index + // we need to multiply by 2. + uint40 trueIndex = uint40(_index * 2); + bytes32 transactionHash = _queueRef.get(trueIndex); + bytes32 timestampAndBlockNumber = _queueRef.get(trueIndex + 1); + + uint40 elementTimestamp; + uint40 elementBlockNumber; + assembly { + elementTimestamp := and(timestampAndBlockNumber, 0x000000000000000000000000000000000000000000000000000000FFFFFFFFFF) + elementBlockNumber := shr(40, and(timestampAndBlockNumber, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000)) + } + + return Lib_OVMCodec.QueueElement({ + transactionHash: transactionHash, + timestamp: elementTimestamp, + blockNumber: elementBlockNumber + }); + } + + /** + * Retrieves the length of the queue. + * @return Length of the queue. + */ + function _getQueueLength( + iOVM_ChainStorageContainer _queueRef + ) + internal + view + returns ( + uint40 + ) + { + // The underlying queue data structure stores 2 elements + // per insertion, so to get the real queue length we need + // to divide by 2. + return uint40(_queueRef.length() / 2); + } + + /** + * Retrieves the hash of a sequencer element. + * @param _context Batch context for the given element. + * @param _nextTransactionPtr Pointer to the next transaction in the calldata. + * @param _txDataLength Length of the transaction item. + * @return Hash of the sequencer element. + */ + function _getSequencerLeafHash( + BatchContext memory _context, + uint256 _nextTransactionPtr, + uint256 _txDataLength, + bytes memory _hashMemory + ) + internal + pure + returns ( + bytes32 + ) + { + // Only allocate more memory if we didn't reserve enough to begin with. + if (BYTES_TILL_TX_DATA + _txDataLength > _hashMemory.length) { + _hashMemory = new bytes(BYTES_TILL_TX_DATA + _txDataLength); + } + + uint256 ctxTimestamp = _context.timestamp; + uint256 ctxBlockNumber = _context.blockNumber; + + bytes32 leafHash; + assembly { + let chainElementStart := add(_hashMemory, 0x20) + + // Set the first byte equal to `1` to indicate this is a sequencer chain element. + // This distinguishes sequencer ChainElements from queue ChainElements because + // all queue ChainElements are ABI encoded and the first byte of ABI encoded + // elements is always zero + mstore8(chainElementStart, 1) + + mstore(add(chainElementStart, 1), ctxTimestamp) + mstore(add(chainElementStart, 33), ctxBlockNumber) + + calldatacopy(add(chainElementStart, BYTES_TILL_TX_DATA), add(_nextTransactionPtr, 3), _txDataLength) + + leafHash := keccak256(chainElementStart, add(BYTES_TILL_TX_DATA, _txDataLength)) + } + + return leafHash; + } + + /** + * Retrieves the hash of a sequencer element. + * @param _txChainElement The chain element which is hashed to calculate the leaf. + * @return Hash of the sequencer element. + */ + function _getSequencerLeafHash( + Lib_OVMCodec.TransactionChainElement memory _txChainElement + ) + internal + view + returns( + bytes32 + ) + { + bytes memory txData = _txChainElement.txData; + uint256 txDataLength = _txChainElement.txData.length; + + bytes memory chainElement = new bytes(BYTES_TILL_TX_DATA + txDataLength); + uint256 ctxTimestamp = _txChainElement.timestamp; + uint256 ctxBlockNumber = _txChainElement.blockNumber; + + bytes32 leafHash; + assembly { + let chainElementStart := add(chainElement, 0x20) + + // Set the first byte equal to `1` to indicate this is a sequencer chain element. + // This distinguishes sequencer ChainElements from queue ChainElements because + // all queue ChainElements are ABI encoded and the first byte of ABI encoded + // elements is always zero + mstore8(chainElementStart, 1) + + mstore(add(chainElementStart, 1), ctxTimestamp) + mstore(add(chainElementStart, 33), ctxBlockNumber) + + pop(staticcall(gas(), 0x04, add(txData, 0x20), txDataLength, add(chainElementStart, BYTES_TILL_TX_DATA), txDataLength)) + + leafHash := keccak256(chainElementStart, add(BYTES_TILL_TX_DATA, txDataLength)) + } + + return leafHash; + } + + /** + * Inserts a batch into the chain of batches. + * @param _transactionRoot Root of the transaction tree for this batch. + * @param _batchSize Number of elements in the batch. + * @param _numQueuedTransactions Number of queue transactions in the batch. + * @param _timestamp The latest batch timestamp. + * @param _blockNumber The latest batch blockNumber. + */ + function _appendBatch( + bytes32 _transactionRoot, + uint256 _batchSize, + uint256 _numQueuedTransactions, + uint40 _timestamp, + uint40 _blockNumber + ) + internal + { + iOVM_ChainStorageContainer batchesRef = batches(); + (uint40 totalElements, uint40 nextQueueIndex,,) = _getBatchExtraData(); + + Lib_OVMCodec.ChainBatchHeader memory header = Lib_OVMCodec.ChainBatchHeader({ + batchIndex: batchesRef.length(), + batchRoot: _transactionRoot, + batchSize: _batchSize, + prevTotalElements: totalElements, + extraData: hex"" + }); + + emit TransactionBatchAppended( + header.batchIndex, + header.batchRoot, + header.batchSize, + header.prevTotalElements, + header.extraData + ); + + bytes32 batchHeaderHash = Lib_OVMCodec.hashBatchHeader(header); + bytes27 latestBatchContext = _makeBatchExtraData( + totalElements + uint40(header.batchSize), + nextQueueIndex + uint40(_numQueuedTransactions), + _timestamp, + _blockNumber + ); + + batchesRef.push(batchHeaderHash, latestBatchContext); + } + + /** + * Checks that the first batch context in a sequencer submission is valid + * @param _firstContext The batch context to validate. + */ + function _validateFirstBatchContext( + BatchContext memory _firstContext + ) + internal + view + { + // If there are existing elements, this batch must have the same context + // or a later timestamp and block number. + if (getTotalElements() > 0) { + (,, uint40 lastTimestamp, uint40 lastBlockNumber) = _getBatchExtraData(); + + require( + _firstContext.blockNumber >= lastBlockNumber, + "Context block number is lower than last submitted." + ); + + require( + _firstContext.timestamp >= lastTimestamp, + "Context timestamp is lower than last submitted." + ); + } + + // Sequencer cannot submit contexts which are more than the force inclusion period old. + require( + _firstContext.timestamp + forceInclusionPeriodSeconds >= block.timestamp, + "Context timestamp too far in the past." + ); + + require( + _firstContext.blockNumber + forceInclusionPeriodBlocks >= block.number, + "Context block number too far in the past." + ); + } + + /** + * Checks that a given batch context has a time context which is below a given que element + * @param _context The batch context to validate has values lower. + * @param _queueIndex Index of the queue element we are validating came later than the context. + * @param _queueRef The storage container for the queue. + */ + function _validateContextBeforeEnqueue( + BatchContext memory _context, + uint40 _queueIndex, + iOVM_ChainStorageContainer _queueRef + ) + internal + view + { + Lib_OVMCodec.QueueElement memory nextQueueElement = _getQueueElement( + _queueIndex, + _queueRef + ); + + // If the force inclusion period has passed for an enqueued transaction, it MUST be the next chain element. + require( + block.timestamp < nextQueueElement.timestamp + forceInclusionPeriodSeconds, + "Previously enqueued batches have expired and must be appended before a new sequencer batch." + ); + + // Just like sequencer transaction times must be increasing relative to each other, + // We also require that they be increasing relative to any interspersed queue elements. + require( + _context.timestamp <= nextQueueElement.timestamp, + "Sequencer transaction timestamp exceeds that of next queue element." + ); + + require( + _context.blockNumber <= nextQueueElement.blockNumber, + "Sequencer transaction blockNumber exceeds that of next queue element." + ); + } + + /** + * Checks that a given batch context is valid based on its previous context, and the next queue elemtent. + * @param _prevContext The previously validated batch context. + * @param _nextContext The batch context to validate with this call. + * @param _nextQueueIndex Index of the next queue element to process for the _nextContext's subsequentQueueElements. + * @param _queueRef The storage container for the queue. + */ + function _validateNextBatchContext( + BatchContext memory _prevContext, + BatchContext memory _nextContext, + uint40 _nextQueueIndex, + iOVM_ChainStorageContainer _queueRef + ) + internal + view + { + // All sequencer transactions' times must be greater than or equal to the previous ones. + require( + _nextContext.timestamp >= _prevContext.timestamp, + "Context timestamp values must monotonically increase." + ); + + require( + _nextContext.blockNumber >= _prevContext.blockNumber, + "Context blockNumber values must monotonically increase." + ); + + // If there is going to be a queue element pulled in from this context: + if (_nextContext.numSubsequentQueueTransactions > 0) { + _validateContextBeforeEnqueue( + _nextContext, + _nextQueueIndex, + _queueRef + ); + } + } + + /** + * Checks that the final batch context in a sequencer submission is valid. + * @param _finalContext The batch context to validate. + * @param _queueLength The length of the queue at the start of the batchAppend call. + * @param _nextQueueIndex The next element in the queue that will be pulled into the CTC. + * @param _queueRef The storage container for the queue. + */ + function _validateFinalBatchContext( + BatchContext memory _finalContext, + uint40 _nextQueueIndex, + uint40 _queueLength, + iOVM_ChainStorageContainer _queueRef + ) + internal + view + { + // If the queue is not now empty, check the mononoticity of whatever the next batch that will come in is. + if (_queueLength - _nextQueueIndex > 0 && _finalContext.numSubsequentQueueTransactions == 0) { + _validateContextBeforeEnqueue( + _finalContext, + _nextQueueIndex, + _queueRef + ); + } + // Batches cannot be added from the future, or subsequent enqueue() contexts would violate monotonicity. + require(_finalContext.timestamp <= block.timestamp, "Context timestamp is from the future."); + require(_finalContext.blockNumber <= block.number, "Context block number is from the future."); + } + + /** + * Hashes a transaction chain element. + * @param _element Chain element to hash. + * @return Hash of the chain element. + */ + function _hashTransactionChainElement( + Lib_OVMCodec.TransactionChainElement memory _element + ) + internal + pure + returns ( + bytes32 + ) + { + return keccak256( + abi.encode( + _element.isSequenced, + _element.queueIndex, + _element.timestamp, + _element.blockNumber, + _element.txData + ) + ); + } + + /** + * Verifies a sequencer transaction, returning true if it was indeed included in the CTC + * @param _transaction The transaction we are verifying inclusion of. + * @param _txChainElement The chain element that the transaction is claimed to be a part of. + * @param _batchHeader Header of the batch the transaction was included in. + * @param _inclusionProof An inclusion proof into the CTC at a particular index. + * @return True if the transaction was included in the specified location, else false. + */ + function _verifySequencerTransaction( + Lib_OVMCodec.Transaction memory _transaction, + Lib_OVMCodec.TransactionChainElement memory _txChainElement, + Lib_OVMCodec.ChainBatchHeader memory _batchHeader, + Lib_OVMCodec.ChainInclusionProof memory _inclusionProof + ) + internal + view + returns ( + bool + ) + { + OVM_ExecutionManager ovmExecutionManager = OVM_ExecutionManager(resolve("OVM_ExecutionManager")); + uint256 gasLimit = ovmExecutionManager.getMaxTransactionGasLimit(); + bytes32 leafHash = _getSequencerLeafHash(_txChainElement); + + require( + _verifyElement( + leafHash, + _batchHeader, + _inclusionProof + ), + "Invalid Sequencer transaction inclusion proof." + ); + + require( + _transaction.blockNumber == _txChainElement.blockNumber + && _transaction.timestamp == _txChainElement.timestamp + && _transaction.entrypoint == resolve("OVM_DecompressionPrecompileAddress") + && _transaction.gasLimit == gasLimit + && _transaction.l1TxOrigin == address(0) + && _transaction.l1QueueOrigin == Lib_OVMCodec.QueueOrigin.SEQUENCER_QUEUE + && keccak256(_transaction.data) == keccak256(_txChainElement.txData), + "Invalid Sequencer transaction." + ); + + return true; + } + + /** + * Verifies a queue transaction, returning true if it was indeed included in the CTC + * @param _transaction The transaction we are verifying inclusion of. + * @param _queueIndex The queueIndex of the queued transaction. + * @param _batchHeader Header of the batch the transaction was included in. + * @param _inclusionProof An inclusion proof into the CTC at a particular index (should point to queue tx). + * @return True if the transaction was included in the specified location, else false. + */ + function _verifyQueueTransaction( + Lib_OVMCodec.Transaction memory _transaction, + uint256 _queueIndex, + Lib_OVMCodec.ChainBatchHeader memory _batchHeader, + Lib_OVMCodec.ChainInclusionProof memory _inclusionProof + ) + internal + view + returns ( + bool + ) + { + bytes32 leafHash = _getQueueLeafHash(_queueIndex); + + require( + _verifyElement( + leafHash, + _batchHeader, + _inclusionProof + ), + "Invalid Queue transaction inclusion proof." + ); + + bytes32 transactionHash = keccak256( + abi.encode( + _transaction.l1TxOrigin, + _transaction.entrypoint, + _transaction.gasLimit, + _transaction.data + ) + ); + + Lib_OVMCodec.QueueElement memory el = getQueueElement(_queueIndex); + require( + el.transactionHash == transactionHash + && el.timestamp == _transaction.timestamp + && el.blockNumber == _transaction.blockNumber, + "Invalid Queue transaction." + ); + + return true; + } + + /** + * Verifies a batch inclusion proof. + * @param _element Hash of the element to verify a proof for. + * @param _batchHeader Header of the batch in which the element was included. + * @param _proof Merkle inclusion proof for the element. + */ + function _verifyElement( + bytes32 _element, + Lib_OVMCodec.ChainBatchHeader memory _batchHeader, + Lib_OVMCodec.ChainInclusionProof memory _proof + ) + internal + view + returns ( + bool + ) + { + require( + Lib_OVMCodec.hashBatchHeader(_batchHeader) == batches().get(uint32(_batchHeader.batchIndex)), + "Invalid batch header." + ); + + require( + Lib_MerkleTree.verify( + _batchHeader.batchRoot, + _element, + _proof.index, + _proof.siblings, + _batchHeader.batchSize + ), + "Invalid inclusion proof." + ); + + return true; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/chain/OVM_ChainStorageContainer.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/chain/OVM_ChainStorageContainer.sol new file mode 100644 index 000000000000..1c2b56dffac3 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/chain/OVM_ChainStorageContainer.sol @@ -0,0 +1,205 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_RingBuffer } from "../../libraries/utils/Lib_RingBuffer.sol"; +import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; + +/* Interface Imports */ +import { iOVM_ChainStorageContainer } from "../../iOVM/chain/iOVM_ChainStorageContainer.sol"; + +/** + * @title OVM_ChainStorageContainer + * @dev The Chain Storage Container provides its owner contract with read, write and delete functionality. + * This provides gas efficiency gains by enabling it to overwrite storage slots which can no longer be used + * in a fraud proof due to the fraud window having passed, and the associated chain state or + * transactions being finalized. + * Three distinct Chain Storage Containers will be deployed on Layer 1: + * 1. Stores transaction batches for the Canonical Transaction Chain + * 2. Stores queued transactions for the Canonical Transaction Chain + * 3. Stores chain state batches for the State Commitment Chain + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressResolver { + + /************* + * Libraries * + *************/ + + using Lib_RingBuffer for Lib_RingBuffer.RingBuffer; + + + /************* + * Variables * + *************/ + + string public owner; + Lib_RingBuffer.RingBuffer internal buffer; + + + /*************** + * Constructor * + ***************/ + + /** + * @param _libAddressManager Address of the Address Manager. + * @param _owner Name of the contract that owns this container (will be resolved later). + */ + constructor( + address _libAddressManager, + string memory _owner + ) + Lib_AddressResolver(_libAddressManager) + { + owner = _owner; + } + + + /********************** + * Function Modifiers * + **********************/ + + modifier onlyOwner() { + require( + msg.sender == resolve(owner), + "OVM_ChainStorageContainer: Function can only be called by the owner." + ); + _; + } + + + /******************** + * Public Functions * + ********************/ + + /** + * @inheritdoc iOVM_ChainStorageContainer + */ + function setGlobalMetadata( + bytes27 _globalMetadata + ) + override + public + onlyOwner + { + return buffer.setExtraData(_globalMetadata); + } + + /** + * @inheritdoc iOVM_ChainStorageContainer + */ + function getGlobalMetadata() + override + public + view + returns ( + bytes27 + ) + { + return buffer.getExtraData(); + } + + /** + * @inheritdoc iOVM_ChainStorageContainer + */ + function length() + override + public + view + returns ( + uint256 + ) + { + return uint256(buffer.getLength()); + } + + /** + * @inheritdoc iOVM_ChainStorageContainer + */ + function push( + bytes32 _object + ) + override + public + onlyOwner + { + buffer.push(_object); + } + + /** + * @inheritdoc iOVM_ChainStorageContainer + */ + function push( + bytes32 _object, + bytes27 _globalMetadata + ) + override + public + onlyOwner + { + buffer.push(_object, _globalMetadata); + } + + /** + * @inheritdoc iOVM_ChainStorageContainer + */ + function get( + uint256 _index + ) + override + public + view + returns ( + bytes32 + ) + { + return buffer.get(uint40(_index)); + } + + /** + * @inheritdoc iOVM_ChainStorageContainer + */ + function deleteElementsAfterInclusive( + uint256 _index + ) + override + public + onlyOwner + { + buffer.deleteElementsAfterInclusive( + uint40(_index) + ); + } + + /** + * @inheritdoc iOVM_ChainStorageContainer + */ + function deleteElementsAfterInclusive( + uint256 _index, + bytes27 _globalMetadata + ) + override + public + onlyOwner + { + buffer.deleteElementsAfterInclusive( + uint40(_index), + _globalMetadata + ); + } + + /** + * @inheritdoc iOVM_ChainStorageContainer + */ + function setNextOverwritableIndex( + uint256 _index + ) + override + public + onlyOwner + { + buffer.nextOverwritableIndex = _index; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/chain/OVM_StateCommitmentChain.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/chain/OVM_StateCommitmentChain.sol new file mode 100644 index 000000000000..a860b7236f06 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/chain/OVM_StateCommitmentChain.sol @@ -0,0 +1,414 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; +import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; +import { Lib_MerkleTree } from "../../libraries/utils/Lib_MerkleTree.sol"; + +/* Interface Imports */ +import { iOVM_FraudVerifier } from "../../iOVM/verification/iOVM_FraudVerifier.sol"; +import { iOVM_StateCommitmentChain } from "../../iOVM/chain/iOVM_StateCommitmentChain.sol"; +import { iOVM_CanonicalTransactionChain } from "../../iOVM/chain/iOVM_CanonicalTransactionChain.sol"; +import { iOVM_BondManager } from "../../iOVM/verification/iOVM_BondManager.sol"; +import { iOVM_ChainStorageContainer } from "../../iOVM/chain/iOVM_ChainStorageContainer.sol"; + +/* External Imports */ +import '@openzeppelin/contracts/math/SafeMath.sol'; + +/** + * @title OVM_StateCommitmentChain + * @dev The State Commitment Chain (SCC) contract contains a list of proposed state roots which + * Proposers assert to be a result of each transaction in the Canonical Transaction Chain (CTC). + * Elements here have a 1:1 correspondence with transactions in the CTC, and should be the unique + * state root calculated off-chain by applying the canonical transactions one by one. + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResolver { + + /************* + * Constants * + *************/ + + uint256 public FRAUD_PROOF_WINDOW; + uint256 public SEQUENCER_PUBLISH_WINDOW; + + + /*************** + * Constructor * + ***************/ + + /** + * @param _libAddressManager Address of the Address Manager. + */ + constructor( + address _libAddressManager, + uint256 _fraudProofWindow, + uint256 _sequencerPublishWindow + ) + Lib_AddressResolver(_libAddressManager) + { + FRAUD_PROOF_WINDOW = _fraudProofWindow; + SEQUENCER_PUBLISH_WINDOW = _sequencerPublishWindow; + } + + + /******************** + * Public Functions * + ********************/ + + /** + * Accesses the batch storage container. + * @return Reference to the batch storage container. + */ + function batches() + public + view + returns ( + iOVM_ChainStorageContainer + ) + { + return iOVM_ChainStorageContainer( + resolve("OVM_ChainStorageContainer:SCC:batches") + ); + } + + /** + * @inheritdoc iOVM_StateCommitmentChain + */ + function getTotalElements() + override + public + view + returns ( + uint256 _totalElements + ) + { + (uint40 totalElements, ) = _getBatchExtraData(); + return uint256(totalElements); + } + + /** + * @inheritdoc iOVM_StateCommitmentChain + */ + function getTotalBatches() + override + public + view + returns ( + uint256 _totalBatches + ) + { + return batches().length(); + } + + /** + * @inheritdoc iOVM_StateCommitmentChain + */ + function getLastSequencerTimestamp() + override + public + view + returns ( + uint256 _lastSequencerTimestamp + ) + { + (, uint40 lastSequencerTimestamp) = _getBatchExtraData(); + return uint256(lastSequencerTimestamp); + } + + /** + * @inheritdoc iOVM_StateCommitmentChain + */ + function appendStateBatch( + bytes32[] memory _batch, + uint256 _shouldStartAtElement + ) + override + public + { + // Fail fast in to make sure our batch roots aren't accidentally made fraudulent by the + // publication of batches by some other user. + require( + _shouldStartAtElement == getTotalElements(), + "Actual batch start index does not match expected start index." + ); + + // Proposers must have previously staked at the BondManager + require( + iOVM_BondManager(resolve("OVM_BondManager")).isCollateralized(msg.sender), + "Proposer does not have enough collateral posted" + ); + + require( + _batch.length > 0, + "Cannot submit an empty state batch." + ); + + require( + getTotalElements() + _batch.length <= iOVM_CanonicalTransactionChain(resolve("OVM_CanonicalTransactionChain")).getTotalElements(), + "Number of state roots cannot exceed the number of canonical transactions." + ); + + // Pass the block's timestamp and the publisher of the data + // to be used in the fraud proofs + _appendBatch( + _batch, + abi.encode(block.timestamp, msg.sender) + ); + } + + /** + * @inheritdoc iOVM_StateCommitmentChain + */ + function deleteStateBatch( + Lib_OVMCodec.ChainBatchHeader memory _batchHeader + ) + override + public + { + require( + msg.sender == resolve("OVM_FraudVerifier"), + "State batches can only be deleted by the OVM_FraudVerifier." + ); + + require( + _isValidBatchHeader(_batchHeader), + "Invalid batch header." + ); + + require( + insideFraudProofWindow(_batchHeader), + "State batches can only be deleted within the fraud proof window." + ); + + _deleteBatch(_batchHeader); + } + + /** + * @inheritdoc iOVM_StateCommitmentChain + */ + function verifyStateCommitment( + bytes32 _element, + Lib_OVMCodec.ChainBatchHeader memory _batchHeader, + Lib_OVMCodec.ChainInclusionProof memory _proof + ) + override + public + view + returns ( + bool + ) + { + require( + _isValidBatchHeader(_batchHeader), + "Invalid batch header." + ); + + require( + Lib_MerkleTree.verify( + _batchHeader.batchRoot, + _element, + _proof.index, + _proof.siblings, + _batchHeader.batchSize + ), + "Invalid inclusion proof." + ); + + return true; + } + + /** + * @inheritdoc iOVM_StateCommitmentChain + */ + function insideFraudProofWindow( + Lib_OVMCodec.ChainBatchHeader memory _batchHeader + ) + override + public + view + returns ( + bool _inside + ) + { + (uint256 timestamp,) = abi.decode( + _batchHeader.extraData, + (uint256, address) + ); + + require( + timestamp != 0, + "Batch header timestamp cannot be zero" + ); + return SafeMath.add(timestamp, FRAUD_PROOF_WINDOW) > block.timestamp; + } + + + /********************** + * Internal Functions * + **********************/ + + /** + * Parses the batch context from the extra data. + * @return Total number of elements submitted. + * @return Timestamp of the last batch submitted by the sequencer. + */ + function _getBatchExtraData() + internal + view + returns ( + uint40, + uint40 + ) + { + bytes27 extraData = batches().getGlobalMetadata(); + + uint40 totalElements; + uint40 lastSequencerTimestamp; + assembly { + extraData := shr(40, extraData) + totalElements := and(extraData, 0x000000000000000000000000000000000000000000000000000000FFFFFFFFFF) + lastSequencerTimestamp := shr(40, and(extraData, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000)) + } + + return ( + totalElements, + lastSequencerTimestamp + ); + } + + /** + * Encodes the batch context for the extra data. + * @param _totalElements Total number of elements submitted. + * @param _lastSequencerTimestamp Timestamp of the last batch submitted by the sequencer. + * @return Encoded batch context. + */ + function _makeBatchExtraData( + uint40 _totalElements, + uint40 _lastSequencerTimestamp + ) + internal + pure + returns ( + bytes27 + ) + { + bytes27 extraData; + assembly { + extraData := _totalElements + extraData := or(extraData, shl(40, _lastSequencerTimestamp)) + extraData := shl(40, extraData) + } + + return extraData; + } + + /** + * Appends a batch to the chain. + * @param _batch Elements within the batch. + * @param _extraData Any extra data to append to the batch. + */ + function _appendBatch( + bytes32[] memory _batch, + bytes memory _extraData + ) + internal + { + address sequencer = resolve("OVM_Proposer"); + (uint40 totalElements, uint40 lastSequencerTimestamp) = _getBatchExtraData(); + + if (msg.sender == sequencer) { + lastSequencerTimestamp = uint40(block.timestamp); + } else { + // We keep track of the last batch submitted by the sequencer so there's a window in + // which only the sequencer can publish state roots. A window like this just reduces + // the chance of "system breaking" state roots being published while we're still in + // testing mode. This window should be removed or significantly reduced in the future. + require( + lastSequencerTimestamp + SEQUENCER_PUBLISH_WINDOW < block.timestamp, + "Cannot publish state roots within the sequencer publication window." + ); + } + + // For efficiency reasons getMerkleRoot modifies the `_batch` argument in place + // while calculating the root hash therefore any arguments passed to it must not + // be used again afterwards + Lib_OVMCodec.ChainBatchHeader memory batchHeader = Lib_OVMCodec.ChainBatchHeader({ + batchIndex: getTotalBatches(), + batchRoot: Lib_MerkleTree.getMerkleRoot(_batch), + batchSize: _batch.length, + prevTotalElements: totalElements, + extraData: _extraData + }); + + emit StateBatchAppended( + batchHeader.batchIndex, + batchHeader.batchRoot, + batchHeader.batchSize, + batchHeader.prevTotalElements, + batchHeader.extraData + ); + + batches().push( + Lib_OVMCodec.hashBatchHeader(batchHeader), + _makeBatchExtraData( + uint40(batchHeader.prevTotalElements + batchHeader.batchSize), + lastSequencerTimestamp + ) + ); + } + + /** + * Removes a batch and all subsequent batches from the chain. + * @param _batchHeader Header of the batch to remove. + */ + function _deleteBatch( + Lib_OVMCodec.ChainBatchHeader memory _batchHeader + ) + internal + { + require( + _batchHeader.batchIndex < batches().length(), + "Invalid batch index." + ); + + require( + _isValidBatchHeader(_batchHeader), + "Invalid batch header." + ); + + batches().deleteElementsAfterInclusive( + _batchHeader.batchIndex, + _makeBatchExtraData( + uint40(_batchHeader.prevTotalElements), + 0 + ) + ); + + emit StateBatchDeleted( + _batchHeader.batchIndex, + _batchHeader.batchRoot + ); + } + + /** + * Checks that a batch header matches the stored hash for the given index. + * @param _batchHeader Batch header to validate. + * @return Whether or not the header matches the stored one. + */ + function _isValidBatchHeader( + Lib_OVMCodec.ChainBatchHeader memory _batchHeader + ) + internal + view + returns ( + bool + ) + { + return Lib_OVMCodec.hashBatchHeader(_batchHeader) == batches().get(_batchHeader.batchIndex); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol new file mode 100644 index 000000000000..7038980fdebf --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol @@ -0,0 +1,1866 @@ +// SPDX-License-Identifier: MIT +// @unsupported: ovm +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; +import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; +import { Lib_EthUtils } from "../../libraries/utils/Lib_EthUtils.sol"; +import { Lib_ErrorUtils } from "../../libraries/utils/Lib_ErrorUtils.sol"; + +/* Interface Imports */ +import { iOVM_ExecutionManager } from "../../iOVM/execution/iOVM_ExecutionManager.sol"; +import { iOVM_StateManager } from "../../iOVM/execution/iOVM_StateManager.sol"; +import { iOVM_SafetyChecker } from "../../iOVM/execution/iOVM_SafetyChecker.sol"; + +/* Contract Imports */ +import { OVM_ECDSAContractAccount } from "../accounts/OVM_ECDSAContractAccount.sol"; +import { OVM_ProxyEOA } from "../accounts/OVM_ProxyEOA.sol"; +import { OVM_DeployerWhitelist } from "../predeploys/OVM_DeployerWhitelist.sol"; + +/** + * @title OVM_ExecutionManager + * @dev The Execution Manager (EM) is the core of our OVM implementation, and provides a sandboxed + * environment allowing us to execute OVM transactions deterministically on either Layer 1 or + * Layer 2. + * The EM's run() function is the first function called during the execution of any + * transaction on L2. + * For each context-dependent EVM operation the EM has a function which implements a corresponding + * OVM operation, which will read state from the State Manager contract. + * The EM relies on the Safety Checker to verify that code deployed to Layer 2 does not contain any + * context-dependent operations. + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { + + /******************************** + * External Contract References * + ********************************/ + + iOVM_SafetyChecker internal ovmSafetyChecker; + iOVM_StateManager internal ovmStateManager; + + + /******************************* + * Execution Context Variables * + *******************************/ + + GasMeterConfig internal gasMeterConfig; + GlobalContext internal globalContext; + TransactionContext internal transactionContext; + MessageContext internal messageContext; + TransactionRecord internal transactionRecord; + MessageRecord internal messageRecord; + + + /************************** + * Gas Metering Constants * + **************************/ + + address constant GAS_METADATA_ADDRESS = 0x06a506A506a506A506a506a506A506A506A506A5; + uint256 constant NUISANCE_GAS_SLOAD = 20000; + uint256 constant NUISANCE_GAS_SSTORE = 20000; + uint256 constant MIN_NUISANCE_GAS_PER_CONTRACT = 30000; + uint256 constant NUISANCE_GAS_PER_CONTRACT_BYTE = 100; + uint256 constant MIN_GAS_FOR_INVALID_STATE_ACCESS = 30000; + + + /*************** + * Constructor * + ***************/ + + /** + * @param _libAddressManager Address of the Address Manager. + */ + constructor( + address _libAddressManager, + GasMeterConfig memory _gasMeterConfig, + GlobalContext memory _globalContext + ) + Lib_AddressResolver(_libAddressManager) + { + ovmSafetyChecker = iOVM_SafetyChecker(resolve("OVM_SafetyChecker")); + gasMeterConfig = _gasMeterConfig; + globalContext = _globalContext; + _resetContext(); + } + + + /********************** + * Function Modifiers * + **********************/ + + /** + * Applies dynamically-sized refund to a transaction to account for the difference in execution + * between L1 and L2, so that the overall cost of the ovmOPCODE is fixed. + * @param _cost Desired gas cost for the function after the refund. + */ + modifier netGasCost( + uint256 _cost + ) { + uint256 gasProvided = gasleft(); + _; + uint256 gasUsed = gasProvided - gasleft(); + + // We want to refund everything *except* the specified cost. + if (_cost < gasUsed) { + transactionRecord.ovmGasRefund += gasUsed - _cost; + } + } + + /** + * Applies a fixed-size gas refund to a transaction to account for the difference in execution + * between L1 and L2, so that the overall cost of an ovmOPCODE can be lowered. + * @param _discount Amount of gas cost to refund for the ovmOPCODE. + */ + modifier fixedGasDiscount( + uint256 _discount + ) { + uint256 gasProvided = gasleft(); + _; + uint256 gasUsed = gasProvided - gasleft(); + + // We want to refund the specified _discount, unless this risks underflow. + if (_discount < gasUsed) { + transactionRecord.ovmGasRefund += _discount; + } else { + // refund all we can without risking underflow. + transactionRecord.ovmGasRefund += gasUsed; + } + } + + /** + * Makes sure we're not inside a static context. + */ + modifier notStatic() { + if (messageContext.isStatic == true) { + _revertWithFlag(RevertFlag.STATIC_VIOLATION); + } + _; + } + + + /************************************ + * Transaction Execution Entrypoint * + ************************************/ + + /** + * Starts the execution of a transaction via the OVM_ExecutionManager. + * @param _transaction Transaction data to be executed. + * @param _ovmStateManager iOVM_StateManager implementation providing account state. + */ + function run( + Lib_OVMCodec.Transaction memory _transaction, + address _ovmStateManager + ) + override + public + { + require(transactionContext.ovmNUMBER == 0, "Only be callable at the start of a transaction"); + // Store our OVM_StateManager instance (significantly easier than attempting to pass the + // address around in calldata). + ovmStateManager = iOVM_StateManager(_ovmStateManager); + + // Make sure this function can't be called by anyone except the owner of the + // OVM_StateManager (expected to be an OVM_StateTransitioner). We can revert here because + // this would make the `run` itself invalid. + require( + // This method may return false during fraud proofs, but always returns true in L2 nodes' State Manager precompile. + ovmStateManager.isAuthenticated(msg.sender), + "Only authenticated addresses in ovmStateManager can call this function" + ); + + // Initialize the execution context, must be initialized before we perform any gas metering + // or we'll throw a nuisance gas error. + _initContext(_transaction); + + // TEMPORARY: Gas metering is disabled for minnet. + // // Check whether we need to start a new epoch, do so if necessary. + // _checkNeedsNewEpoch(_transaction.timestamp); + + // Make sure the transaction's gas limit is valid. We don't revert here because we reserve + // reverts for INVALID_STATE_ACCESS. + if (_isValidGasLimit(_transaction.gasLimit, _transaction.l1QueueOrigin) == false) { + _resetContext(); + return; + } + + // TEMPORARY: Gas metering is disabled for minnet. + // // Check gas right before the call to get total gas consumed by OVM transaction. + // uint256 gasProvided = gasleft(); + + // Run the transaction, make sure to meter the gas usage. + ovmCALL( + _transaction.gasLimit - gasMeterConfig.minTransactionGasLimit, + _transaction.entrypoint, + _transaction.data + ); + + // TEMPORARY: Gas metering is disabled for minnet. + // // Update the cumulative gas based on the amount of gas used. + // uint256 gasUsed = gasProvided - gasleft(); + // _updateCumulativeGas(gasUsed, _transaction.l1QueueOrigin); + + // Wipe the execution context. + _resetContext(); + + // Reset the ovmStateManager. + ovmStateManager = iOVM_StateManager(address(0)); + } + + + /****************************** + * Opcodes: Execution Context * + ******************************/ + + /** + * @notice Overrides CALLER. + * @return _CALLER Address of the CALLER within the current message context. + */ + function ovmCALLER() + override + public + view + returns ( + address _CALLER + ) + { + return messageContext.ovmCALLER; + } + + /** + * @notice Overrides ADDRESS. + * @return _ADDRESS Active ADDRESS within the current message context. + */ + function ovmADDRESS() + override + public + view + returns ( + address _ADDRESS + ) + { + return messageContext.ovmADDRESS; + } + + /** + * @notice Overrides TIMESTAMP. + * @return _TIMESTAMP Value of the TIMESTAMP within the transaction context. + */ + function ovmTIMESTAMP() + override + public + view + returns ( + uint256 _TIMESTAMP + ) + { + return transactionContext.ovmTIMESTAMP; + } + + /** + * @notice Overrides NUMBER. + * @return _NUMBER Value of the NUMBER within the transaction context. + */ + function ovmNUMBER() + override + public + view + returns ( + uint256 _NUMBER + ) + { + return transactionContext.ovmNUMBER; + } + + /** + * @notice Overrides GASLIMIT. + * @return _GASLIMIT Value of the block's GASLIMIT within the transaction context. + */ + function ovmGASLIMIT() + override + public + view + returns ( + uint256 _GASLIMIT + ) + { + return transactionContext.ovmGASLIMIT; + } + + /** + * @notice Overrides CHAINID. + * @return _CHAINID Value of the chain's CHAINID within the global context. + */ + function ovmCHAINID() + override + public + view + returns ( + uint256 _CHAINID + ) + { + return globalContext.ovmCHAINID; + } + + /********************************* + * Opcodes: L2 Execution Context * + *********************************/ + + /** + * @notice Specifies from which L1 rollup queue this transaction originated from. + * @return _queueOrigin Address of the ovmL1QUEUEORIGIN within the current message context. + */ + function ovmL1QUEUEORIGIN() + override + public + view + returns ( + Lib_OVMCodec.QueueOrigin _queueOrigin + ) + { + return transactionContext.ovmL1QUEUEORIGIN; + } + + /** + * @notice Specifies which L1 account, if any, sent this transaction by calling enqueue(). + * @return _l1TxOrigin Address of the account which sent the tx into L2 from L1. + */ + function ovmL1TXORIGIN() + override + public + view + returns ( + address _l1TxOrigin + ) + { + return transactionContext.ovmL1TXORIGIN; + } + + /******************** + * Opcodes: Halting * + ********************/ + + /** + * @notice Overrides REVERT. + * @param _data Bytes data to pass along with the REVERT. + */ + function ovmREVERT( + bytes memory _data + ) + override + public + { + _revertWithFlag(RevertFlag.INTENTIONAL_REVERT, _data); + } + + + /****************************** + * Opcodes: Contract Creation * + ******************************/ + + /** + * @notice Overrides CREATE. + * @param _bytecode Code to be used to CREATE a new contract. + * @return Address of the created contract. + * @return Revert data, if and only if the creation threw an exception. + */ + function ovmCREATE( + bytes memory _bytecode + ) + override + public + notStatic + fixedGasDiscount(40000) + returns ( + address, + bytes memory + ) + { + // Creator is always the current ADDRESS. + address creator = ovmADDRESS(); + + // Check that the deployer is whitelisted, or + // that arbitrary contract deployment has been enabled. + _checkDeployerAllowed(creator); + + // Generate the correct CREATE address. + address contractAddress = Lib_EthUtils.getAddressForCREATE( + creator, + _getAccountNonce(creator) + ); + + return _createContract( + contractAddress, + _bytecode + ); + } + + /** + * @notice Overrides CREATE2. + * @param _bytecode Code to be used to CREATE2 a new contract. + * @param _salt Value used to determine the contract's address. + * @return Address of the created contract. + * @return Revert data, if and only if the creation threw an exception. + */ + function ovmCREATE2( + bytes memory _bytecode, + bytes32 _salt + ) + override + public + notStatic + fixedGasDiscount(40000) + returns ( + address, + bytes memory + ) + { + // Creator is always the current ADDRESS. + address creator = ovmADDRESS(); + + // Check that the deployer is whitelisted, or + // that arbitrary contract deployment has been enabled. + _checkDeployerAllowed(creator); + + // Generate the correct CREATE2 address. + address contractAddress = Lib_EthUtils.getAddressForCREATE2( + creator, + _bytecode, + _salt + ); + + return _createContract( + contractAddress, + _bytecode + ); + } + + + /******************************* + * Account Abstraction Opcodes * + ******************************/ + + /** + * Retrieves the nonce of the current ovmADDRESS. + * @return _nonce Nonce of the current contract. + */ + function ovmGETNONCE() + override + public + returns ( + uint256 _nonce + ) + { + return _getAccountNonce(ovmADDRESS()); + } + + /** + * Bumps the nonce of the current ovmADDRESS by one. + */ + function ovmINCREMENTNONCE() + override + public + notStatic + { + address account = ovmADDRESS(); + uint256 nonce = _getAccountNonce(account); + + // Prevent overflow. + if (nonce + 1 > nonce) { + _setAccountNonce(account, nonce + 1); + } + } + + /** + * Creates a new EOA contract account, for account abstraction. + * @dev Essentially functions like ovmCREATE or ovmCREATE2, but we can bypass a lot of checks + * because the contract we're creating is trusted (no need to do safety checking or to + * handle unexpected reverts). Doesn't need to return an address because the address is + * assumed to be the user's actual address. + * @param _messageHash Hash of a message signed by some user, for verification. + * @param _v Signature `v` parameter. + * @param _r Signature `r` parameter. + * @param _s Signature `s` parameter. + */ + function ovmCREATEEOA( + bytes32 _messageHash, + uint8 _v, + bytes32 _r, + bytes32 _s + ) + override + public + notStatic + { + // Recover the EOA address from the message hash and signature parameters. Since we do the + // hashing in advance, we don't have handle different message hashing schemes. Even if this + // function were to return the wrong address (rather than explicitly returning the zero + // address), the rest of the transaction would simply fail (since there's no EOA account to + // actually execute the transaction). + address eoa = ecrecover( + _messageHash, + _v + 27, + _r, + _s + ); + + // Invalid signature is a case we proactively handle with a revert. We could alternatively + // have this function return a `success` boolean, but this is just easier. + if (eoa == address(0)) { + ovmREVERT(bytes("Signature provided for EOA contract creation is invalid.")); + } + + // If the user already has an EOA account, then there's no need to perform this operation. + if (_hasEmptyAccount(eoa) == false) { + return; + } + + // We always need to initialize the contract with the default account values. + _initPendingAccount(eoa); + + // Temporarily set the current address so it's easier to access on L2. + address prevADDRESS = messageContext.ovmADDRESS; + messageContext.ovmADDRESS = eoa; + + // Now actually create the account and get its bytecode. We're not worried about reverts + // (other than out of gas, which we can't capture anyway) because this contract is trusted. + OVM_ProxyEOA proxyEOA = new OVM_ProxyEOA(0x4200000000000000000000000000000000000003); + + // Reset the address now that we're done deploying. + messageContext.ovmADDRESS = prevADDRESS; + + // Commit the account with its final values. + _commitPendingAccount( + eoa, + address(proxyEOA), + keccak256(Lib_EthUtils.getCode(address(proxyEOA))) + ); + + _setAccountNonce(eoa, 0); + } + + + /********************************* + * Opcodes: Contract Interaction * + *********************************/ + + /** + * @notice Overrides CALL. + * @param _gasLimit Amount of gas to be passed into this call. + * @param _address Address of the contract to call. + * @param _calldata Data to send along with the call. + * @return _success Whether or not the call returned (rather than reverted). + * @return _returndata Data returned by the call. + */ + function ovmCALL( + uint256 _gasLimit, + address _address, + bytes memory _calldata + ) + override + public + fixedGasDiscount(100000) + returns ( + bool _success, + bytes memory _returndata + ) + { + // CALL updates the CALLER and ADDRESS. + MessageContext memory nextMessageContext = messageContext; + nextMessageContext.ovmCALLER = nextMessageContext.ovmADDRESS; + nextMessageContext.ovmADDRESS = _address; + + return _callContract( + nextMessageContext, + _gasLimit, + _address, + _calldata + ); + } + + /** + * @notice Overrides STATICCALL. + * @param _gasLimit Amount of gas to be passed into this call. + * @param _address Address of the contract to call. + * @param _calldata Data to send along with the call. + * @return _success Whether or not the call returned (rather than reverted). + * @return _returndata Data returned by the call. + */ + function ovmSTATICCALL( + uint256 _gasLimit, + address _address, + bytes memory _calldata + ) + override + public + fixedGasDiscount(80000) + returns ( + bool _success, + bytes memory _returndata + ) + { + // STATICCALL updates the CALLER, updates the ADDRESS, and runs in a static context. + MessageContext memory nextMessageContext = messageContext; + nextMessageContext.ovmCALLER = nextMessageContext.ovmADDRESS; + nextMessageContext.ovmADDRESS = _address; + nextMessageContext.isStatic = true; + + return _callContract( + nextMessageContext, + _gasLimit, + _address, + _calldata + ); + } + + /** + * @notice Overrides DELEGATECALL. + * @param _gasLimit Amount of gas to be passed into this call. + * @param _address Address of the contract to call. + * @param _calldata Data to send along with the call. + * @return _success Whether or not the call returned (rather than reverted). + * @return _returndata Data returned by the call. + */ + function ovmDELEGATECALL( + uint256 _gasLimit, + address _address, + bytes memory _calldata + ) + override + public + fixedGasDiscount(40000) + returns ( + bool _success, + bytes memory _returndata + ) + { + // DELEGATECALL does not change anything about the message context. + MessageContext memory nextMessageContext = messageContext; + + return _callContract( + nextMessageContext, + _gasLimit, + _address, + _calldata + ); + } + + + /************************************ + * Opcodes: Contract Storage Access * + ************************************/ + + /** + * @notice Overrides SLOAD. + * @param _key 32 byte key of the storage slot to load. + * @return _value 32 byte value of the requested storage slot. + */ + function ovmSLOAD( + bytes32 _key + ) + override + public + netGasCost(40000) + returns ( + bytes32 _value + ) + { + // We always SLOAD from the storage of ADDRESS. + address contractAddress = ovmADDRESS(); + + return _getContractStorage( + contractAddress, + _key + ); + } + + /** + * @notice Overrides SSTORE. + * @param _key 32 byte key of the storage slot to set. + * @param _value 32 byte value for the storage slot. + */ + function ovmSSTORE( + bytes32 _key, + bytes32 _value + ) + override + public + notStatic + netGasCost(60000) + { + // We always SSTORE to the storage of ADDRESS. + address contractAddress = ovmADDRESS(); + + _putContractStorage( + contractAddress, + _key, + _value + ); + } + + + /********************************* + * Opcodes: Contract Code Access * + *********************************/ + + /** + * @notice Overrides EXTCODECOPY. + * @param _contract Address of the contract to copy code from. + * @param _offset Offset in bytes from the start of contract code to copy beyond. + * @param _length Total number of bytes to copy from the contract's code. + * @return _code Bytes of code copied from the requested contract. + */ + function ovmEXTCODECOPY( + address _contract, + uint256 _offset, + uint256 _length + ) + override + public + returns ( + bytes memory _code + ) + { + // `ovmEXTCODECOPY` is the only overridden opcode capable of producing exactly one byte of + // return data. By blocking reads of one byte, we're able to use the condition that an + // OVM_ExecutionManager function return value having a length of exactly one byte indicates + // an error without an explicit revert. If users were able to read a single byte, they + // could forcibly trigger behavior that should only be available to this contract. + uint256 length = _length == 1 ? 2 : _length; + + return Lib_EthUtils.getCode( + _getAccountEthAddress(_contract), + _offset, + length + ); + } + + /** + * @notice Overrides EXTCODESIZE. + * @param _contract Address of the contract to query the size of. + * @return _EXTCODESIZE Size of the requested contract in bytes. + */ + function ovmEXTCODESIZE( + address _contract + ) + override + public + returns ( + uint256 _EXTCODESIZE + ) + { + return Lib_EthUtils.getCodeSize( + _getAccountEthAddress(_contract) + ); + } + + /** + * @notice Overrides EXTCODEHASH. + * @param _contract Address of the contract to query the hash of. + * @return _EXTCODEHASH Hash of the requested contract. + */ + function ovmEXTCODEHASH( + address _contract + ) + override + public + returns ( + bytes32 _EXTCODEHASH + ) + { + return Lib_EthUtils.getCodeHash( + _getAccountEthAddress(_contract) + ); + } + + /*************************************** + * Public Functions: Execution Context * + ***************************************/ + + function getMaxTransactionGasLimit() + external + view + override + returns ( + uint256 _maxTransactionGasLimit + ) + { + return gasMeterConfig.maxTransactionGasLimit; + } + + /******************************************** + * Public Functions: Deployment Whitelisting * + ********************************************/ + + /** + * Checks whether the given address is on the whitelist to ovmCREATE/ovmCREATE2, and reverts if not. + * @param _deployerAddress Address attempting to deploy a contract. + */ + function _checkDeployerAllowed( + address _deployerAddress + ) + internal + { + // From an OVM semantics perspective, this will appear identical to + // the deployer ovmCALLing the whitelist. This is fine--in a sense, we are forcing them to. + (bool success, bytes memory data) = ovmCALL( + gasleft(), + 0x4200000000000000000000000000000000000002, + abi.encodeWithSignature("isDeployerAllowed(address)", _deployerAddress) + ); + bool isAllowed = abi.decode(data, (bool)); + + if (!isAllowed || !success) { + _revertWithFlag(RevertFlag.CREATOR_NOT_ALLOWED); + } + } + + /******************************************** + * Internal Functions: Contract Interaction * + ********************************************/ + + /** + * Creates a new contract and associates it with some contract address. + * @param _contractAddress Address to associate the created contract with. + * @param _bytecode Bytecode to be used to create the contract. + * @return Final OVM contract address. + * @return Revertdata, if and only if the creation threw an exception. + */ + function _createContract( + address _contractAddress, + bytes memory _bytecode + ) + internal + returns ( + address, + bytes memory + ) + { + // We always update the nonce of the creating account, even if the creation fails. + _setAccountNonce(ovmADDRESS(), _getAccountNonce(ovmADDRESS()) + 1); + + // We're stepping into a CREATE or CREATE2, so we need to update ADDRESS to point + // to the contract's associated address and CALLER to point to the previous ADDRESS. + MessageContext memory nextMessageContext = messageContext; + nextMessageContext.ovmCALLER = messageContext.ovmADDRESS; + nextMessageContext.ovmADDRESS = _contractAddress; + + // Run the common logic which occurs between call-type and create-type messages, + // passing in the creation bytecode and `true` to trigger create-specific logic. + (bool success, bytes memory data) = _handleExternalMessage( + nextMessageContext, + gasleft(), + _contractAddress, + _bytecode, + true + ); + + // Yellow paper requires that address returned is zero if the contract deployment fails. + return ( + success ? _contractAddress : address(0), + data + ); + } + + /** + * Calls the deployed contract associated with a given address. + * @param _nextMessageContext Message context to be used for the call. + * @param _gasLimit Amount of gas to be passed into this call. + * @param _contract OVM address to be called. + * @param _calldata Data to send along with the call. + * @return _success Whether or not the call returned (rather than reverted). + * @return _returndata Data returned by the call. + */ + function _callContract( + MessageContext memory _nextMessageContext, + uint256 _gasLimit, + address _contract, + bytes memory _calldata + ) + internal + returns ( + bool _success, + bytes memory _returndata + ) + { + // We reserve addresses of the form 0xdeaddeaddead...NNNN for the container contracts in L2 geth. + // So, we block calls to these addresses since they are not safe to run as an OVM contract itself. + if ( + (uint256(_contract) & uint256(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000)) + == uint256(0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000) + ) { + // EVM does not return data in the success case, see: https://github.com/ethereum/go-ethereum/blob/aae7660410f0ef90279e14afaaf2f429fdc2a186/core/vm/instructions.go#L600-L604 + return (true, hex''); + } + + // Both 0x0000... and the EVM precompiles have the same address on L1 and L2 --> no trie lookup needed. + address codeContractAddress = + uint(_contract) < 100 + ? _contract + : _getAccountEthAddress(_contract); + + return _handleExternalMessage( + _nextMessageContext, + _gasLimit, + codeContractAddress, + _calldata, + false + ); + } + + /** + * Handles all interactions which involve the execution manager calling out to untrusted code (both calls and creates). + * Ensures that OVM-related measures are enforced, including L2 gas refunds, nuisance gas, and flagged reversions. + * + * @param _nextMessageContext Message context to be used for the external message. + * @param _gasLimit Amount of gas to be passed into this message. + * @param _contract OVM address being called or deployed to + * @param _data Data for the message (either calldata or creation code) + * @param _isCreate Whether this is a create-type message. + * @return Whether or not the message (either a call or deployment) succeeded. + * @return Data returned by the message. + */ + function _handleExternalMessage( + MessageContext memory _nextMessageContext, + uint256 _gasLimit, + address _contract, + bytes memory _data, + bool _isCreate + ) + internal + returns ( + bool, + bytes memory + ) + { + // We need to switch over to our next message context for the duration of this call. + MessageContext memory prevMessageContext = messageContext; + _switchMessageContext(prevMessageContext, _nextMessageContext); + + // Nuisance gas is a system used to bound the ability for an attacker to make fraud proofs + // expensive by touching a lot of different accounts or storage slots. Since most contracts + // only use a few storage slots during any given transaction, this shouldn't be a limiting + // factor. + uint256 prevNuisanceGasLeft = messageRecord.nuisanceGasLeft; + uint256 nuisanceGasLimit = _getNuisanceGasLimit(_gasLimit); + messageRecord.nuisanceGasLeft = nuisanceGasLimit; + + // Make the call and make sure to pass in the gas limit. Another instance of hidden + // complexity. `_contract` is guaranteed to be a safe contract, meaning its return/revert + // behavior can be controlled. In particular, we enforce that flags are passed through + // revert data as to retrieve execution metadata that would normally be reverted out of + // existence. + + (bool success, bytes memory returndata) = + _isCreate + ? _handleContractCreation(_gasLimit, _data, _contract) + : _contract.call{gas: _gasLimit}(_data); + + // Switch back to the original message context now that we're out of the call. + _switchMessageContext(_nextMessageContext, prevMessageContext); + + // Assuming there were no reverts, the message record should be accurate here. We'll update + // this value in the case of a revert. + uint256 nuisanceGasLeft = messageRecord.nuisanceGasLeft; + + // Reverts at this point are completely OK, but we need to make a few updates based on the + // information passed through the revert. + if (success == false) { + ( + RevertFlag flag, + uint256 nuisanceGasLeftPostRevert, + uint256 ovmGasRefund, + bytes memory returndataFromFlag + ) = _decodeRevertData(returndata); + + // INVALID_STATE_ACCESS is the only flag that triggers an immediate abort of the + // parent EVM message. This behavior is necessary because INVALID_STATE_ACCESS must + // halt any further transaction execution that could impact the execution result. + if (flag == RevertFlag.INVALID_STATE_ACCESS) { + _revertWithFlag(flag); + } + + // INTENTIONAL_REVERT, UNSAFE_BYTECODE, STATIC_VIOLATION, and CREATOR_NOT_ALLOWED aren't + // dependent on the input state, so we can just handle them like standard reverts. Our only change here + // is to record the gas refund reported by the call (enforced by safety checking). + if ( + flag == RevertFlag.INTENTIONAL_REVERT + || flag == RevertFlag.UNSAFE_BYTECODE + || flag == RevertFlag.STATIC_VIOLATION + || flag == RevertFlag.CREATOR_NOT_ALLOWED + ) { + transactionRecord.ovmGasRefund = ovmGasRefund; + } + + // INTENTIONAL_REVERT needs to pass up the user-provided return data encoded into the + // flag, *not* the full encoded flag. All other revert types return no data. + if ( + flag == RevertFlag.INTENTIONAL_REVERT + || _isCreate + ) { + returndata = returndataFromFlag; + } else { + returndata = hex''; + } + + // Reverts mean we need to use up whatever "nuisance gas" was used by the call. + // EXCEEDS_NUISANCE_GAS explicitly reduces the remaining nuisance gas for this message + // to zero. OUT_OF_GAS is a "pseudo" flag given that messages return no data when they + // run out of gas, so we have to treat this like EXCEEDS_NUISANCE_GAS. All other flags + // will simply pass up the remaining nuisance gas. + nuisanceGasLeft = nuisanceGasLeftPostRevert; + } + + // We need to reset the nuisance gas back to its original value minus the amount used here. + messageRecord.nuisanceGasLeft = prevNuisanceGasLeft - (nuisanceGasLimit - nuisanceGasLeft); + + return ( + success, + returndata + ); + } + + /** + * Handles the creation-specific safety measures required for OVM contract deployment. + * This function sanitizes the return types for creation messages to match calls (bool, bytes). + * This allows for consistent handling of both types of messages in _handleExternalMessage(). + * + * @param _gasLimit Amount of gas to be passed into this creation. + * @param _creationCode Code to pass into CREATE for deployment. + * @param _address OVM address being deployed to. + * @return Whether or not the call succeeded. + * @return If creation fails: revert data. Otherwise: empty. + */ + function _handleContractCreation( + uint _gasLimit, + bytes memory _creationCode, + address _address + ) + internal + returns( + bool, + bytes memory + ) + { + // Check that there is not already code at this address. + if (_hasEmptyAccount(_address) == false) { + // Note: in the EVM, this case burns all allotted gas. For improved + // developer experience, we do return the remaining ones. + return ( + false, + _encodeRevertData( + RevertFlag.CREATE_COLLISION, + Lib_ErrorUtils.encodeRevertString("A contract has already been deployed to this address") + ) + ); + } + + // Check the creation bytecode against the OVM_SafetyChecker. + if (ovmSafetyChecker.isBytecodeSafe(_creationCode) == false) { + return ( + false, + _encodeRevertData( + RevertFlag.UNSAFE_BYTECODE, + Lib_ErrorUtils.encodeRevertString("Contract creation code contains unsafe opcodes. Did you use the right compiler or pass an unsafe constructor argument?") + ) + ); + } + + // We always need to initialize the contract with the default account values. + _initPendingAccount(_address); + + // Actually execute the EVM create message, + address ethAddress = Lib_EthUtils.createContract(_creationCode); + + if (ethAddress == address(0)) { + // If the creation fails, the EVM lets us grab its revert data. This may contain a revert flag + // to be used above in _handleExternalMessage. + uint256 revertDataSize; + assembly { revertDataSize := returndatasize() } + bytes memory revertdata = new bytes(revertDataSize); + assembly { + returndatacopy( + add(revertdata, 0x20), + 0, + revertDataSize + ) + } + // Return that the creation failed, and the data it reverted with. + return (false, revertdata); + } + + // Again simply checking that the deployed code is safe too. Contracts can generate + // arbitrary deployment code, so there's no easy way to analyze this beforehand. + bytes memory deployedCode = Lib_EthUtils.getCode(ethAddress); + if (ovmSafetyChecker.isBytecodeSafe(deployedCode) == false) { + return ( + false, + _encodeRevertData( + RevertFlag.UNSAFE_BYTECODE, + Lib_ErrorUtils.encodeRevertString("Constructor attempted to deploy unsafe bytecode.") + ) + ); + } + + // Contract creation didn't need to be reverted and the bytecode is safe. We finish up by + // associating the desired address with the newly created contract's code hash and address. + _commitPendingAccount( + _address, + ethAddress, + Lib_EthUtils.getCodeHash(ethAddress) + ); + + // Successful deployments will not give access to returndata, in both the EVM and the OVM. + return (true, hex''); + } + + /****************************************** + * Internal Functions: State Manipulation * + ******************************************/ + + /** + * Checks whether an account exists within the OVM_StateManager. + * @param _address Address of the account to check. + * @return _exists Whether or not the account exists. + */ + function _hasAccount( + address _address + ) + internal + returns ( + bool _exists + ) + { + _checkAccountLoad(_address); + return ovmStateManager.hasAccount(_address); + } + + /** + * Checks whether a known empty account exists within the OVM_StateManager. + * @param _address Address of the account to check. + * @return _exists Whether or not the account empty exists. + */ + function _hasEmptyAccount( + address _address + ) + internal + returns ( + bool _exists + ) + { + _checkAccountLoad(_address); + return ovmStateManager.hasEmptyAccount(_address); + } + + /** + * Sets the nonce of an account. + * @param _address Address of the account to modify. + * @param _nonce New account nonce. + */ + function _setAccountNonce( + address _address, + uint256 _nonce + ) + internal + { + _checkAccountChange(_address); + ovmStateManager.setAccountNonce(_address, _nonce); + } + + /** + * Gets the nonce of an account. + * @param _address Address of the account to access. + * @return _nonce Nonce of the account. + */ + function _getAccountNonce( + address _address + ) + internal + returns ( + uint256 _nonce + ) + { + _checkAccountLoad(_address); + return ovmStateManager.getAccountNonce(_address); + } + + /** + * Retrieves the Ethereum address of an account. + * @param _address Address of the account to access. + * @return _ethAddress Corresponding Ethereum address. + */ + function _getAccountEthAddress( + address _address + ) + internal + returns ( + address _ethAddress + ) + { + _checkAccountLoad(_address); + return ovmStateManager.getAccountEthAddress(_address); + } + + /** + * Creates the default account object for the given address. + * @param _address Address of the account create. + */ + function _initPendingAccount( + address _address + ) + internal + { + // Although it seems like `_checkAccountChange` would be more appropriate here, we don't + // actually consider an account "changed" until it's inserted into the state (in this case + // by `_commitPendingAccount`). + _checkAccountLoad(_address); + ovmStateManager.initPendingAccount(_address); + } + + /** + * Stores additional relevant data for a new account, thereby "committing" it to the state. + * This function is only called during `ovmCREATE` and `ovmCREATE2` after a successful contract + * creation. + * @param _address Address of the account to commit. + * @param _ethAddress Address of the associated deployed contract. + * @param _codeHash Hash of the code stored at the address. + */ + function _commitPendingAccount( + address _address, + address _ethAddress, + bytes32 _codeHash + ) + internal + { + _checkAccountChange(_address); + ovmStateManager.commitPendingAccount( + _address, + _ethAddress, + _codeHash + ); + } + + /** + * Retrieves the value of a storage slot. + * @param _contract Address of the contract to query. + * @param _key 32 byte key of the storage slot. + * @return _value 32 byte storage slot value. + */ + function _getContractStorage( + address _contract, + bytes32 _key + ) + internal + returns ( + bytes32 _value + ) + { + _checkContractStorageLoad(_contract, _key); + return ovmStateManager.getContractStorage(_contract, _key); + } + + /** + * Sets the value of a storage slot. + * @param _contract Address of the contract to modify. + * @param _key 32 byte key of the storage slot. + * @param _value 32 byte storage slot value. + */ + function _putContractStorage( + address _contract, + bytes32 _key, + bytes32 _value + ) + internal + { + // We don't set storage if the value didn't change. Although this acts as a convenient + // optimization, it's also necessary to avoid the case in which a contract with no storage + // attempts to store the value "0" at any key. Putting this value (and therefore requiring + // that the value be committed into the storage trie after execution) would incorrectly + // modify the storage root. + if (_getContractStorage(_contract, _key) == _value) { + return; + } + + _checkContractStorageChange(_contract, _key); + ovmStateManager.putContractStorage(_contract, _key, _value); + } + + /** + * Validation whenever a contract needs to be loaded. Checks that the account exists, charges + * nuisance gas if the account hasn't been loaded before. + * @param _address Address of the account to load. + */ + function _checkAccountLoad( + address _address + ) + internal + { + // See `_checkContractStorageLoad` for more information. + if (gasleft() < MIN_GAS_FOR_INVALID_STATE_ACCESS) { + _revertWithFlag(RevertFlag.OUT_OF_GAS); + } + + // See `_checkContractStorageLoad` for more information. + if (ovmStateManager.hasAccount(_address) == false) { + _revertWithFlag(RevertFlag.INVALID_STATE_ACCESS); + } + + // Check whether the account has been loaded before and mark it as loaded if not. We need + // this because "nuisance gas" only applies to the first time that an account is loaded. + ( + bool _wasAccountAlreadyLoaded + ) = ovmStateManager.testAndSetAccountLoaded(_address); + + // If we hadn't already loaded the account, then we'll need to charge "nuisance gas" based + // on the size of the contract code. + if (_wasAccountAlreadyLoaded == false) { + _useNuisanceGas( + (Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address)) * NUISANCE_GAS_PER_CONTRACT_BYTE) + MIN_NUISANCE_GAS_PER_CONTRACT + ); + } + } + + /** + * Validation whenever a contract needs to be changed. Checks that the account exists, charges + * nuisance gas if the account hasn't been changed before. + * @param _address Address of the account to change. + */ + function _checkAccountChange( + address _address + ) + internal + { + // Start by checking for a load as we only want to charge nuisance gas proportional to + // contract size once. + _checkAccountLoad(_address); + + // Check whether the account has been changed before and mark it as changed if not. We need + // this because "nuisance gas" only applies to the first time that an account is changed. + ( + bool _wasAccountAlreadyChanged + ) = ovmStateManager.testAndSetAccountChanged(_address); + + // If we hadn't already loaded the account, then we'll need to charge "nuisance gas" based + // on the size of the contract code. + if (_wasAccountAlreadyChanged == false) { + ovmStateManager.incrementTotalUncommittedAccounts(); + _useNuisanceGas( + (Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address)) * NUISANCE_GAS_PER_CONTRACT_BYTE) + MIN_NUISANCE_GAS_PER_CONTRACT + ); + } + } + + /** + * Validation whenever a slot needs to be loaded. Checks that the account exists, charges + * nuisance gas if the slot hasn't been loaded before. + * @param _contract Address of the account to load from. + * @param _key 32 byte key to load. + */ + function _checkContractStorageLoad( + address _contract, + bytes32 _key + ) + internal + { + // Another case of hidden complexity. If we didn't enforce this requirement, then a + // contract could pass in just enough gas to cause the INVALID_STATE_ACCESS check to fail + // on L1 but not on L2. A contract could use this behavior to prevent the + // OVM_ExecutionManager from detecting an invalid state access. Reverting with OUT_OF_GAS + // allows us to also charge for the full message nuisance gas, because you deserve that for + // trying to break the contract in this way. + if (gasleft() < MIN_GAS_FOR_INVALID_STATE_ACCESS) { + _revertWithFlag(RevertFlag.OUT_OF_GAS); + } + + // We need to make sure that the transaction isn't trying to access storage that hasn't + // been provided to the OVM_StateManager. We'll immediately abort if this is the case. + // We know that we have enough gas to do this check because of the above test. + if (ovmStateManager.hasContractStorage(_contract, _key) == false) { + _revertWithFlag(RevertFlag.INVALID_STATE_ACCESS); + } + + // Check whether the slot has been loaded before and mark it as loaded if not. We need + // this because "nuisance gas" only applies to the first time that a slot is loaded. + ( + bool _wasContractStorageAlreadyLoaded + ) = ovmStateManager.testAndSetContractStorageLoaded(_contract, _key); + + // If we hadn't already loaded the account, then we'll need to charge some fixed amount of + // "nuisance gas". + if (_wasContractStorageAlreadyLoaded == false) { + _useNuisanceGas(NUISANCE_GAS_SLOAD); + } + } + + /** + * Validation whenever a slot needs to be changed. Checks that the account exists, charges + * nuisance gas if the slot hasn't been changed before. + * @param _contract Address of the account to change. + * @param _key 32 byte key to change. + */ + function _checkContractStorageChange( + address _contract, + bytes32 _key + ) + internal + { + // Start by checking for load to make sure we have the storage slot and that we charge the + // "nuisance gas" necessary to prove the storage slot state. + _checkContractStorageLoad(_contract, _key); + + // Check whether the slot has been changed before and mark it as changed if not. We need + // this because "nuisance gas" only applies to the first time that a slot is changed. + ( + bool _wasContractStorageAlreadyChanged + ) = ovmStateManager.testAndSetContractStorageChanged(_contract, _key); + + // If we hadn't already changed the account, then we'll need to charge some fixed amount of + // "nuisance gas". + if (_wasContractStorageAlreadyChanged == false) { + // Changing a storage slot means that we're also going to have to change the + // corresponding account, so do an account change check. + _checkAccountChange(_contract); + + ovmStateManager.incrementTotalUncommittedContractStorage(); + _useNuisanceGas(NUISANCE_GAS_SSTORE); + } + } + + + /************************************ + * Internal Functions: Revert Logic * + ************************************/ + + /** + * Simple encoding for revert data. + * @param _flag Flag to revert with. + * @param _data Additional user-provided revert data. + * @return _revertdata Encoded revert data. + */ + function _encodeRevertData( + RevertFlag _flag, + bytes memory _data + ) + internal + view + returns ( + bytes memory _revertdata + ) + { + // Out of gas and create exceptions will fundamentally return no data, so simulating it shouldn't either. + if ( + _flag == RevertFlag.OUT_OF_GAS + ) { + return bytes(''); + } + + // INVALID_STATE_ACCESS doesn't need to return any data other than the flag. + if (_flag == RevertFlag.INVALID_STATE_ACCESS) { + return abi.encode( + _flag, + 0, + 0, + bytes('') + ); + } + + // Just ABI encode the rest of the parameters. + return abi.encode( + _flag, + messageRecord.nuisanceGasLeft, + transactionRecord.ovmGasRefund, + _data + ); + } + + /** + * Simple decoding for revert data. + * @param _revertdata Revert data to decode. + * @return _flag Flag used to revert. + * @return _nuisanceGasLeft Amount of nuisance gas unused by the message. + * @return _ovmGasRefund Amount of gas refunded during the message. + * @return _data Additional user-provided revert data. + */ + function _decodeRevertData( + bytes memory _revertdata + ) + internal + pure + returns ( + RevertFlag _flag, + uint256 _nuisanceGasLeft, + uint256 _ovmGasRefund, + bytes memory _data + ) + { + // A length of zero means the call ran out of gas, just return empty data. + if (_revertdata.length == 0) { + return ( + RevertFlag.OUT_OF_GAS, + 0, + 0, + bytes('') + ); + } + + // ABI decode the incoming data. + return abi.decode(_revertdata, (RevertFlag, uint256, uint256, bytes)); + } + + /** + * Causes a message to revert or abort. + * @param _flag Flag to revert with. + * @param _data Additional user-provided data. + */ + function _revertWithFlag( + RevertFlag _flag, + bytes memory _data + ) + internal + view + { + bytes memory revertdata = _encodeRevertData( + _flag, + _data + ); + + assembly { + revert(add(revertdata, 0x20), mload(revertdata)) + } + } + + /** + * Causes a message to revert or abort. + * @param _flag Flag to revert with. + */ + function _revertWithFlag( + RevertFlag _flag + ) + internal + { + _revertWithFlag(_flag, bytes('')); + } + + + /****************************************** + * Internal Functions: Nuisance Gas Logic * + ******************************************/ + + /** + * Computes the nuisance gas limit from the gas limit. + * @dev This function is currently using a naive implementation whereby the nuisance gas limit + * is set to exactly equal the lesser of the gas limit or remaining gas. It's likely that + * this implementation is perfectly fine, but we may change this formula later. + * @param _gasLimit Gas limit to compute from. + * @return _nuisanceGasLimit Computed nuisance gas limit. + */ + function _getNuisanceGasLimit( + uint256 _gasLimit + ) + internal + view + returns ( + uint256 _nuisanceGasLimit + ) + { + return _gasLimit < gasleft() ? _gasLimit : gasleft(); + } + + /** + * Uses a certain amount of nuisance gas. + * @param _amount Amount of nuisance gas to use. + */ + function _useNuisanceGas( + uint256 _amount + ) + internal + { + // Essentially the same as a standard OUT_OF_GAS, except we also retain a record of the gas + // refund to be given at the end of the transaction. + if (messageRecord.nuisanceGasLeft < _amount) { + _revertWithFlag(RevertFlag.EXCEEDS_NUISANCE_GAS); + } + + messageRecord.nuisanceGasLeft -= _amount; + } + + + /************************************ + * Internal Functions: Gas Metering * + ************************************/ + + /** + * Checks whether a transaction needs to start a new epoch and does so if necessary. + * @param _timestamp Transaction timestamp. + */ + function _checkNeedsNewEpoch( + uint256 _timestamp + ) + internal + { + if ( + _timestamp >= ( + _getGasMetadata(GasMetadataKey.CURRENT_EPOCH_START_TIMESTAMP) + + gasMeterConfig.secondsPerEpoch + ) + ) { + _putGasMetadata( + GasMetadataKey.CURRENT_EPOCH_START_TIMESTAMP, + _timestamp + ); + + _putGasMetadata( + GasMetadataKey.PREV_EPOCH_SEQUENCER_QUEUE_GAS, + _getGasMetadata( + GasMetadataKey.CUMULATIVE_SEQUENCER_QUEUE_GAS + ) + ); + + _putGasMetadata( + GasMetadataKey.PREV_EPOCH_L1TOL2_QUEUE_GAS, + _getGasMetadata( + GasMetadataKey.CUMULATIVE_L1TOL2_QUEUE_GAS + ) + ); + } + } + + /** + * Validates the gas limit for a given transaction. + * @param _gasLimit Gas limit provided by the transaction. + * param _queueOrigin Queue from which the transaction originated. + * @return _valid Whether or not the gas limit is valid. + */ + function _isValidGasLimit( + uint256 _gasLimit, + Lib_OVMCodec.QueueOrigin // _queueOrigin + ) + view + internal + returns ( + bool _valid + ) + { + // Always have to be below the maximum gas limit. + if (_gasLimit > gasMeterConfig.maxTransactionGasLimit) { + return false; + } + + // Always have to be above the minimum gas limit. + if (_gasLimit < gasMeterConfig.minTransactionGasLimit) { + return false; + } + + // TEMPORARY: Gas metering is disabled for minnet. + return true; + // GasMetadataKey cumulativeGasKey; + // GasMetadataKey prevEpochGasKey; + // if (_queueOrigin == Lib_OVMCodec.QueueOrigin.SEQUENCER_QUEUE) { + // cumulativeGasKey = GasMetadataKey.CUMULATIVE_SEQUENCER_QUEUE_GAS; + // prevEpochGasKey = GasMetadataKey.PREV_EPOCH_SEQUENCER_QUEUE_GAS; + // } else { + // cumulativeGasKey = GasMetadataKey.CUMULATIVE_L1TOL2_QUEUE_GAS; + // prevEpochGasKey = GasMetadataKey.PREV_EPOCH_L1TOL2_QUEUE_GAS; + // } + + // return ( + // ( + // _getGasMetadata(cumulativeGasKey) + // - _getGasMetadata(prevEpochGasKey) + // + _gasLimit + // ) < gasMeterConfig.maxGasPerQueuePerEpoch + // ); + } + + /** + * Updates the cumulative gas after a transaction. + * @param _gasUsed Gas used by the transaction. + * @param _queueOrigin Queue from which the transaction originated. + */ + function _updateCumulativeGas( + uint256 _gasUsed, + Lib_OVMCodec.QueueOrigin _queueOrigin + ) + internal + { + GasMetadataKey cumulativeGasKey; + if (_queueOrigin == Lib_OVMCodec.QueueOrigin.SEQUENCER_QUEUE) { + cumulativeGasKey = GasMetadataKey.CUMULATIVE_SEQUENCER_QUEUE_GAS; + } else { + cumulativeGasKey = GasMetadataKey.CUMULATIVE_L1TOL2_QUEUE_GAS; + } + + _putGasMetadata( + cumulativeGasKey, + ( + _getGasMetadata(cumulativeGasKey) + + gasMeterConfig.minTransactionGasLimit + + _gasUsed + - transactionRecord.ovmGasRefund + ) + ); + } + + /** + * Retrieves the value of a gas metadata key. + * @param _key Gas metadata key to retrieve. + * @return _value Value stored at the given key. + */ + function _getGasMetadata( + GasMetadataKey _key + ) + internal + returns ( + uint256 _value + ) + { + return uint256(_getContractStorage( + GAS_METADATA_ADDRESS, + bytes32(uint256(_key)) + )); + } + + /** + * Sets the value of a gas metadata key. + * @param _key Gas metadata key to set. + * @param _value Value to store at the given key. + */ + function _putGasMetadata( + GasMetadataKey _key, + uint256 _value + ) + internal + { + _putContractStorage( + GAS_METADATA_ADDRESS, + bytes32(uint256(_key)), + bytes32(uint256(_value)) + ); + } + + + /***************************************** + * Internal Functions: Execution Context * + *****************************************/ + + /** + * Swaps over to a new message context. + * @param _prevMessageContext Context we're switching from. + * @param _nextMessageContext Context we're switching to. + */ + function _switchMessageContext( + MessageContext memory _prevMessageContext, + MessageContext memory _nextMessageContext + ) + internal + { + // Avoid unnecessary the SSTORE. + if (_prevMessageContext.ovmCALLER != _nextMessageContext.ovmCALLER) { + messageContext.ovmCALLER = _nextMessageContext.ovmCALLER; + } + + // Avoid unnecessary the SSTORE. + if (_prevMessageContext.ovmADDRESS != _nextMessageContext.ovmADDRESS) { + messageContext.ovmADDRESS = _nextMessageContext.ovmADDRESS; + } + + // Avoid unnecessary the SSTORE. + if (_prevMessageContext.isStatic != _nextMessageContext.isStatic) { + messageContext.isStatic = _nextMessageContext.isStatic; + } + } + + /** + * Initializes the execution context. + * @param _transaction OVM transaction being executed. + */ + function _initContext( + Lib_OVMCodec.Transaction memory _transaction + ) + internal + { + transactionContext.ovmTIMESTAMP = _transaction.timestamp; + transactionContext.ovmNUMBER = _transaction.blockNumber; + transactionContext.ovmTXGASLIMIT = _transaction.gasLimit; + transactionContext.ovmL1QUEUEORIGIN = _transaction.l1QueueOrigin; + transactionContext.ovmL1TXORIGIN = _transaction.l1TxOrigin; + transactionContext.ovmGASLIMIT = gasMeterConfig.maxGasPerQueuePerEpoch; + + messageRecord.nuisanceGasLeft = _getNuisanceGasLimit(_transaction.gasLimit); + } + + /** + * Resets the transaction and message context. + */ + function _resetContext() + internal + { + transactionContext.ovmL1TXORIGIN = address(0); + transactionContext.ovmTIMESTAMP = 0; + transactionContext.ovmNUMBER = 0; + transactionContext.ovmGASLIMIT = 0; + transactionContext.ovmTXGASLIMIT = 0; + transactionContext.ovmL1QUEUEORIGIN = Lib_OVMCodec.QueueOrigin.SEQUENCER_QUEUE; + + transactionRecord.ovmGasRefund = 0; + + messageContext.ovmCALLER = address(0); + messageContext.ovmADDRESS = address(0); + messageContext.isStatic = false; + + messageRecord.nuisanceGasLeft = 0; + } + + /***************************** + * L2-only Helper Functions * + *****************************/ + + /** + * Unreachable helper function for simulating eth_calls with an OVM message context. + * This function will throw an exception in all cases other than when used as a custom entrypoint in L2 Geth to simulate eth_call. + * @param _transaction the message transaction to simulate. + * @param _from the OVM account the simulated call should be from. + */ + function simulateMessage( + Lib_OVMCodec.Transaction memory _transaction, + address _from, + iOVM_StateManager _ovmStateManager + ) + external + returns ( + bool, + bytes memory + ) + { + // Prevent this call from having any effect unless in a custom-set VM frame + require(msg.sender == address(0)); + + ovmStateManager = _ovmStateManager; + _initContext(_transaction); + messageRecord.nuisanceGasLeft = uint(-1); + + messageContext.ovmADDRESS = _from; + + bool isCreate = _transaction.entrypoint == address(0); + if (isCreate) { + (address created, bytes memory revertData) = ovmCREATE(_transaction.data); + if (created == address(0)) { + return (false, revertData); + } else { + // The eth_call RPC endpoint for to = undefined will return the deployed bytecode + // in the success case, differing from standard create messages. + return (true, Lib_EthUtils.getCode(created)); + } + } else { + return ovmCALL( + _transaction.gasLimit, + _transaction.entrypoint, + _transaction.data + ); + } + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_SafetyChecker.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_SafetyChecker.sol new file mode 100644 index 000000000000..ff90584a6b64 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_SafetyChecker.sol @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Interface Imports */ +import { iOVM_SafetyChecker } from "../../iOVM/execution/iOVM_SafetyChecker.sol"; + +/** + * @title OVM_SafetyChecker + * @dev The Safety Checker verifies that contracts deployed on L2 do not contain any + * "unsafe" operations. An operation is considered unsafe if it would access state variables which + * are specific to the environment (ie. L1 or L2) in which it is executed, as this could be used + * to "escape the sandbox" of the OVM, resulting in non-deterministic fraud proofs. + * That is, an attacker would be able to "prove fraud" on an honestly applied transaction. + * Note that a "safe" contract requires opcodes to appear in a particular pattern; + * omission of "unsafe" opcodes is necessary, but not sufficient. + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_SafetyChecker is iOVM_SafetyChecker { + + /******************** + * Public Functions * + ********************/ + + /** + * Returns whether or not all of the provided bytecode is safe. + * @param _bytecode The bytecode to safety check. + * @return `true` if the bytecode is safe, `false` otherwise. + */ + function isBytecodeSafe( + bytes memory _bytecode + ) + override + external + pure + returns ( + bool + ) + { + // autogenerated by gen_safety_checker_constants.py + // number of bytes to skip for each opcode + uint256[8] memory opcodeSkippableBytes = [ + uint256(0x0001010101010101010101010000000001010101010101010101010101010000), + uint256(0x0100000000000000000000000000000000000000010101010101000000010100), + uint256(0x0000000000000000000000000000000001010101000000010101010100000000), + uint256(0x0203040500000000000000000000000000000000000000000000000000000000), + uint256(0x0101010101010101010101010101010101010101010101010101010101010101), + uint256(0x0101010101000000000000000000000000000000000000000000000000000000), + uint256(0x0000000000000000000000000000000000000000000000000000000000000000), + uint256(0x0000000000000000000000000000000000000000000000000000000000000000) + ]; + // Mask to gate opcode specific cases + uint256 opcodeGateMask = ~uint256(0xffffffffffffffffffffffe000000000fffffffff070ffff9c0ffffec000f001); + // Halting opcodes + uint256 opcodeHaltingMask = ~uint256(0x4008000000000000000000000000000000000000004000000000000000000001); + // PUSH opcodes + uint256 opcodePushMask = ~uint256(0xffffffff000000000000000000000000); + + uint256 codeLength; + uint256 _pc; + assembly { + _pc := add(_bytecode, 0x20) + } + codeLength = _pc + _bytecode.length; + do { + // current opcode: 0x00...0xff + uint256 opNum; + + // inline assembly removes the extra add + bounds check + assembly { + let word := mload(_pc) //load the next 32 bytes at pc into word + + // Look up number of bytes to skip from opcodeSkippableBytes and then update indexInWord + // E.g. the 02030405 in opcodeSkippableBytes is the number of bytes to skip for PUSH1->4 + // We repeat this 6 times, thus we can only skip bytes for up to PUSH4 ((1+4) * 6 = 30 < 32). + // If we see an opcode that is listed as 0 skippable bytes e.g. PUSH5, + // then we will get stuck on that indexInWord and then opNum will be set to the PUSH5 opcode. + let indexInWord := byte(0, mload(add(opcodeSkippableBytes, byte(0, word)))) + indexInWord := add(indexInWord, byte(0, mload(add(opcodeSkippableBytes, byte(indexInWord, word))))) + indexInWord := add(indexInWord, byte(0, mload(add(opcodeSkippableBytes, byte(indexInWord, word))))) + indexInWord := add(indexInWord, byte(0, mload(add(opcodeSkippableBytes, byte(indexInWord, word))))) + indexInWord := add(indexInWord, byte(0, mload(add(opcodeSkippableBytes, byte(indexInWord, word))))) + indexInWord := add(indexInWord, byte(0, mload(add(opcodeSkippableBytes, byte(indexInWord, word))))) + _pc := add(_pc, indexInWord) + + opNum := byte(indexInWord, word) + } + + // + push opcodes + // + stop opcodes [STOP(0x00),JUMP(0x56),RETURN(0xf3),INVALID(0xfe)] + // + caller opcode CALLER(0x33) + // + blacklisted opcodes + uint256 opBit = 1 << opNum; + if (opBit & opcodeGateMask == 0) { + if (opBit & opcodePushMask == 0) { + // all pushes are valid opcodes + // subsequent bytes are not opcodes. Skip them. + _pc += (opNum - 0x5e); // PUSH1 is 0x60, so opNum-0x5f = PUSHed bytes and we +1 to + // skip the _pc++; line below in order to save gas ((-0x5f + 1) = -0x5e) + continue; + } else if (opBit & opcodeHaltingMask == 0) { + // STOP or JUMP or RETURN or INVALID (Note: REVERT is blacklisted, so not included here) + // We are now inside unreachable code until we hit a JUMPDEST! + do { + _pc++; + assembly { + opNum := byte(0, mload(_pc)) + } + // encountered a JUMPDEST + if (opNum == 0x5b) break; + // skip PUSHed bytes + if ((1 << opNum) & opcodePushMask == 0) _pc += (opNum - 0x5f); // opNum-0x5f = PUSHed bytes (PUSH1 is 0x60) + } while (_pc < codeLength); + // opNum is 0x5b, so we don't continue here since the pc++ is fine + } else if (opNum == 0x33) { // Caller opcode + uint256 firstOps; // next 32 bytes of bytecode + uint256 secondOps; // following 32 bytes of bytecode + + assembly { + firstOps := mload(_pc) + // 37 bytes total, 5 left over --> 32 - 5 bytes = 27 bytes = 216 bits + secondOps := shr(216, mload(add(_pc, 0x20))) + } + + // Call identity precompile + // CALLER POP PUSH1 0x00 PUSH1 0x04 GAS CALL + // 32 - 8 bytes = 24 bytes = 192 + if ((firstOps >> 192) == 0x3350600060045af1) { + _pc += 8; + // Call EM and abort execution if instructed + // CALLER PUSH1 0x00 SWAP1 GAS CALL PC PUSH1 0x0E ADD JUMPI RETURNDATASIZE PUSH1 0x00 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1 0x00 REVERT JUMPDEST RETURNDATASIZE PUSH1 0x01 EQ ISZERO PC PUSH1 0x0a ADD JUMPI PUSH1 0x01 PUSH1 0x00 RETURN JUMPDEST + } else if (firstOps == 0x336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760 && secondOps == 0x016000f35b) { + _pc += 37; + } else { + return false; + } + continue; + } else { + // encountered a non-whitelisted opcode! + return false; + } + } + _pc++; + } while (_pc < codeLength); + return true; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_StateManager.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_StateManager.sol new file mode 100644 index 000000000000..2d8a95bc13e6 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_StateManager.sol @@ -0,0 +1,738 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; + +/* Interface Imports */ +import { iOVM_StateManager } from "../../iOVM/execution/iOVM_StateManager.sol"; + +/** + * @title OVM_StateManager + * @dev The State Manager contract holds all storage values for contracts in the OVM. It can only be written to by the + * the Execution Manager and State Transitioner. It runs on L1 during the setup and execution of a fraud proof. + * The same logic runs on L2, but has been implemented as a precompile in the L2 go-ethereum client + * (see https://github.com/ethereum-optimism/go-ethereum/blob/master/core/vm/ovm_state_manager.go). + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_StateManager is iOVM_StateManager { + + /************* + * Constants * + *************/ + + bytes32 constant internal EMPTY_ACCOUNT_STORAGE_ROOT = 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421; + bytes32 constant internal EMPTY_ACCOUNT_CODE_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; + bytes32 constant internal STORAGE_XOR_VALUE = 0xFEEDFACECAFEBEEFFEEDFACECAFEBEEFFEEDFACECAFEBEEFFEEDFACECAFEBEEF; + + + /************* + * Variables * + *************/ + + address override public owner; + address override public ovmExecutionManager; + mapping (address => Lib_OVMCodec.Account) internal accounts; + mapping (address => mapping (bytes32 => bytes32)) internal contractStorage; + mapping (address => mapping (bytes32 => bool)) internal verifiedContractStorage; + mapping (bytes32 => ItemState) internal itemStates; + uint256 internal totalUncommittedAccounts; + uint256 internal totalUncommittedContractStorage; + + + /*************** + * Constructor * + ***************/ + + /** + * @param _owner Address of the owner of this contract. + */ + constructor( + address _owner + ) + { + owner = _owner; + } + + + /********************** + * Function Modifiers * + **********************/ + + /** + * Simple authentication, this contract should only be accessible to the owner (which is expected to be the State Transitioner during `PRE_EXECUTION` + * or the OVM_ExecutionManager during transaction execution. + */ + modifier authenticated() { + // owner is the State Transitioner + require( + msg.sender == owner || msg.sender == ovmExecutionManager, + "Function can only be called by authenticated addresses" + ); + _; + } + + /******************** + * Public Functions * + ********************/ + + /** + * Checks whether a given address is allowed to modify this contract. + * @param _address Address to check. + * @return Whether or not the address can modify this contract. + */ + function isAuthenticated( + address _address + ) + override + public + view + returns ( + bool + ) + { + return (_address == owner || _address == ovmExecutionManager); + } + + /** + * Sets the address of the OVM_ExecutionManager. + * @param _ovmExecutionManager Address of the OVM_ExecutionManager. + */ + function setExecutionManager( + address _ovmExecutionManager + ) + override + public + authenticated + { + ovmExecutionManager = _ovmExecutionManager; + } + + /** + * Inserts an account into the state. + * @param _address Address of the account to insert. + * @param _account Account to insert for the given address. + */ + function putAccount( + address _address, + Lib_OVMCodec.Account memory _account + ) + override + public + authenticated + { + accounts[_address] = _account; + } + + /** + * Marks an account as empty. + * @param _address Address of the account to mark. + */ + function putEmptyAccount( + address _address + ) + override + public + authenticated + { + Lib_OVMCodec.Account storage account = accounts[_address]; + account.storageRoot = EMPTY_ACCOUNT_STORAGE_ROOT; + account.codeHash = EMPTY_ACCOUNT_CODE_HASH; + } + + /** + * Retrieves an account from the state. + * @param _address Address of the account to retrieve. + * @return Account for the given address. + */ + function getAccount( + address _address + ) + override + public + view + returns ( + Lib_OVMCodec.Account memory + ) + { + return accounts[_address]; + } + + /** + * Checks whether the state has a given account. + * @param _address Address of the account to check. + * @return Whether or not the state has the account. + */ + function hasAccount( + address _address + ) + override + public + view + returns ( + bool + ) + { + return accounts[_address].codeHash != bytes32(0); + } + + /** + * Checks whether the state has a given known empty account. + * @param _address Address of the account to check. + * @return Whether or not the state has the empty account. + */ + function hasEmptyAccount( + address _address + ) + override + public + view + returns ( + bool + ) + { + return ( + accounts[_address].codeHash == EMPTY_ACCOUNT_CODE_HASH + && accounts[_address].nonce == 0 + ); + } + + /** + * Sets the nonce of an account. + * @param _address Address of the account to modify. + * @param _nonce New account nonce. + */ + function setAccountNonce( + address _address, + uint256 _nonce + ) + override + public + authenticated + { + accounts[_address].nonce = _nonce; + } + + /** + * Gets the nonce of an account. + * @param _address Address of the account to access. + * @return Nonce of the account. + */ + function getAccountNonce( + address _address + ) + override + public + view + returns ( + uint256 + ) + { + return accounts[_address].nonce; + } + + /** + * Retrieves the Ethereum address of an account. + * @param _address Address of the account to access. + * @return Corresponding Ethereum address. + */ + function getAccountEthAddress( + address _address + ) + override + public + view + returns ( + address + ) + { + return accounts[_address].ethAddress; + } + + /** + * Retrieves the storage root of an account. + * @param _address Address of the account to access. + * @return Corresponding storage root. + */ + function getAccountStorageRoot( + address _address + ) + override + public + view + returns ( + bytes32 + ) + { + return accounts[_address].storageRoot; + } + + /** + * Initializes a pending account (during CREATE or CREATE2) with the default values. + * @param _address Address of the account to initialize. + */ + function initPendingAccount( + address _address + ) + override + public + authenticated + { + Lib_OVMCodec.Account storage account = accounts[_address]; + account.nonce = 1; + account.storageRoot = EMPTY_ACCOUNT_STORAGE_ROOT; + account.codeHash = EMPTY_ACCOUNT_CODE_HASH; + account.isFresh = true; + } + + /** + * Finalizes the creation of a pending account (during CREATE or CREATE2). + * @param _address Address of the account to finalize. + * @param _ethAddress Address of the account's associated contract on Ethereum. + * @param _codeHash Hash of the account's code. + */ + function commitPendingAccount( + address _address, + address _ethAddress, + bytes32 _codeHash + ) + override + public + authenticated + { + Lib_OVMCodec.Account storage account = accounts[_address]; + account.ethAddress = _ethAddress; + account.codeHash = _codeHash; + } + + /** + * Checks whether an account has already been retrieved, and marks it as retrieved if not. + * @param _address Address of the account to check. + * @return Whether or not the account was already loaded. + */ + function testAndSetAccountLoaded( + address _address + ) + override + public + authenticated + returns ( + bool + ) + { + return _testAndSetItemState( + _getItemHash(_address), + ItemState.ITEM_LOADED + ); + } + + /** + * Checks whether an account has already been modified, and marks it as modified if not. + * @param _address Address of the account to check. + * @return Whether or not the account was already modified. + */ + function testAndSetAccountChanged( + address _address + ) + override + public + authenticated + returns ( + bool + ) + { + return _testAndSetItemState( + _getItemHash(_address), + ItemState.ITEM_CHANGED + ); + } + + /** + * Attempts to mark an account as committed. + * @param _address Address of the account to commit. + * @return Whether or not the account was committed. + */ + function commitAccount( + address _address + ) + override + public + authenticated + returns ( + bool + ) + { + bytes32 item = _getItemHash(_address); + if (itemStates[item] != ItemState.ITEM_CHANGED) { + return false; + } + + itemStates[item] = ItemState.ITEM_COMMITTED; + totalUncommittedAccounts -= 1; + + return true; + } + + /** + * Increments the total number of uncommitted accounts. + */ + function incrementTotalUncommittedAccounts() + override + public + authenticated + { + totalUncommittedAccounts += 1; + } + + /** + * Gets the total number of uncommitted accounts. + * @return Total uncommitted accounts. + */ + function getTotalUncommittedAccounts() + override + public + view + returns ( + uint256 + ) + { + return totalUncommittedAccounts; + } + + /** + * Checks whether a given account was changed during execution. + * @param _address Address to check. + * @return Whether or not the account was changed. + */ + function wasAccountChanged( + address _address + ) + override + public + view + returns ( + bool + ) + { + bytes32 item = _getItemHash(_address); + return itemStates[item] >= ItemState.ITEM_CHANGED; + } + + /** + * Checks whether a given account was committed after execution. + * @param _address Address to check. + * @return Whether or not the account was committed. + */ + function wasAccountCommitted( + address _address + ) + override + public + view + returns ( + bool + ) + { + bytes32 item = _getItemHash(_address); + return itemStates[item] >= ItemState.ITEM_COMMITTED; + } + + + /************************************ + * Public Functions: Storage Access * + ************************************/ + + /** + * Changes a contract storage slot value. + * @param _contract Address of the contract to modify. + * @param _key 32 byte storage slot key. + * @param _value 32 byte storage slot value. + */ + function putContractStorage( + address _contract, + bytes32 _key, + bytes32 _value + ) + override + public + authenticated + { + // A hilarious optimization. `SSTORE`ing a value of `bytes32(0)` is common enough that it's + // worth populating this with a non-zero value in advance (during the fraud proof + // initialization phase) to cut the execution-time cost down to 5000 gas. + contractStorage[_contract][_key] = _value ^ STORAGE_XOR_VALUE; + + // Only used when initially populating the contract storage. OVM_ExecutionManager will + // perform a `hasContractStorage` INVALID_STATE_ACCESS check before putting any contract + // storage because writing to zero when the actual value is nonzero causes a gas + // discrepancy. Could be moved into a new `putVerifiedContractStorage` function, or + // something along those lines. + if (verifiedContractStorage[_contract][_key] == false) { + verifiedContractStorage[_contract][_key] = true; + } + } + + /** + * Retrieves a contract storage slot value. + * @param _contract Address of the contract to access. + * @param _key 32 byte storage slot key. + * @return 32 byte storage slot value. + */ + function getContractStorage( + address _contract, + bytes32 _key + ) + override + public + view + returns ( + bytes32 + ) + { + // Storage XOR system doesn't work for newly created contracts that haven't set this + // storage slot value yet. + if ( + verifiedContractStorage[_contract][_key] == false + && accounts[_contract].isFresh + ) { + return bytes32(0); + } + + // See `putContractStorage` for more information about the XOR here. + return contractStorage[_contract][_key] ^ STORAGE_XOR_VALUE; + } + + /** + * Checks whether a contract storage slot exists in the state. + * @param _contract Address of the contract to access. + * @param _key 32 byte storage slot key. + * @return Whether or not the key was set in the state. + */ + function hasContractStorage( + address _contract, + bytes32 _key + ) + override + public + view + returns ( + bool + ) + { + return verifiedContractStorage[_contract][_key] || accounts[_contract].isFresh; + } + + /** + * Checks whether a storage slot has already been retrieved, and marks it as retrieved if not. + * @param _contract Address of the contract to check. + * @param _key 32 byte storage slot key. + * @return Whether or not the slot was already loaded. + */ + function testAndSetContractStorageLoaded( + address _contract, + bytes32 _key + ) + override + public + authenticated + returns ( + bool + ) + { + return _testAndSetItemState( + _getItemHash(_contract, _key), + ItemState.ITEM_LOADED + ); + } + + /** + * Checks whether a storage slot has already been modified, and marks it as modified if not. + * @param _contract Address of the contract to check. + * @param _key 32 byte storage slot key. + * @return Whether or not the slot was already modified. + */ + function testAndSetContractStorageChanged( + address _contract, + bytes32 _key + ) + override + public + authenticated + returns ( + bool + ) + { + return _testAndSetItemState( + _getItemHash(_contract, _key), + ItemState.ITEM_CHANGED + ); + } + + /** + * Attempts to mark a storage slot as committed. + * @param _contract Address of the account to commit. + * @param _key 32 byte slot key to commit. + * @return Whether or not the slot was committed. + */ + function commitContractStorage( + address _contract, + bytes32 _key + ) + override + public + authenticated + returns ( + bool + ) + { + bytes32 item = _getItemHash(_contract, _key); + if (itemStates[item] != ItemState.ITEM_CHANGED) { + return false; + } + + itemStates[item] = ItemState.ITEM_COMMITTED; + totalUncommittedContractStorage -= 1; + + return true; + } + + /** + * Increments the total number of uncommitted storage slots. + */ + function incrementTotalUncommittedContractStorage() + override + public + authenticated + { + totalUncommittedContractStorage += 1; + } + + /** + * Gets the total number of uncommitted storage slots. + * @return Total uncommitted storage slots. + */ + function getTotalUncommittedContractStorage() + override + public + view + returns ( + uint256 + ) + { + return totalUncommittedContractStorage; + } + + /** + * Checks whether a given storage slot was changed during execution. + * @param _contract Address to check. + * @param _key Key of the storage slot to check. + * @return Whether or not the storage slot was changed. + */ + function wasContractStorageChanged( + address _contract, + bytes32 _key + ) + override + public + view + returns ( + bool + ) + { + bytes32 item = _getItemHash(_contract, _key); + return itemStates[item] >= ItemState.ITEM_CHANGED; + } + + /** + * Checks whether a given storage slot was committed after execution. + * @param _contract Address to check. + * @param _key Key of the storage slot to check. + * @return Whether or not the storage slot was committed. + */ + function wasContractStorageCommitted( + address _contract, + bytes32 _key + ) + override + public + view + returns ( + bool + ) + { + bytes32 item = _getItemHash(_contract, _key); + return itemStates[item] >= ItemState.ITEM_COMMITTED; + } + + + /********************** + * Internal Functions * + **********************/ + + /** + * Generates a unique hash for an address. + * @param _address Address to generate a hash for. + * @return Unique hash for the given address. + */ + function _getItemHash( + address _address + ) + internal + pure + returns ( + bytes32 + ) + { + return keccak256(abi.encodePacked(_address)); + } + + /** + * Generates a unique hash for an address/key pair. + * @param _contract Address to generate a hash for. + * @param _key Key to generate a hash for. + * @return Unique hash for the given pair. + */ + function _getItemHash( + address _contract, + bytes32 _key + ) + internal + pure + returns ( + bytes32 + ) + { + return keccak256(abi.encodePacked( + _contract, + _key + )); + } + + /** + * Checks whether an item is in a particular state (ITEM_LOADED or ITEM_CHANGED) and sets the + * item to the provided state if not. + * @param _item 32 byte item ID to check. + * @param _minItemState Minimum state that must be satisfied by the item. + * @return Whether or not the item was already in the state. + */ + function _testAndSetItemState( + bytes32 _item, + ItemState _minItemState + ) + internal + returns ( + bool + ) + { + bool wasItemState = itemStates[_item] >= _minItemState; + + if (wasItemState == false) { + itemStates[_item] = _minItemState; + } + + return wasItemState; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_StateManagerFactory.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_StateManagerFactory.sol new file mode 100644 index 000000000000..292d3dcb66ea --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_StateManagerFactory.sol @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Interface Imports */ +import { iOVM_StateManager } from "../../iOVM/execution/iOVM_StateManager.sol"; +import { iOVM_StateManagerFactory } from "../../iOVM/execution/iOVM_StateManagerFactory.sol"; + +/* Contract Imports */ +import { OVM_StateManager } from "./OVM_StateManager.sol"; + +/** + * @title OVM_StateManagerFactory + * @dev The State Manager Factory is called by a State Transitioner's init code, to create a new + * State Manager for use in the Fraud Verification process. + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_StateManagerFactory is iOVM_StateManagerFactory { + + /******************** + * Public Functions * + ********************/ + + /** + * Creates a new OVM_StateManager + * @param _owner Owner of the created contract. + * @return New OVM_StateManager instance. + */ + function create( + address _owner + ) + override + public + returns ( + iOVM_StateManager + ) + { + return new OVM_StateManager(_owner); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/ERC1820Registry.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/ERC1820Registry.sol new file mode 100644 index 000000000000..550c9d87afe4 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/ERC1820Registry.sol @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: CC0-1.0 +/* ERC1820 Pseudo-introspection Registry Contract + * This standard defines a universal registry smart contract where any address (contract or regular account) can + * register which interface it supports and which smart contract is responsible for its implementation. + * + * Written in 2019 by Jordi Baylina and Jacques Dafflon + * + * To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to + * this software to the public domain worldwide. This software is distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see + * . + */ +pragma solidity >0.5.0 <0.8.0; + +/// @dev The interface a contract MUST implement if it is the implementer of +/// some (other) interface for any address other than itself. +interface ERC1820ImplementerInterface { + /// @notice Indicates whether the contract implements the interface 'interfaceHash' for the address 'addr' or not. + /// @param interfaceHash keccak256 hash of the name of the interface + /// @param addr Address for which the contract will implement the interface + /// @return ERC1820_ACCEPT_MAGIC only if the contract implements 'interfaceHash' for the address 'addr'. + function canImplementInterfaceForAddress(bytes32 interfaceHash, address addr) external view returns(bytes32); +} + +/** + * @title ERC1820 Pseudo-introspection Registry Contract + * @author Jordi Baylina and Jacques Dafflon + * @dev This contract is the official implementation of the ERC1820 Registry + * For more details, see https://eips.ethereum.org/EIPS/eip-1820 + * + * Compiler used: optimistic-solc + * Runtime target: OVM + */ +contract ERC1820Registry { + bytes4 constant internal INVALID_ID = 0xffffffff; + bytes4 constant internal ERC165ID = 0x01ffc9a7; + bytes32 constant internal ERC1820_ACCEPT_MAGIC = keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC")); + + mapping(address => mapping(bytes32 => address)) internal interfaces; + mapping(address => address) internal managers; + mapping(address => mapping(bytes4 => bool)) internal erc165Cached; + + /// @notice Indicates a contract is the 'implementer' of 'interfaceHash' for 'addr'. + event InterfaceImplementerSet(address indexed addr, bytes32 indexed interfaceHash, address indexed implementer); + /// @notice Indicates 'newManager' is the address of the new manager for 'addr'. + event ManagerChanged(address indexed addr, address indexed newManager); + + /// @notice Query if an address implements an interface and through which contract. + /// @param _addr Address being queried for the implementer of an interface. + /// (If '_addr' is the zero address then 'msg.sender' is assumed.) + /// @param _interfaceHash Keccak256 hash of the name of the interface as a string. + /// E.g., 'web3.utils.keccak256("ERC777TokensRecipient")' for the 'ERC777TokensRecipient' interface. + /// @return The address of the contract which implements the interface '_interfaceHash' for '_addr' + /// or '0' if '_addr' did not register an implementer for this interface. + function getInterfaceImplementer(address _addr, bytes32 _interfaceHash) external view returns (address) { + address addr = _addr == address(0) ? msg.sender : _addr; + if (isERC165Interface(_interfaceHash)) { + bytes4 erc165InterfaceHash = bytes4(_interfaceHash); + return implementsERC165Interface(addr, erc165InterfaceHash) ? addr : address(0); + } + return interfaces[addr][_interfaceHash]; + } + + /// @notice Sets the contract which implements a specific interface for an address. + /// Only the manager defined for that address can set it. + /// (Each address is the manager for itself until it sets a new manager.) + /// @param _addr Address for which to set the interface. + /// (If '_addr' is the zero address then 'msg.sender' is assumed.) + /// @param _interfaceHash Keccak256 hash of the name of the interface as a string. + /// E.g., 'web3.utils.keccak256("ERC777TokensRecipient")' for the 'ERC777TokensRecipient' interface. + /// @param _implementer Contract address implementing '_interfaceHash' for '_addr'. + function setInterfaceImplementer(address _addr, bytes32 _interfaceHash, address _implementer) external { + address addr = _addr == address(0) ? msg.sender : _addr; + require(getManager(addr) == msg.sender, "Not the manager"); + + require(!isERC165Interface(_interfaceHash), "Must not be an ERC165 hash"); + if (_implementer != address(0) && _implementer != msg.sender) { + require( + ERC1820ImplementerInterface(_implementer) + .canImplementInterfaceForAddress(_interfaceHash, addr) == ERC1820_ACCEPT_MAGIC, + "Does not implement the interface" + ); + } + interfaces[addr][_interfaceHash] = _implementer; + emit InterfaceImplementerSet(addr, _interfaceHash, _implementer); + } + + /// @notice Sets '_newManager' as manager for '_addr'. + /// The new manager will be able to call 'setInterfaceImplementer' for '_addr'. + /// @param _addr Address for which to set the new manager. + /// @param _newManager Address of the new manager for 'addr'. (Pass '0x0' to reset the manager to '_addr'.) + function setManager(address _addr, address _newManager) external { + require(getManager(_addr) == msg.sender, "Not the manager"); + managers[_addr] = _newManager == _addr ? address(0) : _newManager; + emit ManagerChanged(_addr, _newManager); + } + + /// @notice Get the manager of an address. + /// @param _addr Address for which to return the manager. + /// @return Address of the manager for a given address. + function getManager(address _addr) public view returns(address) { + // By default the manager of an address is the same address + if (managers[_addr] == address(0)) { + return _addr; + } else { + return managers[_addr]; + } + } + + /// @notice Compute the keccak256 hash of an interface given its name. + /// @param _interfaceName Name of the interface. + /// @return The keccak256 hash of an interface name. + function interfaceHash(string calldata _interfaceName) external pure returns(bytes32) { + return keccak256(abi.encodePacked(_interfaceName)); + } + + /* --- ERC165 Related Functions --- */ + /* --- Developed in collaboration with William Entriken. --- */ + + /// @notice Updates the cache with whether the contract implements an ERC165 interface or not. + /// @param _contract Address of the contract for which to update the cache. + /// @param _interfaceId ERC165 interface for which to update the cache. + function updateERC165Cache(address _contract, bytes4 _interfaceId) external { + interfaces[_contract][_interfaceId] = implementsERC165InterfaceNoCache( + _contract, _interfaceId) ? _contract : address(0); + erc165Cached[_contract][_interfaceId] = true; + } + + /// @notice Checks whether a contract implements an ERC165 interface or not. + // If the result is not cached a direct lookup on the contract address is performed. + // If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling + // 'updateERC165Cache' with the contract address. + /// @param _contract Address of the contract to check. + /// @param _interfaceId ERC165 interface to check. + /// @return True if '_contract' implements '_interfaceId', false otherwise. + function implementsERC165Interface(address _contract, bytes4 _interfaceId) public view returns (bool) { + if (!erc165Cached[_contract][_interfaceId]) { + return implementsERC165InterfaceNoCache(_contract, _interfaceId); + } + return interfaces[_contract][_interfaceId] == _contract; + } + + /// @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache. + /// @param _contract Address of the contract to check. + /// @param _interfaceId ERC165 interface to check. + /// @return True if '_contract' implements '_interfaceId', false otherwise. + function implementsERC165InterfaceNoCache(address _contract, bytes4 _interfaceId) public view returns (bool) { + uint256 success; + uint256 result; + + (success, result) = noThrowCall(_contract, ERC165ID); + if (success == 0 || result == 0) { + return false; + } + + (success, result) = noThrowCall(_contract, INVALID_ID); + if (success == 0 || result != 0) { + return false; + } + + (success, result) = noThrowCall(_contract, _interfaceId); + if (success == 1 && result == 1) { + return true; + } + return false; + } + + /// @notice Checks whether the hash is a ERC165 interface (ending with 28 zeroes) or not. + /// @param _interfaceHash The hash to check. + /// @return True if '_interfaceHash' is an ERC165 interface (ending with 28 zeroes), false otherwise. + function isERC165Interface(bytes32 _interfaceHash) internal pure returns (bool) { + return _interfaceHash & 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF == 0; + } + + /// @dev Make a call on a contract without throwing if the function does not exist. + function noThrowCall(address _contract, bytes4 _interfaceId) + internal view returns (uint256 success, uint256 result) + { + bytes4 erc165ID = ERC165ID; + + assembly { + let x := mload(0x40) // Find empty storage location using "free memory pointer" + mstore(x, erc165ID) // Place signature at beginning of empty storage + mstore(add(x, 0x04), _interfaceId) // Place first argument directly next to signature + + success := staticcall( + 30000, // 30k gas + _contract, // To addr + x, // Inputs are stored at location x + 0x24, // Inputs are 36 (4 + 32) bytes long + x, // Store output over input (saves space) + 0x20 // Outputs are 32 bytes long + ) + + result := mload(x) // Load the result + } + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_DeployerWhitelist.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_DeployerWhitelist.sol new file mode 100644 index 000000000000..8b5189cfdaf2 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_DeployerWhitelist.sol @@ -0,0 +1,212 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_Bytes32Utils } from "../../libraries/utils/Lib_Bytes32Utils.sol"; + +/* Interface Imports */ +import { iOVM_DeployerWhitelist } from "../../iOVM/predeploys/iOVM_DeployerWhitelist.sol"; +import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol"; + +/** + * @title OVM_DeployerWhitelist + * @dev The Deployer Whitelist is a temporary predeploy used to provide additional safety during the + * initial phases of our mainnet roll out. It is owned by the Optimism team, and defines accounts + * which are allowed to deploy contracts on Layer2. The Execution Manager will only allow an + * ovmCREATE or ovmCREATE2 operation to proceed if the deployer's address whitelisted. + * + * Compiler used: solc + * Runtime target: OVM + */ +contract OVM_DeployerWhitelist is iOVM_DeployerWhitelist { + + /********************** + * Contract Constants * + **********************/ + + bytes32 internal constant KEY_INITIALIZED = 0x0000000000000000000000000000000000000000000000000000000000000010; + bytes32 internal constant KEY_OWNER = 0x0000000000000000000000000000000000000000000000000000000000000011; + bytes32 internal constant KEY_ALLOW_ARBITRARY_DEPLOYMENT = 0x0000000000000000000000000000000000000000000000000000000000000012; + + + /********************** + * Function Modifiers * + **********************/ + + /** + * Blocks functions to anyone except the contract owner. + */ + modifier onlyOwner() { + address owner = Lib_Bytes32Utils.toAddress( + Lib_SafeExecutionManagerWrapper.safeSLOAD( + KEY_OWNER + ) + ); + + Lib_SafeExecutionManagerWrapper.safeREQUIRE( + Lib_SafeExecutionManagerWrapper.safeCALLER() == owner, + "Function can only be called by the owner of this contract." + ); + _; + } + + + /******************** + * Public Functions * + ********************/ + + /** + * Initializes the whitelist. + * @param _owner Address of the owner for this contract. + * @param _allowArbitraryDeployment Whether or not to allow arbitrary contract deployment. + */ + function initialize( + address _owner, + bool _allowArbitraryDeployment + ) + override + public + { + bool initialized = Lib_Bytes32Utils.toBool( + Lib_SafeExecutionManagerWrapper.safeSLOAD(KEY_INITIALIZED) + ); + + if (initialized == true) { + return; + } + + Lib_SafeExecutionManagerWrapper.safeSSTORE( + KEY_INITIALIZED, + Lib_Bytes32Utils.fromBool(true) + ); + Lib_SafeExecutionManagerWrapper.safeSSTORE( + KEY_OWNER, + Lib_Bytes32Utils.fromAddress(_owner) + ); + Lib_SafeExecutionManagerWrapper.safeSSTORE( + KEY_ALLOW_ARBITRARY_DEPLOYMENT, + Lib_Bytes32Utils.fromBool(_allowArbitraryDeployment) + ); + } + + /** + * Gets the owner of the whitelist. + */ + function getOwner() + override + public + returns( + address + ) + { + return Lib_Bytes32Utils.toAddress( + Lib_SafeExecutionManagerWrapper.safeSLOAD( + KEY_OWNER + ) + ); + } + + /** + * Adds or removes an address from the deployment whitelist. + * @param _deployer Address to update permissions for. + * @param _isWhitelisted Whether or not the address is whitelisted. + */ + function setWhitelistedDeployer( + address _deployer, + bool _isWhitelisted + ) + override + public + onlyOwner + { + Lib_SafeExecutionManagerWrapper.safeSSTORE( + Lib_Bytes32Utils.fromAddress(_deployer), + Lib_Bytes32Utils.fromBool(_isWhitelisted) + ); + } + + /** + * Updates the owner of this contract. + * @param _owner Address of the new owner. + */ + function setOwner( + address _owner + ) + override + public + onlyOwner + { + Lib_SafeExecutionManagerWrapper.safeSSTORE( + KEY_OWNER, + Lib_Bytes32Utils.fromAddress(_owner) + ); + } + + /** + * Updates the arbitrary deployment flag. + * @param _allowArbitraryDeployment Whether or not to allow arbitrary contract deployment. + */ + function setAllowArbitraryDeployment( + bool _allowArbitraryDeployment + ) + override + public + onlyOwner + { + Lib_SafeExecutionManagerWrapper.safeSSTORE( + KEY_ALLOW_ARBITRARY_DEPLOYMENT, + Lib_Bytes32Utils.fromBool(_allowArbitraryDeployment) + ); + } + + /** + * Permanently enables arbitrary contract deployment and deletes the owner. + */ + function enableArbitraryContractDeployment() + override + public + onlyOwner + { + setAllowArbitraryDeployment(true); + setOwner(address(0)); + } + + /** + * Checks whether an address is allowed to deploy contracts. + * @param _deployer Address to check. + * @return _allowed Whether or not the address can deploy contracts. + */ + function isDeployerAllowed( + address _deployer + ) + override + public + returns ( + bool _allowed + ) + { + bool initialized = Lib_Bytes32Utils.toBool( + Lib_SafeExecutionManagerWrapper.safeSLOAD(KEY_INITIALIZED) + ); + + if (initialized == false) { + return true; + } + + bool allowArbitraryDeployment = Lib_Bytes32Utils.toBool( + Lib_SafeExecutionManagerWrapper.safeSLOAD(KEY_ALLOW_ARBITRARY_DEPLOYMENT) + ); + + if (allowArbitraryDeployment == true) { + return true; + } + + bool isWhitelisted = Lib_Bytes32Utils.toBool( + Lib_SafeExecutionManagerWrapper.safeSLOAD( + Lib_Bytes32Utils.fromAddress(_deployer) + ) + ); + + return isWhitelisted; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_ETH.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_ETH.sol new file mode 100644 index 000000000000..dcfb04b453f0 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_ETH.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; + +/* Interface Imports */ +import { iOVM_L1TokenGateway } from "../../iOVM/bridge/tokens/iOVM_L1TokenGateway.sol"; + +/* Contract Imports */ +import { OVM_L2DepositedERC20 } from "../bridge/tokens/OVM_L2DepositedERC20.sol"; + +/** + * @title OVM_ETH + * @dev The ETH predeploy provides an ERC20 interface for ETH deposited to Layer 2. Note that + * unlike on Layer 1, Layer 2 accounts do not have a balance field. + * + * Compiler used: optimistic-solc + * Runtime target: OVM + */ +contract OVM_ETH is OVM_L2DepositedERC20 { + constructor( + address _l2CrossDomainMessenger, + address _l1ETHGateway + ) + OVM_L2DepositedERC20( + _l2CrossDomainMessenger, + "Ether", + "ETH" + ) + { + init(iOVM_L1TokenGateway(_l1ETHGateway)); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_L1MessageSender.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_L1MessageSender.sol new file mode 100644 index 000000000000..e6c749b87014 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_L1MessageSender.sol @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Interface Imports */ +import { iOVM_L1MessageSender } from "../../iOVM/predeploys/iOVM_L1MessageSender.sol"; +import { iOVM_ExecutionManager } from "../../iOVM/execution/iOVM_ExecutionManager.sol"; + +/** + * @title OVM_L1MessageSender + * @dev The L1MessageSender is a predeploy contract running on L2. During the execution of cross + * domain transaction from L1 to L2, it returns the address of the L1 account (either an EOA or + * contract) which sent the message to L2 via the Canonical Transaction Chain's `enqueue()` + * function. + * + * This contract exclusively serves as a getter for the ovmL1TXORIGIN operation. This is necessary + * because there is no corresponding operation in the EVM which the the optimistic solidity compiler + * can be replaced with a call to the ExecutionManager's ovmL1TXORIGIN() function. + * + * + * Compiler used: solc + * Runtime target: OVM + */ +contract OVM_L1MessageSender is iOVM_L1MessageSender { + + /******************** + * Public Functions * + ********************/ + + /** + * @return _l1MessageSender L1 message sender address (msg.sender). + */ + function getL1MessageSender() + override + public + view + returns ( + address _l1MessageSender + ) + { + // Note that on L2 msg.sender (ie. evmCALLER) will always be the Execution Manager + return iOVM_ExecutionManager(msg.sender).ovmL1TXORIGIN(); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_L2ToL1MessagePasser.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_L2ToL1MessagePasser.sol new file mode 100644 index 000000000000..479cd2151568 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_L2ToL1MessagePasser.sol @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Interface Imports */ +import { iOVM_L2ToL1MessagePasser } from "../../iOVM/predeploys/iOVM_L2ToL1MessagePasser.sol"; + +/** + * @title OVM_L2ToL1MessagePasser + * @dev The L2 to L1 Message Passer is a utility contract which facilitate an L1 proof of the + * of a message on L2. The L1 Cross Domain Messenger performs this proof in its + * _verifyStorageProof function, which verifies the existence of the transaction hash in this + * contract's `sentMessages` mapping. + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_L2ToL1MessagePasser is iOVM_L2ToL1MessagePasser { + + /********************** + * Contract Variables * + **********************/ + + mapping (bytes32 => bool) public sentMessages; + + + /******************** + * Public Functions * + ********************/ + + /** + * Passes a message to L1. + * @param _message Message to pass to L1. + */ + function passMessageToL1( + bytes memory _message + ) + override + public + { + // Note: although this function is public, only messages sent from the OVM_L2CrossDomainMessenger + // will be relayed by the OVM_L1CrossDomainMessenger. This is enforced by a check in + // OVM_L1CrossDomainMessenger._verifyStorageProof(). + sentMessages[keccak256( + abi.encodePacked( + _message, + msg.sender + ) + )] = true; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_ProxySequencerEntrypoint.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_ProxySequencerEntrypoint.sol new file mode 100644 index 000000000000..8ef0ca5df797 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_ProxySequencerEntrypoint.sol @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol"; + +/** + * @title OVM_ProxySequencerEntrypoint + * @dev The Proxy Sequencer Entrypoint is a predeployed proxy to the implementation of the + * Sequencer Entrypoint. This will enable the Optimism team to upgrade the Sequencer Entrypoint + * contract. + * + * Compiler used: solc + * Runtime target: OVM + */ +contract OVM_ProxySequencerEntrypoint { + + /********************* + * Fallback Function * + *********************/ + + fallback() + external + { + Lib_SafeExecutionManagerWrapper.safeDELEGATECALL( + gasleft(), + _getImplementation(), + msg.data + ); + } + + + /******************** + * Public Functions * + ********************/ + + function init( + address _implementation, + address _owner + ) + external + { + Lib_SafeExecutionManagerWrapper.safeREQUIRE( + _getOwner() == address(0), + "ProxySequencerEntrypoint has already been inited" + ); + _setOwner(_owner); + _setImplementation(_implementation); + } + + function upgrade( + address _implementation + ) + external + { + Lib_SafeExecutionManagerWrapper.safeREQUIRE( + _getOwner() == Lib_SafeExecutionManagerWrapper.safeCALLER(), + "Only owner can upgrade the Entrypoint" + ); + + _setImplementation(_implementation); + } + + + /********************** + * Internal Functions * + **********************/ + + function _setImplementation( + address _implementation + ) + internal + { + Lib_SafeExecutionManagerWrapper.safeSSTORE( + bytes32(uint256(0)), + bytes32(uint256(uint160(_implementation))) + ); + } + + function _getImplementation() + internal + returns ( + address _implementation + ) + { + return address(uint160(uint256( + Lib_SafeExecutionManagerWrapper.safeSLOAD( + bytes32(uint256(0)) + ) + ))); + } + + function _setOwner( + address _owner + ) + internal + { + Lib_SafeExecutionManagerWrapper.safeSSTORE( + bytes32(uint256(1)), + bytes32(uint256(uint160(_owner))) + ); + } + + function _getOwner() + internal + returns ( + address _owner + ) + { + return address(uint160(uint256( + Lib_SafeExecutionManagerWrapper.safeSLOAD( + bytes32(uint256(1)) + ) + ))); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerEntrypoint.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerEntrypoint.sol new file mode 100644 index 000000000000..bba7dd59c90f --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerEntrypoint.sol @@ -0,0 +1,127 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_BytesUtils } from "../../libraries/utils/Lib_BytesUtils.sol"; +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; +import { Lib_ECDSAUtils } from "../../libraries/utils/Lib_ECDSAUtils.sol"; +import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol"; + +/** + * @title OVM_SequencerEntrypoint + * @dev The Sequencer Entrypoint is a predeploy which, despite its name, can in fact be called by + * any account. It accepts a more efficient compressed calldata format, which it decompresses and + * encodes to the standard EIP155 transaction format. + * This contract is the implementation referenced by the Proxy Sequencer Entrypoint, thus enabling + * the Optimism team to upgrade the decompression of calldata from the Sequencer. + * + * Compiler used: solc + * Runtime target: OVM + */ +contract OVM_SequencerEntrypoint { + + /********* + * Enums * + *********/ + + enum TransactionType { + NATIVE_ETH_TRANSACTION, + ETH_SIGNED_MESSAGE + } + + + /********************* + * Fallback Function * + *********************/ + + /** + * Uses a custom "compressed" format to save on calldata gas: + * calldata[00:01]: transaction type (0 == EIP 155, 2 == Eth Sign Message) + * calldata[01:33]: signature "r" parameter + * calldata[33:65]: signature "s" parameter + * calldata[65:66]: signature "v" parameter + * calldata[66:69]: transaction gas limit + * calldata[69:72]: transaction gas price + * calldata[72:75]: transaction nonce + * calldata[75:95]: transaction target address + * calldata[95:XX]: transaction data + */ + fallback() + external + { + TransactionType transactionType = _getTransactionType(Lib_BytesUtils.toUint8(msg.data, 0)); + + bytes32 r = Lib_BytesUtils.toBytes32(Lib_BytesUtils.slice(msg.data, 1, 32)); + bytes32 s = Lib_BytesUtils.toBytes32(Lib_BytesUtils.slice(msg.data, 33, 32)); + uint8 v = Lib_BytesUtils.toUint8(msg.data, 65); + + // Remainder is the transaction to execute. + bytes memory compressedTx = Lib_BytesUtils.slice(msg.data, 66); + bool isEthSignedMessage = transactionType == TransactionType.ETH_SIGNED_MESSAGE; + + // Need to decompress and then re-encode the transaction based on the original encoding. + bytes memory encodedTx = Lib_OVMCodec.encodeEIP155Transaction( + Lib_OVMCodec.decompressEIP155Transaction(compressedTx), + isEthSignedMessage + ); + + address target = Lib_ECDSAUtils.recover( + encodedTx, + isEthSignedMessage, + uint8(v), + r, + s + ); + + if (Lib_SafeExecutionManagerWrapper.safeEXTCODESIZE(target) == 0) { + // ProxyEOA has not yet been deployed for this EOA. + bytes32 messageHash = Lib_ECDSAUtils.getMessageHash(encodedTx, isEthSignedMessage); + Lib_SafeExecutionManagerWrapper.safeCREATEEOA(messageHash, uint8(v), r, s); + } + + // ProxyEOA has been deployed for this EOA, continue to CALL. + bytes memory callbytes = abi.encodeWithSignature( + "execute(bytes,uint8,uint8,bytes32,bytes32)", + encodedTx, + isEthSignedMessage, + uint8(v), + r, + s + ); + + Lib_SafeExecutionManagerWrapper.safeCALL( + gasleft(), + target, + callbytes + ); + } + + + /********************** + * Internal Functions * + **********************/ + + /** + * Converts a uint256 into a TransactionType enum. + * @param _transactionType Transaction type index. + * @return _txType Transaction type enum value. + */ + function _getTransactionType( + uint8 _transactionType + ) + internal + returns ( + TransactionType _txType + ) + { + if (_transactionType == 0) { + return TransactionType.NATIVE_ETH_TRANSACTION; + } if (_transactionType == 2) { + return TransactionType.ETH_SIGNED_MESSAGE; + } else { + Lib_SafeExecutionManagerWrapper.safeREVERT( + "Transaction type must be 0 or 2" + ); + } + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/verification/Abs_FraudContributor.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/verification/Abs_FraudContributor.sol new file mode 100644 index 000000000000..39b82e67dbea --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/verification/Abs_FraudContributor.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +import { iOVM_BondManager } from "../../iOVM/verification/iOVM_BondManager.sol"; +import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; + +/// Minimal contract to be inherited by contracts consumed by users that provide +/// data for fraud proofs +abstract contract Abs_FraudContributor is Lib_AddressResolver { + /// Decorate your functions with this modifier to store how much total gas was + /// consumed by the sender, to reward users fairly + modifier contributesToFraudProof(bytes32 preStateRoot, bytes32 txHash) { + uint256 startGas = gasleft(); + _; + uint256 gasSpent = startGas - gasleft(); + iOVM_BondManager(resolve('OVM_BondManager')).recordGasSpent(preStateRoot, txHash, msg.sender, gasSpent); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_BondManager.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_BondManager.sol new file mode 100644 index 000000000000..4b0f5df0010a --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_BondManager.sol @@ -0,0 +1,208 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; + +/* Interface Imports */ +import { iOVM_BondManager, Errors, ERC20 } from "../../iOVM/verification/iOVM_BondManager.sol"; +import { iOVM_FraudVerifier } from "../../iOVM/verification/iOVM_FraudVerifier.sol"; + +/** + * @title OVM_BondManager + * @dev The Bond Manager contract handles deposits in the form of an ERC20 token from bonded + * Proposers. It also handles the accounting of gas costs spent by a Verifier during the course of a + * fraud proof. In the event of a successful fraud proof, the fraudulent Proposer's bond is slashed, + * and the Verifier's gas costs are refunded. + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_BondManager is iOVM_BondManager, Lib_AddressResolver { + + /**************************** + * Constants and Parameters * + ****************************/ + + /// The period to find the earliest fraud proof for a publisher + uint256 public constant multiFraudProofPeriod = 7 days; + + /// The dispute period + uint256 public constant disputePeriodSeconds = 7 days; + + /// The minimum collateral a sequencer must post + uint256 public constant requiredCollateral = 1 ether; + + + /******************************************* + * Contract Variables: Contract References * + *******************************************/ + + /// The bond token + ERC20 immutable public token; + + + /******************************************** + * Contract Variables: Internal Accounting * + *******************************************/ + + /// The bonds posted by each proposer + mapping(address => Bond) public bonds; + + /// For each pre-state root, there's an array of witnessProviders that must be rewarded + /// for posting witnesses + mapping(bytes32 => Rewards) public witnessProviders; + + + /*************** + * Constructor * + ***************/ + + /// Initializes with a ERC20 token to be used for the fidelity bonds + /// and with the Address Manager + constructor( + ERC20 _token, + address _libAddressManager + ) + Lib_AddressResolver(_libAddressManager) + { + token = _token; + } + + + /******************** + * Public Functions * + ********************/ + + /// Adds `who` to the list of witnessProviders for the provided `preStateRoot`. + function recordGasSpent(bytes32 _preStateRoot, bytes32 _txHash, address who, uint256 gasSpent) override public { + // The sender must be the transitioner that corresponds to the claimed pre-state root + address transitioner = address(iOVM_FraudVerifier(resolve("OVM_FraudVerifier")).getStateTransitioner(_preStateRoot, _txHash)); + require(transitioner == msg.sender, Errors.ONLY_TRANSITIONER); + + witnessProviders[_preStateRoot].total += gasSpent; + witnessProviders[_preStateRoot].gasSpent[who] += gasSpent; + } + + /// Slashes + distributes rewards or frees up the sequencer's bond, only called by + /// `FraudVerifier.finalizeFraudVerification` + function finalize(bytes32 _preStateRoot, address publisher, uint256 timestamp) override public { + require(msg.sender == resolve("OVM_FraudVerifier"), Errors.ONLY_FRAUD_VERIFIER); + require(witnessProviders[_preStateRoot].canClaim == false, Errors.ALREADY_FINALIZED); + + // allow users to claim from that state root's + // pool of collateral (effectively slashing the sequencer) + witnessProviders[_preStateRoot].canClaim = true; + + Bond storage bond = bonds[publisher]; + if (bond.firstDisputeAt == 0) { + bond.firstDisputeAt = block.timestamp; + bond.earliestDisputedStateRoot = _preStateRoot; + bond.earliestTimestamp = timestamp; + } else if ( + // only update the disputed state root for the publisher if it's within + // the dispute period _and_ if it's before the previous one + block.timestamp < bond.firstDisputeAt + multiFraudProofPeriod && + timestamp < bond.earliestTimestamp + ) { + bond.earliestDisputedStateRoot = _preStateRoot; + bond.earliestTimestamp = timestamp; + } + + // if the fraud proof's dispute period does not intersect with the + // withdrawal's timestamp, then the user should not be slashed + // e.g if a user at day 10 submits a withdrawal, and a fraud proof + // from day 1 gets published, the user won't be slashed since day 8 (1d + 7d) + // is before the user started their withdrawal. on the contrary, if the user + // had started their withdrawal at, say, day 6, they would be slashed + if ( + bond.withdrawalTimestamp != 0 && + uint256(bond.withdrawalTimestamp) > timestamp + disputePeriodSeconds && + bond.state == State.WITHDRAWING + ) { + return; + } + + // slash! + bond.state = State.NOT_COLLATERALIZED; + } + + /// Sequencers call this function to post collateral which will be used for + /// the `appendBatch` call + function deposit() override public { + require( + token.transferFrom(msg.sender, address(this), requiredCollateral), + Errors.ERC20_ERR + ); + + // This cannot overflow + bonds[msg.sender].state = State.COLLATERALIZED; + } + + /// Starts the withdrawal for a publisher + function startWithdrawal() override public { + Bond storage bond = bonds[msg.sender]; + require(bond.withdrawalTimestamp == 0, Errors.WITHDRAWAL_PENDING); + require(bond.state == State.COLLATERALIZED, Errors.WRONG_STATE); + + bond.state = State.WITHDRAWING; + bond.withdrawalTimestamp = uint32(block.timestamp); + } + + /// Finalizes a pending withdrawal from a publisher + function finalizeWithdrawal() override public { + Bond storage bond = bonds[msg.sender]; + + require( + block.timestamp >= uint256(bond.withdrawalTimestamp) + disputePeriodSeconds, + Errors.TOO_EARLY + ); + require(bond.state == State.WITHDRAWING, Errors.SLASHED); + + // refunds! + bond.state = State.NOT_COLLATERALIZED; + bond.withdrawalTimestamp = 0; + + require( + token.transfer(msg.sender, requiredCollateral), + Errors.ERC20_ERR + ); + } + + /// Claims the user's reward for the witnesses they provided for the earliest + /// disputed state root of the designated publisher + function claim(address who) override public { + Bond storage bond = bonds[who]; + require( + block.timestamp >= bond.firstDisputeAt + multiFraudProofPeriod, + Errors.WAIT_FOR_DISPUTES + ); + + // reward the earliest state root for this publisher + bytes32 _preStateRoot = bond.earliestDisputedStateRoot; + Rewards storage rewards = witnessProviders[_preStateRoot]; + + // only allow claiming if fraud was proven in `finalize` + require(rewards.canClaim, Errors.CANNOT_CLAIM); + + // proportional allocation - only reward 50% (rest gets locked in the + // contract forever + uint256 amount = (requiredCollateral * rewards.gasSpent[msg.sender]) / (2 * rewards.total); + + // reset the user's spent gas so they cannot double claim + rewards.gasSpent[msg.sender] = 0; + + // transfer + require(token.transfer(msg.sender, amount), Errors.ERC20_ERR); + } + + /// Checks if the user is collateralized + function isCollateralized(address who) override public view returns (bool) { + return bonds[who].state == State.COLLATERALIZED; + } + + /// Gets how many witnesses the user has provided for the state root + function getGasSpent(bytes32 preStateRoot, address who) override public view returns (uint256) { + return witnessProviders[preStateRoot].gasSpent[who]; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_FraudVerifier.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_FraudVerifier.sol new file mode 100644 index 000000000000..e0db75f15466 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_FraudVerifier.sol @@ -0,0 +1,296 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; +import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; + +/* Interface Imports */ +import { iOVM_FraudVerifier } from "../../iOVM/verification/iOVM_FraudVerifier.sol"; +import { iOVM_StateTransitioner } from "../../iOVM/verification/iOVM_StateTransitioner.sol"; +import { iOVM_StateTransitionerFactory } from "../../iOVM/verification/iOVM_StateTransitionerFactory.sol"; +import { iOVM_BondManager } from "../../iOVM/verification/iOVM_BondManager.sol"; +import { iOVM_StateCommitmentChain } from "../../iOVM/chain/iOVM_StateCommitmentChain.sol"; +import { iOVM_CanonicalTransactionChain } from "../../iOVM/chain/iOVM_CanonicalTransactionChain.sol"; + +/* Contract Imports */ +import { Abs_FraudContributor } from "./Abs_FraudContributor.sol"; + + + +/** + * @title OVM_FraudVerifier + * @dev The Fraud Verifier contract coordinates the entire fraud proof verification process. + * If the fraud proof was successful it prunes any state batches from State Commitment Chain + * which were published after the fraudulent state root. + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_FraudVerifier is Lib_AddressResolver, Abs_FraudContributor, iOVM_FraudVerifier { + + /******************************************* + * Contract Variables: Internal Accounting * + *******************************************/ + + mapping (bytes32 => iOVM_StateTransitioner) internal transitioners; + + + /*************** + * Constructor * + ***************/ + + /** + * @param _libAddressManager Address of the Address Manager. + */ + constructor( + address _libAddressManager + ) + Lib_AddressResolver(_libAddressManager) + {} + + + /*************************************** + * Public Functions: Transition Status * + ***************************************/ + + /** + * Retrieves the state transitioner for a given root. + * @param _preStateRoot State root to query a transitioner for. + * @return _transitioner Corresponding state transitioner contract. + */ + function getStateTransitioner( + bytes32 _preStateRoot, + bytes32 _txHash + ) + override + public + view + returns ( + iOVM_StateTransitioner _transitioner + ) + { + return transitioners[keccak256(abi.encodePacked(_preStateRoot, _txHash))]; + } + + + /**************************************** + * Public Functions: Fraud Verification * + ****************************************/ + + /** + * Begins the fraud verification process. + * @param _preStateRoot State root before the fraudulent transaction. + * @param _preStateRootBatchHeader Batch header for the provided pre-state root. + * @param _preStateRootProof Inclusion proof for the provided pre-state root. + * @param _transaction OVM transaction claimed to be fraudulent. + * @param _txChainElement OVM transaction chain element. + * @param _transactionBatchHeader Batch header for the provided transaction. + * @param _transactionProof Inclusion proof for the provided transaction. + */ + function initializeFraudVerification( + bytes32 _preStateRoot, + Lib_OVMCodec.ChainBatchHeader memory _preStateRootBatchHeader, + Lib_OVMCodec.ChainInclusionProof memory _preStateRootProof, + Lib_OVMCodec.Transaction memory _transaction, + Lib_OVMCodec.TransactionChainElement memory _txChainElement, + Lib_OVMCodec.ChainBatchHeader memory _transactionBatchHeader, + Lib_OVMCodec.ChainInclusionProof memory _transactionProof + ) + override + public + contributesToFraudProof(_preStateRoot, Lib_OVMCodec.hashTransaction(_transaction)) + { + bytes32 _txHash = Lib_OVMCodec.hashTransaction(_transaction); + + if (_hasStateTransitioner(_preStateRoot, _txHash)) { + return; + } + + iOVM_StateCommitmentChain ovmStateCommitmentChain = iOVM_StateCommitmentChain(resolve("OVM_StateCommitmentChain")); + iOVM_CanonicalTransactionChain ovmCanonicalTransactionChain = iOVM_CanonicalTransactionChain(resolve("OVM_CanonicalTransactionChain")); + + require( + ovmStateCommitmentChain.verifyStateCommitment( + _preStateRoot, + _preStateRootBatchHeader, + _preStateRootProof + ), + "Invalid pre-state root inclusion proof." + ); + + require( + ovmCanonicalTransactionChain.verifyTransaction( + _transaction, + _txChainElement, + _transactionBatchHeader, + _transactionProof + ), + "Invalid transaction inclusion proof." + ); + + require ( + _preStateRootBatchHeader.prevTotalElements + _preStateRootProof.index + 1 == _transactionBatchHeader.prevTotalElements + _transactionProof.index, + "Pre-state root global index must equal to the transaction root global index." + ); + + _deployTransitioner(_preStateRoot, _txHash, _preStateRootProof.index); + + emit FraudProofInitialized( + _preStateRoot, + _preStateRootProof.index, + _txHash, + msg.sender + ); + } + + /** + * Finalizes the fraud verification process. + * @param _preStateRoot State root before the fraudulent transaction. + * @param _preStateRootBatchHeader Batch header for the provided pre-state root. + * @param _preStateRootProof Inclusion proof for the provided pre-state root. + * @param _txHash The transaction for the state root + * @param _postStateRoot State root after the fraudulent transaction. + * @param _postStateRootBatchHeader Batch header for the provided post-state root. + * @param _postStateRootProof Inclusion proof for the provided post-state root. + */ + function finalizeFraudVerification( + bytes32 _preStateRoot, + Lib_OVMCodec.ChainBatchHeader memory _preStateRootBatchHeader, + Lib_OVMCodec.ChainInclusionProof memory _preStateRootProof, + bytes32 _txHash, + bytes32 _postStateRoot, + Lib_OVMCodec.ChainBatchHeader memory _postStateRootBatchHeader, + Lib_OVMCodec.ChainInclusionProof memory _postStateRootProof + ) + override + public + contributesToFraudProof(_preStateRoot, _txHash) + { + iOVM_StateTransitioner transitioner = getStateTransitioner(_preStateRoot, _txHash); + iOVM_StateCommitmentChain ovmStateCommitmentChain = iOVM_StateCommitmentChain(resolve("OVM_StateCommitmentChain")); + + require( + transitioner.isComplete() == true, + "State transition process must be completed prior to finalization." + ); + + require ( + _postStateRootBatchHeader.prevTotalElements + _postStateRootProof.index == _preStateRootBatchHeader.prevTotalElements + _preStateRootProof.index + 1, + "Post-state root global index must equal to the pre state root global index plus one." + ); + + require( + ovmStateCommitmentChain.verifyStateCommitment( + _preStateRoot, + _preStateRootBatchHeader, + _preStateRootProof + ), + "Invalid pre-state root inclusion proof." + ); + + require( + ovmStateCommitmentChain.verifyStateCommitment( + _postStateRoot, + _postStateRootBatchHeader, + _postStateRootProof + ), + "Invalid post-state root inclusion proof." + ); + + // If the post state root did not match, then there was fraud and we should delete the batch + require( + _postStateRoot != transitioner.getPostStateRoot(), + "State transition has not been proven fraudulent." + ); + + _cancelStateTransition(_postStateRootBatchHeader, _preStateRoot); + + // TEMPORARY: Remove the transitioner; for minnet. + transitioners[keccak256(abi.encodePacked(_preStateRoot, _txHash))] = iOVM_StateTransitioner(0x0000000000000000000000000000000000000000); + + emit FraudProofFinalized( + _preStateRoot, + _preStateRootProof.index, + _txHash, + msg.sender + ); + } + + + /************************************ + * Internal Functions: Verification * + ************************************/ + + /** + * Checks whether a transitioner already exists for a given pre-state root. + * @param _preStateRoot Pre-state root to check. + * @return _exists Whether or not we already have a transitioner for the root. + */ + function _hasStateTransitioner( + bytes32 _preStateRoot, + bytes32 _txHash + ) + internal + view + returns ( + bool _exists + ) + { + return address(getStateTransitioner(_preStateRoot, _txHash)) != address(0); + } + + /** + * Deploys a new state transitioner. + * @param _preStateRoot Pre-state root to initialize the transitioner with. + * @param _txHash Hash of the transaction this transitioner will execute. + * @param _stateTransitionIndex Index of the transaction in the chain. + */ + function _deployTransitioner( + bytes32 _preStateRoot, + bytes32 _txHash, + uint256 _stateTransitionIndex + ) + internal + { + transitioners[keccak256(abi.encodePacked(_preStateRoot, _txHash))] = iOVM_StateTransitionerFactory( + resolve("OVM_StateTransitionerFactory") + ).create( + address(libAddressManager), + _stateTransitionIndex, + _preStateRoot, + _txHash + ); + } + + /** + * Removes a state transition from the state commitment chain. + * @param _postStateRootBatchHeader Header for the post-state root. + * @param _preStateRoot Pre-state root hash. + */ + function _cancelStateTransition( + Lib_OVMCodec.ChainBatchHeader memory _postStateRootBatchHeader, + bytes32 _preStateRoot + ) + internal + { + iOVM_StateCommitmentChain ovmStateCommitmentChain = iOVM_StateCommitmentChain(resolve("OVM_StateCommitmentChain")); + iOVM_BondManager ovmBondManager = iOVM_BondManager(resolve("OVM_BondManager")); + + // Delete the state batch. + ovmStateCommitmentChain.deleteStateBatch( + _postStateRootBatchHeader + ); + + // Get the timestamp and publisher for that block. + (uint256 timestamp, address publisher) = abi.decode(_postStateRootBatchHeader.extraData, (uint256, address)); + + // Slash the bonds at the bond manager. + ovmBondManager.finalize( + _preStateRoot, + publisher, + timestamp + ); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_StateTransitioner.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_StateTransitioner.sol new file mode 100644 index 000000000000..8e00d8a1112d --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_StateTransitioner.sol @@ -0,0 +1,473 @@ +// SPDX-License-Identifier: MIT +// @unsupported: ovm +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; +import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; +import { Lib_EthUtils } from "../../libraries/utils/Lib_EthUtils.sol"; +import { Lib_Bytes32Utils } from "../../libraries/utils/Lib_Bytes32Utils.sol"; +import { Lib_BytesUtils } from "../../libraries/utils/Lib_BytesUtils.sol"; +import { Lib_SecureMerkleTrie } from "../../libraries/trie/Lib_SecureMerkleTrie.sol"; +import { Lib_RLPWriter } from "../../libraries/rlp/Lib_RLPWriter.sol"; +import { Lib_RLPReader } from "../../libraries/rlp/Lib_RLPReader.sol"; + +/* Interface Imports */ +import { iOVM_StateTransitioner } from "../../iOVM/verification/iOVM_StateTransitioner.sol"; +import { iOVM_BondManager } from "../../iOVM/verification/iOVM_BondManager.sol"; +import { iOVM_ExecutionManager } from "../../iOVM/execution/iOVM_ExecutionManager.sol"; +import { iOVM_StateManager } from "../../iOVM/execution/iOVM_StateManager.sol"; +import { iOVM_StateManagerFactory } from "../../iOVM/execution/iOVM_StateManagerFactory.sol"; + +/* Contract Imports */ +import { Abs_FraudContributor } from "./Abs_FraudContributor.sol"; + +/** + * @title OVM_StateTransitioner + * @dev The State Transitioner coordinates the execution of a state transition during the evaluation of a + * fraud proof. It feeds verified input to the Execution Manager's run(), and controls a State Manager (which is + * uniquely created for each fraud proof). + * Once a fraud proof has been initialized, this contract is provided with the pre-state root and verifies + * that the OVM storage slots committed to the State Mangager are contained in that state + * This contract controls the State Manager and Execution Manager, and uses them to calculate the + * post-state root by applying the transaction. The Fraud Verifier can then check for fraud by comparing + * the calculated post-state root with the proposed post-state root. + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_StateTransitioner is Lib_AddressResolver, Abs_FraudContributor, iOVM_StateTransitioner { + + /******************* + * Data Structures * + *******************/ + + enum TransitionPhase { + PRE_EXECUTION, + POST_EXECUTION, + COMPLETE + } + + + /******************************************* + * Contract Variables: Contract References * + *******************************************/ + + iOVM_StateManager public ovmStateManager; + + + /******************************************* + * Contract Variables: Internal Accounting * + *******************************************/ + + bytes32 internal preStateRoot; + bytes32 internal postStateRoot; + TransitionPhase public phase; + uint256 internal stateTransitionIndex; + bytes32 internal transactionHash; + + + /************* + * Constants * + *************/ + + bytes32 internal constant EMPTY_ACCOUNT_CODE_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; + bytes32 internal constant EMPTY_ACCOUNT_STORAGE_ROOT = 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421; + + + /*************** + * Constructor * + ***************/ + + /** + * @param _libAddressManager Address of the Address Manager. + * @param _stateTransitionIndex Index of the state transition being verified. + * @param _preStateRoot State root before the transition was executed. + * @param _transactionHash Hash of the executed transaction. + */ + constructor( + address _libAddressManager, + uint256 _stateTransitionIndex, + bytes32 _preStateRoot, + bytes32 _transactionHash + ) + Lib_AddressResolver(_libAddressManager) + { + stateTransitionIndex = _stateTransitionIndex; + preStateRoot = _preStateRoot; + postStateRoot = _preStateRoot; + transactionHash = _transactionHash; + + ovmStateManager = iOVM_StateManagerFactory(resolve("OVM_StateManagerFactory")).create(address(this)); + } + + + /********************** + * Function Modifiers * + **********************/ + + /** + * Checks that a function is only run during a specific phase. + * @param _phase Phase the function must run within. + */ + modifier onlyDuringPhase( + TransitionPhase _phase + ) { + require( + phase == _phase, + "Function must be called during the correct phase." + ); + _; + } + + + /********************************** + * Public Functions: State Access * + **********************************/ + + /** + * Retrieves the state root before execution. + * @return _preStateRoot State root before execution. + */ + function getPreStateRoot() + override + public + view + returns ( + bytes32 _preStateRoot + ) + { + return preStateRoot; + } + + /** + * Retrieves the state root after execution. + * @return _postStateRoot State root after execution. + */ + function getPostStateRoot() + override + public + view + returns ( + bytes32 _postStateRoot + ) + { + return postStateRoot; + } + + /** + * Checks whether the transitioner is complete. + * @return _complete Whether or not the transition process is finished. + */ + function isComplete() + override + public + view + returns ( + bool _complete + ) + { + return phase == TransitionPhase.COMPLETE; + } + + + /*********************************** + * Public Functions: Pre-Execution * + ***********************************/ + + /** + * Allows a user to prove the initial state of a contract. + * @param _ovmContractAddress Address of the contract on the OVM. + * @param _ethContractAddress Address of the corresponding contract on L1. + * @param _stateTrieWitness Proof of the account state. + */ + function proveContractState( + address _ovmContractAddress, + address _ethContractAddress, + bytes memory _stateTrieWitness + ) + override + public + onlyDuringPhase(TransitionPhase.PRE_EXECUTION) + contributesToFraudProof(preStateRoot, transactionHash) + { + // Exit quickly to avoid unnecessary work. + require( + ( + ovmStateManager.hasAccount(_ovmContractAddress) == false + && ovmStateManager.hasEmptyAccount(_ovmContractAddress) == false + ), + "Account state has already been proven." + ); + + // Function will fail if the proof is not a valid inclusion or exclusion proof. + ( + bool exists, + bytes memory encodedAccount + ) = Lib_SecureMerkleTrie.get( + abi.encodePacked(_ovmContractAddress), + _stateTrieWitness, + preStateRoot + ); + + if (exists == true) { + // Account exists, this was an inclusion proof. + Lib_OVMCodec.EVMAccount memory account = Lib_OVMCodec.decodeEVMAccount( + encodedAccount + ); + + address ethContractAddress = _ethContractAddress; + if (account.codeHash == EMPTY_ACCOUNT_CODE_HASH) { + // Use a known empty contract to prevent an attack in which a user provides a + // contract address here and then later deploys code to it. + ethContractAddress = 0x0000000000000000000000000000000000000000; + } else { + // Otherwise, make sure that the code at the provided eth address matches the hash + // of the code stored on L2. + require( + Lib_EthUtils.getCodeHash(ethContractAddress) == account.codeHash, + "OVM_StateTransitioner: Provided L1 contract code hash does not match L2 contract code hash." + ); + } + + ovmStateManager.putAccount( + _ovmContractAddress, + Lib_OVMCodec.Account({ + nonce: account.nonce, + balance: account.balance, + storageRoot: account.storageRoot, + codeHash: account.codeHash, + ethAddress: ethContractAddress, + isFresh: false + }) + ); + } else { + // Account does not exist, this was an exclusion proof. + ovmStateManager.putEmptyAccount(_ovmContractAddress); + } + } + + /** + * Allows a user to prove the initial state of a contract storage slot. + * @param _ovmContractAddress Address of the contract on the OVM. + * @param _key Claimed account slot key. + * @param _storageTrieWitness Proof of the storage slot. + */ + function proveStorageSlot( + address _ovmContractAddress, + bytes32 _key, + bytes memory _storageTrieWitness + ) + override + public + onlyDuringPhase(TransitionPhase.PRE_EXECUTION) + contributesToFraudProof(preStateRoot, transactionHash) + { + // Exit quickly to avoid unnecessary work. + require( + ovmStateManager.hasContractStorage(_ovmContractAddress, _key) == false, + "Storage slot has already been proven." + ); + + require( + ovmStateManager.hasAccount(_ovmContractAddress) == true, + "Contract must be verified before proving a storage slot." + ); + + bytes32 storageRoot = ovmStateManager.getAccountStorageRoot(_ovmContractAddress); + bytes32 value; + + if (storageRoot == EMPTY_ACCOUNT_STORAGE_ROOT) { + // Storage trie was empty, so the user is always allowed to insert zero-byte values. + value = bytes32(0); + } else { + // Function will fail if the proof is not a valid inclusion or exclusion proof. + ( + bool exists, + bytes memory encodedValue + ) = Lib_SecureMerkleTrie.get( + abi.encodePacked(_key), + _storageTrieWitness, + storageRoot + ); + + if (exists == true) { + // Inclusion proof. + // Stored values are RLP encoded, with leading zeros removed. + value = Lib_BytesUtils.toBytes32PadLeft( + Lib_RLPReader.readBytes(encodedValue) + ); + } else { + // Exclusion proof, can only be zero bytes. + value = bytes32(0); + } + } + + ovmStateManager.putContractStorage( + _ovmContractAddress, + _key, + value + ); + } + + + /******************************* + * Public Functions: Execution * + *******************************/ + + /** + * Executes the state transition. + * @param _transaction OVM transaction to execute. + */ + function applyTransaction( + Lib_OVMCodec.Transaction memory _transaction + ) + override + public + onlyDuringPhase(TransitionPhase.PRE_EXECUTION) + contributesToFraudProof(preStateRoot, transactionHash) + { + require( + Lib_OVMCodec.hashTransaction(_transaction) == transactionHash, + "Invalid transaction provided." + ); + + // We require gas to complete the logic here in run() before/after execution, + // But must ensure the full _tx.gasLimit can be given to the ovmCALL (determinism) + // This includes 1/64 of the gas getting lost because of EIP-150 (lost twice--first + // going into EM, then going into the code contract). + require( + gasleft() >= 100000 + _transaction.gasLimit * 1032 / 1000, // 1032/1000 = 1.032 = (64/63)^2 rounded up + "Not enough gas to execute transaction deterministically." + ); + + iOVM_ExecutionManager ovmExecutionManager = iOVM_ExecutionManager(resolve("OVM_ExecutionManager")); + + // We call `setExecutionManager` right before `run` (and not earlier) just in case the + // OVM_ExecutionManager address was updated between the time when this contract was created + // and when `applyTransaction` was called. + ovmStateManager.setExecutionManager(address(ovmExecutionManager)); + + // `run` always succeeds *unless* the user hasn't provided enough gas to `applyTransaction` + // or an INVALID_STATE_ACCESS flag was triggered. Either way, we won't get beyond this line + // if that's the case. + ovmExecutionManager.run(_transaction, address(ovmStateManager)); + + phase = TransitionPhase.POST_EXECUTION; + } + + + /************************************ + * Public Functions: Post-Execution * + ************************************/ + + /** + * Allows a user to commit the final state of a contract. + * @param _ovmContractAddress Address of the contract on the OVM. + * @param _stateTrieWitness Proof of the account state. + */ + function commitContractState( + address _ovmContractAddress, + bytes memory _stateTrieWitness + ) + override + public + onlyDuringPhase(TransitionPhase.POST_EXECUTION) + contributesToFraudProof(preStateRoot, transactionHash) + { + require( + ovmStateManager.getTotalUncommittedContractStorage() == 0, + "All storage must be committed before committing account states." + ); + + require ( + ovmStateManager.commitAccount(_ovmContractAddress) == true, + "Account state wasn't changed or has already been committed." + ); + + Lib_OVMCodec.Account memory account = ovmStateManager.getAccount(_ovmContractAddress); + + postStateRoot = Lib_SecureMerkleTrie.update( + abi.encodePacked(_ovmContractAddress), + Lib_OVMCodec.encodeEVMAccount( + Lib_OVMCodec.toEVMAccount(account) + ), + _stateTrieWitness, + postStateRoot + ); + + // Emit an event to help clients figure out the proof ordering. + emit AccountCommitted( + _ovmContractAddress + ); + } + + /** + * Allows a user to commit the final state of a contract storage slot. + * @param _ovmContractAddress Address of the contract on the OVM. + * @param _key Claimed account slot key. + * @param _storageTrieWitness Proof of the storage slot. + */ + function commitStorageSlot( + address _ovmContractAddress, + bytes32 _key, + bytes memory _storageTrieWitness + ) + override + public + onlyDuringPhase(TransitionPhase.POST_EXECUTION) + contributesToFraudProof(preStateRoot, transactionHash) + { + require( + ovmStateManager.commitContractStorage(_ovmContractAddress, _key) == true, + "Storage slot value wasn't changed or has already been committed." + ); + + Lib_OVMCodec.Account memory account = ovmStateManager.getAccount(_ovmContractAddress); + bytes32 value = ovmStateManager.getContractStorage(_ovmContractAddress, _key); + + account.storageRoot = Lib_SecureMerkleTrie.update( + abi.encodePacked(_key), + Lib_RLPWriter.writeBytes( + Lib_Bytes32Utils.removeLeadingZeros(value) + ), + _storageTrieWitness, + account.storageRoot + ); + + ovmStateManager.putAccount(_ovmContractAddress, account); + + // Emit an event to help clients figure out the proof ordering. + emit ContractStorageCommitted( + _ovmContractAddress, + _key + ); + } + + + /********************************** + * Public Functions: Finalization * + **********************************/ + + /** + * Finalizes the transition process. + */ + function completeTransition() + override + public + onlyDuringPhase(TransitionPhase.POST_EXECUTION) + { + require( + ovmStateManager.getTotalUncommittedAccounts() == 0, + "All accounts must be committed before completing a transition." + ); + + require( + ovmStateManager.getTotalUncommittedContractStorage() == 0, + "All storage must be committed before completing a transition." + ); + + phase = TransitionPhase.COMPLETE; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_StateTransitionerFactory.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_StateTransitionerFactory.sol new file mode 100644 index 000000000000..67e6138daee2 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_StateTransitionerFactory.sol @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: MIT +// @unsupported: ovm +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; + +/* Interface Imports */ +import { iOVM_StateTransitioner } from "../../iOVM/verification/iOVM_StateTransitioner.sol"; +import { iOVM_StateTransitionerFactory } from "../../iOVM/verification/iOVM_StateTransitionerFactory.sol"; +import { iOVM_FraudVerifier } from "../../iOVM/verification/iOVM_FraudVerifier.sol"; + +/* Contract Imports */ +import { OVM_StateTransitioner } from "./OVM_StateTransitioner.sol"; + +/** + * @title OVM_StateTransitionerFactory + * @dev The State Transitioner Factory is used by the Fraud Verifier to create a new State + * Transitioner during the initialization of a fraud proof. + * + * Compiler used: solc + * Runtime target: EVM + */ +contract OVM_StateTransitionerFactory is iOVM_StateTransitionerFactory, Lib_AddressResolver { + + constructor( + address _libAddressManager + ) + Lib_AddressResolver(_libAddressManager) + {} + + /*************************************** + * Public Functions: Contract Creation * + ***************************************/ + + /** + * Creates a new OVM_StateTransitioner + * @param _libAddressManager Address of the Address Manager. + * @param _stateTransitionIndex Index of the state transition being verified. + * @param _preStateRoot State root before the transition was executed. + * @param _transactionHash Hash of the executed transaction. + * @return _ovmStateTransitioner New OVM_StateTransitioner instance. + */ + function create( + address _libAddressManager, + uint256 _stateTransitionIndex, + bytes32 _preStateRoot, + bytes32 _transactionHash + ) + override + public + returns ( + iOVM_StateTransitioner _ovmStateTransitioner + ) + { + require( + msg.sender == resolve("OVM_FraudVerifier"), + "Create can only be done by the OVM_FraudVerifier." + ); + return new OVM_StateTransitioner( + _libAddressManager, + _stateTransitionIndex, + _preStateRoot, + _transactionHash + ); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/accounts/iOVM_ECDSAContractAccount.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/accounts/iOVM_ECDSAContractAccount.sol new file mode 100644 index 000000000000..16c956580f85 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/accounts/iOVM_ECDSAContractAccount.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; + +/** + * @title iOVM_ECDSAContractAccount + */ +interface iOVM_ECDSAContractAccount { + + /******************** + * Public Functions * + ********************/ + + function execute( + bytes memory _transaction, + Lib_OVMCodec.EOASignatureType _signatureType, + uint8 _v, + bytes32 _r, + bytes32 _s + ) external returns (bool _success, bytes memory _returndata); +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iAbs_BaseCrossDomainMessenger.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iAbs_BaseCrossDomainMessenger.sol new file mode 100644 index 000000000000..d8e13d11420f --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iAbs_BaseCrossDomainMessenger.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/** + * @title iAbs_BaseCrossDomainMessenger + */ +interface iAbs_BaseCrossDomainMessenger { + + /********** + * Events * + **********/ + event SentMessage(bytes message); + event RelayedMessage(bytes32 msgHash); + + /********************** + * Contract Variables * + **********************/ + function xDomainMessageSender() external view returns (address); + + /******************** + * Public Functions * + ********************/ + + /** + * Sends a cross domain message to the target messenger. + * @param _target Target contract address. + * @param _message Message to send to the target. + * @param _gasLimit Gas limit for the provided message. + */ + function sendMessage( + address _target, + bytes calldata _message, + uint32 _gasLimit + ) external; +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_L1CrossDomainMessenger.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_L1CrossDomainMessenger.sol new file mode 100644 index 000000000000..629e20e1d618 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_L1CrossDomainMessenger.sol @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../../libraries/codec/Lib_OVMCodec.sol"; + +/* Interface Imports */ +import { iAbs_BaseCrossDomainMessenger } from "./iAbs_BaseCrossDomainMessenger.sol"; + +/** + * @title iOVM_L1CrossDomainMessenger + */ +interface iOVM_L1CrossDomainMessenger is iAbs_BaseCrossDomainMessenger { + + /******************* + * Data Structures * + *******************/ + + struct L2MessageInclusionProof { + bytes32 stateRoot; + Lib_OVMCodec.ChainBatchHeader stateRootBatchHeader; + Lib_OVMCodec.ChainInclusionProof stateRootProof; + bytes stateTrieWitness; + bytes storageTrieWitness; + } + + + /******************** + * Public Functions * + ********************/ + + /** + * Relays a cross domain message to a contract. + * @param _target Target contract address. + * @param _sender Message sender address. + * @param _message Message to send to the target. + * @param _messageNonce Nonce for the provided message. + * @param _proof Inclusion proof for the given message. + */ + function relayMessage( + address _target, + address _sender, + bytes memory _message, + uint256 _messageNonce, + L2MessageInclusionProof memory _proof + ) external; + + /** + * Replays a cross domain message to the target messenger. + * @param _target Target contract address. + * @param _sender Original sender address. + * @param _message Message to send to the target. + * @param _messageNonce Nonce for the provided message. + * @param _gasLimit Gas limit for the provided message. + */ + function replayMessage( + address _target, + address _sender, + bytes memory _message, + uint256 _messageNonce, + uint32 _gasLimit + ) external; +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_L1MultiMessageRelayer.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_L1MultiMessageRelayer.sol new file mode 100644 index 000000000000..a2ae03910aa1 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_L1MultiMessageRelayer.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Interface Imports */ +import { iOVM_L1CrossDomainMessenger } from "../../../iOVM/bridge/messaging/iOVM_L1CrossDomainMessenger.sol"; +interface iOVM_L1MultiMessageRelayer { + + struct L2ToL1Message { + address target; + address sender; + bytes message; + uint256 messageNonce; + iOVM_L1CrossDomainMessenger.L2MessageInclusionProof proof; + } + + function batchRelayMessages(L2ToL1Message[] calldata _messages) external; +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_L2CrossDomainMessenger.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_L2CrossDomainMessenger.sol new file mode 100644 index 000000000000..900d59d09727 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_L2CrossDomainMessenger.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Interface Imports */ +import { iAbs_BaseCrossDomainMessenger } from "./iAbs_BaseCrossDomainMessenger.sol"; + +/** + * @title iOVM_L2CrossDomainMessenger + */ +interface iOVM_L2CrossDomainMessenger is iAbs_BaseCrossDomainMessenger { + + /******************** + * Public Functions * + ********************/ + + /** + * Relays a cross domain message to a contract. + * @param _target Target contract address. + * @param _sender Message sender address. + * @param _message Message to send to the target. + * @param _messageNonce Nonce for the provided message. + */ + function relayMessage( + address _target, + address _sender, + bytes memory _message, + uint256 _messageNonce + ) external; +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/tokens/iOVM_L1ETHGateway.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/tokens/iOVM_L1ETHGateway.sol new file mode 100644 index 000000000000..32a9918d9cca --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/tokens/iOVM_L1ETHGateway.sol @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0; +pragma experimental ABIEncoderV2; + +/** + * @title iOVM_L1ETHGateway + */ +interface iOVM_L1ETHGateway { + + /********** + * Events * + **********/ + + event DepositInitiated( + address indexed _from, + address _to, + uint256 _amount + ); + + event WithdrawalFinalized( + address indexed _to, + uint256 _amount + ); + + /******************** + * Public Functions * + ********************/ + + function deposit() + external + payable; + + function depositTo( + address _to + ) + external + payable; + + /************************* + * Cross-chain Functions * + *************************/ + + function finalizeWithdrawal( + address _to, + uint _amount + ) + external; + + function getFinalizeDepositL2Gas() + external + view + returns( + uint32 + ); +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/tokens/iOVM_L1TokenGateway.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/tokens/iOVM_L1TokenGateway.sol new file mode 100644 index 000000000000..39abd4562b31 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/tokens/iOVM_L1TokenGateway.sol @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0; +pragma experimental ABIEncoderV2; + +/** + * @title iOVM_L1TokenGateway + */ +interface iOVM_L1TokenGateway { + + /********** + * Events * + **********/ + + event DepositInitiated( + address indexed _from, + address _to, + uint256 _amount + ); + + event WithdrawalFinalized( + address indexed _to, + uint256 _amount + ); + + + /******************** + * Public Functions * + ********************/ + + function deposit( + uint _amount + ) + external; + + function depositTo( + address _to, + uint _amount + ) + external; + + + /************************* + * Cross-chain Functions * + *************************/ + + function finalizeWithdrawal( + address _to, + uint _amount + ) + external; +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/tokens/iOVM_L2DepositedToken.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/tokens/iOVM_L2DepositedToken.sol new file mode 100644 index 000000000000..3b5d932af9b3 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/tokens/iOVM_L2DepositedToken.sol @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0; +pragma experimental ABIEncoderV2; + +/** + * @title iOVM_L2DepositedToken + */ +interface iOVM_L2DepositedToken { + + /********** + * Events * + **********/ + + event WithdrawalInitiated( + address indexed _from, + address _to, + uint256 _amount + ); + + event DepositFinalized( + address indexed _to, + uint256 _amount + ); + + + /******************** + * Public Functions * + ********************/ + + function withdraw( + uint _amount + ) + external; + + function withdrawTo( + address _to, + uint _amount + ) + external; + + + /************************* + * Cross-chain Functions * + *************************/ + + function finalizeDeposit( + address _to, + uint _amount + ) + external; +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/chain/iOVM_CanonicalTransactionChain.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/chain/iOVM_CanonicalTransactionChain.sol new file mode 100644 index 000000000000..94de09a372e8 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/chain/iOVM_CanonicalTransactionChain.sol @@ -0,0 +1,239 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; + +/* Interface Imports */ +import { iOVM_ChainStorageContainer } from "./iOVM_ChainStorageContainer.sol"; + +/** + * @title iOVM_CanonicalTransactionChain + */ +interface iOVM_CanonicalTransactionChain { + + /********** + * Events * + **********/ + + event TransactionEnqueued( + address _l1TxOrigin, + address _target, + uint256 _gasLimit, + bytes _data, + uint256 _queueIndex, + uint256 _timestamp + ); + + event QueueBatchAppended( + uint256 _startingQueueIndex, + uint256 _numQueueElements, + uint256 _totalElements + ); + + event SequencerBatchAppended( + uint256 _startingQueueIndex, + uint256 _numQueueElements, + uint256 _totalElements + ); + + event TransactionBatchAppended( + uint256 indexed _batchIndex, + bytes32 _batchRoot, + uint256 _batchSize, + uint256 _prevTotalElements, + bytes _extraData + ); + + + /*********** + * Structs * + ***********/ + + struct BatchContext { + uint256 numSequencedTransactions; + uint256 numSubsequentQueueTransactions; + uint256 timestamp; + uint256 blockNumber; + } + + + /******************** + * Public Functions * + ********************/ + + + /** + * Accesses the batch storage container. + * @return Reference to the batch storage container. + */ + function batches() + external + view + returns ( + iOVM_ChainStorageContainer + ); + + /** + * Accesses the queue storage container. + * @return Reference to the queue storage container. + */ + function queue() + external + view + returns ( + iOVM_ChainStorageContainer + ); + + /** + * Retrieves the total number of elements submitted. + * @return _totalElements Total submitted elements. + */ + function getTotalElements() + external + view + returns ( + uint256 _totalElements + ); + + /** + * Retrieves the total number of batches submitted. + * @return _totalBatches Total submitted batches. + */ + function getTotalBatches() + external + view + returns ( + uint256 _totalBatches + ); + + /** + * Returns the index of the next element to be enqueued. + * @return Index for the next queue element. + */ + function getNextQueueIndex() + external + view + returns ( + uint40 + ); + + /** + * Gets the queue element at a particular index. + * @param _index Index of the queue element to access. + * @return _element Queue element at the given index. + */ + function getQueueElement( + uint256 _index + ) + external + view + returns ( + Lib_OVMCodec.QueueElement memory _element + ); + + /** + * Returns the timestamp of the last transaction. + * @return Timestamp for the last transaction. + */ + function getLastTimestamp() + external + view + returns ( + uint40 + ); + + /** + * Returns the blocknumber of the last transaction. + * @return Blocknumber for the last transaction. + */ + function getLastBlockNumber() + external + view + returns ( + uint40 + ); + + /** + * Get the number of queue elements which have not yet been included. + * @return Number of pending queue elements. + */ + function getNumPendingQueueElements() + external + view + returns ( + uint40 + ); + + /** + * Retrieves the length of the queue, including + * both pending and canonical transactions. + * @return Length of the queue. + */ + function getQueueLength() + external + view + returns ( + uint40 + ); + + + /** + * Adds a transaction to the queue. + * @param _target Target contract to send the transaction to. + * @param _gasLimit Gas limit for the given transaction. + * @param _data Transaction data. + */ + function enqueue( + address _target, + uint256 _gasLimit, + bytes memory _data + ) + external; + + /** + * Appends a given number of queued transactions as a single batch. + * @param _numQueuedTransactions Number of transactions to append. + */ + function appendQueueBatch( + uint256 _numQueuedTransactions + ) + external; + + /** + * Allows the sequencer to append a batch of transactions. + * @dev This function uses a custom encoding scheme for efficiency reasons. + * .param _shouldStartAtElement Specific batch we expect to start appending to. + * .param _totalElementsToAppend Total number of batch elements we expect to append. + * .param _contexts Array of batch contexts. + * .param _transactionDataFields Array of raw transaction data. + */ + function appendSequencerBatch( + // uint40 _shouldStartAtElement, + // uint24 _totalElementsToAppend, + // BatchContext[] _contexts, + // bytes[] _transactionDataFields + ) + external; + + /** + * Verifies whether a transaction is included in the chain. + * @param _transaction Transaction to verify. + * @param _txChainElement Transaction chain element corresponding to the transaction. + * @param _batchHeader Header of the batch the transaction was included in. + * @param _inclusionProof Inclusion proof for the provided transaction chain element. + * @return True if the transaction exists in the CTC, false if not. + */ + function verifyTransaction( + Lib_OVMCodec.Transaction memory _transaction, + Lib_OVMCodec.TransactionChainElement memory _txChainElement, + Lib_OVMCodec.ChainBatchHeader memory _batchHeader, + Lib_OVMCodec.ChainInclusionProof memory _inclusionProof + ) + external + view + returns ( + bool + ); +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/chain/iOVM_ChainStorageContainer.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/chain/iOVM_ChainStorageContainer.sol new file mode 100644 index 000000000000..3c0670497cef --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/chain/iOVM_ChainStorageContainer.sol @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @title iOVM_ChainStorageContainer + */ +interface iOVM_ChainStorageContainer { + + /******************** + * Public Functions * + ********************/ + + /** + * Sets the container's global metadata field. We're using `bytes27` here because we use five + * bytes to maintain the length of the underlying data structure, meaning we have an extra + * 27 bytes to store arbitrary data. + * @param _globalMetadata New global metadata to set. + */ + function setGlobalMetadata( + bytes27 _globalMetadata + ) + external; + + /** + * Retrieves the container's global metadata field. + * @return Container global metadata field. + */ + function getGlobalMetadata() + external + view + returns ( + bytes27 + ); + + /** + * Retrieves the number of objects stored in the container. + * @return Number of objects in the container. + */ + function length() + external + view + returns ( + uint256 + ); + + /** + * Pushes an object into the container. + * @param _object A 32 byte value to insert into the container. + */ + function push( + bytes32 _object + ) + external; + + /** + * Pushes an object into the container. Function allows setting the global metadata since + * we'll need to touch the "length" storage slot anyway, which also contains the global + * metadata (it's an optimization). + * @param _object A 32 byte value to insert into the container. + * @param _globalMetadata New global metadata for the container. + */ + function push( + bytes32 _object, + bytes27 _globalMetadata + ) + external; + + /** + * Retrieves an object from the container. + * @param _index Index of the particular object to access. + * @return 32 byte object value. + */ + function get( + uint256 _index + ) + external + view + returns ( + bytes32 + ); + + /** + * Removes all objects after and including a given index. + * @param _index Object index to delete from. + */ + function deleteElementsAfterInclusive( + uint256 _index + ) + external; + + /** + * Removes all objects after and including a given index. Also allows setting the global + * metadata field. + * @param _index Object index to delete from. + * @param _globalMetadata New global metadata for the container. + */ + function deleteElementsAfterInclusive( + uint256 _index, + bytes27 _globalMetadata + ) + external; + + /** + * Marks an index as overwritable, meaing the underlying buffer can start to write values over + * any objects before and including the given index. + */ + function setNextOverwritableIndex( + uint256 _index + ) + external; +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/chain/iOVM_StateCommitmentChain.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/chain/iOVM_StateCommitmentChain.sol new file mode 100644 index 000000000000..b90f00dc66ec --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/chain/iOVM_StateCommitmentChain.sol @@ -0,0 +1,118 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; + +/** + * @title iOVM_StateCommitmentChain + */ +interface iOVM_StateCommitmentChain { + + /********** + * Events * + **********/ + + event StateBatchAppended( + uint256 indexed _batchIndex, + bytes32 _batchRoot, + uint256 _batchSize, + uint256 _prevTotalElements, + bytes _extraData + ); + + event StateBatchDeleted( + uint256 indexed _batchIndex, + bytes32 _batchRoot + ); + + + /******************** + * Public Functions * + ********************/ + + /** + * Retrieves the total number of elements submitted. + * @return _totalElements Total submitted elements. + */ + function getTotalElements() + external + view + returns ( + uint256 _totalElements + ); + + /** + * Retrieves the total number of batches submitted. + * @return _totalBatches Total submitted batches. + */ + function getTotalBatches() + external + view + returns ( + uint256 _totalBatches + ); + + /** + * Retrieves the timestamp of the last batch submitted by the sequencer. + * @return _lastSequencerTimestamp Last sequencer batch timestamp. + */ + function getLastSequencerTimestamp() + external + view + returns ( + uint256 _lastSequencerTimestamp + ); + + /** + * Appends a batch of state roots to the chain. + * @param _batch Batch of state roots. + * @param _shouldStartAtElement Index of the element at which this batch should start. + */ + function appendStateBatch( + bytes32[] calldata _batch, + uint256 _shouldStartAtElement + ) + external; + + /** + * Deletes all state roots after (and including) a given batch. + * @param _batchHeader Header of the batch to start deleting from. + */ + function deleteStateBatch( + Lib_OVMCodec.ChainBatchHeader memory _batchHeader + ) + external; + + /** + * Verifies a batch inclusion proof. + * @param _element Hash of the element to verify a proof for. + * @param _batchHeader Header of the batch in which the element was included. + * @param _proof Merkle inclusion proof for the element. + */ + function verifyStateCommitment( + bytes32 _element, + Lib_OVMCodec.ChainBatchHeader memory _batchHeader, + Lib_OVMCodec.ChainInclusionProof memory _proof + ) + external + view + returns ( + bool _verified + ); + + /** + * Checks whether a given batch is still inside its fraud proof window. + * @param _batchHeader Header of the batch to check. + * @return _inside Whether or not the batch is inside the fraud proof window. + */ + function insideFraudProofWindow( + Lib_OVMCodec.ChainBatchHeader memory _batchHeader + ) + external + view + returns ( + bool _inside + ); +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_ExecutionManager.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_ExecutionManager.sol new file mode 100644 index 000000000000..9be045cfc748 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_ExecutionManager.sol @@ -0,0 +1,156 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; + +interface iOVM_ExecutionManager { + /********** + * Enums * + *********/ + + enum RevertFlag { + OUT_OF_GAS, + INTENTIONAL_REVERT, + EXCEEDS_NUISANCE_GAS, + INVALID_STATE_ACCESS, + UNSAFE_BYTECODE, + CREATE_COLLISION, + STATIC_VIOLATION, + CREATOR_NOT_ALLOWED + } + + enum GasMetadataKey { + CURRENT_EPOCH_START_TIMESTAMP, + CUMULATIVE_SEQUENCER_QUEUE_GAS, + CUMULATIVE_L1TOL2_QUEUE_GAS, + PREV_EPOCH_SEQUENCER_QUEUE_GAS, + PREV_EPOCH_L1TOL2_QUEUE_GAS + } + + /*********** + * Structs * + ***********/ + + struct GasMeterConfig { + uint256 minTransactionGasLimit; + uint256 maxTransactionGasLimit; + uint256 maxGasPerQueuePerEpoch; + uint256 secondsPerEpoch; + } + + struct GlobalContext { + uint256 ovmCHAINID; + } + + struct TransactionContext { + Lib_OVMCodec.QueueOrigin ovmL1QUEUEORIGIN; + uint256 ovmTIMESTAMP; + uint256 ovmNUMBER; + uint256 ovmGASLIMIT; + uint256 ovmTXGASLIMIT; + address ovmL1TXORIGIN; + } + + struct TransactionRecord { + uint256 ovmGasRefund; + } + + struct MessageContext { + address ovmCALLER; + address ovmADDRESS; + bool isStatic; + } + + struct MessageRecord { + uint256 nuisanceGasLeft; + } + + + /************************************ + * Transaction Execution Entrypoint * + ************************************/ + + function run( + Lib_OVMCodec.Transaction calldata _transaction, + address _txStateManager + ) external; + + + /******************* + * Context Opcodes * + *******************/ + + function ovmCALLER() external view returns (address _caller); + function ovmADDRESS() external view returns (address _address); + function ovmTIMESTAMP() external view returns (uint256 _timestamp); + function ovmNUMBER() external view returns (uint256 _number); + function ovmGASLIMIT() external view returns (uint256 _gasLimit); + function ovmCHAINID() external view returns (uint256 _chainId); + + + /********************** + * L2 Context Opcodes * + **********************/ + + function ovmL1QUEUEORIGIN() external view returns (Lib_OVMCodec.QueueOrigin _queueOrigin); + function ovmL1TXORIGIN() external view returns (address _l1TxOrigin); + + + /******************* + * Halting Opcodes * + *******************/ + + function ovmREVERT(bytes memory _data) external; + + + /***************************** + * Contract Creation Opcodes * + *****************************/ + + function ovmCREATE(bytes memory _bytecode) external returns (address _contract, bytes memory _revertdata); + function ovmCREATE2(bytes memory _bytecode, bytes32 _salt) external returns (address _contract, bytes memory _revertdata); + + + /******************************* + * Account Abstraction Opcodes * + ******************************/ + + function ovmGETNONCE() external returns (uint256 _nonce); + function ovmINCREMENTNONCE() external; + function ovmCREATEEOA(bytes32 _messageHash, uint8 _v, bytes32 _r, bytes32 _s) external; + + + /**************************** + * Contract Calling Opcodes * + ****************************/ + + function ovmCALL(uint256 _gasLimit, address _address, bytes memory _calldata) external returns (bool _success, bytes memory _returndata); + function ovmSTATICCALL(uint256 _gasLimit, address _address, bytes memory _calldata) external returns (bool _success, bytes memory _returndata); + function ovmDELEGATECALL(uint256 _gasLimit, address _address, bytes memory _calldata) external returns (bool _success, bytes memory _returndata); + + + /**************************** + * Contract Storage Opcodes * + ****************************/ + + function ovmSLOAD(bytes32 _key) external returns (bytes32 _value); + function ovmSSTORE(bytes32 _key, bytes32 _value) external; + + + /************************* + * Contract Code Opcodes * + *************************/ + + function ovmEXTCODECOPY(address _contract, uint256 _offset, uint256 _length) external returns (bytes memory _code); + function ovmEXTCODESIZE(address _contract) external returns (uint256 _size); + function ovmEXTCODEHASH(address _contract) external returns (bytes32 _hash); + + + /*************************************** + * Public Functions: Execution Context * + ***************************************/ + + function getMaxTransactionGasLimit() external view returns (uint _maxTransactionGasLimit); +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_SafetyChecker.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_SafetyChecker.sol new file mode 100644 index 000000000000..848e47ddff81 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_SafetyChecker.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @title iOVM_SafetyChecker + */ +interface iOVM_SafetyChecker { + + /******************** + * Public Functions * + ********************/ + + function isBytecodeSafe(bytes calldata _bytecode) external pure returns (bool); +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_StateManager.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_StateManager.sol new file mode 100644 index 000000000000..1c4870a5841a --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_StateManager.sol @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; + +/** + * @title iOVM_StateManager + */ +interface iOVM_StateManager { + + /******************* + * Data Structures * + *******************/ + + enum ItemState { + ITEM_UNTOUCHED, + ITEM_LOADED, + ITEM_CHANGED, + ITEM_COMMITTED + } + + /*************************** + * Public Functions: Misc * + ***************************/ + + function isAuthenticated(address _address) external view returns (bool); + + /*************************** + * Public Functions: Setup * + ***************************/ + + function owner() external view returns (address _owner); + function ovmExecutionManager() external view returns (address _ovmExecutionManager); + function setExecutionManager(address _ovmExecutionManager) external; + + + /************************************ + * Public Functions: Account Access * + ************************************/ + + function putAccount(address _address, Lib_OVMCodec.Account memory _account) external; + function putEmptyAccount(address _address) external; + function getAccount(address _address) external view returns (Lib_OVMCodec.Account memory _account); + function hasAccount(address _address) external view returns (bool _exists); + function hasEmptyAccount(address _address) external view returns (bool _exists); + function setAccountNonce(address _address, uint256 _nonce) external; + function getAccountNonce(address _address) external view returns (uint256 _nonce); + function getAccountEthAddress(address _address) external view returns (address _ethAddress); + function getAccountStorageRoot(address _address) external view returns (bytes32 _storageRoot); + function initPendingAccount(address _address) external; + function commitPendingAccount(address _address, address _ethAddress, bytes32 _codeHash) external; + function testAndSetAccountLoaded(address _address) external returns (bool _wasAccountAlreadyLoaded); + function testAndSetAccountChanged(address _address) external returns (bool _wasAccountAlreadyChanged); + function commitAccount(address _address) external returns (bool _wasAccountCommitted); + function incrementTotalUncommittedAccounts() external; + function getTotalUncommittedAccounts() external view returns (uint256 _total); + function wasAccountChanged(address _address) external view returns (bool); + function wasAccountCommitted(address _address) external view returns (bool); + + + /************************************ + * Public Functions: Storage Access * + ************************************/ + + function putContractStorage(address _contract, bytes32 _key, bytes32 _value) external; + function getContractStorage(address _contract, bytes32 _key) external view returns (bytes32 _value); + function hasContractStorage(address _contract, bytes32 _key) external view returns (bool _exists); + function testAndSetContractStorageLoaded(address _contract, bytes32 _key) external returns (bool _wasContractStorageAlreadyLoaded); + function testAndSetContractStorageChanged(address _contract, bytes32 _key) external returns (bool _wasContractStorageAlreadyChanged); + function commitContractStorage(address _contract, bytes32 _key) external returns (bool _wasContractStorageCommitted); + function incrementTotalUncommittedContractStorage() external; + function getTotalUncommittedContractStorage() external view returns (uint256 _total); + function wasContractStorageChanged(address _contract, bytes32 _key) external view returns (bool); + function wasContractStorageCommitted(address _contract, bytes32 _key) external view returns (bool); +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_StateManagerFactory.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_StateManagerFactory.sol new file mode 100644 index 000000000000..1a79613c08c2 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_StateManagerFactory.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Contract Imports */ +import { iOVM_StateManager } from "./iOVM_StateManager.sol"; + +/** + * @title iOVM_StateManagerFactory + */ +interface iOVM_StateManagerFactory { + + /*************************************** + * Public Functions: Contract Creation * + ***************************************/ + + function create( + address _owner + ) + external + returns ( + iOVM_StateManager _ovmStateManager + ); +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_DeployerWhitelist.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_DeployerWhitelist.sol new file mode 100644 index 000000000000..8274f6413eeb --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_DeployerWhitelist.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @title iOVM_DeployerWhitelist + */ +interface iOVM_DeployerWhitelist { + + /******************** + * Public Functions * + ********************/ + + function initialize(address _owner, bool _allowArbitraryDeployment) external; + function getOwner() external returns (address _owner); + function setWhitelistedDeployer(address _deployer, bool _isWhitelisted) external; + function setOwner(address _newOwner) external; + function setAllowArbitraryDeployment(bool _allowArbitraryDeployment) external; + function enableArbitraryContractDeployment() external; + function isDeployerAllowed(address _deployer) external returns (bool _allowed); +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_ERC20.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_ERC20.sol new file mode 100644 index 000000000000..1c765799cd10 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_ERC20.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @title iOVM_ERC20 + */ +interface iOVM_ERC20 { + /* This is a slight change to the ERC20 base standard. + function totalSupply() constant returns (uint256 supply); + is replaced with: + uint256 public totalSupply; + This automatically creates a getter function for the totalSupply. + This is moved to the base contract since public getter functions are not + currently recognised as an implementation of the matching abstract + function by the compiler. + */ + /// total amount of tokens + function totalSupply() external view returns (uint256); + + /// @param _owner The address from which the balance will be retrieved + /// @return balance The balance + function balanceOf(address _owner) external view returns (uint256 balance); + + /// @notice send `_value` token to `_to` from `msg.sender` + /// @param _to The address of the recipient + /// @param _value The amount of token to be transferred + /// @return success Whether the transfer was successful or not + function transfer(address _to, uint256 _value) external returns (bool success); + + /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` + /// @param _from The address of the sender + /// @param _to The address of the recipient + /// @param _value The amount of token to be transferred + /// @return success Whether the transfer was successful or not + function transferFrom(address _from, address _to, uint256 _value) external returns (bool success); + + /// @notice `msg.sender` approves `_spender` to spend `_value` tokens + /// @param _spender The address of the account able to transfer the tokens + /// @param _value The amount of tokens to be approved for transfer + /// @return success Whether the approval was successful or not + function approve(address _spender, uint256 _value) external returns (bool success); + + /// @param _owner The address of the account owning tokens + /// @param _spender The address of the account able to transfer the tokens + /// @return remaining Amount of remaining tokens allowed to spent + function allowance(address _owner, address _spender) external view returns (uint256 remaining); + + // solhint-disable-next-line no-simple-event-func-name + event Transfer(address indexed _from, address indexed _to, uint256 _value); + event Approval(address indexed _owner, address indexed _spender, uint256 _value); + event Mint(address indexed _account, uint256 _amount); + event Burn(address indexed _account, uint256 _amount); +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_L1MessageSender.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_L1MessageSender.sol new file mode 100644 index 000000000000..ead8e7783ed3 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_L1MessageSender.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @title iOVM_L1MessageSender + */ +interface iOVM_L1MessageSender { + + /******************** + * Public Functions * + ********************/ + + function getL1MessageSender() external view returns (address _l1MessageSender); +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_L2ToL1MessagePasser.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_L2ToL1MessagePasser.sol new file mode 100644 index 000000000000..a8b00053ba73 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_L2ToL1MessagePasser.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @title iOVM_L2ToL1MessagePasser + */ +interface iOVM_L2ToL1MessagePasser { + + /********** + * Events * + **********/ + + event L2ToL1Message( + uint256 _nonce, + address _sender, + bytes _data + ); + + + /******************** + * Public Functions * + ********************/ + + function passMessageToL1(bytes calldata _message) external; +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_BondManager.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_BondManager.sol new file mode 100644 index 000000000000..dd9c7e30abc0 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_BondManager.sol @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +interface ERC20 { + function transfer(address, uint256) external returns (bool); + function transferFrom(address, address, uint256) external returns (bool); +} + +/// All the errors which may be encountered on the bond manager +library Errors { + string constant ERC20_ERR = "BondManager: Could not post bond"; + string constant ALREADY_FINALIZED = "BondManager: Fraud proof for this pre-state root has already been finalized"; + string constant SLASHED = "BondManager: Cannot finalize withdrawal, you probably got slashed"; + string constant WRONG_STATE = "BondManager: Wrong bond state for proposer"; + string constant CANNOT_CLAIM = "BondManager: Cannot claim yet. Dispute must be finalized first"; + + string constant WITHDRAWAL_PENDING = "BondManager: Withdrawal already pending"; + string constant TOO_EARLY = "BondManager: Too early to finalize your withdrawal"; + + string constant ONLY_TRANSITIONER = "BondManager: Only the transitioner for this pre-state root may call this function"; + string constant ONLY_FRAUD_VERIFIER = "BondManager: Only the fraud verifier may call this function"; + string constant ONLY_STATE_COMMITMENT_CHAIN = "BondManager: Only the state commitment chain may call this function"; + string constant WAIT_FOR_DISPUTES = "BondManager: Wait for other potential disputes"; +} + +/** + * @title iOVM_BondManager + */ +interface iOVM_BondManager { + + /******************* + * Data Structures * + *******************/ + + /// The lifecycle of a proposer's bond + enum State { + // Before depositing or after getting slashed, a user is uncollateralized + NOT_COLLATERALIZED, + // After depositing, a user is collateralized + COLLATERALIZED, + // After a user has initiated a withdrawal + WITHDRAWING + } + + /// A bond posted by a proposer + struct Bond { + // The user's state + State state; + // The timestamp at which a proposer issued their withdrawal request + uint32 withdrawalTimestamp; + // The time when the first disputed was initiated for this bond + uint256 firstDisputeAt; + // The earliest observed state root for this bond which has had fraud + bytes32 earliestDisputedStateRoot; + // The state root's timestamp + uint256 earliestTimestamp; + } + + // Per pre-state root, store the number of state provisions that were made + // and how many of these calls were made by each user. Payouts will then be + // claimed by users proportionally for that dispute. + struct Rewards { + // Flag to check if rewards for a fraud proof are claimable + bool canClaim; + // Total number of `recordGasSpent` calls made + uint256 total; + // The gas spent by each user to provide witness data. The sum of all + // values inside this map MUST be equal to the value of `total` + mapping(address => uint256) gasSpent; + } + + + /******************** + * Public Functions * + ********************/ + + function recordGasSpent( + bytes32 _preStateRoot, + bytes32 _txHash, + address _who, + uint256 _gasSpent + ) external; + + function finalize( + bytes32 _preStateRoot, + address _publisher, + uint256 _timestamp + ) external; + + function deposit() external; + + function startWithdrawal() external; + + function finalizeWithdrawal() external; + + function claim( + address _who + ) external; + + function isCollateralized( + address _who + ) external view returns (bool); + + function getGasSpent( + bytes32 _preStateRoot, + address _who + ) external view returns (uint256); +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_FraudVerifier.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_FraudVerifier.sol new file mode 100644 index 000000000000..171a9e49bddb --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_FraudVerifier.sol @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; + +/* Interface Imports */ +import { iOVM_StateTransitioner } from "./iOVM_StateTransitioner.sol"; + +/** + * @title iOVM_FraudVerifier + */ +interface iOVM_FraudVerifier { + + /********** + * Events * + **********/ + + event FraudProofInitialized( + bytes32 _preStateRoot, + uint256 _preStateRootIndex, + bytes32 _transactionHash, + address _who + ); + + event FraudProofFinalized( + bytes32 _preStateRoot, + uint256 _preStateRootIndex, + bytes32 _transactionHash, + address _who + ); + + + /*************************************** + * Public Functions: Transition Status * + ***************************************/ + + function getStateTransitioner(bytes32 _preStateRoot, bytes32 _txHash) external view returns (iOVM_StateTransitioner _transitioner); + + + /**************************************** + * Public Functions: Fraud Verification * + ****************************************/ + + function initializeFraudVerification( + bytes32 _preStateRoot, + Lib_OVMCodec.ChainBatchHeader calldata _preStateRootBatchHeader, + Lib_OVMCodec.ChainInclusionProof calldata _preStateRootProof, + Lib_OVMCodec.Transaction calldata _transaction, + Lib_OVMCodec.TransactionChainElement calldata _txChainElement, + Lib_OVMCodec.ChainBatchHeader calldata _transactionBatchHeader, + Lib_OVMCodec.ChainInclusionProof calldata _transactionProof + ) external; + + function finalizeFraudVerification( + bytes32 _preStateRoot, + Lib_OVMCodec.ChainBatchHeader calldata _preStateRootBatchHeader, + Lib_OVMCodec.ChainInclusionProof calldata _preStateRootProof, + bytes32 _txHash, + bytes32 _postStateRoot, + Lib_OVMCodec.ChainBatchHeader calldata _postStateRootBatchHeader, + Lib_OVMCodec.ChainInclusionProof calldata _postStateRootProof + ) external; +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_StateTransitioner.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_StateTransitioner.sol new file mode 100644 index 000000000000..b823993a1604 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_StateTransitioner.sol @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; + +/** + * @title iOVM_StateTransitioner + */ +interface iOVM_StateTransitioner { + + /********** + * Events * + **********/ + + event AccountCommitted( + address _address + ); + + event ContractStorageCommitted( + address _address, + bytes32 _key + ); + + + /********************************** + * Public Functions: State Access * + **********************************/ + + function getPreStateRoot() external view returns (bytes32 _preStateRoot); + function getPostStateRoot() external view returns (bytes32 _postStateRoot); + function isComplete() external view returns (bool _complete); + + + /*********************************** + * Public Functions: Pre-Execution * + ***********************************/ + + function proveContractState( + address _ovmContractAddress, + address _ethContractAddress, + bytes calldata _stateTrieWitness + ) external; + + function proveStorageSlot( + address _ovmContractAddress, + bytes32 _key, + bytes calldata _storageTrieWitness + ) external; + + + /******************************* + * Public Functions: Execution * + *******************************/ + + function applyTransaction( + Lib_OVMCodec.Transaction calldata _transaction + ) external; + + + /************************************ + * Public Functions: Post-Execution * + ************************************/ + + function commitContractState( + address _ovmContractAddress, + bytes calldata _stateTrieWitness + ) external; + + function commitStorageSlot( + address _ovmContractAddress, + bytes32 _key, + bytes calldata _storageTrieWitness + ) external; + + + /********************************** + * Public Functions: Finalization * + **********************************/ + + function completeTransition() external; +} diff --git a/packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_StateTransitionerFactory.sol b/packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_StateTransitionerFactory.sol new file mode 100644 index 000000000000..219df194429d --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/iOVM/verification/iOVM_StateTransitionerFactory.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Contract Imports */ +import { iOVM_StateTransitioner } from "./iOVM_StateTransitioner.sol"; + +/** + * @title iOVM_StateTransitionerFactory + */ +interface iOVM_StateTransitionerFactory { + + /*************************************** + * Public Functions: Contract Creation * + ***************************************/ + + function create( + address _proxyManager, + uint256 _stateTransitionIndex, + bytes32 _preStateRoot, + bytes32 _transactionHash + ) + external + returns ( + iOVM_StateTransitioner _ovmStateTransitioner + ); +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/bridge/OVM_CrossDomainEnabled.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/bridge/OVM_CrossDomainEnabled.sol new file mode 100644 index 000000000000..e329f90cff74 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/bridge/OVM_CrossDomainEnabled.sol @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +/* Interface Imports */ +import { iAbs_BaseCrossDomainMessenger } from "../../iOVM/bridge/messaging/iAbs_BaseCrossDomainMessenger.sol"; + +/** + * @title OVM_CrossDomainEnabled + * @dev Helper contract for contracts performing cross-domain communications + * + * Compiler used: defined by inheriting contract + * Runtime target: defined by inheriting contract + */ +contract OVM_CrossDomainEnabled { + // Messenger contract used to send and recieve messages from the other domain. + address public messenger; + + /*************** + * Constructor * + ***************/ + constructor( + address _messenger + ) { + messenger = _messenger; + } + + /********************** + * Function Modifiers * + **********************/ + + /** + * @notice Enforces that the modified function is only callable by a specific cross-domain account. + * @param _sourceDomainAccount The only account on the originating domain which is authenticated to call this function. + */ + modifier onlyFromCrossDomainAccount( + address _sourceDomainAccount + ) { + require( + msg.sender == address(getCrossDomainMessenger()), + "OVM_XCHAIN: messenger contract unauthenticated" + ); + + require( + getCrossDomainMessenger().xDomainMessageSender() == _sourceDomainAccount, + "OVM_XCHAIN: wrong sender of cross-domain message" + ); + + _; + } + + /********************** + * Internal Functions * + **********************/ + + /** + * @notice Gets the messenger, usually from storage. This function is exposed in case a child contract needs to override. + * @return The address of the cross-domain messenger contract which should be used. + */ + function getCrossDomainMessenger() + internal + virtual + returns( + iAbs_BaseCrossDomainMessenger + ) + { + return iAbs_BaseCrossDomainMessenger(messenger); + } + + /** + * @notice Sends a message to an account on another domain + * @param _crossDomainTarget The intended recipient on the destination domain + * @param _data The data to send to the target (usually calldata to a function with `onlyFromCrossDomainAccount()`) + * @param _gasLimit The gasLimit for the receipt of the message on the target domain. + */ + function sendCrossDomainMessage( + address _crossDomainTarget, + bytes memory _data, + uint32 _gasLimit + ) internal { + getCrossDomainMessenger().sendMessage(_crossDomainTarget, _data, _gasLimit); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/codec/Lib_OVMCodec.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/codec/Lib_OVMCodec.sol new file mode 100644 index 000000000000..0cb7245956a5 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/codec/Lib_OVMCodec.sol @@ -0,0 +1,371 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_RLPReader } from "../rlp/Lib_RLPReader.sol"; +import { Lib_RLPWriter } from "../rlp/Lib_RLPWriter.sol"; +import { Lib_BytesUtils } from "../utils/Lib_BytesUtils.sol"; +import { Lib_Bytes32Utils } from "../utils/Lib_Bytes32Utils.sol"; +import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol"; + +/** + * @title Lib_OVMCodec + */ +library Lib_OVMCodec { + + /********* + * Enums * + *********/ + + enum EOASignatureType { + EIP155_TRANSACTION, + ETH_SIGNED_MESSAGE + } + + enum QueueOrigin { + SEQUENCER_QUEUE, + L1TOL2_QUEUE + } + + + /*********** + * Structs * + ***********/ + + struct Account { + uint256 nonce; + uint256 balance; + bytes32 storageRoot; + bytes32 codeHash; + address ethAddress; + bool isFresh; + } + + struct EVMAccount { + uint256 nonce; + uint256 balance; + bytes32 storageRoot; + bytes32 codeHash; + } + + struct ChainBatchHeader { + uint256 batchIndex; + bytes32 batchRoot; + uint256 batchSize; + uint256 prevTotalElements; + bytes extraData; + } + + struct ChainInclusionProof { + uint256 index; + bytes32[] siblings; + } + + struct Transaction { + uint256 timestamp; + uint256 blockNumber; + QueueOrigin l1QueueOrigin; + address l1TxOrigin; + address entrypoint; + uint256 gasLimit; + bytes data; + } + + struct TransactionChainElement { + bool isSequenced; + uint256 queueIndex; // QUEUED TX ONLY + uint256 timestamp; // SEQUENCER TX ONLY + uint256 blockNumber; // SEQUENCER TX ONLY + bytes txData; // SEQUENCER TX ONLY + } + + struct QueueElement { + bytes32 transactionHash; + uint40 timestamp; + uint40 blockNumber; + } + + struct EIP155Transaction { + uint256 nonce; + uint256 gasPrice; + uint256 gasLimit; + address to; + uint256 value; + bytes data; + uint256 chainId; + } + + + /********************** + * Internal Functions * + **********************/ + + /** + * Decodes an EOA transaction (i.e., native Ethereum RLP encoding). + * @param _transaction Encoded EOA transaction. + * @return Transaction decoded into a struct. + */ + function decodeEIP155Transaction( + bytes memory _transaction, + bool _isEthSignedMessage + ) + internal + pure + returns ( + EIP155Transaction memory + ) + { + if (_isEthSignedMessage) { + ( + uint256 _nonce, + uint256 _gasLimit, + uint256 _gasPrice, + uint256 _chainId, + address _to, + bytes memory _data + ) = abi.decode( + _transaction, + (uint256, uint256, uint256, uint256, address ,bytes) + ); + return EIP155Transaction({ + nonce: _nonce, + gasPrice: _gasPrice, + gasLimit: _gasLimit, + to: _to, + value: 0, + data: _data, + chainId: _chainId + }); + } else { + Lib_RLPReader.RLPItem[] memory decoded = Lib_RLPReader.readList(_transaction); + + return EIP155Transaction({ + nonce: Lib_RLPReader.readUint256(decoded[0]), + gasPrice: Lib_RLPReader.readUint256(decoded[1]), + gasLimit: Lib_RLPReader.readUint256(decoded[2]), + to: Lib_RLPReader.readAddress(decoded[3]), + value: Lib_RLPReader.readUint256(decoded[4]), + data: Lib_RLPReader.readBytes(decoded[5]), + chainId: Lib_RLPReader.readUint256(decoded[6]) + }); + } + } + + /** + * Decompresses a compressed EIP155 transaction. + * @param _transaction Compressed EIP155 transaction bytes. + * @return Transaction parsed into a struct. + */ + function decompressEIP155Transaction( + bytes memory _transaction + ) + internal + returns ( + EIP155Transaction memory + ) + { + return EIP155Transaction({ + gasLimit: Lib_BytesUtils.toUint24(_transaction, 0), + gasPrice: uint256(Lib_BytesUtils.toUint24(_transaction, 3)) * 1000000, + nonce: Lib_BytesUtils.toUint24(_transaction, 6), + to: Lib_BytesUtils.toAddress(_transaction, 9), + data: Lib_BytesUtils.slice(_transaction, 29), + chainId: Lib_SafeExecutionManagerWrapper.safeCHAINID(), + value: 0 + }); + } + + /** + * Encodes an EOA transaction back into the original transaction. + * @param _transaction EIP155transaction to encode. + * @param _isEthSignedMessage Whether or not this was an eth signed message. + * @return Encoded transaction. + */ + function encodeEIP155Transaction( + EIP155Transaction memory _transaction, + bool _isEthSignedMessage + ) + internal + pure + returns ( + bytes memory + ) + { + if (_isEthSignedMessage) { + return abi.encode( + _transaction.nonce, + _transaction.gasLimit, + _transaction.gasPrice, + _transaction.chainId, + _transaction.to, + _transaction.data + ); + } else { + bytes[] memory raw = new bytes[](9); + + raw[0] = Lib_RLPWriter.writeUint(_transaction.nonce); + raw[1] = Lib_RLPWriter.writeUint(_transaction.gasPrice); + raw[2] = Lib_RLPWriter.writeUint(_transaction.gasLimit); + if (_transaction.to == address(0)) { + raw[3] = Lib_RLPWriter.writeBytes(''); + } else { + raw[3] = Lib_RLPWriter.writeAddress(_transaction.to); + } + raw[4] = Lib_RLPWriter.writeUint(0); + raw[5] = Lib_RLPWriter.writeBytes(_transaction.data); + raw[6] = Lib_RLPWriter.writeUint(_transaction.chainId); + raw[7] = Lib_RLPWriter.writeBytes(bytes('')); + raw[8] = Lib_RLPWriter.writeBytes(bytes('')); + + return Lib_RLPWriter.writeList(raw); + } + } + + /** + * Encodes a standard OVM transaction. + * @param _transaction OVM transaction to encode. + * @return Encoded transaction bytes. + */ + function encodeTransaction( + Transaction memory _transaction + ) + internal + pure + returns ( + bytes memory + ) + { + return abi.encodePacked( + _transaction.timestamp, + _transaction.blockNumber, + _transaction.l1QueueOrigin, + _transaction.l1TxOrigin, + _transaction.entrypoint, + _transaction.gasLimit, + _transaction.data + ); + } + + /** + * Hashes a standard OVM transaction. + * @param _transaction OVM transaction to encode. + * @return Hashed transaction + */ + function hashTransaction( + Transaction memory _transaction + ) + internal + pure + returns ( + bytes32 + ) + { + return keccak256(encodeTransaction(_transaction)); + } + + /** + * Converts an OVM account to an EVM account. + * @param _in OVM account to convert. + * @return Converted EVM account. + */ + function toEVMAccount( + Account memory _in + ) + internal + pure + returns ( + EVMAccount memory + ) + { + return EVMAccount({ + nonce: _in.nonce, + balance: _in.balance, + storageRoot: _in.storageRoot, + codeHash: _in.codeHash + }); + } + + /** + * @notice RLP-encodes an account state struct. + * @param _account Account state struct. + * @return RLP-encoded account state. + */ + function encodeEVMAccount( + EVMAccount memory _account + ) + internal + pure + returns ( + bytes memory + ) + { + bytes[] memory raw = new bytes[](4); + + // Unfortunately we can't create this array outright because + // Lib_RLPWriter.writeList will reject fixed-size arrays. Assigning + // index-by-index circumvents this issue. + raw[0] = Lib_RLPWriter.writeBytes( + Lib_Bytes32Utils.removeLeadingZeros( + bytes32(_account.nonce) + ) + ); + raw[1] = Lib_RLPWriter.writeBytes( + Lib_Bytes32Utils.removeLeadingZeros( + bytes32(_account.balance) + ) + ); + raw[2] = Lib_RLPWriter.writeBytes(abi.encodePacked(_account.storageRoot)); + raw[3] = Lib_RLPWriter.writeBytes(abi.encodePacked(_account.codeHash)); + + return Lib_RLPWriter.writeList(raw); + } + + /** + * @notice Decodes an RLP-encoded account state into a useful struct. + * @param _encoded RLP-encoded account state. + * @return Account state struct. + */ + function decodeEVMAccount( + bytes memory _encoded + ) + internal + pure + returns ( + EVMAccount memory + ) + { + Lib_RLPReader.RLPItem[] memory accountState = Lib_RLPReader.readList(_encoded); + + return EVMAccount({ + nonce: Lib_RLPReader.readUint256(accountState[0]), + balance: Lib_RLPReader.readUint256(accountState[1]), + storageRoot: Lib_RLPReader.readBytes32(accountState[2]), + codeHash: Lib_RLPReader.readBytes32(accountState[3]) + }); + } + + /** + * Calculates a hash for a given batch header. + * @param _batchHeader Header to hash. + * @return Hash of the header. + */ + function hashBatchHeader( + Lib_OVMCodec.ChainBatchHeader memory _batchHeader + ) + internal + pure + returns ( + bytes32 + ) + { + return keccak256( + abi.encode( + _batchHeader.batchRoot, + _batchHeader.batchSize, + _batchHeader.prevTotalElements, + _batchHeader.extraData + ) + ); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_AddressManager.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_AddressManager.sol new file mode 100644 index 000000000000..ef78d3750c84 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_AddressManager.sol @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Contract Imports */ +import { Ownable } from "./Lib_Ownable.sol"; + +/** + * @title Lib_AddressManager + */ +contract Lib_AddressManager is Ownable { + + /********** + * Events * + **********/ + + event AddressSet( + string _name, + address _newAddress + ); + + /******************************************* + * Contract Variables: Internal Accounting * + *******************************************/ + + mapping (bytes32 => address) private addresses; + + + /******************** + * Public Functions * + ********************/ + + function setAddress( + string memory _name, + address _address + ) + public + onlyOwner + { + emit AddressSet(_name, _address); + addresses[_getNameHash(_name)] = _address; + } + + function getAddress( + string memory _name + ) + public + view + returns (address) + { + return addresses[_getNameHash(_name)]; + } + + + /********************** + * Internal Functions * + **********************/ + + function _getNameHash( + string memory _name + ) + internal + pure + returns ( + bytes32 _hash + ) + { + return keccak256(abi.encodePacked(_name)); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_AddressResolver.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_AddressResolver.sol new file mode 100644 index 000000000000..2b768d6b240e --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_AddressResolver.sol @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_AddressManager } from "./Lib_AddressManager.sol"; + +/** + * @title Lib_AddressResolver + */ +abstract contract Lib_AddressResolver { + + /******************************************* + * Contract Variables: Contract References * + *******************************************/ + + Lib_AddressManager public libAddressManager; + + + /*************** + * Constructor * + ***************/ + + /** + * @param _libAddressManager Address of the Lib_AddressManager. + */ + constructor( + address _libAddressManager + ) { + libAddressManager = Lib_AddressManager(_libAddressManager); + } + + + /******************** + * Public Functions * + ********************/ + + function resolve( + string memory _name + ) + public + view + returns ( + address _contract + ) + { + return libAddressManager.getAddress(_name); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_Ownable.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_Ownable.sol new file mode 100644 index 000000000000..8b08666d236c --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_Ownable.sol @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @title Ownable + * @dev Adapted from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol + */ +abstract contract Ownable { + + /************* + * Variables * + *************/ + + address public owner; + + + /********** + * Events * + **********/ + + event OwnershipTransferred( + address indexed previousOwner, + address indexed newOwner + ); + + + /*************** + * Constructor * + ***************/ + + constructor() { + owner = msg.sender; + emit OwnershipTransferred(address(0), owner); + } + + + /********************** + * Function Modifiers * + **********************/ + + modifier onlyOwner() { + require( + owner == msg.sender, + "Ownable: caller is not the owner" + ); + _; + } + + + /******************** + * Public Functions * + ********************/ + + function renounceOwnership() + public + virtual + onlyOwner + { + emit OwnershipTransferred(owner, address(0)); + owner = address(0); + } + + function transferOwnership(address _newOwner) + public + virtual + onlyOwner + { + require( + _newOwner != address(0), + "Ownable: new owner cannot be the zero address" + ); + + emit OwnershipTransferred(owner, _newOwner); + owner = _newOwner; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_ResolvedDelegateProxy.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_ResolvedDelegateProxy.sol new file mode 100644 index 000000000000..18a0bb935a10 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_ResolvedDelegateProxy.sol @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_AddressManager } from "./Lib_AddressManager.sol"; + +/** + * @title Lib_ResolvedDelegateProxy + */ +contract Lib_ResolvedDelegateProxy { + + /************* + * Variables * + *************/ + + + // Using mappings to store fields to avoid overwriting storage slots in the + // implementation contract. For example, instead of storing these fields at + // storage slot `0` & `1`, they are stored at `keccak256(key + slot)`. + // See: https://solidity.readthedocs.io/en/v0.7.0/internals/layout_in_storage.html + // NOTE: Do not use this code in your own contract system. + // There is a known flaw in this contract, and we will remove it from the repository + // in the near future. Due to the very limited way that we are using it, this flaw is + // not an issue in our system. + mapping(address=>string) private implementationName; + mapping(address=>Lib_AddressManager) private addressManager; + + + /*************** + * Constructor * + ***************/ + + /** + * @param _libAddressManager Address of the Lib_AddressManager. + * @param _implementationName implementationName of the contract to proxy to. + */ + constructor( + address _libAddressManager, + string memory _implementationName + ) + { + addressManager[address(this)] = Lib_AddressManager(_libAddressManager); + implementationName[address(this)] = _implementationName; + } + + + /********************* + * Fallback Function * + *********************/ + + fallback() + external + { + address target = addressManager[address(this)].getAddress((implementationName[address(this)])); + require( + target != address(0), + "Target address must be initialized." + ); + + (bool success, bytes memory returndata) = target.delegatecall(msg.data); + + if (success == true) { + assembly { + return(add(returndata, 0x20), mload(returndata)) + } + } else { + assembly { + revert(add(returndata, 0x20), mload(returndata)) + } + } + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/rlp/Lib_RLPReader.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/rlp/Lib_RLPReader.sol new file mode 100644 index 000000000000..5e81c5de2ae6 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/rlp/Lib_RLPReader.sol @@ -0,0 +1,625 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @title Lib_RLPReader + * @dev Adapted from "RLPReader" by Hamdi Allam (hamdi.allam97@gmail.com). + */ +library Lib_RLPReader { + + /************* + * Constants * + *************/ + + uint256 constant internal MAX_LIST_LENGTH = 32; + + + /********* + * Enums * + *********/ + + enum RLPItemType { + DATA_ITEM, + LIST_ITEM + } + + + /*********** + * Structs * + ***********/ + + struct RLPItem { + uint256 length; + uint256 ptr; + } + + + /********************** + * Internal Functions * + **********************/ + + /** + * Converts bytes to a reference to memory position and length. + * @param _in Input bytes to convert. + * @return Output memory reference. + */ + function toRLPItem( + bytes memory _in + ) + internal + pure + returns ( + RLPItem memory + ) + { + uint256 ptr; + assembly { + ptr := add(_in, 32) + } + + return RLPItem({ + length: _in.length, + ptr: ptr + }); + } + + /** + * Reads an RLP list value into a list of RLP items. + * @param _in RLP list value. + * @return Decoded RLP list items. + */ + function readList( + RLPItem memory _in + ) + internal + pure + returns ( + RLPItem[] memory + ) + { + ( + uint256 listOffset, + , + RLPItemType itemType + ) = _decodeLength(_in); + + require( + itemType == RLPItemType.LIST_ITEM, + "Invalid RLP list value." + ); + + // Solidity in-memory arrays can't be increased in size, but *can* be decreased in size by + // writing to the length. Since we can't know the number of RLP items without looping over + // the entire input, we'd have to loop twice to accurately size this array. It's easier to + // simply set a reasonable maximum list length and decrease the size before we finish. + RLPItem[] memory out = new RLPItem[](MAX_LIST_LENGTH); + + uint256 itemCount = 0; + uint256 offset = listOffset; + while (offset < _in.length) { + require( + itemCount < MAX_LIST_LENGTH, + "Provided RLP list exceeds max list length." + ); + + ( + uint256 itemOffset, + uint256 itemLength, + ) = _decodeLength(RLPItem({ + length: _in.length - offset, + ptr: _in.ptr + offset + })); + + out[itemCount] = RLPItem({ + length: itemLength + itemOffset, + ptr: _in.ptr + offset + }); + + itemCount += 1; + offset += itemOffset + itemLength; + } + + // Decrease the array size to match the actual item count. + assembly { + mstore(out, itemCount) + } + + return out; + } + + /** + * Reads an RLP list value into a list of RLP items. + * @param _in RLP list value. + * @return Decoded RLP list items. + */ + function readList( + bytes memory _in + ) + internal + pure + returns ( + RLPItem[] memory + ) + { + return readList( + toRLPItem(_in) + ); + } + + /** + * Reads an RLP bytes value into bytes. + * @param _in RLP bytes value. + * @return Decoded bytes. + */ + function readBytes( + RLPItem memory _in + ) + internal + pure + returns ( + bytes memory + ) + { + ( + uint256 itemOffset, + uint256 itemLength, + RLPItemType itemType + ) = _decodeLength(_in); + + require( + itemType == RLPItemType.DATA_ITEM, + "Invalid RLP bytes value." + ); + + return _copy(_in.ptr, itemOffset, itemLength); + } + + /** + * Reads an RLP bytes value into bytes. + * @param _in RLP bytes value. + * @return Decoded bytes. + */ + function readBytes( + bytes memory _in + ) + internal + pure + returns ( + bytes memory + ) + { + return readBytes( + toRLPItem(_in) + ); + } + + /** + * Reads an RLP string value into a string. + * @param _in RLP string value. + * @return Decoded string. + */ + function readString( + RLPItem memory _in + ) + internal + pure + returns ( + string memory + ) + { + return string(readBytes(_in)); + } + + /** + * Reads an RLP string value into a string. + * @param _in RLP string value. + * @return Decoded string. + */ + function readString( + bytes memory _in + ) + internal + pure + returns ( + string memory + ) + { + return readString( + toRLPItem(_in) + ); + } + + /** + * Reads an RLP bytes32 value into a bytes32. + * @param _in RLP bytes32 value. + * @return Decoded bytes32. + */ + function readBytes32( + RLPItem memory _in + ) + internal + pure + returns ( + bytes32 + ) + { + require( + _in.length <= 33, + "Invalid RLP bytes32 value." + ); + + ( + uint256 itemOffset, + uint256 itemLength, + RLPItemType itemType + ) = _decodeLength(_in); + + require( + itemType == RLPItemType.DATA_ITEM, + "Invalid RLP bytes32 value." + ); + + uint256 ptr = _in.ptr + itemOffset; + bytes32 out; + assembly { + out := mload(ptr) + + // Shift the bytes over to match the item size. + if lt(itemLength, 32) { + out := div(out, exp(256, sub(32, itemLength))) + } + } + + return out; + } + + /** + * Reads an RLP bytes32 value into a bytes32. + * @param _in RLP bytes32 value. + * @return Decoded bytes32. + */ + function readBytes32( + bytes memory _in + ) + internal + pure + returns ( + bytes32 + ) + { + return readBytes32( + toRLPItem(_in) + ); + } + + /** + * Reads an RLP uint256 value into a uint256. + * @param _in RLP uint256 value. + * @return Decoded uint256. + */ + function readUint256( + RLPItem memory _in + ) + internal + pure + returns ( + uint256 + ) + { + return uint256(readBytes32(_in)); + } + + /** + * Reads an RLP uint256 value into a uint256. + * @param _in RLP uint256 value. + * @return Decoded uint256. + */ + function readUint256( + bytes memory _in + ) + internal + pure + returns ( + uint256 + ) + { + return readUint256( + toRLPItem(_in) + ); + } + + /** + * Reads an RLP bool value into a bool. + * @param _in RLP bool value. + * @return Decoded bool. + */ + function readBool( + RLPItem memory _in + ) + internal + pure + returns ( + bool + ) + { + require( + _in.length == 1, + "Invalid RLP boolean value." + ); + + uint256 ptr = _in.ptr; + uint256 out; + assembly { + out := byte(0, mload(ptr)) + } + + require( + out == 0 || out == 1, + "Lib_RLPReader: Invalid RLP boolean value, must be 0 or 1" + ); + + return out != 0; + } + + /** + * Reads an RLP bool value into a bool. + * @param _in RLP bool value. + * @return Decoded bool. + */ + function readBool( + bytes memory _in + ) + internal + pure + returns ( + bool + ) + { + return readBool( + toRLPItem(_in) + ); + } + + /** + * Reads an RLP address value into a address. + * @param _in RLP address value. + * @return Decoded address. + */ + function readAddress( + RLPItem memory _in + ) + internal + pure + returns ( + address + ) + { + if (_in.length == 1) { + return address(0); + } + + require( + _in.length == 21, + "Invalid RLP address value." + ); + + return address(readUint256(_in)); + } + + /** + * Reads an RLP address value into a address. + * @param _in RLP address value. + * @return Decoded address. + */ + function readAddress( + bytes memory _in + ) + internal + pure + returns ( + address + ) + { + return readAddress( + toRLPItem(_in) + ); + } + + /** + * Reads the raw bytes of an RLP item. + * @param _in RLP item to read. + * @return Raw RLP bytes. + */ + function readRawBytes( + RLPItem memory _in + ) + internal + pure + returns ( + bytes memory + ) + { + return _copy(_in); + } + + + /********************* + * Private Functions * + *********************/ + + /** + * Decodes the length of an RLP item. + * @param _in RLP item to decode. + * @return Offset of the encoded data. + * @return Length of the encoded data. + * @return RLP item type (LIST_ITEM or DATA_ITEM). + */ + function _decodeLength( + RLPItem memory _in + ) + private + pure + returns ( + uint256, + uint256, + RLPItemType + ) + { + require( + _in.length > 0, + "RLP item cannot be null." + ); + + uint256 ptr = _in.ptr; + uint256 prefix; + assembly { + prefix := byte(0, mload(ptr)) + } + + if (prefix <= 0x7f) { + // Single byte. + + return (0, 1, RLPItemType.DATA_ITEM); + } else if (prefix <= 0xb7) { + // Short string. + + uint256 strLen = prefix - 0x80; + + require( + _in.length > strLen, + "Invalid RLP short string." + ); + + return (1, strLen, RLPItemType.DATA_ITEM); + } else if (prefix <= 0xbf) { + // Long string. + uint256 lenOfStrLen = prefix - 0xb7; + + require( + _in.length > lenOfStrLen, + "Invalid RLP long string length." + ); + + uint256 strLen; + assembly { + // Pick out the string length. + strLen := div( + mload(add(ptr, 1)), + exp(256, sub(32, lenOfStrLen)) + ) + } + + require( + _in.length > lenOfStrLen + strLen, + "Invalid RLP long string." + ); + + return (1 + lenOfStrLen, strLen, RLPItemType.DATA_ITEM); + } else if (prefix <= 0xf7) { + // Short list. + uint256 listLen = prefix - 0xc0; + + require( + _in.length > listLen, + "Invalid RLP short list." + ); + + return (1, listLen, RLPItemType.LIST_ITEM); + } else { + // Long list. + uint256 lenOfListLen = prefix - 0xf7; + + require( + _in.length > lenOfListLen, + "Invalid RLP long list length." + ); + + uint256 listLen; + assembly { + // Pick out the list length. + listLen := div( + mload(add(ptr, 1)), + exp(256, sub(32, lenOfListLen)) + ) + } + + require( + _in.length > lenOfListLen + listLen, + "Invalid RLP long list." + ); + + return (1 + lenOfListLen, listLen, RLPItemType.LIST_ITEM); + } + } + + /** + * Copies the bytes from a memory location. + * @param _src Pointer to the location to read from. + * @param _offset Offset to start reading from. + * @param _length Number of bytes to read. + * @return Copied bytes. + */ + function _copy( + uint256 _src, + uint256 _offset, + uint256 _length + ) + private + pure + returns ( + bytes memory + ) + { + bytes memory out = new bytes(_length); + if (out.length == 0) { + return out; + } + + uint256 src = _src + _offset; + uint256 dest; + assembly { + dest := add(out, 32) + } + + // Copy over as many complete words as we can. + for (uint256 i = 0; i < _length / 32; i++) { + assembly { + mstore(dest, mload(src)) + } + + src += 32; + dest += 32; + } + + // Pick out the remaining bytes. + uint256 mask = 256 ** (32 - (_length % 32)) - 1; + assembly { + mstore( + dest, + or( + and(mload(src), not(mask)), + and(mload(dest), mask) + ) + ) + } + + return out; + } + + /** + * Copies an RLP item into bytes. + * @param _in RLP item to copy. + * @return Copied bytes. + */ + function _copy( + RLPItem memory _in + ) + private + pure + returns ( + bytes memory + ) + { + return _copy(_in.ptr, 0, _in.length); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/rlp/Lib_RLPWriter.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/rlp/Lib_RLPWriter.sol new file mode 100644 index 000000000000..8040eac0a2fa --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/rlp/Lib_RLPWriter.sol @@ -0,0 +1,283 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_BytesUtils } from "../utils/Lib_BytesUtils.sol"; + +/** + * @title Lib_RLPWriter + * @author Bakaoh (with modifications) + */ +library Lib_RLPWriter { + + /********************** + * Internal Functions * + **********************/ + + /** + * RLP encodes a byte string. + * @param _in The byte string to encode. + * @return _out The RLP encoded string in bytes. + */ + function writeBytes( + bytes memory _in + ) + internal + pure + returns ( + bytes memory _out + ) + { + bytes memory encoded; + + if (_in.length == 1 && uint8(_in[0]) < 128) { + encoded = _in; + } else { + encoded = abi.encodePacked(_writeLength(_in.length, 128), _in); + } + + return encoded; + } + + /** + * RLP encodes a list of RLP encoded byte byte strings. + * @param _in The list of RLP encoded byte strings. + * @return _out The RLP encoded list of items in bytes. + */ + function writeList( + bytes[] memory _in + ) + internal + pure + returns ( + bytes memory _out + ) + { + bytes memory list = _flatten(_in); + return abi.encodePacked(_writeLength(list.length, 192), list); + } + + /** + * RLP encodes a string. + * @param _in The string to encode. + * @return _out The RLP encoded string in bytes. + */ + function writeString( + string memory _in + ) + internal + pure + returns ( + bytes memory _out + ) + { + return writeBytes(bytes(_in)); + } + + /** + * RLP encodes an address. + * @param _in The address to encode. + * @return _out The RLP encoded address in bytes. + */ + function writeAddress( + address _in + ) + internal + pure + returns ( + bytes memory _out + ) + { + return writeBytes(abi.encodePacked(_in)); + } + + /** + * RLP encodes a uint. + * @param _in The uint256 to encode. + * @return _out The RLP encoded uint256 in bytes. + */ + function writeUint( + uint256 _in + ) + internal + pure + returns ( + bytes memory _out + ) + { + return writeBytes(_toBinary(_in)); + } + + /** + * RLP encodes a bool. + * @param _in The bool to encode. + * @return _out The RLP encoded bool in bytes. + */ + function writeBool( + bool _in + ) + internal + pure + returns ( + bytes memory _out + ) + { + bytes memory encoded = new bytes(1); + encoded[0] = (_in ? bytes1(0x01) : bytes1(0x80)); + return encoded; + } + + + /********************* + * Private Functions * + *********************/ + + /** + * Encode the first byte, followed by the `len` in binary form if `length` is more than 55. + * @param _len The length of the string or the payload. + * @param _offset 128 if item is string, 192 if item is list. + * @return _encoded RLP encoded bytes. + */ + function _writeLength( + uint256 _len, + uint256 _offset + ) + private + pure + returns ( + bytes memory _encoded + ) + { + bytes memory encoded; + + if (_len < 56) { + encoded = new bytes(1); + encoded[0] = byte(uint8(_len) + uint8(_offset)); + } else { + uint256 lenLen; + uint256 i = 1; + while (_len / i != 0) { + lenLen++; + i *= 256; + } + + encoded = new bytes(lenLen + 1); + encoded[0] = byte(uint8(lenLen) + uint8(_offset) + 55); + for(i = 1; i <= lenLen; i++) { + encoded[i] = byte(uint8((_len / (256**(lenLen-i))) % 256)); + } + } + + return encoded; + } + + /** + * Encode integer in big endian binary form with no leading zeroes. + * @notice TODO: This should be optimized with assembly to save gas costs. + * @param _x The integer to encode. + * @return _binary RLP encoded bytes. + */ + function _toBinary( + uint256 _x + ) + private + pure + returns ( + bytes memory _binary + ) + { + bytes memory b = abi.encodePacked(_x); + + uint256 i = 0; + for (; i < 32; i++) { + if (b[i] != 0) { + break; + } + } + + bytes memory res = new bytes(32 - i); + for (uint256 j = 0; j < res.length; j++) { + res[j] = b[i++]; + } + + return res; + } + + /** + * Copies a piece of memory to another location. + * @notice From: https://github.com/Arachnid/solidity-stringutils/blob/master/src/strings.sol. + * @param _dest Destination location. + * @param _src Source location. + * @param _len Length of memory to copy. + */ + function _memcpy( + uint256 _dest, + uint256 _src, + uint256 _len + ) + private + pure + { + uint256 dest = _dest; + uint256 src = _src; + uint256 len = _len; + + for(; len >= 32; len -= 32) { + assembly { + mstore(dest, mload(src)) + } + dest += 32; + src += 32; + } + + uint256 mask = 256 ** (32 - len) - 1; + assembly { + let srcpart := and(mload(src), not(mask)) + let destpart := and(mload(dest), mask) + mstore(dest, or(destpart, srcpart)) + } + } + + /** + * Flattens a list of byte strings into one byte string. + * @notice From: https://github.com/sammayo/solidity-rlp-encoder/blob/master/RLPEncode.sol. + * @param _list List of byte strings to flatten. + * @return _flattened The flattened byte string. + */ + function _flatten( + bytes[] memory _list + ) + private + pure + returns ( + bytes memory _flattened + ) + { + if (_list.length == 0) { + return new bytes(0); + } + + uint256 len; + uint256 i = 0; + for (; i < _list.length; i++) { + len += _list[i].length; + } + + bytes memory flattened = new bytes(len); + uint256 flattenedPtr; + assembly { flattenedPtr := add(flattened, 0x20) } + + for(i = 0; i < _list.length; i++) { + bytes memory item = _list[i]; + + uint256 listPtr; + assembly { listPtr := add(item, 0x20)} + + _memcpy(flattenedPtr, listPtr, item.length); + flattenedPtr += _list[i].length; + } + + return flattened; + } +} \ No newline at end of file diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/standards/IUniswapV2ERC20.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/standards/IUniswapV2ERC20.sol new file mode 100644 index 000000000000..f83dae349771 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/standards/IUniswapV2ERC20.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.5.16 <0.8.0; + +interface IUniswapV2ERC20 { + event Approval(address indexed owner, address indexed spender, uint value); + event Transfer(address indexed from, address indexed to, uint value); + + function name() external view returns (string memory); + function symbol() external view returns (string memory); + function decimals() external view returns (uint8); + function totalSupply() external view returns (uint); + function balanceOf(address owner) external view returns (uint); + function allowance(address owner, address spender) external view returns (uint); + + function approve(address spender, uint value) external returns (bool); + function transfer(address to, uint value) external returns (bool); + function transferFrom(address from, address to, uint value) external returns (bool); + + function DOMAIN_SEPARATOR() external view returns (bytes32); + function PERMIT_TYPEHASH() external pure returns (bytes32); + function nonces(address owner) external view returns (uint); + + function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/standards/UniSafeMath.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/standards/UniSafeMath.sol new file mode 100644 index 000000000000..de87bab5d72d --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/standards/UniSafeMath.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.5.16 <0.8.0; + +// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) + +library UniSafeMath { + function add(uint x, uint y) internal pure returns (uint z) { + require((z = x + y) >= x, 'ds-math-add-overflow'); + } + + function sub(uint x, uint y) internal pure returns (uint z) { + require((z = x - y) <= x, 'ds-math-sub-underflow'); + } + + function mul(uint x, uint y) internal pure returns (uint z) { + require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow'); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/standards/UniswapV2ERC20.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/standards/UniswapV2ERC20.sol new file mode 100644 index 000000000000..303d53484bd5 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/standards/UniswapV2ERC20.sol @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.5.16 <0.8.0; + +import './IUniswapV2ERC20.sol'; +import './UniSafeMath.sol'; + +contract UniswapV2ERC20 is IUniswapV2ERC20 { + using UniSafeMath for uint; + + string public override name; + string public override symbol; + uint8 public constant override decimals = 18; + uint public override totalSupply; + mapping(address => uint) public override balanceOf; + mapping(address => mapping(address => uint)) public override allowance; + + bytes32 public override DOMAIN_SEPARATOR; + // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); + bytes32 public constant override PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; + mapping(address => uint) public override nonces; + + constructor( + string memory _name, + string memory _symbol + ) { + name = _name; + symbol = _symbol; + + uint chainId; + assembly { + chainId := chainid() + } + DOMAIN_SEPARATOR = keccak256( + abi.encode( + keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'), + keccak256(bytes(name)), + keccak256(bytes('1')), + chainId, + address(this) + ) + ); + } + + function _mint(address to, uint value) internal { + totalSupply = totalSupply.add(value); + balanceOf[to] = balanceOf[to].add(value); + emit Transfer(address(0), to, value); + } + + function _burn(address from, uint value) internal { + balanceOf[from] = balanceOf[from].sub(value); + totalSupply = totalSupply.sub(value); + emit Transfer(from, address(0), value); + } + + function _approve(address owner, address spender, uint value) private { + allowance[owner][spender] = value; + emit Approval(owner, spender, value); + } + + function _transfer(address from, address to, uint value) private { + balanceOf[from] = balanceOf[from].sub(value); + balanceOf[to] = balanceOf[to].add(value); + emit Transfer(from, to, value); + } + + function approve(address spender, uint value) external override returns (bool) { + _approve(msg.sender, spender, value); + return true; + } + + function transfer(address to, uint value) external override returns (bool) { + _transfer(msg.sender, to, value); + return true; + } + + function transferFrom(address from, address to, uint value) external override returns (bool) { + if (allowance[from][msg.sender] != uint(-1)) { + allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); + } + _transfer(from, to, value); + return true; + } + + function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external override { + require(deadline >= block.timestamp, 'UniswapV2: EXPIRED'); + bytes32 digest = keccak256( + abi.encodePacked( + '\x19\x01', + DOMAIN_SEPARATOR, + keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) + ) + ); + address recoveredAddress = ecrecover(digest, v, r, s); + require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE'); + _approve(owner, spender, value); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/trie/Lib_MerkleTrie.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/trie/Lib_MerkleTrie.sol new file mode 100644 index 000000000000..6b873fcbe517 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/trie/Lib_MerkleTrie.sol @@ -0,0 +1,960 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_BytesUtils } from "../utils/Lib_BytesUtils.sol"; +import { Lib_RLPReader } from "../rlp/Lib_RLPReader.sol"; +import { Lib_RLPWriter } from "../rlp/Lib_RLPWriter.sol"; + +/** + * @title Lib_MerkleTrie + */ +library Lib_MerkleTrie { + + /******************* + * Data Structures * + *******************/ + + enum NodeType { + BranchNode, + ExtensionNode, + LeafNode + } + + struct TrieNode { + bytes encoded; + Lib_RLPReader.RLPItem[] decoded; + } + + + /********************** + * Contract Constants * + **********************/ + + // TREE_RADIX determines the number of elements per branch node. + uint256 constant TREE_RADIX = 16; + // Branch nodes have TREE_RADIX elements plus an additional `value` slot. + uint256 constant BRANCH_NODE_LENGTH = TREE_RADIX + 1; + // Leaf nodes and extension nodes always have two elements, a `path` and a `value`. + uint256 constant LEAF_OR_EXTENSION_NODE_LENGTH = 2; + + // Prefixes are prepended to the `path` within a leaf or extension node and + // allow us to differentiate between the two node types. `ODD` or `EVEN` is + // determined by the number of nibbles within the unprefixed `path`. If the + // number of nibbles if even, we need to insert an extra padding nibble so + // the resulting prefixed `path` has an even number of nibbles. + uint8 constant PREFIX_EXTENSION_EVEN = 0; + uint8 constant PREFIX_EXTENSION_ODD = 1; + uint8 constant PREFIX_LEAF_EVEN = 2; + uint8 constant PREFIX_LEAF_ODD = 3; + + // Just a utility constant. RLP represents `NULL` as 0x80. + bytes1 constant RLP_NULL = bytes1(0x80); + bytes constant RLP_NULL_BYTES = hex'80'; + bytes32 constant internal KECCAK256_RLP_NULL_BYTES = keccak256(RLP_NULL_BYTES); + + + /********************** + * Internal Functions * + **********************/ + + /** + * @notice Verifies a proof that a given key/value pair is present in the + * Merkle trie. + * @param _key Key of the node to search for, as a hex string. + * @param _value Value of the node to search for, as a hex string. + * @param _proof Merkle trie inclusion proof for the desired node. Unlike + * traditional Merkle trees, this proof is executed top-down and consists + * of a list of RLP-encoded nodes that make a path down to the target node. + * @param _root Known root of the Merkle trie. Used to verify that the + * included proof is correctly constructed. + * @return _verified `true` if the k/v pair exists in the trie, `false` otherwise. + */ + function verifyInclusionProof( + bytes memory _key, + bytes memory _value, + bytes memory _proof, + bytes32 _root + ) + internal + pure + returns ( + bool _verified + ) + { + ( + bool exists, + bytes memory value + ) = get(_key, _proof, _root); + + return ( + exists && Lib_BytesUtils.equal(_value, value) + ); + } + + /** + * @notice Verifies a proof that a given key is *not* present in + * the Merkle trie. + * @param _key Key of the node to search for, as a hex string. + * @param _proof Merkle trie inclusion proof for the node *nearest* the + * target node. + * @param _root Known root of the Merkle trie. Used to verify that the + * included proof is correctly constructed. + * @return _verified `true` if the key is absent in the trie, `false` otherwise. + */ + function verifyExclusionProof( + bytes memory _key, + bytes memory _proof, + bytes32 _root + ) + internal + pure + returns ( + bool _verified + ) + { + ( + bool exists, + ) = get(_key, _proof, _root); + + return exists == false; + } + + /** + * @notice Updates a Merkle trie and returns a new root hash. + * @param _key Key of the node to update, as a hex string. + * @param _value Value of the node to update, as a hex string. + * @param _proof Merkle trie inclusion proof for the node *nearest* the + * target node. If the key exists, we can simply update the value. + * Otherwise, we need to modify the trie to handle the new k/v pair. + * @param _root Known root of the Merkle trie. Used to verify that the + * included proof is correctly constructed. + * @return _updatedRoot Root hash of the newly constructed trie. + */ + function update( + bytes memory _key, + bytes memory _value, + bytes memory _proof, + bytes32 _root + ) + internal + pure + returns ( + bytes32 _updatedRoot + ) + { + // Special case when inserting the very first node. + if (_root == KECCAK256_RLP_NULL_BYTES) { + return getSingleNodeRootHash(_key, _value); + } + + TrieNode[] memory proof = _parseProof(_proof); + (uint256 pathLength, bytes memory keyRemainder, ) = _walkNodePath(proof, _key, _root); + TrieNode[] memory newPath = _getNewPath(proof, pathLength, keyRemainder, _value); + + return _getUpdatedTrieRoot(newPath, _key); + } + + /** + * @notice Retrieves the value associated with a given key. + * @param _key Key to search for, as hex bytes. + * @param _proof Merkle trie inclusion proof for the key. + * @param _root Known root of the Merkle trie. + * @return _exists Whether or not the key exists. + * @return _value Value of the key if it exists. + */ + function get( + bytes memory _key, + bytes memory _proof, + bytes32 _root + ) + internal + pure + returns ( + bool _exists, + bytes memory _value + ) + { + TrieNode[] memory proof = _parseProof(_proof); + (uint256 pathLength, bytes memory keyRemainder, bool isFinalNode) = _walkNodePath(proof, _key, _root); + + bool exists = keyRemainder.length == 0; + + require( + exists || isFinalNode, + "Provided proof is invalid." + ); + + bytes memory value = exists ? _getNodeValue(proof[pathLength - 1]) : bytes(''); + + return ( + exists, + value + ); + } + + /** + * Computes the root hash for a trie with a single node. + * @param _key Key for the single node. + * @param _value Value for the single node. + * @return _updatedRoot Hash of the trie. + */ + function getSingleNodeRootHash( + bytes memory _key, + bytes memory _value + ) + internal + pure + returns ( + bytes32 _updatedRoot + ) + { + return keccak256(_makeLeafNode( + Lib_BytesUtils.toNibbles(_key), + _value + ).encoded); + } + + + /********************* + * Private Functions * + *********************/ + + /** + * @notice Walks through a proof using a provided key. + * @param _proof Inclusion proof to walk through. + * @param _key Key to use for the walk. + * @param _root Known root of the trie. + * @return _pathLength Length of the final path + * @return _keyRemainder Portion of the key remaining after the walk. + * @return _isFinalNode Whether or not we've hit a dead end. + */ + function _walkNodePath( + TrieNode[] memory _proof, + bytes memory _key, + bytes32 _root + ) + private + pure + returns ( + uint256 _pathLength, + bytes memory _keyRemainder, + bool _isFinalNode + ) + { + uint256 pathLength = 0; + bytes memory key = Lib_BytesUtils.toNibbles(_key); + + bytes32 currentNodeID = _root; + uint256 currentKeyIndex = 0; + uint256 currentKeyIncrement = 0; + TrieNode memory currentNode; + + // Proof is top-down, so we start at the first element (root). + for (uint256 i = 0; i < _proof.length; i++) { + currentNode = _proof[i]; + currentKeyIndex += currentKeyIncrement; + + // Keep track of the proof elements we actually need. + // It's expensive to resize arrays, so this simply reduces gas costs. + pathLength += 1; + + if (currentKeyIndex == 0) { + // First proof element is always the root node. + require( + keccak256(currentNode.encoded) == currentNodeID, + "Invalid root hash" + ); + } else if (currentNode.encoded.length >= 32) { + // Nodes 32 bytes or larger are hashed inside branch nodes. + require( + keccak256(currentNode.encoded) == currentNodeID, + "Invalid large internal hash" + ); + } else { + // Nodes smaller than 31 bytes aren't hashed. + require( + Lib_BytesUtils.toBytes32(currentNode.encoded) == currentNodeID, + "Invalid internal node hash" + ); + } + + if (currentNode.decoded.length == BRANCH_NODE_LENGTH) { + if (currentKeyIndex == key.length) { + // We've hit the end of the key, meaning the value should be within this branch node. + break; + } else { + // We're not at the end of the key yet. + // Figure out what the next node ID should be and continue. + uint8 branchKey = uint8(key[currentKeyIndex]); + Lib_RLPReader.RLPItem memory nextNode = currentNode.decoded[branchKey]; + currentNodeID = _getNodeID(nextNode); + currentKeyIncrement = 1; + continue; + } + } else if (currentNode.decoded.length == LEAF_OR_EXTENSION_NODE_LENGTH) { + bytes memory path = _getNodePath(currentNode); + uint8 prefix = uint8(path[0]); + uint8 offset = 2 - prefix % 2; + bytes memory pathRemainder = Lib_BytesUtils.slice(path, offset); + bytes memory keyRemainder = Lib_BytesUtils.slice(key, currentKeyIndex); + uint256 sharedNibbleLength = _getSharedNibbleLength(pathRemainder, keyRemainder); + + if (prefix == PREFIX_LEAF_EVEN || prefix == PREFIX_LEAF_ODD) { + if ( + pathRemainder.length == sharedNibbleLength && + keyRemainder.length == sharedNibbleLength + ) { + // The key within this leaf matches our key exactly. + // Increment the key index to reflect that we have no remainder. + currentKeyIndex += sharedNibbleLength; + } + + // We've hit a leaf node, so our next node should be NULL. + currentNodeID = bytes32(RLP_NULL); + break; + } else if (prefix == PREFIX_EXTENSION_EVEN || prefix == PREFIX_EXTENSION_ODD) { + if (sharedNibbleLength == 0) { + // Our extension node doesn't share any part of our key. + // We've hit the end of this path, updates will need to modify this extension. + currentNodeID = bytes32(RLP_NULL); + break; + } else { + // Our extension shares some nibbles. + // Carry on to the next node. + currentNodeID = _getNodeID(currentNode.decoded[1]); + currentKeyIncrement = sharedNibbleLength; + continue; + } + } else { + revert("Received a node with an unknown prefix"); + } + } else { + revert("Received an unparseable node."); + } + } + + // If our node ID is NULL, then we're at a dead end. + bool isFinalNode = currentNodeID == bytes32(RLP_NULL); + return (pathLength, Lib_BytesUtils.slice(key, currentKeyIndex), isFinalNode); + } + + /** + * @notice Creates new nodes to support a k/v pair insertion into a given + * Merkle trie path. + * @param _path Path to the node nearest the k/v pair. + * @param _pathLength Length of the path. Necessary because the provided + * path may include additional nodes (e.g., it comes directly from a proof) + * and we can't resize in-memory arrays without costly duplication. + * @param _keyRemainder Portion of the initial key that must be inserted + * into the trie. + * @param _value Value to insert at the given key. + * @return _newPath A new path with the inserted k/v pair and extra supporting nodes. + */ + function _getNewPath( + TrieNode[] memory _path, + uint256 _pathLength, + bytes memory _keyRemainder, + bytes memory _value + ) + private + pure + returns ( + TrieNode[] memory _newPath + ) + { + bytes memory keyRemainder = _keyRemainder; + + // Most of our logic depends on the status of the last node in the path. + TrieNode memory lastNode = _path[_pathLength - 1]; + NodeType lastNodeType = _getNodeType(lastNode); + + // Create an array for newly created nodes. + // We need up to three new nodes, depending on the contents of the last node. + // Since array resizing is expensive, we'll keep track of the size manually. + // We're using an explicit `totalNewNodes += 1` after insertions for clarity. + TrieNode[] memory newNodes = new TrieNode[](3); + uint256 totalNewNodes = 0; + + if (keyRemainder.length == 0 && lastNodeType == NodeType.LeafNode) { + // We've found a leaf node with the given key. + // Simply need to update the value of the node to match. + newNodes[totalNewNodes] = _makeLeafNode(_getNodeKey(lastNode), _value); + totalNewNodes += 1; + } else if (lastNodeType == NodeType.BranchNode) { + if (keyRemainder.length == 0) { + // We've found a branch node with the given key. + // Simply need to update the value of the node to match. + newNodes[totalNewNodes] = _editBranchValue(lastNode, _value); + totalNewNodes += 1; + } else { + // We've found a branch node, but it doesn't contain our key. + // Reinsert the old branch for now. + newNodes[totalNewNodes] = lastNode; + totalNewNodes += 1; + // Create a new leaf node, slicing our remainder since the first byte points + // to our branch node. + newNodes[totalNewNodes] = _makeLeafNode(Lib_BytesUtils.slice(keyRemainder, 1), _value); + totalNewNodes += 1; + } + } else { + // Our last node is either an extension node or a leaf node with a different key. + bytes memory lastNodeKey = _getNodeKey(lastNode); + uint256 sharedNibbleLength = _getSharedNibbleLength(lastNodeKey, keyRemainder); + + if (sharedNibbleLength != 0) { + // We've got some shared nibbles between the last node and our key remainder. + // We'll need to insert an extension node that covers these shared nibbles. + bytes memory nextNodeKey = Lib_BytesUtils.slice(lastNodeKey, 0, sharedNibbleLength); + newNodes[totalNewNodes] = _makeExtensionNode(nextNodeKey, _getNodeHash(_value)); + totalNewNodes += 1; + + // Cut down the keys since we've just covered these shared nibbles. + lastNodeKey = Lib_BytesUtils.slice(lastNodeKey, sharedNibbleLength); + keyRemainder = Lib_BytesUtils.slice(keyRemainder, sharedNibbleLength); + } + + // Create an empty branch to fill in. + TrieNode memory newBranch = _makeEmptyBranchNode(); + + if (lastNodeKey.length == 0) { + // Key remainder was larger than the key for our last node. + // The value within our last node is therefore going to be shifted into + // a branch value slot. + newBranch = _editBranchValue(newBranch, _getNodeValue(lastNode)); + } else { + // Last node key was larger than the key remainder. + // We're going to modify some index of our branch. + uint8 branchKey = uint8(lastNodeKey[0]); + // Move on to the next nibble. + lastNodeKey = Lib_BytesUtils.slice(lastNodeKey, 1); + + if (lastNodeType == NodeType.LeafNode) { + // We're dealing with a leaf node. + // We'll modify the key and insert the old leaf node into the branch index. + TrieNode memory modifiedLastNode = _makeLeafNode(lastNodeKey, _getNodeValue(lastNode)); + newBranch = _editBranchIndex(newBranch, branchKey, _getNodeHash(modifiedLastNode.encoded)); + } else if (lastNodeKey.length != 0) { + // We're dealing with a shrinking extension node. + // We need to modify the node to decrease the size of the key. + TrieNode memory modifiedLastNode = _makeExtensionNode(lastNodeKey, _getNodeValue(lastNode)); + newBranch = _editBranchIndex(newBranch, branchKey, _getNodeHash(modifiedLastNode.encoded)); + } else { + // We're dealing with an unnecessary extension node. + // We're going to delete the node entirely. + // Simply insert its current value into the branch index. + newBranch = _editBranchIndex(newBranch, branchKey, _getNodeValue(lastNode)); + } + } + + if (keyRemainder.length == 0) { + // We've got nothing left in the key remainder. + // Simply insert the value into the branch value slot. + newBranch = _editBranchValue(newBranch, _value); + // Push the branch into the list of new nodes. + newNodes[totalNewNodes] = newBranch; + totalNewNodes += 1; + } else { + // We've got some key remainder to work with. + // We'll be inserting a leaf node into the trie. + // First, move on to the next nibble. + keyRemainder = Lib_BytesUtils.slice(keyRemainder, 1); + // Push the branch into the list of new nodes. + newNodes[totalNewNodes] = newBranch; + totalNewNodes += 1; + // Push a new leaf node for our k/v pair. + newNodes[totalNewNodes] = _makeLeafNode(keyRemainder, _value); + totalNewNodes += 1; + } + } + + // Finally, join the old path with our newly created nodes. + // Since we're overwriting the last node in the path, we use `_pathLength - 1`. + return _joinNodeArrays(_path, _pathLength - 1, newNodes, totalNewNodes); + } + + /** + * @notice Computes the trie root from a given path. + * @param _nodes Path to some k/v pair. + * @param _key Key for the k/v pair. + * @return _updatedRoot Root hash for the updated trie. + */ + function _getUpdatedTrieRoot( + TrieNode[] memory _nodes, + bytes memory _key + ) + private + pure + returns ( + bytes32 _updatedRoot + ) + { + bytes memory key = Lib_BytesUtils.toNibbles(_key); + + // Some variables to keep track of during iteration. + TrieNode memory currentNode; + NodeType currentNodeType; + bytes memory previousNodeHash; + + // Run through the path backwards to rebuild our root hash. + for (uint256 i = _nodes.length; i > 0; i--) { + // Pick out the current node. + currentNode = _nodes[i - 1]; + currentNodeType = _getNodeType(currentNode); + + if (currentNodeType == NodeType.LeafNode) { + // Leaf nodes are already correctly encoded. + // Shift the key over to account for the nodes key. + bytes memory nodeKey = _getNodeKey(currentNode); + key = Lib_BytesUtils.slice(key, 0, key.length - nodeKey.length); + } else if (currentNodeType == NodeType.ExtensionNode) { + // Shift the key over to account for the nodes key. + bytes memory nodeKey = _getNodeKey(currentNode); + key = Lib_BytesUtils.slice(key, 0, key.length - nodeKey.length); + + // If this node is the last element in the path, it'll be correctly encoded + // and we can skip this part. + if (previousNodeHash.length > 0) { + // Re-encode the node based on the previous node. + currentNode = _makeExtensionNode(nodeKey, previousNodeHash); + } + } else if (currentNodeType == NodeType.BranchNode) { + // If this node is the last element in the path, it'll be correctly encoded + // and we can skip this part. + if (previousNodeHash.length > 0) { + // Re-encode the node based on the previous node. + uint8 branchKey = uint8(key[key.length - 1]); + key = Lib_BytesUtils.slice(key, 0, key.length - 1); + currentNode = _editBranchIndex(currentNode, branchKey, previousNodeHash); + } + } + + // Compute the node hash for the next iteration. + previousNodeHash = _getNodeHash(currentNode.encoded); + } + + // Current node should be the root at this point. + // Simply return the hash of its encoding. + return keccak256(currentNode.encoded); + } + + /** + * @notice Parses an RLP-encoded proof into something more useful. + * @param _proof RLP-encoded proof to parse. + * @return _parsed Proof parsed into easily accessible structs. + */ + function _parseProof( + bytes memory _proof + ) + private + pure + returns ( + TrieNode[] memory _parsed + ) + { + Lib_RLPReader.RLPItem[] memory nodes = Lib_RLPReader.readList(_proof); + TrieNode[] memory proof = new TrieNode[](nodes.length); + + for (uint256 i = 0; i < nodes.length; i++) { + bytes memory encoded = Lib_RLPReader.readBytes(nodes[i]); + proof[i] = TrieNode({ + encoded: encoded, + decoded: Lib_RLPReader.readList(encoded) + }); + } + + return proof; + } + + /** + * @notice Picks out the ID for a node. Node ID is referred to as the + * "hash" within the specification, but nodes < 32 bytes are not actually + * hashed. + * @param _node Node to pull an ID for. + * @return _nodeID ID for the node, depending on the size of its contents. + */ + function _getNodeID( + Lib_RLPReader.RLPItem memory _node + ) + private + pure + returns ( + bytes32 _nodeID + ) + { + bytes memory nodeID; + + if (_node.length < 32) { + // Nodes smaller than 32 bytes are RLP encoded. + nodeID = Lib_RLPReader.readRawBytes(_node); + } else { + // Nodes 32 bytes or larger are hashed. + nodeID = Lib_RLPReader.readBytes(_node); + } + + return Lib_BytesUtils.toBytes32(nodeID); + } + + /** + * @notice Gets the path for a leaf or extension node. + * @param _node Node to get a path for. + * @return _path Node path, converted to an array of nibbles. + */ + function _getNodePath( + TrieNode memory _node + ) + private + pure + returns ( + bytes memory _path + ) + { + return Lib_BytesUtils.toNibbles(Lib_RLPReader.readBytes(_node.decoded[0])); + } + + /** + * @notice Gets the key for a leaf or extension node. Keys are essentially + * just paths without any prefix. + * @param _node Node to get a key for. + * @return _key Node key, converted to an array of nibbles. + */ + function _getNodeKey( + TrieNode memory _node + ) + private + pure + returns ( + bytes memory _key + ) + { + return _removeHexPrefix(_getNodePath(_node)); + } + + /** + * @notice Gets the path for a node. + * @param _node Node to get a value for. + * @return _value Node value, as hex bytes. + */ + function _getNodeValue( + TrieNode memory _node + ) + private + pure + returns ( + bytes memory _value + ) + { + return Lib_RLPReader.readBytes(_node.decoded[_node.decoded.length - 1]); + } + + /** + * @notice Computes the node hash for an encoded node. Nodes < 32 bytes + * are not hashed, all others are keccak256 hashed. + * @param _encoded Encoded node to hash. + * @return _hash Hash of the encoded node. Simply the input if < 32 bytes. + */ + function _getNodeHash( + bytes memory _encoded + ) + private + pure + returns ( + bytes memory _hash + ) + { + if (_encoded.length < 32) { + return _encoded; + } else { + return abi.encodePacked(keccak256(_encoded)); + } + } + + /** + * @notice Determines the type for a given node. + * @param _node Node to determine a type for. + * @return _type Type of the node; BranchNode/ExtensionNode/LeafNode. + */ + function _getNodeType( + TrieNode memory _node + ) + private + pure + returns ( + NodeType _type + ) + { + if (_node.decoded.length == BRANCH_NODE_LENGTH) { + return NodeType.BranchNode; + } else if (_node.decoded.length == LEAF_OR_EXTENSION_NODE_LENGTH) { + bytes memory path = _getNodePath(_node); + uint8 prefix = uint8(path[0]); + + if (prefix == PREFIX_LEAF_EVEN || prefix == PREFIX_LEAF_ODD) { + return NodeType.LeafNode; + } else if (prefix == PREFIX_EXTENSION_EVEN || prefix == PREFIX_EXTENSION_ODD) { + return NodeType.ExtensionNode; + } + } + + revert("Invalid node type"); + } + + /** + * @notice Utility; determines the number of nibbles shared between two + * nibble arrays. + * @param _a First nibble array. + * @param _b Second nibble array. + * @return _shared Number of shared nibbles. + */ + function _getSharedNibbleLength( + bytes memory _a, + bytes memory _b + ) + private + pure + returns ( + uint256 _shared + ) + { + uint256 i = 0; + while (_a.length > i && _b.length > i && _a[i] == _b[i]) { + i++; + } + return i; + } + + /** + * @notice Utility; converts an RLP-encoded node into our nice struct. + * @param _raw RLP-encoded node to convert. + * @return _node Node as a TrieNode struct. + */ + function _makeNode( + bytes[] memory _raw + ) + private + pure + returns ( + TrieNode memory _node + ) + { + bytes memory encoded = Lib_RLPWriter.writeList(_raw); + + return TrieNode({ + encoded: encoded, + decoded: Lib_RLPReader.readList(encoded) + }); + } + + /** + * @notice Utility; converts an RLP-decoded node into our nice struct. + * @param _items RLP-decoded node to convert. + * @return _node Node as a TrieNode struct. + */ + function _makeNode( + Lib_RLPReader.RLPItem[] memory _items + ) + private + pure + returns ( + TrieNode memory _node + ) + { + bytes[] memory raw = new bytes[](_items.length); + for (uint256 i = 0; i < _items.length; i++) { + raw[i] = Lib_RLPReader.readRawBytes(_items[i]); + } + return _makeNode(raw); + } + + /** + * @notice Creates a new extension node. + * @param _key Key for the extension node, unprefixed. + * @param _value Value for the extension node. + * @return _node New extension node with the given k/v pair. + */ + function _makeExtensionNode( + bytes memory _key, + bytes memory _value + ) + private + pure + returns ( + TrieNode memory _node + ) + { + bytes[] memory raw = new bytes[](2); + bytes memory key = _addHexPrefix(_key, false); + raw[0] = Lib_RLPWriter.writeBytes(Lib_BytesUtils.fromNibbles(key)); + raw[1] = Lib_RLPWriter.writeBytes(_value); + return _makeNode(raw); + } + + /** + * @notice Creates a new leaf node. + * @dev This function is essentially identical to `_makeExtensionNode`. + * Although we could route both to a single method with a flag, it's + * more gas efficient to keep them separate and duplicate the logic. + * @param _key Key for the leaf node, unprefixed. + * @param _value Value for the leaf node. + * @return _node New leaf node with the given k/v pair. + */ + function _makeLeafNode( + bytes memory _key, + bytes memory _value + ) + private + pure + returns ( + TrieNode memory _node + ) + { + bytes[] memory raw = new bytes[](2); + bytes memory key = _addHexPrefix(_key, true); + raw[0] = Lib_RLPWriter.writeBytes(Lib_BytesUtils.fromNibbles(key)); + raw[1] = Lib_RLPWriter.writeBytes(_value); + return _makeNode(raw); + } + + /** + * @notice Creates an empty branch node. + * @return _node Empty branch node as a TrieNode struct. + */ + function _makeEmptyBranchNode() + private + pure + returns ( + TrieNode memory _node + ) + { + bytes[] memory raw = new bytes[](BRANCH_NODE_LENGTH); + for (uint256 i = 0; i < raw.length; i++) { + raw[i] = RLP_NULL_BYTES; + } + return _makeNode(raw); + } + + /** + * @notice Modifies the value slot for a given branch. + * @param _branch Branch node to modify. + * @param _value Value to insert into the branch. + * @return _updatedNode Modified branch node. + */ + function _editBranchValue( + TrieNode memory _branch, + bytes memory _value + ) + private + pure + returns ( + TrieNode memory _updatedNode + ) + { + bytes memory encoded = Lib_RLPWriter.writeBytes(_value); + _branch.decoded[_branch.decoded.length - 1] = Lib_RLPReader.toRLPItem(encoded); + return _makeNode(_branch.decoded); + } + + /** + * @notice Modifies a slot at an index for a given branch. + * @param _branch Branch node to modify. + * @param _index Slot index to modify. + * @param _value Value to insert into the slot. + * @return _updatedNode Modified branch node. + */ + function _editBranchIndex( + TrieNode memory _branch, + uint8 _index, + bytes memory _value + ) + private + pure + returns ( + TrieNode memory _updatedNode + ) + { + bytes memory encoded = _value.length < 32 ? _value : Lib_RLPWriter.writeBytes(_value); + _branch.decoded[_index] = Lib_RLPReader.toRLPItem(encoded); + return _makeNode(_branch.decoded); + } + + /** + * @notice Utility; adds a prefix to a key. + * @param _key Key to prefix. + * @param _isLeaf Whether or not the key belongs to a leaf. + * @return _prefixedKey Prefixed key. + */ + function _addHexPrefix( + bytes memory _key, + bool _isLeaf + ) + private + pure + returns ( + bytes memory _prefixedKey + ) + { + uint8 prefix = _isLeaf ? uint8(0x02) : uint8(0x00); + uint8 offset = uint8(_key.length % 2); + bytes memory prefixed = new bytes(2 - offset); + prefixed[0] = bytes1(prefix + offset); + return abi.encodePacked(prefixed, _key); + } + + /** + * @notice Utility; removes a prefix from a path. + * @param _path Path to remove the prefix from. + * @return _unprefixedKey Unprefixed key. + */ + function _removeHexPrefix( + bytes memory _path + ) + private + pure + returns ( + bytes memory _unprefixedKey + ) + { + if (uint8(_path[0]) % 2 == 0) { + return Lib_BytesUtils.slice(_path, 2); + } else { + return Lib_BytesUtils.slice(_path, 1); + } + } + + /** + * @notice Utility; combines two node arrays. Array lengths are required + * because the actual lengths may be longer than the filled lengths. + * Array resizing is extremely costly and should be avoided. + * @param _a First array to join. + * @param _aLength Length of the first array. + * @param _b Second array to join. + * @param _bLength Length of the second array. + * @return _joined Combined node array. + */ + function _joinNodeArrays( + TrieNode[] memory _a, + uint256 _aLength, + TrieNode[] memory _b, + uint256 _bLength + ) + private + pure + returns ( + TrieNode[] memory _joined + ) + { + TrieNode[] memory ret = new TrieNode[](_aLength + _bLength); + + // Copy elements from the first array. + for (uint256 i = 0; i < _aLength; i++) { + ret[i] = _a[i]; + } + + // Copy elements from the second array. + for (uint256 i = 0; i < _bLength; i++) { + ret[i + _aLength] = _b[i]; + } + + return ret; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/trie/Lib_SecureMerkleTrie.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/trie/Lib_SecureMerkleTrie.sol new file mode 100644 index 000000000000..80a6702540d6 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/trie/Lib_SecureMerkleTrie.sol @@ -0,0 +1,162 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_MerkleTrie } from "./Lib_MerkleTrie.sol"; + +/** + * @title Lib_SecureMerkleTrie + */ +library Lib_SecureMerkleTrie { + + /********************** + * Internal Functions * + **********************/ + + /** + * @notice Verifies a proof that a given key/value pair is present in the + * Merkle trie. + * @param _key Key of the node to search for, as a hex string. + * @param _value Value of the node to search for, as a hex string. + * @param _proof Merkle trie inclusion proof for the desired node. Unlike + * traditional Merkle trees, this proof is executed top-down and consists + * of a list of RLP-encoded nodes that make a path down to the target node. + * @param _root Known root of the Merkle trie. Used to verify that the + * included proof is correctly constructed. + * @return _verified `true` if the k/v pair exists in the trie, `false` otherwise. + */ + function verifyInclusionProof( + bytes memory _key, + bytes memory _value, + bytes memory _proof, + bytes32 _root + ) + internal + pure + returns ( + bool _verified + ) + { + bytes memory key = _getSecureKey(_key); + return Lib_MerkleTrie.verifyInclusionProof(key, _value, _proof, _root); + } + + /** + * @notice Verifies a proof that a given key is *not* present in + * the Merkle trie. + * @param _key Key of the node to search for, as a hex string. + * @param _proof Merkle trie inclusion proof for the node *nearest* the + * target node. + * @param _root Known root of the Merkle trie. Used to verify that the + * included proof is correctly constructed. + * @return _verified `true` if the key is not present in the trie, `false` otherwise. + */ + function verifyExclusionProof( + bytes memory _key, + bytes memory _proof, + bytes32 _root + ) + internal + pure + returns ( + bool _verified + ) + { + bytes memory key = _getSecureKey(_key); + return Lib_MerkleTrie.verifyExclusionProof(key, _proof, _root); + } + + /** + * @notice Updates a Merkle trie and returns a new root hash. + * @param _key Key of the node to update, as a hex string. + * @param _value Value of the node to update, as a hex string. + * @param _proof Merkle trie inclusion proof for the node *nearest* the + * target node. If the key exists, we can simply update the value. + * Otherwise, we need to modify the trie to handle the new k/v pair. + * @param _root Known root of the Merkle trie. Used to verify that the + * included proof is correctly constructed. + * @return _updatedRoot Root hash of the newly constructed trie. + */ + function update( + bytes memory _key, + bytes memory _value, + bytes memory _proof, + bytes32 _root + ) + internal + pure + returns ( + bytes32 _updatedRoot + ) + { + bytes memory key = _getSecureKey(_key); + return Lib_MerkleTrie.update(key, _value, _proof, _root); + } + + /** + * @notice Retrieves the value associated with a given key. + * @param _key Key to search for, as hex bytes. + * @param _proof Merkle trie inclusion proof for the key. + * @param _root Known root of the Merkle trie. + * @return _exists Whether or not the key exists. + * @return _value Value of the key if it exists. + */ + function get( + bytes memory _key, + bytes memory _proof, + bytes32 _root + ) + internal + pure + returns ( + bool _exists, + bytes memory _value + ) + { + bytes memory key = _getSecureKey(_key); + return Lib_MerkleTrie.get(key, _proof, _root); + } + + /** + * Computes the root hash for a trie with a single node. + * @param _key Key for the single node. + * @param _value Value for the single node. + * @return _updatedRoot Hash of the trie. + */ + function getSingleNodeRootHash( + bytes memory _key, + bytes memory _value + ) + internal + pure + returns ( + bytes32 _updatedRoot + ) + { + bytes memory key = _getSecureKey(_key); + return Lib_MerkleTrie.getSingleNodeRootHash(key, _value); + } + + + /********************* + * Private Functions * + *********************/ + + /** + * Computes the secure counterpart to a key. + * @param _key Key to get a secure key from. + * @return _secureKey Secure version of the key. + */ + function _getSecureKey( + bytes memory _key + ) + private + pure + returns ( + bytes memory _secureKey + ) + { + return abi.encodePacked(keccak256(_key)); + } +} \ No newline at end of file diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_Bytes32Utils.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_Bytes32Utils.sol new file mode 100644 index 000000000000..b06cc335aab3 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_Bytes32Utils.sol @@ -0,0 +1,117 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @title Lib_Byte32Utils + */ +library Lib_Bytes32Utils { + + /********************** + * Internal Functions * + **********************/ + + /** + * Converts a bytes32 value to a boolean. Anything non-zero will be converted to "true." + * @param _in Input bytes32 value. + * @return Bytes32 as a boolean. + */ + function toBool( + bytes32 _in + ) + internal + pure + returns ( + bool + ) + { + return _in != 0; + } + + /** + * Converts a boolean to a bytes32 value. + * @param _in Input boolean value. + * @return Boolean as a bytes32. + */ + function fromBool( + bool _in + ) + internal + pure + returns ( + bytes32 + ) + { + return bytes32(uint256(_in ? 1 : 0)); + } + + /** + * Converts a bytes32 value to an address. Takes the *last* 20 bytes. + * @param _in Input bytes32 value. + * @return Bytes32 as an address. + */ + function toAddress( + bytes32 _in + ) + internal + pure + returns ( + address + ) + { + return address(uint160(uint256(_in))); + } + + /** + * Converts an address to a bytes32. + * @param _in Input address value. + * @return Address as a bytes32. + */ + function fromAddress( + address _in + ) + internal + pure + returns ( + bytes32 + ) + { + return bytes32(uint256(_in)); + } + + /** + * Removes the leading zeros from a bytes32 value and returns a new (smaller) bytes value. + * @param _in Input bytes32 value. + * @return Bytes32 without any leading zeros. + */ + function removeLeadingZeros( + bytes32 _in + ) + internal + pure + returns ( + bytes memory + ) + { + bytes memory out; + + assembly { + // Figure out how many leading zero bytes to remove. + let shift := 0 + for { let i := 0 } and(lt(i, 32), eq(byte(i, _in), 0)) { i := add(i, 1) } { + shift := add(shift, 1) + } + + // Reserve some space for our output and fix the free memory pointer. + out := mload(0x40) + mstore(0x40, add(out, 0x40)) + + // Shift the value and store it into the output bytes. + mstore(add(out, 0x20), shl(mul(shift, 8), _in)) + + // Store the new size (with leading zero bytes removed) in the output byte size. + mstore(out, sub(32, shift)) + } + + return out; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_BytesUtils.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_BytesUtils.sol new file mode 100644 index 000000000000..e7e46363e0c8 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_BytesUtils.sol @@ -0,0 +1,221 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @title Lib_BytesUtils + */ +library Lib_BytesUtils { + + /********************** + * Internal Functions * + **********************/ + + function slice( + bytes memory _bytes, + uint256 _start, + uint256 _length + ) + internal + pure + returns (bytes memory) + { + require(_length + 31 >= _length, "slice_overflow"); + require(_start + _length >= _start, "slice_overflow"); + require(_bytes.length >= _start + _length, "slice_outOfBounds"); + + bytes memory tempBytes; + + assembly { + switch iszero(_length) + case 0 { + // Get a location of some free memory and store it in tempBytes as + // Solidity does for memory variables. + tempBytes := mload(0x40) + + // The first word of the slice result is potentially a partial + // word read from the original array. To read it, we calculate + // the length of that partial word and start copying that many + // bytes into the array. The first word we copy will start with + // data we don't care about, but the last `lengthmod` bytes will + // land at the beginning of the contents of the new array. When + // we're done copying, we overwrite the full first word with + // the actual length of the slice. + let lengthmod := and(_length, 31) + + // The multiplication in the next line is necessary + // because when slicing multiples of 32 bytes (lengthmod == 0) + // the following copy loop was copying the origin's length + // and then ending prematurely not copying everything it should. + let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) + let end := add(mc, _length) + + for { + // The multiplication in the next line has the same exact purpose + // as the one above. + let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) + } lt(mc, end) { + mc := add(mc, 0x20) + cc := add(cc, 0x20) + } { + mstore(mc, mload(cc)) + } + + mstore(tempBytes, _length) + + //update free-memory pointer + //allocating the array padded to 32 bytes like the compiler does now + mstore(0x40, and(add(mc, 31), not(31))) + } + //if we want a zero-length slice let's just return a zero-length array + default { + tempBytes := mload(0x40) + + //zero out the 32 bytes slice we are about to return + //we need to do it because Solidity does not garbage collect + mstore(tempBytes, 0) + + mstore(0x40, add(tempBytes, 0x20)) + } + } + + return tempBytes; + } + + function slice( + bytes memory _bytes, + uint256 _start + ) + internal + pure + returns (bytes memory) + { + if (_bytes.length - _start == 0) { + return bytes(''); + } + + return slice(_bytes, _start, _bytes.length - _start); + } + + function toBytes32PadLeft( + bytes memory _bytes + ) + internal + pure + returns (bytes32) + { + bytes32 ret; + uint256 len = _bytes.length <= 32 ? _bytes.length : 32; + assembly { + ret := shr(mul(sub(32, len), 8), mload(add(_bytes, 32))) + } + return ret; + } + + function toBytes32( + bytes memory _bytes + ) + internal + pure + returns (bytes32) + { + if (_bytes.length < 32) { + bytes32 ret; + assembly { + ret := mload(add(_bytes, 32)) + } + return ret; + } + + return abi.decode(_bytes,(bytes32)); // will truncate if input length > 32 bytes + } + + function toUint256( + bytes memory _bytes + ) + internal + pure + returns (uint256) + { + return uint256(toBytes32(_bytes)); + } + + function toUint24(bytes memory _bytes, uint256 _start) internal pure returns (uint24) { + require(_start + 3 >= _start, "toUint24_overflow"); + require(_bytes.length >= _start + 3 , "toUint24_outOfBounds"); + uint24 tempUint; + + assembly { + tempUint := mload(add(add(_bytes, 0x3), _start)) + } + + return tempUint; + } + + function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) { + require(_start + 1 >= _start, "toUint8_overflow"); + require(_bytes.length >= _start + 1 , "toUint8_outOfBounds"); + uint8 tempUint; + + assembly { + tempUint := mload(add(add(_bytes, 0x1), _start)) + } + + return tempUint; + } + + function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { + require(_start + 20 >= _start, "toAddress_overflow"); + require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); + address tempAddress; + + assembly { + tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) + } + + return tempAddress; + } + + function toNibbles( + bytes memory _bytes + ) + internal + pure + returns (bytes memory) + { + bytes memory nibbles = new bytes(_bytes.length * 2); + + for (uint256 i = 0; i < _bytes.length; i++) { + nibbles[i * 2] = _bytes[i] >> 4; + nibbles[i * 2 + 1] = bytes1(uint8(_bytes[i]) % 16); + } + + return nibbles; + } + + function fromNibbles( + bytes memory _bytes + ) + internal + pure + returns (bytes memory) + { + bytes memory ret = new bytes(_bytes.length / 2); + + for (uint256 i = 0; i < ret.length; i++) { + ret[i] = (_bytes[i * 2] << 4) | (_bytes[i * 2 + 1]); + } + + return ret; + } + + function equal( + bytes memory _bytes, + bytes memory _other + ) + internal + pure + returns (bool) + { + return keccak256(_bytes) == keccak256(_other); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_ECDSAUtils.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_ECDSAUtils.sol new file mode 100644 index 000000000000..9d973758b920 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_ECDSAUtils.sol @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @title Lib_ECDSAUtils + */ +library Lib_ECDSAUtils { + + /************************************** + * Internal Functions: ECDSA Recovery * + **************************************/ + + /** + * Recovers a signed address given a message and signature. + * @param _message Message that was originally signed. + * @param _isEthSignedMessage Whether or not the user used the `Ethereum Signed Message` prefix. + * @param _v Signature `v` parameter. + * @param _r Signature `r` parameter. + * @param _s Signature `s` parameter. + * @return _sender Signer address. + */ + function recover( + bytes memory _message, + bool _isEthSignedMessage, + uint8 _v, + bytes32 _r, + bytes32 _s + ) + internal + pure + returns ( + address _sender + ) + { + bytes32 messageHash = getMessageHash(_message, _isEthSignedMessage); + + return ecrecover( + messageHash, + _v + 27, + _r, + _s + ); + } + + function getMessageHash( + bytes memory _message, + bool _isEthSignedMessage + ) + internal + pure + returns (bytes32) { + if (_isEthSignedMessage) { + return getEthSignedMessageHash(_message); + } + return getNativeMessageHash(_message); + } + + + /************************************* + * Private Functions: ECDSA Recovery * + *************************************/ + + /** + * Gets the native message hash (simple keccak256) for a message. + * @param _message Message to hash. + * @return _messageHash Native message hash. + */ + function getNativeMessageHash( + bytes memory _message + ) + private + pure + returns ( + bytes32 _messageHash + ) + { + return keccak256(_message); + } + + /** + * Gets the hash of a message with the `Ethereum Signed Message` prefix. + * @param _message Message to hash. + * @return _messageHash Prefixed message hash. + */ + function getEthSignedMessageHash( + bytes memory _message + ) + private + pure + returns ( + bytes32 _messageHash + ) + { + bytes memory prefix = "\x19Ethereum Signed Message:\n32"; + bytes32 messageHash = keccak256(_message); + return keccak256(abi.encodePacked(prefix, messageHash)); + } +} \ No newline at end of file diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_ErrorUtils.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_ErrorUtils.sol new file mode 100644 index 000000000000..ea6200ea9a3f --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_ErrorUtils.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/** + * @title Lib_ErrorUtils + */ +library Lib_ErrorUtils { + + /********************** + * Internal Functions * + **********************/ + + /** + * Encodes an error string into raw solidity-style revert data. + * (i.e. ascii bytes, prefixed with bytes4(keccak("Error(string))")) + * Ref: https://docs.soliditylang.org/en/v0.8.2/control-structures.html?highlight=Error(string)#panic-via-assert-and-error-via-require + * @param _reason Reason for the reversion. + * @return Standard solidity revert data for the given reason. + */ + function encodeRevertString( + string memory _reason + ) + internal + pure + returns ( + bytes memory + ) + { + return abi.encodeWithSignature( + "Error(string)", + _reason + ); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_EthUtils.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_EthUtils.sol new file mode 100644 index 000000000000..6709edf9562f --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_EthUtils.sol @@ -0,0 +1,188 @@ +// SPDX-License-Identifier: MIT +// @unsupported: ovm +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_RLPWriter } from "../rlp/Lib_RLPWriter.sol"; +import { Lib_Bytes32Utils } from "./Lib_Bytes32Utils.sol"; + +/** + * @title Lib_EthUtils + */ +library Lib_EthUtils { + + /*********************************** + * Internal Functions: Code Access * + ***********************************/ + + /** + * Gets the code for a given address. + * @param _address Address to get code for. + * @param _offset Offset to start reading from. + * @param _length Number of bytes to read. + * @return _code Code read from the contract. + */ + function getCode( + address _address, + uint256 _offset, + uint256 _length + ) + internal + view + returns ( + bytes memory _code + ) + { + assembly { + _code := mload(0x40) + mstore(0x40, add(_code, add(_length, 0x20))) + mstore(_code, _length) + extcodecopy(_address, add(_code, 0x20), _offset, _length) + } + + return _code; + } + + /** + * Gets the full code for a given address. + * @param _address Address to get code for. + * @return _code Full code of the contract. + */ + function getCode( + address _address + ) + internal + view + returns ( + bytes memory _code + ) + { + return getCode( + _address, + 0, + getCodeSize(_address) + ); + } + + /** + * Gets the size of a contract's code in bytes. + * @param _address Address to get code size for. + * @return _codeSize Size of the contract's code in bytes. + */ + function getCodeSize( + address _address + ) + internal + view + returns ( + uint256 _codeSize + ) + { + assembly { + _codeSize := extcodesize(_address) + } + + return _codeSize; + } + + /** + * Gets the hash of a contract's code. + * @param _address Address to get a code hash for. + * @return _codeHash Hash of the contract's code. + */ + function getCodeHash( + address _address + ) + internal + view + returns ( + bytes32 _codeHash + ) + { + assembly { + _codeHash := extcodehash(_address) + } + + return _codeHash; + } + + + /***************************************** + * Internal Functions: Contract Creation * + *****************************************/ + + /** + * Creates a contract with some given initialization code. + * @param _code Contract initialization code. + * @return _created Address of the created contract. + */ + function createContract( + bytes memory _code + ) + internal + returns ( + address _created + ) + { + assembly { + _created := create( + 0, + add(_code, 0x20), + mload(_code) + ) + } + + return _created; + } + + /** + * Computes the address that would be generated by CREATE. + * @param _creator Address creating the contract. + * @param _nonce Creator's nonce. + * @return _address Address to be generated by CREATE. + */ + function getAddressForCREATE( + address _creator, + uint256 _nonce + ) + internal + pure + returns ( + address _address + ) + { + bytes[] memory encoded = new bytes[](2); + encoded[0] = Lib_RLPWriter.writeAddress(_creator); + encoded[1] = Lib_RLPWriter.writeUint(_nonce); + + bytes memory encodedList = Lib_RLPWriter.writeList(encoded); + return Lib_Bytes32Utils.toAddress(keccak256(encodedList)); + } + + /** + * Computes the address that would be generated by CREATE2. + * @param _creator Address creating the contract. + * @param _bytecode Bytecode of the contract to be created. + * @param _salt 32 byte salt value mixed into the hash. + * @return _address Address to be generated by CREATE2. + */ + function getAddressForCREATE2( + address _creator, + bytes memory _bytecode, + bytes32 _salt + ) + internal + pure + returns (address _address) + { + bytes32 hashedData = keccak256(abi.encodePacked( + byte(0xff), + _creator, + _salt, + keccak256(_bytecode) + )); + + return Lib_Bytes32Utils.toAddress(hashedData); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_Math.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_Math.sol new file mode 100644 index 000000000000..2227cc5449f8 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_Math.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @title Lib_Math + */ +library Lib_Math { + + /********************** + * Internal Functions * + **********************/ + + /** + * Calculates the minumum of two numbers. + * @param _x First number to compare. + * @param _y Second number to compare. + * @return Lesser of the two numbers. + */ + function min( + uint256 _x, + uint256 _y + ) + internal + pure + returns ( + uint256 + ) + { + if (_x < _y) { + return _x; + } + + return _y; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_MerkleTree.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_MerkleTree.sol new file mode 100644 index 000000000000..5ba888e18fd2 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_MerkleTree.sol @@ -0,0 +1,220 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @title Lib_MerkleTree + * @author River Keefer + */ +library Lib_MerkleTree { + + /********************** + * Internal Functions * + **********************/ + + /** + * Calculates a merkle root for a list of 32-byte leaf hashes. WARNING: If the number + * of leaves passed in is not a power of two, it pads out the tree with zero hashes. + * If you do not know the original length of elements for the tree you are verifying, + * then this may allow empty leaves past _elements.length to pass a verification check down the line. + * Note that the _elements argument is modified, therefore it must not be used again afterwards + * @param _elements Array of hashes from which to generate a merkle root. + * @return Merkle root of the leaves, with zero hashes for non-powers-of-two (see above). + */ + function getMerkleRoot( + bytes32[] memory _elements + ) + internal + pure + returns ( + bytes32 + ) + { + require( + _elements.length > 0, + "Lib_MerkleTree: Must provide at least one leaf hash." + ); + + if (_elements.length == 0) { + return _elements[0]; + } + + uint256[16] memory defaults = [ + 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563, + 0x633dc4d7da7256660a892f8f1604a44b5432649cc8ec5cb3ced4c4e6ac94dd1d, + 0x890740a8eb06ce9be422cb8da5cdafc2b58c0a5e24036c578de2a433c828ff7d, + 0x3b8ec09e026fdc305365dfc94e189a81b38c7597b3d941c279f042e8206e0bd8, + 0xecd50eee38e386bd62be9bedb990706951b65fe053bd9d8a521af753d139e2da, + 0xdefff6d330bb5403f63b14f33b578274160de3a50df4efecf0e0db73bcdd3da5, + 0x617bdd11f7c0a11f49db22f629387a12da7596f9d1704d7465177c63d88ec7d7, + 0x292c23a9aa1d8bea7e2435e555a4a60e379a5a35f3f452bae60121073fb6eead, + 0xe1cea92ed99acdcb045a6726b2f87107e8a61620a232cf4d7d5b5766b3952e10, + 0x7ad66c0a68c72cb89e4fb4303841966e4062a76ab97451e3b9fb526a5ceb7f82, + 0xe026cc5a4aed3c22a58cbd3d2ac754c9352c5436f638042dca99034e83636516, + 0x3d04cffd8b46a874edf5cfae63077de85f849a660426697b06a829c70dd1409c, + 0xad676aa337a485e4728a0b240d92b3ef7b3c372d06d189322bfd5f61f1e7203e, + 0xa2fca4a49658f9fab7aa63289c91b7c7b6c832a6d0e69334ff5b0a3483d09dab, + 0x4ebfd9cd7bca2505f7bef59cc1c12ecc708fff26ae4af19abe852afe9e20c862, + 0x2def10d13dd169f550f578bda343d9717a138562e0093b380a1120789d53cf10 + ]; + + // Reserve memory space for our hashes. + bytes memory buf = new bytes(64); + + // We'll need to keep track of left and right siblings. + bytes32 leftSibling; + bytes32 rightSibling; + + // Number of non-empty nodes at the current depth. + uint256 rowSize = _elements.length; + + // Current depth, counting from 0 at the leaves + uint256 depth = 0; + + // Common sub-expressions + uint256 halfRowSize; // rowSize / 2 + bool rowSizeIsOdd; // rowSize % 2 == 1 + + while (rowSize > 1) { + halfRowSize = rowSize / 2; + rowSizeIsOdd = rowSize % 2 == 1; + + for (uint256 i = 0; i < halfRowSize; i++) { + leftSibling = _elements[(2 * i) ]; + rightSibling = _elements[(2 * i) + 1]; + assembly { + mstore(add(buf, 32), leftSibling ) + mstore(add(buf, 64), rightSibling) + } + + _elements[i] = keccak256(buf); + } + + if (rowSizeIsOdd) { + leftSibling = _elements[rowSize - 1]; + rightSibling = bytes32(defaults[depth]); + assembly { + mstore(add(buf, 32), leftSibling) + mstore(add(buf, 64), rightSibling) + } + + _elements[halfRowSize] = keccak256(buf); + } + + rowSize = halfRowSize + (rowSizeIsOdd ? 1 : 0); + depth++; + } + + return _elements[0]; + } + + /** + * Verifies a merkle branch for the given leaf hash. Assumes the original length + * of leaves generated is a known, correct input, and does not return true for indices + * extending past that index (even if _siblings would be otherwise valid.) + * @param _root The Merkle root to verify against. + * @param _leaf The leaf hash to verify inclusion of. + * @param _index The index in the tree of this leaf. + * @param _siblings Array of sibline nodes in the inclusion proof, starting from depth 0 (bottom of the tree). + * @param _totalLeaves The total number of leaves originally passed into. + * @return Whether or not the merkle branch and leaf passes verification. + */ + function verify( + bytes32 _root, + bytes32 _leaf, + uint256 _index, + bytes32[] memory _siblings, + uint256 _totalLeaves + ) + internal + pure + returns ( + bool + ) + { + require( + _totalLeaves > 0, + "Lib_MerkleTree: Total leaves must be greater than zero." + ); + + require( + _index < _totalLeaves, + "Lib_MerkleTree: Index out of bounds." + ); + + require( + _siblings.length == _ceilLog2(_totalLeaves), + "Lib_MerkleTree: Total siblings does not correctly correspond to total leaves." + ); + + bytes32 computedRoot = _leaf; + + for (uint256 i = 0; i < _siblings.length; i++) { + if ((_index & 1) == 1) { + computedRoot = keccak256( + abi.encodePacked( + _siblings[i], + computedRoot + ) + ); + } else { + computedRoot = keccak256( + abi.encodePacked( + computedRoot, + _siblings[i] + ) + ); + } + + _index >>= 1; + } + + return _root == computedRoot; + } + + + /********************* + * Private Functions * + *********************/ + + /** + * Calculates the integer ceiling of the log base 2 of an input. + * @param _in Unsigned input to calculate the log. + * @return ceil(log_base_2(_in)) + */ + function _ceilLog2( + uint256 _in + ) + private + pure + returns ( + uint256 + ) + { + require( + _in > 0, + "Lib_MerkleTree: Cannot compute ceil(log_2) of 0." + ); + + if (_in == 1) { + return 0; + } + + // Find the highest set bit (will be floor(log_2)). + // Borrowed with <3 from https://github.com/ethereum/solidity-examples + uint256 val = _in; + uint256 highest = 0; + for (uint8 i = 128; i >= 1; i >>= 1) { + if (val & (uint(1) << i) - 1 << i != 0) { + highest += i; + val >>= i; + } + } + + // Increment by one if this is not a perfect logarithm. + if ((uint(1) << highest) != _in) { + highest += 1; + } + + return highest; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_ReentrancyGuard.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_ReentrancyGuard.sol new file mode 100644 index 000000000000..a2aaa4d0e098 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_ReentrancyGuard.sol @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/** + * @dev Contract module that helps prevent reentrant calls to a function. + * + * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier + * available, which can be applied to functions to make sure there are no nested + * (reentrant) calls to them. + * + * Note that because there is a single `nonReentrant` guard, functions marked as + * `nonReentrant` may not call one another. This can be worked around by making + * those functions `private`, and then adding `external` `nonReentrant` entry + * points to them. + * + * TIP: If you would like to learn more about reentrancy and alternative ways + * to protect against it, check out our blog post + * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. + */ +abstract contract Lib_ReentrancyGuard { + // Booleans are more expensive than uint256 or any type that takes up a full + // word because each write operation emits an extra SLOAD to first read the + // slot's contents, replace the bits taken up by the boolean, and then write + // back. This is the compiler's defense against contract upgrades and + // pointer aliasing, and it cannot be disabled. + + // The values being non-zero value makes deployment a bit more expensive, + // but in exchange the refund on every call to nonReentrant will be lower in + // amount. Since refunds are capped to a percentage of the total + // transaction's gas, it is best to keep them low in cases like this one, to + // increase the likelihood of the full refund coming into effect. + uint256 private constant _NOT_ENTERED = 1; + uint256 private constant _ENTERED = 2; + + uint256 private _status; + + constructor () { + _status = _NOT_ENTERED; + } + + /** + * @dev Prevents a contract from calling itself, directly or indirectly. + * Calling a `nonReentrant` function from another `nonReentrant` + * function is not supported. It is possible to prevent this from happening + * by making the `nonReentrant` function external, and make it call a + * `private` function that does the actual work. + */ + modifier nonReentrant() { + // On the first call to nonReentrant, _notEntered will be true + require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); + + // Any calls to nonReentrant after this point will fail + _status = _ENTERED; + + _; + + // By storing the original value once again, a refund is triggered (see + // https://eips.ethereum.org/EIPS/eip-2200) + _status = _NOT_ENTERED; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_RingBuffer.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_RingBuffer.sol new file mode 100644 index 000000000000..49a65c15e8e9 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_RingBuffer.sol @@ -0,0 +1,376 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +library Lib_RingBuffer { + using Lib_RingBuffer for RingBuffer; + + /*********** + * Structs * + ***********/ + + struct Buffer { + uint256 length; + mapping (uint256 => bytes32) buf; + } + + struct RingBuffer { + bytes32 contextA; + bytes32 contextB; + Buffer bufferA; + Buffer bufferB; + uint256 nextOverwritableIndex; + } + + struct RingBufferContext { + // contextA + uint40 globalIndex; + bytes27 extraData; + + // contextB + uint64 currBufferIndex; + uint40 prevResetIndex; + uint40 currResetIndex; + } + + + /************* + * Constants * + *************/ + + uint256 constant MIN_CAPACITY = 16; + + + /********************** + * Internal Functions * + **********************/ + + /** + * Pushes a single element to the buffer. + * @param _self Buffer to access. + * @param _value Value to push to the buffer. + * @param _extraData Optional global extra data. + */ + function push( + RingBuffer storage _self, + bytes32 _value, + bytes27 _extraData + ) + internal + { + RingBufferContext memory ctx = _self.getContext(); + Buffer storage currBuffer = _self.getBuffer(ctx.currBufferIndex); + + // Set a minimum capacity. + if (currBuffer.length == 0) { + currBuffer.length = MIN_CAPACITY; + } + + // Check if we need to expand the buffer. + if (ctx.globalIndex - ctx.currResetIndex >= currBuffer.length) { + if (ctx.currResetIndex < _self.nextOverwritableIndex) { + // We're going to overwrite the inactive buffer. + // Bump the buffer index, reset the delete offset, and set our reset indices. + ctx.currBufferIndex++; + ctx.prevResetIndex = ctx.currResetIndex; + ctx.currResetIndex = ctx.globalIndex; + + // Swap over to the next buffer. + currBuffer = _self.getBuffer(ctx.currBufferIndex); + } else { + // We're not overwriting yet, double the length of the current buffer. + currBuffer.length *= 2; + } + } + + // Index to write to is the difference of the global and reset indices. + uint256 writeHead = ctx.globalIndex - ctx.currResetIndex; + currBuffer.buf[writeHead] = _value; + + // Bump the global index and insert our extra data, then save the context. + ctx.globalIndex++; + ctx.extraData = _extraData; + _self.setContext(ctx); + } + + /** + * Pushes a single element to the buffer. + * @param _self Buffer to access. + * @param _value Value to push to the buffer. + */ + function push( + RingBuffer storage _self, + bytes32 _value + ) + internal + { + RingBufferContext memory ctx = _self.getContext(); + + _self.push( + _value, + ctx.extraData + ); + } + + /** + * Retrieves an element from the buffer. + * @param _self Buffer to access. + * @param _index Element index to retrieve. + * @return Value of the element at the given index. + */ + function get( + RingBuffer storage _self, + uint256 _index + ) + internal + view + returns ( + bytes32 + ) + { + RingBufferContext memory ctx = _self.getContext(); + + require( + _index < ctx.globalIndex, + "Index out of bounds." + ); + + Buffer storage currBuffer = _self.getBuffer(ctx.currBufferIndex); + Buffer storage prevBuffer = _self.getBuffer(ctx.currBufferIndex + 1); + + if (_index >= ctx.currResetIndex) { + // We're trying to load an element from the current buffer. + // Relative index is just the difference from the reset index. + uint256 relativeIndex = _index - ctx.currResetIndex; + + // Shouldn't happen but why not check. + require( + relativeIndex < currBuffer.length, + "Index out of bounds." + ); + + return currBuffer.buf[relativeIndex]; + } else { + // We're trying to load an element from the previous buffer. + // Relative index is the difference from the reset index in the other direction. + uint256 relativeIndex = ctx.currResetIndex - _index; + + // Condition only fails in the case that we deleted and flipped buffers. + require( + ctx.currResetIndex > ctx.prevResetIndex, + "Index out of bounds." + ); + + // Make sure we're not trying to read beyond the array. + require( + relativeIndex <= prevBuffer.length, + "Index out of bounds." + ); + + return prevBuffer.buf[prevBuffer.length - relativeIndex]; + } + } + + /** + * Deletes all elements after (and including) a given index. + * @param _self Buffer to access. + * @param _index Index of the element to delete from (inclusive). + * @param _extraData Optional global extra data. + */ + function deleteElementsAfterInclusive( + RingBuffer storage _self, + uint40 _index, + bytes27 _extraData + ) + internal + { + RingBufferContext memory ctx = _self.getContext(); + + require( + _index < ctx.globalIndex && _index >= ctx.prevResetIndex, + "Index out of bounds." + ); + + if (_index < ctx.currResetIndex) { + // We're switching back to the previous buffer. + // Reduce the buffer index, set the current reset index back to match the previous one. + // We use the equality of these two values to prevent reading beyond this buffer. + ctx.currBufferIndex--; + ctx.currResetIndex = ctx.prevResetIndex; + } + + // Set our global index and extra data, save the context. + ctx.globalIndex = _index; + ctx.extraData = _extraData; + _self.setContext(ctx); + } + + /** + * Deletes all elements after (and including) a given index. + * @param _self Buffer to access. + * @param _index Index of the element to delete from (inclusive). + */ + function deleteElementsAfterInclusive( + RingBuffer storage _self, + uint40 _index + ) + internal + { + RingBufferContext memory ctx = _self.getContext(); + _self.deleteElementsAfterInclusive( + _index, + ctx.extraData + ); + } + + /** + * Retrieves the current global index. + * @param _self Buffer to access. + * @return Current global index. + */ + function getLength( + RingBuffer storage _self + ) + internal + view + returns ( + uint40 + ) + { + RingBufferContext memory ctx = _self.getContext(); + return ctx.globalIndex; + } + + /** + * Changes current global extra data. + * @param _self Buffer to access. + * @param _extraData New global extra data. + */ + function setExtraData( + RingBuffer storage _self, + bytes27 _extraData + ) + internal + { + RingBufferContext memory ctx = _self.getContext(); + ctx.extraData = _extraData; + _self.setContext(ctx); + } + + /** + * Retrieves the current global extra data. + * @param _self Buffer to access. + * @return Current global extra data. + */ + function getExtraData( + RingBuffer storage _self + ) + internal + view + returns ( + bytes27 + ) + { + RingBufferContext memory ctx = _self.getContext(); + return ctx.extraData; + } + + /** + * Sets the current ring buffer context. + * @param _self Buffer to access. + * @param _ctx Current ring buffer context. + */ + function setContext( + RingBuffer storage _self, + RingBufferContext memory _ctx + ) + internal + { + bytes32 contextA; + bytes32 contextB; + + uint40 globalIndex = _ctx.globalIndex; + bytes27 extraData = _ctx.extraData; + assembly { + contextA := globalIndex + contextA := or(contextA, extraData) + } + + uint64 currBufferIndex = _ctx.currBufferIndex; + uint40 prevResetIndex = _ctx.prevResetIndex; + uint40 currResetIndex = _ctx.currResetIndex; + assembly { + contextB := currBufferIndex + contextB := or(contextB, shl(64, prevResetIndex)) + contextB := or(contextB, shl(104, currResetIndex)) + } + + if (_self.contextA != contextA) { + _self.contextA = contextA; + } + + if (_self.contextB != contextB) { + _self.contextB = contextB; + } + } + + /** + * Retrieves the current ring buffer context. + * @param _self Buffer to access. + * @return Current ring buffer context. + */ + function getContext( + RingBuffer storage _self + ) + internal + view + returns ( + RingBufferContext memory + ) + { + bytes32 contextA = _self.contextA; + bytes32 contextB = _self.contextB; + + uint40 globalIndex; + bytes27 extraData; + assembly { + globalIndex := and(contextA, 0x000000000000000000000000000000000000000000000000000000FFFFFFFFFF) + extraData := and(contextA, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000) + } + + uint64 currBufferIndex; + uint40 prevResetIndex; + uint40 currResetIndex; + assembly { + currBufferIndex := and(contextB, 0x000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFF) + prevResetIndex := shr(64, and(contextB, 0x00000000000000000000000000000000000000FFFFFFFFFF0000000000000000)) + currResetIndex := shr(104, and(contextB, 0x0000000000000000000000000000FFFFFFFFFF00000000000000000000000000)) + } + + return RingBufferContext({ + globalIndex: globalIndex, + extraData: extraData, + currBufferIndex: currBufferIndex, + prevResetIndex: prevResetIndex, + currResetIndex: currResetIndex + }); + } + + /** + * Retrieves the a buffer from the ring buffer by index. + * @param _self Buffer to access. + * @param _which Index of the sub buffer to access. + * @return Sub buffer for the index. + */ + function getBuffer( + RingBuffer storage _self, + uint256 _which + ) + internal + view + returns ( + Buffer storage + ) + { + return _which % 2 == 0 ? _self.bufferA : _self.bufferB; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol new file mode 100644 index 000000000000..14dc89bdf8ed --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol @@ -0,0 +1,376 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_ErrorUtils } from "../utils/Lib_ErrorUtils.sol"; + +/** + * @title Lib_SafeExecutionManagerWrapper + * @dev The Safe Execution Manager Wrapper provides functions which facilitate writing OVM safe + * code using the standard solidity compiler, by routing all its operations through the Execution + * Manager. + * + * Compiler used: solc + * Runtime target: OVM + */ +library Lib_SafeExecutionManagerWrapper { + + /********************** + * Internal Functions * + **********************/ + + /** + * Performs a safe ovmCALL. + * @param _gasLimit Gas limit for the call. + * @param _target Address to call. + * @param _calldata Data to send to the call. + * @return _success Whether or not the call reverted. + * @return _returndata Data returned by the call. + */ + function safeCALL( + uint256 _gasLimit, + address _target, + bytes memory _calldata + ) + internal + returns ( + bool _success, + bytes memory _returndata + ) + { + bytes memory returndata = _safeExecutionManagerInteraction( + abi.encodeWithSignature( + "ovmCALL(uint256,address,bytes)", + _gasLimit, + _target, + _calldata + ) + ); + + return abi.decode(returndata, (bool, bytes)); + } + + /** + * Performs a safe ovmDELEGATECALL. + * @param _gasLimit Gas limit for the call. + * @param _target Address to call. + * @param _calldata Data to send to the call. + * @return _success Whether or not the call reverted. + * @return _returndata Data returned by the call. + */ + function safeDELEGATECALL( + uint256 _gasLimit, + address _target, + bytes memory _calldata + ) + internal + returns ( + bool _success, + bytes memory _returndata + ) + { + bytes memory returndata = _safeExecutionManagerInteraction( + abi.encodeWithSignature( + "ovmDELEGATECALL(uint256,address,bytes)", + _gasLimit, + _target, + _calldata + ) + ); + + return abi.decode(returndata, (bool, bytes)); + } + + /** + * Performs a safe ovmCREATE call. + * @param _gasLimit Gas limit for the creation. + * @param _bytecode Code for the new contract. + * @return _contract Address of the created contract. + */ + function safeCREATE( + uint256 _gasLimit, + bytes memory _bytecode + ) + internal + returns ( + address, + bytes memory + ) + { + bytes memory returndata = _safeExecutionManagerInteraction( + _gasLimit, + abi.encodeWithSignature( + "ovmCREATE(bytes)", + _bytecode + ) + ); + + return abi.decode(returndata, (address, bytes)); + } + + /** + * Performs a safe ovmEXTCODESIZE call. + * @param _contract Address of the contract to query the size of. + * @return _EXTCODESIZE Size of the requested contract in bytes. + */ + function safeEXTCODESIZE( + address _contract + ) + internal + returns ( + uint256 _EXTCODESIZE + ) + { + bytes memory returndata = _safeExecutionManagerInteraction( + abi.encodeWithSignature( + "ovmEXTCODESIZE(address)", + _contract + ) + ); + + return abi.decode(returndata, (uint256)); + } + + /** + * Performs a safe ovmCHAINID call. + * @return _CHAINID Result of calling ovmCHAINID. + */ + function safeCHAINID() + internal + returns ( + uint256 _CHAINID + ) + { + bytes memory returndata = _safeExecutionManagerInteraction( + abi.encodeWithSignature( + "ovmCHAINID()" + ) + ); + + return abi.decode(returndata, (uint256)); + } + + /** + * Performs a safe ovmCALLER call. + * @return _CALLER Result of calling ovmCALLER. + */ + function safeCALLER() + internal + returns ( + address _CALLER + ) + { + bytes memory returndata = _safeExecutionManagerInteraction( + abi.encodeWithSignature( + "ovmCALLER()" + ) + ); + + return abi.decode(returndata, (address)); + } + + /** + * Performs a safe ovmADDRESS call. + * @return _ADDRESS Result of calling ovmADDRESS. + */ + function safeADDRESS() + internal + returns ( + address _ADDRESS + ) + { + bytes memory returndata = _safeExecutionManagerInteraction( + abi.encodeWithSignature( + "ovmADDRESS()" + ) + ); + + return abi.decode(returndata, (address)); + } + + /** + * Performs a safe ovmGETNONCE call. + * @return _nonce Result of calling ovmGETNONCE. + */ + function safeGETNONCE() + internal + returns ( + uint256 _nonce + ) + { + bytes memory returndata = _safeExecutionManagerInteraction( + abi.encodeWithSignature( + "ovmGETNONCE()" + ) + ); + + return abi.decode(returndata, (uint256)); + } + + /** + * Performs a safe ovmINCREMENTNONCE call. + */ + function safeINCREMENTNONCE() + internal + { + _safeExecutionManagerInteraction( + abi.encodeWithSignature( + "ovmINCREMENTNONCE()" + ) + ); + } + + /** + * Performs a safe ovmCREATEEOA call. + * @param _messageHash Message hash which was signed by EOA + * @param _v v value of signature (0 or 1) + * @param _r r value of signature + * @param _s s value of signature + */ + function safeCREATEEOA( + bytes32 _messageHash, + uint8 _v, + bytes32 _r, + bytes32 _s + ) + internal + { + _safeExecutionManagerInteraction( + abi.encodeWithSignature( + "ovmCREATEEOA(bytes32,uint8,bytes32,bytes32)", + _messageHash, + _v, + _r, + _s + ) + ); + } + + /** + * Performs a safe REVERT. + * @param _reason String revert reason to pass along with the REVERT. + */ + function safeREVERT( + string memory _reason + ) + internal + { + _safeExecutionManagerInteraction( + abi.encodeWithSignature( + "ovmREVERT(bytes)", + Lib_ErrorUtils.encodeRevertString( + _reason + ) + ) + ); + } + + /** + * Performs a safe "require". + * @param _condition Boolean condition that must be true or will revert. + * @param _reason String revert reason to pass along with the REVERT. + */ + function safeREQUIRE( + bool _condition, + string memory _reason + ) + internal + { + if (!_condition) { + safeREVERT( + _reason + ); + } + } + + /** + * Performs a safe ovmSLOAD call. + */ + function safeSLOAD( + bytes32 _key + ) + internal + returns ( + bytes32 + ) + { + bytes memory returndata = _safeExecutionManagerInteraction( + abi.encodeWithSignature( + "ovmSLOAD(bytes32)", + _key + ) + ); + + return abi.decode(returndata, (bytes32)); + } + + /** + * Performs a safe ovmSSTORE call. + */ + function safeSSTORE( + bytes32 _key, + bytes32 _value + ) + internal + { + _safeExecutionManagerInteraction( + abi.encodeWithSignature( + "ovmSSTORE(bytes32,bytes32)", + _key, + _value + ) + ); + } + + /********************* + * Private Functions * + *********************/ + + /** + * Performs an ovm interaction and the necessary safety checks. + * @param _gasLimit Gas limit for the interaction. + * @param _calldata Data to send to the OVM_ExecutionManager (encoded with sighash). + * @return _returndata Data sent back by the OVM_ExecutionManager. + */ + function _safeExecutionManagerInteraction( + uint256 _gasLimit, + bytes memory _calldata + ) + private + returns ( + bytes memory _returndata + ) + { + address ovmExecutionManager = msg.sender; + ( + bool success, + bytes memory returndata + ) = ovmExecutionManager.call{gas: _gasLimit}(_calldata); + + if (success == false) { + assembly { + revert(add(returndata, 0x20), mload(returndata)) + } + } else if (returndata.length == 1) { + assembly { + return(0, 1) + } + } else { + return returndata; + } + } + + function _safeExecutionManagerInteraction( + bytes memory _calldata + ) + private + returns ( + bytes memory _returndata + ) + { + return _safeExecutionManagerInteraction( + gasleft(), + _calldata + ); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/libraries/wrappers/Lib_SafeMathWrapper.sol b/packages/contracts/contracts/optimistic-ethereum/libraries/wrappers/Lib_SafeMathWrapper.sol new file mode 100644 index 000000000000..767be1ff0b11 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/libraries/wrappers/Lib_SafeMathWrapper.sol @@ -0,0 +1,168 @@ +// SPDX-License-Identifier: MIT +// Pulled from @openzeppelin/contracts/math/SafeMath.sol +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_SafeExecutionManagerWrapper } from "./Lib_SafeExecutionManagerWrapper.sol"; + +/** + * @title Lib_SafeMathWrapper + */ + +/** + * @dev Wrappers over Solidity's arithmetic operations with added overflow + * checks. + * + * Arithmetic operations in Solidity wrap on overflow. This can easily result + * in bugs, because programmers usually assume that an overflow raises an + * error, which is the standard behavior in high level programming languages. + * `SafeMath` restores this intuition by reverting the transaction when an + * operation overflows. + * + * Using this library instead of the unchecked operations eliminates an entire + * class of bugs, so it's recommended to use it always. + */ + +library Lib_SafeMathWrapper { + /** + * @dev Returns the addition of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `+` operator. + * + * Requirements: + * + * - Addition cannot overflow. + */ + function add(uint256 a, uint256 b) internal returns (uint256) { + uint256 c = a + b; + Lib_SafeExecutionManagerWrapper.safeREQUIRE(c >= a, "Lib_SafeMathWrapper: addition overflow"); + + return c; + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b) internal returns (uint256) { + return sub(a, b, "Lib_SafeMathWrapper: subtraction overflow"); + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting with custom message on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b, string memory errorMessage) internal returns (uint256) { + Lib_SafeExecutionManagerWrapper.safeREQUIRE(b <= a, errorMessage); + uint256 c = a - b; + + return c; + } + + /** + * @dev Returns the multiplication of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `*` operator. + * + * Requirements: + * + * - Multiplication cannot overflow. + */ + function mul(uint256 a, uint256 b) internal returns (uint256) { + // Gas optimization: this is cheaper than requiring 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 + if (a == 0) { + return 0; + } + + uint256 c = a * b; + Lib_SafeExecutionManagerWrapper.safeREQUIRE(c / a == b, "Lib_SafeMathWrapper: multiplication overflow"); + + return c; + } + + /** + * @dev Returns the integer division of two unsigned integers. Reverts on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b) internal returns (uint256) { + return div(a, b, "Lib_SafeMathWrapper: division by zero"); + } + + /** + * @dev Returns the integer division of two unsigned integers. Reverts with custom message on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b, string memory errorMessage) internal returns (uint256) { + Lib_SafeExecutionManagerWrapper.safeREQUIRE(b > 0, errorMessage); + uint256 c = a / b; + // assert(a == b * c + a % b); // There is no case in which this doesn't hold + + return c; + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * Reverts when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b) internal returns (uint256) { + return mod(a, b, "Lib_SafeMathWrapper: modulo by zero"); + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * Reverts with custom message when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b, string memory errorMessage) internal returns (uint256) { + Lib_SafeExecutionManagerWrapper.safeREQUIRE(b != 0, errorMessage); + return a % b; + } +} \ No newline at end of file diff --git a/packages/contracts/contracts/optimistic-ethereum/mockOVM/accounts/mockOVM_ECDSAContractAccount.sol b/packages/contracts/contracts/optimistic-ethereum/mockOVM/accounts/mockOVM_ECDSAContractAccount.sol new file mode 100644 index 000000000000..15c51fcf21fb --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/mockOVM/accounts/mockOVM_ECDSAContractAccount.sol @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Interface Imports */ +import { iOVM_ECDSAContractAccount } from "../../iOVM/accounts/iOVM_ECDSAContractAccount.sol"; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; +import { Lib_ECDSAUtils } from "../../libraries/utils/Lib_ECDSAUtils.sol"; +import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol"; + +/** + * @title mockOVM_ECDSAContractAccount + */ +contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount { + + /******************** + * Public Functions * + ********************/ + + /** + * Executes a signed transaction. + * @param _transaction Signed EOA transaction. + * @param _signatureType Hashing scheme used for the transaction (e.g., ETH signed message). + * param _v Signature `v` parameter. + * param _r Signature `r` parameter. + * param _s Signature `s` parameter. + * @return _success Whether or not the call returned (rather than reverted). + * @return _returndata Data returned by the call. + */ + function execute( + bytes memory _transaction, + Lib_OVMCodec.EOASignatureType _signatureType, + uint8, // _v, + bytes32, // _r, + bytes32 // _s + ) + override + public + returns ( + bool _success, + bytes memory _returndata + ) + { + bool isEthSign = _signatureType == Lib_OVMCodec.EOASignatureType.ETH_SIGNED_MESSAGE; + Lib_OVMCodec.EIP155Transaction memory decodedTx = Lib_OVMCodec.decodeEIP155Transaction(_transaction, isEthSign); + + // Need to make sure that the transaction nonce is right. + Lib_SafeExecutionManagerWrapper.safeREQUIRE( + decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(), + "Transaction nonce does not match the expected nonce." + ); + + // Contract creations are signalled by sending a transaction to the zero address. + if (decodedTx.to == address(0)) { + (address created, ) = Lib_SafeExecutionManagerWrapper.safeCREATE( + decodedTx.gasLimit, + decodedTx.data + ); + + // If the created address is the ZERO_ADDRESS then we know the deployment failed, though not why + return (created != address(0), abi.encode(created)); + } else { + // We only want to bump the nonce for `ovmCALL` because `ovmCREATE` automatically bumps + // the nonce of the calling account. Normally an EOA would bump the nonce for both + // cases, but since this is a contract we'd end up bumping the nonce twice. + Lib_SafeExecutionManagerWrapper.safeINCREMENTNONCE(); + + return Lib_SafeExecutionManagerWrapper.safeCALL( + decodedTx.gasLimit, + decodedTx.to, + decodedTx.data + ); + } + } + + function qall( + uint256 _gasLimit, + address _to, + bytes memory _data + ) + public + returns ( + bool _success, + bytes memory _returndata + ) + { + return Lib_SafeExecutionManagerWrapper.safeCALL( + _gasLimit, + _to, + _data + ); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/mockOVM/bridge/mockOVM_CrossDomainMessenger.sol b/packages/contracts/contracts/optimistic-ethereum/mockOVM/bridge/mockOVM_CrossDomainMessenger.sol new file mode 100644 index 000000000000..2025e1050d48 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/mockOVM/bridge/mockOVM_CrossDomainMessenger.sol @@ -0,0 +1,145 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Contract Imports */ +import { iAbs_BaseCrossDomainMessenger } from "../../iOVM/bridge/messaging/iAbs_BaseCrossDomainMessenger.sol"; + +/** + * @title mockOVM_CrossDomainMessenger + */ +contract mockOVM_CrossDomainMessenger is iAbs_BaseCrossDomainMessenger { + + /*********** + * Structs * + ***********/ + + struct ReceivedMessage { + uint256 timestamp; + address target; + address sender; + bytes message; + uint256 messageNonce; + uint32 gasLimit; + } + + + /********************** + * Contract Variables * + **********************/ + + ReceivedMessage[] internal fullReceivedMessages; + address internal targetMessengerAddress; + uint256 internal lastRelayedMessage; + uint256 internal delay; + uint256 public messageNonce; + address override public xDomainMessageSender; + + + /*************** + * Constructor * + ***************/ + + /** + * @param _delay Time in seconds before a message can be relayed. + */ + constructor( + uint256 _delay + ) + { + delay = _delay; + } + + + /******************** + * Public Functions * + ********************/ + + /** + * Sets the target messenger address. + * @dev Currently, this function is public and therefore allows anyone to modify the target + * messenger for a given xdomain messenger contract. Obviously this shouldn't be allowed, + * but we still need to determine an adequate mechanism for updating this address. + * @param _targetMessengerAddress New messenger address. + */ + function setTargetMessengerAddress( + address _targetMessengerAddress + ) + public + { + targetMessengerAddress = _targetMessengerAddress; + } + + /** + * Sends a message to another mock xdomain messenger. + * @param _target Target for the message. + * @param _message Message to send. + * @param _gasLimit Amount of gas to send with the call. + */ + function sendMessage( + address _target, + bytes memory _message, + uint32 _gasLimit + ) + override + public + { + mockOVM_CrossDomainMessenger targetMessenger = mockOVM_CrossDomainMessenger( + targetMessengerAddress + ); + + // Just send it over! + targetMessenger.receiveMessage(ReceivedMessage({ + timestamp: block.timestamp, + target: _target, + sender: msg.sender, + message: _message, + messageNonce: messageNonce, + gasLimit: _gasLimit + })); + + messageNonce += 1; + } + + /** + * Receives a message to be sent later. + * @param _message Message to send later. + */ + function receiveMessage( + ReceivedMessage memory _message + ) + public + { + fullReceivedMessages.push(_message); + } + + /** + * Checks whether we have messages to relay. + * @param _exists Whether or not we have more messages to relay. + */ + function hasNextMessage() + public + view + returns ( + bool _exists + ) + { + return fullReceivedMessages.length > lastRelayedMessage; + } + + /** + * Relays the last received message not yet relayed. + */ + function relayNextMessage() + public + { + require(hasNextMessage(), "No pending messages to relay"); + ReceivedMessage memory nextMessage = fullReceivedMessages[lastRelayedMessage]; + require(nextMessage.timestamp + delay < block.timestamp, "Message is not ready to be relayed. The delay period is not up yet!"); + + xDomainMessageSender = nextMessage.sender; + (bool success,) = nextMessage.target.call{gas: nextMessage.gasLimit}(nextMessage.message); + require(success, "Cross-domain message call reverted. Did you set your gas limit high enough?"); + lastRelayedMessage += 1; + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/mockOVM/bridge/mockOVM_GenericCrossDomainMessenger.sol b/packages/contracts/contracts/optimistic-ethereum/mockOVM/bridge/mockOVM_GenericCrossDomainMessenger.sol new file mode 100644 index 000000000000..8ceeaca9d076 --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/mockOVM/bridge/mockOVM_GenericCrossDomainMessenger.sol @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/** + * @title mockOVM_GenericCrossDomainMessenger + * @dev An experimental alternative mock for local testing. + */ +contract mockOVM_GenericCrossDomainMessenger { + address public xDomainMessageSender; + + event SentMessage( + address _sender, + address _target, + bytes _message, + uint256 _gasLimit + ); + + function sendMessage( + address _target, + bytes memory _message, + uint32 _gasLimit + ) + public + { + emit SentMessage( + msg.sender, + _target, + _message, + _gasLimit + ); + } + + function relayMessage( + address _sender, + address _target, + bytes memory _message, + uint256 _gasLimit + ) + public + { + xDomainMessageSender = _sender; + (bool success, ) = _target.call{gas: _gasLimit}(_message); + require(success, "Cross-domain message call reverted. Did you set your gas limit high enough?"); + xDomainMessageSender = address(0); + } +} diff --git a/packages/contracts/contracts/optimistic-ethereum/mockOVM/verification/mockOVM_BondManager.sol b/packages/contracts/contracts/optimistic-ethereum/mockOVM/verification/mockOVM_BondManager.sol new file mode 100644 index 000000000000..7f030935cd7c --- /dev/null +++ b/packages/contracts/contracts/optimistic-ethereum/mockOVM/verification/mockOVM_BondManager.sol @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Interface Imports */ +import { iOVM_BondManager } from "../../iOVM/verification/iOVM_BondManager.sol"; + +/* Contract Imports */ +import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; + +/** + * @title mockOVM_BondManager + */ +contract mockOVM_BondManager is iOVM_BondManager, Lib_AddressResolver { + constructor( + address _libAddressManager + ) + Lib_AddressResolver(_libAddressManager) + {} + + function recordGasSpent( + bytes32 _preStateRoot, + bytes32 _txHash, + address _who, + uint256 _gasSpent + ) + override + public + {} + + function finalize( + bytes32 _preStateRoot, + address _publisher, + uint256 _timestamp + ) + override + public + {} + + function deposit() + override + public + {} + + function startWithdrawal() + override + public + {} + + function finalizeWithdrawal() + override + public + {} + + function claim( + address _who + ) + override + public + {} + + function isCollateralized( + address _who + ) + override + public + view + returns ( + bool + ) + { + // Only authenticate sequencer to submit state root batches. + return _who == resolve("OVM_Proposer"); + } + + function getGasSpent( + bytes32, // _preStateRoot, + address // _who + ) + override + public + pure + returns ( + uint256 + ) + { + return 0; + } +} diff --git a/packages/contracts/contracts/test-helpers/Helper_GasMeasurer.sol b/packages/contracts/contracts/test-helpers/Helper_GasMeasurer.sol new file mode 100644 index 000000000000..50f4474d2fff --- /dev/null +++ b/packages/contracts/contracts/test-helpers/Helper_GasMeasurer.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +contract Helper_GasMeasurer { + function measureCallGas( + address _target, + bytes memory _data + ) + public + returns ( uint256 ) + { + uint256 gasBefore; + uint256 gasAfter; + + uint256 calldataStart; + uint256 calldataLength; + assembly { + calldataStart := add(_data,0x20) + calldataLength := mload(_data) + } + + bool success; + assembly { + gasBefore := gas() + success := call(gas(), _target, 0, calldataStart, calldataLength, 0, 0) + gasAfter := gas() + } + require(success, "Call failed, but calls we want to measure gas for should succeed!"); + + return gasBefore - gasAfter; + } +} diff --git a/packages/contracts/contracts/test-helpers/Helper_ModifiableStorage.sol b/packages/contracts/contracts/test-helpers/Helper_ModifiableStorage.sol new file mode 100644 index 000000000000..03303dd45e87 --- /dev/null +++ b/packages/contracts/contracts/test-helpers/Helper_ModifiableStorage.sol @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +contract Helper_ModifiableStorage { + mapping (address => address) private target; + + constructor( + address _target + ) + { + target[address(this)] = _target; + } + + fallback() + external + { + (bool success, bytes memory returndata) = target[address(this)].delegatecall(msg.data); + + if (success) { + assembly { + return(add(returndata, 0x20), mload(returndata)) + } + } else { + assembly { + revert(add(returndata, 0x20), mload(returndata)) + } + } + } + + function __setStorageSlot( + bytes32 _key, + bytes32 _value + ) + public + { + assembly { + sstore(_key, _value) + } + } + + function __getStorageSlot( + bytes32 _key + ) + public + view + returns ( + bytes32 _value + ) + { + bytes32 value; + assembly { + value := sload(_key) + } + return value; + } +} diff --git a/packages/contracts/contracts/test-helpers/Helper_PrecompileCaller.sol b/packages/contracts/contracts/test-helpers/Helper_PrecompileCaller.sol new file mode 100644 index 000000000000..53fb914a740c --- /dev/null +++ b/packages/contracts/contracts/test-helpers/Helper_PrecompileCaller.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +import { Helper_SimpleProxy } from "./Helper_SimpleProxy.sol"; + +contract Helper_PredeployCaller is Helper_SimpleProxy { + function callPredeploy( + address _predeploy, + bytes memory _data + ) + public + { + if (msg.sender == owner) { + makeExternalCall(_predeploy, _data); + } else { + makeExternalCall(target, msg.data); + } + } + + function callPredeployAbi( + address _predeploy, + bytes memory _data + ) + public + returns ( + bytes memory + ) + { + + bool success; + bytes memory returndata; + if (msg.sender == owner) { + (success, returndata) = _predeploy.call(_data); + } else { + (success, returndata) = target.call(msg.data); + } + require(success, "Predeploy call reverted"); + return returndata; + } + + function getL1MessageSender( + address _predeploy, + bytes memory _data + ) + public + returns ( + address + ) + { + callPredeploy(_predeploy, _data); + return address(0); // unused: silence compiler + } +} diff --git a/packages/contracts/contracts/test-helpers/Helper_SimpleProxy.sol b/packages/contracts/contracts/test-helpers/Helper_SimpleProxy.sol new file mode 100644 index 000000000000..3ba74a24e935 --- /dev/null +++ b/packages/contracts/contracts/test-helpers/Helper_SimpleProxy.sol @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +contract Helper_SimpleProxy { + address internal owner; + address internal target; + + constructor() + { + owner = msg.sender; + } + + fallback() + external + { + makeExternalCall(target, msg.data); + } + + function setTarget( + address _target + ) + public + { + if (msg.sender == owner) { + target = _target; + } else { + makeExternalCall(target, msg.data); + } + } + + function makeExternalCall( + address _target, + bytes memory _calldata + ) + internal + { + (bool success, bytes memory returndata) = _target.call(_calldata); + + if (success) { + assembly { + return(add(returndata, 0x20), mload(returndata)) + } + } else { + assembly { + revert(add(returndata, 0x20), mload(returndata)) + } + } + } +} diff --git a/packages/contracts/contracts/test-helpers/Helper_TestRunner.sol b/packages/contracts/contracts/test-helpers/Helper_TestRunner.sol new file mode 100644 index 000000000000..8a46ef22b695 --- /dev/null +++ b/packages/contracts/contracts/test-helpers/Helper_TestRunner.sol @@ -0,0 +1,194 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Logging */ +import { console } from "hardhat/console.sol"; + +/** + * @title Helper_TestRunner + */ +contract Helper_TestRunner { + struct TestStep { + string functionName; + bytes functionData; + bool expectedReturnStatus; + bytes expectedReturnData; + bool onlyValidateFlag; + } + + function runSingleTestStep( + TestStep memory _step + ) + public + { + bytes32 namehash = keccak256(abi.encodePacked(_step.functionName)); + if (namehash == keccak256("evmRETURN")) { + bytes memory functionData = _step.functionData; + assembly { + return(add(functionData, 0x20), mload(functionData)) + } + } + if (namehash == keccak256("evmREVERT")) { + bytes memory functionData = _step.functionData; + assembly { + revert(add(functionData, 0x20), mload(functionData)) + } + } + if (namehash == keccak256("evmINVALID")) { + assembly { + invalid() + } + } + + (bool success, bytes memory returndata) = address(msg.sender).call(_step.functionData); + + if (success != _step.expectedReturnStatus) { + if (success == true) { + console.log("ERROR: Expected function to revert, but function returned successfully"); + console.log("Offending Step: %s", _step.functionName); + console.log("Return Data:"); + console.logBytes(returndata); + console.log(""); + } else { + ( + uint256 _flag, + uint256 _nuisanceGasLeft, + uint256 _ovmGasRefund, + bytes memory _data + ) = _decodeRevertData(returndata); + + console.log("ERROR: Expected function to return successfully, but function reverted"); + console.log("Offending Step: %s", _step.functionName); + console.log("Flag: %s", _flag); + console.log("Nuisance Gas Left: %s", _nuisanceGasLeft); + console.log("OVM Gas Refund: %s", _ovmGasRefund); + console.log("Extra Data:"); + console.logBytes(_data); + console.log(""); + } + + _failStep(); + } + + if (keccak256(returndata) != keccak256(_step.expectedReturnData)) { + if (success == true) { + console.log("ERROR: Actual return data does not match expected return data"); + console.log("Offending Step: %s", _step.functionName); + console.log("Expected:"); + console.logBytes(_step.expectedReturnData); + console.log("Actual:"); + console.logBytes(returndata); + console.log(""); + + _failStep(); + } else { + ( + uint256 _expectedFlag, + uint256 _expectedNuisanceGasLeft, + uint256 _expectedOvmGasRefund, + bytes memory _expectedData + ) = _decodeRevertData(_step.expectedReturnData); + + ( + uint256 _flag, + uint256 _nuisanceGasLeft, + uint256 _ovmGasRefund, + bytes memory _data + ) = _decodeRevertData(returndata); + + if ( + _step.onlyValidateFlag + ) { + if ( + _expectedFlag != _flag + ) { + console.log("ERROR: Actual revert flag does not match expected revert flag data"); + console.log("Offending Step: %s", _step.functionName); + console.log("Expected Flag: %s", _expectedFlag); + console.log("Actual Flag: %s", _flag); + _failStep(); + } + } else { + console.log("ERROR: Actual revert flag data does not match expected revert flag data"); + console.log("Offending Step: %s", _step.functionName); + console.log("Expected Flag: %s", _expectedFlag); + console.log("Actual Flag: %s", _flag); + console.log("Expected Nuisance Gas Left: %s", _expectedNuisanceGasLeft); + console.log("Actual Nuisance Gas Left: %s", _nuisanceGasLeft); + console.log("Expected OVM Gas Refund: %s", _expectedOvmGasRefund); + console.log("Actual OVM Gas Refund: %s", _ovmGasRefund); + console.log("Expected Extra Data:"); + console.logBytes(_expectedData); + console.log("Actual Extra Data:"); + console.logBytes(_data); + console.log(""); + _failStep(); + } + } + } + + if (success == false) { + assembly { + revert(add(returndata, 0x20), mload(returndata)) + } + } + } + + function runMultipleTestSteps( + TestStep[] memory _steps + ) + public + { + for (uint256 i = 0; i < _steps.length; i++) { + runSingleTestStep(_steps[i]); + } + } + + function _decodeRevertData( + bytes memory _revertdata + ) + internal + pure + returns ( + uint256 _flag, + uint256 _nuisanceGasLeft, + uint256 _ovmGasRefund, + bytes memory _data + ) + { + if (_revertdata.length == 0) { + return ( + 0, + 0, + 0, + bytes('') + ); + } + + return abi.decode(_revertdata, (uint256, uint256, uint256, bytes)); + } + + function _failStep() + internal + pure + { + revert("Test step failed."); + } +} + +contract Helper_TestRunner_CREATE is Helper_TestRunner { + constructor( + bytes memory _bytecode, + TestStep[] memory _steps + ) + { + if (_steps.length > 0) { + runMultipleTestSteps(_steps); + } else { + assembly { + return(add(_bytecode, 0x20), mload(_bytecode)) + } + } + } +} diff --git a/packages/contracts/contracts/test-helpers/Mock_FraudVerifier.sol b/packages/contracts/contracts/test-helpers/Mock_FraudVerifier.sol new file mode 100644 index 000000000000..8b8221e8ba01 --- /dev/null +++ b/packages/contracts/contracts/test-helpers/Mock_FraudVerifier.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +import { OVM_BondManager } from "./../optimistic-ethereum/OVM/verification/OVM_BondManager.sol"; + +contract Mock_FraudVerifier { + OVM_BondManager bondManager; + + mapping (bytes32 => address) transitioners; + + function setBondManager(OVM_BondManager _bondManager) public { + bondManager = _bondManager; + } + + function setStateTransitioner(bytes32 preStateRoot, bytes32 txHash, address addr) public { + transitioners[keccak256(abi.encodePacked(preStateRoot, txHash))] = addr; + } + + function getStateTransitioner( + bytes32 _preStateRoot, + bytes32 _txHash + ) + public + view + returns ( + address + ) + { + return transitioners[keccak256(abi.encodePacked(_preStateRoot, _txHash))]; + } + + function finalize(bytes32 _preStateRoot, address publisher, uint256 timestamp) public { + bondManager.finalize(_preStateRoot, publisher, timestamp); + } +} diff --git a/packages/contracts/contracts/test-helpers/TestERC20.sol b/packages/contracts/contracts/test-helpers/TestERC20.sol new file mode 100644 index 000000000000..9671dee68ea8 --- /dev/null +++ b/packages/contracts/contracts/test-helpers/TestERC20.sol @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +// a test ERC20 token with an open mint function +contract TestERC20 { + using SafeMath for uint; + + string public constant name = 'Test'; + string public constant symbol = 'TST'; + uint8 public constant decimals = 18; + uint256 public totalSupply; + mapping(address => uint) public balanceOf; + mapping(address => mapping(address => uint)) public allowance; + + event Approval(address indexed owner, address indexed spender, uint256 value); + event Transfer(address indexed from, address indexed to, uint256 value); + + constructor() {} + + function mint(address to, uint256 value) public { + totalSupply = totalSupply.add(value); + balanceOf[to] = balanceOf[to].add(value); + emit Transfer(address(0), to, value); + } + + function _approve(address owner, address spender, uint256 value) private { + allowance[owner][spender] = value; + emit Approval(owner, spender, value); + } + + function _transfer(address from, address to, uint256 value) private { + balanceOf[from] = balanceOf[from].sub(value); + balanceOf[to] = balanceOf[to].add(value); + emit Transfer(from, to, value); + } + + function approve(address spender, uint256 value) external returns (bool) { + _approve(msg.sender, spender, value); + return true; + } + + function transfer(address to, uint256 value) external returns (bool) { + _transfer(msg.sender, to, value); + return true; + } + + function transferFrom(address from, address to, uint256 value) external returns (bool) { + if (allowance[from][msg.sender] != uint(-1)) { + allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); + } + _transfer(from, to, value); + return true; + } +} + +library SafeMath { + function add(uint256 x, uint256 y) internal pure returns (uint256 z) { + require((z = x + y) >= x, 'ds-math-add-overflow'); + } + + function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { + require((z = x - y) <= x, 'ds-math-sub-underflow'); + } + + function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { + require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow'); + } +} diff --git a/packages/contracts/contracts/test-libraries/codec/TestLib_OVMCodec.sol b/packages/contracts/contracts/test-libraries/codec/TestLib_OVMCodec.sol new file mode 100644 index 000000000000..b9046ac8a776 --- /dev/null +++ b/packages/contracts/contracts/test-libraries/codec/TestLib_OVMCodec.sol @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_OVMCodec } from "../../optimistic-ethereum/libraries/codec/Lib_OVMCodec.sol"; + +/** + * @title TestLib_OVMCodec + */ +contract TestLib_OVMCodec { + + function decodeEIP155Transaction( + bytes memory _transaction, + bool _isEthSignedMessage + ) + public + pure + returns ( + Lib_OVMCodec.EIP155Transaction memory _decoded + ) + { + return Lib_OVMCodec.decodeEIP155Transaction(_transaction, _isEthSignedMessage); + } + + function encodeTransaction( + Lib_OVMCodec.Transaction memory _transaction + ) + public + pure + returns ( + bytes memory _encoded + ) + { + return Lib_OVMCodec.encodeTransaction(_transaction); + } + + function hashTransaction( + Lib_OVMCodec.Transaction memory _transaction + ) + public + pure + returns ( + bytes32 _hash + ) + { + return Lib_OVMCodec.hashTransaction(_transaction); + } + + function decompressEIP155Transaction( + bytes memory _transaction + ) + public + returns ( + Lib_OVMCodec.EIP155Transaction memory _decompressed + ) + { + return Lib_OVMCodec.decompressEIP155Transaction(_transaction); + } +} diff --git a/packages/contracts/contracts/test-libraries/rlp/TestLib_RLPReader.sol b/packages/contracts/contracts/test-libraries/rlp/TestLib_RLPReader.sol new file mode 100644 index 000000000000..199592a54661 --- /dev/null +++ b/packages/contracts/contracts/test-libraries/rlp/TestLib_RLPReader.sol @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_RLPReader } from "../../optimistic-ethereum/libraries/rlp/Lib_RLPReader.sol"; + +/** + * @title TestLib_RLPReader + */ +contract TestLib_RLPReader { + + function readList( + bytes memory _in + ) + public + pure + returns ( + bytes[] memory + ) + { + Lib_RLPReader.RLPItem[] memory decoded = Lib_RLPReader.readList(_in); + bytes[] memory out = new bytes[](decoded.length); + for (uint256 i = 0; i < out.length; i++) { + out[i] = Lib_RLPReader.readRawBytes(decoded[i]); + } + return out; + } + + function readString( + bytes memory _in + ) + public + pure + returns ( + string memory + ) + { + return Lib_RLPReader.readString(_in); + } + + function readBytes( + bytes memory _in + ) + public + pure + returns ( + bytes memory + ) + { + return Lib_RLPReader.readBytes(_in); + } + + function readBytes32( + bytes memory _in + ) + public + pure + returns ( + bytes32 + ) + { + return Lib_RLPReader.readBytes32(_in); + } + + function readUint256( + bytes memory _in + ) + public + pure + returns ( + uint256 + ) + { + return Lib_RLPReader.readUint256(_in); + } + + function readBool( + bytes memory _in + ) + public + pure + returns ( + bool + ) + { + return Lib_RLPReader.readBool(_in); + } + + function readAddress( + bytes memory _in + ) + public + pure + returns ( + address + ) + { + return Lib_RLPReader.readAddress(_in); + } +} diff --git a/packages/contracts/contracts/test-libraries/rlp/TestLib_RLPWriter.sol b/packages/contracts/contracts/test-libraries/rlp/TestLib_RLPWriter.sol new file mode 100644 index 000000000000..6888a596daad --- /dev/null +++ b/packages/contracts/contracts/test-libraries/rlp/TestLib_RLPWriter.sol @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_RLPWriter } from "../../optimistic-ethereum/libraries/rlp/Lib_RLPWriter.sol"; +import { TestERC20 } from "../../test-helpers/TestERC20.sol"; + +/** + * @title TestLib_RLPWriter + */ +contract TestLib_RLPWriter { + + function writeBytes( + bytes memory _in + ) + public + pure + returns ( + bytes memory _out + ) + { + return Lib_RLPWriter.writeBytes(_in); + } + + function writeList( + bytes[] memory _in + ) + public + pure + returns ( + bytes memory _out + ) + { + return Lib_RLPWriter.writeList(_in); + } + + function writeString( + string memory _in + ) + public + pure + returns ( + bytes memory _out + ) + { + return Lib_RLPWriter.writeString(_in); + } + + function writeAddress( + address _in + ) + public + pure + returns ( + bytes memory _out + ) + { + return Lib_RLPWriter.writeAddress(_in); + } + + function writeUint( + uint256 _in + ) + public + pure + returns ( + bytes memory _out + ) + { + return Lib_RLPWriter.writeUint(_in); + } + + function writeBool( + bool _in + ) + public + pure + returns ( + bytes memory _out + ) + { + return Lib_RLPWriter.writeBool(_in); + } + + function writeAddressWithTaintedMemory( + address _in + ) + public + returns ( + bytes memory _out + ) + { + new TestERC20(); + return Lib_RLPWriter.writeAddress(_in); + } +} diff --git a/packages/contracts/contracts/test-libraries/trie/TestLib_MerkleTrie.sol b/packages/contracts/contracts/test-libraries/trie/TestLib_MerkleTrie.sol new file mode 100644 index 000000000000..36335db39f14 --- /dev/null +++ b/packages/contracts/contracts/test-libraries/trie/TestLib_MerkleTrie.sol @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_MerkleTrie } from "../../optimistic-ethereum/libraries/trie/Lib_MerkleTrie.sol"; + +/** + * @title TestLib_MerkleTrie + */ +contract TestLib_MerkleTrie { + + function verifyInclusionProof( + bytes memory _key, + bytes memory _value, + bytes memory _proof, + bytes32 _root + ) + public + pure + returns ( + bool + ) + { + return Lib_MerkleTrie.verifyInclusionProof( + _key, + _value, + _proof, + _root + ); + } + + function verifyExclusionProof( + bytes memory _key, + bytes memory _proof, + bytes32 _root + ) + public + pure + returns ( + bool + ) + { + return Lib_MerkleTrie.verifyExclusionProof( + _key, + _proof, + _root + ); + } + + function update( + bytes memory _key, + bytes memory _value, + bytes memory _proof, + bytes32 _root + ) + public + pure + returns ( + bytes32 + ) + { + return Lib_MerkleTrie.update( + _key, + _value, + _proof, + _root + ); + } + + function get( + bytes memory _key, + bytes memory _proof, + bytes32 _root + ) + public + pure + returns ( + bool, + bytes memory + ) + { + return Lib_MerkleTrie.get( + _key, + _proof, + _root + ); + } + + function getSingleNodeRootHash( + bytes memory _key, + bytes memory _value + ) + public + pure + returns ( + bytes32 + ) + { + return Lib_MerkleTrie.getSingleNodeRootHash( + _key, + _value + ); + } +} diff --git a/packages/contracts/contracts/test-libraries/trie/TestLib_SecureMerkleTrie.sol b/packages/contracts/contracts/test-libraries/trie/TestLib_SecureMerkleTrie.sol new file mode 100644 index 000000000000..5ab749a42647 --- /dev/null +++ b/packages/contracts/contracts/test-libraries/trie/TestLib_SecureMerkleTrie.sol @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_SecureMerkleTrie } from "../../optimistic-ethereum/libraries/trie/Lib_SecureMerkleTrie.sol"; + +/** + * @title TestLib_SecureMerkleTrie + */ +contract TestLib_SecureMerkleTrie { + + function verifyInclusionProof( + bytes memory _key, + bytes memory _value, + bytes memory _proof, + bytes32 _root + ) + public + pure + returns ( + bool + ) + { + return Lib_SecureMerkleTrie.verifyInclusionProof( + _key, + _value, + _proof, + _root + ); + } + + function verifyExclusionProof( + bytes memory _key, + bytes memory _proof, + bytes32 _root + ) + public + pure + returns ( + bool + ) + { + return Lib_SecureMerkleTrie.verifyExclusionProof( + _key, + _proof, + _root + ); + } + + function update( + bytes memory _key, + bytes memory _value, + bytes memory _proof, + bytes32 _root + ) + public + pure + returns ( + bytes32 + ) + { + return Lib_SecureMerkleTrie.update( + _key, + _value, + _proof, + _root + ); + } + + function get( + bytes memory _key, + bytes memory _proof, + bytes32 _root + ) + public + pure + returns ( + bool, + bytes memory + ) + { + return Lib_SecureMerkleTrie.get( + _key, + _proof, + _root + ); + } + + function getSingleNodeRootHash( + bytes memory _key, + bytes memory _value + ) + public + pure + returns ( + bytes32 + ) + { + return Lib_SecureMerkleTrie.getSingleNodeRootHash( + _key, + _value + ); + } +} diff --git a/packages/contracts/contracts/test-libraries/utils/TestLib_Bytes32Utils.sol b/packages/contracts/contracts/test-libraries/utils/TestLib_Bytes32Utils.sol new file mode 100644 index 000000000000..402693fe40d4 --- /dev/null +++ b/packages/contracts/contracts/test-libraries/utils/TestLib_Bytes32Utils.sol @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_Bytes32Utils } from "../../optimistic-ethereum/libraries/utils/Lib_Bytes32Utils.sol"; + +/** + * @title TestLib_Byte32Utils + */ +contract TestLib_Bytes32Utils { + + function toBool( + bytes32 _in + ) + public + pure + returns ( + bool _out + ) + { + return Lib_Bytes32Utils.toBool(_in); + } + + function fromBool( + bool _in + ) + public + pure + returns ( + bytes32 _out + ) + { + return Lib_Bytes32Utils.fromBool(_in); + } + + function toAddress( + bytes32 _in + ) + public + pure + returns ( + address _out + ) + { + return Lib_Bytes32Utils.toAddress(_in); + } + + function fromAddress( + address _in + ) + public + pure + returns ( + bytes32 _out + ) + { + return Lib_Bytes32Utils.fromAddress(_in); + } +} diff --git a/packages/contracts/contracts/test-libraries/utils/TestLib_BytesUtils.sol b/packages/contracts/contracts/test-libraries/utils/TestLib_BytesUtils.sol new file mode 100644 index 000000000000..21b75e1b0d61 --- /dev/null +++ b/packages/contracts/contracts/test-libraries/utils/TestLib_BytesUtils.sol @@ -0,0 +1,121 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_BytesUtils } from "../../optimistic-ethereum/libraries/utils/Lib_BytesUtils.sol"; +import { TestERC20 } from "../../test-helpers/TestERC20.sol"; + +/** + * @title TestLib_BytesUtils + */ +contract TestLib_BytesUtils { + + function concat( + bytes memory _preBytes, + bytes memory _postBytes + ) + public + pure + returns (bytes memory) + { + return abi.encodePacked( + _preBytes, + _postBytes + ); + } + + function slice( + bytes memory _bytes, + uint256 _start, + uint256 _length + ) + public + pure + returns (bytes memory) + { + return Lib_BytesUtils.slice( + _bytes, + _start, + _length + ); + } + + function toBytes32( + bytes memory _bytes + ) + public + pure + returns (bytes32) + { + return Lib_BytesUtils.toBytes32( + _bytes + ); + } + + function toUint256( + bytes memory _bytes + ) + public + pure + returns (uint256) + { + return Lib_BytesUtils.toUint256( + _bytes + ); + } + + function toNibbles( + bytes memory _bytes + ) + public + pure + returns (bytes memory) + { + return Lib_BytesUtils.toNibbles( + _bytes + ); + } + + function fromNibbles( + bytes memory _bytes + ) + public + pure + returns (bytes memory) + { + return Lib_BytesUtils.fromNibbles( + _bytes + ); + } + + function equal( + bytes memory _bytes, + bytes memory _other + ) + public + pure + returns (bool) + { + return Lib_BytesUtils.equal( + _bytes, + _other + ); + } + + function sliceWithTaintedMemory( + bytes memory _bytes, + uint256 _start, + uint256 _length + ) + public + returns (bytes memory) + { + new TestERC20(); + return Lib_BytesUtils.slice( + _bytes, + _start, + _length + ); + } +} diff --git a/packages/contracts/contracts/test-libraries/utils/TestLib_ECDSAUtils.sol b/packages/contracts/contracts/test-libraries/utils/TestLib_ECDSAUtils.sol new file mode 100644 index 000000000000..4b66bf7f0ec8 --- /dev/null +++ b/packages/contracts/contracts/test-libraries/utils/TestLib_ECDSAUtils.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; + +/* Library Imports */ +import { Lib_ECDSAUtils } from "../../optimistic-ethereum/libraries/utils/Lib_ECDSAUtils.sol"; + +/** + * @title TestLib_ECDSAUtils + */ +contract TestLib_ECDSAUtils { + + function recover( + bytes memory _message, + bool _isEthSignedMessage, + uint8 _v, + bytes32 _r, + bytes32 _s + ) + public + pure + returns ( + address _sender + ) + { + return Lib_ECDSAUtils.recover( + _message, + _isEthSignedMessage, + _v, + _r, + _s + ); + } +} diff --git a/packages/contracts/contracts/test-libraries/utils/TestLib_EthUtils.sol b/packages/contracts/contracts/test-libraries/utils/TestLib_EthUtils.sol new file mode 100644 index 000000000000..2949e763a496 --- /dev/null +++ b/packages/contracts/contracts/test-libraries/utils/TestLib_EthUtils.sol @@ -0,0 +1,118 @@ +// SPDX-License-Identifier: MIT +// @unsupported: ovm +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_EthUtils } from "../../optimistic-ethereum/libraries/utils/Lib_EthUtils.sol"; + +/** + * @title TestLib_EthUtils + */ +contract TestLib_EthUtils { + + function getCode( + address _address, + uint256 _offset, + uint256 _length + ) + public + view + returns ( + bytes memory _code + ) + { + return Lib_EthUtils.getCode( + _address, + _offset, + _length + ); + } + + function getCode( + address _address + ) + public + view + returns ( + bytes memory _code + ) + { + return Lib_EthUtils.getCode( + _address + ); + } + + function getCodeSize( + address _address + ) + public + view + returns ( + uint256 _codeSize + ) + { + return Lib_EthUtils.getCodeSize( + _address + ); + } + + function getCodeHash( + address _address + ) + public + view + returns ( + bytes32 _codeHash + ) + { + return Lib_EthUtils.getCodeHash( + _address + ); + } + + function createContract( + bytes memory _code + ) + public + returns ( + address _created + ) + { + return Lib_EthUtils.createContract( + _code + ); + } + + function getAddressForCREATE( + address _creator, + uint256 _nonce + ) + public + pure + returns ( + address _address + ) + { + return Lib_EthUtils.getAddressForCREATE( + _creator, + _nonce + ); + } + + function getAddressForCREATE2( + address _creator, + bytes memory _bytecode, + bytes32 _salt + ) + public + pure + returns (address _address) + { + return Lib_EthUtils.getAddressForCREATE2( + _creator, + _bytecode, + _salt + ); + } +} diff --git a/packages/contracts/contracts/test-libraries/utils/TestLib_MerkleTree.sol b/packages/contracts/contracts/test-libraries/utils/TestLib_MerkleTree.sol new file mode 100644 index 000000000000..30a93504b56e --- /dev/null +++ b/packages/contracts/contracts/test-libraries/utils/TestLib_MerkleTree.sol @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_MerkleTree } from "../../optimistic-ethereum/libraries/utils/Lib_MerkleTree.sol"; + +/** + * @title TestLib_MerkleTree + */ +contract TestLib_MerkleTree { + + function getMerkleRoot( + bytes32[] memory _elements + ) + public + pure + returns ( + bytes32 + ) + { + return Lib_MerkleTree.getMerkleRoot( + _elements + ); + } + + function verify( + bytes32 _root, + bytes32 _leaf, + uint256 _index, + bytes32[] memory _siblings, + uint256 _totalLeaves + ) + public + pure + returns ( + bool + ) + { + return Lib_MerkleTree.verify( + _root, + _leaf, + _index, + _siblings, + _totalLeaves + ); + } +} diff --git a/packages/contracts/contracts/test-libraries/utils/TestLib_RingBuffer.sol b/packages/contracts/contracts/test-libraries/utils/TestLib_RingBuffer.sol new file mode 100644 index 000000000000..b1bddcf7a646 --- /dev/null +++ b/packages/contracts/contracts/test-libraries/utils/TestLib_RingBuffer.sol @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: MIT +pragma solidity >0.5.0 <0.8.0; +pragma experimental ABIEncoderV2; + +/* Library Imports */ +import { Lib_RingBuffer } from "../../optimistic-ethereum/libraries/utils/Lib_RingBuffer.sol"; + +/** + * @title TestLib_RingBuffer + */ +contract TestLib_RingBuffer { + using Lib_RingBuffer for Lib_RingBuffer.RingBuffer; + + Lib_RingBuffer.RingBuffer internal buf; + + function push( + bytes32 _value, + bytes27 _extraData + ) + public + { + buf.push( + _value, + _extraData + ); + } + + function get( + uint256 _index + ) + public + view + returns ( + bytes32 + ) + { + return buf.get(_index); + } + + function deleteElementsAfterInclusive( + uint40 _index, + bytes27 _extraData + ) + internal + { + return buf.deleteElementsAfterInclusive( + _index, + _extraData + ); + } + + function getLength() + internal + view + returns ( + uint40 + ) + { + return buf.getLength(); + } + + function getExtraData() + internal + view + returns ( + bytes27 + ) + { + return buf.getExtraData(); + } +} diff --git a/packages/contracts/hardhat.config.ts b/packages/contracts/hardhat.config.ts new file mode 100644 index 000000000000..606c2527cb79 --- /dev/null +++ b/packages/contracts/hardhat.config.ts @@ -0,0 +1,41 @@ +import { HardhatUserConfig } from 'hardhat/types' + +import { + DEFAULT_ACCOUNTS_HARDHAT, + RUN_OVM_TEST_GAS, +} from './test/helpers/constants' + +// Hardhat plugins +import '@nomiclabs/hardhat-ethers' +import '@nomiclabs/hardhat-waffle' +import '@typechain/hardhat' +import '@eth-optimism/hardhat-ovm' + +const config: HardhatUserConfig = { + networks: { + hardhat: { + accounts: DEFAULT_ACCOUNTS_HARDHAT, + blockGasLimit: RUN_OVM_TEST_GAS * 2, + }, + }, + mocha: { + timeout: 50000, + }, + solidity: { + version: '0.7.6', + settings: { + optimizer: { enabled: true, runs: 200 }, + outputSelection: { + '*': { + '*': ['storageLayout'], + }, + }, + }, + }, + typechain: { + outDir: 'dist/types', + target: 'ethers-v5', + }, +} + +export default config diff --git a/packages/contracts/package.json b/packages/contracts/package.json new file mode 100644 index 000000000000..73431bf510c1 --- /dev/null +++ b/packages/contracts/package.json @@ -0,0 +1,73 @@ +{ + "name": "@eth-optimism/contracts", + "version": "0.1.11", + "main": "dist/index", + "files": [ + "dist/index" + ], + "types": "dist/index", + "license": "MIT", + "scripts": { + "all": "yarn clean && yarn build && yarn test && yarn lint:fix && yarn lint", + "build": "yarn run build:contracts && yarn run build:contracts:ovm && yarn run build:typescript && yarn run build:copy && yarn run build:dump && yarn run build:typechain", + "build:kovan": "yarn run build:contracts && yarn run build:typescript && yarn run build:copy && CHAIN_ID=69 yarn run build:dump && yarn run build:typechain", + "build:mainnet": "yarn run build:contracts && yarn run build:typescript && yarn run build:copy && CHAIN_ID=10 yarn run build:dump && yarn run build:typechain", + "build:typescript": "tsc -p ./tsconfig.build.json", + "build:contracts": "hardhat compile --show-stack-traces", + "build:contracts:ovm": "TARGET=ovm hardhat compile --show-stack-traces", + "build:dump": "ts-node \"bin/take-dump.ts\"", + "build:copy": "yarn run build:copy:artifacts && yarn build:copy:artifacts:ovm && yarn run build:copy:contracts", + "build:copy:artifacts": "copyfiles -u 1 \"artifacts/**/*.json\" \"dist/artifacts\"", + "build:copy:artifacts:ovm": "copyfiles -u 1 \"artifacts-ovm/**/*.json\" \"dist/artifacts-ovm\"", + "build:copy:contracts": "copyfiles -u 2 \"contracts/optimistic-ethereum/**/*.sol\" \"dist/contracts\"", + "build:typechain": "hardhat typechain", + "test": "yarn run test:contracts", + "test:contracts": "hardhat test --show-stack-traces", + "test:gas": "hardhat test \"test/contracts/OVM/execution/OVM_StateManager.gas-spec.ts\" --no-compile --show-stack-traces", + "lint": "yarn run lint:typescript", + "lint:typescript": "tslint --format stylish --project .", + "lint:fix": "yarn run lint:fix:typescript", + "lint:fix:typescript": "prettier --config prettier-config.json --write \"hardhat.config.ts\" \"{src,test}/**/*.ts\"", + "clean": "rm -rf ./dist ./artifacts ./artifacts-ovm ./cache ./cache-ovm", + "deploy": "./bin/deploy.js", + "serve": "./bin/serve_dump.sh" + }, + "dependencies": { + "@eth-optimism/core-utils": "^0.1.10", + "@eth-optimism/solc": "^0.6.12-alpha.1", + "@ethersproject/abstract-provider": "^5.0.8", + "@ethersproject/contracts": "^5.0.5", + "@ethersproject/hardware-wallets": "^5.0.8", + "@openzeppelin/contracts": "^3.3.0", + "@typechain/hardhat": "^1.0.1", + "ganache-core": "^2.13.2", + "glob": "^7.1.6" + }, + "devDependencies": { + "@eth-optimism/hardhat-ovm": "^0.0.1", + "@eth-optimism/smock": "^1.0.0-alpha.3", + "@nomiclabs/hardhat-ethers": "^2.0.1", + "@nomiclabs/hardhat-waffle": "^2.0.1", + "@typechain/ethers-v5": "1.0.0", + "@types/glob": "^7.1.3", + "@types/lodash": "^4.14.161", + "buffer-xor": "^2.0.2", + "chai": "^4.3.1", + "copyfiles": "^2.3.0", + "ethereum-waffle": "^3.3.0", + "ethers": "^5.0.31", + "hardhat": "^2.0.8", + "lodash": "^4.17.20", + "merkle-patricia-tree": "^4.0.0", + "merkletreejs": "^0.2.12", + "mkdirp": "^1.0.4", + "mocha": "^8.3.0", + "random-bytes-seed": "^1.0.3", + "rlp": "^2.2.6", + "ts-generator": "0.0.8", + "typechain": "2.0.0" + }, + "peerDependencies": { + "ethers": "^5.0.0" + } +} diff --git a/packages/contracts/prettier-config.json b/packages/contracts/prettier-config.json new file mode 120000 index 000000000000..e9de01cf0ce0 --- /dev/null +++ b/packages/contracts/prettier-config.json @@ -0,0 +1 @@ +../../prettier-config.json \ No newline at end of file diff --git a/packages/contracts/src/contract-defs.ts b/packages/contracts/src/contract-defs.ts new file mode 100644 index 000000000000..8155512e9326 --- /dev/null +++ b/packages/contracts/src/contract-defs.ts @@ -0,0 +1,35 @@ +import * as path from 'path' +import * as glob from 'glob' +import { ethers, ContractFactory, Signer } from 'ethers' +import { Interface } from 'ethers/lib/utils' + +export const getContractDefinition = (name: string, ovm?: boolean): any => { + const match = glob.sync( + path.resolve(__dirname, `../artifacts${ovm ? '-ovm' : ''}`) + + `/**/${name}.json` + ) + + if (match.length > 0) { + return require(match[0]) + } else { + throw new Error(`Unable to find artifact for contract: ${name}`) + } +} + +export const getContractInterface = ( + name: string, + ovm?: boolean +): Interface => { + const definition = getContractDefinition(name, ovm) + return new ethers.utils.Interface(definition.abi) +} + +export const getContractFactory = ( + name: string, + signer?: Signer, + ovm?: boolean +): ContractFactory => { + const definition = getContractDefinition(name, ovm) + const contractInterface = getContractInterface(name, ovm) + return new ContractFactory(contractInterface, definition.bytecode, signer) +} diff --git a/packages/contracts/src/contract-deployment/config.ts b/packages/contracts/src/contract-deployment/config.ts new file mode 100644 index 000000000000..b12d04960a72 --- /dev/null +++ b/packages/contracts/src/contract-deployment/config.ts @@ -0,0 +1,245 @@ +/* External Imports */ +import { Signer, ContractFactory, Contract } from 'ethers' +import { TransactionResponse } from '@ethersproject/abstract-provider' +import { Overrides } from '@ethersproject/contracts' + +/* Internal Imports */ +import { getContractFactory } from '../contract-defs' + +export interface RollupDeployConfig { + deploymentSigner: Signer + ovmGasMeteringConfig: { + minTransactionGasLimit: number + maxTransactionGasLimit: number + maxGasPerQueuePerEpoch: number + secondsPerEpoch: number + } + ovmGlobalContext: { + ovmCHAINID: number + L2CrossDomainMessengerAddress: string + } + transactionChainConfig: { + sequencer: string | Signer + forceInclusionPeriodSeconds: number + forceInclusionPeriodBlocks: number + } + stateChainConfig: { + fraudProofWindowSeconds: number + sequencerPublishWindowSeconds: number + } + l1CrossDomainMessengerConfig: { + relayerAddress?: string | Signer + } + whitelistConfig: { + owner: string | Signer + allowArbitraryContractDeployment: boolean + } + addressManager?: string + dependencies?: string[] + deployOverrides: Overrides + waitForReceipts: boolean +} + +export interface ContractDeployParameters { + factory: ContractFactory + params?: any[] + afterDeploy?: (contracts?: { [name: string]: Contract }) => Promise +} + +export interface ContractDeployConfig { + [name: string]: ContractDeployParameters +} + +export const makeContractDeployConfig = async ( + config: RollupDeployConfig, + AddressManager: Contract +): Promise => { + const _sendTx = async ( + txPromise: Promise + ): Promise => { + const res = await txPromise + if (config.waitForReceipts) { + await res.wait() + } + return res + } + + return { + OVM_L2CrossDomainMessenger: { + factory: getContractFactory('OVM_L2CrossDomainMessenger'), + params: [AddressManager.address], + }, + OVM_L1CrossDomainMessenger: { + factory: getContractFactory('OVM_L1CrossDomainMessenger'), + params: [], + afterDeploy: async (contracts): Promise => { + if (config.l1CrossDomainMessengerConfig.relayerAddress) { + const relayer = config.l1CrossDomainMessengerConfig.relayerAddress + const address = + typeof relayer === 'string' ? relayer : await relayer.getAddress() + await _sendTx( + AddressManager.setAddress('OVM_L2MessageRelayer', address) + ) + } + }, + }, + Proxy__OVM_L1CrossDomainMessenger: { + factory: getContractFactory('Lib_ResolvedDelegateProxy'), + params: [AddressManager.address, 'OVM_L1CrossDomainMessenger'], + afterDeploy: async (contracts): Promise => { + const xDomainMessenger = getContractFactory( + 'OVM_L1CrossDomainMessenger' + ) + .connect(config.deploymentSigner) + .attach(contracts.Proxy__OVM_L1CrossDomainMessenger.address) + await _sendTx( + xDomainMessenger.initialize( + AddressManager.address, + config.deployOverrides + ) + ) + await _sendTx( + AddressManager.setAddress( + 'OVM_L2CrossDomainMessenger', + config.ovmGlobalContext.L2CrossDomainMessengerAddress, + config.deployOverrides + ) + ) + }, + }, + OVM_L1ETHGateway: { + factory: getContractFactory('OVM_L1ETHGateway'), + params: [ + AddressManager.address, + '0x4200000000000000000000000000000000000006', + ], + }, + OVM_L1MultiMessageRelayer: { + factory: getContractFactory('OVM_L1MultiMessageRelayer'), + params: [AddressManager.address], + }, + OVM_CanonicalTransactionChain: { + factory: getContractFactory('OVM_CanonicalTransactionChain'), + params: [ + AddressManager.address, + config.transactionChainConfig.forceInclusionPeriodSeconds, + config.transactionChainConfig.forceInclusionPeriodBlocks, + config.ovmGasMeteringConfig.maxTransactionGasLimit, + ], + afterDeploy: async (): Promise => { + const sequencer = config.transactionChainConfig.sequencer + const sequencerAddress = + typeof sequencer === 'string' + ? sequencer + : await sequencer.getAddress() + await _sendTx( + AddressManager.setAddress( + 'OVM_DecompressionPrecompileAddress', + '0x4200000000000000000000000000000000000005' + ) + ) + await _sendTx( + AddressManager.setAddress('OVM_Sequencer', sequencerAddress) + ) + await _sendTx( + AddressManager.setAddress('OVM_Proposer', sequencerAddress) + ) + await _sendTx(AddressManager.setAddress('Sequencer', sequencerAddress)) + }, + }, + OVM_StateCommitmentChain: { + factory: getContractFactory('OVM_StateCommitmentChain'), + params: [ + AddressManager.address, + config.stateChainConfig.fraudProofWindowSeconds, + config.stateChainConfig.sequencerPublishWindowSeconds, + ], + }, + OVM_DeployerWhitelist: { + factory: getContractFactory('OVM_DeployerWhitelist'), + params: [], + }, + OVM_L1MessageSender: { + factory: getContractFactory('OVM_L1MessageSender'), + params: [], + }, + OVM_L2ToL1MessagePasser: { + factory: getContractFactory('OVM_L2ToL1MessagePasser'), + params: [], + }, + OVM_SafetyChecker: { + factory: getContractFactory('OVM_SafetyChecker'), + params: [], + }, + OVM_ExecutionManager: { + factory: getContractFactory('OVM_ExecutionManager'), + params: [ + AddressManager.address, + config.ovmGasMeteringConfig, + config.ovmGlobalContext, + ], + }, + OVM_StateManager: { + factory: getContractFactory('OVM_StateManager'), + params: [await config.deploymentSigner.getAddress()], + afterDeploy: async (contracts): Promise => { + await _sendTx( + contracts.OVM_StateManager.setExecutionManager( + contracts.OVM_ExecutionManager.address, + config.deployOverrides + ) + ) + }, + }, + OVM_StateManagerFactory: { + factory: getContractFactory('OVM_StateManagerFactory'), + params: [], + }, + OVM_FraudVerifier: { + factory: getContractFactory('OVM_FraudVerifier'), + params: [AddressManager.address], + }, + OVM_StateTransitionerFactory: { + factory: getContractFactory('OVM_StateTransitionerFactory'), + params: [AddressManager.address], + }, + OVM_ECDSAContractAccount: { + factory: getContractFactory('OVM_ECDSAContractAccount'), + }, + OVM_SequencerEntrypoint: { + factory: getContractFactory('OVM_SequencerEntrypoint'), + }, + OVM_ProxySequencerEntrypoint: { + factory: getContractFactory('OVM_ProxySequencerEntrypoint'), + }, + mockOVM_ECDSAContractAccount: { + factory: getContractFactory('mockOVM_ECDSAContractAccount'), + }, + OVM_BondManager: { + factory: getContractFactory('mockOVM_BondManager'), + params: [AddressManager.address], + }, + OVM_ETH: { + factory: getContractFactory('OVM_ETH'), + params: [ + '0x4200000000000000000000000000000000000007', + '0x0000000000000000000000000000000000000000', // will be overridden by geth when state dump is ingested. Storage key: 0x0000000000000000000000000000000000000000000000000000000000000008 + ], + }, + 'OVM_ChainStorageContainer:CTC:batches': { + factory: getContractFactory('OVM_ChainStorageContainer'), + params: [AddressManager.address, 'OVM_CanonicalTransactionChain'], + }, + 'OVM_ChainStorageContainer:CTC:queue': { + factory: getContractFactory('OVM_ChainStorageContainer'), + params: [AddressManager.address, 'OVM_CanonicalTransactionChain'], + }, + 'OVM_ChainStorageContainer:SCC:batches': { + factory: getContractFactory('OVM_ChainStorageContainer'), + params: [AddressManager.address, 'OVM_StateCommitmentChain'], + }, + ERC1820Registry: { + factory: getContractFactory('ERC1820Registry'), + }, + } +} diff --git a/packages/contracts/src/contract-deployment/deploy.ts b/packages/contracts/src/contract-deployment/deploy.ts new file mode 100644 index 000000000000..0655bd810d63 --- /dev/null +++ b/packages/contracts/src/contract-deployment/deploy.ts @@ -0,0 +1,94 @@ +/* External Imports */ +import { Contract } from 'ethers' + +/* Internal Imports */ +import { RollupDeployConfig, makeContractDeployConfig } from './config' +import { getContractFactory } from '../contract-defs' + +export interface DeployResult { + AddressManager: Contract + failedDeployments: string[] + contracts: { + [name: string]: Contract + } +} + +export const deploy = async ( + config: RollupDeployConfig +): Promise => { + let AddressManager: Contract + + if (config.addressManager) { + // console.log(`Connecting to existing address manager.`) //console.logs currently break our deployer + AddressManager = getContractFactory( + 'Lib_AddressManager', + config.deploymentSigner + ).attach(config.addressManager) + } else { + // console.log( + // `Address manager wasn't provided, so we're deploying a new one.` + // ) //console.logs currently break our deployer + AddressManager = await getContractFactory( + 'Lib_AddressManager', + config.deploymentSigner + ).deploy() + if (config.waitForReceipts) { + await AddressManager.deployTransaction.wait() + } + } + + const contractDeployConfig = await makeContractDeployConfig( + config, + AddressManager + ) + + const failedDeployments: string[] = [] + const contracts: { + [name: string]: Contract + } = {} + + for (const [name, contractDeployParameters] of Object.entries( + contractDeployConfig + )) { + if (config.dependencies && !config.dependencies.includes(name)) { + continue + } + + try { + contracts[name] = await contractDeployParameters.factory + .connect(config.deploymentSigner) + .deploy( + ...(contractDeployParameters.params || []), + config.deployOverrides + ) + if (config.waitForReceipts) { + await contracts[name].deployTransaction.wait() + } + const res = await AddressManager.setAddress(name, contracts[name].address) + if (config.waitForReceipts) { + await res.wait() + } + } catch (err) { + console.error(`Error deploying ${name}: ${err}`) + failedDeployments.push(name) + } + } + + for (const [name, contractDeployParameters] of Object.entries( + contractDeployConfig + )) { + if (config.dependencies && !config.dependencies.includes(name)) { + continue + } + + if (contractDeployParameters.afterDeploy) { + await contractDeployParameters.afterDeploy(contracts) + } + } + + return { + AddressManager, + failedDeployments, + contracts, + } +} diff --git a/packages/contracts/src/contract-deployment/index.ts b/packages/contracts/src/contract-deployment/index.ts new file mode 100644 index 000000000000..8c3b5b0c4f8e --- /dev/null +++ b/packages/contracts/src/contract-deployment/index.ts @@ -0,0 +1,2 @@ +export { RollupDeployConfig } from './config' +export { deploy } from './deploy' diff --git a/packages/contracts/src/contract-dumps.ts b/packages/contracts/src/contract-dumps.ts new file mode 100644 index 000000000000..04a10c978118 --- /dev/null +++ b/packages/contracts/src/contract-dumps.ts @@ -0,0 +1,262 @@ +/* External Imports */ +import * as path from 'path' +import { ethers } from 'ethers' +import * as Ganache from 'ganache-core' +import { keccak256 } from 'ethers/lib/utils' +import { fromHexString, toHexString, remove0x } from '@eth-optimism/core-utils' + +/* Internal Imports */ +import { deploy, RollupDeployConfig } from './contract-deployment' +import { getContractDefinition } from './contract-defs' + +interface StorageDump { + [key: string]: string +} + +export interface StateDump { + accounts: { + [name: string]: { + address: string + code: string + codeHash: string + storage: StorageDump + abi: any + } + } +} + +/** + * Generates a storage dump for a given address. + * @param cStateManager Instance of the callback-based internal vm StateManager. + * @param address Address to generate a state dump for. + */ +const getStorageDump = async ( + cStateManager: any, + address: string +): Promise => { + return new Promise((resolve, reject) => { + cStateManager._getStorageTrie(address, (err: any, trie: any) => { + if (err) { + reject(err) + } + + const storage: StorageDump = {} + const stream = trie.createReadStream() + + stream.on('data', (val: any) => { + const storageSlotValue = ethers.utils.RLP.decode( + '0x' + val.value.toString('hex') + ) + storage['0x' + val.key.toString('hex')] = storageSlotValue + }) + + stream.on('end', () => { + resolve(storage) + }) + }) + }) +} + +/** + * Replaces old addresses found in a storage dump with new ones. + * @param storageDump Storage dump to sanitize. + * @param accounts Set of accounts to sanitize with. + * @returns Sanitized storage dump. + */ +const sanitizeStorageDump = ( + storageDump: StorageDump, + accounts: Array<{ + originalAddress: string + deadAddress: string + }> +): StorageDump => { + for (const account of accounts) { + account.originalAddress = remove0x(account.originalAddress).toLowerCase() + account.deadAddress = remove0x(account.deadAddress).toLowerCase() + } + + for (const [key, value] of Object.entries(storageDump)) { + let parsedKey = key + let parsedValue = value + for (const account of accounts) { + const re = new RegExp(`${account.originalAddress}`, 'g') + parsedValue = parsedValue.replace(re, account.deadAddress) + parsedKey = parsedKey.replace(re, account.deadAddress) + } + + if (parsedKey !== key) { + delete storageDump[key] + } + + storageDump[parsedKey] = parsedValue + } + + return storageDump +} + +export const makeStateDump = async (cfg: RollupDeployConfig): Promise => { + const ganache = (Ganache as any).provider({ + gasLimit: 100_000_000, + allowUnlimitedContractSize: true, + accounts: [ + { + secretKey: + '0x29f3edee0ad3abf8e2699402e0e28cd6492c9be7eaab00d732a791c33552f797', + balance: 10000000000000000000000000000000000, + }, + ], + }) + + const provider = new ethers.providers.Web3Provider(ganache) + const signer = provider.getSigner(0) + + let config: RollupDeployConfig = { + deploymentSigner: signer, + ovmGasMeteringConfig: { + minTransactionGasLimit: 0, + maxTransactionGasLimit: 9_000_000, + maxGasPerQueuePerEpoch: 1_000_000_000_000, + secondsPerEpoch: 0, + }, + ovmGlobalContext: { + ovmCHAINID: 420, + L2CrossDomainMessengerAddress: + '0x4200000000000000000000000000000000000007', + }, + transactionChainConfig: { + sequencer: signer, + forceInclusionPeriodSeconds: 600, + forceInclusionPeriodBlocks: 600 / 12, + }, + stateChainConfig: { + fraudProofWindowSeconds: 600, + sequencerPublishWindowSeconds: 60_000, + }, + whitelistConfig: { + owner: signer, + allowArbitraryContractDeployment: true, + }, + l1CrossDomainMessengerConfig: {}, + dependencies: [ + 'ERC1820Registry', + 'Lib_AddressManager', + 'OVM_DeployerWhitelist', + 'OVM_L1MessageSender', + 'OVM_L2ToL1MessagePasser', + 'OVM_ProxyEOA', + 'OVM_ECDSAContractAccount', + 'OVM_ProxySequencerEntrypoint', + 'OVM_SequencerEntrypoint', + 'OVM_L2CrossDomainMessenger', + 'OVM_SafetyChecker', + 'OVM_ExecutionManager', + 'OVM_StateManager', + 'OVM_ETH', + 'mockOVM_ECDSAContractAccount', + ], + deployOverrides: {}, + waitForReceipts: false, + } + + config = { ...config, ...cfg } + + const predeploys = { + OVM_L2ToL1MessagePasser: '0x4200000000000000000000000000000000000000', + OVM_L1MessageSender: '0x4200000000000000000000000000000000000001', + OVM_DeployerWhitelist: '0x4200000000000000000000000000000000000002', + OVM_ECDSAContractAccount: '0x4200000000000000000000000000000000000003', + OVM_ProxySequencerEntrypoint: '0x4200000000000000000000000000000000000004', + OVM_SequencerEntrypoint: '0x4200000000000000000000000000000000000005', + OVM_ETH: '0x4200000000000000000000000000000000000006', + OVM_L2CrossDomainMessenger: '0x4200000000000000000000000000000000000007', + Lib_AddressManager: '0x4200000000000000000000000000000000000008', + ERC1820Registry: '0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24', + } + + const ovmCompiled = [ + 'OVM_L2ToL1MessagePasser', + 'OVM_L2CrossDomainMessenger', + 'Lib_AddressManager', + 'OVM_ETH', + ] + + const deploymentResult = await deploy(config) + deploymentResult.contracts['Lib_AddressManager'] = + deploymentResult.AddressManager + + if (deploymentResult.failedDeployments.length > 0) { + throw new Error( + `Could not generate state dump, deploy failed for: ${deploymentResult.failedDeployments}` + ) + } + + const pStateManager = ganache.engine.manager.state.blockchain.vm.pStateManager + const cStateManager = pStateManager._wrapped + + const dump: StateDump = { + accounts: {}, + } + + for (let i = 0; i < Object.keys(deploymentResult.contracts).length; i++) { + const name = Object.keys(deploymentResult.contracts)[i] + const contract = deploymentResult.contracts[name] + let code + if (ovmCompiled.includes(name)) { + const ovmDeployedBytecode = getContractDefinition(name, true) + .deployedBytecode + // TODO remove: deployedBytecode is missing the find and replace in solidity + code = ovmDeployedBytecode + .split( + '336000905af158601d01573d60011458600c01573d6000803e3d621234565260ea61109c52' + ) + .join( + '336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b' + ) + } else { + const codeBuf = await pStateManager.getContractCode( + fromHexString(contract.address) + ) + code = toHexString(codeBuf) + } + + const deadAddress = + predeploys[name] || + `0xdeaddeaddeaddeaddeaddeaddeaddeaddead${i.toString(16).padStart(4, '0')}` + + dump.accounts[name] = { + address: deadAddress, + code, + codeHash: keccak256(code), + storage: await getStorageDump(cStateManager, contract.address), + abi: getContractDefinition(name.replace('Proxy__', '')).abi, + } + } + + const addressMap = Object.keys(dump.accounts).map((name) => { + return { + originalAddress: deploymentResult.contracts[name].address, + deadAddress: dump.accounts[name].address, + } + }) + + for (const name of Object.keys(dump.accounts)) { + dump.accounts[name].storage = sanitizeStorageDump( + dump.accounts[name].storage, + addressMap + ) + } + + dump.accounts['OVM_GasMetadata'] = { + address: '0x06a506a506a506a506a506a506a506a506a506a5', + code: '0x00', + codeHash: keccak256('0x00'), + storage: {}, + abi: [], + } + + return dump +} + +export const getLatestStateDump = (): StateDump => { + return require(path.join(__dirname, '../dumps', `state-dump.latest.json`)) +} diff --git a/packages/contracts/src/index.ts b/packages/contracts/src/index.ts new file mode 100644 index 000000000000..f86b06052137 --- /dev/null +++ b/packages/contracts/src/index.ts @@ -0,0 +1,3 @@ +export * from './contract-defs' +export { getLatestStateDump, StateDump } from './contract-dumps' +export * from './contract-deployment' diff --git a/packages/contracts/test/contracts/OVM/accounts/OVM_ECDSAContractAccount.spec.ts b/packages/contracts/test/contracts/OVM/accounts/OVM_ECDSAContractAccount.spec.ts new file mode 100644 index 000000000000..186aff6aa71c --- /dev/null +++ b/packages/contracts/test/contracts/OVM/accounts/OVM_ECDSAContractAccount.spec.ts @@ -0,0 +1,294 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers, waffle } from 'hardhat' +import { ContractFactory, Contract, Wallet } from 'ethers' +import { MockContract, smockit } from '@eth-optimism/smock' + +/* Internal Imports */ +import { NON_ZERO_ADDRESS } from '../../../helpers/constants' +import { + serializeNativeTransaction, + signNativeTransaction, + DEFAULT_EIP155_TX, + serializeEthSignTransaction, + signEthSignMessage, + decodeSolidityError, +} from '../../../helpers' + +const callPredeploy = async ( + Helper_PredeployCaller: Contract, + predeploy: Contract, + functionName: string, + functionParams?: any[], + gasLimit?: number +): Promise => { + if (gasLimit) { + return Helper_PredeployCaller.callPredeploy( + predeploy.address, + predeploy.interface.encodeFunctionData( + functionName, + functionParams || [] + ), + { gasLimit } + ) + } + return Helper_PredeployCaller.callPredeploy( + predeploy.address, + predeploy.interface.encodeFunctionData(functionName, functionParams || []) + ) +} + +describe('OVM_ECDSAContractAccount', () => { + let wallet: Wallet + let badWallet: Wallet + before(async () => { + const provider = waffle.provider + ;[wallet, badWallet] = provider.getWallets() + }) + + let Mock__OVM_ExecutionManager: MockContract + let Helper_PredeployCaller: Contract + before(async () => { + Mock__OVM_ExecutionManager = await smockit( + await ethers.getContractFactory('OVM_ExecutionManager') + ) + + Helper_PredeployCaller = await ( + await ethers.getContractFactory('Helper_PredeployCaller') + ).deploy() + Helper_PredeployCaller.setTarget(Mock__OVM_ExecutionManager.address) + }) + + let Factory__OVM_ECDSAContractAccount: ContractFactory + before(async () => { + Factory__OVM_ECDSAContractAccount = await ethers.getContractFactory( + 'OVM_ECDSAContractAccount' + ) + }) + + let OVM_ECDSAContractAccount: Contract + beforeEach(async () => { + OVM_ECDSAContractAccount = await Factory__OVM_ECDSAContractAccount.deploy() + + Mock__OVM_ExecutionManager.smocked.ovmADDRESS.will.return.with( + await wallet.getAddress() + ) + Mock__OVM_ExecutionManager.smocked.ovmCHAINID.will.return.with(420) + Mock__OVM_ExecutionManager.smocked.ovmGETNONCE.will.return.with(100) + Mock__OVM_ExecutionManager.smocked.ovmCALL.will.return.with([true, '0x']) + Mock__OVM_ExecutionManager.smocked.ovmCREATE.will.return.with([ + NON_ZERO_ADDRESS, + '0x', + ]) + Mock__OVM_ExecutionManager.smocked.ovmCALLER.will.return.with( + NON_ZERO_ADDRESS + ) + }) + + describe('fallback()', () => { + it(`should successfully execute an EIP155Transaction`, async () => { + const message = serializeNativeTransaction(DEFAULT_EIP155_TX) + const sig = await signNativeTransaction(wallet, DEFAULT_EIP155_TX) + + await callPredeploy( + Helper_PredeployCaller, + OVM_ECDSAContractAccount, + 'execute', + [ + message, + 0, // isEthSignedMessage + `0x${sig.v}`, //v + `0x${sig.r}`, //r + `0x${sig.s}`, //s + ] + ) + + // The ovmCALL is the 2nd call because the first call transfers the fee. + const ovmCALL: any = Mock__OVM_ExecutionManager.smocked.ovmCALL.calls[1] + expect(ovmCALL._gasLimit).to.equal(DEFAULT_EIP155_TX.gasLimit) + expect(ovmCALL._address).to.equal(DEFAULT_EIP155_TX.to) + expect(ovmCALL._calldata).to.equal(DEFAULT_EIP155_TX.data) + }) + + it(`should successfully execute an ETHSignedTransaction`, async () => { + const message = serializeEthSignTransaction(DEFAULT_EIP155_TX) + const sig = await signEthSignMessage(wallet, DEFAULT_EIP155_TX) + + await callPredeploy( + Helper_PredeployCaller, + OVM_ECDSAContractAccount, + 'execute', + [ + message, + 1, //isEthSignedMessage + `0x${sig.v}`, //v + `0x${sig.r}`, //r + `0x${sig.s}`, //s + ] + ) + + // The ovmCALL is the 2nd call because the first call transfers the fee. + const ovmCALL: any = Mock__OVM_ExecutionManager.smocked.ovmCALL.calls[1] + expect(ovmCALL._gasLimit).to.equal(DEFAULT_EIP155_TX.gasLimit) + expect(ovmCALL._address).to.equal(DEFAULT_EIP155_TX.to) + expect(ovmCALL._calldata).to.equal(DEFAULT_EIP155_TX.data) + }) + + it(`should ovmCREATE if EIP155Transaction.to is zero address`, async () => { + const createTx = { ...DEFAULT_EIP155_TX, to: '' } + const message = serializeNativeTransaction(createTx) + const sig = await signNativeTransaction(wallet, createTx) + + await callPredeploy( + Helper_PredeployCaller, + OVM_ECDSAContractAccount, + 'execute', + [ + message, + 0, //isEthSignedMessage + `0x${sig.v}`, //v + `0x${sig.r}`, //r + `0x${sig.s}`, //s + ] + ) + + const ovmCREATE: any = + Mock__OVM_ExecutionManager.smocked.ovmCREATE.calls[0] + expect(ovmCREATE._bytecode).to.equal(createTx.data) + }) + + it(`should revert on invalid signature`, async () => { + const message = serializeNativeTransaction(DEFAULT_EIP155_TX) + const sig = await signNativeTransaction(badWallet, DEFAULT_EIP155_TX) + + await callPredeploy( + Helper_PredeployCaller, + OVM_ECDSAContractAccount, + 'execute', + [ + message, + 0, //isEthSignedMessage + `0x${sig.v}`, //v + `0x${sig.r}`, //r + `0x${sig.s}`, //s + ] + ) + const ovmREVERT: any = + Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0] + expect(decodeSolidityError(ovmREVERT._data)).to.equal( + 'Signature provided for EOA transaction execution is invalid.' + ) + }) + + it(`should revert on incorrect nonce`, async () => { + const alteredNonceTx = { + ...DEFAULT_EIP155_TX, + nonce: 99, + } + const message = serializeNativeTransaction(alteredNonceTx) + const sig = await signNativeTransaction(wallet, alteredNonceTx) + + await callPredeploy( + Helper_PredeployCaller, + OVM_ECDSAContractAccount, + 'execute', + [ + message, + 0, //isEthSignedMessage + `0x${sig.v}`, //v + `0x${sig.r}`, //r + `0x${sig.s}`, //s + ] + ) + const ovmREVERT: any = + Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0] + expect(decodeSolidityError(ovmREVERT._data)).to.equal( + 'Transaction nonce does not match the expected nonce.' + ) + }) + + it(`should revert on incorrect chainId`, async () => { + const alteredChainIdTx = { + ...DEFAULT_EIP155_TX, + chainId: 421, + } + const message = serializeNativeTransaction(alteredChainIdTx) + const sig = await signNativeTransaction(wallet, alteredChainIdTx) + + await callPredeploy( + Helper_PredeployCaller, + OVM_ECDSAContractAccount, + 'execute', + [ + message, + 0, //isEthSignedMessage + `0x${sig.v}`, //v + `0x${sig.r}`, //r + `0x${sig.s}`, //s + ] + ) + const ovmREVERT: any = + Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0] + expect(decodeSolidityError(ovmREVERT._data)).to.equal( + 'Transaction chainId does not match expected OVM chainId.' + ) + }) + + // TEMPORARY: Skip gas checks for minnet. + it.skip(`should revert on insufficient gas`, async () => { + const alteredInsufficientGasTx = { + ...DEFAULT_EIP155_TX, + gasLimit: 200000000, + } + const message = serializeNativeTransaction(alteredInsufficientGasTx) + const sig = await signNativeTransaction(wallet, alteredInsufficientGasTx) + + await callPredeploy( + Helper_PredeployCaller, + OVM_ECDSAContractAccount, + 'execute', + [ + message, + 0, //isEthSignedMessage + `0x${sig.v}`, //v + `0x${sig.r}`, //r + `0x${sig.s}`, //s + ], + 40000000 + ) + + const ovmREVERT: any = + Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0] + expect(decodeSolidityError(ovmREVERT._data)).to.equal( + 'Gas is not sufficient to execute the transaction.' + ) + }) + + it(`should revert if fee is not transferred to the relayer`, async () => { + const message = serializeNativeTransaction(DEFAULT_EIP155_TX) + const sig = await signNativeTransaction(wallet, DEFAULT_EIP155_TX) + Mock__OVM_ExecutionManager.smocked.ovmCALL.will.return.with([false, '0x']) + + await callPredeploy( + Helper_PredeployCaller, + OVM_ECDSAContractAccount, + 'execute', + [ + message, + 0, //isEthSignedMessage + `0x${sig.v}`, //v + `0x${sig.r}`, //r + `0x${sig.s}`, //s + ], + 40000000 + ) + + const ovmREVERT: any = + Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0] + expect(decodeSolidityError(ovmREVERT._data)).to.equal( + 'Fee was not transferred to relayer.' + ) + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/accounts/OVM_ProxyEOA.spec.ts b/packages/contracts/test/contracts/OVM/accounts/OVM_ProxyEOA.spec.ts new file mode 100644 index 000000000000..ce576e23f769 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/accounts/OVM_ProxyEOA.spec.ts @@ -0,0 +1,149 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers, waffle } from 'hardhat' +import { ContractFactory, Contract, Wallet } from 'ethers' +import { MockContract, smockit } from '@eth-optimism/smock' +import { remove0x } from '@eth-optimism/core-utils' + +/* Internal Imports */ +import { decodeSolidityError } from '../../../helpers' + +const callPredeploy = async ( + Helper_PredeployCaller: Contract, + predeploy: Contract, + functionName: string, + functionParams?: any[], + ethCall: boolean = false +): Promise => { + if (ethCall) { + return Helper_PredeployCaller.callStatic.callPredeployAbi( + predeploy.address, + predeploy.interface.encodeFunctionData(functionName, functionParams || []) + ) + } + return Helper_PredeployCaller.callPredeploy( + predeploy.address, + predeploy.interface.encodeFunctionData(functionName, functionParams || []) + ) +} + +const addrToBytes32 = (addr: string) => '0x' + '00'.repeat(12) + remove0x(addr) + +const eoaDefaultAddr = '0x4200000000000000000000000000000000000003' + +describe('OVM_ProxyEOA', () => { + let wallet: Wallet + before(async () => { + const provider = waffle.provider + ;[wallet] = provider.getWallets() + }) + + let Mock__OVM_ExecutionManager: MockContract + let Mock__OVM_ECDSAContractAccount: MockContract + let Helper_PredeployCaller: Contract + before(async () => { + Mock__OVM_ExecutionManager = await smockit( + await ethers.getContractFactory('OVM_ExecutionManager') + ) + + Helper_PredeployCaller = await ( + await ethers.getContractFactory('Helper_PredeployCaller') + ).deploy() + + Helper_PredeployCaller.setTarget(Mock__OVM_ExecutionManager.address) + + Mock__OVM_ECDSAContractAccount = await smockit( + await ethers.getContractFactory('OVM_ECDSAContractAccount') + ) + }) + + let OVM_ProxyEOAFactory: ContractFactory + before(async () => { + OVM_ProxyEOAFactory = await ethers.getContractFactory('OVM_ProxyEOA') + }) + + let OVM_ProxyEOA: Contract + beforeEach(async () => { + OVM_ProxyEOA = await OVM_ProxyEOAFactory.deploy(eoaDefaultAddr) + + Mock__OVM_ExecutionManager.smocked.ovmADDRESS.will.return.with( + OVM_ProxyEOA.address + ) + Mock__OVM_ExecutionManager.smocked.ovmCALLER.will.return.with( + OVM_ProxyEOA.address + ) + }) + + describe('getImplementation()', () => { + it(`should be created with implementation at predeploy address`, async () => { + const eoaDefaultAddrBytes32 = addrToBytes32(eoaDefaultAddr) + Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with( + eoaDefaultAddrBytes32 + ) + const implAddrBytes32 = await callPredeploy( + Helper_PredeployCaller, + OVM_ProxyEOA, + 'getImplementation', + [], + true + ) + expect(implAddrBytes32).to.equal(eoaDefaultAddrBytes32) + }) + }) + describe('upgrade()', () => { + const implSlotKey = + '0xdeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead' + it(`should upgrade the proxy implementation`, async () => { + const newImpl = `0x${'81'.repeat(20)}` + const newImplBytes32 = addrToBytes32(newImpl) + await callPredeploy(Helper_PredeployCaller, OVM_ProxyEOA, 'upgrade', [ + newImpl, + ]) + const ovmSSTORE: any = + Mock__OVM_ExecutionManager.smocked.ovmSSTORE.calls[0] + expect(ovmSSTORE._key).to.equal(implSlotKey) + expect(ovmSSTORE._value).to.equal(newImplBytes32) + }) + it(`should not allow upgrade of the proxy implementation by another account`, async () => { + Mock__OVM_ExecutionManager.smocked.ovmCALLER.will.return.with( + await wallet.getAddress() + ) + const newImpl = `0x${'81'.repeat(20)}` + await callPredeploy(Helper_PredeployCaller, OVM_ProxyEOA, 'upgrade', [ + newImpl, + ]) + const ovmREVERT: any = + Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0] + expect(decodeSolidityError(ovmREVERT._data)).to.equal( + 'EOAs can only upgrade their own EOA implementation' + ) + }) + }) + describe('fallback()', () => { + it(`should call delegateCall with right calldata`, async () => { + Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with( + addrToBytes32(Mock__OVM_ECDSAContractAccount.address) + ) + Mock__OVM_ExecutionManager.smocked.ovmDELEGATECALL.will.return.with([ + true, + '0x1234', + ]) + const calldata = '0xdeadbeef' + await Helper_PredeployCaller.callPredeploy(OVM_ProxyEOA.address, calldata) + + const ovmDELEGATECALL: any = + Mock__OVM_ExecutionManager.smocked.ovmDELEGATECALL.calls[0] + expect(ovmDELEGATECALL._address).to.equal( + Mock__OVM_ECDSAContractAccount.address + ) + expect(ovmDELEGATECALL._calldata).to.equal(calldata) + }) + it.skip(`should return data from fallback`, async () => { + //TODO test return data from fallback + }) + it.skip(`should revert in fallback`, async () => { + //TODO test reversion from fallback + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/bridge/assets/OVM_L1ERC20Gateway.spec.ts b/packages/contracts/test/contracts/OVM/bridge/assets/OVM_L1ERC20Gateway.spec.ts new file mode 100644 index 000000000000..f72e23c9c041 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/bridge/assets/OVM_L1ERC20Gateway.spec.ts @@ -0,0 +1,237 @@ +import { expect } from '../../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Signer, ContractFactory, Contract, constants } from 'ethers' +import { smockit, MockContract, smoddit } from '@eth-optimism/smock' + +/* Internal Imports */ +import { NON_ZERO_ADDRESS } from '../../../../helpers' + +const INITIAL_TOTAL_L1_SUPPLY = 3000 + +const ERR_INVALID_MESSENGER = 'OVM_XCHAIN: messenger contract unauthenticated' +const ERR_INVALID_X_DOMAIN_MSG_SENDER = + 'OVM_XCHAIN: wrong sender of cross-domain message' + +describe('OVM_L1ERC20Gateway', () => { + // init signers + let alice: Signer + let bob: Signer + + // we can just make up this string since it's on the "other" Layer + let Mock__OVM_L2DepositedERC20: MockContract + let Factory__L1ERC20: ContractFactory + let L1ERC20: Contract + before(async () => { + ;[alice, bob] = await ethers.getSigners() + + Mock__OVM_L2DepositedERC20 = await smockit( + await ethers.getContractFactory('OVM_L2DepositedERC20') + ) + + // deploy an ERC20 contract on L1 + Factory__L1ERC20 = await smoddit('UniswapV2ERC20') + + L1ERC20 = await Factory__L1ERC20.deploy('L1ERC20', 'ERC') + + const aliceAddress = await alice.getAddress() + L1ERC20.smodify.put({ + totalSupply: INITIAL_TOTAL_L1_SUPPLY, + balanceOf: { + [aliceAddress]: INITIAL_TOTAL_L1_SUPPLY, + }, + }) + }) + + let OVM_L1ERC20Gateway: Contract + let Mock__OVM_L1CrossDomainMessenger: MockContract + let finalizeDepositGasLimit: number + beforeEach(async () => { + // Create a special signer which will enable us to send messages from the L1Messenger contract + let l1MessengerImpersonator: Signer + ;[l1MessengerImpersonator, alice, bob] = await ethers.getSigners() + // Get a new mock L1 messenger + Mock__OVM_L1CrossDomainMessenger = await smockit( + await ethers.getContractFactory('OVM_L1CrossDomainMessenger'), + { address: await l1MessengerImpersonator.getAddress() } // This allows us to use an ethers override {from: Mock__OVM_L2CrossDomainMessenger.address} to mock calls + ) + + // Deploy the contract under test + OVM_L1ERC20Gateway = await ( + await ethers.getContractFactory('OVM_L1ERC20Gateway') + ).deploy( + L1ERC20.address, + Mock__OVM_L2DepositedERC20.address, + Mock__OVM_L1CrossDomainMessenger.address + ) + + finalizeDepositGasLimit = await OVM_L1ERC20Gateway.DEFAULT_FINALIZE_DEPOSIT_L2_GAS() + }) + + describe('finalizeWithdrawal', () => { + it('onlyFromCrossDomainAccount: should revert on calls from a non-crossDomainMessenger L1 account', async () => { + // Deploy new gateway, initialize with random messenger + OVM_L1ERC20Gateway = await ( + await ethers.getContractFactory('OVM_L1ERC20Gateway') + ).deploy( + L1ERC20.address, + Mock__OVM_L2DepositedERC20.address, + NON_ZERO_ADDRESS + ) + + await expect( + OVM_L1ERC20Gateway.finalizeWithdrawal(constants.AddressZero, 1) + ).to.be.revertedWith(ERR_INVALID_MESSENGER) + }) + + it('onlyFromCrossDomainAccount: should revert on calls from the right crossDomainMessenger, but wrong xDomainMessageSender (ie. not the L2ERC20Gateway)', async () => { + Mock__OVM_L1CrossDomainMessenger.smocked.xDomainMessageSender.will.return.with( + () => NON_ZERO_ADDRESS + ) + + await expect( + OVM_L1ERC20Gateway.finalizeWithdrawal(constants.AddressZero, 1, { + from: Mock__OVM_L1CrossDomainMessenger.address, + }) + ).to.be.revertedWith(ERR_INVALID_X_DOMAIN_MSG_SENDER) + }) + + it('should credit funds to the withdrawer and not use too much gas', async () => { + // make sure no balance at start of test + await expect(await L1ERC20.balanceOf(NON_ZERO_ADDRESS)).to.be.equal(0) + + const withdrawalAmount = 100 + Mock__OVM_L1CrossDomainMessenger.smocked.xDomainMessageSender.will.return.with( + () => Mock__OVM_L2DepositedERC20.address + ) + + await L1ERC20.transfer(OVM_L1ERC20Gateway.address, withdrawalAmount) + + const res = await OVM_L1ERC20Gateway.finalizeWithdrawal( + NON_ZERO_ADDRESS, + withdrawalAmount, + { from: Mock__OVM_L1CrossDomainMessenger.address } + ) + + await expect(await L1ERC20.balanceOf(NON_ZERO_ADDRESS)).to.be.equal( + withdrawalAmount + ) + + const gasUsed = ( + await OVM_L1ERC20Gateway.provider.getTransactionReceipt(res.hash) + ).gasUsed + + const OVM_L2DepositedERC20 = await ( + await ethers.getContractFactory('OVM_L2DepositedERC20') + ).deploy(constants.AddressZero, '', '') + const defaultFinalizeWithdrawalGas = await OVM_L2DepositedERC20.getFinalizeWithdrawalL1Gas() + await expect(gasUsed.gt((defaultFinalizeWithdrawalGas * 11) / 10)) + }) + + it.skip('finalizeWithdrawalAndCall(): should should credit funds to the withdrawer, and forward from and data', async () => { + // TODO: implement this functionality in a future update + expect.fail() + }) + }) + + describe('deposits', () => { + const INITIAL_DEPOSITER_BALANCE = 100_000 + let depositer: string + const depositAmount = 1_000 + + beforeEach(async () => { + // Deploy the L1 ERC20 token, Alice will receive the full initialSupply + L1ERC20 = await Factory__L1ERC20.deploy('L1ERC20', 'ERC') + + // get a new mock L1 messenger + Mock__OVM_L1CrossDomainMessenger = await smockit( + await ethers.getContractFactory('OVM_L1CrossDomainMessenger') + ) + + // Deploy the contract under test: + OVM_L1ERC20Gateway = await ( + await ethers.getContractFactory('OVM_L1ERC20Gateway') + ).deploy( + L1ERC20.address, + Mock__OVM_L2DepositedERC20.address, + Mock__OVM_L1CrossDomainMessenger.address + ) + + // the Signer sets approve for the L1 Gateway + await L1ERC20.approve(OVM_L1ERC20Gateway.address, depositAmount) + depositer = await L1ERC20.signer.getAddress() + + await L1ERC20.smodify.put({ + balanceOf: { + [depositer]: INITIAL_DEPOSITER_BALANCE, + }, + }) + }) + + it('deposit() escrows the deposit amount and sends the correct deposit message', async () => { + // alice calls deposit on the gateway and the L1 gateway calls transferFrom on the token + await OVM_L1ERC20Gateway.deposit(depositAmount) + const depositCallToMessenger = + Mock__OVM_L1CrossDomainMessenger.smocked.sendMessage.calls[0] + + const depositerBalance = await L1ERC20.balanceOf(depositer) + expect(depositerBalance).to.equal( + INITIAL_DEPOSITER_BALANCE - depositAmount + ) + + // gateway's balance is increased + const gatewayBalance = await L1ERC20.balanceOf(OVM_L1ERC20Gateway.address) + expect(gatewayBalance).to.equal(depositAmount) + + // Check the correct cross-chain call was sent: + // Message should be sent to the L2ERC20Gateway on L2 + expect(depositCallToMessenger._target).to.equal( + Mock__OVM_L2DepositedERC20.address + ) + // Message data should be a call telling the L2ERC20Gateway to finalize the deposit + + // the L1 gateway sends the correct message to the L1 messenger + expect(depositCallToMessenger._message).to.equal( + await Mock__OVM_L2DepositedERC20.interface.encodeFunctionData( + 'finalizeDeposit', + [depositer, depositAmount] + ) + ) + expect(depositCallToMessenger._gasLimit).to.equal(finalizeDepositGasLimit) + }) + + it('depositTo() escrows the deposit amount and sends the correct deposit message', async () => { + // depositor calls deposit on the gateway and the L1 gateway calls transferFrom on the token + const bobsAddress = await bob.getAddress() + await OVM_L1ERC20Gateway.depositTo(bobsAddress, depositAmount) + const depositCallToMessenger = + Mock__OVM_L1CrossDomainMessenger.smocked.sendMessage.calls[0] + + const depositerBalance = await L1ERC20.balanceOf(depositer) + expect(depositerBalance).to.equal( + INITIAL_DEPOSITER_BALANCE - depositAmount + ) + + // gateway's balance is increased + const gatewayBalance = await L1ERC20.balanceOf(OVM_L1ERC20Gateway.address) + expect(gatewayBalance).to.equal(depositAmount) + + // Check the correct cross-chain call was sent: + // Message should be sent to the L2ERC20Gateway on L2 + expect(depositCallToMessenger._target).to.equal( + Mock__OVM_L2DepositedERC20.address + ) + // Message data should be a call telling the L2ERC20Gateway to finalize the deposit + + // the L1 gateway sends the correct message to the L1 messenger + expect(depositCallToMessenger._message).to.equal( + await Mock__OVM_L2DepositedERC20.interface.encodeFunctionData( + 'finalizeDeposit', + [bobsAddress, depositAmount] + ) + ) + expect(depositCallToMessenger._gasLimit).to.equal(finalizeDepositGasLimit) + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/bridge/assets/OVM_L1ETHGateway.spec.ts b/packages/contracts/test/contracts/OVM/bridge/assets/OVM_L1ETHGateway.spec.ts new file mode 100644 index 000000000000..d39f39beeb53 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/bridge/assets/OVM_L1ETHGateway.spec.ts @@ -0,0 +1,235 @@ +import { expect } from '../../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Signer, Contract, constants } from 'ethers' +import { smockit, MockContract } from '@eth-optimism/smock' + +/* Internal Imports */ +import { NON_ZERO_ADDRESS, makeAddressManager } from '../../../../helpers' + +const L1_ETH_GATEWAY_NAME = 'Proxy__OVM_L1CrossDomainMessenger' + +const ERR_INVALID_MESSENGER = 'OVM_XCHAIN: messenger contract unauthenticated' +const ERR_INVALID_X_DOMAIN_MSG_SENDER = + 'OVM_XCHAIN: wrong sender of cross-domain message' + +describe('OVM_L1ETHGateway', () => { + // init signers + let l1MessengerImpersonator: Signer + let alice: Signer + let bob: Signer + + let AddressManager: Contract + before(async () => { + AddressManager = await makeAddressManager() + }) + + // we can just make up this string since it's on the "other" Layer + let Mock__OVM_L2DepositedERC20: MockContract + before(async () => { + ;[l1MessengerImpersonator, alice, bob] = await ethers.getSigners() + + Mock__OVM_L2DepositedERC20 = await smockit( + await ethers.getContractFactory('OVM_L2DepositedERC20') + ) + }) + + let OVM_L1ETHGateway: Contract + let Mock__OVM_L1CrossDomainMessenger: MockContract + let finalizeDepositGasLimit: number + beforeEach(async () => { + // Get a new mock L1 messenger + Mock__OVM_L1CrossDomainMessenger = await smockit( + await ethers.getContractFactory('OVM_L1CrossDomainMessenger'), + { address: await l1MessengerImpersonator.getAddress() } // This allows us to use an ethers override {from: Mock__OVM_L2CrossDomainMessenger.address} to mock calls + ) + + // Deploy the contract under test + OVM_L1ETHGateway = await ( + await ethers.getContractFactory('OVM_L1ETHGateway') + ).deploy(AddressManager.address, Mock__OVM_L2DepositedERC20.address) + + finalizeDepositGasLimit = await OVM_L1ETHGateway.getFinalizeDepositL2Gas() + }) + + describe('finalizeWithdrawal', () => { + it('onlyFromCrossDomainAccount: should revert on calls from a non-crossDomainMessenger L1 account', async () => { + // Deploy new gateway, initialize with random messenger + await expect( + OVM_L1ETHGateway.connect(alice).finalizeWithdrawal( + constants.AddressZero, + 1 + ) + ).to.be.revertedWith(ERR_INVALID_MESSENGER) + }) + + it('onlyFromCrossDomainAccount: should revert on calls from the right crossDomainMessenger, but wrong xDomainMessageSender (ie. not the L2ETHGateway)', async () => { + await AddressManager.setAddress( + L1_ETH_GATEWAY_NAME, + Mock__OVM_L1CrossDomainMessenger.address + ) + + OVM_L1ETHGateway = await ( + await ethers.getContractFactory('OVM_L1ETHGateway') + ).deploy(AddressManager.address, Mock__OVM_L2DepositedERC20.address) + + Mock__OVM_L1CrossDomainMessenger.smocked.xDomainMessageSender.will.return.with( + NON_ZERO_ADDRESS + ) + + await expect( + OVM_L1ETHGateway.finalizeWithdrawal(constants.AddressZero, 1) + ).to.be.revertedWith(ERR_INVALID_X_DOMAIN_MSG_SENDER) + }) + + it('should credit funds to the withdrawer and not use too much gas', async () => { + // make sure no balance at start of test + await expect( + await ethers.provider.getBalance(NON_ZERO_ADDRESS) + ).to.be.equal(0) + + const withdrawalAmount = 100 + Mock__OVM_L1CrossDomainMessenger.smocked.xDomainMessageSender.will.return.with( + () => Mock__OVM_L2DepositedERC20.address + ) + + // thanks Alice + await OVM_L1ETHGateway.connect(alice).deposit({ + value: ethers.utils.parseEther('1.0'), + gasPrice: 0, + }) + + const res = await OVM_L1ETHGateway.finalizeWithdrawal( + NON_ZERO_ADDRESS, + withdrawalAmount, + { from: Mock__OVM_L1CrossDomainMessenger.address } + ) + + await expect( + await ethers.provider.getBalance(NON_ZERO_ADDRESS) + ).to.be.equal(withdrawalAmount) + + const gasUsed = ( + await OVM_L1ETHGateway.provider.getTransactionReceipt(res.hash) + ).gasUsed + + // Deploy this just for the getter + const OVM_L2DepositedERC20 = await ( + await ethers.getContractFactory('OVM_L2DepositedERC20') + ).deploy(constants.AddressZero, '', '') + + await expect( + gasUsed.gt( + ((await OVM_L2DepositedERC20.getFinalizeWithdrawalL1Gas()) * 11) / 10 + ) + ) + }) + + it.skip('finalizeWithdrawalAndCall(): should should credit funds to the withdrawer, and forward from and data', async () => { + // TODO: implement this functionality in a future update + expect.fail() + }) + }) + + describe('deposits', () => { + const depositAmount = 1_000 + + beforeEach(async () => { + // Deploy the L1 ETH token, Alice will receive the full initialSupply + + // get a new mock L1 messenger and set in AM + Mock__OVM_L1CrossDomainMessenger = await smockit( + await ethers.getContractFactory('OVM_L1CrossDomainMessenger') + ) + await AddressManager.setAddress( + L1_ETH_GATEWAY_NAME, + Mock__OVM_L1CrossDomainMessenger.address + ) + + // Deploy the contract under test: + OVM_L1ETHGateway = await ( + await ethers.getContractFactory('OVM_L1ETHGateway') + ).deploy(AddressManager.address, Mock__OVM_L2DepositedERC20.address) + }) + + it('deposit() escrows the deposit amount and sends the correct deposit message', async () => { + const depositer = await alice.getAddress() + const initialBalance = await ethers.provider.getBalance(depositer) + + // alice calls deposit on the gateway and the L1 gateway calls transferFrom on the token + await OVM_L1ETHGateway.connect(alice).deposit({ + value: depositAmount, + gasPrice: 0, + }) + + const depositCallToMessenger = + Mock__OVM_L1CrossDomainMessenger.smocked.sendMessage.calls[0] + + const depositerBalance = await ethers.provider.getBalance(depositer) + + expect(depositerBalance).to.equal(initialBalance.sub(depositAmount)) + + // gateway's balance is increased + const gatewayBalance = await ethers.provider.getBalance( + OVM_L1ETHGateway.address + ) + expect(gatewayBalance).to.equal(depositAmount) + + // Check the correct cross-chain call was sent: + // Message should be sent to the L2ETHGateway on L2 + expect(depositCallToMessenger._target).to.equal( + Mock__OVM_L2DepositedERC20.address + ) + // Message data should be a call telling the L2ETHGateway to finalize the deposit + + // the L1 gateway sends the correct message to the L1 messenger + expect(depositCallToMessenger._message).to.equal( + await Mock__OVM_L2DepositedERC20.interface.encodeFunctionData( + 'finalizeDeposit', + [depositer, depositAmount] + ) + ) + expect(depositCallToMessenger._gasLimit).to.equal(finalizeDepositGasLimit) + }) + + it('depositTo() escrows the deposit amount and sends the correct deposit message', async () => { + // depositor calls deposit on the gateway and the L1 gateway calls transferFrom on the token + const bobsAddress = await bob.getAddress() + const aliceAddress = await alice.getAddress() + const initialBalance = await ethers.provider.getBalance(aliceAddress) + + await OVM_L1ETHGateway.connect(alice).depositTo(bobsAddress, { + value: depositAmount, + gasPrice: 0, + }) + const depositCallToMessenger = + Mock__OVM_L1CrossDomainMessenger.smocked.sendMessage.calls[0] + + const depositerBalance = await ethers.provider.getBalance(aliceAddress) + expect(depositerBalance).to.equal(initialBalance.sub(depositAmount)) + + // gateway's balance is increased + const gatewayBalance = await ethers.provider.getBalance( + OVM_L1ETHGateway.address + ) + expect(gatewayBalance).to.equal(depositAmount) + + // Check the correct cross-chain call was sent: + // Message should be sent to the L2ETHGateway on L2 + expect(depositCallToMessenger._target).to.equal( + Mock__OVM_L2DepositedERC20.address + ) + // Message data should be a call telling the L2ETHGateway to finalize the deposit + + // the L1 gateway sends the correct message to the L1 messenger + expect(depositCallToMessenger._message).to.equal( + await Mock__OVM_L2DepositedERC20.interface.encodeFunctionData( + 'finalizeDeposit', + [bobsAddress, depositAmount] + ) + ) + expect(depositCallToMessenger._gasLimit).to.equal(finalizeDepositGasLimit) + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/bridge/assets/OVM_L2DepositedERC20.spec.ts b/packages/contracts/test/contracts/OVM/bridge/assets/OVM_L2DepositedERC20.spec.ts new file mode 100644 index 000000000000..94e22562931e --- /dev/null +++ b/packages/contracts/test/contracts/OVM/bridge/assets/OVM_L2DepositedERC20.spec.ts @@ -0,0 +1,207 @@ +import { expect } from '../../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Signer, ContractFactory, Contract, constants } from 'ethers' +import { + smockit, + MockContract, + smoddit, + ModifiableContract, +} from '@eth-optimism/smock' + +/* Internal Imports */ +import { NON_ZERO_ADDRESS } from '../../../../helpers' + +const ERR_INVALID_MESSENGER = 'OVM_XCHAIN: messenger contract unauthenticated' +const ERR_INVALID_X_DOMAIN_MSG_SENDER = + 'OVM_XCHAIN: wrong sender of cross-domain message' +const MOCK_L1GATEWAY_ADDRESS: string = + '0x1234123412341234123412341234123412341234' + +describe('OVM_L2DepositedERC20', () => { + let alice: Signer + let bob: Signer + let Factory__OVM_L1ERC20Gateway: ContractFactory + before(async () => { + ;[alice, bob] = await ethers.getSigners() + Factory__OVM_L1ERC20Gateway = await ethers.getContractFactory( + 'OVM_L1ERC20Gateway' + ) + }) + + let OVM_L2DepositedERC20: Contract + let Mock__OVM_L2CrossDomainMessenger: MockContract + let finalizeWithdrawalGasLimit: number + beforeEach(async () => { + // Create a special signer which will enable us to send messages from the L2Messenger contract + let l2MessengerImpersonator: Signer + ;[l2MessengerImpersonator] = await ethers.getSigners() + + // Get a new mock L2 messenger + Mock__OVM_L2CrossDomainMessenger = await smockit( + await ethers.getContractFactory('OVM_L2CrossDomainMessenger'), + // This allows us to use an ethers override {from: Mock__OVM_L2CrossDomainMessenger.address} to mock calls + { address: await l2MessengerImpersonator.getAddress() } + ) + + // Deploy the contract under test + OVM_L2DepositedERC20 = await ( + await ethers.getContractFactory('OVM_L2DepositedERC20') + ).deploy(Mock__OVM_L2CrossDomainMessenger.address, 'ovmWETH', 'oWETH') + + // initialize the L2 Gateway with the L1G ateway addrss + await OVM_L2DepositedERC20.init(MOCK_L1GATEWAY_ADDRESS) + + finalizeWithdrawalGasLimit = await OVM_L2DepositedERC20.getFinalizeWithdrawalL1Gas() + }) + + // test the transfer flow of moving a token from L2 to L1 + describe('finalizeDeposit', () => { + it('onlyFromCrossDomainAccount: should revert on calls from a non-crossDomainMessenger L2 account', async () => { + // Deploy new gateway, initialize with random messenger + OVM_L2DepositedERC20 = await ( + await ethers.getContractFactory('OVM_L2DepositedERC20') + ).deploy(NON_ZERO_ADDRESS, 'ovmWETH', 'oWETH') + await OVM_L2DepositedERC20.init(NON_ZERO_ADDRESS) + + await expect( + OVM_L2DepositedERC20.finalizeDeposit(constants.AddressZero, 0) + ).to.be.revertedWith(ERR_INVALID_MESSENGER) + }) + + it('onlyFromCrossDomainAccount: should revert on calls from the right crossDomainMessenger, but wrong xDomainMessageSender (ie. not the L1ERC20Gateway)', async () => { + Mock__OVM_L2CrossDomainMessenger.smocked.xDomainMessageSender.will.return.with( + NON_ZERO_ADDRESS + ) + + await expect( + OVM_L2DepositedERC20.finalizeDeposit(constants.AddressZero, 0, { + from: Mock__OVM_L2CrossDomainMessenger.address, + }) + ).to.be.revertedWith(ERR_INVALID_X_DOMAIN_MSG_SENDER) + }) + + it('should credit funds to the depositor', async () => { + const depositAmount = 100 + Mock__OVM_L2CrossDomainMessenger.smocked.xDomainMessageSender.will.return.with( + () => MOCK_L1GATEWAY_ADDRESS + ) + + await OVM_L2DepositedERC20.finalizeDeposit( + await alice.getAddress(), + depositAmount, + { from: Mock__OVM_L2CrossDomainMessenger.address } + ) + + const aliceBalance = await OVM_L2DepositedERC20.balanceOf( + await alice.getAddress() + ) + aliceBalance.should.equal(depositAmount) + }) + }) + + describe('withdrawals', () => { + const INITIAL_TOTAL_SUPPLY = 100_000 + const ALICE_INITIAL_BALANCE = 50_000 + const withdrawAmount = 1_000 + let SmoddedL2Gateway: ModifiableContract + beforeEach(async () => { + // Deploy a smodded gateway so we can give some balances to withdraw + SmoddedL2Gateway = await ( + await smoddit('OVM_L2DepositedERC20', alice) + ).deploy(Mock__OVM_L2CrossDomainMessenger.address, 'ovmWETH', 'oWETH') + await SmoddedL2Gateway.init(MOCK_L1GATEWAY_ADDRESS) + + // Populate the initial state with a total supply and some money in alice's balance + const aliceAddress = await alice.getAddress() + SmoddedL2Gateway.smodify.put({ + totalSupply: INITIAL_TOTAL_SUPPLY, + balanceOf: { + [aliceAddress]: ALICE_INITIAL_BALANCE, + }, + }) + }) + + it('withdraw() burns and sends the correct withdrawal message', async () => { + await SmoddedL2Gateway.withdraw(withdrawAmount) + const withdrawalCallToMessenger = + Mock__OVM_L2CrossDomainMessenger.smocked.sendMessage.calls[0] + + // Assert Alice's balance went down + const aliceBalance = await SmoddedL2Gateway.balanceOf( + await alice.getAddress() + ) + expect(aliceBalance).to.deep.equal( + ethers.BigNumber.from(ALICE_INITIAL_BALANCE - withdrawAmount) + ) + + // Assert totalSupply went down + const newTotalSupply = await SmoddedL2Gateway.totalSupply() + expect(newTotalSupply).to.deep.equal( + ethers.BigNumber.from(INITIAL_TOTAL_SUPPLY - withdrawAmount) + ) + + // Assert the correct cross-chain call was sent: + // Message should be sent to the L1ERC20Gateway on L1 + expect(withdrawalCallToMessenger._target).to.equal(MOCK_L1GATEWAY_ADDRESS) + // Message data should be a call telling the L1ERC20Gateway to finalize the withdrawal + expect(withdrawalCallToMessenger._message).to.equal( + await Factory__OVM_L1ERC20Gateway.interface.encodeFunctionData( + 'finalizeWithdrawal', + [await alice.getAddress(), withdrawAmount] + ) + ) + // Hardcoded gaslimit should be correct + expect(withdrawalCallToMessenger._gasLimit).to.equal( + finalizeWithdrawalGasLimit + ) + }) + + it('withdrawTo() burns and sends the correct withdrawal message', async () => { + await SmoddedL2Gateway.withdrawTo(await bob.getAddress(), withdrawAmount) + const withdrawalCallToMessenger = + Mock__OVM_L2CrossDomainMessenger.smocked.sendMessage.calls[0] + + // Assert Alice's balance went down + const aliceBalance = await SmoddedL2Gateway.balanceOf( + await alice.getAddress() + ) + expect(aliceBalance).to.deep.equal( + ethers.BigNumber.from(ALICE_INITIAL_BALANCE - withdrawAmount) + ) + + // Assert totalSupply went down + const newTotalSupply = await SmoddedL2Gateway.totalSupply() + expect(newTotalSupply).to.deep.equal( + ethers.BigNumber.from(INITIAL_TOTAL_SUPPLY - withdrawAmount) + ) + + // Assert the correct cross-chain call was sent. + // Message should be sent to the L1ERC20Gateway on L1 + expect(withdrawalCallToMessenger._target).to.equal(MOCK_L1GATEWAY_ADDRESS) + // The message data should be a call telling the L1ERC20Gateway to finalize the withdrawal + expect(withdrawalCallToMessenger._message).to.equal( + await Factory__OVM_L1ERC20Gateway.interface.encodeFunctionData( + 'finalizeWithdrawal', + [await bob.getAddress(), withdrawAmount] + ) + ) + // Hardcoded gaslimit should be correct + expect(withdrawalCallToMessenger._gasLimit).to.equal( + finalizeWithdrawalGasLimit + ) + }) + }) + + // low priority todos: see question in contract + describe.skip('Initialization logic', () => { + it('should not allow calls to onlyInitialized functions', async () => { + // TODO + }) + + it('should only allow initialization once and emits initialized event', async () => { + // TODO + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/bridge/base/OVM_L1CrossDomainMessenger.spec.ts b/packages/contracts/test/contracts/OVM/bridge/base/OVM_L1CrossDomainMessenger.spec.ts new file mode 100644 index 000000000000..bc88722cabf5 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/bridge/base/OVM_L1CrossDomainMessenger.spec.ts @@ -0,0 +1,378 @@ +import { expect } from '../../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Signer, ContractFactory, Contract, BigNumber } from 'ethers' +import { smockit, MockContract } from '@eth-optimism/smock' +import { remove0x, toHexString } from '@eth-optimism/core-utils' + +/* Internal Imports */ +import { + makeAddressManager, + setProxyTarget, + NON_NULL_BYTES32, + NON_ZERO_ADDRESS, + DUMMY_BATCH_HEADERS, + DUMMY_BATCH_PROOFS, + TrieTestGenerator, + getNextBlockNumber, + getXDomainCalldata, +} from '../../../../helpers' +import { keccak256 } from 'ethers/lib/utils' + +const deployProxyXDomainMessenger = async ( + addressManager: Contract, + l1XDomainMessenger: Contract +): Promise => { + await addressManager.setAddress( + 'OVM_L1CrossDomainMessenger', + l1XDomainMessenger.address + ) + const proxy = await ( + await ethers.getContractFactory('Lib_ResolvedDelegateProxy') + ).deploy(addressManager.address, 'OVM_L1CrossDomainMessenger') + return l1XDomainMessenger.attach(proxy.address) +} + +describe('OVM_L1CrossDomainMessenger', () => { + let signer: Signer + before(async () => { + ;[signer] = await ethers.getSigners() + }) + + let AddressManager: Contract + before(async () => { + AddressManager = await makeAddressManager() + }) + + let Mock__TargetContract: MockContract + let Mock__OVM_L2CrossDomainMessenger: MockContract + let Mock__OVM_CanonicalTransactionChain: MockContract + let Mock__OVM_StateCommitmentChain: MockContract + before(async () => { + Mock__TargetContract = await smockit( + await ethers.getContractFactory('Helper_SimpleProxy') + ) + Mock__OVM_L2CrossDomainMessenger = await smockit( + await ethers.getContractFactory('OVM_L2CrossDomainMessenger') + ) + Mock__OVM_CanonicalTransactionChain = await smockit( + await ethers.getContractFactory('OVM_CanonicalTransactionChain') + ) + Mock__OVM_StateCommitmentChain = await smockit( + await ethers.getContractFactory('OVM_StateCommitmentChain') + ) + + await AddressManager.setAddress( + 'OVM_L2CrossDomainMessenger', + Mock__OVM_L2CrossDomainMessenger.address + ) + + await setProxyTarget( + AddressManager, + 'OVM_CanonicalTransactionChain', + Mock__OVM_CanonicalTransactionChain + ) + await setProxyTarget( + AddressManager, + 'OVM_StateCommitmentChain', + Mock__OVM_StateCommitmentChain + ) + }) + + let Factory__OVM_L1CrossDomainMessenger: ContractFactory + before(async () => { + Factory__OVM_L1CrossDomainMessenger = await ethers.getContractFactory( + 'OVM_L1CrossDomainMessenger' + ) + }) + + let OVM_L1CrossDomainMessenger: Contract + beforeEach(async () => { + const xDomainMessenerImpl = await Factory__OVM_L1CrossDomainMessenger.deploy() + // We use an upgradable proxy for the XDomainMessenger--deploy & set up the proxy. + OVM_L1CrossDomainMessenger = await deployProxyXDomainMessenger( + AddressManager, + xDomainMessenerImpl + ) + await OVM_L1CrossDomainMessenger.initialize(AddressManager.address) + }) + + describe('sendMessage', () => { + const target = NON_ZERO_ADDRESS + const message = NON_NULL_BYTES32 + const gasLimit = 100_000 + + it('should be able to send a single message', async () => { + await expect( + OVM_L1CrossDomainMessenger.sendMessage(target, message, gasLimit) + ).to.not.be.reverted + + expect( + Mock__OVM_CanonicalTransactionChain.smocked.enqueue.calls[0] + ).to.deep.equal([ + Mock__OVM_L2CrossDomainMessenger.address, + BigNumber.from(gasLimit), + getXDomainCalldata(await signer.getAddress(), target, message, 0), + ]) + }) + + it('should be able to send the same message twice', async () => { + await OVM_L1CrossDomainMessenger.sendMessage(target, message, gasLimit) + + await expect( + OVM_L1CrossDomainMessenger.sendMessage(target, message, gasLimit) + ).to.not.be.reverted + }) + }) + + describe('replayMessage', () => { + const target = NON_ZERO_ADDRESS + const message = NON_NULL_BYTES32 + const gasLimit = 100_000 + + it('should revert if the message does not exist', async () => { + await expect( + OVM_L1CrossDomainMessenger.replayMessage( + target, + await signer.getAddress(), + message, + 0, + gasLimit + ) + ).to.be.revertedWith('Provided message has not already been sent.') + }) + + it('should succeed if the message exists', async () => { + await OVM_L1CrossDomainMessenger.sendMessage(target, message, gasLimit) + + await expect( + OVM_L1CrossDomainMessenger.replayMessage( + target, + await signer.getAddress(), + message, + 0, + gasLimit + ) + ).to.not.be.reverted + }) + }) + + describe('relayMessage', () => { + let target: string + let message: string + let sender: string + let proof: any + let calldata: string + before(async () => { + target = Mock__TargetContract.address + message = Mock__TargetContract.interface.encodeFunctionData('setTarget', [ + NON_ZERO_ADDRESS, + ]) + sender = await signer.getAddress() + + calldata = getXDomainCalldata(sender, target, message, 0) + + const precompile = '0x4200000000000000000000000000000000000000' + + const storageKey = keccak256( + keccak256( + calldata + remove0x(Mock__OVM_L2CrossDomainMessenger.address) + ) + '00'.repeat(32) + ) + const storageGenerator = await TrieTestGenerator.fromNodes({ + nodes: [ + { + key: storageKey, + val: '0x' + '01'.padStart(2, '0'), + }, + ], + secure: true, + }) + + const generator = await TrieTestGenerator.fromAccounts({ + accounts: [ + { + address: precompile, + nonce: 0, + balance: 0, + codeHash: keccak256('0x1234'), + storageRoot: toHexString(storageGenerator._trie.root), + }, + ], + secure: true, + }) + + proof = { + stateRoot: toHexString(generator._trie.root), + stateRootBatchHeader: DUMMY_BATCH_HEADERS[0], + stateRootProof: DUMMY_BATCH_PROOFS[0], + stateTrieWitness: (await generator.makeAccountProofTest(precompile)) + .accountTrieWitness, + storageTrieWitness: ( + await storageGenerator.makeInclusionProofTest(storageKey) + ).proof, + } + }) + + beforeEach(async () => { + Mock__OVM_StateCommitmentChain.smocked.verifyStateCommitment.will.return.with( + true + ) + Mock__OVM_StateCommitmentChain.smocked.insideFraudProofWindow.will.return.with( + false + ) + }) + + it('should revert if still inside the fraud proof window', async () => { + Mock__OVM_StateCommitmentChain.smocked.insideFraudProofWindow.will.return.with( + true + ) + + const proof1 = { + stateRoot: ethers.constants.HashZero, + stateRootBatchHeader: DUMMY_BATCH_HEADERS[0], + stateRootProof: DUMMY_BATCH_PROOFS[0], + stateTrieWitness: '0x', + storageTrieWitness: '0x', + } + + await expect( + OVM_L1CrossDomainMessenger.relayMessage( + target, + sender, + message, + 0, + proof1 + ) + ).to.be.revertedWith('Provided message could not be verified.') + }) + + it('should revert if provided an invalid state root proof', async () => { + Mock__OVM_StateCommitmentChain.smocked.verifyStateCommitment.will.return.with( + false + ) + + const proof1 = { + stateRoot: ethers.constants.HashZero, + stateRootBatchHeader: DUMMY_BATCH_HEADERS[0], + stateRootProof: DUMMY_BATCH_PROOFS[0], + stateTrieWitness: '0x', + storageTrieWitness: '0x', + } + + await expect( + OVM_L1CrossDomainMessenger.relayMessage( + target, + sender, + message, + 0, + proof1 + ) + ).to.be.revertedWith('Provided message could not be verified.') + }) + + it('should revert if provided an invalid storage trie witness', async () => { + await expect( + OVM_L1CrossDomainMessenger.relayMessage(target, sender, message, 0, { + ...proof, + storageTrieWitness: '0x', + }) + ).to.be.reverted + }) + + it('should revert if provided an invalid state trie witness', async () => { + await expect( + OVM_L1CrossDomainMessenger.relayMessage(target, sender, message, 0, { + ...proof, + stateTrieWitness: '0x', + }) + ).to.be.reverted + }) + + it('should send a successful call to the target contract', async () => { + const blockNumber = await getNextBlockNumber(ethers.provider) + + await OVM_L1CrossDomainMessenger.relayMessage( + target, + sender, + message, + 0, + proof + ) + + expect( + await OVM_L1CrossDomainMessenger.successfulMessages(keccak256(calldata)) + ).to.equal(true) + + expect( + await OVM_L1CrossDomainMessenger.relayedMessages( + keccak256( + calldata + + remove0x(await signer.getAddress()) + + remove0x(BigNumber.from(blockNumber).toHexString()).padStart( + 64, + '0' + ) + ) + ) + ).to.equal(true) + }) + + it('the xDomainMessageSender is reset to the original value', async () => { + await expect( + OVM_L1CrossDomainMessenger.xDomainMessageSender() + ).to.be.revertedWith('xDomainMessageSender is not set') + await OVM_L1CrossDomainMessenger.relayMessage( + target, + sender, + message, + 0, + proof + ) + await expect( + OVM_L1CrossDomainMessenger.xDomainMessageSender() + ).to.be.revertedWith('xDomainMessageSender is not set') + }) + + it('should revert if trying to send the same message twice', async () => { + await OVM_L1CrossDomainMessenger.relayMessage( + target, + sender, + message, + 0, + proof + ) + + await expect( + OVM_L1CrossDomainMessenger.relayMessage( + target, + sender, + message, + 0, + proof + ) + ).to.be.revertedWith('Provided message has already been received.') + }) + + it('when the OVM_L2MessageRelayer address is set, should revert if called by a different account', async () => { + // set to a random NON-ZERO address + await AddressManager.setAddress( + 'OVM_L2MessageRelayer', + '0x1234123412341234123412341234123412341234' + ) + + await expect( + OVM_L1CrossDomainMessenger.relayMessage( + target, + sender, + message, + 0, + proof + ) + ).to.be.revertedWith( + 'Only OVM_L2MessageRelayer can relay L2-to-L1 messages.' + ) + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/bridge/base/OVM_L1MultiMessageRelayer.ts b/packages/contracts/test/contracts/OVM/bridge/base/OVM_L1MultiMessageRelayer.ts new file mode 100644 index 000000000000..b3acb9b7b089 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/bridge/base/OVM_L1MultiMessageRelayer.ts @@ -0,0 +1,136 @@ +import { expect } from '../../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Signer, ContractFactory, Contract } from 'ethers' +import { smockit, MockContract } from '@eth-optimism/smock' +import { toHexString } from '@eth-optimism/core-utils' + +/* Internal Imports */ +import { + makeAddressManager, + NON_ZERO_ADDRESS, + NON_NULL_BYTES32, + DUMMY_BATCH_HEADERS, + DUMMY_BATCH_PROOFS, +} from '../../../../helpers' + +describe('OVM_L1MultiMessageRelayer', () => { + let signer: Signer + before(async () => { + ;[signer] = await ethers.getSigners() + }) + + let AddressManager: Contract + let Factory__OVM_L1MultiMessageRelayer: ContractFactory + let Mock__OVM_L1CrossDomainMessenger: MockContract + let messages: any[] + + before(async () => { + // We do all the 'reusable setup' in here, ie. creating factories, mocks and setting addresses + // for everything but the contract under test + AddressManager = await makeAddressManager() + + // create a mock for the L1CrossDomainMessenger implementation + Mock__OVM_L1CrossDomainMessenger = await smockit( + await ethers.getContractFactory('OVM_L1CrossDomainMessenger') + ) + + // set the address of the mock contract to target + await AddressManager.setAddress( + // 'Proxy__OVM_L1CrossDomainMessenger' is the string used by the contract under test to lookup + // the target contract. On mainnet the target is a proxy which points to the implementation of + // the L1CrossDomainMessenger. + // In order to keep the tests simple, we skip the proxy here, and point directly to the impl. + 'Proxy__OVM_L1CrossDomainMessenger', + Mock__OVM_L1CrossDomainMessenger.address + ) + + // set the signer as the address required by access control + await AddressManager.setAddress( + 'OVM_L2BatchMessageRelayer', + signer.getAddress() + ) + + // define a dummy proof to satisfy the abi + const dummyProof = { + stateRoot: NON_NULL_BYTES32, + stateRootBatchHeader: DUMMY_BATCH_HEADERS[0], + stateRootProof: DUMMY_BATCH_PROOFS[0], + stateTrieWitness: toHexString('some bytes'), + storageTrieWitness: toHexString('some more bytes'), + } + + // create a few dummy messages to relay + const m1 = { + target: '0x1100000000000000000000000000000000000000', + message: NON_NULL_BYTES32, + sender: '0x2200000000000000000000000000000000000000', + messageNonce: 1, + proof: dummyProof, + } + + const m2 = { + target: '0x1100000000000000000000000000000000000000', + message: NON_NULL_BYTES32, + sender: '0x2200000000000000000000000000000000000000', + messageNonce: 2, + proof: dummyProof, + } + + const m3 = { + target: '0x1100000000000000000000000000000000000000', + message: NON_NULL_BYTES32, + sender: '0x2200000000000000000000000000000000000000', + messageNonce: 2, + proof: dummyProof, + } + + messages = [m1, m2, m3] + }) + + let OVM_L1MultiMessageRelayer: Contract + + beforeEach(async () => { + // setup a factory and deploy a new test-contract for each unit test + Factory__OVM_L1MultiMessageRelayer = await ethers.getContractFactory( + 'OVM_L1MultiMessageRelayer' + ) + OVM_L1MultiMessageRelayer = await Factory__OVM_L1MultiMessageRelayer.deploy( + AddressManager.address + ) + + // set the address of the OVM_L1MultiMessageRelayer, which the OVM_L1CrossDomainMessenger will + // check in its onlyRelayer modifier. + // The string currently used in the AddressManager is 'OVM_L2MessageRelayer' + await AddressManager.setAddress( + 'OVM_L2MessageRelayer', + OVM_L1MultiMessageRelayer.address + ) + // set the mock return value + Mock__OVM_L1CrossDomainMessenger.smocked.relayMessage.will.return() + }) + + describe('batchRelayMessages', () => { + it('Successfully relay multiple messages', async () => { + await OVM_L1MultiMessageRelayer.batchRelayMessages(messages) + await expect( + Mock__OVM_L1CrossDomainMessenger.smocked.relayMessage.calls.length + ).to.deep.equal(messages.length) + }) + + it('should revert if called by the wrong account', async () => { + // set the wrong address to use for ACL + await AddressManager.setAddress( + 'OVM_L2BatchMessageRelayer', + NON_ZERO_ADDRESS + ) + + await expect( + OVM_L1MultiMessageRelayer.batchRelayMessages(messages) + ).to.be.revertedWith( + 'OVM_L1MultiMessageRelayer: Function can only be called by the OVM_L2BatchMessageRelayer' + ) + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/bridge/base/OVM_L2CrossDomainMessenger.spec.ts b/packages/contracts/test/contracts/OVM/bridge/base/OVM_L2CrossDomainMessenger.spec.ts new file mode 100644 index 000000000000..3e68667ce45f --- /dev/null +++ b/packages/contracts/test/contracts/OVM/bridge/base/OVM_L2CrossDomainMessenger.spec.ts @@ -0,0 +1,161 @@ +import { expect } from '../../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Signer, ContractFactory, Contract, constants } from 'ethers' +import { smockit, MockContract } from '@eth-optimism/smock' + +/* Internal Imports */ +import { + makeAddressManager, + setProxyTarget, + NON_NULL_BYTES32, + NON_ZERO_ADDRESS, + getXDomainCalldata, +} from '../../../../helpers' + +describe('OVM_L2CrossDomainMessenger', () => { + let signer: Signer + before(async () => { + ;[signer] = await ethers.getSigners() + }) + + let AddressManager: Contract + before(async () => { + AddressManager = await makeAddressManager() + }) + + let Mock__TargetContract: MockContract + let Mock__OVM_L1CrossDomainMessenger: MockContract + let Mock__OVM_L1MessageSender: MockContract + let Mock__OVM_L2ToL1MessagePasser: MockContract + before(async () => { + Mock__TargetContract = await smockit( + await ethers.getContractFactory('Helper_SimpleProxy') + ) + Mock__OVM_L1CrossDomainMessenger = await smockit( + await ethers.getContractFactory('OVM_L1CrossDomainMessenger') + ) + Mock__OVM_L1MessageSender = await smockit( + await ethers.getContractFactory('OVM_L1MessageSender') + ) + Mock__OVM_L2ToL1MessagePasser = await smockit( + await ethers.getContractFactory('OVM_L2ToL1MessagePasser') + ) + + await AddressManager.setAddress( + 'OVM_L1CrossDomainMessenger', + Mock__OVM_L1CrossDomainMessenger.address + ) + + await setProxyTarget( + AddressManager, + 'OVM_L1MessageSender', + Mock__OVM_L1MessageSender + ) + await setProxyTarget( + AddressManager, + 'OVM_L2ToL1MessagePasser', + Mock__OVM_L2ToL1MessagePasser + ) + }) + + let Factory__OVM_L2CrossDomainMessenger: ContractFactory + before(async () => { + Factory__OVM_L2CrossDomainMessenger = await ethers.getContractFactory( + 'OVM_L2CrossDomainMessenger' + ) + }) + + let OVM_L2CrossDomainMessenger: Contract + beforeEach(async () => { + OVM_L2CrossDomainMessenger = await Factory__OVM_L2CrossDomainMessenger.deploy( + AddressManager.address + ) + }) + + describe('sendMessage', () => { + const target = NON_ZERO_ADDRESS + const message = NON_NULL_BYTES32 + const gasLimit = 100_000 + + it('should be able to send a single message', async () => { + await expect( + OVM_L2CrossDomainMessenger.sendMessage(target, message, gasLimit) + ).to.not.be.reverted + + expect( + Mock__OVM_L2ToL1MessagePasser.smocked.passMessageToL1.calls[0] + ).to.deep.equal([ + getXDomainCalldata(await signer.getAddress(), target, message, 0), + ]) + }) + + it('should be able to send the same message twice', async () => { + await OVM_L2CrossDomainMessenger.sendMessage(target, message, gasLimit) + + await expect( + OVM_L2CrossDomainMessenger.sendMessage(target, message, gasLimit) + ).to.not.be.reverted + }) + }) + + describe('relayMessage', () => { + let target: string + let message: string + let sender: string + before(async () => { + target = Mock__TargetContract.address + message = Mock__TargetContract.interface.encodeFunctionData('setTarget', [ + NON_ZERO_ADDRESS, + ]) + sender = await signer.getAddress() + }) + + beforeEach(async () => { + Mock__OVM_L1MessageSender.smocked.getL1MessageSender.will.return.with( + Mock__OVM_L1CrossDomainMessenger.address + ) + }) + + it('should revert if the L1 message sender is not the OVM_L1CrossDomainMessenger', async () => { + Mock__OVM_L1MessageSender.smocked.getL1MessageSender.will.return.with( + constants.AddressZero + ) + + await expect( + OVM_L2CrossDomainMessenger.relayMessage(target, sender, message, 0) + ).to.be.revertedWith('Provided message could not be verified.') + }) + + it('should send a call to the target contract', async () => { + await OVM_L2CrossDomainMessenger.relayMessage(target, sender, message, 0) + + expect(Mock__TargetContract.smocked.setTarget.calls[0]).to.deep.equal([ + NON_ZERO_ADDRESS, + ]) + }) + + it('the xDomainMessageSender is reset to the original value', async () => { + await expect( + OVM_L2CrossDomainMessenger.xDomainMessageSender() + ).to.be.revertedWith('xDomainMessageSender is not set') + await OVM_L2CrossDomainMessenger.relayMessage(target, sender, message, 0) + await expect( + OVM_L2CrossDomainMessenger.xDomainMessageSender() + ).to.be.revertedWith('xDomainMessageSender is not set') + }) + + it('should revert if trying to send the same message twice', async () => { + Mock__OVM_L1MessageSender.smocked.getL1MessageSender.will.return.with( + Mock__OVM_L1CrossDomainMessenger.address + ) + + await OVM_L2CrossDomainMessenger.relayMessage(target, sender, message, 0) + + await expect( + OVM_L2CrossDomainMessenger.relayMessage(target, sender, message, 0) + ).to.be.revertedWith('Provided message has already been received.') + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/chain/OVM_CanonicalTransactionChain.gas.spec.ts b/packages/contracts/test/contracts/OVM/chain/OVM_CanonicalTransactionChain.gas.spec.ts new file mode 100644 index 000000000000..7cadde783456 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/chain/OVM_CanonicalTransactionChain.gas.spec.ts @@ -0,0 +1,219 @@ +/* External Imports */ +import { ethers } from 'hardhat' +import { Signer, ContractFactory, Contract } from 'ethers' +import { smockit, MockContract } from '@eth-optimism/smock' +import { + AppendSequencerBatchParams, + encodeAppendSequencerBatch, +} from '@eth-optimism/core-utils' +import { TransactionResponse } from '@ethersproject/abstract-provider' +import { keccak256 } from 'ethers/lib/utils' +import _ from 'lodash' + +/* Internal Imports */ +import { + makeAddressManager, + setProxyTarget, + FORCE_INCLUSION_PERIOD_SECONDS, + FORCE_INCLUSION_PERIOD_BLOCKS, + getEthTime, + getNextBlockNumber, +} from '../../../helpers' + +// Still have some duplication from OVM_CanonicalTransactionChain.spec.ts, but it's so minimal that +// this is probably cleaner for now. Particularly since we're planning to move all of this out into +// core-utils soon anyway. +const DECOMPRESSION_ADDRESS = '0x4200000000000000000000000000000000000008' +const MAX_GAS_LIMIT = 8_000_000 + +const appendSequencerBatch = async ( + OVM_CanonicalTransactionChain: Contract, + batch: AppendSequencerBatchParams +): Promise => { + const methodId = keccak256(Buffer.from('appendSequencerBatch()')).slice(2, 10) + const calldata = encodeAppendSequencerBatch(batch) + return OVM_CanonicalTransactionChain.signer.sendTransaction({ + to: OVM_CanonicalTransactionChain.address, + data: '0x' + methodId + calldata, + }) +} + +describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => { + let sequencer: Signer + before(async () => { + ;[sequencer] = await ethers.getSigners() + }) + + let AddressManager: Contract + let Mock__OVM_ExecutionManager: MockContract + let Mock__OVM_StateCommitmentChain: MockContract + before(async () => { + AddressManager = await makeAddressManager() + await AddressManager.setAddress( + 'OVM_Sequencer', + await sequencer.getAddress() + ) + await AddressManager.setAddress( + 'OVM_DecompressionPrecompileAddress', + DECOMPRESSION_ADDRESS + ) + + Mock__OVM_ExecutionManager = await smockit( + await ethers.getContractFactory('OVM_ExecutionManager') + ) + + Mock__OVM_StateCommitmentChain = await smockit( + await ethers.getContractFactory('OVM_StateCommitmentChain') + ) + + await setProxyTarget( + AddressManager, + 'OVM_ExecutionManager', + Mock__OVM_ExecutionManager + ) + + await setProxyTarget( + AddressManager, + 'OVM_StateCommitmentChain', + Mock__OVM_StateCommitmentChain + ) + + Mock__OVM_ExecutionManager.smocked.getMaxTransactionGasLimit.will.return.with( + MAX_GAS_LIMIT + ) + }) + + let Factory__OVM_CanonicalTransactionChain: ContractFactory + let Factory__OVM_ChainStorageContainer: ContractFactory + before(async () => { + Factory__OVM_CanonicalTransactionChain = await ethers.getContractFactory( + 'OVM_CanonicalTransactionChain' + ) + + Factory__OVM_ChainStorageContainer = await ethers.getContractFactory( + 'OVM_ChainStorageContainer' + ) + }) + + let OVM_CanonicalTransactionChain: Contract + beforeEach(async () => { + OVM_CanonicalTransactionChain = await Factory__OVM_CanonicalTransactionChain.deploy( + AddressManager.address, + FORCE_INCLUSION_PERIOD_SECONDS, + FORCE_INCLUSION_PERIOD_BLOCKS, + MAX_GAS_LIMIT + ) + + const batches = await Factory__OVM_ChainStorageContainer.deploy( + AddressManager.address, + 'OVM_CanonicalTransactionChain' + ) + const queue = await Factory__OVM_ChainStorageContainer.deploy( + AddressManager.address, + 'OVM_CanonicalTransactionChain' + ) + + await AddressManager.setAddress( + 'OVM_ChainStorageContainer:CTC:batches', + batches.address + ) + + await AddressManager.setAddress( + 'OVM_ChainStorageContainer:CTC:queue', + queue.address + ) + + await AddressManager.setAddress( + 'OVM_CanonicalTransactionChain', + OVM_CanonicalTransactionChain.address + ) + }) + + describe('appendSequencerBatch', () => { + beforeEach(() => { + OVM_CanonicalTransactionChain = OVM_CanonicalTransactionChain.connect( + sequencer + ) + }) + + it('200 transactions in a single context', async () => { + console.log(`Benchmark: 200 transactions in a single context.`) + const timestamp = (await getEthTime(ethers.provider)) - 100 + const blockNumber = await getNextBlockNumber(ethers.provider) + + const transactionTemplate = '0x' + '11'.repeat(400) + const transactions = [] + const numTxs = 200 + for (let i = 0; i < numTxs; i++) { + transactions.push(transactionTemplate) + } + + const fixedCalldataCost = + (transactionTemplate.slice(2).length / 2) * 16 * numTxs + + const res = await appendSequencerBatch(OVM_CanonicalTransactionChain, { + shouldStartAtElement: 0, + totalElementsToAppend: numTxs, + contexts: [ + { + numSequencedTransactions: numTxs, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + }, + ], + transactions, + }) + + const receipt = await res.wait() + + console.log('Benchmark complete.') + console.log('Gas used:', receipt.gasUsed.toNumber()) + console.log('Fixed calldata cost:', fixedCalldataCost) + console.log( + 'Non-calldata overhead gas cost per transaction:', + (receipt.gasUsed.toNumber() - fixedCalldataCost) / numTxs + ) + }).timeout(100000000) + + it('200 transactions in 200 contexts', async () => { + console.log(`Benchmark: 200 transactions in 200 contexts.`) + const timestamp = (await getEthTime(ethers.provider)) - 100 + const blockNumber = await getNextBlockNumber(ethers.provider) + + const transactionTemplate = '0x' + '11'.repeat(400) + const transactions = [] + const numTxs = 200 + for (let i = 0; i < numTxs; i++) { + transactions.push(transactionTemplate) + } + + const fixedCalldataCost = + (transactionTemplate.slice(2).length / 2) * 16 * numTxs + + const res = await appendSequencerBatch(OVM_CanonicalTransactionChain, { + shouldStartAtElement: 0, + totalElementsToAppend: numTxs, + contexts: [...Array(numTxs)].map(() => { + return { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + } + }), + transactions, + }) + + const receipt = await res.wait() + + console.log('Benchmark complete.') + console.log('Gas used:', receipt.gasUsed.toNumber()) + console.log('Fixed calldata cost:', fixedCalldataCost) + console.log( + 'Non-calldata overhead gas cost per transaction:', + (receipt.gasUsed.toNumber() - fixedCalldataCost) / numTxs + ) + }).timeout(100000000) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/chain/OVM_CanonicalTransactionChain.spec.ts b/packages/contracts/test/contracts/OVM/chain/OVM_CanonicalTransactionChain.spec.ts new file mode 100644 index 000000000000..5c9b023660b4 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/chain/OVM_CanonicalTransactionChain.spec.ts @@ -0,0 +1,1469 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Signer, ContractFactory, Contract, BigNumber, constants } from 'ethers' +import { smockit, MockContract } from '@eth-optimism/smock' +import { + AppendSequencerBatchParams, + encodeAppendSequencerBatch, + remove0x, +} from '@eth-optimism/core-utils' +import { TransactionResponse } from '@ethersproject/abstract-provider' +import { keccak256 } from 'ethers/lib/utils' +import _ from 'lodash' + +/* Internal Imports */ +import { + makeAddressManager, + setProxyTarget, + FORCE_INCLUSION_PERIOD_SECONDS, + FORCE_INCLUSION_PERIOD_BLOCKS, + setEthTime, + NON_ZERO_ADDRESS, + getEthTime, + getNextBlockNumber, + increaseEthTime, + getBlockTime, + mineBlock, +} from '../../../helpers' + +const ELEMENT_TEST_SIZES = [1, 2, 4, 8, 16] +const DECOMPRESSION_ADDRESS = '0x4200000000000000000000000000000000000008' +const MAX_GAS_LIMIT = 8_000_000 + +const getQueueLeafHash = (index: number): string => { + return keccak256( + ethers.utils.defaultAbiCoder.encode( + ['bool', 'uint256', 'uint256', 'uint256', 'bytes'], + [false, index, 0, 0, '0x'] + ) + ) +} + +const getSequencerLeafHash = ( + timestamp: number, + blockNumber: number, + data: string +): string => { + return keccak256( + '0x01' + + remove0x(BigNumber.from(timestamp).toHexString()).padStart(64, '0') + + remove0x(BigNumber.from(blockNumber).toHexString()).padStart(64, '0') + + remove0x(data) + ) +} + +const getTransactionHash = ( + sender: string, + target: string, + gasLimit: number, + data: string +): string => { + return keccak256(encodeQueueTransaction(sender, target, gasLimit, data)) +} + +const encodeQueueTransaction = ( + sender: string, + target: string, + gasLimit: number, + data: string +): string => { + return ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256', 'bytes'], + [sender, target, gasLimit, data] + ) +} + +const appendSequencerBatch = async ( + OVM_CanonicalTransactionChain: Contract, + batch: AppendSequencerBatchParams +): Promise => { + const methodId = keccak256(Buffer.from('appendSequencerBatch()')).slice(2, 10) + const calldata = encodeAppendSequencerBatch(batch) + return OVM_CanonicalTransactionChain.signer.sendTransaction({ + to: OVM_CanonicalTransactionChain.address, + data: '0x' + methodId + calldata, + }) +} + +describe('OVM_CanonicalTransactionChain', () => { + let signer: Signer + let sequencer: Signer + before(async () => { + ;[signer, sequencer] = await ethers.getSigners() + }) + + let AddressManager: Contract + let Mock__OVM_ExecutionManager: MockContract + let Mock__OVM_StateCommitmentChain: MockContract + before(async () => { + AddressManager = await makeAddressManager() + await AddressManager.setAddress( + 'OVM_Sequencer', + await sequencer.getAddress() + ) + await AddressManager.setAddress( + 'OVM_DecompressionPrecompileAddress', + DECOMPRESSION_ADDRESS + ) + + Mock__OVM_ExecutionManager = await smockit( + await ethers.getContractFactory('OVM_ExecutionManager') + ) + + Mock__OVM_StateCommitmentChain = await smockit( + await ethers.getContractFactory('OVM_StateCommitmentChain') + ) + + await setProxyTarget( + AddressManager, + 'OVM_ExecutionManager', + Mock__OVM_ExecutionManager + ) + + await setProxyTarget( + AddressManager, + 'OVM_StateCommitmentChain', + Mock__OVM_StateCommitmentChain + ) + + Mock__OVM_ExecutionManager.smocked.getMaxTransactionGasLimit.will.return.with( + MAX_GAS_LIMIT + ) + }) + + let Factory__OVM_CanonicalTransactionChain: ContractFactory + let Factory__OVM_ChainStorageContainer: ContractFactory + before(async () => { + Factory__OVM_CanonicalTransactionChain = await ethers.getContractFactory( + 'OVM_CanonicalTransactionChain' + ) + + Factory__OVM_ChainStorageContainer = await ethers.getContractFactory( + 'OVM_ChainStorageContainer' + ) + }) + + let OVM_CanonicalTransactionChain: Contract + beforeEach(async () => { + OVM_CanonicalTransactionChain = await Factory__OVM_CanonicalTransactionChain.deploy( + AddressManager.address, + FORCE_INCLUSION_PERIOD_SECONDS, + FORCE_INCLUSION_PERIOD_BLOCKS, + MAX_GAS_LIMIT + ) + + const batches = await Factory__OVM_ChainStorageContainer.deploy( + AddressManager.address, + 'OVM_CanonicalTransactionChain' + ) + const queue = await Factory__OVM_ChainStorageContainer.deploy( + AddressManager.address, + 'OVM_CanonicalTransactionChain' + ) + + await AddressManager.setAddress( + 'OVM_ChainStorageContainer:CTC:batches', + batches.address + ) + + await AddressManager.setAddress( + 'OVM_ChainStorageContainer:CTC:queue', + queue.address + ) + + await AddressManager.setAddress( + 'OVM_CanonicalTransactionChain', + OVM_CanonicalTransactionChain.address + ) + }) + + describe('enqueue', () => { + const target = NON_ZERO_ADDRESS + const gasLimit = 500_000 + + it('should revert when trying to input more data than the max data size', async () => { + const MAX_ROLLUP_TX_SIZE = await OVM_CanonicalTransactionChain.MAX_ROLLUP_TX_SIZE() + const data = '0x' + '12'.repeat(MAX_ROLLUP_TX_SIZE + 1) + + await expect( + OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data) + ).to.be.revertedWith( + 'Transaction data size exceeds maximum for rollup transaction.' + ) + }) + + it('should revert when trying to enqueue a transaction with a higher gasLimit than the max', async () => { + const data = '0x1234567890' + + await expect( + OVM_CanonicalTransactionChain.enqueue(target, MAX_GAS_LIMIT + 1, data) + ).to.be.revertedWith( + 'Transaction gas limit exceeds maximum for rollup transaction.' + ) + }) + + it('should revert if gas limit parameter is not at least MIN_ROLLUP_TX_GAS', async () => { + const MIN_ROLLUP_TX_GAS = await OVM_CanonicalTransactionChain.MIN_ROLLUP_TX_GAS() + const customGasLimit = MIN_ROLLUP_TX_GAS / 2 + const data = '0x' + '12'.repeat(1234) + + await expect( + OVM_CanonicalTransactionChain.enqueue(target, customGasLimit, data) + ).to.be.revertedWith('Transaction gas limit too low to enqueue.') + }) + + it('should revert if transaction gas limit does not cover rollup burn', async () => { + const L2_GAS_DISCOUNT_DIVISOR = await OVM_CanonicalTransactionChain.L2_GAS_DISCOUNT_DIVISOR() + const data = '0x' + '12'.repeat(1234) + + await expect( + OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data, { + gasLimit: gasLimit / L2_GAS_DISCOUNT_DIVISOR + 30_000, // offset constant overhead + }) + ).to.be.revertedWith('Insufficient gas for L2 rate limiting burn.') + }) + + describe('with valid input parameters', () => { + it('should emit a TransactionEnqueued event', async () => { + const timestamp = (await getEthTime(ethers.provider)) + 100 + const data = '0x' + '12'.repeat(1234) + + await setEthTime(ethers.provider, timestamp) + + await expect( + OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data) + ).to.emit(OVM_CanonicalTransactionChain, 'TransactionEnqueued') + }) + + describe('when enqueing multiple times', () => { + const data = '0x' + '12'.repeat(1234) + + for (const size of ELEMENT_TEST_SIZES) { + it(`should be able to enqueue ${size} elements`, async () => { + for (let i = 0; i < size; i++) { + await expect( + OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data) + ).to.not.be.reverted + } + }) + } + }) + }) + }) + + describe('getQueueElement', () => { + it('should revert when accessing a non-existent element', async () => { + await expect( + OVM_CanonicalTransactionChain.getQueueElement(0) + ).to.be.revertedWith('Index out of bounds.') + }) + + describe('when the requested element exists', () => { + const target = NON_ZERO_ADDRESS + const gasLimit = 500_000 + const data = '0x' + '12'.repeat(1234) + + describe('when getting the first element', () => { + for (const size of ELEMENT_TEST_SIZES) { + it(`gets the element when ${size} + 1 elements exist`, async () => { + const timestamp = (await getEthTime(ethers.provider)) + 100 + const blockNumber = await getNextBlockNumber(ethers.provider) + await setEthTime(ethers.provider, timestamp) + + const transactionHash = getTransactionHash( + await signer.getAddress(), + target, + gasLimit, + data + ) + + await OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data) + + for (let i = 0; i < size; i++) { + await OVM_CanonicalTransactionChain.enqueue( + target, + gasLimit, + '0x' + '12'.repeat(i + 1) + ) + } + + expect( + _.toPlainObject( + await OVM_CanonicalTransactionChain.getQueueElement(0) + ) + ).to.deep.include({ + transactionHash, + timestamp, + blockNumber, + }) + }) + } + }) + + describe('when getting the middle element', () => { + for (const size of ELEMENT_TEST_SIZES) { + it(`gets the element when ${size} elements exist`, async () => { + let timestamp: number + let blockNumber: number + let transactionHash: string + + const middleIndex = Math.floor(size / 2) + for (let i = 0; i < size; i++) { + if (i === middleIndex) { + timestamp = (await getEthTime(ethers.provider)) + 100 + blockNumber = await getNextBlockNumber(ethers.provider) + await setEthTime(ethers.provider, timestamp) + + transactionHash = getTransactionHash( + await signer.getAddress(), + target, + gasLimit, + data + ) + + await OVM_CanonicalTransactionChain.enqueue( + target, + gasLimit, + data + ) + } else { + await OVM_CanonicalTransactionChain.enqueue( + target, + gasLimit, + '0x' + '12'.repeat(i + 1) + ) + } + } + + expect( + _.toPlainObject( + await OVM_CanonicalTransactionChain.getQueueElement(middleIndex) + ) + ).to.deep.include({ + transactionHash, + timestamp, + blockNumber, + }) + }) + } + }) + + describe('when getting the last element', () => { + for (const size of ELEMENT_TEST_SIZES) { + it(`gets the element when ${size} elements exist`, async () => { + let timestamp: number + let blockNumber: number + let transactionHash: string + + for (let i = 0; i < size; i++) { + if (i === size - 1) { + timestamp = (await getEthTime(ethers.provider)) + 100 + blockNumber = await getNextBlockNumber(ethers.provider) + await setEthTime(ethers.provider, timestamp) + + transactionHash = getTransactionHash( + await signer.getAddress(), + target, + gasLimit, + data + ) + + await OVM_CanonicalTransactionChain.enqueue( + target, + gasLimit, + data + ) + } else { + await OVM_CanonicalTransactionChain.enqueue( + target, + gasLimit, + '0x' + '12'.repeat(i + 1) + ) + } + } + + expect( + _.toPlainObject( + await OVM_CanonicalTransactionChain.getQueueElement(size - 1) + ) + ).to.deep.include({ + transactionHash, + timestamp, + blockNumber, + }) + }) + } + }) + }) + }) + + describe('appendQueueBatch disabled', () => { + it('should revert', async () => { + await expect( + OVM_CanonicalTransactionChain.appendQueueBatch(0) + ).to.be.revertedWith('appendQueueBatch is currently disabled.') + }) + }) + + describe.skip('appendQueueBatch', () => { + it('should revert if trying to append zero transactions', async () => { + await expect( + OVM_CanonicalTransactionChain.appendQueueBatch(0) + ).to.be.revertedWith('Must append more than zero transactions.') + }) + + it('should revert if the queue is empty', async () => { + await expect( + OVM_CanonicalTransactionChain.appendQueueBatch(1) + ).to.be.revertedWith('Must append more than zero transactions.') + }) + + describe('when the queue is not empty', () => { + const target = NON_ZERO_ADDRESS + const gasLimit = 500_000 + const data = '0x' + '12'.repeat(1234) + + for (const size of ELEMENT_TEST_SIZES) { + describe(`when the queue has ${size} elements`, () => { + beforeEach(async () => { + for (let i = 0; i < size; i++) { + await OVM_CanonicalTransactionChain.enqueue( + target, + gasLimit, + data + ) + } + }) + + describe('when the sequencer inclusion period has not passed', () => { + it('should revert if not called by the sequencer', async () => { + await expect( + OVM_CanonicalTransactionChain.connect(signer).appendQueueBatch( + 1 + ) + ).to.be.revertedWith( + 'Queue transactions cannot be submitted during the sequencer inclusion period.' + ) + }) + + it('should succeed if called by the sequencer', async () => { + await expect( + OVM_CanonicalTransactionChain.connect( + sequencer + ).appendQueueBatch(1) + ) + .to.emit(OVM_CanonicalTransactionChain, 'QueueBatchAppended') + .withArgs(0, 1, 1) + }) + }) + + describe('when the sequencer inclusion period has passed', () => { + beforeEach(async () => { + await increaseEthTime( + ethers.provider, + FORCE_INCLUSION_PERIOD_SECONDS * 2 + ) + }) + + it('should be able to append a single element', async () => { + await expect(OVM_CanonicalTransactionChain.appendQueueBatch(1)) + .to.emit(OVM_CanonicalTransactionChain, 'QueueBatchAppended') + .withArgs(0, 1, 1) + }) + + it(`should be able to append ${size} elements`, async () => { + await expect(OVM_CanonicalTransactionChain.appendQueueBatch(size)) + .to.emit(OVM_CanonicalTransactionChain, 'QueueBatchAppended') + .withArgs(0, size, size) + }) + + it(`should be able to append ${size} elements even if attempting to append ${size} + 1 elements`, async () => { + await expect( + OVM_CanonicalTransactionChain.appendQueueBatch(size + 1) + ) + .to.emit(OVM_CanonicalTransactionChain, 'QueueBatchAppended') + .withArgs(0, size, size) + }) + }) + }) + } + }) + }) + + describe('verifyTransaction', () => { + it('should successfully verify against a valid queue transaction appended by the sequencer', async () => { + const entrypoint = NON_ZERO_ADDRESS + const gasLimit = 500_000 + const data = '0x' + '12'.repeat(1234) + + const timestamp = (await getEthTime(ethers.provider)) + 100 + await setEthTime(ethers.provider, timestamp) + await OVM_CanonicalTransactionChain.enqueue(entrypoint, gasLimit, data) + + const blockNumber = await ethers.provider.getBlockNumber() + + await appendSequencerBatch( + OVM_CanonicalTransactionChain.connect(sequencer), + { + shouldStartAtElement: 0, + totalElementsToAppend: 1, + contexts: [ + { + numSequencedTransactions: 0, + numSubsequentQueueTransactions: 1, + timestamp, + blockNumber, + }, + ], + transactions: [], + } + ) + + expect( + await OVM_CanonicalTransactionChain.verifyTransaction( + { + timestamp, + blockNumber, + l1QueueOrigin: 1, + l1TxOrigin: await OVM_CanonicalTransactionChain.signer.getAddress(), + entrypoint, + gasLimit, + data, + }, + { + isSequenced: false, + queueIndex: 0, + timestamp: 0, + blockNumber: 0, + txData: '0x', + }, + { + batchIndex: 0, + batchRoot: getQueueLeafHash(0), + batchSize: 1, + prevTotalElements: 0, + extraData: '0x', + }, + { + index: 0, + siblings: [], + } + ) + ).to.equal(true) + }) + + it.skip('should successfully verify against a valid queue transaction appended by force', async () => { + const entrypoint = NON_ZERO_ADDRESS + const gasLimit = 500_000 + const data = '0x' + '12'.repeat(1234) + + const timestamp = (await getEthTime(ethers.provider)) + 100 + await setEthTime(ethers.provider, timestamp) + await OVM_CanonicalTransactionChain.enqueue(entrypoint, gasLimit, data) + + const blockNumber = await ethers.provider.getBlockNumber() + await increaseEthTime(ethers.provider, FORCE_INCLUSION_PERIOD_SECONDS * 2) + + await OVM_CanonicalTransactionChain.appendQueueBatch(1) + + expect( + await OVM_CanonicalTransactionChain.verifyTransaction( + { + timestamp, + blockNumber, + l1QueueOrigin: 1, + l1TxOrigin: await OVM_CanonicalTransactionChain.signer.getAddress(), + entrypoint, + gasLimit, + data, + }, + { + isSequenced: false, + queueIndex: 0, + timestamp: 0, + blockNumber: 0, + txData: '0x', + }, + { + batchIndex: 0, + batchRoot: getQueueLeafHash(0), + batchSize: 1, + prevTotalElements: 0, + extraData: '0x', + }, + { + index: 0, + siblings: [], + } + ) + ).to.equal(true) + }) + + it('should successfully verify against a valid sequencer transaction', async () => { + const entrypoint = DECOMPRESSION_ADDRESS + const gasLimit = MAX_GAS_LIMIT + const data = '0x' + '12'.repeat(1234) + const timestamp = (await getEthTime(ethers.provider)) - 10 + const blockNumber = (await ethers.provider.getBlockNumber()) - 1 + + await appendSequencerBatch( + OVM_CanonicalTransactionChain.connect(sequencer), + { + shouldStartAtElement: 0, + totalElementsToAppend: 1, + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + }, + ], + transactions: [data], + } + ) + + expect( + await OVM_CanonicalTransactionChain.verifyTransaction( + { + timestamp, + blockNumber, + l1QueueOrigin: 0, + l1TxOrigin: constants.AddressZero, + entrypoint, + gasLimit, + data, + }, + { + isSequenced: true, + queueIndex: 0, + timestamp, + blockNumber, + txData: data, + }, + { + batchIndex: 0, + batchRoot: getSequencerLeafHash(timestamp, blockNumber, data), + batchSize: 1, + prevTotalElements: 0, + extraData: '0x', + }, + { + index: 0, + siblings: [], + } + ) + ).to.equal(true) + }) + }) + + describe('appendSequencerBatch', () => { + beforeEach(() => { + OVM_CanonicalTransactionChain = OVM_CanonicalTransactionChain.connect( + sequencer + ) + }) + + it('should revert if expected start does not match current total batches', async () => { + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 0, + numSubsequentQueueTransactions: 0, + timestamp: 0, + blockNumber: 0, + }, + ], + shouldStartAtElement: 1234, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith( + 'Actual batch start index does not match expected start index.' + ) + }) + + it('should revert if not all sequencer transactions are processed', async () => { + const timestamp = await getEthTime(ethers.provider) + const blockNumber = (await getNextBlockNumber(ethers.provider)) - 1 + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234', '0x1234'], + contexts: [ + { + numSequencedTransactions: 0, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith('Not all sequencer transactions were processed.') + }) + + it('should revert if not called by the sequencer', async () => { + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain.connect(signer), { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 0, + numSubsequentQueueTransactions: 0, + timestamp: 0, + blockNumber: 0, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith('Function can only be called by the Sequencer.') + }) + + it('should revert if no contexts are provided', async () => { + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [], + shouldStartAtElement: 0, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith('Must provide at least one batch context.') + }) + + it('should revert if total elements to append is zero', async () => { + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 0, + numSubsequentQueueTransactions: 0, + timestamp: 0, + blockNumber: 0, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 0, + }) + ).to.be.revertedWith('Must append at least one element.') + }) + + describe('Sad path cases', () => { + const target = NON_ZERO_ADDRESS + const gasLimit = 500_000 + const data = '0x' + '12'.repeat(1234) + + describe('when the sequencer attempts to add more queue transactions than exist', () => { + it('reverts when there are zero transactions in the queue', async () => { + const timestamp = await getEthTime(ethers.provider) + const blockNumber = (await getNextBlockNumber(ethers.provider)) - 1 + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 1, + timestamp, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith('Index out of bounds.') + }) + + it('reverts when there are insufficient (but nonzero) transactions in the queue', async () => { + const timestamp = await getEthTime(ethers.provider) + const blockNumber = (await getNextBlockNumber(ethers.provider)) - 1 + + const numEnqueues = 7 + for (let i = 0; i < numEnqueues; i++) { + await OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data) + } + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: numEnqueues + 1, + timestamp, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: numEnqueues + 1, + }) + ).to.be.revertedWith('Not enough queued transactions to append.') + }) + }) + + describe('when the sequencer attempts to add transactions which are not monotonically increasing', () => { + describe('when the sequencer transactions themselves have out-of-order times', () => { + it('should revert when adding two out-of-order-timestamp sequencer elements', async () => { + const timestamp = await getEthTime(ethers.provider) + const blockNumber = (await getNextBlockNumber(ethers.provider)) - 1 + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234', '0x5678'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp: timestamp + 1, + blockNumber, + }, + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 2, + }) + ).to.be.revertedWith( + 'Context timestamp values must monotonically increase.' + ) + }) + + it('should revert when adding two out-of-order-blocknumber sequencer elements', async () => { + const timestamp = await getEthTime(ethers.provider) + const blockNumber = (await getNextBlockNumber(ethers.provider)) - 1 + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234', '0x5678'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber: blockNumber + 1, + }, + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 2, + }) + ).to.be.revertedWith( + 'Context blockNumber values must monotonically increase.' + ) + }) + }) + describe('when the elements are out-of-order with regards to pending queue elements', async () => { + describe('adding a single sequencer transaction with a single pending queue element', () => { + beforeEach(async () => { + // enqueue a single element so that it is pending, but do not yet apply it + await OVM_CanonicalTransactionChain.enqueue( + target, + gasLimit, + data + ) + }) + it('should revert if the first context timestamp is > the head queue element timestamp', async () => { + const timestamp = (await getEthTime(ethers.provider)) + 100 + const blockNumber = + (await getNextBlockNumber(ethers.provider)) - 1 + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith( + 'Sequencer transaction timestamp exceeds that of next queue element.' + ) + }) + + it('should revert if the context block number is > the head queue element block number', async () => { + const timestamp = (await getEthTime(ethers.provider)) - 100 + const blockNumber = + (await getNextBlockNumber(ethers.provider)) + 100 + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith( + 'Sequencer transaction blockNumber exceeds that of next queue element.' + ) + }) + }) + describe('adding multiple sequencer transactions with multiple pending queue elements', () => { + const numQueuedTransactions = 10 + const queueElements = [] + const validContexts = [] + beforeEach(async () => { + for (let i = 0; i < numQueuedTransactions; i++) { + await OVM_CanonicalTransactionChain.enqueue( + target, + gasLimit, + data + ) + queueElements[ + i + ] = await OVM_CanonicalTransactionChain.getQueueElement(i) + // this is a valid context for this TX + validContexts[i] = { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 1, + timestamp: queueElements[i].timestamp, + blockNumber: queueElements[i].blockNumber, + } + } + }) + + it('does not revert for valid context', async () => { + await appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: new Array(numQueuedTransactions).fill('0x1234'), + contexts: validContexts, + shouldStartAtElement: 0, + totalElementsToAppend: 2 * numQueuedTransactions, + }) + }) + + it('reverts if wrong timestamp in middle', async () => { + const invalidTimestampContexts = [...validContexts] + // put a bigger timestamp early + invalidTimestampContexts[6].timestamp = + invalidTimestampContexts[8].timestamp + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: new Array(numQueuedTransactions).fill('0x1234'), + contexts: invalidTimestampContexts, + shouldStartAtElement: 0, + totalElementsToAppend: 2 * numQueuedTransactions, + }) + ).to.be.revertedWith( + 'Sequencer transaction timestamp exceeds that of next queue element.' + ) + }) + + it('reverts if wrong block number in the middle', async () => { + const invalidBlockNumberContexts = [...validContexts] + // put a bigger block number early + invalidBlockNumberContexts[6].blockNumber = + invalidBlockNumberContexts[8].blockNumber + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: new Array(numQueuedTransactions).fill('0x1234'), + contexts: invalidBlockNumberContexts, + shouldStartAtElement: 0, + totalElementsToAppend: 2 * numQueuedTransactions, + }) + ).to.be.revertedWith( + 'Sequencer transaction blockNumber exceeds that of next queue element.' + ) + }) + }) + }) + }) + + describe('when the sequencer attempts to add transactions with out-of-bounds times', async () => { + describe('when trying to add elements from the future', () => { + it('reverts on initial timestamp in the future', async () => { + const timestamp = (await getEthTime(ethers.provider)) + 100_000_000 + const blockNumber = (await getNextBlockNumber(ethers.provider)) - 1 + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith('Context timestamp is from the future.') + }) + + it('reverts on non-initial timestamp in the future', async () => { + const timestamp = await getEthTime(ethers.provider) + const blockNumber = (await getNextBlockNumber(ethers.provider)) - 1 + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234', '0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + }, + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp: timestamp + 100_000_000, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 2, + }) + ).to.be.revertedWith('Context timestamp is from the future.') + }) + + it('reverts on initial blocknumber in the future', async () => { + const timestamp = await getEthTime(ethers.provider) + const blockNumber = (await getNextBlockNumber(ethers.provider)) + 1 + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith('Context block number is from the future.') + }) + }) + }) + + describe('when trying to add elements which are older than the force inclusion period', async () => { + it('reverts for a timestamp older than the f.i.p. ago', async () => { + const timestamp = await getEthTime(ethers.provider) + await increaseEthTime( + ethers.provider, + FORCE_INCLUSION_PERIOD_SECONDS + 1 + ) + const blockNumber = (await getNextBlockNumber(ethers.provider)) - 1 + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith('Context timestamp too far in the past.') + }) + + it('reverts for a blockNumber older than the f.i.p. ago', async () => { + const timestamp = await getEthTime(ethers.provider) + + for (let i = 0; i < FORCE_INCLUSION_PERIOD_BLOCKS + 1; i++) { + await mineBlock(ethers.provider) + } + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber: 10, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith('Context block number too far in the past.') + }) + }) + + describe('when trying to add elements which are older than already existing CTC elements', () => { + let timestamp + let blockNumber + describe('when the most recent CTC element is a sequencer transaction', () => { + beforeEach(async () => { + timestamp = await getEthTime(ethers.provider) + blockNumber = (await getNextBlockNumber(ethers.provider)) - 1 + await appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 1, + }) + }) + + it('reverts if timestamp is older than previous one', async () => { + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp: timestamp - 1, + blockNumber, + }, + ], + shouldStartAtElement: 1, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith( + 'Context timestamp is lower than last submitted.' + ) + }) + + it('reverts if block number is older than previous one', async () => { + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber: blockNumber - 1, + }, + ], + shouldStartAtElement: 1, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith( + 'Context block number is lower than last submitted.' + ) + }) + }) + + describe('when the previous transaction is a queue transaction', () => { + beforeEach(async () => { + // enqueue + timestamp = await getEthTime(ethers.provider) + blockNumber = await getNextBlockNumber(ethers.provider) + await OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data) + await appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 1, // final element will be CTC + timestamp, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 2, + }) + }) + + it('reverts if timestamp is older than previous one', async () => { + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp: timestamp - 1, + blockNumber, + }, + ], + shouldStartAtElement: 2, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith( + 'Context timestamp is lower than last submitted.' + ) + }) + + it('reverts if block number is older than previous one', async () => { + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber: blockNumber - 1, + }, + ], + shouldStartAtElement: 2, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith( + 'Context block number is lower than last submitted.' + ) + }) + }) + }) + + it('should revert if a queue element has expired and needs to be included', async () => { + // enqueue a tx + await OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data) + // increase time past force inclusion period + await increaseEthTime( + ethers.provider, + FORCE_INCLUSION_PERIOD_SECONDS * 2 + ) + + const blockNumber = (await ethers.provider.getBlockNumber()) - 1 + + const validTimestamp = (await getBlockTime(ethers.provider)) + 100 + + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions: ['0x1234'], + contexts: [ + { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 0, + timestamp: validTimestamp, + blockNumber, + }, + ], + shouldStartAtElement: 0, + totalElementsToAppend: 1, + }) + ).to.be.revertedWith( + 'Previously enqueued batches have expired and must be appended before a new sequencer batch.' + ) + }) + }) + + for (const size of ELEMENT_TEST_SIZES) { + const target = NON_ZERO_ADDRESS + const gasLimit = 500_000 + const data = '0x' + '12'.repeat(1234) + + describe(`Happy path: when appending ${size} sequencer transactions`, () => { + describe('when not inserting queue elements in between', () => { + describe('when using a single batch context', () => { + let contexts: any[] + let transactions: any[] + beforeEach(async () => { + const timestamp = (await getEthTime(ethers.provider)) - 100 + const blockNumber = + (await getNextBlockNumber(ethers.provider)) - 10 + + contexts = [ + { + numSequencedTransactions: size, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber, + }, + ] + + transactions = [...Array(size)].map((el, idx) => { + return '0x' + '12' + '34'.repeat(idx) + }) + }) + + it('should append the given number of transactions', async () => { + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions, + contexts, + shouldStartAtElement: 0, + totalElementsToAppend: size, + }) + ) + .to.emit( + OVM_CanonicalTransactionChain, + 'SequencerBatchAppended' + ) + .withArgs(0, 0, size) + }) + }) + }) + + describe('when inserting queue elements in between', () => { + beforeEach(async () => { + for (let i = 0; i < size; i++) { + await OVM_CanonicalTransactionChain.enqueue( + target, + gasLimit, + data + ) + } + }) + + describe('between every other sequencer transaction', () => { + let contexts: any[] + let transactions: any[] + beforeEach(async () => { + const timestamp = (await getEthTime(ethers.provider)) - 100 + const blockNumber = + (await getNextBlockNumber(ethers.provider)) - 50 + + contexts = [...Array(size)].map(() => { + return { + numSequencedTransactions: 1, + numSubsequentQueueTransactions: 1, + timestamp, + blockNumber: Math.max(blockNumber, 0), + } + }) + + transactions = [...Array(size)].map((el, idx) => { + return '0x' + '12' + '34'.repeat(idx) + }) + }) + + it('should append the batch', async () => { + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions, + contexts, + shouldStartAtElement: 0, + totalElementsToAppend: size * 2, + }) + ) + .to.emit( + OVM_CanonicalTransactionChain, + 'SequencerBatchAppended' + ) + .withArgs(0, size, size * 2) + }) + }) + + const spacing = Math.max(Math.floor(size / 4), 1) + describe(`between every ${spacing} sequencer transaction`, () => { + let contexts: any[] + let transactions: any[] + beforeEach(async () => { + const timestamp = (await getEthTime(ethers.provider)) - 100 + const blockNumber = + (await getNextBlockNumber(ethers.provider)) - 50 + + contexts = [...Array(spacing)].map(() => { + return { + numSequencedTransactions: size / spacing, + numSubsequentQueueTransactions: 1, + timestamp, + blockNumber: Math.max(blockNumber, 0), + } + }) + + transactions = [...Array(size)].map((el, idx) => { + return '0x' + '12' + '34'.repeat(idx) + }) + }) + + it('should append the batch', async () => { + await expect( + appendSequencerBatch(OVM_CanonicalTransactionChain, { + transactions, + contexts, + shouldStartAtElement: 0, + totalElementsToAppend: size + spacing, + }) + ) + .to.emit( + OVM_CanonicalTransactionChain, + 'SequencerBatchAppended' + ) + .withArgs(0, spacing, size + spacing) + }) + }) + }) + }) + } + }) + + describe('getTotalElements', () => { + it('should return zero when no elements exist', async () => { + expect(await OVM_CanonicalTransactionChain.getTotalElements()).to.equal(0) + }) + + for (const size of ELEMENT_TEST_SIZES) { + describe(`when the sequencer inserts a batch of ${size} elements`, () => { + beforeEach(async () => { + const timestamp = (await getEthTime(ethers.provider)) - 100 + const blockNumber = (await getNextBlockNumber(ethers.provider)) - 10 + + const contexts = [ + { + numSequencedTransactions: size, + numSubsequentQueueTransactions: 0, + timestamp, + blockNumber: Math.max(blockNumber, 0), + }, + ] + + const transactions = [...Array(size)].map((el, idx) => { + return '0x' + '12' + '34'.repeat(idx) + }) + + const res = await appendSequencerBatch( + OVM_CanonicalTransactionChain.connect(sequencer), + { + transactions, + contexts, + shouldStartAtElement: 0, + totalElementsToAppend: size, + } + ) + await res.wait() + }) + + it(`should return ${size}`, async () => { + expect( + await OVM_CanonicalTransactionChain.getTotalElements() + ).to.equal(size) + }) + }) + } + }) +}) diff --git a/packages/contracts/test/contracts/OVM/chain/OVM_StateCommitmentChain.spec.ts b/packages/contracts/test/contracts/OVM/chain/OVM_StateCommitmentChain.spec.ts new file mode 100644 index 000000000000..9f83711210c1 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/chain/OVM_StateCommitmentChain.spec.ts @@ -0,0 +1,372 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Signer, ContractFactory, Contract, constants } from 'ethers' +import { smockit, MockContract } from '@eth-optimism/smock' + +/* Internal Imports */ +import { + makeAddressManager, + setProxyTarget, + NON_NULL_BYTES32, + getEthTime, + increaseEthTime, +} from '../../../helpers' + +describe('OVM_StateCommitmentChain', () => { + let sequencer: Signer + let user: Signer + before(async () => { + ;[sequencer, user] = await ethers.getSigners() + }) + + let AddressManager: Contract + before(async () => { + AddressManager = await makeAddressManager() + }) + + let Mock__OVM_CanonicalTransactionChain: MockContract + let Mock__OVM_BondManager: MockContract + before(async () => { + Mock__OVM_CanonicalTransactionChain = await smockit( + await ethers.getContractFactory('OVM_CanonicalTransactionChain') + ) + + await setProxyTarget( + AddressManager, + 'OVM_CanonicalTransactionChain', + Mock__OVM_CanonicalTransactionChain + ) + + Mock__OVM_BondManager = await smockit( + await ethers.getContractFactory('OVM_BondManager') + ) + + await setProxyTarget( + AddressManager, + 'OVM_BondManager', + Mock__OVM_BondManager + ) + + Mock__OVM_BondManager.smocked.isCollateralized.will.return.with(true) + + await AddressManager.setAddress( + 'OVM_Proposer', + await sequencer.getAddress() + ) + }) + + let Factory__OVM_StateCommitmentChain: ContractFactory + let Factory__OVM_ChainStorageContainer: ContractFactory + before(async () => { + Factory__OVM_StateCommitmentChain = await ethers.getContractFactory( + 'OVM_StateCommitmentChain' + ) + + Factory__OVM_ChainStorageContainer = await ethers.getContractFactory( + 'OVM_ChainStorageContainer' + ) + }) + + let OVM_StateCommitmentChain: Contract + beforeEach(async () => { + OVM_StateCommitmentChain = await Factory__OVM_StateCommitmentChain.deploy( + AddressManager.address, + 60 * 60 * 24 * 7, // 1 week fraud proof window + 60 * 30 // 30 minute sequencer publish window + ) + + const batches = await Factory__OVM_ChainStorageContainer.deploy( + AddressManager.address, + 'OVM_StateCommitmentChain' + ) + + await AddressManager.setAddress( + 'OVM_ChainStorageContainer:SCC:batches', + batches.address + ) + + await AddressManager.setAddress( + 'OVM_StateCommitmentChain', + OVM_StateCommitmentChain.address + ) + }) + + describe('appendStateBatch', () => { + describe('when the provided batch is empty', () => { + const batch = [] + + it('should revert', async () => { + await expect( + OVM_StateCommitmentChain.appendStateBatch(batch, 0) + ).to.be.revertedWith('Cannot submit an empty state batch.') + }) + }) + + describe('when the provided batch is not empty', () => { + const batch = [NON_NULL_BYTES32] + + describe('when start index does not match total elements', () => { + it('should revert', async () => { + await expect( + OVM_StateCommitmentChain.appendStateBatch(batch, 1) + ).to.be.revertedWith( + 'Actual batch start index does not match expected start index.' + ) + }) + }) + + describe('when submitting more elements than present in the OVM_CanonicalTransactionChain', () => { + before(() => { + Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( + batch.length - 1 + ) + }) + + it('should revert', async () => { + await expect( + OVM_StateCommitmentChain.appendStateBatch(batch, 0) + ).to.be.revertedWith( + 'Number of state roots cannot exceed the number of canonical transactions.' + ) + }) + }) + + describe('when not submitting more elements than present in the OVM_CanonicalTransactionChain', () => { + before(() => { + Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( + batch.length + ) + }) + + it('should append the state batch', async () => { + await expect(OVM_StateCommitmentChain.appendStateBatch(batch, 0)).to + .not.be.reverted + }) + }) + + describe('when a sequencer submits ', () => { + beforeEach(async () => { + Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( + batch.length * 2 + ) + + await OVM_StateCommitmentChain.connect(sequencer).appendStateBatch( + batch, + 0 + ) + }) + + describe('when inside sequencer publish window', () => { + it('should revert', async () => { + await expect( + OVM_StateCommitmentChain.connect(user).appendStateBatch(batch, 1) + ).to.be.revertedWith( + 'Cannot publish state roots within the sequencer publication window.' + ) + }) + }) + + describe('when outside sequencer publish window', () => { + beforeEach(async () => { + const SEQUENCER_PUBLISH_WINDOW = await OVM_StateCommitmentChain.SEQUENCER_PUBLISH_WINDOW() + await increaseEthTime( + ethers.provider, + SEQUENCER_PUBLISH_WINDOW.toNumber() + 1 + ) + }) + + it('should succeed', async () => { + await expect( + OVM_StateCommitmentChain.connect(user).appendStateBatch(batch, 1) + ).to.not.be.reverted + }) + }) + }) + }) + }) + + describe('deleteStateBatch', () => { + const batch = [NON_NULL_BYTES32] + const batchHeader = { + batchIndex: 0, + batchRoot: NON_NULL_BYTES32, + batchSize: 1, + prevTotalElements: 0, + extraData: ethers.constants.HashZero, + } + + beforeEach(async () => { + Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( + batch.length + ) + await OVM_StateCommitmentChain.appendStateBatch(batch, 0) + batchHeader.extraData = ethers.utils.defaultAbiCoder.encode( + ['uint256', 'address'], + [await getEthTime(ethers.provider), await sequencer.getAddress()] + ) + }) + + describe('when the sender is not the OVM_FraudVerifier', () => { + before(async () => { + await AddressManager.setAddress( + 'OVM_FraudVerifier', + constants.AddressZero + ) + }) + + it('should revert', async () => { + await expect( + OVM_StateCommitmentChain.deleteStateBatch(batchHeader) + ).to.be.revertedWith( + 'State batches can only be deleted by the OVM_FraudVerifier.' + ) + }) + }) + + describe('when the sender is the OVM_FraudVerifier', () => { + before(async () => { + await AddressManager.setAddress( + 'OVM_FraudVerifier', + await sequencer.getAddress() + ) + }) + + describe('when the provided batch index is greater than the total submitted', () => { + it('should revert', async () => { + await expect( + OVM_StateCommitmentChain.deleteStateBatch({ + ...batchHeader, + batchIndex: 1, + }) + ).to.be.revertedWith('Index out of bounds.') + }) + }) + + describe('when the provided batch index is not greater than the total submitted', () => { + describe('when the provided batch header is invalid', () => { + it('should revert', async () => { + await expect( + OVM_StateCommitmentChain.deleteStateBatch({ + ...batchHeader, + extraData: '0x' + '22'.repeat(32), + }) + ).to.be.revertedWith('Invalid batch header.') + }) + }) + + describe('when the provided batch header is valid', () => { + it('should remove the batch and all following batches', async () => { + await expect(OVM_StateCommitmentChain.deleteStateBatch(batchHeader)) + .to.not.be.reverted + }) + }) + }) + }) + }) + + describe('getTotalElements', () => { + describe('when no batch elements have been inserted', () => { + it('should return zero', async () => { + expect(await OVM_StateCommitmentChain.getTotalElements()).to.equal(0) + }) + }) + + describe('when one batch element has been inserted', () => { + beforeEach(async () => { + const batch = [NON_NULL_BYTES32] + Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( + batch.length + ) + await OVM_StateCommitmentChain.appendStateBatch(batch, 0) + }) + + it('should return the number of inserted batch elements', async () => { + expect(await OVM_StateCommitmentChain.getTotalElements()).to.equal(1) + }) + }) + + describe('when 64 batch elements have been inserted in one batch', () => { + beforeEach(async () => { + const batch = Array(64).fill(NON_NULL_BYTES32) + Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( + batch.length + ) + await OVM_StateCommitmentChain.appendStateBatch(batch, 0) + }) + + it('should return the number of inserted batch elements', async () => { + expect(await OVM_StateCommitmentChain.getTotalElements()).to.equal(64) + }) + }) + + describe('when 32 batch elements have been inserted in each of two batches', () => { + beforeEach(async () => { + const batch = Array(32).fill(NON_NULL_BYTES32) + Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( + batch.length * 2 + ) + await OVM_StateCommitmentChain.appendStateBatch(batch, 0) + await OVM_StateCommitmentChain.appendStateBatch(batch, 32) + }) + + it('should return the number of inserted batch elements', async () => { + expect(await OVM_StateCommitmentChain.getTotalElements()).to.equal(64) + }) + }) + }) + + describe('getTotalBatches()', () => { + describe('when no batches have been inserted', () => { + it('should return zero', async () => { + expect(await OVM_StateCommitmentChain.getTotalBatches()).to.equal(0) + }) + }) + + describe('when one batch has been inserted', () => { + beforeEach(async () => { + const batch = [NON_NULL_BYTES32] + Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( + batch.length + ) + await OVM_StateCommitmentChain.appendStateBatch(batch, 0) + }) + + it('should return the number of inserted batch elements', async () => { + expect(await OVM_StateCommitmentChain.getTotalBatches()).to.equal(1) + }) + }) + + describe('when 8 batches have been inserted', () => { + beforeEach(async () => { + const batch = [NON_NULL_BYTES32] + Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( + batch.length * 8 + ) + + for (let i = 0; i < 8; i++) { + await OVM_StateCommitmentChain.appendStateBatch(batch, i) + } + }) + + it('should return the number of inserted batch elements', async () => { + expect(await OVM_StateCommitmentChain.getTotalBatches()).to.equal(8) + }) + }) + }) + + describe('verifyElement()', () => { + it('should revert when given an invalid batch header', async () => { + // TODO + }) + + it('should revert when given an invalid inclusion proof', async () => { + // TODO + }) + + it('should return true when given a valid proof', async () => { + // TODO + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager.gas-spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager.gas-spec.ts new file mode 100644 index 000000000000..af28dd7fd81b --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager.gas-spec.ts @@ -0,0 +1,121 @@ +import { expect } from '../../../setup' +import { deployContractCode } from '../../../helpers/utils' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Contract, ContractFactory, Signer } from 'ethers' +import { smockit, MockContract } from '@eth-optimism/smock' + +/* Internal Imports */ +import { + makeAddressManager, + NON_ZERO_ADDRESS, + NON_NULL_BYTES32, + GasMeasurement, +} from '../../../helpers' + +const DUMMY_GASMETERCONFIG = { + minTransactionGasLimit: 0, + maxTransactionGasLimit: NON_NULL_BYTES32, + maxGasPerQueuePerEpoch: NON_NULL_BYTES32, + secondsPerEpoch: NON_NULL_BYTES32, +} + +const DUMMY_GLOBALCONTEXT = { + ovmCHAINID: 420, +} + +const QUEUE_ORIGIN = { + SEQUENCER_QUEUE: 0, + L1TOL2_QUEUE: 1, +} + +const DUMMY_TRANSACTION = { + timestamp: 111111111111, + blockNumber: 20, + l1QueueOrigin: QUEUE_ORIGIN.SEQUENCER_QUEUE, + l1TxOrigin: NON_ZERO_ADDRESS, + entrypoint: NON_ZERO_ADDRESS, // update this below + gasLimit: 10_000_000, + data: 0, +} + +describe('OVM_ExecutionManager gas consumption', () => { + let wallet: Signer + before(async () => { + ;[wallet] = await ethers.getSigners() + }) + + let Factory__OVM_ExecutionManager: ContractFactory + let MOCK__STATE_MANAGER: MockContract + let AddressManager: Contract + let targetContractAddress: string + let gasMeasurement: GasMeasurement + before(async () => { + Factory__OVM_ExecutionManager = await ethers.getContractFactory( + 'OVM_ExecutionManager' + ) + + // Deploy a simple contract that just returns successfully with no data + targetContractAddress = await deployContractCode( + '60206001f3', + wallet, + 10_000_000 + ) + DUMMY_TRANSACTION.entrypoint = targetContractAddress + + AddressManager = await makeAddressManager() + + // deploy the state manager and mock it for the state transitioner + MOCK__STATE_MANAGER = await smockit( + await (await ethers.getContractFactory('OVM_StateManager')).deploy( + NON_ZERO_ADDRESS + ) + ) + + // Setup the SM to satisfy all the checks executed during EM.run() + MOCK__STATE_MANAGER.smocked.isAuthenticated.will.return.with(true) + MOCK__STATE_MANAGER.smocked.getAccountEthAddress.will.return.with( + targetContractAddress + ) + MOCK__STATE_MANAGER.smocked.hasAccount.will.return.with(true) + MOCK__STATE_MANAGER.smocked.testAndSetAccountLoaded.will.return.with(true) + + await AddressManager.setAddress( + 'OVM_StateManagerFactory', + MOCK__STATE_MANAGER.address + ) + + gasMeasurement = new GasMeasurement() + await gasMeasurement.init(wallet) + }) + + let OVM_ExecutionManager: Contract + beforeEach(async () => { + OVM_ExecutionManager = ( + await Factory__OVM_ExecutionManager.deploy( + AddressManager.address, + DUMMY_GASMETERCONFIG, + DUMMY_GLOBALCONTEXT + ) + ).connect(wallet) + }) + + describe('Measure cost of a very simple contract', async () => { + it('Gas cost of run', async () => { + const gasCost = await gasMeasurement.getGasCost( + OVM_ExecutionManager, + 'run', + [DUMMY_TRANSACTION, MOCK__STATE_MANAGER.address] + ) + console.log(`calculated gas cost of ${gasCost}`) + + const benchmark: number = 225_500 + expect(gasCost).to.be.lte(benchmark) + expect(gasCost).to.be.gte( + benchmark - 1_000, + 'Gas cost has significantly decreased, consider updating the benchmark to reflect the change' + ) + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/context-opcodes.spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/context-opcodes.spec.ts new file mode 100644 index 000000000000..bddcd4baa4de --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/context-opcodes.spec.ts @@ -0,0 +1,128 @@ +/* Internal Imports */ +import { + ExecutionManagerTestRunner, + TestDefinition, + NON_NULL_BYTES32, + OVM_TX_GAS_LIMIT, +} from '../../../../helpers' + +const globalContext = { + ovmCHAINID: 420, +} + +const transactionContext = { + ovmTIMESTAMP: 12341234, + ovmNUMBER: 13371337, + ovmGASLIMIT: 45674567, + ovmTXGASLIMIT: 78907890, + ovmL1QUEUEORIGIN: 1, + ovmL1TXORIGIN: '0x1234123412341234123412341234123412341234', +} + +const messageContext = { + ovmCALLER: '0x6789678967896789678967896789678967896789', + ovmADDRESS: '0x4567456745674567456745674567456745674567', +} + +const test_contextOpcodes: TestDefinition = { + name: 'unit tests for basic getter opcodes', + preState: { + ExecutionManager: { + ovmStateManager: '$OVM_STATE_MANAGER', + ovmSafetyChecker: '$OVM_SAFETY_CHECKER', + messageRecord: { + nuisanceGasLeft: OVM_TX_GAS_LIMIT, + }, + globalContext, + transactionContext, + messageContext, + }, + StateManager: { + owner: '$OVM_EXECUTION_MANAGER', + accounts: { + $DUMMY_OVM_ADDRESS_1: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + }, + }, + }, + parameters: [ + // TODO: re-enable when we can unwrap tests' ovmCALL + // { + // name: 'gets ovmCALLER', + // steps: [ + // { + // functionName: 'ovmCALLER', + // expectedReturnValue: messageContext.ovmCALLER + // } + // ], + // }, + // { + // name: 'gets ovmADDRESS', + // steps: [ + // { + // functionName: 'ovmADDRESS', + // expectedReturnValue: messageContext.ovmADDRESS + // } + // ], + // }, + { + name: 'gets ovmTIMESTAMP', + steps: [ + { + functionName: 'ovmTIMESTAMP', + expectedReturnValue: transactionContext.ovmTIMESTAMP, + }, + ], + }, + { + name: 'gets ovmNUMBER', + steps: [ + { + functionName: 'ovmNUMBER', + expectedReturnValue: transactionContext.ovmNUMBER, + }, + ], + }, + { + name: 'gets ovmGASLIMIT', + steps: [ + { + functionName: 'ovmGASLIMIT', + expectedReturnValue: transactionContext.ovmGASLIMIT, + }, + ], + }, + { + name: 'gets ovmL1QUEUEORIGIN', + steps: [ + { + functionName: 'ovmL1QUEUEORIGIN', + expectedReturnValue: transactionContext.ovmL1QUEUEORIGIN, + }, + ], + }, + { + name: 'gets ovmL1TXORIGIN', + steps: [ + { + functionName: 'ovmL1TXORIGIN', + expectedReturnValue: transactionContext.ovmL1TXORIGIN, + }, + ], + }, + { + name: 'gets ovmCHAINID', + steps: [ + { + functionName: 'ovmCHAINID', + expectedReturnValue: globalContext.ovmCHAINID, + }, + ], + }, + ], +} + +const runner = new ExecutionManagerTestRunner() +runner.run(test_contextOpcodes) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/nuisance-gas.spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/nuisance-gas.spec.ts new file mode 100644 index 000000000000..f630eb1d3249 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/nuisance-gas.spec.ts @@ -0,0 +1,229 @@ +/* Internal Imports */ +import { constants } from 'ethers' +import { + ExecutionManagerTestRunner, + TestDefinition, + OVM_TX_GAS_LIMIT, + NON_NULL_BYTES32, + VERIFIED_EMPTY_CONTRACT_HASH, + NUISANCE_GAS_COSTS, + Helper_TestRunner_BYTELEN, +} from '../../../../helpers' + +const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb' + +const FRESH_CALL_NUISANCE_GAS_COST = + Helper_TestRunner_BYTELEN * + NUISANCE_GAS_COSTS.NUISANCE_GAS_PER_CONTRACT_BYTE + + NUISANCE_GAS_COSTS.MIN_NUISANCE_GAS_PER_CONTRACT + +const test_nuisanceGas: TestDefinition = { + name: 'Basic tests for nuisance gas', + preState: { + ExecutionManager: { + ovmStateManager: '$OVM_STATE_MANAGER', + ovmSafetyChecker: '$OVM_SAFETY_CHECKER', + messageRecord: { + nuisanceGasLeft: OVM_TX_GAS_LIMIT, + }, + }, + StateManager: { + owner: '$OVM_EXECUTION_MANAGER', + accounts: { + $DUMMY_OVM_ADDRESS_1: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_2: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_3: { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + [CREATED_CONTRACT_1]: { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + }, + }, + }, + subTests: [ + { + name: + 'ovmCALL consumes nuisance gas of CODESIZE * NUISANCE_GAS_PER_CONTRACT_BYTE', + postState: { + ExecutionManager: { + messageRecord: { + nuisanceGasLeft: OVM_TX_GAS_LIMIT - FRESH_CALL_NUISANCE_GAS_COST, + }, + }, + }, + parameters: [ + { + name: 'single ovmCALL', + steps: [ + // do a non-nuisance-gas-consuming opcode (test runner auto-wraps in ovmCALL) + { + functionName: 'ovmADDRESS', + expectedReturnValue: '$DUMMY_OVM_ADDRESS_1', + }, + ], + }, + { + name: 'nested ovmCALL, same address', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [], + }, + expectedReturnStatus: true, + }, + ], + }, + ], + }, + { + name: + 'ovmCALL consumes nuisance gas of CODESIZE * NUISANCE_GAS_PER_CONTRACT_BYTE twice for two unique ovmCALLS', + postState: { + ExecutionManager: { + messageRecord: { + nuisanceGasLeft: + OVM_TX_GAS_LIMIT - 2 * FRESH_CALL_NUISANCE_GAS_COST, + }, + }, + }, + parameters: [ + { + name: 'directly nested ovmCALL', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: 'with a call to previously called contract too', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + ], + }, + { + name: + 'ovmCALL consumes all allotted nuisance gas if code contract throws unknown exception', + postState: { + ExecutionManager: { + messageRecord: { + nuisanceGasLeft: + OVM_TX_GAS_LIMIT - + FRESH_CALL_NUISANCE_GAS_COST - + OVM_TX_GAS_LIMIT / 2, + }, + }, + }, + parameters: [ + { + name: 'give 1/2 gas to evmINVALID', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'evmINVALID', + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: { + ovmSuccess: false, + returnData: '0x', + }, + }, + ], + }, + ], + }, + { + name: + 'ovmCREATE consumes all allotted nuisance gas if creation code throws data-less exception', + postState: { + ExecutionManager: { + messageRecord: { + // note: this is slightly higher than the "idealized" value which would be: + // OVM_TX_GAS_LIMIT / 2 - 2 * ( Helper_TestRunner_BYTELEN * NUISANCE_GAS_PER_CONTRACT_BYTE ) + // This is because there is natural gas consumption between the ovmCALL(GAS/2) and ovmCREATE, which allots nuisance gas via _getNuisanceGasLimit. + // This means that the ovmCREATE exception, DOES consumes all nuisance gas allotted, but that allotment + // is less than the full OVM_TX_GAS_LIMIT / 2 which is alloted to the parent ovmCALL. + nuisanceGasLeft: 4531286, + }, + }, + }, + parameters: [ + { + name: 'give 1/2 gas to ovmCALL => ovmCREATE, evmINVALID', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + target: '$DUMMY_OVM_ADDRESS_1', + gasLimit: OVM_TX_GAS_LIMIT / 2, + subSteps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'evmINVALID', + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: constants.AddressZero, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + ], + }, + ], +} + +const runner = new ExecutionManagerTestRunner() +runner.run(test_nuisanceGas) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmCALL.spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmCALL.spec.ts new file mode 100644 index 000000000000..6ff25e8148ab --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmCALL.spec.ts @@ -0,0 +1,268 @@ +/* Internal Imports */ +import { + ExecutionManagerTestRunner, + TestDefinition, + OVM_TX_GAS_LIMIT, + NON_NULL_BYTES32, + REVERT_FLAGS, + VERIFIED_EMPTY_CONTRACT_HASH, +} from '../../../../helpers' + +const DUMMY_REVERT_DATA = + '0xdeadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420' + +const DEAD_ADDRESS = '0xdeaddeaddeaddeaddeaddeaddeaddeaddead1234' + +const test_ovmCALL: TestDefinition = { + name: 'Basic tests for ovmCALL', + preState: { + ExecutionManager: { + ovmStateManager: '$OVM_STATE_MANAGER', + ovmSafetyChecker: '$OVM_SAFETY_CHECKER', + messageRecord: { + nuisanceGasLeft: OVM_TX_GAS_LIMIT, + }, + }, + StateManager: { + owner: '$OVM_EXECUTION_MANAGER', + accounts: { + $DUMMY_OVM_ADDRESS_1: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_2: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_3: { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + }, + verifiedContractStorage: { + $DUMMY_OVM_ADDRESS_1: { + [NON_NULL_BYTES32]: true, + }, + }, + }, + }, + parameters: [ + { + name: 'ovmCALL(ADDRESS_1) => ovmADDRESS', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmADDRESS', + expectedReturnValue: '$DUMMY_OVM_ADDRESS_1', + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: 'ovmCALL(ADDRESS_1) => ovmSSTORE', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmSSTORE', + functionParams: { + key: NON_NULL_BYTES32, + value: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: + 'ovmCALL(ADDRESS_1) => ovmSSTORE + ovmSLOAD, ovmCALL(ADDRESS_1) => ovmSLOAD', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmSSTORE', + functionParams: { + key: NON_NULL_BYTES32, + value: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + }, + { + functionName: 'ovmSLOAD', + functionParams: { + key: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + expectedReturnValue: NON_NULL_BYTES32, + }, + ], + }, + expectedReturnStatus: true, + }, + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmSLOAD', + functionParams: { + key: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + expectedReturnValue: NON_NULL_BYTES32, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: + 'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmADDRESS + ovmCALLER', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmADDRESS', + expectedReturnValue: '$DUMMY_OVM_ADDRESS_2', + }, + { + functionName: 'ovmCALLER', + expectedReturnValue: '$DUMMY_OVM_ADDRESS_1', + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: 'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_3)', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_3', + calldata: '0x', + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: '0x', + }, + ], + }, + { + name: 'ovmCALL(ADDRESS_1) => INTENTIONAL_REVERT', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'evmREVERT', + returnData: { + flag: REVERT_FLAGS.INTENTIONAL_REVERT, + data: DUMMY_REVERT_DATA, + }, + }, + ], + }, + expectedReturnStatus: false, + expectedReturnValue: DUMMY_REVERT_DATA, + }, + ], + }, + { + name: 'ovmCALL(ADDRESS_1) => EXCEEDS_NUISANCE_GAS', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'evmREVERT', + returnData: { + flag: REVERT_FLAGS.EXCEEDS_NUISANCE_GAS, + }, + }, + ], + }, + expectedReturnStatus: false, + expectedReturnValue: '0x', + }, + ], + }, + { + name: 'ovmCALL(0xdeaddeaddead...) returns (true, 0x)', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: DEAD_ADDRESS, + subSteps: [], + }, + expectedReturnStatus: true, + expectedReturnValue: { + ovmSuccess: true, + returnData: '0x', + }, + }, + ], + }, + ], +} + +const runner = new ExecutionManagerTestRunner() +runner.run(test_ovmCALL) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmCREATE.spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmCREATE.spec.ts new file mode 100644 index 000000000000..147fac7be9f0 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmCREATE.spec.ts @@ -0,0 +1,967 @@ +/* Internal Imports */ +import { constants, ethers } from 'ethers' +import { + ExecutionManagerTestRunner, + TestDefinition, + OVM_TX_GAS_LIMIT, + NON_NULL_BYTES32, + REVERT_FLAGS, + DUMMY_BYTECODE, + UNSAFE_BYTECODE, + VERIFIED_EMPTY_CONTRACT_HASH, + DUMMY_BYTECODE_BYTELEN, + DUMMY_BYTECODE_HASH, + getStorageXOR, + encodeSolidityError, +} from '../../../../helpers' + +const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb' +const CREATED_CONTRACT_2 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb' +const CREATED_CONTRACT_BY_2_1 = '0xe0d8be8101f36ebe6b01abacec884422c39a1f62' +const CREATED_CONTRACT_BY_2_2 = '0x15ac629e1a3866b17179ee4ae86de5cbda744335' +const NESTED_CREATED_CONTRACT = '0xcb964b3f4162a0d4f5c997b40e19da5a546bc36f' +const DUMMY_REVERT_DATA = + '0xdeadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420' + +const NON_WHITELISTED_DEPLOYER = '0x1234123412341234123412341234123412341234' +const NON_WHITELISTED_DEPLOYER_KEY = + '0x0000000000000000000000001234123412341234123412341234123412341234' +const CREATED_BY_NON_WHITELISTED_DEPLOYER = + '0x794e4aa3be128b0fc01ba12543b70bf9d77072fc' + +const WHITELISTED_DEPLOYER = '0x3456345634563456345634563456345634563456' +const WHITELISTED_DEPLOYER_KEY = + '0x0000000000000000000000003456345634563456345634563456345634563456' +const CREATED_BY_WHITELISTED_DEPLOYER = + '0x9f397a91ccb7cc924d1585f1053bc697d30f343f' + +const test_ovmCREATE: TestDefinition = { + name: 'Basic tests for ovmCREATE', + preState: { + ExecutionManager: { + ovmStateManager: '$OVM_STATE_MANAGER', + ovmSafetyChecker: '$OVM_SAFETY_CHECKER', + messageRecord: { + nuisanceGasLeft: OVM_TX_GAS_LIMIT, + }, + }, + StateManager: { + owner: '$OVM_EXECUTION_MANAGER', + accounts: { + $DUMMY_OVM_ADDRESS_1: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_2: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + [CREATED_CONTRACT_1]: { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + [CREATED_CONTRACT_2]: { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + [CREATED_CONTRACT_BY_2_1]: { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + [CREATED_CONTRACT_BY_2_2]: { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + [NESTED_CREATED_CONTRACT]: { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + }, + contractStorage: { + $DUMMY_OVM_ADDRESS_2: { + [ethers.constants.HashZero]: getStorageXOR(ethers.constants.HashZero), + [NON_NULL_BYTES32]: getStorageXOR(ethers.constants.HashZero), + }, + }, + verifiedContractStorage: { + $DUMMY_OVM_ADDRESS_1: { + [NON_NULL_BYTES32]: true, + }, + $DUMMY_OVM_ADDRESS_2: { + [ethers.constants.HashZero]: true, + [NON_NULL_BYTES32]: true, + }, + }, + }, + }, + parameters: [ + { + name: 'ovmCREATE, ovmEXTCODESIZE(CREATED)', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + bytecode: DUMMY_BYTECODE, + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_CONTRACT_1, + }, + { + functionName: 'ovmEXTCODESIZE', + functionParams: { + address: CREATED_CONTRACT_1, + }, + expectedReturnStatus: true, + expectedReturnValue: DUMMY_BYTECODE_BYTELEN, + }, + ], + }, + { + name: 'ovmCREATE, ovmEXTCODEHASH(CREATED)', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + bytecode: DUMMY_BYTECODE, + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_CONTRACT_1, + }, + { + functionName: 'ovmEXTCODEHASH', + functionParams: { + address: CREATED_CONTRACT_1, + }, + expectedReturnStatus: true, + expectedReturnValue: DUMMY_BYTECODE_HASH, + }, + ], + }, + { + name: 'ovmCREATE, ovmEXTCODECOPY(CREATED)', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + bytecode: DUMMY_BYTECODE, + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_CONTRACT_1, + }, + { + functionName: 'ovmEXTCODECOPY', + functionParams: { + address: CREATED_CONTRACT_1, + offset: 0, + length: DUMMY_BYTECODE_BYTELEN, + }, + expectedReturnStatus: true, + expectedReturnValue: DUMMY_BYTECODE, + }, + ], + }, + { + name: 'ovmCREATE => ovmREVERT', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmREVERT', + revertData: DUMMY_REVERT_DATA, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.INTENTIONAL_REVERT, + onlyValidateFlag: true, + }, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: { + address: constants.AddressZero, + revertData: DUMMY_REVERT_DATA, + }, + }, + ], + }, + { + name: 'ovmCREATE => ovmREVERT, ovmEXTCODESIZE(CREATED)', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmREVERT', + revertData: DUMMY_REVERT_DATA, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.INTENTIONAL_REVERT, + onlyValidateFlag: true, + }, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: { + address: constants.AddressZero, + revertData: DUMMY_REVERT_DATA, + }, + }, + { + functionName: 'ovmEXTCODESIZE', + functionParams: { + address: CREATED_CONTRACT_1, + }, + expectedReturnStatus: true, + expectedReturnValue: 0, + }, + ], + }, + { + name: 'ovmCREATE => ovmREVERT, ovmEXTCODEHASH(CREATED)', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmREVERT', + revertData: DUMMY_REVERT_DATA, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.INTENTIONAL_REVERT, + onlyValidateFlag: true, + }, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: { + address: constants.AddressZero, + revertData: DUMMY_REVERT_DATA, + }, + }, + { + functionName: 'ovmEXTCODEHASH', + functionParams: { + address: CREATED_CONTRACT_1, + }, + expectedReturnStatus: true, + expectedReturnValue: ethers.constants.HashZero, + }, + ], + }, + { + name: 'ovmCREATE => ovmREVERT, ovmEXTCODECOPY(CREATED)', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmREVERT', + revertData: DUMMY_REVERT_DATA, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.INTENTIONAL_REVERT, + onlyValidateFlag: true, + }, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: { + address: constants.AddressZero, + revertData: DUMMY_REVERT_DATA, + }, + }, + { + functionName: 'ovmEXTCODECOPY', + functionParams: { + address: CREATED_CONTRACT_1, + offset: 0, + length: 256, + }, + expectedReturnStatus: true, + expectedReturnValue: '0x' + '00'.repeat(256), + }, + ], + }, + { + name: 'ovmCREATE => ovmADDRESS', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmADDRESS', + expectedReturnValue: CREATED_CONTRACT_1, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_CONTRACT_1, + }, + ], + }, + { + name: 'ovmCREATE => ovmSLOAD', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmSLOAD', + functionParams: { + key: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + expectedReturnValue: ethers.constants.HashZero, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_CONTRACT_1, + }, + ], + }, + { + name: 'ovmCALL => ovmCREATE => ovmCALLER', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmSLOAD', + functionParams: { + key: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + expectedReturnValue: ethers.constants.HashZero, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_CONTRACT_2, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: 'ovmCREATE => ovmSSTORE + ovmSLOAD', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmSSTORE', + functionParams: { + key: NON_NULL_BYTES32, + value: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + }, + { + functionName: 'ovmSLOAD', + functionParams: { + key: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + expectedReturnValue: NON_NULL_BYTES32, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_CONTRACT_1, + }, + ], + }, + { + name: + 'ovmCREATE => ovmSSTORE, ovmCALL(CREATED) => ovmSLOAD(EXIST) + ovmSLOAD(NONEXIST)', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmSSTORE', + functionParams: { + key: NON_NULL_BYTES32, + value: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_CONTRACT_1, + }, + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: CREATED_CONTRACT_1, + subSteps: [ + { + functionName: 'ovmSLOAD', + functionParams: { + key: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + expectedReturnValue: NON_NULL_BYTES32, + }, + { + functionName: 'ovmSLOAD', + functionParams: { + key: ethers.constants.HashZero, + }, + expectedReturnStatus: true, + expectedReturnValue: ethers.constants.HashZero, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: + 'ovmCREATE => ovmCALL(ADDRESS_1) => ovmSSTORE, ovmCALL(ADDRESS_1) => ovmSLOAD', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmSSTORE', + functionParams: { + key: NON_NULL_BYTES32, + value: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_CONTRACT_1, + }, + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmSLOAD', + functionParams: { + key: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + expectedReturnValue: NON_NULL_BYTES32, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + // TODO: appears to be failing due to a smoddit issue + skip: true, + name: + 'ovmCREATE => (ovmCALL(ADDRESS_2) => ovmSSTORE) + ovmREVERT, ovmCALL(ADDRESS_2) => ovmSLOAD', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmSLOAD', + functionParams: { + key: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + expectedReturnValue: NON_NULL_BYTES32, + }, + { + functionName: 'ovmSSTORE', + functionParams: { + key: NON_NULL_BYTES32, + value: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + { + functionName: 'ovmREVERT', + revertData: DUMMY_REVERT_DATA, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.INTENTIONAL_REVERT, + onlyValidateFlag: true, + }, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: { + address: constants.AddressZero, + revertData: DUMMY_REVERT_DATA, + }, + }, + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmSLOAD', + functionParams: { + key: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + expectedReturnValue: NON_NULL_BYTES32, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: 'ovmCREATE => ovmCALL(ADDRESS_NONEXIST)', + expectInvalidStateAccess: true, + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_3', + calldata: '0x', + }, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.INVALID_STATE_ACCESS, + onlyValidateFlag: true, + }, + }, + ], + }, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.INVALID_STATE_ACCESS, + }, + }, + ], + }, + { + name: 'ovmCALL => ovmCREATE => ovmCREATE', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmCREATE', + functionParams: { + bytecode: '0x', // this will still succeed with empty bytecode + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_CONTRACT_BY_2_2, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_CONTRACT_BY_2_1, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: 'ovmCREATE => ovmCREATE => ovmCALL(ADDRESS_NONEXIST)', + expectInvalidStateAccess: true, + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_3', + calldata: '0x', + }, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.INVALID_STATE_ACCESS, + onlyValidateFlag: true, + }, + }, + ], + }, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.INVALID_STATE_ACCESS, + onlyValidateFlag: true, + }, + }, + ], + }, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.INVALID_STATE_ACCESS, + onlyValidateFlag: true, + }, + }, + ], + }, + { + name: 'OZ-AUDIT: ovmCREATE => ((ovmCREATE => ovmADDRESS), ovmREVERT)', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'ovmADDRESS', + expectedReturnValue: NESTED_CREATED_CONTRACT, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: NESTED_CREATED_CONTRACT, + }, + { + functionName: 'ovmREVERT', + revertData: DUMMY_REVERT_DATA, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.INTENTIONAL_REVERT, + onlyValidateFlag: true, + }, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: { + address: constants.AddressZero, + revertData: DUMMY_REVERT_DATA, + }, + }, + ], + }, + { + name: 'ovmCREATE => OUT_OF_GAS', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [ + { + functionName: 'evmINVALID', + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: constants.AddressZero, + }, + ], + }, + { + name: 'ovmCREATE(UNSAFE_CODE)', + steps: [ + { + functionName: 'ovmCREATE', + functionParams: { + bytecode: UNSAFE_BYTECODE, + }, + expectedReturnStatus: true, + expectedReturnValue: { + address: constants.AddressZero, + revertData: encodeSolidityError( + 'Constructor attempted to deploy unsafe bytecode.' + ), + }, + }, + ], + }, + ], + subTests: [ + { + name: 'Deployer whitelist tests', + preState: { + StateManager: { + accounts: { + [NON_WHITELISTED_DEPLOYER]: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + [WHITELISTED_DEPLOYER]: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + [CREATED_BY_WHITELISTED_DEPLOYER]: { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + }, + contractStorage: { + ['0x4200000000000000000000000000000000000002']: { + // initialized? true + '0x0000000000000000000000000000000000000000000000000000000000000010': getStorageXOR( + '0x' + '00'.repeat(31) + '01' + ), + // allowArbitraryDeployment? false + '0x0000000000000000000000000000000000000000000000000000000000000012': getStorageXOR( + ethers.constants.HashZero + ), + // non-whitelisted deployer is whitelisted? false + [NON_WHITELISTED_DEPLOYER_KEY]: getStorageXOR( + ethers.constants.HashZero + ), + // whitelisted deployer is whitelisted? true + [WHITELISTED_DEPLOYER_KEY]: getStorageXOR( + '0x' + '00'.repeat(31) + '01' + ), + }, + }, + verifiedContractStorage: { + ['0x4200000000000000000000000000000000000002']: { + '0x0000000000000000000000000000000000000000000000000000000000000010': 1, + '0x0000000000000000000000000000000000000000000000000000000000000012': 1, + [NON_WHITELISTED_DEPLOYER_KEY]: 1, + [WHITELISTED_DEPLOYER_KEY]: 1, + }, + }, + }, + }, + parameters: [ + { + name: 'ovmCREATE by WHITELISTED_DEPLOYER', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: WHITELISTED_DEPLOYER, + subSteps: [ + { + functionName: 'ovmCREATE', + functionParams: { + bytecode: DUMMY_BYTECODE, + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_BY_WHITELISTED_DEPLOYER, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: 'ovmCREATE by NON_WHITELISTED_DEPLOYER', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: NON_WHITELISTED_DEPLOYER, + subSteps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [], + }, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.CREATOR_NOT_ALLOWED, + onlyValidateFlag: true, + }, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: { + ovmSuccess: false, + returnData: '0x', + }, + }, + ], + }, + { + name: 'ovmCREATE2 by NON_WHITELISTED_DEPLOYER', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: NON_WHITELISTED_DEPLOYER, + subSteps: [ + { + functionName: 'ovmCREATE2', + functionParams: { + salt: ethers.constants.HashZero, + bytecode: '0x', + }, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.CREATOR_NOT_ALLOWED, + onlyValidateFlag: true, + }, + }, + ], + }, + expectedReturnStatus: true, + expectedReturnValue: { + ovmSuccess: false, + returnData: '0x', + }, + }, + ], + }, + ], + }, + { + name: 'Deployer whitelist tests', + preState: { + StateManager: { + accounts: { + [NON_WHITELISTED_DEPLOYER]: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + [WHITELISTED_DEPLOYER]: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + [CREATED_BY_NON_WHITELISTED_DEPLOYER]: { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + }, + contractStorage: { + ['0x4200000000000000000000000000000000000002']: { + // initialized? true + '0x0000000000000000000000000000000000000000000000000000000000000010': getStorageXOR( + '0x' + '00'.repeat(31) + '01' + ), + // allowArbitraryDeployment? true + '0x0000000000000000000000000000000000000000000000000000000000000012': getStorageXOR( + '0x' + '00'.repeat(31) + '01' + ), + // non-whitelisted deployer is whitelisted? false + [NON_WHITELISTED_DEPLOYER_KEY]: getStorageXOR( + ethers.constants.HashZero + ), + // whitelisted deployer is whitelisted? true + [WHITELISTED_DEPLOYER_KEY]: getStorageXOR( + '0x' + '00'.repeat(31) + '01' + ), + }, + }, + verifiedContractStorage: { + ['0x4200000000000000000000000000000000000002']: { + '0x0000000000000000000000000000000000000000000000000000000000000010': 1, + '0x0000000000000000000000000000000000000000000000000000000000000012': 1, + [NON_WHITELISTED_DEPLOYER_KEY]: 1, + [WHITELISTED_DEPLOYER_KEY]: 1, + }, + }, + }, + }, + subTests: [ + { + name: 'when arbitrary contract deployment is enabled', + parameters: [ + { + name: 'ovmCREATE by NON_WHITELISTED_DEPLOYER', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: NON_WHITELISTED_DEPLOYER, + subSteps: [ + { + functionName: 'ovmCREATE', + functionParams: { + subSteps: [], + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_BY_NON_WHITELISTED_DEPLOYER, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + ], + }, + ], + }, + ], +} + +const runner = new ExecutionManagerTestRunner() +runner.run(test_ovmCREATE) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmCREATEEOA.spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmCREATEEOA.spec.ts new file mode 100644 index 000000000000..665479e61867 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmCREATEEOA.spec.ts @@ -0,0 +1,135 @@ +/* External Imports */ +import { fromHexString } from '@eth-optimism/core-utils' + +/* Internal Imports */ +import { + ExecutionManagerTestRunner, + TestDefinition, + OVM_TX_GAS_LIMIT, + NON_NULL_BYTES32, + VERIFIED_EMPTY_CONTRACT_HASH, +} from '../../../../helpers' +import { getContractDefinition } from '../../../../../src' + +const test_ovmCREATEEOA: TestDefinition = { + name: 'Basic tests for CREATEEOA', + preState: { + ExecutionManager: { + ovmStateManager: '$OVM_STATE_MANAGER', + ovmSafetyChecker: '$OVM_SAFETY_CHECKER', + messageRecord: { + nuisanceGasLeft: OVM_TX_GAS_LIMIT, + }, + }, + StateManager: { + owner: '$OVM_EXECUTION_MANAGER', + accounts: { + $DUMMY_OVM_ADDRESS_1: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_2: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + '0x17ec8597ff92C3F44523bDc65BF0f1bE632917ff': { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + }, + verifiedContractStorage: { + $DUMMY_OVM_ADDRESS_1: { + [NON_NULL_BYTES32]: true, + }, + }, + }, + }, + parameters: [ + { + name: 'ovmCREATEEOA, ovmEXTCODESIZE(CREATED)', + steps: [ + { + functionName: 'ovmCREATEEOA', + functionParams: { + _messageHash: + '0x92d658d25f963af824e9d4bd533c165773d4a694a67d88135d119d5bca97c001', + _v: 1, + _r: + '0x73757c671fae2c3fb6825766c724b7715720bda4b309d3612f2c623364556967', + _s: + '0x2fc9b7222783390b9f10e22e92a52871beaff2613193d6e2dbf18d0e2d2eb8ff', + }, + expectedReturnStatus: true, + expectedReturnValue: undefined, + }, + { + functionName: 'ovmGETNONCE', + expectedReturnValue: 0, + }, + { + functionName: 'ovmEXTCODESIZE', + functionParams: { + address: '0x17ec8597ff92C3F44523bDc65BF0f1bE632917ff', + }, + expectedReturnStatus: true, + expectedReturnValue: fromHexString( + getContractDefinition('OVM_ProxyEOA').deployedBytecode + ).length, + }, + ], + }, + { + name: 'ovmCALL(ADDRESS_1) => ovmGETNONCE', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmGETNONCE', + expectedReturnValue: 0, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: 'ovmCALL(ADDRESS_1) => ovmINCREMENTNONCEx3 => ovmGETNONCE', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmINCREMENTNONCE', + expectedReturnStatus: true, + }, + { + functionName: 'ovmINCREMENTNONCE', + expectedReturnStatus: true, + }, + { + functionName: 'ovmINCREMENTNONCE', + expectedReturnStatus: true, + }, + { + functionName: 'ovmGETNONCE', + expectedReturnValue: 3, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + ], +} + +const runner = new ExecutionManagerTestRunner() +runner.run(test_ovmCREATEEOA) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmDELEGATECALL.spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmDELEGATECALL.spec.ts new file mode 100644 index 000000000000..a6d114c75373 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmDELEGATECALL.spec.ts @@ -0,0 +1,362 @@ +/* Internal Imports */ +import { + ExecutionManagerTestRunner, + TestDefinition, + OVM_TX_GAS_LIMIT, + NON_NULL_BYTES32, + DUMMY_BYTECODE, + VERIFIED_EMPTY_CONTRACT_HASH, +} from '../../../../helpers' + +const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb' +const CREATED_CONTRACT_2 = '0xe0d8be8101f36ebe6b01abacec884422c39a1f62' + +const test_ovmDELEGATECALL: TestDefinition = { + name: 'Basic tests for ovmDELEGATECALL', + preState: { + ExecutionManager: { + ovmStateManager: '$OVM_STATE_MANAGER', + ovmSafetyChecker: '$OVM_SAFETY_CHECKER', + messageRecord: { + nuisanceGasLeft: OVM_TX_GAS_LIMIT, + }, + }, + StateManager: { + owner: '$OVM_EXECUTION_MANAGER', + accounts: { + $DUMMY_OVM_ADDRESS_1: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_2: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_3: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_4: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + [CREATED_CONTRACT_1]: { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + [CREATED_CONTRACT_2]: { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + }, + verifiedContractStorage: { + $DUMMY_OVM_ADDRESS_1: { + [NON_NULL_BYTES32]: true, + }, + }, + }, + }, + parameters: [ + { + name: 'ovmCALL(ADDRESS_1) => ovmDELEGATECALL(ADDRESS_2) => ovmADDRESS', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmDELEGATECALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmADDRESS', + expectedReturnValue: '$DUMMY_OVM_ADDRESS_1', + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: + 'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmDELEGATECALL(ADDRESS_3) => ovmCALLER', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmDELEGATECALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmCALLER', + expectedReturnValue: '$DUMMY_OVM_ADDRESS_1', + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: + 'ovmCALL(ADDRESS_1) => (ovmDELEGATECALL(ADDRESS_2) => ovmSSTORE) + ovmSLOAD', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmDELEGATECALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmSSTORE', + functionParams: { + key: NON_NULL_BYTES32, + value: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + { + functionName: 'ovmSLOAD', + functionParams: { + key: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + expectedReturnValue: NON_NULL_BYTES32, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: 'ovmCALL(ADDRESS_1) => (ovmDELEGATECALL(ADDRESS_2) => ovmCREATE)', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmDELEGATECALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmCREATE', + functionParams: { + bytecode: DUMMY_BYTECODE, + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_CONTRACT_1, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: + 'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmDELEGATECALL(ADDRESS_3) => ovmDELEGATECALL(ADDRESS_4) => ovmCALLER', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmDELEGATECALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmDELEGATECALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_3', + subSteps: [ + { + functionName: 'ovmCALLER', + expectedReturnValue: '$DUMMY_OVM_ADDRESS_1', + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: + 'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmDELEGATECALL(ADDRESS_3) => ovmDELEGATECALL(ADDRESS_4) => ovmADDRESS', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmDELEGATECALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmDELEGATECALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_3', + subSteps: [ + { + functionName: 'ovmADDRESS', + expectedReturnValue: '$DUMMY_OVM_ADDRESS_2', + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: + 'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmDELEGATECALL(ADDRESS_3) => ovmDELEGATECALL(ADDRESS_4) => ovmCREATE', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmDELEGATECALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmDELEGATECALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_3', + subSteps: [ + { + functionName: 'ovmCREATE', + functionParams: { + bytecode: DUMMY_BYTECODE, + }, + expectedReturnStatus: true, + expectedReturnValue: CREATED_CONTRACT_2, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + ], +} + +const runner = new ExecutionManagerTestRunner() +runner.run(test_ovmDELEGATECALL) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmREVERT.spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmREVERT.spec.ts new file mode 100644 index 000000000000..fb5590c901b5 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmREVERT.spec.ts @@ -0,0 +1,101 @@ +/* Internal Imports */ +import { + ExecutionManagerTestRunner, + TestDefinition, + OVM_TX_GAS_LIMIT, + NON_NULL_BYTES32, + REVERT_FLAGS, +} from '../../../../helpers' + +const test_ovmREVERT: TestDefinition = { + name: 'Basic tests for ovmREVERT', + preState: { + ExecutionManager: { + ovmStateManager: '$OVM_STATE_MANAGER', + ovmSafetyChecker: '$OVM_SAFETY_CHECKER', + messageRecord: { + nuisanceGasLeft: OVM_TX_GAS_LIMIT, + }, + }, + StateManager: { + owner: '$OVM_EXECUTION_MANAGER', + accounts: { + $DUMMY_OVM_ADDRESS_1: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + }, + }, + }, + parameters: [ + { + name: 'ovmCALL => ovmREVERT', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmREVERT', + revertData: '0xdeadbeef', + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.INTENTIONAL_REVERT, + data: '0xdeadbeef', + nuisanceGasLeft: OVM_TX_GAS_LIMIT / 2, + ovmGasRefund: 0, + }, + }, + ], + }, + expectedReturnStatus: false, + expectedReturnValue: '0xdeadbeef', + }, + ], + }, + // TODO: fix this. only way to do it is manually set up and call ovmREVERT directly inside a context which mirrors that during creation. + // { + // name: "ovmREVERT inside ovmCREATE ?", + // parameters: [ + // { + // steps: [ + // { + // functionName: "ovmCALL", + // functionParams: [ + // GAS_LIMIT / 2, + // "$DUMMY_OVM_ADDRESS_1", + // [ + // { + // functionName: "ovmCREATE", + // functionParams: [ + // USELESS_BYTECODE, + // false, // "create will be successful?" + // [ + // { + // functionName: "ovmREVERT", + // functionParams: [ "0xdeadbeef" ], + // expectedReturnStatus: false, + // expectedReturnValues: [ "0x00" ] // no return values for reversion in constructor + // }, + // // TODO: check internally flagged storage here + // ] + // ], + // expectedReturnStatus: true, + // expectedReturnValues: [ CREATED_CONTRACT_1 ] + // } + // ], + // ], + // expectedReturnStatus: true, + // expectedReturnValues: [] + // } + // ] + // } + // ] + // } + ], +} + +const runner = new ExecutionManagerTestRunner() +runner.run(test_ovmREVERT) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmSLOAD.spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmSLOAD.spec.ts new file mode 100644 index 000000000000..cf93f2b38c27 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmSLOAD.spec.ts @@ -0,0 +1,75 @@ +/* External Imports */ +import { ethers } from 'ethers' + +/* Internal Imports */ +import { + ExecutionManagerTestRunner, + TestDefinition, + OVM_TX_GAS_LIMIT, + NON_NULL_BYTES32, + getStorageXOR, +} from '../../../../helpers' + +const test_ovmSLOAD: TestDefinition = { + name: 'Basic tests for ovmSLOAD', + preState: { + ExecutionManager: { + ovmStateManager: '$OVM_STATE_MANAGER', + ovmSafetyChecker: '$OVM_SAFETY_CHECKER', + messageRecord: { + nuisanceGasLeft: OVM_TX_GAS_LIMIT, + }, + }, + StateManager: { + owner: '$OVM_EXECUTION_MANAGER', + accounts: { + $DUMMY_OVM_ADDRESS_1: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_2: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + }, + contractStorage: { + $DUMMY_OVM_ADDRESS_1: { + [NON_NULL_BYTES32]: getStorageXOR(ethers.constants.HashZero), + }, + }, + verifiedContractStorage: { + $DUMMY_OVM_ADDRESS_1: { + [NON_NULL_BYTES32]: true, + }, + }, + }, + }, + parameters: [ + { + name: 'ovmCALL => ovmSLOAD', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmSLOAD', + functionParams: { + key: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + expectedReturnValue: ethers.constants.HashZero, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + ], +} + +const runner = new ExecutionManagerTestRunner() +runner.run(test_ovmSLOAD) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmSTATICCALL.spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmSTATICCALL.spec.ts new file mode 100644 index 000000000000..95ecff87efbf --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/ovmSTATICCALL.spec.ts @@ -0,0 +1,337 @@ +/* External Imports */ +import { ethers } from 'ethers' + +/* Internal Imports */ +import { + ExecutionManagerTestRunner, + TestDefinition, + OVM_TX_GAS_LIMIT, + NON_NULL_BYTES32, + REVERT_FLAGS, + DUMMY_BYTECODE, + getStorageXOR, +} from '../../../../helpers' + +const test_ovmSTATICCALL: TestDefinition = { + name: 'Basic tests for ovmSTATICCALL', + preState: { + ExecutionManager: { + ovmStateManager: '$OVM_STATE_MANAGER', + ovmSafetyChecker: '$OVM_SAFETY_CHECKER', + messageRecord: { + nuisanceGasLeft: OVM_TX_GAS_LIMIT, + }, + }, + StateManager: { + owner: '$OVM_EXECUTION_MANAGER', + accounts: { + $DUMMY_OVM_ADDRESS_1: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_2: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_3: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + }, + contractStorage: { + $DUMMY_OVM_ADDRESS_1: { + [NON_NULL_BYTES32]: getStorageXOR(ethers.constants.HashZero), + }, + $DUMMY_OVM_ADDRESS_3: { + [NON_NULL_BYTES32]: getStorageXOR(ethers.constants.HashZero), + }, + }, + verifiedContractStorage: { + $DUMMY_OVM_ADDRESS_1: { + [NON_NULL_BYTES32]: true, + }, + $DUMMY_OVM_ADDRESS_3: { + [NON_NULL_BYTES32]: true, + }, + }, + }, + }, + parameters: [ + { + name: 'ovmSTATICCALL => ovmSSTORE', + steps: [ + { + functionName: 'ovmSTATICCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmSSTORE', + functionParams: { + key: ethers.constants.HashZero, + value: ethers.constants.HashZero, + }, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.STATIC_VIOLATION, + nuisanceGasLeft: OVM_TX_GAS_LIMIT / 2, + }, + }, + ], + }, + expectedReturnStatus: false, + }, + ], + }, + { + name: 'ovmSTATICCALL => ovmSLOAD', + steps: [ + { + functionName: 'ovmSTATICCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmSLOAD', + functionParams: { + key: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + expectedReturnValue: ethers.constants.HashZero, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: 'ovmSTATICCALL => ovmCREATE', + steps: [ + { + functionName: 'ovmSTATICCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmCREATE', + functionParams: { + bytecode: DUMMY_BYTECODE, + }, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.STATIC_VIOLATION, + nuisanceGasLeft: OVM_TX_GAS_LIMIT / 2, + }, + }, + ], + }, + expectedReturnStatus: false, + }, + ], + }, + { + name: 'ovmCALL(ADDRESS_1) => ovmSTATICCALL(ADDRESS_2) => ovmCALLER', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmSTATICCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmCALLER', + expectedReturnValue: '$DUMMY_OVM_ADDRESS_1', + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: 'ovmCALL(ADDRESS_1) => ovmSTATICCALL(ADDRESS_2) => ovmADDRESS', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmSTATICCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmADDRESS', + expectedReturnValue: '$DUMMY_OVM_ADDRESS_2', + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: + 'ovmCALL(ADDRESS_1) => ovmSTATICCALL(ADDRESS_2) => ovmCALL(ADDRESS_3) => ovmSSTORE', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmSTATICCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_3', + subSteps: [ + { + functionName: 'ovmSSTORE', + functionParams: { + key: ethers.constants.HashZero, + value: ethers.constants.HashZero, + }, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.STATIC_VIOLATION, + nuisanceGasLeft: OVM_TX_GAS_LIMIT / 2, + }, + }, + ], + }, + expectedReturnStatus: false, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: + 'ovmCALL(ADDRESS_1) => ovmSTATICCALL(ADDRESS_2) => ovmCALL(ADDRESS_3) => ovmSLOAD', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmSTATICCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_3', + subSteps: [ + { + functionName: 'ovmSLOAD', + functionParams: { + key: NON_NULL_BYTES32, + }, + expectedReturnStatus: true, + expectedReturnValue: ethers.constants.HashZero, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + { + name: + 'ovmCALL(ADDRESS_1) => ovmSTATICCALL(ADDRESS_2) => ovmCALL(ADDRESS_3) => ovmCREATE', + steps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmSTATICCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_2', + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT / 2, + target: '$DUMMY_OVM_ADDRESS_3', + subSteps: [ + { + functionName: 'ovmCREATE', + functionParams: { + bytecode: DUMMY_BYTECODE, + }, + expectedReturnStatus: false, + expectedReturnValue: { + flag: REVERT_FLAGS.STATIC_VIOLATION, + nuisanceGasLeft: OVM_TX_GAS_LIMIT / 2, + }, + }, + ], + }, + expectedReturnStatus: false, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + ], +} + +const runner = new ExecutionManagerTestRunner() +runner.run(test_ovmSTATICCALL) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/run.spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/run.spec.ts new file mode 100644 index 000000000000..8bac0e096a1c --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/run.spec.ts @@ -0,0 +1,131 @@ +/* Internal Imports */ +import { constants } from 'ethers' +import { + ExecutionManagerTestRunner, + TestDefinition, + OVM_TX_GAS_LIMIT, + NON_NULL_BYTES32, + VERIFIED_EMPTY_CONTRACT_HASH, +} from '../../../../helpers' + +const GAS_METADATA_ADDRESS = '0x06a506a506a506a506a506a506a506a506a506a5' + +enum GasMetadataKey { + CURRENT_EPOCH_START_TIMESTAMP, + CUMULATIVE_SEQUENCER_QUEUE_GAS, + CUMULATIVE_L1TOL2_QUEUE_GAS, + PREV_EPOCH_SEQUENCER_QUEUE_GAS, + PREV_EPOCH_L1TOL2_QUEUE_GAS, +} + +const keyToBytes32 = (key: GasMetadataKey): string => { + return '0x' + `0${key}`.padStart(64, '0') +} + +const test_run: TestDefinition = { + name: 'Basic tests for ovmCALL', + preState: { + ExecutionManager: { + ovmStateManager: '$OVM_STATE_MANAGER', + ovmSafetyChecker: '$OVM_SAFETY_CHECKER', + messageRecord: { + nuisanceGasLeft: OVM_TX_GAS_LIMIT, + }, + }, + StateManager: { + owner: '$OVM_EXECUTION_MANAGER', + accounts: { + $DUMMY_OVM_ADDRESS_1: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_2: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_CALL_HELPER', + }, + $DUMMY_OVM_ADDRESS_3: { + codeHash: VERIFIED_EMPTY_CONTRACT_HASH, + ethAddress: '0x' + '00'.repeat(20), + }, + }, + contractStorage: { + [GAS_METADATA_ADDRESS]: { + [keyToBytes32(GasMetadataKey.CURRENT_EPOCH_START_TIMESTAMP)]: 1, + [keyToBytes32(GasMetadataKey.CUMULATIVE_SEQUENCER_QUEUE_GAS)]: 0, + [keyToBytes32(GasMetadataKey.CUMULATIVE_L1TOL2_QUEUE_GAS)]: 0, + [keyToBytes32(GasMetadataKey.PREV_EPOCH_SEQUENCER_QUEUE_GAS)]: 0, + [keyToBytes32(GasMetadataKey.PREV_EPOCH_L1TOL2_QUEUE_GAS)]: 0, + }, + }, + verifiedContractStorage: { + [GAS_METADATA_ADDRESS]: { + [keyToBytes32(GasMetadataKey.CURRENT_EPOCH_START_TIMESTAMP)]: true, + [keyToBytes32(GasMetadataKey.CUMULATIVE_SEQUENCER_QUEUE_GAS)]: true, + [keyToBytes32(GasMetadataKey.CUMULATIVE_L1TOL2_QUEUE_GAS)]: true, + [keyToBytes32(GasMetadataKey.PREV_EPOCH_SEQUENCER_QUEUE_GAS)]: true, + [keyToBytes32(GasMetadataKey.PREV_EPOCH_L1TOL2_QUEUE_GAS)]: true, + }, + }, + }, + }, + parameters: [ + { + name: 'run => ovmCALL(ADDRESS_1) => ovmADDRESS', + // TODO: Appears to be failing because of a bug in smock. + skip: true, + steps: [ + { + functionName: 'run', + functionParams: { + timestamp: 0, + queueOrigin: 0, + entrypoint: '$OVM_CALL_HELPER', + origin: constants.AddressZero, + msgSender: constants.AddressZero, + gasLimit: OVM_TX_GAS_LIMIT, + subSteps: [ + { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: '$DUMMY_OVM_ADDRESS_1', + subSteps: [ + { + functionName: 'ovmADDRESS', + expectedReturnValue: '$DUMMY_OVM_ADDRESS_1', + }, + ], + }, + expectedReturnStatus: true, + }, + ], + }, + }, + ], + }, + // This functionality has moved to the OVM_StateTransitioner, + // but leaving here for future reference on how to use this feature of the EM TestRunner. + // { + // name: 'run with insufficient gas supplied', + // steps: [ + // { + // functionName: 'run', + // suppliedGas: OVM_TX_GAS_LIMIT / 2, + // functionParams: { + // timestamp: 0, + // queueOrigin: 0, + // entrypoint: '$OVM_CALL_HELPER', + // origin: constants.AddressZero, + // msgSender: constants.AddressZero, + // gasLimit: OVM_TX_GAS_LIMIT, + // subSteps: [], + // }, + // expectedRevertValue: 'Not enough gas to execute deterministically', + // }, + // ], + // }, + ], +} + +const runner = new ExecutionManagerTestRunner() +runner.run(test_run) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_SafetyChecker.spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_SafetyChecker.spec.ts new file mode 100644 index 000000000000..b1d72059e0a5 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_SafetyChecker.spec.ts @@ -0,0 +1,30 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Contract } from 'ethers' + +/* Internal Imports */ +import { SAFETY_CHECKER_TEST_JSON } from '../../../data' + +describe('OVM_SafetyChecker', () => { + let OVM_SafetyChecker: Contract + before(async () => { + const Factory__OVM_SafetyChecker = await ethers.getContractFactory( + 'OVM_SafetyChecker' + ) + + OVM_SafetyChecker = await Factory__OVM_SafetyChecker.deploy() + }) + + describe('isBytecodeSafe()', () => { + for (const testName of Object.keys(SAFETY_CHECKER_TEST_JSON)) { + const test = SAFETY_CHECKER_TEST_JSON[testName] + it(`should correctly classify: ${testName}`, async () => { + expect(await OVM_SafetyChecker.isBytecodeSafe(test.in)).to.equal( + test.out + ) + }) + } + }) +}) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_StateManager.gas-spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_StateManager.gas-spec.ts new file mode 100644 index 000000000000..adc62e5f9193 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_StateManager.gas-spec.ts @@ -0,0 +1,441 @@ +import '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { constants, Contract, ContractFactory, Signer } from 'ethers' +import _ from 'lodash' + +/* Internal Imports */ +import { + DUMMY_ACCOUNTS, + DUMMY_BYTES32, + EMPTY_ACCOUNT_CODE_HASH, + NON_ZERO_ADDRESS, + NON_NULL_BYTES32, + STORAGE_XOR_VALUE, + GasMeasurement, +} from '../../../helpers' + +const DUMMY_ACCOUNT = DUMMY_ACCOUNTS[0] +const DUMMY_KEY = DUMMY_BYTES32[0] +const DUMMY_VALUE_1 = DUMMY_BYTES32[1] +const DUMMY_VALUE_2 = DUMMY_BYTES32[2] + +describe('OVM_StateManager gas consumption', () => { + let owner: Signer + before(async () => { + ;[owner] = await ethers.getSigners() + }) + + let Factory__OVM_StateManager: ContractFactory + let gasMeasurement: GasMeasurement + before(async () => { + Factory__OVM_StateManager = await ethers.getContractFactory( + 'OVM_StateManager' + ) + gasMeasurement = new GasMeasurement() + await gasMeasurement.init(owner) + }) + + let OVM_StateManager: Contract + beforeEach(async () => { + OVM_StateManager = ( + await Factory__OVM_StateManager.deploy(await owner.getAddress()) + ).connect(owner) + + await OVM_StateManager.setExecutionManager( + gasMeasurement.GasMeasurementContract.address + ) + }) + + const measure = ( + methodName: string, + methodArgs: Array = [], + doFirst: () => Promise = async () => { + return + } + ) => { + it('measured consumption!', async () => { + await doFirst() + const gasCost = await gasMeasurement.getGasCost( + OVM_StateManager, + methodName, + methodArgs + ) + console.log(` calculated gas cost of ${gasCost}`) + }) + } + + const setupFreshAccount = async () => { + await OVM_StateManager.putAccount(DUMMY_ACCOUNT.address, { + ...DUMMY_ACCOUNT.data, + isFresh: true, + }) + } + const setupNonFreshAccount = async () => { + await OVM_StateManager.putAccount(DUMMY_ACCOUNT.address, DUMMY_ACCOUNT.data) + } + const putSlot = async (value: string) => { + await OVM_StateManager.putContractStorage( + DUMMY_ACCOUNT.address, + DUMMY_KEY, + value + ) + } + + describe('ItemState testAndSetters', () => { + describe('testAndSetAccountLoaded', () => { + describe('when account ItemState is ITEM_UNTOUCHED', () => { + measure('testAndSetAccountLoaded', [NON_ZERO_ADDRESS]) + }) + describe('when account ItemState is ITEM_LOADED', () => { + measure('testAndSetAccountLoaded', [NON_ZERO_ADDRESS], async () => { + await OVM_StateManager.testAndSetAccountLoaded(NON_ZERO_ADDRESS) + }) + }) + describe('when account ItemState is ITEM_CHANGED', () => { + measure('testAndSetAccountLoaded', [NON_ZERO_ADDRESS], async () => { + await OVM_StateManager.testAndSetAccountChanged(NON_ZERO_ADDRESS) + }) + }) + }) + + describe('testAndSetAccountChanged', () => { + describe('when account ItemState is ITEM_UNTOUCHED', () => { + measure('testAndSetAccountChanged', [NON_ZERO_ADDRESS]) + }) + describe('when account ItemState is ITEM_LOADED', () => { + measure('testAndSetAccountChanged', [NON_ZERO_ADDRESS], async () => { + await OVM_StateManager.testAndSetAccountLoaded(NON_ZERO_ADDRESS) + }) + }) + describe('when account ItemState is ITEM_CHANGED', () => { + measure('testAndSetAccountChanged', [NON_ZERO_ADDRESS], async () => { + await OVM_StateManager.testAndSetAccountChanged(NON_ZERO_ADDRESS) + }) + }) + }) + + describe('testAndSetContractStorageLoaded', () => { + describe('when storage ItemState is ITEM_UNTOUCHED', () => { + measure('testAndSetContractStorageLoaded', [ + NON_ZERO_ADDRESS, + DUMMY_KEY, + ]) + }) + describe('when storage ItemState is ITEM_LOADED', () => { + measure( + 'testAndSetContractStorageLoaded', + [NON_ZERO_ADDRESS, DUMMY_KEY], + async () => { + await OVM_StateManager.testAndSetContractStorageLoaded( + NON_ZERO_ADDRESS, + DUMMY_KEY + ) + } + ) + }) + describe('when storage ItemState is ITEM_CHANGED', () => { + measure( + 'testAndSetContractStorageLoaded', + [NON_ZERO_ADDRESS, DUMMY_KEY], + async () => { + await OVM_StateManager.testAndSetContractStorageChanged( + NON_ZERO_ADDRESS, + DUMMY_KEY + ) + } + ) + }) + }) + + describe('testAndSetContractStorageChanged', () => { + describe('when storage ItemState is ITEM_UNTOUCHED', () => { + measure('testAndSetContractStorageChanged', [ + NON_ZERO_ADDRESS, + DUMMY_KEY, + ]) + }) + describe('when storage ItemState is ITEM_LOADED', () => { + measure( + 'testAndSetContractStorageChanged', + [NON_ZERO_ADDRESS, DUMMY_KEY], + async () => { + await OVM_StateManager.testAndSetContractStorageLoaded( + NON_ZERO_ADDRESS, + DUMMY_KEY + ) + } + ) + }) + describe('when storage ItemState is ITEM_CHANGED', () => { + measure( + 'testAndSetContractStorageChanged', + [NON_ZERO_ADDRESS, DUMMY_KEY], + async () => { + await OVM_StateManager.testAndSetContractStorageChanged( + NON_ZERO_ADDRESS, + DUMMY_KEY + ) + } + ) + }) + }) + }) + + describe('incrementTotalUncommittedAccounts', () => { + describe('when totalUncommittedAccounts is 0', () => { + measure('incrementTotalUncommittedAccounts') + }) + describe('when totalUncommittedAccounts is nonzero', () => { + const doFirst = async () => { + await OVM_StateManager.incrementTotalUncommittedAccounts() + } + measure('incrementTotalUncommittedAccounts', [], doFirst) + }) + }) + + describe('incrementTotalUncommittedContractStorage', () => { + describe('when totalUncommittedContractStorage is 0', () => { + measure('incrementTotalUncommittedContractStorage') + }) + describe('when totalUncommittedContractStorage is nonzero', () => { + const doFirst = async () => { + await OVM_StateManager.incrementTotalUncommittedContractStorage() + } + measure('incrementTotalUncommittedContractStorage', [], doFirst) + }) + }) + + describe('hasAccount', () => { + describe('when it does have the account', () => { + const doFirst = async () => { + await OVM_StateManager.putAccount( + DUMMY_ACCOUNT.address, + DUMMY_ACCOUNT.data + ) + } + measure('hasAccount', [DUMMY_ACCOUNT.address], doFirst) + }) + }) + + describe('hasEmptyAccount', () => { + describe('when it does have an empty account', () => { + measure('hasEmptyAccount', [DUMMY_ACCOUNT.address], async () => { + await OVM_StateManager.putAccount(DUMMY_ACCOUNT.address, { + ...DUMMY_ACCOUNT.data, + codeHash: EMPTY_ACCOUNT_CODE_HASH, + }) + }) + }) + describe('when it has an account which is not emtpy', () => { + measure('hasEmptyAccount', [DUMMY_ACCOUNT.address], async () => { + await OVM_StateManager.putAccount( + DUMMY_ACCOUNT.address, + DUMMY_ACCOUNT.data + ) + }) + }) + }) + + describe('setAccountNonce', () => { + describe('when the nonce is 0 and set to 0', () => { + measure('setAccountNonce', [DUMMY_ACCOUNT.address, 0], async () => { + await OVM_StateManager.putAccount(DUMMY_ACCOUNT.address, { + ...DUMMY_ACCOUNT.data, + nonce: 0, + }) + }) + }) + describe('when the nonce is 0 and set to nonzero', () => { + measure('setAccountNonce', [DUMMY_ACCOUNT.address, 1], async () => { + await OVM_StateManager.putAccount(DUMMY_ACCOUNT.address, { + ...DUMMY_ACCOUNT.data, + nonce: 0, + }) + }) + }) + describe('when the nonce is nonzero and set to 0', () => { + measure('setAccountNonce', [DUMMY_ACCOUNT.address, 0], async () => { + await OVM_StateManager.putAccount(DUMMY_ACCOUNT.address, { + ...DUMMY_ACCOUNT.data, + nonce: 1, + }) + }) + }) + describe('when the nonce is nonzero and set to nonzero', () => { + measure('setAccountNonce', [DUMMY_ACCOUNT.address, 2], async () => { + await OVM_StateManager.putAccount(DUMMY_ACCOUNT.address, { + ...DUMMY_ACCOUNT.data, + nonce: 1, + }) + }) + }) + }) + + describe('getAccountNonce', () => { + describe('when the nonce is 0', () => { + measure('getAccountNonce', [DUMMY_ACCOUNT.address]) + }) + describe('when the nonce is nonzero', () => { + measure('getAccountNonce', [DUMMY_ACCOUNT.address], async () => { + await OVM_StateManager.putAccount(DUMMY_ACCOUNT.address, { + ...DUMMY_ACCOUNT.data, + nonce: 1, + }) + }) + }) + }) + + describe('getAccountEthAddress', () => { + describe('when the ethAddress is a random address', () => { + measure('getAccountEthAddress', [DUMMY_ACCOUNT.address], async () => { + await OVM_StateManager.putAccount(DUMMY_ACCOUNT.address, { + ...DUMMY_ACCOUNT.data, + ethAddress: NON_ZERO_ADDRESS, + }) + }) + }) + describe('when the ethAddress is zero', () => { + measure('getAccountEthAddress', [DUMMY_ACCOUNT.address], async () => { + await OVM_StateManager.putAccount(DUMMY_ACCOUNT.address, { + ...DUMMY_ACCOUNT.data, + ethAddress: constants.AddressZero, + }) + }) + }) + }) + + describe('initPendingAccount', () => { + // note: this method should only be accessibl if _hasEmptyAccount is true, so it should always be empty nonce etc + measure('initPendingAccount', [NON_ZERO_ADDRESS]) + }) + + describe('commitPendingAccount', () => { + // this should only set ethAddress and codeHash from ZERO to NONZERO, so one case should be sufficient + measure( + 'commitPendingAccount', + [NON_ZERO_ADDRESS, NON_ZERO_ADDRESS, NON_NULL_BYTES32], + async () => { + await OVM_StateManager.initPendingAccount(NON_ZERO_ADDRESS) + } + ) + }) + + describe('getContractStorage', () => { + // confirm with kelvin that this covers all cases + describe('when the account isFresh', () => { + describe('when the storage slot value has not been set', () => { + measure( + 'getContractStorage', + [DUMMY_ACCOUNT.address, DUMMY_KEY], + setupFreshAccount + ) + }) + describe('when the storage slot has already been set', () => { + describe('when the storage slot value is STORAGE_XOR_VALUE', () => { + measure( + 'getContractStorage', + [DUMMY_ACCOUNT.address, DUMMY_KEY], + async () => { + await setupFreshAccount() + await putSlot(STORAGE_XOR_VALUE) + } + ) + }) + describe('when the storage slot value is something other than STORAGE_XOR_VALUE', () => { + measure( + 'getContractStorage', + [DUMMY_ACCOUNT.address, DUMMY_KEY], + async () => { + await setupFreshAccount() + await putSlot(DUMMY_VALUE_1) + } + ) + }) + }) + }) + describe('when the account is not fresh', () => { + describe('when the storage slot value is STORAGE_XOR_VALUE', () => { + measure( + 'getContractStorage', + [DUMMY_ACCOUNT.address, DUMMY_KEY], + async () => { + await setupNonFreshAccount() + await putSlot(STORAGE_XOR_VALUE) + } + ) + }) + describe('when the storage slot value is something other than STORAGE_XOR_VALUE', () => { + measure( + 'getContractStorage', + [DUMMY_ACCOUNT.address, DUMMY_KEY], + async () => { + await setupNonFreshAccount() + await putSlot(DUMMY_VALUE_1) + } + ) + }) + }) + }) + + describe('putContractStorage', () => { + const relevantValues = [DUMMY_VALUE_1, DUMMY_VALUE_2, STORAGE_XOR_VALUE] + for (const preValue of relevantValues) { + for (const postValue of relevantValues) { + describe(`when overwriting ${preValue} with ${postValue}`, () => { + measure( + 'putContractStorage', + [NON_ZERO_ADDRESS, DUMMY_KEY, postValue], + async () => { + await OVM_StateManager.putContractStorage( + NON_ZERO_ADDRESS, + DUMMY_KEY, + preValue + ) + } + ) + }) + } + } + }) + + describe('hasContractStorage', () => { + describe('when the account is fresh', () => { + describe('when the storage slot has not been set', () => { + measure( + 'hasContractStorage', + [DUMMY_ACCOUNT.address, DUMMY_KEY], + setupFreshAccount + ) + }) + describe('when the slot has already been set', () => { + measure( + 'hasContractStorage', + [DUMMY_ACCOUNT.address, DUMMY_KEY], + async () => { + await setupFreshAccount() + await OVM_StateManager.putContractStorage( + DUMMY_ACCOUNT.address, + DUMMY_KEY, + DUMMY_VALUE_1 + ) + } + ) + }) + }) + describe('when the account is not fresh', () => { + measure( + 'hasContractStorage', + [DUMMY_ACCOUNT.address, DUMMY_KEY], + async () => { + await OVM_StateManager.putContractStorage( + DUMMY_ACCOUNT.address, + DUMMY_KEY, + DUMMY_VALUE_1 + ) + } + ) + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/execution/OVM_StateManager.spec.ts b/packages/contracts/test/contracts/OVM/execution/OVM_StateManager.spec.ts new file mode 100644 index 000000000000..0ee681e3b00e --- /dev/null +++ b/packages/contracts/test/contracts/OVM/execution/OVM_StateManager.spec.ts @@ -0,0 +1,981 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Contract, ContractFactory, Signer, BigNumber, constants } from 'ethers' +import _ from 'lodash' + +/* Internal Imports */ +import { + DUMMY_ACCOUNTS, + DUMMY_BYTES32, + EMPTY_ACCOUNT_CODE_HASH, + KECCAK_256_NULL, +} from '../../../helpers' + +describe('OVM_StateManager', () => { + let signer1: Signer + let signer2: Signer + let signer3: Signer + before(async () => { + ;[signer1, signer2, signer3] = await ethers.getSigners() + }) + + let Factory__OVM_StateManager: ContractFactory + before(async () => { + Factory__OVM_StateManager = await ethers.getContractFactory( + 'OVM_StateManager' + ) + }) + + let OVM_StateManager: Contract + beforeEach(async () => { + OVM_StateManager = ( + await Factory__OVM_StateManager.deploy(await signer1.getAddress()) + ).connect(signer1) + }) + + describe('setExecutionManager', () => { + describe('when called by the current owner', () => { + beforeEach(async () => { + OVM_StateManager = OVM_StateManager.connect(signer1) + }) + + it('should change the current OVM_ExecutionManager', async () => { + await expect( + OVM_StateManager.connect(signer1).setExecutionManager( + await signer2.getAddress() + ) + ).to.not.be.reverted + + expect(await OVM_StateManager.ovmExecutionManager()).to.equal( + await signer2.getAddress() + ) + }) + }) + + describe('when called by the current OVM_ExecutionManager', () => { + beforeEach(async () => { + await OVM_StateManager.connect(signer1).setExecutionManager( + await signer2.getAddress() + ) + }) + + it('should change the current OVM_ExecutionManager', async () => { + await expect( + OVM_StateManager.connect(signer2).setExecutionManager( + await signer3.getAddress() + ) + ).to.not.be.reverted + + expect(await OVM_StateManager.ovmExecutionManager()).to.equal( + await signer3.getAddress() + ) + }) + }) + + describe('when called by any other account', () => { + beforeEach(async () => { + OVM_StateManager = OVM_StateManager.connect(signer1) + }) + + it('should revert', async () => { + await expect( + OVM_StateManager.connect(signer3).setExecutionManager( + await signer3.getAddress() + ) + ).to.be.revertedWith( + 'Function can only be called by authenticated addresses' + ) + }) + }) + }) + + describe('putAccount', () => { + it('should be able to store an OVM account', async () => { + await expect( + OVM_StateManager.putAccount( + DUMMY_ACCOUNTS[0].address, + DUMMY_ACCOUNTS[0].data + ) + ).to.not.be.reverted + }) + + it('should be able to overwrite an OVM account', async () => { + await OVM_StateManager.putAccount( + DUMMY_ACCOUNTS[0].address, + DUMMY_ACCOUNTS[0].data + ) + + await expect( + OVM_StateManager.putAccount( + DUMMY_ACCOUNTS[0].address, + DUMMY_ACCOUNTS[1].data + ) + ).to.not.be.reverted + }) + }) + + describe('getAccount', () => { + it('should be able to retrieve an OVM account', async () => { + await OVM_StateManager.putAccount( + DUMMY_ACCOUNTS[0].address, + DUMMY_ACCOUNTS[0].data + ) + + expect( + _.toPlainObject( + await OVM_StateManager.callStatic.getAccount( + DUMMY_ACCOUNTS[0].address + ) + ) + ).to.deep.include(DUMMY_ACCOUNTS[0].data) + }) + + it('should be able to retrieve an overwritten OVM account', async () => { + await OVM_StateManager.putAccount( + DUMMY_ACCOUNTS[0].address, + DUMMY_ACCOUNTS[0].data + ) + + await OVM_StateManager.putAccount( + DUMMY_ACCOUNTS[0].address, + DUMMY_ACCOUNTS[1].data + ) + + expect( + _.toPlainObject( + await OVM_StateManager.callStatic.getAccount( + DUMMY_ACCOUNTS[0].address + ) + ) + ).to.deep.include(DUMMY_ACCOUNTS[1].data) + }) + }) + + describe('hasAccount', () => { + describe('when the account exists', () => { + beforeEach(async () => { + await OVM_StateManager.putAccount( + DUMMY_ACCOUNTS[0].address, + DUMMY_ACCOUNTS[0].data + ) + }) + + it('should return true', async () => { + expect( + await OVM_StateManager.callStatic.hasAccount( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(true) + }) + }) + + describe('when the account does not exist', () => { + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.hasAccount( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(false) + }) + }) + }) + + describe('hasEmptyAccount', () => { + describe('when the account has the EMPTY_ACCOUNT_CODE_HASH', () => { + beforeEach(async () => { + await OVM_StateManager.putAccount(DUMMY_ACCOUNTS[0].address, { + ...DUMMY_ACCOUNTS[0].data, + nonce: 0, + codeHash: EMPTY_ACCOUNT_CODE_HASH, + }) + }) + + it('should return true', async () => { + expect( + await OVM_StateManager.callStatic.hasEmptyAccount( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(true) + }) + }) + + describe('when the account has a different non-zero codehash', () => { + beforeEach(async () => { + await OVM_StateManager.putAccount( + DUMMY_ACCOUNTS[0].address, + DUMMY_ACCOUNTS[0].data + ) + }) + + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.hasEmptyAccount( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(false) + }) + }) + + describe('when the account does not exist', () => { + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.hasEmptyAccount( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(false) + }) + }) + }) + + describe('setAccountNonce', () => { + it('should change the account nonce', async () => { + await expect( + OVM_StateManager.setAccountNonce(DUMMY_ACCOUNTS[0].address, 1234) + ).to.not.be.reverted + }) + }) + + describe('getAccountNonce', () => { + describe('when the account exists', () => { + beforeEach(async () => { + await OVM_StateManager.putAccount( + DUMMY_ACCOUNTS[0].address, + DUMMY_ACCOUNTS[0].data + ) + }) + + it('should return the current nonce', async () => { + expect( + await OVM_StateManager.callStatic.getAccountNonce( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(DUMMY_ACCOUNTS[0].data.nonce) + }) + + describe('when the nonce has been modified', () => { + beforeEach(async () => { + await OVM_StateManager.setAccountNonce( + DUMMY_ACCOUNTS[0].address, + 1234 + ) + }) + + it('should return the updated nonce', async () => { + expect( + await OVM_StateManager.callStatic.getAccountNonce( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(1234) + }) + }) + }) + + describe('when the account does not exist', () => { + it('should return zero', async () => { + expect( + await OVM_StateManager.callStatic.getAccountNonce( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(0) + }) + }) + }) + + describe('getAccountEthAddress', () => { + describe('when the account exists', () => { + beforeEach(async () => { + await OVM_StateManager.putAccount( + DUMMY_ACCOUNTS[0].address, + DUMMY_ACCOUNTS[0].data + ) + }) + + it('should return the account eth address', async () => { + expect( + await OVM_StateManager.getAccountEthAddress(DUMMY_ACCOUNTS[0].address) + ).to.equal(DUMMY_ACCOUNTS[0].data.ethAddress) + }) + }) + + describe('when the account does not exist', () => { + it('should return the zero address', async () => { + expect( + await OVM_StateManager.getAccountEthAddress(DUMMY_ACCOUNTS[0].address) + ).to.equal(constants.AddressZero) + }) + }) + }) + + describe('initPendingAccount', () => { + it('should set the initial account values', async () => { + await expect( + OVM_StateManager.initPendingAccount(DUMMY_ACCOUNTS[0].address) + ).to.not.be.reverted + + expect( + _.toPlainObject( + await OVM_StateManager.callStatic.getAccount( + DUMMY_ACCOUNTS[0].address + ) + ) + ).to.deep.include({ + nonce: BigNumber.from(1), + codeHash: KECCAK_256_NULL, + isFresh: true, + }) + }) + }) + + describe('commitPendingAccount', () => { + it('should set the remaining account values', async () => { + await expect( + OVM_StateManager.commitPendingAccount( + DUMMY_ACCOUNTS[0].address, + DUMMY_ACCOUNTS[0].data.ethAddress, + DUMMY_ACCOUNTS[0].data.codeHash + ) + ).to.not.be.reverted + + expect( + _.toPlainObject( + await OVM_StateManager.callStatic.getAccount( + DUMMY_ACCOUNTS[0].address + ) + ) + ).to.deep.include({ + ethAddress: DUMMY_ACCOUNTS[0].data.ethAddress, + codeHash: DUMMY_ACCOUNTS[0].data.codeHash, + }) + }) + }) + + describe('testAndSetAccountChanged', () => { + describe('when the account has not yet been changed', () => { + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.testAndSetAccountChanged( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(false) + }) + }) + + describe('when the account has been changed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetAccountChanged( + DUMMY_ACCOUNTS[0].address + ) + }) + + it('should return true', async () => { + expect( + await OVM_StateManager.callStatic.testAndSetAccountChanged( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(true) + }) + }) + }) + + describe('testAndSetAccountLoaded', () => { + describe('when the account has not yet been loaded', () => { + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.testAndSetAccountLoaded( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(false) + }) + }) + + describe('when the account has been loaded', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetAccountLoaded( + DUMMY_ACCOUNTS[0].address + ) + }) + + it('should return true', async () => { + expect( + await OVM_StateManager.callStatic.testAndSetAccountLoaded( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(true) + }) + }) + + describe('when the account has been changed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetAccountChanged( + DUMMY_ACCOUNTS[0].address + ) + }) + + it('should return true', async () => { + expect( + await OVM_StateManager.callStatic.testAndSetAccountLoaded( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(true) + }) + }) + }) + + describe('commitAccount', () => { + describe('when the account has not been touched', () => { + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.commitAccount( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(false) + }) + }) + + describe('when the account has been loaded but not changed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetAccountLoaded( + DUMMY_ACCOUNTS[0].address + ) + }) + + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.commitAccount( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(false) + }) + }) + + describe('when the account has been changed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetAccountChanged( + DUMMY_ACCOUNTS[0].address + ) + }) + + it('should return true', async () => { + expect( + await OVM_StateManager.callStatic.commitAccount( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(true) + }) + }) + + describe('when the account has already been committed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetAccountChanged( + DUMMY_ACCOUNTS[0].address + ) + await OVM_StateManager.commitAccount(DUMMY_ACCOUNTS[0].address) + }) + + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.commitAccount( + DUMMY_ACCOUNTS[0].address + ) + ).to.equal(false) + }) + }) + }) + + describe('incrementTotalUncommittedAccounts', () => { + it('should update the total uncommitted accounts', async () => { + await expect(OVM_StateManager.incrementTotalUncommittedAccounts()).to.not + .be.reverted + }) + }) + + describe('getTotalUncommittedAccounts', () => { + describe('when the total count has not been changed', () => { + it('should return zero', async () => { + expect( + await OVM_StateManager.callStatic.getTotalUncommittedAccounts() + ).to.equal(0) + }) + }) + + describe('when the count has been incremented', () => { + describe('one time', () => { + beforeEach(async () => { + await OVM_StateManager.incrementTotalUncommittedAccounts() + }) + + it('should return one', async () => { + expect( + await OVM_StateManager.callStatic.getTotalUncommittedAccounts() + ).to.equal(1) + }) + + describe('when an account has been committed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetAccountChanged( + DUMMY_ACCOUNTS[0].address + ) + await OVM_StateManager.commitAccount(DUMMY_ACCOUNTS[0].address) + }) + + it('should return zero', async () => { + expect( + await OVM_StateManager.callStatic.getTotalUncommittedAccounts() + ).to.equal(0) + }) + }) + }) + + describe('ten times', () => { + beforeEach(async () => { + for (let i = 0; i < 10; i++) { + await OVM_StateManager.incrementTotalUncommittedAccounts() + } + }) + + it('should return one', async () => { + expect( + await OVM_StateManager.callStatic.getTotalUncommittedAccounts() + ).to.equal(10) + }) + + describe('when an account has been committed', () => { + describe('one time', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetAccountChanged( + DUMMY_ACCOUNTS[0].address + ) + await OVM_StateManager.commitAccount(DUMMY_ACCOUNTS[0].address) + }) + + it('should return nine', async () => { + expect( + await OVM_StateManager.callStatic.getTotalUncommittedAccounts() + ).to.equal(9) + }) + }) + }) + }) + }) + }) + + describe('putContractStorage', () => { + it('should be able to insert a storage slot for a given contract', async () => { + await expect( + OVM_StateManager.putContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0], + DUMMY_BYTES32[1] + ) + ).to.not.be.reverted + }) + + it('should be able to overwrite a storage slot for a given contract', async () => { + await OVM_StateManager.putContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0], + DUMMY_BYTES32[1] + ) + + await expect( + OVM_StateManager.putContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0], + DUMMY_BYTES32[2] + ) + ).to.not.be.reverted + }) + }) + + describe('getContractStorage', () => { + it('should be able to retrieve a storage slot for a given contract', async () => { + await OVM_StateManager.putContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0], + DUMMY_BYTES32[1] + ) + + expect( + await OVM_StateManager.callStatic.getContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(DUMMY_BYTES32[1]) + }) + + it('should be able to retrieve an overwritten storage slot for a given contract', async () => { + await OVM_StateManager.putContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0], + DUMMY_BYTES32[1] + ) + + await OVM_StateManager.putContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0], + DUMMY_BYTES32[2] + ) + + expect( + await OVM_StateManager.callStatic.getContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(DUMMY_BYTES32[2]) + }) + }) + + describe('hasContractStorage', () => { + describe('when the storage slot has not been verified', () => { + it('should return false', async () => { + expect( + await OVM_StateManager.hasContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(false) + }) + }) + + describe('when the storage slot has been verified', () => { + beforeEach(async () => { + await OVM_StateManager.putContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0], + DUMMY_BYTES32[1] + ) + }) + + it('should return true', async () => { + expect( + await OVM_StateManager.hasContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(true) + }) + }) + + describe('when the account is newly created', () => { + beforeEach(async () => { + await OVM_StateManager.initPendingAccount(DUMMY_ACCOUNTS[0].address) + }) + + it('should return true for any slot', async () => { + for (const DUMMY_KEY of DUMMY_BYTES32) { + expect( + await OVM_StateManager.hasContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_KEY + ) + ).to.equal(true) + } + }) + }) + }) + + describe('testAndSetContractStorageChanged', () => { + describe('when the storage slot has not been touched', () => { + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.testAndSetContractStorageChanged( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(false) + }) + }) + + describe('when the storage slot has been loaded but not changed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetContractStorageLoaded( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + }) + + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.testAndSetContractStorageChanged( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(false) + }) + }) + + describe('when the storage slot has been changed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetContractStorageChanged( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + }) + + it('should return true', async () => { + expect( + await OVM_StateManager.callStatic.testAndSetContractStorageChanged( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(true) + }) + }) + + describe('when the storage slot has been committed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetContractStorageChanged( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + + await OVM_StateManager.commitContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + }) + + it('should return true', async () => { + expect( + await OVM_StateManager.callStatic.testAndSetContractStorageChanged( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(true) + }) + }) + }) + + describe('testAndSetContractStorageLoaded', () => { + describe('when the storage slot has not been touched', () => { + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.testAndSetContractStorageLoaded( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(false) + }) + }) + + describe('when the storage slot has already been loaded', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetContractStorageLoaded( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + }) + + it('should return true', async () => { + expect( + await OVM_StateManager.callStatic.testAndSetContractStorageLoaded( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(true) + }) + }) + + describe('when the storage slot has already been changed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetContractStorageChanged( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + }) + + it('should return true', async () => { + expect( + await OVM_StateManager.callStatic.testAndSetContractStorageLoaded( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(true) + }) + }) + + describe('when the storage slot has been committed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetContractStorageChanged( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + + await OVM_StateManager.commitContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + }) + + it('should return true', async () => { + expect( + await OVM_StateManager.callStatic.testAndSetContractStorageLoaded( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(true) + }) + }) + }) + + describe('commitContractStorage', () => { + describe('when the storage slot has not been touched', () => { + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.commitContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(false) + }) + }) + + describe('when the storage slot has been loaded', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetContractStorageLoaded( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + }) + + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.commitContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(false) + }) + }) + + describe('when the storage slot has been changed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetContractStorageChanged( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + }) + + it('should return true', async () => { + expect( + await OVM_StateManager.callStatic.commitContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(true) + }) + }) + + describe('when the storage slot has been committed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetContractStorageChanged( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + + await OVM_StateManager.commitContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + }) + + it('should return false', async () => { + expect( + await OVM_StateManager.callStatic.commitContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + ).to.equal(false) + }) + }) + }) + + describe('incrementTotalUncommittedContractStorage', () => { + it('should update the total uncommitted storage slots', async () => { + await expect(OVM_StateManager.incrementTotalUncommittedContractStorage()) + .to.not.be.reverted + }) + }) + + describe('getTotalUncommittedContractStorage', () => { + describe('when the total count has not been changed', () => { + it('should return zero', async () => { + expect( + await OVM_StateManager.callStatic.getTotalUncommittedContractStorage() + ).to.equal(0) + }) + }) + + describe('when the count has been incremented', () => { + describe('one time', () => { + beforeEach(async () => { + await OVM_StateManager.incrementTotalUncommittedContractStorage() + }) + + it('should return one', async () => { + expect( + await OVM_StateManager.callStatic.getTotalUncommittedContractStorage() + ).to.equal(1) + }) + + describe('when a storage slot has been committed', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetContractStorageChanged( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + + await OVM_StateManager.commitContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + }) + + it('should return zero', async () => { + expect( + await OVM_StateManager.callStatic.getTotalUncommittedContractStorage() + ).to.equal(0) + }) + }) + }) + + describe('ten times', () => { + beforeEach(async () => { + for (let i = 0; i < 10; i++) { + await OVM_StateManager.incrementTotalUncommittedContractStorage() + } + }) + + it('should return ten', async () => { + expect( + await OVM_StateManager.callStatic.getTotalUncommittedContractStorage() + ).to.equal(10) + }) + + describe('when a storage slot has been committed', () => { + describe('one time', () => { + beforeEach(async () => { + await OVM_StateManager.testAndSetContractStorageChanged( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + + await OVM_StateManager.commitContractStorage( + DUMMY_ACCOUNTS[0].address, + DUMMY_BYTES32[0] + ) + }) + + it('should return nine', async () => { + expect( + await OVM_StateManager.callStatic.getTotalUncommittedContractStorage() + ).to.equal(9) + }) + }) + }) + }) + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/precompiles/OVM_L1MessageSender.spec.ts b/packages/contracts/test/contracts/OVM/precompiles/OVM_L1MessageSender.spec.ts new file mode 100644 index 000000000000..dbecd901800b --- /dev/null +++ b/packages/contracts/test/contracts/OVM/precompiles/OVM_L1MessageSender.spec.ts @@ -0,0 +1,67 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { ContractFactory, Contract } from 'ethers' +import { MockContract, smockit } from '@eth-optimism/smock' +import { NON_ZERO_ADDRESS } from '../../../helpers/constants' + +const callPredeployStatic = async ( + Helper_PredeployCaller: Contract, + predeploy: Contract, + functionName: string, + functionParams?: any[] +): Promise => { + return Helper_PredeployCaller.callStatic[functionName]( + predeploy.address, + predeploy.interface.encodeFunctionData(functionName, functionParams || []) + ) +} + +describe('OVM_L1MessageSender', () => { + let Mock__OVM_ExecutionManager: MockContract + before(async () => { + Mock__OVM_ExecutionManager = await smockit( + await ethers.getContractFactory('OVM_ExecutionManager') + ) + }) + + let Helper_PredeployCaller: Contract + before(async () => { + Helper_PredeployCaller = await ( + await ethers.getContractFactory('Helper_PredeployCaller') + ).deploy() + + Helper_PredeployCaller.setTarget(Mock__OVM_ExecutionManager.address) + }) + + let Factory__OVM_L1MessageSender: ContractFactory + before(async () => { + Factory__OVM_L1MessageSender = await ethers.getContractFactory( + 'OVM_L1MessageSender' + ) + }) + + let OVM_L1MessageSender: Contract + beforeEach(async () => { + OVM_L1MessageSender = await Factory__OVM_L1MessageSender.deploy() + }) + + describe('getL1MessageSender', () => { + before(async () => { + Mock__OVM_ExecutionManager.smocked.ovmL1TXORIGIN.will.return.with( + NON_ZERO_ADDRESS + ) + }) + + it('should return the L1 message sender', async () => { + expect( + await callPredeployStatic( + Helper_PredeployCaller, + OVM_L1MessageSender, + 'getL1MessageSender' + ) + ).to.equal(NON_ZERO_ADDRESS) + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/precompiles/OVM_L2ToL1MessagePasser.spec.ts b/packages/contracts/test/contracts/OVM/precompiles/OVM_L2ToL1MessagePasser.spec.ts new file mode 100644 index 000000000000..38f50b4ce666 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/precompiles/OVM_L2ToL1MessagePasser.spec.ts @@ -0,0 +1,84 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { ContractFactory, Contract } from 'ethers' +import { MockContract, smockit } from '@eth-optimism/smock' +import { remove0x } from '@eth-optimism/core-utils' +import { keccak256 } from 'ethers/lib/utils' + +/* Internal Imports */ +import { NON_ZERO_ADDRESS } from '../../../helpers/constants' + +const ELEMENT_TEST_SIZES = [1, 2, 4, 8, 16] + +const callPredeploy = async ( + Helper_PredeployCaller: Contract, + predeploy: Contract, + functionName: string, + functionParams?: any[] +): Promise => { + return Helper_PredeployCaller.callPredeploy( + predeploy.address, + predeploy.interface.encodeFunctionData(functionName, functionParams || []) + ) +} + +describe('OVM_L2ToL1MessagePasser', () => { + let Mock__OVM_ExecutionManager: MockContract + before(async () => { + Mock__OVM_ExecutionManager = await smockit( + await ethers.getContractFactory('OVM_ExecutionManager') + ) + }) + + let Helper_PredeployCaller: Contract + before(async () => { + Helper_PredeployCaller = await ( + await ethers.getContractFactory('Helper_PredeployCaller') + ).deploy() + + Helper_PredeployCaller.setTarget(Mock__OVM_ExecutionManager.address) + }) + + let Factory__OVM_L2ToL1MessagePasser: ContractFactory + before(async () => { + Factory__OVM_L2ToL1MessagePasser = await ethers.getContractFactory( + 'OVM_L2ToL1MessagePasser' + ) + }) + + let OVM_L2ToL1MessagePasser: Contract + beforeEach(async () => { + OVM_L2ToL1MessagePasser = await Factory__OVM_L2ToL1MessagePasser.deploy() + }) + + describe('passMessageToL1', () => { + before(async () => { + Mock__OVM_ExecutionManager.smocked.ovmCALLER.will.return.with( + NON_ZERO_ADDRESS + ) + }) + + for (const size of ELEMENT_TEST_SIZES) { + it(`should be able to pass ${size} messages`, async () => { + for (let i = 0; i < size; i++) { + const message = '0x' + '12' + '34'.repeat(i) + + await callPredeploy( + Helper_PredeployCaller, + OVM_L2ToL1MessagePasser, + 'passMessageToL1', + [message] + ) + + expect( + await OVM_L2ToL1MessagePasser.sentMessages( + keccak256(message + remove0x(Helper_PredeployCaller.address)) + ) + ).to.equal(true) + } + }) + } + }) +}) diff --git a/packages/contracts/test/contracts/OVM/precompiles/OVM_ProxySequencerEntrypoint.spec.ts b/packages/contracts/test/contracts/OVM/precompiles/OVM_ProxySequencerEntrypoint.spec.ts new file mode 100644 index 000000000000..ec1e40fac373 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/precompiles/OVM_ProxySequencerEntrypoint.spec.ts @@ -0,0 +1,164 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers, waffle } from 'hardhat' +import { ContractFactory, Contract, Wallet, constants } from 'ethers' +import { MockContract, smockit } from '@eth-optimism/smock' +import { remove0x } from '@eth-optimism/core-utils' + +/* Internal Imports */ +import { decodeSolidityError } from '../../../helpers' + +const callPredeploy = async ( + Helper_PredeployCaller: Contract, + predeploy: Contract, + functionName: string, + functionParams?: any[] +): Promise => { + return Helper_PredeployCaller.callPredeploy( + predeploy.address, + predeploy.interface.encodeFunctionData(functionName, functionParams || []) + ) +} + +const addrToBytes32 = (addr: string) => + '0x' + '00'.repeat(12) + remove0x(addr.toLowerCase()) + +describe('OVM_ProxySequencerEntrypoint', () => { + let wallet: Wallet + before(async () => { + const provider = waffle.provider + ;[wallet] = provider.getWallets() + }) + + let Factory__OVM_ProxySequencerEntrypoint: ContractFactory + before(async () => { + Factory__OVM_ProxySequencerEntrypoint = await ethers.getContractFactory( + 'OVM_ProxySequencerEntrypoint' + ) + }) + + let Mock__OVM_ExecutionManager: MockContract + let Helper_PredeployCaller: Contract + let OVM_SequencerEntrypoint: Contract + before(async () => { + Mock__OVM_ExecutionManager = await smockit( + await ethers.getContractFactory('OVM_ExecutionManager') + ) + + Mock__OVM_ExecutionManager.smocked.ovmCALLER.will.return.with( + await wallet.getAddress() + ) + + Mock__OVM_ExecutionManager.smocked.ovmEXTCODESIZE.will.return.with(0) + Mock__OVM_ExecutionManager.smocked.ovmCHAINID.will.return.with(420) + + Helper_PredeployCaller = await ( + await ethers.getContractFactory('Helper_PredeployCaller') + ).deploy() + + Helper_PredeployCaller.setTarget(Mock__OVM_ExecutionManager.address) + + OVM_SequencerEntrypoint = await ( + await ethers.getContractFactory('OVM_SequencerEntrypoint') + ).deploy() + }) + + let OVM_ProxySequencerEntrypoint: Contract + beforeEach(async () => { + OVM_ProxySequencerEntrypoint = await Factory__OVM_ProxySequencerEntrypoint.deploy() + }) + it(`should init the proxy with owner and implementation`, async () => { + Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with( + `0x${'00'.repeat(32)}` + ) + await callPredeploy( + Helper_PredeployCaller, + OVM_ProxySequencerEntrypoint, + 'init', + [OVM_SequencerEntrypoint.address, await wallet.getAddress()] + ) + const ovmSSTOREs: any = Mock__OVM_ExecutionManager.smocked.ovmSSTORE.calls + + expect(ovmSSTOREs[0]._key).to.equal(`0x${'00'.repeat(31)}01`) + expect(ovmSSTOREs[0]._value).to.equal( + addrToBytes32(await wallet.getAddress()) + ) + + expect(ovmSSTOREs[1]._key).to.equal(`0x${'00'.repeat(32)}`) + expect(ovmSSTOREs[1]._value).to.equal( + addrToBytes32(OVM_SequencerEntrypoint.address) + ) + + // expect(await OVM_ProxySequencerEntrypoint.implementation()).to.equal( + // OVM_SequencerEntrypoint.address + // ) + }) + it(`should revert if proxy has already been inited`, async () => { + Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with( + addrToBytes32(await wallet.getAddress()) + ) + await callPredeploy( + Helper_PredeployCaller, + OVM_ProxySequencerEntrypoint, + 'init', + [constants.AddressZero, constants.AddressZero] + ) + + const ovmREVERT: any = Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0] + expect(decodeSolidityError(ovmREVERT._data)).to.equal( + 'ProxySequencerEntrypoint has already been inited' + ) + }) + + it(`should allow owner to upgrade Entrypoint`, async () => { + Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with( + addrToBytes32(await wallet.getAddress()) + ) + await callPredeploy( + Helper_PredeployCaller, + OVM_ProxySequencerEntrypoint, + 'upgrade', + [`0x${'12'.repeat(20)}`] + ) + + const ovmSSTORE: any = Mock__OVM_ExecutionManager.smocked.ovmSSTORE.calls[0] + expect(ovmSSTORE._key).to.equal(`0x${'00'.repeat(32)}`) + expect(ovmSSTORE._value).to.equal(addrToBytes32(`0x${'12'.repeat(20)}`)) + }) + + it(`should revert if non-owner tries to upgrade Entrypoint`, async () => { + Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with( + `0x${'00'.repeat(32)}` + ) + await callPredeploy( + Helper_PredeployCaller, + OVM_ProxySequencerEntrypoint, + 'upgrade', + [`0x${'12'.repeat(20)}`] + ) + const ovmREVERT: any = Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0] + expect(decodeSolidityError(ovmREVERT._data)).to.equal( + 'Only owner can upgrade the Entrypoint' + ) + }) + + it(`successfully calls ovmCREATEEOA through Entrypoint fallback`, async () => { + Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with( + addrToBytes32(OVM_SequencerEntrypoint.address) + ) + Mock__OVM_ExecutionManager.smocked.ovmDELEGATECALL.will.return.with([ + true, + '0x', + ]) + const calldata = '0xdeadbeef' + await Helper_PredeployCaller.callPredeploy( + OVM_ProxySequencerEntrypoint.address, + calldata + ) + const ovmDELEGATECALL: any = + Mock__OVM_ExecutionManager.smocked.ovmDELEGATECALL.calls[0] + expect(ovmDELEGATECALL._address).to.equal(OVM_SequencerEntrypoint.address) + expect(ovmDELEGATECALL._calldata).to.equal(calldata) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/precompiles/OVM_SequencerEntrypoint.spec.ts b/packages/contracts/test/contracts/OVM/precompiles/OVM_SequencerEntrypoint.spec.ts new file mode 100644 index 000000000000..2979ad3bc33e --- /dev/null +++ b/packages/contracts/test/contracts/OVM/precompiles/OVM_SequencerEntrypoint.spec.ts @@ -0,0 +1,182 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { waffle, ethers } from 'hardhat' +import { ContractFactory, Wallet, Contract } from 'ethers' +import { smockit, MockContract } from '@eth-optimism/smock' + +/* Internal Imports */ +import { getContractInterface } from '../../../../src' +import { + encodeSequencerCalldata, + signNativeTransaction, + signEthSignMessage, + DEFAULT_EIP155_TX, + serializeNativeTransaction, + serializeEthSignTransaction, +} from '../../../helpers' + +describe('OVM_SequencerEntrypoint', () => { + let wallet: Wallet + before(async () => { + const provider = waffle.provider + ;[wallet] = provider.getWallets() + }) + + let Mock__OVM_ExecutionManager: MockContract + let Helper_PredeployCaller: Contract + before(async () => { + Mock__OVM_ExecutionManager = await smockit( + await ethers.getContractFactory('OVM_ExecutionManager') + ) + + Mock__OVM_ExecutionManager.smocked.ovmCHAINID.will.return.with(420) + Mock__OVM_ExecutionManager.smocked.ovmCALL.will.return.with([true, '0x']) + + Helper_PredeployCaller = await ( + await ethers.getContractFactory('Helper_PredeployCaller') + ).deploy() + + Helper_PredeployCaller.setTarget(Mock__OVM_ExecutionManager.address) + }) + + let OVM_SequencerEntrypointFactory: ContractFactory + before(async () => { + OVM_SequencerEntrypointFactory = await ethers.getContractFactory( + 'OVM_SequencerEntrypoint' + ) + }) + + let OVM_SequencerEntrypoint: Contract + beforeEach(async () => { + OVM_SequencerEntrypoint = await OVM_SequencerEntrypointFactory.deploy() + Mock__OVM_ExecutionManager.smocked.ovmEXTCODESIZE.will.return.with(1) + Mock__OVM_ExecutionManager.smocked.ovmREVERT.will.revert() + }) + + describe('fallback()', async () => { + it('should call EIP155 if the transaction type is 0', async () => { + const calldata = await encodeSequencerCalldata( + wallet, + DEFAULT_EIP155_TX, + 0 + ) + await Helper_PredeployCaller.callPredeploy( + OVM_SequencerEntrypoint.address, + calldata + ) + + const encodedTx = serializeNativeTransaction(DEFAULT_EIP155_TX) + const sig = await signNativeTransaction(wallet, DEFAULT_EIP155_TX) + + const expectedEOACalldata = getContractInterface( + 'OVM_ECDSAContractAccount' + ).encodeFunctionData('execute', [ + encodedTx, + 0, //isEthSignedMessage + `0x${sig.v}`, //v + `0x${sig.r}`, //r + `0x${sig.s}`, //s + ]) + const ovmCALL: any = Mock__OVM_ExecutionManager.smocked.ovmCALL.calls[0] + expect(ovmCALL._address).to.equal(await wallet.getAddress()) + expect(ovmCALL._calldata).to.equal(expectedEOACalldata) + }) + + it('should send correct calldata if tx is a create and the transaction type is 0', async () => { + const createTx = { ...DEFAULT_EIP155_TX, to: '' } + const calldata = await encodeSequencerCalldata(wallet, createTx, 0) + await Helper_PredeployCaller.callPredeploy( + OVM_SequencerEntrypoint.address, + calldata + ) + + const encodedTx = serializeNativeTransaction(createTx) + const sig = await signNativeTransaction(wallet, createTx) + + const expectedEOACalldata = getContractInterface( + 'OVM_ECDSAContractAccount' + ).encodeFunctionData('execute', [ + encodedTx, + 0, //isEthSignedMessage + `0x${sig.v}`, //v + `0x${sig.r}`, //r + `0x${sig.s}`, //s + ]) + const ovmCALL: any = Mock__OVM_ExecutionManager.smocked.ovmCALL.calls[0] + expect(ovmCALL._address).to.equal(await wallet.getAddress()) + expect(ovmCALL._calldata).to.equal(expectedEOACalldata) + }) + + for (let i = 0; i < 3; i += 2) { + it(`should call ovmCreateEOA when tx type is ${i} and ovmEXTCODESIZE returns 0`, async () => { + Mock__OVM_ExecutionManager.smocked.ovmEXTCODESIZE.will.return.with(0) + const calldata = await encodeSequencerCalldata( + wallet, + DEFAULT_EIP155_TX, + i + ) + await Helper_PredeployCaller.callPredeploy( + OVM_SequencerEntrypoint.address, + calldata + ) + const call: any = + Mock__OVM_ExecutionManager.smocked.ovmCREATEEOA.calls[0] + const eoaAddress = ethers.utils.recoverAddress(call._messageHash, { + v: call._v + 27, + r: call._r, + s: call._s, + }) + expect(eoaAddress).to.equal(await wallet.getAddress()) + }) + } + + it('should submit ETHSignedTypedData if TransactionType is 2', async () => { + const calldata = await encodeSequencerCalldata( + wallet, + DEFAULT_EIP155_TX, + 2 + ) + await Helper_PredeployCaller.callPredeploy( + OVM_SequencerEntrypoint.address, + calldata + ) + + const encodedTx = serializeEthSignTransaction(DEFAULT_EIP155_TX) + const sig = await signEthSignMessage(wallet, DEFAULT_EIP155_TX) + + const expectedEOACalldata = getContractInterface( + 'OVM_ECDSAContractAccount' + ).encodeFunctionData('execute', [ + encodedTx, + 1, //isEthSignedMessage + `0x${sig.v}`, //v + `0x${sig.r}`, //r + `0x${sig.s}`, //s + ]) + const ovmCALL: any = Mock__OVM_ExecutionManager.smocked.ovmCALL.calls[0] + expect(ovmCALL._address).to.equal(await wallet.getAddress()) + expect(ovmCALL._calldata).to.equal(expectedEOACalldata) + }) + + it('should revert if TransactionType is >2', async () => { + const calldata = '0x03' + await expect( + Helper_PredeployCaller.callPredeploy( + OVM_SequencerEntrypoint.address, + calldata + ) + ).to.be.reverted + }) + + it('should revert if TransactionType is 1', async () => { + const calldata = '0x01' + await expect( + Helper_PredeployCaller.callPredeploy( + OVM_SequencerEntrypoint.address, + calldata + ) + ).to.be.reverted + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/verification/OVM_BondManager.spec.ts b/packages/contracts/test/contracts/OVM/verification/OVM_BondManager.spec.ts new file mode 100644 index 000000000000..3a9fd6b8916e --- /dev/null +++ b/packages/contracts/test/contracts/OVM/verification/OVM_BondManager.spec.ts @@ -0,0 +1,410 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { waffle, ethers as deployer } from 'hardhat' +import { smoddit, smockit } from '@eth-optimism/smock' +import { ethers, Contract, BigNumber } from 'ethers' + +/* Internal Imports */ +import { mineBlock } from '../../../helpers' + +describe('OVM_BondManager', () => { + const provider = waffle.provider + const wallets = provider.getWallets() + + let bondManager: Contract + let token: Contract + let manager: Contract + let fraudVerifier: Contract + + const publisher = wallets[0].address + const stateTransitioner = wallets[3] + const witnessProvider = wallets[4] + const witnessProvider2 = wallets[5] + + const sender = wallets[0].address + const txHash = ethers.constants.HashZero + + const ONE_WEEK = 3600 * 24 * 7 + + const preStateRoot = + '0x1111111111111111111111111111111111111111111111111111111111111111' + const amount = ethers.utils.parseEther('1') + const half = amount.div(2) + + beforeEach(async () => { + // deploy the address manager + manager = await ( + await deployer.getContractFactory('Lib_AddressManager') + ).deploy() + + // deploy the state manager and mock it for the state transitioner + const stateManagerFactory = await smockit( + await ( + await deployer.getContractFactory('OVM_StateManagerFactory') + ).deploy() + ) + stateManagerFactory.smocked.create.will.return.with( + ethers.constants.AddressZero + ) + await manager.setAddress( + 'OVM_StateManagerFactory', + stateManagerFactory.address + ) + + // deploy the fraud verifier and mock its pre-state root transitioner + fraudVerifier = await ( + await deployer.getContractFactory('Mock_FraudVerifier') + ).deploy() + await fraudVerifier.setStateTransitioner( + preStateRoot, + txHash, + stateTransitioner.address + ) + await manager.setAddress('OVM_FraudVerifier', fraudVerifier.address) + + // deploy a test erc20 token to be used for the bonds + token = await (await deployer.getContractFactory('TestERC20')).deploy() + await token.mint(sender, ethers.utils.parseEther('100')) + + bondManager = await (await smoddit('OVM_BondManager')).deploy( + token.address, + manager.address + ) + await manager.setAddress('OVM_BondManager', bondManager.address) + await fraudVerifier.setBondManager(bondManager.address) + }) + + describe('collateral management', () => { + let balanceBefore: BigNumber + + beforeEach(async () => { + await token.approve(bondManager.address, ethers.constants.MaxUint256) + balanceBefore = await token.balanceOf(sender) + await bondManager.deposit() + }) + + it('can deposit', async () => { + const balanceAfter = await token.balanceOf(sender) + expect(balanceAfter).to.be.eq(balanceBefore.sub(amount)) + const bond = await bondManager.bonds(sender) + expect(bond.state).to.eq(State.COLLATERALIZED) + expect(bond.withdrawalTimestamp).to.eq(0) + }) + + it('isCollateralized is true after depositing', async () => { + expect(await bondManager.isCollateralized(sender)).to.be.true + }) + + it('isCollateralized is false after starting a withdrawal', async () => { + await bondManager.startWithdrawal() + expect(await bondManager.isCollateralized(sender)).to.be.false + }) + + it('can start a withdrawal', async () => { + await bondManager.startWithdrawal() + const bond = await bondManager.bonds(sender) + expect(bond.state).to.eq(State.WITHDRAWING) + expect(bond.withdrawalTimestamp).to.not.eq(0) + }) + + it('can only withdraw after the dispute period', async () => { + await bondManager.startWithdrawal() + await expect(bondManager.finalizeWithdrawal()).to.be.revertedWith( + Errors.TOO_EARLY + ) + + const { withdrawalTimestamp } = await bondManager.bonds(sender) + const timestamp = withdrawalTimestamp + ONE_WEEK + await mineBlock(deployer.provider, timestamp) + + balanceBefore = await token.balanceOf(sender) + await bondManager.finalizeWithdrawal() + const bond = await bondManager.bonds(sender) + expect(bond.state).to.eq(State.NOT_COLLATERALIZED) + expect(bond.withdrawalTimestamp).to.eq(0) + expect(await token.balanceOf(sender)).to.eq(balanceBefore.add(amount)) + }) + + it('is not collateralized after withdrawing', async () => { + await bondManager.startWithdrawal() + const { withdrawalTimestamp } = await bondManager.bonds(sender) + const timestamp = withdrawalTimestamp + ONE_WEEK + await mineBlock(deployer.provider, timestamp) + await bondManager.finalizeWithdrawal() + expect(await bondManager.isCollateralized(sender)).to.be.false + }) + }) + + describe('dispute resolution', () => { + const user1Gas = [382100, 500000] + const user2Gas = 100000 + + const totalUser1Gas = user1Gas[0] + user1Gas[1] + const totalGas = totalUser1Gas + user2Gas + + beforeEach(async () => { + await bondManager + .connect(stateTransitioner) + .recordGasSpent( + preStateRoot, + txHash, + witnessProvider.address, + user1Gas[0] + ) + await bondManager + .connect(stateTransitioner) + .recordGasSpent( + preStateRoot, + txHash, + witnessProvider.address, + user1Gas[1] + ) + await bondManager + .connect(stateTransitioner) + .recordGasSpent( + preStateRoot, + txHash, + witnessProvider2.address, + user2Gas + ) + }) + + describe('post witnesses', () => { + it('can post witnesses from the transitioner for a state root', async () => { + const reward = await bondManager.witnessProviders(preStateRoot) + expect(reward.canClaim).to.be.false + expect(reward.total).to.be.equal(totalGas) + expect( + await bondManager.getGasSpent(preStateRoot, witnessProvider.address) + ).to.be.equal(totalUser1Gas) + expect( + await bondManager.getGasSpent(preStateRoot, witnessProvider2.address) + ).to.be.equal(user2Gas) + }) + + it('cannot post witnesses from non-transitioners for that state root', async () => { + await expect( + bondManager.recordGasSpent( + preStateRoot, + txHash, + witnessProvider.address, + 100 + ) + ).to.be.revertedWith(Errors.ONLY_TRANSITIONER) + }) + }) + + it('cannot claim before canClaim is set', async () => { + await expect(bondManager.claim(publisher)).to.be.revertedWith( + Errors.CANNOT_CLAIM + ) + }) + + describe('claims', () => { + let timestamp: number + // prepare by setting the claim flag and linking the publisher to the state root + beforeEach(async () => { + // deposit the collateral to be distributed + await token.approve(bondManager.address, ethers.constants.MaxUint256) + await bondManager.deposit() + + // smodify the canClaim value to true to test claiming + const block = await provider.getBlock('latest') + timestamp = block.timestamp + bondManager.smodify.set({ + witnessProviders: { + [preStateRoot]: { + canClaim: true, + }, + }, + bonds: { + [publisher]: { + earliestDisputedStateRoot: preStateRoot, + firstDisputeAt: timestamp, + }, + }, + }) + const reward = await bondManager.witnessProviders(preStateRoot) + expect(reward.canClaim).to.be.true + }) + + it('cannot claim before time for other disputes has passed', async () => { + await expect( + bondManager.connect(witnessProvider).claim(publisher) + ).to.be.revertedWith(Errors.WAIT_FOR_DISPUTES) + }) + + it('rewards get paid out proportionally', async () => { + await mineBlock(deployer.provider, timestamp + ONE_WEEK) + + // One will get 2/3rds of the bond, the other will get 1/3rd + const balanceBefore1 = await token.balanceOf(witnessProvider.address) + const balanceBefore2 = await token.balanceOf(witnessProvider2.address) + + await bondManager.connect(witnessProvider).claim(publisher) + await bondManager.connect(witnessProvider2).claim(publisher) + + const balanceAfter1 = await token.balanceOf(witnessProvider.address) + const balanceAfter2 = await token.balanceOf(witnessProvider2.address) + + expect(balanceAfter1).to.be.eq( + balanceBefore1.add(half.mul(totalUser1Gas).div(totalGas)) + ) + expect(balanceAfter2).to.be.eq( + balanceBefore2.add(half.mul(user2Gas).div(totalGas)) + ) + }) + + it('cannot double claim', async () => { + await mineBlock(deployer.provider, timestamp + ONE_WEEK) + const balance1 = await token.balanceOf(witnessProvider.address) + await bondManager.connect(witnessProvider).claim(publisher) + const balance2 = await token.balanceOf(witnessProvider.address) + expect(balance2).to.be.eq( + balance1.add(half.mul(totalUser1Gas).div(totalGas)) + ) + + // re-claiming does not give the user any extra funds + await bondManager.connect(witnessProvider).claim(publisher) + const balance3 = await token.balanceOf(witnessProvider.address) + expect(balance3).to.be.eq(balance2) + }) + }) + + describe('finalize', () => { + beforeEach(async () => { + await token.approve(bondManager.address, ethers.constants.MaxUint256) + await bondManager.deposit() + }) + + it('only fraud verifier can finalize', async () => { + await expect( + bondManager.finalize(preStateRoot, sender, 0) + ).to.be.revertedWith(Errors.ONLY_FRAUD_VERIFIER) + }) + + it('proving fraud allows claiming', async () => { + await fraudVerifier.finalize(preStateRoot, sender, 0) + + expect((await bondManager.witnessProviders(preStateRoot)).canClaim).to + .be.true + + // cannot double finalize + await expect( + fraudVerifier.finalize(preStateRoot, sender, 0) + ).to.be.revertedWith(Errors.ALREADY_FINALIZED) + }) + + it("proving fraud cancels pending withdrawals if the withdrawal was during the batch's proving window", async () => { + await bondManager.startWithdrawal() + const { withdrawalTimestamp } = await bondManager.bonds(sender) + const timestamp = withdrawalTimestamp + ONE_WEEK + + // a dispute is created about a block that intersects + const disputeTimestamp = withdrawalTimestamp - 100 + await fraudVerifier.finalize(preStateRoot, sender, disputeTimestamp) + + await mineBlock(deployer.provider, timestamp) + await expect(bondManager.finalizeWithdrawal()).to.be.revertedWith( + Errors.SLASHED + ) + }) + + it('proving fraud late does not cancel pending withdrawals', async () => { + await bondManager.startWithdrawal() + const { withdrawalTimestamp } = await bondManager.bonds(sender) + + // a dispute is created, but since the fraud period is already over + // it doesn't matter + const disputeTimestamp = withdrawalTimestamp - ONE_WEEK - 1 + await fraudVerifier.finalize(preStateRoot, sender, disputeTimestamp) + + const finalizeWithdrawalTimestamp = withdrawalTimestamp + ONE_WEEK + await mineBlock(deployer.provider, finalizeWithdrawalTimestamp) + await bondManager.finalizeWithdrawal() + }) + + it('proving fraud prevents starting a withdrawal due to slashing', async () => { + await fraudVerifier.finalize(preStateRoot, sender, 0) + await expect(bondManager.startWithdrawal()).to.be.revertedWith( + Errors.WRONG_STATE + ) + }) + + describe('same publisher commits fraud multiple times', async () => { + let timestamp: number + const root1 = + '0x0000000000000000000000000000000000000000000000000000000000000000' + const ts1 = 100 + const root2 = + '0x0000000000000000000000000000000000000000000000000000000000000001' + const ts2 = 110 + + beforeEach(async () => { + await fraudVerifier.finalize(root2, sender, ts2) + const block = await provider.getBlock('latest') + timestamp = block.timestamp + }) + + it('initial dispute data is stored', async () => { + const bond = await bondManager.bonds(sender) + expect(bond.firstDisputeAt).to.be.equal(timestamp) + expect(bond.earliestTimestamp).to.be.equal(ts2) + expect(bond.earliestDisputedStateRoot).to.be.equal(root2) + }) + + it('earlier dispute replaces initial data', async () => { + await fraudVerifier.finalize(root1, sender, ts1) + const bond = await bondManager.bonds(sender) + expect(bond.firstDisputeAt).to.be.equal(timestamp) + expect(bond.earliestTimestamp).to.be.equal(ts1) + expect(bond.earliestDisputedStateRoot).to.be.equal(root1) + }) + + it('earlier dispute does not replace initial data if not in time', async () => { + await mineBlock(deployer.provider, timestamp + ONE_WEEK) + await fraudVerifier.finalize(root1, sender, ts1) + const bond = await bondManager.bonds(sender) + expect(bond.firstDisputeAt).to.be.equal(timestamp) + expect(bond.earliestTimestamp).to.be.equal(ts2) + expect(bond.earliestDisputedStateRoot).to.be.equal(root2) + }) + + it('later dispute does not replace initial data', async () => { + await fraudVerifier.finalize(root1, sender, ts2 + 1) + const bond = await bondManager.bonds(sender) + expect(bond.firstDisputeAt).to.be.equal(timestamp) + expect(bond.earliestTimestamp).to.be.equal(ts2) + expect(bond.earliestDisputedStateRoot).to.be.equal(root2) + }) + }) + }) + }) +}) + +enum State { + // Before depositing or after getting slashed, a user is uncollateralized + NOT_COLLATERALIZED, + // After depositing, a user is collateralized + COLLATERALIZED, + // After a user has initiated a withdrawal + WITHDRAWING, +} + +// Errors from the bond manager smart contract +enum Errors { + ERC20_ERR = 'BondManager: Could not post bond', + ALREADY_FINALIZED = 'BondManager: Fraud proof for this pre-state root has already been finalized', + SLASHED = 'BondManager: Cannot finalize withdrawal, you probably got slashed', + WRONG_STATE = 'BondManager: Wrong bond state for proposer', + CANNOT_CLAIM = 'BondManager: Cannot claim yet. Dispute must be finalized first', + + WITHDRAWAL_PENDING = 'BondManager: Withdrawal already pending', + TOO_EARLY = 'BondManager: Too early to finalize your withdrawal', + + ONLY_TRANSITIONER = 'BondManager: Only the transitioner for this pre-state root may call this function', + ONLY_FRAUD_VERIFIER = 'BondManager: Only the fraud verifier may call this function', + ONLY_STATE_COMMITMENT_CHAIN = 'BondManager: Only the state commitment chain may call this function', + WAIT_FOR_DISPUTES = 'BondManager: Wait for other potential disputes', +} diff --git a/packages/contracts/test/contracts/OVM/verification/OVM_FraudVerifier.spec.ts b/packages/contracts/test/contracts/OVM/verification/OVM_FraudVerifier.spec.ts new file mode 100644 index 000000000000..6dbe93151877 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/verification/OVM_FraudVerifier.spec.ts @@ -0,0 +1,575 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { ContractFactory, Contract, BigNumber } from 'ethers' +import { smockit, MockContract } from '@eth-optimism/smock' + +/* Internal Imports */ +import { + makeAddressManager, + setProxyTarget, + DUMMY_BATCH_HEADERS, + DUMMY_BATCH_PROOFS, + DUMMY_OVM_TRANSACTIONS, + NON_NULL_BYTES32, + hashTransaction, +} from '../../../helpers' + +const DUMMY_TX_CHAIN_ELEMENTS = [...Array(10).keys()].map((i) => { + return { + isSequenced: false, + queueIndex: BigNumber.from(0), + timestamp: BigNumber.from(i), + blockNumber: BigNumber.from(0), + txData: ethers.constants.HashZero, + } +}) + +const DUMMY_HASH = hashTransaction(DUMMY_OVM_TRANSACTIONS[0]) + +const DUMMY_BATCH_PROOFS_WITH_INDEX = [ + { + index: 11, + siblings: [ethers.constants.HashZero], + }, +] + +describe('OVM_FraudVerifier', () => { + let AddressManager: Contract + before(async () => { + AddressManager = await makeAddressManager() + }) + + let Mock__OVM_StateCommitmentChain: MockContract + let Mock__OVM_CanonicalTransactionChain: MockContract + let Mock__OVM_StateTransitioner: MockContract + let Mock__OVM_StateTransitionerFactory: MockContract + let Mock__OVM_BondManager: MockContract + before(async () => { + Mock__OVM_StateCommitmentChain = await smockit( + await ethers.getContractFactory('OVM_StateCommitmentChain') + ) + + Mock__OVM_CanonicalTransactionChain = await smockit( + await ethers.getContractFactory('OVM_CanonicalTransactionChain') + ) + + Mock__OVM_StateTransitioner = await smockit( + await ethers.getContractFactory('OVM_StateTransitioner') + ) + + Mock__OVM_StateTransitionerFactory = await smockit( + await ethers.getContractFactory('OVM_StateTransitionerFactory') + ) + + Mock__OVM_BondManager = await smockit( + await ethers.getContractFactory('OVM_BondManager') + ) + + await setProxyTarget( + AddressManager, + 'OVM_StateCommitmentChain', + Mock__OVM_StateCommitmentChain + ) + + await setProxyTarget( + AddressManager, + 'OVM_CanonicalTransactionChain', + Mock__OVM_CanonicalTransactionChain + ) + + await setProxyTarget( + AddressManager, + 'OVM_StateTransitionerFactory', + Mock__OVM_StateTransitionerFactory + ) + + await setProxyTarget( + AddressManager, + 'OVM_BondManager', + Mock__OVM_BondManager + ) + + Mock__OVM_StateTransitionerFactory.smocked.create.will.return.with( + Mock__OVM_StateTransitioner.address + ) + }) + + let Factory__OVM_FraudVerifier: ContractFactory + before(async () => { + Factory__OVM_FraudVerifier = await ethers.getContractFactory( + 'OVM_FraudVerifier' + ) + }) + + let OVM_FraudVerifier: Contract + beforeEach(async () => { + OVM_FraudVerifier = await Factory__OVM_FraudVerifier.deploy( + AddressManager.address + ) + }) + + describe('initializeFraudVerification', () => { + describe('when provided an invalid pre-state root inclusion proof', () => { + before(() => { + Mock__OVM_StateCommitmentChain.smocked.verifyStateCommitment.will.return.with( + false + ) + }) + + it('should revert', async () => { + await expect( + OVM_FraudVerifier.initializeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_OVM_TRANSACTIONS[0], + DUMMY_TX_CHAIN_ELEMENTS[0], + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0] + ) + ).to.be.revertedWith('Invalid pre-state root inclusion proof.') + }) + }) + + describe('when provided a valid pre-state root inclusion proof', () => { + before(() => { + Mock__OVM_StateCommitmentChain.smocked.verifyStateCommitment.will.return.with( + true + ) + }) + + describe('when provided an invalid transaction inclusion proof', () => { + before(() => { + Mock__OVM_CanonicalTransactionChain.smocked.verifyTransaction.will.return.with( + false + ) + }) + + it('should revert', async () => { + await expect( + OVM_FraudVerifier.initializeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_OVM_TRANSACTIONS[0], + DUMMY_TX_CHAIN_ELEMENTS[0], + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0] + ) + ).to.be.revertedWith('Invalid transaction inclusion proof.') + }) + }) + + describe('when provided a valid transaction inclusion proof', () => { + before(() => { + Mock__OVM_CanonicalTransactionChain.smocked.verifyTransaction.will.return.with( + true + ) + }) + + it('should deploy a new state transitioner', async () => { + await expect( + OVM_FraudVerifier.initializeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_OVM_TRANSACTIONS[0], + DUMMY_TX_CHAIN_ELEMENTS[0], + DUMMY_BATCH_HEADERS[0], + { + ...DUMMY_BATCH_PROOFS[0], + index: DUMMY_BATCH_PROOFS[0].index + 1, + } + ) + ).to.not.be.reverted + + expect( + await OVM_FraudVerifier.getStateTransitioner( + ethers.constants.HashZero, + DUMMY_HASH + ) + ).to.equal(Mock__OVM_StateTransitioner.address) + }) + + it('should revert when provided with a incorrect transaction root global index', async () => { + await expect( + OVM_FraudVerifier.initializeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_OVM_TRANSACTIONS[0], + DUMMY_TX_CHAIN_ELEMENTS[0], + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS_WITH_INDEX[0] + ) + ).to.be.revertedWith( + 'Pre-state root global index must equal to the transaction root global index.' + ) + }) + }) + }) + }) + + describe('finalizeFraudVerification', () => { + beforeEach(async () => { + Mock__OVM_StateCommitmentChain.smocked.verifyStateCommitment.will.return.with( + true + ) + Mock__OVM_CanonicalTransactionChain.smocked.verifyTransaction.will.return.with( + true + ) + + await OVM_FraudVerifier.initializeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_OVM_TRANSACTIONS[0], + DUMMY_TX_CHAIN_ELEMENTS[0], + DUMMY_BATCH_HEADERS[0], + { + ...DUMMY_BATCH_PROOFS[0], + index: DUMMY_BATCH_PROOFS[0].index + 1, + } + ) + }) + + describe('when the transition process is not complete', () => { + before(async () => { + Mock__OVM_StateTransitioner.smocked.isComplete.will.return.with(false) + }) + + it('should revert', async () => { + await expect( + OVM_FraudVerifier.finalizeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_HASH, + NON_NULL_BYTES32, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0] + ) + ).to.be.revertedWith( + 'State transition process must be completed prior to finalization.' + ) + }) + }) + + describe('when the transition process is complete', () => { + before(() => { + Mock__OVM_StateTransitioner.smocked.isComplete.will.return.with(true) + }) + + describe('when provided an invalid post-state root index', () => { + const batchProof = { + ...DUMMY_BATCH_PROOFS[0], + index: DUMMY_BATCH_PROOFS[0].index + 2, + } + + it('should revert', async () => { + await expect( + OVM_FraudVerifier.finalizeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_HASH, + NON_NULL_BYTES32, + DUMMY_BATCH_HEADERS[0], + batchProof + ) + ).to.be.revertedWith( + 'Post-state root global index must equal to the pre state root global index plus one.' + ) + }) + }) + + describe('when provided a valid post-state root index', () => { + const batchProof = { + ...DUMMY_BATCH_PROOFS[0], + index: DUMMY_BATCH_PROOFS[0].index + 1, + } + + describe('when provided an invalid pre-state root inclusion proof', () => { + beforeEach(() => { + Mock__OVM_StateCommitmentChain.smocked.verifyStateCommitment.will.return.with( + false + ) + }) + + it('should revert', async () => { + await expect( + OVM_FraudVerifier.finalizeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_HASH, + NON_NULL_BYTES32, + DUMMY_BATCH_HEADERS[0], + batchProof + ) + ).to.be.revertedWith('Invalid pre-state root inclusion proof.') + }) + }) + + describe('when provided a valid pre-state root inclusion proof', () => { + before(() => { + Mock__OVM_StateCommitmentChain.smocked.verifyStateCommitment.will.return.with( + true + ) + }) + + describe('when provided an invalid post-state root inclusion proof', () => { + beforeEach(() => { + Mock__OVM_StateCommitmentChain.smocked.verifyStateCommitment.will.return.with( + (stateRoot: string, ...args: any) => { + return stateRoot !== NON_NULL_BYTES32 + } + ) + }) + + it('should revert', async () => { + await expect( + OVM_FraudVerifier.finalizeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_HASH, + NON_NULL_BYTES32, + DUMMY_BATCH_HEADERS[0], + batchProof + ) + ).to.be.revertedWith('Invalid post-state root inclusion proof.') + }) + }) + + describe('when provided a valid post-state root inclusion proof', () => { + before(() => { + Mock__OVM_StateCommitmentChain.smocked.verifyStateCommitment.will.return.with( + true + ) + }) + + describe('when the provided post-state root does not differ from the computed one', () => { + before(() => { + Mock__OVM_StateTransitioner.smocked.getPostStateRoot.will.return.with( + NON_NULL_BYTES32 + ) + }) + + it('should revert', async () => { + await expect( + OVM_FraudVerifier.finalizeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_HASH, + NON_NULL_BYTES32, + DUMMY_BATCH_HEADERS[0], + batchProof + ) + ).to.be.revertedWith( + 'State transition has not been proven fraudulent.' + ) + }) + }) + + describe('when the provided post-state root differs from the computed one', () => { + before(() => { + Mock__OVM_StateTransitioner.smocked.getPostStateRoot.will.return.with( + ethers.constants.HashZero + ) + }) + + it('should succeed and attempt to delete a state batch', async () => { + await OVM_FraudVerifier.finalizeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_HASH, + NON_NULL_BYTES32, + DUMMY_BATCH_HEADERS[0], + batchProof + ) + + expect( + Mock__OVM_StateCommitmentChain.smocked.deleteStateBatch + .calls[0] + ).to.deep.equal([ + Object.values(DUMMY_BATCH_HEADERS[0]).map((value) => { + return Number.isInteger(value) + ? BigNumber.from(value) + : value + }), + ]) + }) + }) + }) + }) + }) + + describe('multiple fraud proofs for the same pre-execution state', () => { + let state2: any + const DUMMY_HASH_2 = hashTransaction(DUMMY_OVM_TRANSACTIONS[1]) + beforeEach(async () => { + state2 = await smockit( + await ethers.getContractFactory('OVM_StateTransitioner') + ) + + Mock__OVM_StateTransitionerFactory.smocked.create.will.return.with( + state2.address + ) + + Mock__OVM_StateTransitioner.smocked.getPostStateRoot.will.return.with( + ethers.constants.HashZero + ) + + state2.smocked.getPostStateRoot.will.return.with( + ethers.constants.HashZero + ) + }) + + it('creates multiple state transitioners per tx hash', async () => { + await expect( + OVM_FraudVerifier.initializeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_OVM_TRANSACTIONS[1], + DUMMY_TX_CHAIN_ELEMENTS[0], + DUMMY_BATCH_HEADERS[0], + { + ...DUMMY_BATCH_PROOFS[0], + index: DUMMY_BATCH_PROOFS[0].index + 1, + } + ) + ).to.not.be.reverted + + expect( + await OVM_FraudVerifier.getStateTransitioner( + ethers.constants.HashZero, + DUMMY_HASH + ) + ).to.equal(Mock__OVM_StateTransitioner.address) + expect( + await OVM_FraudVerifier.getStateTransitioner( + ethers.constants.HashZero, + DUMMY_HASH_2 + ) + ).to.equal(state2.address) + }) + + const batchProof = { + ...DUMMY_BATCH_PROOFS[0], + index: DUMMY_BATCH_PROOFS[0].index + 1, + } + + // TODO: Appears to be failing because of a bug in smock. + it.skip('Case 1: allows proving fraud on the same pre-state root twice', async () => { + // finalize previous fraud + await OVM_FraudVerifier.finalizeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_HASH, + NON_NULL_BYTES32, + DUMMY_BATCH_HEADERS[0], + batchProof + ) + + // start new fraud + await OVM_FraudVerifier.initializeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_OVM_TRANSACTIONS[1], + DUMMY_TX_CHAIN_ELEMENTS[1], + DUMMY_BATCH_HEADERS[1], + { + ...DUMMY_BATCH_PROOFS[0], + index: DUMMY_BATCH_PROOFS[0].index + 1, + } + ) + + // finalize it as well + await OVM_FraudVerifier.finalizeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_HASH_2, + NON_NULL_BYTES32, + DUMMY_BATCH_HEADERS[1], + batchProof + ) + + // the new batch was deleted + expect( + Mock__OVM_StateCommitmentChain.smocked.deleteStateBatch.calls[0] + ).to.deep.equal([ + Object.values(DUMMY_BATCH_HEADERS[1]).map((value) => { + return Number.isInteger(value) ? BigNumber.from(value) : value + }), + ]) + }) + + // TODO: Appears to be failing because of a bug in smock. + it.skip('Case 2: does not get blocked by the first transitioner', async () => { + // start new fraud + await OVM_FraudVerifier.initializeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_OVM_TRANSACTIONS[1], + DUMMY_TX_CHAIN_ELEMENTS[1], + DUMMY_BATCH_HEADERS[1], + { + ...DUMMY_BATCH_PROOFS[0], + index: DUMMY_BATCH_PROOFS[0].index + 1, + } + ) + + // finalize the new fraud first + await OVM_FraudVerifier.finalizeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_HASH_2, + NON_NULL_BYTES32, + DUMMY_BATCH_HEADERS[1], + batchProof + ) + + // the new fraud's batch was deleted + expect( + Mock__OVM_StateCommitmentChain.smocked.deleteStateBatch.calls[0] + ).to.deep.equal([ + Object.values(DUMMY_BATCH_HEADERS[1]).map((value) => { + return Number.isInteger(value) ? BigNumber.from(value) : value + }), + ]) + + // finalize previous fraud + await OVM_FraudVerifier.finalizeFraudVerification( + ethers.constants.HashZero, + DUMMY_BATCH_HEADERS[0], + DUMMY_BATCH_PROOFS[0], + DUMMY_HASH, + NON_NULL_BYTES32, + DUMMY_BATCH_HEADERS[0], + batchProof + ) + + // the old fraud's batch was deleted + expect( + Mock__OVM_StateCommitmentChain.smocked.deleteStateBatch.calls[0] + ).to.deep.equal([ + Object.values(DUMMY_BATCH_HEADERS[0]).map((value) => { + return Number.isInteger(value) ? BigNumber.from(value) : value + }), + ]) + }) + }) + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/verification/OVM_StateTransitioner.spec.ts b/packages/contracts/test/contracts/OVM/verification/OVM_StateTransitioner.spec.ts new file mode 100644 index 000000000000..b7d48c833ae9 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/verification/OVM_StateTransitioner.spec.ts @@ -0,0 +1,594 @@ +/* tslint:disable:no-empty */ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { BigNumber, constants, Contract } from 'ethers' +import * as rlp from 'rlp' + +/* Internal Imports */ +import { + makeAddressManager, + NON_NULL_BYTES32, + NON_ZERO_ADDRESS, + setProxyTarget, + TrieTestGenerator, +} from '../../../helpers' +import { + MockContract, + smockit, + ModifiableContract, + smoddit, + ModifiableContractFactory, +} from '@eth-optimism/smock' +import { toHexString } from '@eth-optimism/core-utils' + +describe('OVM_StateTransitioner', () => { + let AddressManager: Contract + before(async () => { + AddressManager = await makeAddressManager() + }) + + let Mock__OVM_ExecutionManager: MockContract + let Mock__OVM_StateManagerFactory: MockContract + let Mock__OVM_StateManager: MockContract + let Mock__OVM_BondManager: MockContract + before(async () => { + Mock__OVM_ExecutionManager = await smockit( + await ethers.getContractFactory('OVM_ExecutionManager') + ) + Mock__OVM_StateManagerFactory = await smockit( + await ethers.getContractFactory('OVM_StateManagerFactory') + ) + Mock__OVM_StateManager = await smockit( + await ethers.getContractFactory('OVM_StateManager') + ) + Mock__OVM_BondManager = await smockit( + await ethers.getContractFactory('OVM_BondManager') + ) + + await setProxyTarget( + AddressManager, + 'OVM_BondManager', + Mock__OVM_BondManager + ) + Mock__OVM_BondManager.smocked.recordGasSpent.will.return() + + await setProxyTarget( + AddressManager, + 'OVM_ExecutionManager', + Mock__OVM_ExecutionManager + ) + + await setProxyTarget( + AddressManager, + 'OVM_StateManagerFactory', + Mock__OVM_StateManagerFactory + ) + + Mock__OVM_StateManagerFactory.smocked.create.will.return.with( + Mock__OVM_StateManager.address + ) + + Mock__OVM_StateManager.smocked.putAccount.will.return() + }) + + let Factory__OVM_StateTransitioner: ModifiableContractFactory + before(async () => { + Factory__OVM_StateTransitioner = await smoddit('OVM_StateTransitioner') + }) + + let OVM_StateTransitioner: ModifiableContract + beforeEach(async () => { + OVM_StateTransitioner = await Factory__OVM_StateTransitioner.deploy( + AddressManager.address, + 0, + ethers.constants.HashZero, + ethers.constants.HashZero + ) + }) + + describe('proveContractState', () => { + const ovmContractAddress = NON_ZERO_ADDRESS + let ethContractAddress = constants.AddressZero + let account: any + beforeEach(() => { + Mock__OVM_StateManager.smocked.hasAccount.will.return.with(false) + Mock__OVM_StateManager.smocked.hasEmptyAccount.will.return.with(false) + account = { + nonce: 0, + balance: 0, + storageRoot: ethers.constants.HashZero, + codeHash: ethers.constants.HashZero, + } + }) + + describe('when provided a valid code hash', () => { + beforeEach(async () => { + ethContractAddress = OVM_StateTransitioner.address + account.codeHash = ethers.utils.keccak256( + await ethers.provider.getCode(OVM_StateTransitioner.address) + ) + }) + + describe('when provided an invalid account inclusion proof', () => { + const proof = '0x' + + it('should revert', async () => { + await expect( + OVM_StateTransitioner.proveContractState( + ovmContractAddress, + ethContractAddress, + proof + ) + ).to.be.reverted + }) + }) + + describe('when provided a valid account inclusion proof', () => { + let proof: string + beforeEach(async () => { + const generator = await TrieTestGenerator.fromAccounts({ + accounts: [ + { + ...account, + address: ovmContractAddress, + }, + ], + secure: true, + }) + + const test = await generator.makeAccountProofTest(ovmContractAddress) + + proof = test.accountTrieWitness + + OVM_StateTransitioner = await Factory__OVM_StateTransitioner.deploy( + AddressManager.address, + 0, + test.accountTrieRoot, + ethers.constants.HashZero + ) + }) + + it('should put the account in the state manager', async () => { + await OVM_StateTransitioner.proveContractState( + ovmContractAddress, + ethContractAddress, + proof + ) + + expect( + Mock__OVM_StateManager.smocked.putAccount.calls[0] + ).to.deep.equal([ + NON_ZERO_ADDRESS, + [ + BigNumber.from(account.nonce), + BigNumber.from(account.balance), + account.storageRoot, + account.codeHash, + ethContractAddress, + false, + ], + ]) + }) + }) + }) + }) + + describe('proveStorageSlot', () => { + beforeEach(() => { + Mock__OVM_StateManager.smocked.hasContractStorage.will.return.with(false) + }) + + describe('when the corresponding account is not proven', () => { + beforeEach(() => { + Mock__OVM_StateManager.smocked.hasAccount.will.return.with(false) + }) + + it('should revert', async () => { + await expect( + OVM_StateTransitioner.proveStorageSlot( + NON_ZERO_ADDRESS, + NON_NULL_BYTES32, + '0x' + ) + ).to.be.revertedWith( + 'Contract must be verified before proving a storage slot.' + ) + }) + }) + + describe('when the corresponding account is proven', () => { + beforeEach(() => { + Mock__OVM_StateManager.smocked.hasAccount.will.return.with(true) + }) + + describe('when provided an invalid slot inclusion proof', () => { + const key = ethers.utils.keccak256('0x1234') + const val = ethers.utils.keccak256('0x5678') + const proof = '0x' + beforeEach(async () => { + const generator = await TrieTestGenerator.fromNodes({ + nodes: [ + { + key, + val: '0x' + rlp.encode(val).toString('hex'), + }, + ], + secure: true, + }) + + const test = await generator.makeInclusionProofTest(0) + + Mock__OVM_StateManager.smocked.getAccountStorageRoot.will.return.with( + test.root + ) + }) + + it('should revert', async () => { + await expect( + OVM_StateTransitioner.proveStorageSlot( + constants.AddressZero, + key, + proof + ) + ).to.be.reverted + }) + }) + + describe('when provided a valid slot inclusion proof', () => { + const key = ethers.utils.keccak256('0x1234') + const val = ethers.utils.keccak256('0x5678') + let proof: string + beforeEach(async () => { + const generator = await TrieTestGenerator.fromNodes({ + nodes: [ + { + key, + val: '0x' + rlp.encode(val).toString('hex'), + }, + ], + secure: true, + }) + + const test = await generator.makeInclusionProofTest(0) + proof = test.proof + + Mock__OVM_StateManager.smocked.getAccountStorageRoot.will.return.with( + test.root + ) + }) + + it('should insert the storage slot', async () => { + await expect( + OVM_StateTransitioner.proveStorageSlot( + constants.AddressZero, + key, + proof + ) + ).to.not.be.reverted + + expect( + Mock__OVM_StateManager.smocked.putContractStorage.calls[0] + ).to.deep.equal([constants.AddressZero, key, val]) + }) + }) + }) + }) + + describe('applyTransaction', () => { + it('Blocks execution if insufficient gas provided', async () => { + const gasLimit = 500_000 + const transaction = { + timestamp: '0x12', + blockNumber: '0x34', + l1QueueOrigin: '0x00', + l1TxOrigin: constants.AddressZero, + entrypoint: constants.AddressZero, + gasLimit: toHexString(gasLimit), + data: '0x1234', + } + + const transactionHash = ethers.utils.keccak256( + ethers.utils.solidityPack( + [ + 'uint256', + 'uint256', + 'uint8', + 'address', + 'address', + 'uint256', + 'bytes', + ], + [ + transaction.timestamp, + transaction.blockNumber, + transaction.l1QueueOrigin, + transaction.l1TxOrigin, + transaction.entrypoint, + transaction.gasLimit, + transaction.data, + ] + ) + ) + + OVM_StateTransitioner.smodify.set({ + phase: 0, + transactionHash, + }) + + await expect( + OVM_StateTransitioner.applyTransaction(transaction, { + gasLimit: 30_000, + }) + ).to.be.revertedWith( + `Not enough gas to execute transaction deterministically` + ) + }) + }) + + describe('commitContractState', () => { + beforeEach(async () => { + OVM_StateTransitioner.smodify.set({ + phase: 1, + }) + }) + + const ovmContractAddress = NON_ZERO_ADDRESS + let account: any + beforeEach(() => { + account = { + nonce: 0, + balance: 0, + storageRoot: ethers.constants.HashZero, + codeHash: ethers.constants.HashZero, + ethAddress: constants.AddressZero, + isFresh: false, + } + Mock__OVM_StateManager.smocked.hasAccount.will.return.with(false) + Mock__OVM_StateManager.smocked.getAccount.will.return.with(account) + }) + + describe('when the account was not changed or has already been committed', () => { + before(() => { + Mock__OVM_StateManager.smocked.getTotalUncommittedContractStorage.will.return.with( + 0 + ) + Mock__OVM_StateManager.smocked.commitAccount.will.return.with(false) + }) + + it('should revert', async () => { + await expect( + OVM_StateTransitioner.commitContractState(ovmContractAddress, '0x') + ).to.be.revertedWith( + `Account state wasn't changed or has already been committed` + ) + }) + }) + + describe('when the account was changed or has not already been committed', () => { + before(() => { + Mock__OVM_StateManager.smocked.commitAccount.will.return.with(true) + }) + + describe('when given an valid update proof', () => { + let proof: string + let postStateRoot: string + beforeEach(async () => { + const generator = await TrieTestGenerator.fromAccounts({ + accounts: [ + { + ...account, + nonce: 10, + address: ovmContractAddress, + }, + ], + secure: true, + }) + + const test = await generator.makeAccountUpdateTest( + ovmContractAddress, + account + ) + + proof = test.accountTrieWitness + postStateRoot = test.newAccountTrieRoot + + OVM_StateTransitioner.smodify.put({ + postStateRoot: test.accountTrieRoot, + }) + }) + + it('should update the post state root', async () => { + await expect( + OVM_StateTransitioner.commitContractState(ovmContractAddress, proof) + ).to.not.be.reverted + + expect(await OVM_StateTransitioner.getPostStateRoot()).to.equal( + postStateRoot + ) + }) + }) + }) + }) + + describe('commitStorageSlot', () => { + beforeEach(() => { + OVM_StateTransitioner.smodify.set({ + phase: 1, + }) + }) + + const ovmContractAddress = NON_ZERO_ADDRESS + let account: any + const key = ethers.utils.keccak256('0x1234') + const val = ethers.utils.keccak256('0x5678') + const newVal = ethers.utils.keccak256('0x4321') + beforeEach(() => { + account = { + nonce: 0, + balance: 0, + storageRoot: ethers.constants.HashZero, + codeHash: ethers.constants.HashZero, + } + + Mock__OVM_StateManager.smocked.getAccount.will.return.with({ + ...account, + ethAddress: constants.AddressZero, + isFresh: false, + }) + + Mock__OVM_StateManager.smocked.getContractStorage.will.return.with(val) + }) + + describe('when the slot was not changed or was already committed', () => { + beforeEach(() => { + Mock__OVM_StateManager.smocked.commitContractStorage.will.return.with( + false + ) + }) + + it('should revert', async () => { + await expect( + OVM_StateTransitioner.commitStorageSlot(ovmContractAddress, key, '0x') + ).to.be.revertedWith( + `Storage slot value wasn't changed or has already been committed.` + ) + }) + }) + + describe('when the slot was changed or not already committed', () => { + beforeEach(() => { + Mock__OVM_StateManager.smocked.commitContractStorage.will.return.with( + true + ) + }) + + describe('with a valid proof', () => { + let storageTrieProof: string + beforeEach(async () => { + const storageGenerator = await TrieTestGenerator.fromNodes({ + nodes: [ + { + key, + val: '0x' + rlp.encode(val).toString('hex'), + }, + ], + secure: true, + }) + + const storageTest = await storageGenerator.makeNodeUpdateTest( + key, + '0x' + rlp.encode(newVal).toString('hex') + ) + + const generator = await TrieTestGenerator.fromAccounts({ + accounts: [ + { + ...account, + storageRoot: storageTest.root, + address: ovmContractAddress, + }, + ], + secure: true, + }) + + const test = await generator.makeAccountUpdateTest( + ovmContractAddress, + { + ...account, + storageRoot: storageTest.newRoot, + } + ) + + Mock__OVM_StateManager.smocked.getAccount.will.return.with({ + ...account, + storageRoot: storageTest.root, + ethAddress: constants.AddressZero, + isFresh: false, + }) + + storageTrieProof = storageTest.proof + + OVM_StateTransitioner.smodify.put({ + postStateRoot: test.accountTrieRoot, + }) + }) + + it('should commit the slot and update the state', async () => { + await expect( + OVM_StateTransitioner.commitStorageSlot( + ovmContractAddress, + key, + storageTrieProof + ) + ).to.not.be.reverted + }) + }) + }) + }) + + describe('completeTransition', () => { + beforeEach(() => { + OVM_StateTransitioner.smodify.set({ + phase: 1, + }) + }) + + describe('when there are uncommitted accounts', () => { + beforeEach(() => { + Mock__OVM_StateManager.smocked.getTotalUncommittedAccounts.will.return.with( + 1 + ) + Mock__OVM_StateManager.smocked.getTotalUncommittedContractStorage.will.return.with( + 0 + ) + }) + + it('should revert', async () => { + await expect( + OVM_StateTransitioner.completeTransition() + ).to.be.revertedWith( + 'All accounts must be committed before completing a transition.' + ) + }) + }) + + describe('when there are uncommitted storage slots', () => { + beforeEach(() => { + Mock__OVM_StateManager.smocked.getTotalUncommittedAccounts.will.return.with( + 0 + ) + Mock__OVM_StateManager.smocked.getTotalUncommittedContractStorage.will.return.with( + 1 + ) + }) + + it('should revert', async () => { + await expect( + OVM_StateTransitioner.completeTransition() + ).to.be.revertedWith( + 'All storage must be committed before completing a transition.' + ) + }) + }) + + describe('when all state changes are committed', () => { + beforeEach(() => { + Mock__OVM_StateManager.smocked.getTotalUncommittedAccounts.will.return.with( + 0 + ) + Mock__OVM_StateManager.smocked.getTotalUncommittedContractStorage.will.return.with( + 0 + ) + }) + + it('should complete the transition', async () => { + await expect(OVM_StateTransitioner.completeTransition()).to.not.be + .reverted + + expect(await OVM_StateTransitioner.isComplete()).to.equal(true) + }) + }) + }) +}) diff --git a/packages/contracts/test/contracts/OVM/verification/OVM_StateTransitionerFactory.spec.ts b/packages/contracts/test/contracts/OVM/verification/OVM_StateTransitionerFactory.spec.ts new file mode 100644 index 000000000000..f9521809ec70 --- /dev/null +++ b/packages/contracts/test/contracts/OVM/verification/OVM_StateTransitionerFactory.spec.ts @@ -0,0 +1,59 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { ContractFactory, Contract, constants } from 'ethers' + +/* Internal Imports */ +import { + makeAddressManager, + DUMMY_OVM_TRANSACTIONS, + hashTransaction, +} from '../../../helpers' + +const DUMMY_HASH = hashTransaction(DUMMY_OVM_TRANSACTIONS[0]) + +describe('OVM_StateTransitionerFactory', () => { + let AddressManager: Contract + before(async () => { + AddressManager = await makeAddressManager() + }) + + let Factory__OVM_StateTransitionerFactory: ContractFactory + before(async () => { + Factory__OVM_StateTransitionerFactory = await ethers.getContractFactory( + 'OVM_StateTransitionerFactory' + ) + }) + + let OVM_StateTransitionerFactory: Contract + beforeEach(async () => { + OVM_StateTransitionerFactory = await Factory__OVM_StateTransitionerFactory.deploy( + AddressManager.address + ) + }) + + describe('create', () => { + describe('when the sender is not the OVM_FraudVerifier', () => { + before(async () => { + await AddressManager.setAddress( + 'OVM_FraudVerifier', + constants.AddressZero + ) + }) + + it('should revert', async () => { + await expect( + OVM_StateTransitionerFactory.create( + AddressManager.address, + ethers.constants.HashZero, + ethers.constants.HashZero, + DUMMY_HASH + ) + ).to.be.revertedWith( + 'Create can only be done by the OVM_FraudVerifier.' + ) + }) + }) + }) +}) diff --git a/packages/contracts/test/contracts/libraries/codec/Lib_OVMCodec.spec.ts b/packages/contracts/test/contracts/libraries/codec/Lib_OVMCodec.spec.ts new file mode 100644 index 000000000000..39310cdc31ba --- /dev/null +++ b/packages/contracts/test/contracts/libraries/codec/Lib_OVMCodec.spec.ts @@ -0,0 +1,12 @@ +/* tslint:disable:no-empty */ +import '../../../setup' + +/* Internal Imports */ +import { Lib_OVMCodec_TEST_JSON } from '../../../data' +import { runJsonTest } from '../../../helpers' + +describe.skip('Lib_OVMCodec', () => { + describe('JSON tests', () => { + runJsonTest('TestLib_OVMCodec', Lib_OVMCodec_TEST_JSON) + }) +}) diff --git a/packages/contracts/test/contracts/libraries/rlp/Lib_RLPReader.spec.ts b/packages/contracts/test/contracts/libraries/rlp/Lib_RLPReader.spec.ts new file mode 100644 index 000000000000..0066b0cb7b5c --- /dev/null +++ b/packages/contracts/test/contracts/libraries/rlp/Lib_RLPReader.spec.ts @@ -0,0 +1,9 @@ +/* Internal Imports */ +import { Lib_RLPReader_TEST_JSON } from '../../../data' +import { runJsonTest } from '../../../helpers' + +describe('Lib_RLPReader', () => { + describe('JSON tests', () => { + runJsonTest('TestLib_RLPReader', Lib_RLPReader_TEST_JSON) + }) +}) diff --git a/packages/contracts/test/contracts/libraries/rlp/Lib_RLPWriter.spec.ts b/packages/contracts/test/contracts/libraries/rlp/Lib_RLPWriter.spec.ts new file mode 100644 index 000000000000..70fab544901b --- /dev/null +++ b/packages/contracts/test/contracts/libraries/rlp/Lib_RLPWriter.spec.ts @@ -0,0 +1,54 @@ +/* tslint:disable:no-empty */ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Contract } from 'ethers' + +/* Internal Imports */ +import { Lib_RLPWriter_TEST_JSON } from '../../../data' + +const encode = async (Lib_RLPWriter: Contract, input: any): Promise => { + if (Array.isArray(input)) { + const elements = await Promise.all( + input.map(async (el) => { + return encode(Lib_RLPWriter, el) + }) + ) + + return Lib_RLPWriter.writeList(elements) + } else if (Number.isInteger(input)) { + return Lib_RLPWriter.writeUint(input) + } else { + return Lib_RLPWriter.writeString(input) + } +} + +describe('Lib_RLPWriter', () => { + let Lib_RLPWriter: Contract + before(async () => { + Lib_RLPWriter = await ( + await ethers.getContractFactory('TestLib_RLPWriter') + ).deploy() + }) + + describe('Official Ethereum RLP Tests', () => { + for (const [key, test] of Object.entries(Lib_RLPWriter_TEST_JSON)) { + it(`should properly encode: ${key}`, async () => { + expect(await encode(Lib_RLPWriter, test.in)).to.equal(test.out) + }) + } + }) + + describe('Use of library with other memory-modifying operations', () => { + it('should allow creation of a contract beforehand and still work', async () => { + const randomAddress = '0x1234123412341234123412341234123412341234' + const rlpEncodedRandomAddress = + '0x941234123412341234123412341234123412341234' + const encoded = await Lib_RLPWriter.callStatic.writeAddressWithTaintedMemory( + randomAddress + ) + expect(encoded).to.eq(rlpEncodedRandomAddress) + }) + }) +}) diff --git a/packages/contracts/test/contracts/libraries/trie/Lib_MerkleTrie.spec.ts b/packages/contracts/test/contracts/libraries/trie/Lib_MerkleTrie.spec.ts new file mode 100644 index 000000000000..2016d39baccf --- /dev/null +++ b/packages/contracts/test/contracts/libraries/trie/Lib_MerkleTrie.spec.ts @@ -0,0 +1,169 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import * as rlp from 'rlp' +import { ethers } from 'hardhat' +import { Contract } from 'ethers' +import { toHexString } from '@eth-optimism/core-utils' + +/* Internal Imports */ +import { TrieTestGenerator } from '../../../helpers' + +const NODE_COUNTS = [1, 2, 128] + +describe('Lib_MerkleTrie', () => { + let Lib_MerkleTrie: Contract + before(async () => { + Lib_MerkleTrie = await ( + await ethers.getContractFactory('TestLib_MerkleTrie') + ).deploy() + }) + + describe('verifyInclusionProof', () => { + for (const nodeCount of NODE_COUNTS) { + describe(`inside a trie with ${nodeCount} nodes`, () => { + let generator: TrieTestGenerator + before(async () => { + generator = await TrieTestGenerator.fromRandom({ + seed: `seed.incluson.${nodeCount}`, + nodeCount, + secure: false, + }) + }) + + for ( + let i = 0; + i < nodeCount; + i += nodeCount / (nodeCount > 8 ? 8 : 1) + ) { + it(`should correctly prove inclusion for node #${i}`, async () => { + const test = await generator.makeInclusionProofTest(i) + + expect( + await Lib_MerkleTrie.verifyInclusionProof( + test.key, + test.val, + test.proof, + test.root + ) + ).to.equal(true) + }) + } + }) + } + }) + + describe('update', () => { + for (const nodeCount of NODE_COUNTS) { + describe(`inside a trie with ${nodeCount} nodes`, () => { + let generator: TrieTestGenerator + before(async () => { + generator = await TrieTestGenerator.fromRandom({ + seed: `seed.update.${nodeCount}`, + nodeCount, + secure: false, + }) + }) + + for ( + let i = 0; + i < nodeCount; + i += nodeCount / (nodeCount > 8 ? 8 : 1) + ) { + it(`should correctly update node #${i}`, async () => { + const test = await generator.makeNodeUpdateTest( + i, + '0x1234123412341234' + ) + + expect( + await Lib_MerkleTrie.update( + test.key, + test.val, + test.proof, + test.root + ) + ).to.equal(test.newRoot) + }) + } + }) + } + }) + + describe('get', () => { + for (const nodeCount of NODE_COUNTS) { + describe(`inside a trie with ${nodeCount} nodes`, () => { + let generator: TrieTestGenerator + before(async () => { + generator = await TrieTestGenerator.fromRandom({ + seed: `seed.get.${nodeCount}`, + nodeCount, + secure: false, + }) + }) + + for ( + let i = 0; + i < nodeCount; + i += nodeCount / (nodeCount > 8 ? 8 : 1) + ) { + it(`should correctly get the value of node #${i}`, async () => { + const test = await generator.makeInclusionProofTest(i) + expect( + await Lib_MerkleTrie.get(test.key, test.proof, test.root) + ).to.deep.equal([true, test.val]) + }) + if (i > 3) { + it(`should revert when the proof node does not pass the root check`, async () => { + const test = await generator.makeInclusionProofTest(i - 1) + const test2 = await generator.makeInclusionProofTest(i - 2) + await expect( + Lib_MerkleTrie.get(test2.key, test.proof, test.root) + ).to.be.revertedWith('Invalid large internal hash') + }) + it(`should revert when the first proof element is not the root node`, async () => { + const test = await generator.makeInclusionProofTest(0) + const decodedProof = rlp.decode(test.proof) + decodedProof[0].write('abcd', 8) // change the 1st element (root) of the proof + const badProof = rlp.encode(decodedProof as rlp.Input) + await expect( + Lib_MerkleTrie.get(test.key, badProof, test.root) + ).to.be.revertedWith('Invalid root hash') + }) + it(`should be false when calling get on an incorrect key`, async () => { + const test = await generator.makeInclusionProofTest(i - 1) + let newKey = test.key.slice(0, test.key.length - 8) + newKey = newKey.concat('88888888') + expect( + await Lib_MerkleTrie.get(newKey, test.proof, test.root) + ).to.deep.equal([false, '0x']) + }) + } + } + }) + } + }) + + describe(`inside a trie with one node`, () => { + let generator: TrieTestGenerator + const nodeCount = 1 + before(async () => { + generator = await TrieTestGenerator.fromRandom({ + seed: `seed.get.${nodeCount}`, + nodeCount, + secure: false, + }) + }) + + it(`should revert on an incorrect proof node prefix`, async () => { + const test = await generator.makeInclusionProofTest(0) + const decodedProof = rlp.decode(test.proof) + decodedProof[0].write('a', 3) // change the prefix + test.root = ethers.utils.keccak256(toHexString(decodedProof[0])) + const badProof = rlp.encode(decodedProof as rlp.Input) + await expect( + Lib_MerkleTrie.get(test.key, badProof, test.root) + ).to.be.revertedWith('Received a node with an unknown prefix') + }) + }) +}) diff --git a/packages/contracts/test/contracts/libraries/trie/Lib_SecureMerkleTrie.spec.ts b/packages/contracts/test/contracts/libraries/trie/Lib_SecureMerkleTrie.spec.ts new file mode 100644 index 000000000000..9e94d588a2a7 --- /dev/null +++ b/packages/contracts/test/contracts/libraries/trie/Lib_SecureMerkleTrie.spec.ts @@ -0,0 +1,119 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Contract } from 'ethers' + +/* Internal Imports */ +import { TrieTestGenerator } from '../../../helpers' + +const NODE_COUNTS = [1, 2, 128] + +describe('Lib_SecureMerkleTrie', () => { + let Lib_SecureMerkleTrie: Contract + before(async () => { + Lib_SecureMerkleTrie = await ( + await ethers.getContractFactory('TestLib_SecureMerkleTrie') + ).deploy() + }) + + describe('verifyInclusionProof', () => { + for (const nodeCount of NODE_COUNTS) { + describe(`inside a trie with ${nodeCount} nodes`, () => { + let generator: TrieTestGenerator + before(async () => { + generator = await TrieTestGenerator.fromRandom({ + seed: `seed.incluson.${nodeCount}`, + nodeCount, + secure: true, + }) + }) + + for ( + let i = 0; + i < nodeCount; + i += nodeCount / (nodeCount > 8 ? 8 : 1) + ) { + it(`should correctly prove inclusion for node #${i}`, async () => { + const test = await generator.makeInclusionProofTest(i) + + expect( + await Lib_SecureMerkleTrie.verifyInclusionProof( + test.key, + test.val, + test.proof, + test.root + ) + ).to.equal(true) + }) + } + }) + } + }) + + describe('update', () => { + for (const nodeCount of NODE_COUNTS) { + describe(`inside a trie with ${nodeCount} nodes`, () => { + let generator: TrieTestGenerator + before(async () => { + generator = await TrieTestGenerator.fromRandom({ + seed: `seed.update.${nodeCount}`, + nodeCount, + secure: true, + }) + }) + + for ( + let i = 0; + i < nodeCount; + i += nodeCount / (nodeCount > 8 ? 8 : 1) + ) { + it(`should correctly update node #${i}`, async () => { + const test = await generator.makeNodeUpdateTest( + i, + '0x1234123412341234' + ) + + expect( + await Lib_SecureMerkleTrie.update( + test.key, + test.val, + test.proof, + test.root + ) + ).to.equal(test.newRoot) + }) + } + }) + } + }) + + describe('get', () => { + for (const nodeCount of NODE_COUNTS) { + describe(`inside a trie with ${nodeCount} nodes`, () => { + let generator: TrieTestGenerator + before(async () => { + generator = await TrieTestGenerator.fromRandom({ + seed: `seed.get.${nodeCount}`, + nodeCount, + secure: true, + }) + }) + + for ( + let i = 0; + i < nodeCount; + i += nodeCount / (nodeCount > 8 ? 8 : 1) + ) { + it(`should correctly get the value of node #${i}`, async () => { + const test = await generator.makeInclusionProofTest(i) + + expect( + await Lib_SecureMerkleTrie.get(test.key, test.proof, test.root) + ).to.deep.equal([true, test.val]) + }) + } + }) + } + }) +}) diff --git a/packages/contracts/test/contracts/libraries/utils/Lib_Bytes32Utils.spec.ts b/packages/contracts/test/contracts/libraries/utils/Lib_Bytes32Utils.spec.ts new file mode 100644 index 000000000000..d7111382c44b --- /dev/null +++ b/packages/contracts/test/contracts/libraries/utils/Lib_Bytes32Utils.spec.ts @@ -0,0 +1,9 @@ +/* Internal Imports */ +import { Lib_Bytes32Utils_TEST_JSON } from '../../../data' +import { runJsonTest } from '../../../helpers' + +describe('Lib_Bytes32Utils', () => { + describe('JSON tests', () => { + runJsonTest('TestLib_Bytes32Utils', Lib_Bytes32Utils_TEST_JSON) + }) +}) diff --git a/packages/contracts/test/contracts/libraries/utils/Lib_BytesUtils.spec.ts b/packages/contracts/test/contracts/libraries/utils/Lib_BytesUtils.spec.ts new file mode 100644 index 000000000000..3dda22dce3f5 --- /dev/null +++ b/packages/contracts/test/contracts/libraries/utils/Lib_BytesUtils.spec.ts @@ -0,0 +1,32 @@ +/* Internal Imports */ +import { Lib_BytesUtils_TEST_JSON } from '../../../data' +import { runJsonTest } from '../../../helpers' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Contract } from 'ethers' +import { expect } from '../../../setup' + +describe('Lib_BytesUtils', () => { + describe('JSON tests', () => { + runJsonTest('TestLib_BytesUtils', Lib_BytesUtils_TEST_JSON) + }) + + describe('Use of library with other memory-modifying operations', () => { + let TestLib_BytesUtils: Contract + before(async () => { + TestLib_BytesUtils = await ( + await ethers.getContractFactory('TestLib_BytesUtils') + ).deploy() + }) + + it('should allow creation of a contract beforehand and still work', async () => { + const slice = await TestLib_BytesUtils.callStatic.sliceWithTaintedMemory( + '0x123412341234', + 0, + 0 + ) + expect(slice).to.eq('0x') + }) + }) +}) diff --git a/packages/contracts/test/contracts/libraries/utils/Lib_ECDSAUtils.spec.ts b/packages/contracts/test/contracts/libraries/utils/Lib_ECDSAUtils.spec.ts new file mode 100644 index 000000000000..baf3c5a999b2 --- /dev/null +++ b/packages/contracts/test/contracts/libraries/utils/Lib_ECDSAUtils.spec.ts @@ -0,0 +1,9 @@ +/* Internal Imports */ +import { Lib_ECDSAUtils_TEST_JSON } from '../../../data' +import { runJsonTest } from '../../../helpers' + +describe('Lib_ECDSAUtils', () => { + describe('JSON tests', () => { + runJsonTest('TestLib_ECDSAUtils', Lib_ECDSAUtils_TEST_JSON) + }) +}) diff --git a/packages/contracts/test/contracts/libraries/utils/Lib_EthUtils.spec.ts b/packages/contracts/test/contracts/libraries/utils/Lib_EthUtils.spec.ts new file mode 100644 index 000000000000..ab6d3aca62b1 --- /dev/null +++ b/packages/contracts/test/contracts/libraries/utils/Lib_EthUtils.spec.ts @@ -0,0 +1,362 @@ +/* tslint:disable:no-empty */ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Contract, Signer, constants } from 'ethers' +import { fromHexString, toHexString } from '@eth-optimism/core-utils' + +// Leaving this here for now. If it's sufficiently useful we can throw it in core-utils. +const getHexSlice = ( + input: Buffer | string, + start: number, + length: number +): string => { + return toHexString(fromHexString(input).slice(start, start + length)) +} + +describe('Lib_EthUtils', () => { + let signer: Signer + before(async () => { + ;[signer] = await ethers.getSigners() + }) + + let Lib_EthUtils: Contract + before(async () => { + Lib_EthUtils = await ( + await ethers.getContractFactory('TestLib_EthUtils') + ).deploy() + }) + + describe('getCode(address,uint256,uint256)', () => { + describe('when the contract does not exist', () => { + const address = constants.AddressZero + + describe('when offset = 0', () => { + const offset = 0 + + it('should return length zero bytes', async () => { + const length = 100 + + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal('0x' + '00'.repeat(length)) + }) + }) + + describe('when offset > 0', () => { + const offset = 50 + + it('should return length zero bytes', async () => { + const length = 100 + + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal('0x' + '00'.repeat(length)) + }) + }) + }) + + describe('when the account is an EOA', () => { + let address: string + before(async () => { + address = await signer.getAddress() + }) + + describe('when offset = 0', () => { + const offset = 0 + + it('should return length zero bytes', async () => { + const length = 100 + + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal('0x' + '00'.repeat(length)) + }) + }) + + describe('when offset > 0', () => { + const offset = 50 + + it('should return length zero bytes', async () => { + const length = 100 + + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal('0x' + '00'.repeat(length)) + }) + }) + }) + + describe('when the contract exists', () => { + let address: string + let code: string + let codeLength: number + before(async () => { + address = Lib_EthUtils.address + code = await ethers.provider.getCode(address) + codeLength = fromHexString(code).length + }) + + describe('when offset = 0', () => { + const offset = 0 + + describe('when length = 0', () => { + const length = 0 + + it('should return empty', async () => { + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal('0x') + }) + }) + + describe('when 0 < length < extcodesize(contract)', () => { + let length: number + before(async () => { + length = Math.floor(codeLength / 2) + }) + + it('should return N bytes from the start of code', async () => { + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal(getHexSlice(code, offset, length)) + }) + }) + + describe('when length = extcodesize(contract)', () => { + let length: number + before(async () => { + length = codeLength + }) + + it('should return the full contract code', async () => { + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal(code) + }) + }) + + describe('when length > extcodesize(contract)', () => { + let length: number + before(async () => { + length = codeLength * 2 + }) + + it('should return the full contract code padded to length with zero bytes', async () => { + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal(code + '00'.repeat(codeLength)) + }) + }) + }) + + describe('when 0 < offset < extcodesize(contract)', () => { + let offset: number + before(async () => { + offset = Math.floor(codeLength / 2) + }) + + describe('when length = 0', () => { + const length = 0 + + it('should return empty', async () => { + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal('0x') + }) + }) + + describe('when 0 < length < extcodesize(contract) - offset', () => { + let length: number + before(async () => { + length = Math.floor((codeLength - offset) / 2) + }) + + it('should return the selected bytes', async () => { + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal(getHexSlice(code, offset, length)) + }) + }) + + describe('when length = extcodesize(contract) - offset', () => { + let length: number + before(async () => { + length = codeLength - offset + }) + + it('should return the selected bytes', async () => { + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal(getHexSlice(code, offset, length)) + }) + }) + + describe('when length > extcodesize(contract) - offset', () => { + let length: number + let extraLength: number + before(async () => { + length = (codeLength - offset) * 2 + extraLength = length - (codeLength - offset) + }) + + it('should return the selected bytes padded to length with zero bytes', async () => { + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal( + getHexSlice(code, offset, codeLength - offset) + + '00'.repeat(extraLength) + ) + }) + }) + }) + + describe('offset >= extcodesize(contract)', () => { + let offset: number + before(async () => { + offset = codeLength * 2 + }) + + describe('when length = 0', () => { + const length = 0 + + it('should return empty', async () => { + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal('0x') + }) + }) + + describe('when length > 0', () => { + let length: number + before(async () => { + length = codeLength * 2 + }) + + it('should return length zero bytes', async () => { + expect( + await Lib_EthUtils['getCode(address,uint256,uint256)']( + address, + offset, + length + ) + ).to.equal('0x' + '00'.repeat(length)) + }) + }) + }) + }) + }) + + describe('getCode(address)', () => { + describe('when the contract does not exist', () => {}) + + describe('when the account is an EOA', () => {}) + + describe('when the contract exists', () => {}) + }) + + describe('getCodeSize', () => { + describe('when the contract does not exist', () => {}) + + describe('when the account is an EOA', () => {}) + + describe('when the contract exists', () => {}) + }) + + describe('getCodeHash', () => { + describe('when the contract does not exist', () => {}) + + describe('when the account is an EOA', () => {}) + + describe('when the contract exists', () => {}) + }) + + describe('createContract', () => { + describe('it should create the contract', () => {}) + }) + + describe('getAddressForCREATE', () => { + describe('when the nonce is zero', () => { + describe('it should return the correct address', () => {}) + }) + + describe('when the nonce is > 0', () => { + describe('it should return the correct address', () => {}) + }) + }) + + describe('getAddressForCREATE2', () => { + describe('when the bytecode is not empty', () => { + describe('when the salt is not zero', () => { + describe('it should return the correct address', () => {}) + }) + + describe('when the salt is zero', () => { + describe('it should return the correct address', () => {}) + }) + }) + + describe('when the bytecode is empty', () => { + describe('when the salt is not zero', () => { + describe('it should return the correct address', () => {}) + }) + + describe('when the salt is zero', () => { + describe('it should return the correct address', () => {}) + }) + }) + }) +}) diff --git a/packages/contracts/test/contracts/libraries/utils/Lib_MerkleTree.spec.ts b/packages/contracts/test/contracts/libraries/utils/Lib_MerkleTree.spec.ts new file mode 100644 index 000000000000..6d6ab278fec8 --- /dev/null +++ b/packages/contracts/test/contracts/libraries/utils/Lib_MerkleTree.spec.ts @@ -0,0 +1,200 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Contract, BigNumber } from 'ethers' +import { MerkleTree } from 'merkletreejs' +import { fromHexString, toHexString } from '@eth-optimism/core-utils' + +/* Internal Imports */ +import { NON_NULL_BYTES32 } from '../../../helpers' + +const NODE_COUNTS = [ + 2, + 3, + 7, + 9, + 13, + 63, + 64, + 123, + 128, + 129, + 255, + 1021, + 1023, + 1024, +] + +const hash = (el: Buffer | string): Buffer => { + return Buffer.from(ethers.utils.keccak256(el).slice(2), 'hex') +} + +const fillDefaultHashes = (elements: string[]): string[] => { + const filled: string[] = [] + + for (let i = 0; i < Math.pow(2, Math.ceil(Math.log2(elements.length))); i++) { + if (i < elements.length) { + filled.push(elements[i]) + } else { + filled.push(ethers.utils.keccak256('0x' + '00'.repeat(32))) + } + } + + return filled +} + +describe('Lib_MerkleTree', () => { + let Lib_MerkleTree: Contract + before(async () => { + Lib_MerkleTree = await ( + await ethers.getContractFactory('TestLib_MerkleTree') + ).deploy() + }) + + describe('getMerkleRoot', () => { + describe('when no elements are provided', () => { + const elements = [] + + it('should revert', async () => { + await expect(Lib_MerkleTree.getMerkleRoot(elements)).to.be.revertedWith( + 'Lib_MerkleTree: Must provide at least one leaf hash.' + ) + }) + }) + + describe('when a single element is provided', () => { + const elements = [ethers.utils.keccak256('0x1234')] + + it('should return the input element', async () => { + expect(await Lib_MerkleTree.getMerkleRoot(elements)).to.equal( + elements[0] + ) + }) + }) + + describe('when more than one element is provided', () => { + for (const size of NODE_COUNTS) { + it(`should generate the correct root when ${size} elements are provided`, async () => { + const elements = [...Array(size)].map((_, i) => { + return ethers.utils.keccak256(BigNumber.from(i).toHexString()) + }) + + const bufs = fillDefaultHashes(elements).map((element) => { + return fromHexString(element) + }) + + const tree = new MerkleTree(bufs, hash) + + expect(await Lib_MerkleTree.getMerkleRoot(bufs)).to.equal( + toHexString(tree.getRoot()) + ) + }) + } + }) + }) + + describe('verify', () => { + describe('when total elements is zero', () => { + const totalLeaves = 0 + + it('should revert', async () => { + await expect( + Lib_MerkleTree.verify( + ethers.constants.HashZero, + ethers.constants.HashZero, + 0, + [], + totalLeaves + ) + ).to.be.revertedWith( + 'Lib_MerkleTree: Total leaves must be greater than zero.' + ) + }) + }) + + describe('when an index is out of bounds', () => { + const totalLeaves = 1 + const index = 2 + + it('should revert', async () => { + await expect( + Lib_MerkleTree.verify( + ethers.constants.HashZero, + ethers.constants.HashZero, + index, + [], + totalLeaves + ) + ).to.be.revertedWith('Lib_MerkleTree: Index out of bounds.') + }) + }) + + describe('when total siblings does not match provided total leaves', () => { + const totalLeaves = 8 + const siblings = [ethers.constants.HashZero, ethers.constants.HashZero] + + it('should revert', async () => { + await expect( + Lib_MerkleTree.verify( + ethers.constants.HashZero, + ethers.constants.HashZero, + 0, + siblings, + totalLeaves + ) + ).to.be.revertedWith( + 'Lib_MerkleTree: Total siblings does not correctly correspond to total leaves.' + ) + }) + }) + + describe('with valid proof for a single element', () => { + const root = NON_NULL_BYTES32 + const leaf = NON_NULL_BYTES32 + const index = 0 + const siblings = [] + const totalLeaves = 1 + + it('should succeed', async () => { + expect( + await Lib_MerkleTree.verify(root, leaf, index, siblings, totalLeaves) + ).to.equal(true) + }) + }) + + describe('with valid proof for more than one element', () => { + for (const size of NODE_COUNTS) { + describe(`for a tree with ${size} total elements`, () => { + const elements = [...Array(size)].map((_, i) => { + return ethers.utils.keccak256(BigNumber.from(i).toHexString()) + }) + + const bufs = fillDefaultHashes(elements).map((element) => { + return fromHexString(element) + }) + + const tree = new MerkleTree(bufs, hash) + + for (let i = 0; i < size; i += Math.ceil(size / 8)) { + it(`should verify a proof for the ${i}(th/st/rd, whatever) element`, async () => { + const proof = tree.getProof(bufs[i], i).map((element) => { + return element.data + }) + + expect( + await Lib_MerkleTree.verify( + tree.getRoot(), + bufs[i], + i, + proof, + size + ) + ).to.equal(true) + }) + } + }) + } + }) + }) +}) diff --git a/packages/contracts/test/contracts/mockOVM/verification/mockOVM_BondManager.spec.ts b/packages/contracts/test/contracts/mockOVM/verification/mockOVM_BondManager.spec.ts new file mode 100644 index 000000000000..6896aaf56ba5 --- /dev/null +++ b/packages/contracts/test/contracts/mockOVM/verification/mockOVM_BondManager.spec.ts @@ -0,0 +1,46 @@ +import { expect } from '../../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Signer, Contract } from 'ethers' + +/* Internal Imports */ +import { makeAddressManager } from '../../../helpers' + +describe('mockOVM_BondManager', () => { + let sequencer: Signer + let nonSequencer: Signer + before(async () => { + ;[sequencer, nonSequencer] = await ethers.getSigners() + }) + + let AddressManager: Contract + before(async () => { + AddressManager = await makeAddressManager() + }) + + let mockOVM_BondManager: Contract + before(async () => { + mockOVM_BondManager = await ( + await ethers.getContractFactory('mockOVM_BondManager') + ).deploy(AddressManager.address) + + AddressManager.setAddress('OVM_Proposer', await sequencer.getAddress()) + }) + + describe('isCollateralized', () => { + it('should return true for OVM_Proposer', async () => { + expect( + await mockOVM_BondManager.isCollateralized(await sequencer.getAddress()) + ).to.equal(true) + }) + + it('should return false for non-sequencer', async () => { + expect( + await mockOVM_BondManager.isCollateralized( + await nonSequencer.getAddress() + ) + ).to.equal(false) + }) + }) +}) diff --git a/packages/contracts/test/data/index.ts b/packages/contracts/test/data/index.ts new file mode 100644 index 000000000000..8a4a1f7e65b8 --- /dev/null +++ b/packages/contracts/test/data/index.ts @@ -0,0 +1,9 @@ +export { tests as Lib_RLPWriter_TEST_JSON } from './json/libraries/rlp/Lib_RLPWriter.test.json' +export { tests as Lib_RLPReader_TEST_JSON } from './json/libraries/rlp/Lib_RLPReader.test.json' +export { tests as Lib_Bytes32Utils_TEST_JSON } from './json/libraries/utils/Lib_Bytes32Utils.test.json' +export { tests as Lib_BytesUtils_TEST_JSON } from './json/libraries/utils/Lib_BytesUtils.test.json' +export { tests as Lib_ECDSAUtils_TEST_JSON } from './json/libraries/utils/Lib_ECDSAUtils.test.json' +export { tests as Lib_MerkleTrie_TEST_JSON } from './json/libraries/trie/Lib_MerkleTrie.test.json' +export { tests as Lib_OVMCodec_TEST_JSON } from './json/libraries/codec/Lib_OVMCodec.test.json' +export { tests as CREATE2_TEST_JSON } from './json/create2.test.json' +export { tests as SAFETY_CHECKER_TEST_JSON } from './json/safety-checker.test.json' diff --git a/packages/contracts/test/data/json/create2.test.json b/packages/contracts/test/data/json/create2.test.json new file mode 100644 index 000000000000..84c843781ff8 --- /dev/null +++ b/packages/contracts/test/data/json/create2.test.json @@ -0,0 +1,61 @@ +{ + "source": "https://eips.ethereum.org/EIPS/eip-1014", + "notes": "added additional tests with more bytecode", + "date": "2020-01-10", + "tests": { + "all zero values": { + "address": "0x0000000000000000000000000000000000000000", + "salt": "0x0000000000000000000000000000000000000000000000000000000000000000", + "init_code": "0x00", + "result": "0x4D1A2e2bB4F88F0250f26Ffff098B0b30B26BF38" + }, + "non-zero address": { + "address": "0xdeadbeef00000000000000000000000000000000", + "salt": "0x0000000000000000000000000000000000000000000000000000000000000000", + "init_code": "0x00", + "result": "0xB928f69Bb1D91Cd65274e3c79d8986362984fDA3" + }, + "non-zero address and salt": { + "address": "0xdeadbeef00000000000000000000000000000000", + "salt": "0x000000000000000000000000feed000000000000000000000000000000000000", + "init_code": "0x00", + "result": "0xD04116cDd17beBE565EB2422F2497E06cC1C9833" + }, + "non-zero init code": { + "address": "0x0000000000000000000000000000000000000000", + "salt": "0x0000000000000000000000000000000000000000000000000000000000000000", + "init_code": "0xdeadbeef", + "result": "0x70f2b2914A2a4b783FaEFb75f459A580616Fcb5e" + }, + "non-zero address, salt, and short init code": { + "address": "0x00000000000000000000000000000000deadbeef", + "salt": "0x00000000000000000000000000000000000000000000000000000000cafebabe", + "init_code": "0xdeadbeef", + "result": "0x60f3f640a8508fC6a86d45DF051962668E1e8AC7" + }, + "non-zero address, salt, and medium init code": { + "address": "0x00000000000000000000000000000000deadbeef", + "salt": "0x00000000000000000000000000000000000000000000000000000000cafebabe", + "init_code": "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef", + "result": "0x1d8bfDC5D46DC4f61D6b6115972536eBE6A8854C" + }, + "non-zero address, salt, and long init code": { + "address": "0x00000000000000000000000000000000deadbeef", + "salt": "0x00000000000000000000000000000000000000000000000000000000cafebabe", + "init_code": "0x61309c56600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526366d38203600051141561013b57602060046101403734156100b457600080fd5b60043560205181106100c557600080fd5b506000610140511415600654156007541516166100e157600080fd5b33600755610140516006557f556e6973776170205631000000000000000000000000000000000000000000006000557f554e492d563100000000000000000000000000000000000000000000000000006001556012600255005b63422f104360005114156105ab5760606004610140376000341160006101605111164261018051111661016d57600080fd5b6003546101a05260006101a051111561043e576000610140511161019057600080fd5b343031101561019e57600080fd5b343031036103a0526006543b6101b357600080fd5b6006543014156101c257600080fd5b602061046060246370a082316103e05230610400526103fc6006545afa6101e857600080fd5b600050610460516103c0526103a05161020057600080fd5b6103a05134151561021257600061022f565b6103c051346103c0513402041461022857600080fd5b6103c05134025b0460016103a05161023f57600080fd5b6103a05134151561025157600061026e565b6103c051346103c0513402041461026757600080fd5b6103c05134025b0401101561027b57600080fd5b60016103a05161028a57600080fd5b6103a05134151561029c5760006102b9565b6103c051346103c051340204146102b257600080fd5b6103c05134025b0401610480526103a0516102cc57600080fd5b6103a0513415156102de5760006102fb565b6101a051346101a051340204146102f457600080fd5b6101a05134025b046104a052610140516104a0511015610480516101605110151661031e57600080fd5b60043360e05260c052604060c02080546104a051825401101561034057600080fd5b6104a0518154018155506101a0516104a0516101a05101101561036257600080fd5b6104a0516101a051016003556006543b61037b57600080fd5b60065430141561038a57600080fd5b602061058060646323b872dd6104c052336104e052306105005261048051610520526104dc60006006545af16103bf57600080fd5b600050610580516103cf57600080fd5b6104805134337f06239653922ac7bea6aa2b19dc486b9361821d37712eb796adfd38d81de278ca60006000a46104a0516105a0523360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206105a0a36104a05160005260206000f36105a9565b633b9aca003410156000600654141560006007541415161661045f57600080fd5b306007543b61046d57600080fd5b60075430141561047c57600080fd5b602061024060246306f2bf626101c0526006546101e0526101dc6007545afa6104a457600080fd5b60005061024051146104b557600080fd5b6101605161026052303161028052610280516003556102805160043360e05260c052604060c020556006543b6104ea57600080fd5b6006543014156104f957600080fd5b602061036060646323b872dd6102a052336102c052306102e05261026051610300526102bc60006006545af161052e57600080fd5b6000506103605161053e57600080fd5b6102605134337f06239653922ac7bea6aa2b19dc486b9361821d37712eb796adfd38d81de278ca60006000a461028051610380523360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6020610380a36102805160005260206000f35b005b63f88bf15a600051141561084a57608060046101403734156105cc57600080fd5b600061018051116000610160511116426101a051116000610140511116166105f357600080fd5b6003546101c05260006101c0511161060a57600080fd5b6006543b61061757600080fd5b60065430141561062657600080fd5b602061028060246370a0823161020052306102205261021c6006545afa61064c57600080fd5b600050610280516101e0526101c05161066457600080fd5b6101c051610140511515610679576000610699565b30316101405130316101405102041461069157600080fd5b303161014051025b046102a0526101c0516106ab57600080fd5b6101c0516101405115156106c05760006106e6565b6101e051610140516101e051610140510204146106dc57600080fd5b6101e05161014051025b046102c052610180516102c0511015610160516102a05110151661070957600080fd5b60043360e05260c052604060c020610140518154101561072857600080fd5b61014051815403815550610140516101c051101561074557600080fd5b610140516101c0510360035560006000600060006102a051336000f161076a57600080fd5b6006543b61077757600080fd5b60065430141561078657600080fd5b6020610380604463a9059cbb6102e05233610300526102c051610320526102fc60006006545af16107b657600080fd5b600050610380516107c657600080fd5b6102c0516102a051337f0fbf06c058b90cb038a618f8c2acbf6145f8b3570fd1fa56abb8f0f3f05b36e860006000a4610140516103a0526000337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206103a0a360406103c0526103e06102a05181526102c0518160200152506103c0516103e0f3005b6000156109c6575b6101a05261014052610160526101805260006101805111600061016051111661087a57600080fd5b61014051151561088b5760006108ae565b6103e5610140516103e5610140510204146108a557600080fd5b6103e561014051025b6101c0526101c05115156108c35760006108e9565b610180516101c051610180516101c0510204146108df57600080fd5b610180516101c051025b6101e0526101605115156108fe576000610921565b6103e8610160516103e86101605102041461091857600080fd5b6103e861016051025b6101c051610160511515610936576000610959565b6103e8610160516103e86101605102041461095057600080fd5b6103e861016051025b01101561096557600080fd5b6101c05161016051151561097a57600061099d565b6103e8610160516103e86101605102041461099457600080fd5b6103e861016051025b0161020052610200516109af57600080fd5b610200516101e051046000526000516101a0515650005b600015610bf3575b6101a0526101405261016052610180526000610180511160006101605111166109f657600080fd5b610160511515610a07576000610a2d565b61014051610160516101405161016051020414610a2357600080fd5b6101405161016051025b1515610a3a576000610af6565b6103e8610160511515610a4e576000610a74565b61014051610160516101405161016051020414610a6a57600080fd5b6101405161016051025b6103e8610160511515610a88576000610aae565b61014051610160516101405161016051020414610aa457600080fd5b6101405161016051025b020414610aba57600080fd5b6103e8610160511515610ace576000610af4565b61014051610160516101405161016051020414610aea57600080fd5b6101405161016051025b025b6101c05261014051610180511015610b0d57600080fd5b6101405161018051031515610b23576000610b8e565b6103e561014051610180511015610b3957600080fd5b6101405161018051036103e561014051610180511015610b5857600080fd5b610140516101805103020414610b6d57600080fd5b6103e561014051610180511015610b8357600080fd5b610140516101805103025b6101e0526101e051610b9f57600080fd5b6101e0516101c0510460016101e051610bb757600080fd5b6101e0516101c05104011015610bcc57600080fd5b60016101e051610bdb57600080fd5b6101e0516101c05104016000526000516101a0515650005b600015610df4575b6101e0526101405261016052610180526101a0526101c0526000610160511160006101405111164261018051101516610c3357600080fd5b6006543b610c4057600080fd5b600654301415610c4f57600080fd5b60206102a060246370a0823161022052306102405261023c6006545afa610c7557600080fd5b6000506102a051610200526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516389f2a8716102e05261014051610300526101405130311015610cd657600080fd5b6101405130310361032052610200516103405261034051610320516103005160065801610852565b6103a0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103a0516102c052610160516102c0511015610d5157600080fd5b6006543b610d5e57600080fd5b600654301415610d6d57600080fd5b6020610460604463a9059cbb6103c0526101c0516103e0526102c051610400526103dc60006006545af1610da057600080fd5b60005061046051610db057600080fd5b6102c051610140516101a0517fcd60aa75dea3072fbc07ae6d7d856b5dc5f4eee88854f5b4abf7b680ef8bc50f60006000a46102c0516000526000516101e0515650005b63f39b5b9b6000511415610e715760406004610140376101405161016051638c717a3361018052346101a052610140516101c052610160516101e0523361020052336102205261022051610200516101e0516101c0516101a05160065801610bfb565b6102805261016052610140526102805160005260206000f3005b63ad65d76d6000511415610f245760606004610140376044356020518110610e9857600080fd5b5060006101805114153061018051141516610eb257600080fd5b610140516101605161018051638c717a336101a052346101c052610140516101e0526101605161020052336102205261018051610240526102405161022051610200516101e0516101c05160065801610bfb565b6102a0526101805261016052610140526102a05160005260206000f3005b60001561116c575b6101e0526101405261016052610180526101a0526101c0526000610160511160006101405111164261018051101516610f6457600080fd5b6006543b610f7157600080fd5b600654301415610f8057600080fd5b60206102a060246370a0823161022052306102405261023c6006545afa610fa657600080fd5b6000506102a051610200526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c05163fd11c2236102e0526101405161030052610160513031101561100757600080fd5b61016051303103610320526102005161034052610340516103205161030051600658016109ce565b6103a0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103a0516102c05260016102c051026103e0526103e05161016051101561108d57600080fd5b6103e05161016051036103c05260006103c05111156110c35760006000600060006103c0516101a0516000f16110c257600080fd5b5b6006543b6110d057600080fd5b6006543014156110df57600080fd5b60206104a0604463a9059cbb610400526101c05161042052610140516104405261041c60006006545af161111257600080fd5b6000506104a05161112257600080fd5b6101405160016102c051026101a0517fcd60aa75dea3072fbc07ae6d7d856b5dc5f4eee88854f5b4abf7b680ef8bc50f60006000a460016102c051026000526000516101e0515650005b636b1d4db760005114156111e95760406004610140376101405161016051632dff394e61018052610140516101a052346101c052610160516101e0523361020052336102205261022051610200516101e0516101c0516101a05160065801610f2c565b6102805261016052610140526102805160005260206000f3005b630b573638600051141561129c576060600461014037604435602051811061121057600080fd5b506000610180511415306101805114151661122a57600080fd5b610140516101605161018051632dff394e6101a052610140516101c052346101e0526101605161020052336102205261018051610240526102405161022051610200516101e0516101c05160065801610f2c565b6102a0526101805261016052610140526102a05160005260206000f3005b6000156114b3575b6101e0526101405261016052610180526101a0526101c05260006101605111600061014051111642610180511015166112dc57600080fd5b6006543b6112e957600080fd5b6006543014156112f857600080fd5b60206102a060246370a0823161022052306102405261023c6006545afa61131e57600080fd5b6000506102a051610200526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516389f2a8716102e0526101405161030052610200516103205230316103405261034051610320516103005160065801610852565b6103a0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103a0516102c05260016102c051026103c052610160516103c05110156113ef57600080fd5b60006000600060006103c0516101c0516000f161140b57600080fd5b6006543b61141857600080fd5b60065430141561142757600080fd5b60206104a060646323b872dd6103e0526101a05161040052306104205261014051610440526103fc60006006545af161145f57600080fd5b6000506104a05161146f57600080fd5b6103c051610140516101a0517f7f4091b46c33e918a0f3aa42307641d17bb67029427a5369e54b35398423870560006000a46103c0516000526000516101e0515650005b6395e3c50b600051141561154657606060046101403734156114d457600080fd5b61014051610160516101805163fa1bb7be6101a052610140516101c052610160516101e0526101805161020052336102205233610240526102405161022051610200516101e0516101c051600658016112a4565b6102a0526101805261016052610140526102a05160005260206000f3005b637237e031600051141561160f576080600461014037341561156757600080fd5b606435602051811061157857600080fd5b5060006101a0511415306101a05114151661159257600080fd5b6101405161016051610180516101a05163fa1bb7be6101c052610140516101e0526101605161020052610180516102205233610240526101a05161026052610260516102405161022051610200516101e051600658016112a4565b6102c0526101a0526101805261016052610140526102c05160005260206000f3005b600015611813575b6101e0526101405261016052610180526101a0526101c05260006101405111426101805110151661164757600080fd5b6006543b61165457600080fd5b60065430141561166357600080fd5b60206102a060246370a0823161022052306102405261023c6006545afa61168957600080fd5b6000506102a051610200526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c05163fd11c2236102e05261014051610300526102005161032052303161034052610340516103205161030051600658016109ce565b6103a0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103a0516102c0526102c05161016051101561174f57600080fd5b6000600060006000610140516101c0516000f161176b57600080fd5b6006543b61177857600080fd5b60065430141561178757600080fd5b602061048060646323b872dd6103c0526101a0516103e05230610400526102c051610420526103dc60006006545af16117bf57600080fd5b600050610480516117cf57600080fd5b610140516102c0516101a0517f7f4091b46c33e918a0f3aa42307641d17bb67029427a5369e54b35398423870560006000a46102c0516000526000516101e0515650005b63013efd8b60005114156118a6576060600461014037341561183457600080fd5b61014051610160516101805163984fe8f66101a052610140516101c052610160516101e0526101805161020052336102205233610240526102405161022051610200516101e0516101c05160065801611617565b6102a0526101805261016052610140526102a05160005260206000f3005b63d4e4841d600051141561196f57608060046101403734156118c757600080fd5b60643560205181106118d857600080fd5b5060006101a0511415306101a0511415166118f257600080fd5b6101405161016051610180516101a05163984fe8f66101c052610140516101e0526101605161020052610180516102205233610240526101a05161026052610260516102405161022051610200516101e05160065801611617565b6102c0526101a0526101805261016052610140526102c05160005260206000f3005b600015611c0a575b610220526101405261016052610180526101a0526101c0526101e0526102005260006101805111600061016051111660006101405111426101a051101516166119bf57600080fd5b600061020051141530610200511415166119d857600080fd5b6006543b6119e557600080fd5b6006543014156119f457600080fd5b60206102e060246370a0823161026052306102805261027c6006545afa611a1a57600080fd5b6000506102e051610240526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e051610300516389f2a871610320526101405161034052610240516103605230316103805261038051610360516103405160065801610852565b6103e052610300526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103e05161030052600161030051026104005261018051610400511015611afb57600080fd5b6006543b611b0857600080fd5b600654301415611b1757600080fd5b60206104e060646323b872dd610420526101c051610440523061046052610140516104805261043c60006006545af1611b4f57600080fd5b6000506104e051611b5f57600080fd5b610200513b611b6d57600080fd5b61020051301415611b7d57600080fd5b60206105e0606463ad65d76d6105205261016051610540526101a051610560526101e0516105805261053c61040051610200515af1611bbb57600080fd5b6000506105e0516105005261040051610140516101c0517f7f4091b46c33e918a0f3aa42307641d17bb67029427a5369e54b35398423870560006000a461050051600052600051610220515650005b63ddf7e1a76000511415611d575760a06004610140373415611c2b57600080fd5b6084356020518110611c3c57600080fd5b506007543b611c4a57600080fd5b600754301415611c5957600080fd5b602061028060246306f2bf62610200526101c0516102205261021c6007545afa611c8257600080fd5b600050610280516101e0526101405161016051610180516101a0516101c0516101e051610200516102205161024051610260516102805163204ea33b6102a052610140516102c052610160516102e05261018051610300526101a05161032052336103405233610360526101e0516103805261038051610360516103405161032051610300516102e0516102c05160065801611977565b6103e05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103e05160005260206000f3005b63f552d91b6000511415611ec15760c06004610140373415611d7857600080fd5b6084356020518110611d8957600080fd5b5060a4356020518110611d9b57600080fd5b506007543b611da957600080fd5b600754301415611db857600080fd5b60206102a060246306f2bf62610220526101e0516102405261023c6007545afa611de157600080fd5b6000506102a051610200526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a05163204ea33b6102c052610140516102e052610160516103005261018051610320526101a0516103405233610360526101c05161038052610200516103a0526103a05161038051610360516103405161032051610300516102e05160065801611977565b610400526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526104005160005260206000f3005b6000156121d7575b610220526101405261016052610180526101a0526101c0526101e05261020052600061018051116000610140511116426101a051101516611f0957600080fd5b60006102005114153061020051141516611f2257600080fd5b610200513b611f3057600080fd5b61020051301415611f4057600080fd5b60206102e060246359e9486261026052610140516102805261027c610200515afa611f6a57600080fd5b6000506102e051610240526006543b611f8257600080fd5b600654301415611f9157600080fd5b60206103a060246370a0823161032052306103405261033c6006545afa611fb757600080fd5b6000506103a051610300526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05161030051610320516103405161036051610380516103a0516103c05163fd11c2236103e05261024051610400526103005161042052303161044052610440516104205161040051600658016109ce565b6104a0526103c0526103a05261038052610360526103405261032052610300526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526104a0516103c052610240516101805110156103c051610160511015166120c857600080fd5b6006543b6120d557600080fd5b6006543014156120e457600080fd5b602061058060646323b872dd6104c0526101c0516104e05230610500526103c051610520526104dc60006006545af161211c57600080fd5b6000506105805161212c57600080fd5b610200513b61213a57600080fd5b6102005130141561214a57600080fd5b60206106806064630b5736386105c052610140516105e0526101a051610600526101e051610620526105dc61024051610200515af161218857600080fd5b600050610680516105a052610240516103c0516101c0517f7f4091b46c33e918a0f3aa42307641d17bb67029427a5369e54b35398423870560006000a46103c051600052600051610220515650005b63b040d54560005114156123245760a060046101403734156121f857600080fd5b608435602051811061220957600080fd5b506007543b61221757600080fd5b60075430141561222657600080fd5b602061028060246306f2bf62610200526101c0516102205261021c6007545afa61224f57600080fd5b600050610280516101e0526101405161016051610180516101a0516101c0516101e0516102005161022051610240516102605161028051631a7b28f26102a052610140516102c052610160516102e05261018051610300526101a05161032052336103405233610360526101e0516103805261038051610360516103405161032051610300516102e0516102c05160065801611ec9565b6103e05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103e05160005260206000f3005b63f3c0efe9600051141561248e5760c0600461014037341561234557600080fd5b608435602051811061235657600080fd5b5060a435602051811061236857600080fd5b506007543b61237657600080fd5b60075430141561238557600080fd5b60206102a060246306f2bf62610220526101e0516102405261023c6007545afa6123ae57600080fd5b6000506102a051610200526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a051631a7b28f26102c052610140516102e052610160516103005261018051610320526101a0516103405233610360526101c05161038052610200516103a0526103a05161038051610360516103405161032051610300516102e05160065801611ec9565b610400526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526104005160005260206000f3005b63b1cb43bf600051141561255b5760a060046101403734156124af57600080fd5b60843560205181106124c057600080fd5b506101405161016051610180516101a0516101c05163204ea33b6101e0526101405161020052610160516102205261018051610240526101a051610260523361028052336102a0526101c0516102c0526102c0516102a051610280516102605161024051610220516102005160065801611977565b610320526101c0526101a0526101805261016052610140526103205160005260206000f3005b63ec384a3e60005114156126555760c0600461014037341561257c57600080fd5b608435602051811061258d57600080fd5b5060a435602051811061259f57600080fd5b50306101c05114156125b057600080fd5b6101405161016051610180516101a0516101c0516101e05163204ea33b610200526101405161022052610160516102405261018051610260526101a05161028052336102a0526101c0516102c0526101e0516102e0526102e0516102c0516102a0516102805161026051610240516102205160065801611977565b610340526101e0526101c0526101a0526101805261016052610140526103405160005260206000f3005b63ea650c7d60005114156127225760a0600461014037341561267657600080fd5b608435602051811061268757600080fd5b506101405161016051610180516101a0516101c051631a7b28f26101e0526101405161020052610160516102205261018051610240526101a051610260523361028052336102a0526101c0516102c0526102c0516102a051610280516102605161024051610220516102005160065801611ec9565b610320526101c0526101a0526101805261016052610140526103205160005260206000f3005b63981a1327600051141561281c5760c0600461014037341561274357600080fd5b608435602051811061275457600080fd5b5060a435602051811061276657600080fd5b50306101c051141561277757600080fd5b6101405161016051610180516101a0516101c0516101e051631a7b28f2610200526101405161022052610160516102405261018051610260526101a05161028052336102a0526101c0516102c0526101e0516102e0526102e0516102c0516102a0516102805161026051610240516102205160065801611ec9565b610340526101e0526101c0526101a0526101805261016052610140526103405160005260206000f3005b63cd7724c36000511415612918576020600461014037341561283d57600080fd5b6000610140511161284d57600080fd5b6006543b61285a57600080fd5b60065430141561286957600080fd5b602061020060246370a0823161018052306101a05261019c6006545afa61288f57600080fd5b60005061020051610160526101405161016051610180516101a0516101c0516101e051610200516389f2a871610220526101405161024052303161026052610160516102805261028051610260516102405160065801610852565b6102e052610200526101e0526101c0526101a0526101805261016052610140526102e05160005260206000f3005b6359e948626000511415612a27576020600461014037341561293957600080fd5b6000610140511161294957600080fd5b6006543b61295657600080fd5b60065430141561296557600080fd5b602061020060246370a0823161018052306101a05261019c6006545afa61298b57600080fd5b60005061020051610160526101405161016051610180516101a0516101c0516101e051610200516102205163fd11c223610240526101405161026052303161028052610160516102a0526102a0516102805161026051600658016109ce565b6103005261022052610200526101e0526101c0526101a05261018052610160526101405261030051610220526001610220510260005260206000f3005b6395b68fe76000511415612b365760206004610140373415612a4857600080fd5b60006101405111612a5857600080fd5b6006543b612a6557600080fd5b600654301415612a7457600080fd5b602061020060246370a0823161018052306101a05261019c6006545afa612a9a57600080fd5b60005061020051610160526101405161016051610180516101a0516101c0516101e05161020051610220516389f2a871610240526101405161026052610160516102805230316102a0526102a051610280516102605160065801610852565b6103005261022052610200526101e0526101c0526101a05261018052610160526101405261030051610220526001610220510260005260206000f3005b632640f62c6000511415612c325760206004610140373415612b5757600080fd5b60006101405111612b6757600080fd5b6006543b612b7457600080fd5b600654301415612b8357600080fd5b602061020060246370a0823161018052306101a05261019c6006545afa612ba957600080fd5b60005061020051610160526101405161016051610180516101a0516101c0516101e0516102005163fd11c2236102205261014051610240526101605161026052303161028052610280516102605161024051600658016109ce565b6102e052610200526101e0526101c0526101a0526101805261016052610140526102e05160005260206000f3005b639d76ea586000511415612c58573415612c4b57600080fd5b60065460005260206000f3005b63966dae0e6000511415612c7e573415612c7157600080fd5b60075460005260206000f3005b6370a082316000511415612ccd5760206004610140373415612c9f57600080fd5b6004356020518110612cb057600080fd5b5060046101405160e05260c052604060c0205460005260206000f3005b63a9059cbb6000511415612d985760406004610140373415612cee57600080fd5b6004356020518110612cff57600080fd5b5060043360e05260c052604060c0206101605181541015612d1f57600080fd5b6101605181540381555060046101405160e05260c052604060c0208054610160518254011015612d4e57600080fd5b61016051815401815550610160516101805261014051337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6020610180a3600160005260206000f3005b6323b872dd6000511415612eb35760606004610140373415612db957600080fd5b6004356020518110612dca57600080fd5b506024356020518110612ddc57600080fd5b5060046101405160e05260c052604060c0206101805181541015612dff57600080fd5b6101805181540381555060046101605160e05260c052604060c0208054610180518254011015612e2e57600080fd5b6101805181540181555060056101405160e05260c052604060c0203360e05260c052604060c0206101805181541015612e6657600080fd5b61018051815403815550610180516101a05261016051610140517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206101a0a3600160005260206000f3005b63095ea7b36000511415612f485760406004610140373415612ed457600080fd5b6004356020518110612ee557600080fd5b506101605160053360e05260c052604060c0206101405160e05260c052604060c02055610160516101805261014051337f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9256020610180a3600160005260206000f3005b63dd62ed3e6000511415612fb85760406004610140373415612f6957600080fd5b6004356020518110612f7a57600080fd5b506024356020518110612f8c57600080fd5b5060056101405160e05260c052604060c0206101605160e05260c052604060c0205460005260206000f3005b6306fdde036000511415612fde573415612fd157600080fd5b60005460005260206000f3005b6395d89b416000511415613004573415612ff757600080fd5b60015460005260206000f3005b63313ce567600051141561302a57341561301d57600080fd5b60025460005260206000f3005b6318160ddd600051141561305057341561304357600080fd5b60035460005260206000f3005b638c717a33610140523461016052600161018052426101a052336101c052336101e0526101e0516101c0516101a051610180516101605160065801610bfb565b610240526102405b61000461309c0361000460003961000461309c036000f3", + "result": "0x27ff8bbb55a2b5cfd4fb7c350ed6a6a2cdbed5d9" + }, + "non-zero address, salt, and very long init code": { + "address": "0x00000000000000000000000000000000deadbeef", + "salt": "0x00000000000000000000000000000000000000000000000000000000cafebabe", + "init_code": "0x60806040526016805460a060020a61ffff02191675010000000000000000000000000000000000000000001790553480156200003a57600080fd5b5060405161016080620062768339810160408181528251602080850151838601516060870151608088015160a089015160c08a015160e08b01516101008c01516101208d0151610140909d01518b8d018c5260178d527f53796e746865746978204e6574776f726b20546f6b656e0000000000000000008a8e01528b51808d01909c5260038c527f534e580000000000000000000000000000000000000000000000000000000000998c0199909952989b969a9599949893979296919590949192918c918c918460128d86818080600160a060020a03811615156200018057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f74206265203000000000000000604482015290519081900360640190fd5b60008054600160a060020a031916600160a060020a038316908117825560408051928352602083019190915280517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9281900390910190a150600160a060020a03811615156200025157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f776e6572206d757374206e6f74206265207a65726f00000000000000000000604482015290519081900360640190fd5b60038054600160a060020a038316610100810261010060a860020a03199092169190911790915560408051918252517fd5da63a0b864b315bc04128dedbc93888c8529ee6cf47ce664dc204339228c539181900360200190a15060048054600160a060020a038416600160a060020a0319909116811790915560408051918252517ffc80377ca9c49cc11ae6982f390a42db976d5530af7c43889264b13fbbd7c57e9181900360200190a15050600160075560088054600160a060020a031916600160a060020a038816179055845162000333906009906020880190620003f0565b5083516200034990600a906020870190620003f0565b5050600b91909155600c805460ff191660ff909216919091179055505060148054600160a060020a0319908116600160a060020a039d8e16179091556013805482169a8d169a909a179099555050601080548816968a16969096179095556015805487169489169490941790935560128054861692881692909217909155601180548516918716919091179055601680549093169416939093179055506200049592505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200043357805160ff191683800117855562000463565b8280016001018555821562000463579182015b828111156200046357825182559160200191906001019062000446565b506200047192915062000475565b5090565b6200049291905b808211156200047157600081556001016200047c565b90565b615dd180620004a56000396000f30060806040526004361061031e5763ffffffff60e060020a60003504166306fdde03811461032357806309231602146103ad578063095ea7b3146103c75780630b887dae146103ff5780631249c58b14610417578063131b0ae71461042c5780631627540c1461044d57806316b2213f1461046e57806317c70de4146104a157806318160ddd146104b657806319db2228146104cb5780631a5c6095146104ec5780631c8aa5fa1461050757806320714f881461052857806323b872dd14610549578063295da87d14610573578063313ce5671461058b57806332608039146105b65780633278c960146105ea5780633fc6df6e146105ff5780634ffcd9df1461061457806353a47bb71461062957806356e449541461063e578063654a60ac1461065f5780636ac0bf9c1461067d5780636b4dff1f1461069e57806370a08231146106b657806372cb051f146106d757806379ba50971461073c5780638357ce3614610751578063835e119c1461077557806383d625d41461078d578063849cf588146107a55780638a290014146107c65780638da5cb5b146107de57806394524096146107f357806395d89b411461080d578063961a929c1461082257806397107d6d146108375780639cb8a26a146108585780639cbdaeb61461086d5780639f76980714610882578063a311c7c2146108a3578063a430be6c146108c4578063a461fc82146108d9578063a5fdc5de146108ee578063a8913cdb1461090f578063a9059cbb14610933578063ab3e337d14610957578063ab67aa581461098a578063ae2e933b146109f9578063af086c7e14610a0e578063b8225dec14610a23578063bc67f83214610a38578063bd32aa4414610a59578063be45fd6214610a6e578063c40dd66f14610ad7578063c58aaae614610aec578063c9df6df514610b01578063d37c4d8b14610b1b578063d67bdd2514610b3f578063dbd4a42214610b54578063dbf6334014610b69578063dd62ed3e14610b7e578063e2fdcc1714610ba5578063e90dd9e214610bba578063ec55688914610bcf578063ee52a2f314610be4578063f534375214610c02578063fe7f7bc314610c17575b600080fd5b34801561032f57600080fd5b50610338610c2c565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561037257818101518382015260200161035a565b50505050905090810190601f16801561039f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103b957600080fd5b506103c5600435610cba565b005b3480156103d357600080fd5b506103eb600160a060020a0360043516602435610d79565b604080519115158252519081900360200190f35b34801561040b57600080fd5b506103c5600435610e7f565b34801561042357600080fd5b506103eb61128f565b34801561043857600080fd5b506103c5600160a060020a036004351661179c565b34801561045957600080fd5b506103c5600160a060020a0360043516611822565b34801561047a57600080fd5b5061048f600160a060020a03600435166118da565b60408051918252519081900360200190f35b3480156104ad57600080fd5b5061048f6118ec565b3480156104c257600080fd5b5061048f6118f2565b3480156104d757600080fd5b506103c5600160a060020a03600435166118f8565b3480156104f857600080fd5b5061048f6004356024356119c5565b34801561051357600080fd5b506103c5600160a060020a0360043516611b91565b34801561053457600080fd5b506103c5600160a060020a0360043516611c5e565b34801561055557600080fd5b506103eb600160a060020a0360043581169060243516604435611d8b565b34801561057f57600080fd5b506103c5600435611da4565b34801561059757600080fd5b506105a0611f89565b6040805160ff9092168252519081900360200190f35b3480156105c257600080fd5b506105ce600435611f92565b60408051600160a060020a039092168252519081900360200190f35b3480156105f657600080fd5b506103c5611fad565b34801561060b57600080fd5b506105ce61204b565b34801561062057600080fd5b506105ce61205a565b34801561063557600080fd5b506105ce612069565b34801561064a57600080fd5b506103c5600160a060020a0360043516612078565b34801561066b57600080fd5b5061048f600435602435604435612145565b34801561068957600080fd5b5061048f600160a060020a03600435166121ef565b3480156106aa57600080fd5b506103c5600435612444565b3480156106c257600080fd5b5061048f600160a060020a03600435166124a1565b3480156106e357600080fd5b506106ec612528565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610728578181015183820152602001610710565b505050509050019250505060405180910390f35b34801561074857600080fd5b506103c56125cc565b34801561075d57600080fd5b5061048f600160a060020a03600435166024356126c7565b34801561078157600080fd5b506105ce60043561270b565b34801561079957600080fd5b5061048f600435612733565b3480156107b157600080fd5b506103c5600160a060020a0360043516612a57565b3480156107d257600080fd5b506103c5600435612cc2565b3480156107ea57600080fd5b506105ce612e38565b3480156107ff57600080fd5b506103c56004351515612e47565b34801561081957600080fd5b50610338612f34565b34801561082e57600080fd5b5061048f612f8f565b34801561084357600080fd5b506103c5600160a060020a0360043516612f95565b34801561086457600080fd5b506103c561304d565b34801561087957600080fd5b506105ce6131c6565b34801561088e57600080fd5b506103c5600160a060020a03600435166131d5565b3480156108af57600080fd5b5061048f600160a060020a03600435166132a4565b3480156108d057600080fd5b506105ce6132f3565b3480156108e557600080fd5b5061048f613302565b3480156108fa57600080fd5b5061048f600160a060020a0360043516613309565b34801561091b57600080fd5b5061048f600160a060020a03600435166024356134a0565b34801561093f57600080fd5b506103eb600160a060020a0360043516602435613558565b34801561096357600080fd5b506103eb600160a060020a0360043581169060243590604435906064359060843516613567565b34801561099657600080fd5b50604080516020601f6064356004818101359283018490048402850184019095528184526103eb94600160a060020a0381358116956024803590921695604435953695608494019181908401838280828437509497506136f99650505050505050565b348015610a0557600080fd5b506105ce6137d6565b348015610a1a57600080fd5b506103c56137e5565b348015610a2f57600080fd5b506103eb6138e4565b348015610a4457600080fd5b506103c5600160a060020a03600435166138ed565b348015610a6557600080fd5b506103c5613988565b348015610a7a57600080fd5b50604080516020600460443581810135601f81018490048402850184019095528484526103eb948235600160a060020a0316946024803595369594606494920191908190840183828082843750949750613a359650505050505050565b348015610ae357600080fd5b506105ce613b1c565b348015610af857600080fd5b506105ce613b2b565b348015610b0d57600080fd5b506103c56004351515613b3f565b348015610b2757600080fd5b5061048f600160a060020a0360043516602435613c5d565b348015610b4b57600080fd5b506105ce613e89565b348015610b6057600080fd5b506105ce613e98565b348015610b7557600080fd5b5061048f613ea7565b348015610b8a57600080fd5b5061048f600160a060020a0360043581169060243516613eae565b348015610bb157600080fd5b506105ce613f54565b348015610bc657600080fd5b506105ce613f63565b348015610bdb57600080fd5b506105ce613f72565b348015610bf057600080fd5b506103eb600435602435604435613f81565b348015610c0e57600080fd5b506103eb61416e565b348015610c2357600080fd5b506105ce614190565b6009805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610cb25780601f10610c8757610100808354040283529160200191610cb2565b820191906000526020600020905b815481529060010190602001808311610c9557829003601f168201915b505050505081565b601854600160a060020a03163314610d1c576040805160e560020a62461bcd02815260206004820152601d60248201527f4f6e6c7920676173206c696d6974206f7261636c6520616c6c6f776564000000604482015290519081900360640190fd5b60008111610d74576040805160e560020a62461bcd02815260206004820152601a60248201527f4e6565647320746f2062652067726561746572207468616e2030000000000000604482015290519081900360640190fd5b601755565b6004546000908190600160a060020a03163314801590610da45750600554600160a060020a03163314155b8015610dbb5750600654600160a060020a03163314155b15610dd35760068054600160a060020a031916331790555b50600654600854604080517fda46098c000000000000000000000000000000000000000000000000000000008152600160a060020a0393841660048201819052878516602483015260448201879052915191939092169163da46098c91606480830192600092919082900301818387803b158015610e5057600080fd5b505af1158015610e64573d6000803e3d6000fd5b50505050610e7381858561419f565b600191505b5092915050565b6004546000908190600160a060020a03163314801590610eaa5750600554600160a060020a03163314155b8015610ec15750600654600160a060020a03163314155b15610ed95760068054600160a060020a031916331790555b600054600654600160a060020a03908116911614610f2f576040805160e560020a62461bcd0281526020600482015260136024820152600080516020615d86833981519152604482015290519081900360640190fd5b6000838152600e6020526040902054600160a060020a03161515610f9d576040805160e560020a62461bcd02815260206004820152601460248201527f53796e746820646f6573206e6f74206578697374000000000000000000000000604482015290519081900360640190fd5b6000838152600e602090815260408083205481517f18160ddd0000000000000000000000000000000000000000000000000000000081529151600160a060020a03909116936318160ddd93600480850194919392918390030190829087803b15801561100857600080fd5b505af115801561101c573d6000803e3d6000fd5b505050506040513d602081101561103257600080fd5b505115611089576040805160e560020a62461bcd02815260206004820152601360248201527f53796e746820737570706c792065786973747300000000000000000000000000604482015290519081900360640190fd5b60e960020a622c2229028314156110ea576040805160e560020a62461bcd02815260206004820152601760248201527f43616e6e6f742072656d6f7665205844522073796e7468000000000000000000604482015290519081900360640190fd5b60e260020a631cd554d10283141561114c576040805160e560020a62461bcd02815260206004820152601860248201527f43616e6e6f742072656d6f766520735553442073796e74680000000000000000604482015290519081900360640190fd5b50506000818152600e6020526040812054600160a060020a0316905b600d5481101561124f5781600160a060020a0316600d8281548110151561118b57fe5b600091825260209091200154600160a060020a0316141561124757600d8054829081106111b457fe5b60009182526020909120018054600160a060020a0319169055600d805460001981019081106111df57fe5b600091825260209091200154600d8054600160a060020a03909216918390811061120557fe5b60009182526020909120018054600160a060020a031916600160a060020a0392909216919091179055600d805490611241906000198301615cfe565b5061124f565b600101611168565b50506000818152600e602081815260408084208054600160a060020a03168552600f83529084208490559390925290528054600160a060020a0319169055565b601654600090819081908190600160a060020a031615156112fa576040805160e560020a62461bcd02815260206004820152601b60248201527f52657761726473446973747269627574696f6e206e6f74207365740000000000604482015290519081900360640190fd5b601560009054906101000a9004600160a060020a0316600160a060020a031663cc5c095c6040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561134d57600080fd5b505af1158015611361573d6000803e3d6000fd5b505050506040513d602081101561137757600080fd5b50519250600083116113d3576040805160e560020a62461bcd02815260206004820152601560248201527f4e6f20737570706c79206973206d696e7461626c650000000000000000000000604482015290519081900360640190fd5b601554604080517f7e7961d7000000000000000000000000000000000000000000000000000000008152600481018690529051600160a060020a0390921691637e7961d7916024808201926020929091908290030181600087803b15801561143a57600080fd5b505af115801561144e573d6000803e3d6000fd5b505050506040513d602081101561146457600080fd5b5050601554604080517f9bdd7ac70000000000000000000000000000000000000000000000000000000081529051600160a060020a0390921691639bdd7ac7916004808201926020929091908290030181600087803b1580156114c657600080fd5b505af11580156114da573d6000803e3d6000fd5b505050506040513d60208110156114f057600080fd5b50519150611504838363ffffffff61430716565b6008546016546040805160e060020a6370a08231028152600160a060020a03928316600482018190529151949550919092169263b46310f692916115a691869186916370a08231916024808201926020929091908290030181600087803b15801561156e57600080fd5b505af1158015611582573d6000803e3d6000fd5b505050506040513d602081101561159857600080fd5b50519063ffffffff61431e16565b6040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050600060405180830381600087803b1580156115f857600080fd5b505af115801561160c573d6000803e3d6000fd5b50506016546116289250309150600160a060020a031683614330565b601654604080517f59974e38000000000000000000000000000000000000000000000000000000008152600481018490529051600160a060020a03909216916359974e389160248082019260009290919082900301818387803b15801561168e57600080fd5b505af11580156116a2573d6000803e3d6000fd5b50506008546040805160e060020a6370a0823102815233600482018190529151600160a060020a03909316945063b46310f69350909161170791879186916370a082319160248083019260209291908290030181600087803b15801561156e57600080fd5b6040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050600060405180830381600087803b15801561175957600080fd5b505af115801561176d573d6000803e3d6000fd5b5050505061177c303384614330565b600b5461178f908463ffffffff61431e16565b600b556001935050505090565b600054600160a060020a03163314611800576040805160e560020a62461bcd02815260206004820152602f6024820152600080516020615d468339815191526044820152600080516020615d66833981519152606482015290519081900360840190fd5b60058054600160a060020a031916600160a060020a0392909216919091179055565b600054600160a060020a03163314611886576040805160e560020a62461bcd02815260206004820152602f6024820152600080516020615d468339815191526044820152600080516020615d66833981519152606482015290519081900360840190fd5b60018054600160a060020a038316600160a060020a0319909116811790915560408051918252517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229181900360200190a150565b600f6020526000908152604090205481565b60025481565b600b5481565b600454600160a060020a0316331480159061191e5750600554600160a060020a03163314155b80156119355750600654600160a060020a03163314155b1561194d5760068054600160a060020a031916331790555b600054600654600160a060020a039081169116146119a3576040805160e560020a62461bcd0281526020600482015260136024820152600080516020615d86833981519152604482015290519081900360640190fd5b60108054600160a060020a031916600160a060020a0392909216919091179055565b6000806000601060009054906101000a9004600160a060020a0316600160a060020a0316630f9b49556040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015611a1d57600080fd5b505af1158015611a31573d6000803e3d6000fd5b505050506040513d6020811015611a4757600080fd5b50519150600190507f7300000000000000000000000000000000000000000000000000000000000000600160f860020a031960f860020a600088901a0216148015611a9c575060e260020a631cd554d1028514155b8015611adb57507f6900000000000000000000000000000000000000000000000000000000000000600160f860020a031960f860020a600087901a0216145b80611b6d57507f6900000000000000000000000000000000000000000000000000000000000000600160f860020a031960f860020a600088901a0216148015611b2e575060e260020a631cd554d1028414155b8015611b6d57507f7300000000000000000000000000000000000000000000000000000000000000600160f860020a031960f860020a600087901a0216145b15611b76575060025b611b86828263ffffffff61443216565b92505b505092915050565b600454600160a060020a03163314801590611bb75750600554600160a060020a03163314155b8015611bce5750600654600160a060020a03163314155b15611be65760068054600160a060020a031916331790555b600054600654600160a060020a03908116911614611c3c576040805160e560020a62461bcd0281526020600482015260136024820152600080516020615d86833981519152604482015290519081900360640190fd5b60188054600160a060020a031916600160a060020a0392909216919091179055565b600054600160a060020a03163314611cc2576040805160e560020a62461bcd02815260206004820152602f6024820152600080516020615d468339815191526044820152600080516020615d66833981519152606482015290519081900360840190fd5b600160a060020a0381161515611d22576040805160e560020a62461bcd02815260206004820152601c60248201527f42656e6566696369617279206d757374206e6f74206265207a65726f00000000604482015290519081900360640190fd5b60038054600160a060020a038316610100810274ffffffffffffffffffffffffffffffffffffffff00199092169190911790915560408051918252517fd5da63a0b864b315bc04128dedbc93888c8529ee6cf47ce664dc204339228c539181900360200190a150565b60006060611d9b858585846136f9565b95945050505050565b60045460009081908190819081908190600160a060020a03163314801590611dd75750600554600160a060020a03163314155b8015611dee5750600654600160a060020a03163314155b15611e065760068054600160a060020a031916331790555b60e260020a631cd554d1029550611e27868860e960020a622c222902612145565b600654909550611e4990600160a060020a031660e960020a622c222902613c5d565b600654909450611e6290600160a060020a031687613c5d565b925060008411611ebc576040805160e560020a62461bcd02815260206004820152601260248201527f4e6f206465627420746f20666f72676976650000000000000000000000000000604482015290519081900360640190fd5b848410611ec95784611ecb565b835b9150611ed78285614460565b868310611ee45786611ee6565b825b6000878152600e60205260408082205460065482517f9dc29fac000000000000000000000000000000000000000000000000000000008152600160a060020a0391821660048201526024810186905292519495501692639dc29fac9260448084019391929182900301818387803b158015611f6057600080fd5b505af1158015611f74573d6000803e3d6000fd5b50505050611f806147be565b50505050505050565b600c5460ff1681565b600e60205260009081526040902054600160a060020a031681565b600054600160a060020a03163314612011576040805160e560020a62461bcd02815260206004820152602f6024820152600080516020615d468339815191526044820152600080516020615d66833981519152606482015290519081900360840190fd5b600060028190556003805460ff191690556040517f6adcc7125002935e0aa31697538ebbd65cfddf20431eb6ecdcfc3e238bfd082c9190a1565b601654600160a060020a031681565b601354600160a060020a031681565b600154600160a060020a031681565b600454600160a060020a0316331480159061209e5750600554600160a060020a03163314155b80156120b55750600654600160a060020a03163314155b156120cd5760068054600160a060020a031916331790555b600054600654600160a060020a03908116911614612123576040805160e560020a62461bcd0281526020600482015260136024820152600080516020615d86833981519152604482015290519081900360640190fd5b60138054600160a060020a031916600160a060020a0392909216919091179055565b601354604080517f654a60ac0000000000000000000000000000000000000000000000000000000081526004810186905260248101859052604481018490529051600092600160a060020a03169163654a60ac91606480830192602092919082900301818787803b1580156121b957600080fd5b505af11580156121cd573d6000803e3d6000fd5b505050506040513d60208110156121e357600080fd5b505190505b9392505050565b601354604080517e9919c000000000000000000000000000000000000000000000000000000000815260eb60020a620a69cb02600482018190529151600093849384939092600160a060020a0390921691629919c09160248082019260209290919082900301818887803b15801561226657600080fd5b505af115801561227a573d6000803e3d6000fd5b505050506040513d602081101561229057600080fd5b5051156122e7576040805160e560020a62461bcd02815260206004820152601960248201527f52617465207374616c65206f72206e6f7420612073796e746800000000000000604482015290519081900360640190fd5b6008546040805160e060020a6370a08231028152600160a060020a038881166004830152915191909216916370a082319160248083019260209291908290030181600087803b15801561233957600080fd5b505af115801561234d573d6000803e3d6000fd5b505050506040513d602081101561236357600080fd5b5051601454604080517fb410a034000000000000000000000000000000000000000000000000000000008152905192955061241792600160a060020a039092169163b410a034916004808201926020929091908290030181600087803b1580156123cc57600080fd5b505af11580156123e0573d6000803e3d6000fd5b505050506040513d60208110156123f657600080fd5b505161240b8760eb60020a620a69cb02613c5d565b9063ffffffff6148f116565b9150828210612429576000935061243c565b612439838363ffffffff61430716565b93505b505050919050565b60175481111561249e576040805160e560020a62461bcd02815260206004820152601560248201527f4761732070726963652061626f7665206c696d69740000000000000000000000604482015290519081900360640190fd5b50565b6008546040805160e060020a6370a08231028152600160a060020a038481166004830152915160009392909216916370a082319160248082019260209290919082900301818787803b1580156124f657600080fd5b505af115801561250a573d6000803e3d6000fd5b505050506040513d602081101561252057600080fd5b505192915050565b6060806000600d8054905060405190808252806020026020018201604052801561255c578160200160208202803883390190505b509150600090505b600d548110156125c657600f6000600d8381548110151561258157fe5b6000918252602080832090910154600160a060020a0316835282019290925260400190205482518390839081106125b457fe5b60209081029091010152600101612564565b50919050565b600154600160a060020a03163314612654576040805160e560020a62461bcd02815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527f2063616e20616363657074206f776e6572736869700000000000000000000000606482015290519081900360840190fd5b60005460015460408051600160a060020a03938416815292909116602083015280517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9281900390910190a16001805460008054600160a060020a0319908116600160a060020a03841617909155169055565b60008060006126d68585613c5d565b91506126e285856134a0565b90508082106126f45760009250611b89565b612704818363ffffffff61430716565b9250611b89565b600d80548290811061271957fe5b600091825260209091200154600160a060020a0316905081565b601354604080517fac82f60800000000000000000000000000000000000000000000000000000000815260048101849052905160009283928392606092849283928392600160a060020a03169163ac82f60891602480830192602092919082900301818787803b1580156127a657600080fd5b505af11580156127ba573d6000803e3d6000fd5b505050506040513d60208110156127d057600080fd5b5051601354909550600160a060020a031663babcb4236127ee612528565b6040518263ffffffff1660e060020a0281526004018080602001828103825283818151815260200191508051906020019060200280838360005b83811015612840578181015183820152602001612828565b5050505090500192505050600060405180830381600087803b15801561286557600080fd5b505af1158015612879573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160409081528110156128a257600080fd5b8101908080516401000000008111156128ba57600080fd5b820160208101848111156128cd57600080fd5b81518560208202830111640100000000821117156128ea57600080fd5b505060209091015190965094505083159050612950576040805160e560020a62461bcd02815260206004820152600f60248201527f526174657320617265207374616c650000000000000000000000000000000000604482015290519081900360640190fd5b600091505b600d54821015612a3b57612a1c848381518110151561297057fe5b90602001906020020151600d8481548110151561298957fe5b9060005260206000200160009054906101000a9004600160a060020a0316600160a060020a03166318160ddd6040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156129e457600080fd5b505af11580156129f8573d6000803e3d6000fd5b505050506040513d6020811015612a0e57600080fd5b50519063ffffffff61490616565b9050612a2e868263ffffffff61431e16565b9550600190910190612955565b612a4b868663ffffffff6148f116565b98975050505050505050565b600454600090600160a060020a03163314801590612a805750600554600160a060020a03163314155b8015612a975750600654600160a060020a03163314155b15612aaf5760068054600160a060020a031916331790555b600054600654600160a060020a03908116911614612b05576040805160e560020a62461bcd0281526020600482015260136024820152600080516020615d86833981519152604482015290519081900360640190fd5b81600160a060020a031663dbd06c856040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015612b4357600080fd5b505af1158015612b57573d6000803e3d6000fd5b505050506040513d6020811015612b6d57600080fd5b50516000818152600e6020526040902054909150600160a060020a031615612bdf576040805160e560020a62461bcd02815260206004820152601460248201527f53796e746820616c726561647920657869737473000000000000000000000000604482015290519081900360640190fd5b600160a060020a0382166000908152600f602052604090205415612c4d576040805160e560020a62461bcd02815260206004820152601c60248201527f53796e7468206164647265737320616c72656164792065786973747300000000604482015290519081900360640190fd5b600d8054600181019091557fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb5018054600160a060020a03909316600160a060020a031993841681179091556000828152600e6020908152604080832080549096168417909555918152600f9091529190912055565b600454600090600160a060020a03163314801590612ceb5750600554600160a060020a03163314155b8015612d025750600654600160a060020a03163314155b15612d1a5760068054600160a060020a031916331790555b5060065460e260020a631cd554d10290612d3d90600160a060020a0316826126c7565b821115612d94576040805160e560020a62461bcd02815260206004820152601060248201527f416d6f756e7420746f6f206c6172676500000000000000000000000000000000604482015290519081900360640190fd5b612d9e818361491b565b6000818152600e60205260408082205460065482517f867904b4000000000000000000000000000000000000000000000000000000008152600160a060020a03918216600482015260248101879052925191169263867904b4926044808201939182900301818387803b158015612e1457600080fd5b505af1158015612e28573d6000803e3d6000fd5b50505050612e346147be565b5050565b600054600160a060020a031681565b600454600160a060020a03163314801590612e6d5750600554600160a060020a03163314155b8015612e845750600654600160a060020a03163314155b15612e9c5760068054600160a060020a031916331790555b600054600654600160a060020a03908116911614612ef2576040805160e560020a62461bcd0281526020600482015260136024820152600080516020615d86833981519152604482015290519081900360640190fd5b6016805491151575010000000000000000000000000000000000000000000275ff00000000000000000000000000000000000000000019909216919091179055565b600a805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610cb25780601f10610c8757610100808354040283529160200191610cb2565b60175481565b600054600160a060020a03163314612ff9576040805160e560020a62461bcd02815260206004820152602f6024820152600080516020615d468339815191526044820152600080516020615d66833981519152606482015290519081900360840190fd5b60048054600160a060020a038316600160a060020a0319909116811790915560408051918252517ffc80377ca9c49cc11ae6982f390a42db976d5530af7c43889264b13fbbd7c57e9181900360200190a150565b60008054600160a060020a031633146130b2576040805160e560020a62461bcd02815260206004820152602f6024820152600080516020615d468339815191526044820152600080516020615d66833981519152606482015290519081900360840190fd5b60035460ff16151561310e576040805160e560020a62461bcd02815260206004820152601f60248201527f53656c66204465737472756374206e6f742079657420696e6974696174656400604482015290519081900360640190fd5b426224ea006002540110151561316e576040805160e560020a62461bcd02815260206004820152601b60248201527f53656c662064657374727563742064656c6179206e6f74206d65740000000000604482015290519081900360640190fd5b5060035460408051600160a060020a0361010090930492909216808352905190917f8a09e1677ced846cb537dc2b172043bd05a1a81ad7e0033a7ef8ba762df990b7919081900360200190a180600160a060020a0316ff5b600554600160a060020a031681565b600454600160a060020a031633148015906131fb5750600554600160a060020a03163314155b80156132125750600654600160a060020a03163314155b1561322a5760068054600160a060020a031916331790555b600054600654600160a060020a03908116911614613280576040805160e560020a62461bcd0281526020600482015260136024820152600080516020615d86833981519152604482015290519081900360640190fd5b60088054600160a060020a031916600160a060020a03831617905561249e81614d82565b60008060006132b284613309565b91508115156132c457600092506132ec565b6132d78460eb60020a620a69cb02613c5d565b90506132e9818363ffffffff6148f116565b92505b5050919050565b601254600160a060020a031681565b6224ea0081565b6008546040805160e060020a6370a08231028152600160a060020a0384811660048301529151600093849316916370a0823191602480830192602092919082900301818787803b15801561335c57600080fd5b505af1158015613370573d6000803e3d6000fd5b505050506040513d602081101561338657600080fd5b5051601154909150600160a060020a03161561342f576011546040805160e060020a6370a08231028152600160a060020a038681166004830152915161342c9392909216916370a08231916024808201926020929091908290030181600087803b1580156133f357600080fd5b505af1158015613407573d6000803e3d6000fd5b505050506040513d602081101561341d57600080fd5b5051829063ffffffff61431e16565b90505b601254600160a060020a03161561349a576012546040805160e060020a6370a08231028152600160a060020a03868116600483015291516134979392909216916370a08231916024808201926020929091908290030181600087803b1580156133f357600080fd5b90505b92915050565b6000806134bf60eb60020a620a69cb026134b986613309565b85612145565b9050613550601460009054906101000a9004600160a060020a0316600160a060020a031663b410a0346040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561351757600080fd5b505af115801561352b573d6000803e3d6000fd5b505050506040513d602081101561354157600080fd5b5051829063ffffffff614ec916565b949350505050565b60006060613550848483613a35565b600454600090600160a060020a031633148015906135905750600554600160a060020a03163314155b80156135a75750600654600160a060020a03163314155b156135bf5760068054600160a060020a031916331790555b600654600160a060020a03166000908152600f60205260409020541515613630576040805160e560020a62461bcd02815260206004820152601260248201527f4f6e6c792073796e746820616c6c6f7765640000000000000000000000000000604482015290519081900360640190fd5b84831415613688576040805160e560020a62461bcd02815260206004820152601360248201527f43616e27742062652073616d652073796e746800000000000000000000000000604482015290519081900360640190fd5b600084116136e0576040805160e560020a62461bcd02815260206004820152600b60248201527f5a65726f20616d6f756e74000000000000000000000000000000000000000000604482015290519081900360640190fd5b6136ef86868686866000614ef5565b9695505050505050565b600454600090600160a060020a031633148015906137225750600554600160a060020a03163314155b80156137395750600654600160a060020a03163314155b156137515760068054600160a060020a031916331790555b61375a856121ef565b8311156137b1576040805160e560020a62461bcd02815260206004820152601460248201527f496e73756666696369656e742062616c616e6365000000000000000000000000604482015290519081900360640190fd5b6006546137ca90600160a060020a0316868686866154d2565b50600195945050505050565b601054600160a060020a031681565b6004546000908190600160a060020a031633148015906138105750600554600160a060020a03163314155b80156138275750600654600160a060020a03163314155b1561383f5760068054600160a060020a031916331790555b60065460e260020a631cd554d102925061386290600160a060020a0316836126c7565b905061386e828261491b565b6000828152600e60205260408082205460065482517f867904b4000000000000000000000000000000000000000000000000000000008152600160a060020a03918216600482015260248101869052925191169263867904b4926044808201939182900301818387803b158015612e1457600080fd5b60035460ff1681565b600454600160a060020a03163314806139105750600554600160a060020a031633145b1515613966576040805160e560020a62461bcd02815260206004820152601760248201527f4f6e6c79207468652070726f78792063616e2063616c6c000000000000000000604482015290519081900360640190fd5b60068054600160a060020a031916600160a060020a0392909216919091179055565b600054600160a060020a031633146139ec576040805160e560020a62461bcd02815260206004820152602f6024820152600080516020615d468339815191526044820152600080516020615d66833981519152606482015290519081900360840190fd5b426002556003805460ff19166001179055604080516224ea00815290517fcbd94ca75b8dc45c9d80c77e851670e78843c0d75180cb81db3e2158228fa9a69181900360200190a1565b600454600090600160a060020a03163314801590613a5e5750600554600160a060020a03163314155b8015613a755750600654600160a060020a03163314155b15613a8d5760068054600160a060020a031916331790555b600654613aa290600160a060020a03166121ef565b831115613af9576040805160e560020a62461bcd02815260206004820152601460248201527f496e73756666696369656e742062616c616e6365000000000000000000000000604482015290519081900360640190fd5b600654613b1190600160a060020a03168585856155e2565b506001949350505050565b601554600160a060020a031681565b6003546101009004600160a060020a031681565b601360009054906101000a9004600160a060020a0316600160a060020a0316637dc0d1d06040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015613b9257600080fd5b505af1158015613ba6573d6000803e3d6000fd5b505050506040513d6020811015613bbc57600080fd5b5051600160a060020a03163314613c1d576040805160e560020a62461bcd02815260206004820152601360248201527f4f6e6c79206f7261636c6520616c6c6f77656400000000000000000000000000604482015290519081900360640190fd5b60168054911515740100000000000000000000000000000000000000000274ff000000000000000000000000000000000000000019909216919091179055565b601454604080517f8b3f8088000000000000000000000000000000000000000000000000000000008152600160a060020a0385811660048301528251600094859485948594859485949190911692638b3f8088926024808201939182900301818787803b158015613ccd57600080fd5b505af1158015613ce1573d6000803e3d6000fd5b505050506040513d6040811015613cf757600080fd5b5080516020909101519095509350841515613d155760009550613e7e565b601454604080517f08d95cd5000000000000000000000000000000000000000000000000000000008152600481018790529051613e56928892613e4a92600160a060020a03909216916308d95cd5916024808201926020929091908290030181600087803b158015613d8657600080fd5b505af1158015613d9a573d6000803e3d6000fd5b505050506040513d6020811015613db057600080fd5b5051601454604080517f463177120000000000000000000000000000000000000000000000000000000081529051600160a060020a03909216916346317712916004808201926020929091908290030181600087803b158015613e1257600080fd5b505af1158015613e26573d6000803e3d6000fd5b505050506040513d6020811015613e3c57600080fd5b50519063ffffffff6155f016565b9063ffffffff61560916565b9250613e6187612733565b9150613e7083613e4a84615622565b9050613e7b81615638565b95505b505050505092915050565b600654600160a060020a031681565b601454600160a060020a031681565b600d545b90565b600854604080517fdd62ed3e000000000000000000000000000000000000000000000000000000008152600160a060020a03858116600483015284811660248301529151600093929092169163dd62ed3e9160448082019260209290919082900301818787803b158015613f2157600080fd5b505af1158015613f35573d6000803e3d6000fd5b505050506040513d6020811015613f4b57600080fd5b50519392505050565b601154600160a060020a031681565b600854600160a060020a031681565b600454600160a060020a031681565b600454600090600160a060020a03163314801590613faa5750600554600160a060020a03163314155b8015613fc15750600654600160a060020a03163314155b15613fd95760068054600160a060020a031916331790555b83821415614031576040805160e560020a62461bcd02815260206004820152601960248201527f4d7573742075736520646966666572656e742073796e74687300000000000000604482015290519081900360640190fd5b60008311614089576040805160e560020a62461bcd02815260206004820152600b60248201527f5a65726f20616d6f756e74000000000000000000000000000000000000000000604482015290519081900360640190fd5b6140923a612444565b60165474010000000000000000000000000000000000000000900460ff161561414c576000848152600e60205260408082205460065482517f9dc29fac000000000000000000000000000000000000000000000000000000008152600160a060020a039182166004820152602481018890529251911692639dc29fac926044808201939182900301818387803b15801561412b57600080fd5b505af115801561413f573d6000803e3d6000fd5b50505050600190506121e8565b60065461416790600160a060020a0316858585836001614ef5565b90506121e8565b6016547501000000000000000000000000000000000000000000900460ff1681565b601854600160a060020a031681565b600480546040805160208082018690528251808303820181528284018085527f417070726f76616c28616464726573732c616464726573732c75696e7432353690527f29000000000000000000000000000000000000000000000000000000000000006060840152925191829003606101822060e060020a63907dff9702835260036024840181905260448401829052600160a060020a038a8116606486018190528a821660848701819052600060a4880181905260c09a88019a8b52885160c48901528851939099169963907dff97999497959692959194939092839260e40191908a0190808383885b838110156142a257818101518382015260200161428a565b50505050905090810190601f1680156142cf5780820380516001836020036101000a031916815260200191505b50975050505050505050600060405180830381600087803b1580156142f357600080fd5b505af1158015611f80573d6000803e3d6000fd5b6000808383111561431757600080fd5b5050900390565b6000828201838110156121e857600080fd5b600480546040805160208082018690528251808303820181528284018085527f5472616e7366657228616464726573732c616464726573732c75696e7432353690527f29000000000000000000000000000000000000000000000000000000000000006060840152925191829003606101822060e060020a63907dff9702835260036024840181905260448401829052600160a060020a038a8116606486018190528a821660848701819052600060a4880181905260c09a88019a8b52885160c48901528851939099169963907dff97999497959692959194939092839260e40191908a019080838388838110156142a257818101518382015260200161428a565b6000808315156144455760009150610e78565b5082820282848281151561445557fe5b04146121e857600080fd5b816000808080808061447a60e960020a622c222902612733565b955061448c868863ffffffff61430716565b945060009350600085111561450f576144ab878663ffffffff6155f016565b925061450c837384d626b2bb4d0f064067e4bf80fce7055d8f3e7b63d5e5e6e66040518163ffffffff1660e060020a02815260040160206040518083038186803b1580156144f857600080fd5b505af4158015611582573d6000803e3d6000fd5b93505b8787141561460e57601454600654604080517fa764eb45000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201526000602482018190529151929093169263a764eb45926044808301939282900301818387803b15801561458657600080fd5b505af115801561459a573d6000803e3d6000fd5b50505050601460009054906101000a9004600160a060020a0316600160a060020a031663ba08f2996040518163ffffffff1660e060020a028152600401600060405180830381600087803b1580156145f157600080fd5b505af1158015614605573d6000803e3d6000fd5b505050506146bc565b61461e888863ffffffff61430716565b9150614630828663ffffffff6155f016565b601454600654604080517fa764eb45000000000000000000000000000000000000000000000000000000008152600160a060020a03928316600482015260248101859052905193945091169163a764eb459160448082019260009290919082900301818387803b1580156146a357600080fd5b505af11580156146b7573d6000803e3d6000fd5b505050505b601454604080517f463177120000000000000000000000000000000000000000000000000000000081529051600160a060020a0390921691633d31e97b9161476291889185916346317712916004808201926020929091908290030181600087803b15801561472a57600080fd5b505af115801561473e573d6000803e3d6000fd5b505050506040513d602081101561475457600080fd5b50519063ffffffff61560916565b6040518263ffffffff1660e060020a02815260040180828152602001915050600060405180830381600087803b15801561479b57600080fd5b505af11580156147af573d6000803e3d6000fd5b50505050505050505050505050565b601454600654604080517f8b3f8088000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152815160009485941692638b3f8088926024808201939182900301818787803b15801561482657600080fd5b505af115801561483a573d6000803e3d6000fd5b505050506040513d604081101561485057600080fd5b508051602090910151601054600654604080517f86645274000000000000000000000000000000000000000000000000000000008152600160a060020a03928316600482015260248101869052604481018590529051949650929450169163866452749160648082019260009290919082900301818387803b1580156148d557600080fd5b505af11580156148e9573d6000803e3d6000fd5b505050505050565b60006121e88383670de0b6b3a764000061565a565b60006121e88383670de0b6b3a764000061569e565b600080600080600080614938888860e960020a622c222902612145565b955061494c60e960020a622c222902612733565b945061495e868663ffffffff61431e16565b9350614970868563ffffffff6155f016565b92506149f5837384d626b2bb4d0f064067e4bf80fce7055d8f3e7b63d5e5e6e66040518163ffffffff1660e060020a02815260040160206040518083038186803b1580156149bd57600080fd5b505af41580156149d1573d6000803e3d6000fd5b505050506040513d60208110156149e757600080fd5b50519063ffffffff61430716565b600654909250614a1790600160a060020a031660e960020a622c222902613c5d565b90506000811115614a4557614a4284614a36888463ffffffff61431e16565b9063ffffffff6155f016565b92505b801515614ab857601460009054906101000a9004600160a060020a0316600160a060020a0316631bfba5956040518163ffffffff1660e060020a028152600401600060405180830381600087803b158015614a9f57600080fd5b505af1158015614ab3573d6000803e3d6000fd5b505050505b601454600654604080517fa764eb45000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152602481018790529051919092169163a764eb4591604480830192600092919082900301818387803b158015614b2957600080fd5b505af1158015614b3d573d6000803e3d6000fd5b505050506000601460009054906101000a9004600160a060020a0316600160a060020a031663cd92eba96040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015614b9657600080fd5b505af1158015614baa573d6000803e3d6000fd5b505050506040513d6020811015614bc057600080fd5b50511115614c8c57601454604080517f463177120000000000000000000000000000000000000000000000000000000081529051600160a060020a0390921691633d31e97b91614c3691869185916346317712916004808201926020929091908290030181600087803b15801561472a57600080fd5b6040518263ffffffff1660e060020a02815260040180828152602001915050600060405180830381600087803b158015614c6f57600080fd5b505af1158015614c83573d6000803e3d6000fd5b50505050614d78565b601460009054906101000a9004600160a060020a0316600160a060020a0316633d31e97b7384d626b2bb4d0f064067e4bf80fce7055d8f3e7b63d5e5e6e66040518163ffffffff1660e060020a02815260040160206040518083038186803b158015614cf757600080fd5b505af4158015614d0b573d6000803e3d6000fd5b505050506040513d6020811015614d2157600080fd5b50516040805160e060020a63ffffffff8516028152600481019290925251602480830192600092919082900301818387803b158015614d5f57600080fd5b505af1158015614d73573d6000803e3d6000fd5b505050505b5050505050505050565b6004805460408051600160a060020a038581166020808401919091528351808403820181528385018086527f546f6b656e5374617465557064617465642861646472657373290000000000009052935192839003605a01832060e060020a63907dff97028452600160248501819052604485018290526000606486018190526084860181905260a4860181905260c0988601988952865160c48701528651949097169763907dff979791959294919384938493839260e4909201918a0190808383885b83811015614e5d578181015183820152602001614e45565b50505050905090810190601f168015614e8a5780820380516001836020036101000a031916815260200191505b50975050505050505050600060405180830381600087803b158015614eae57600080fd5b505af1158015614ec2573d6000803e3d6000fd5b5050505050565b6000670de0b6b3a7640000614ee4848463ffffffff61443216565b811515614eed57fe5b049392505050565b6000806000806000808b601060009054906101000a9004600160a060020a0316600160a060020a031663eb1edd616040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015614f5257600080fd5b505af1158015614f66573d6000803e3d6000fd5b505050506040513d6020811015614f7c57600080fd5b5051600160a060020a0382811691161415614fe1576040805160e560020a62461bcd02815260206004820152601760248201527f4665652061646472657373206e6f7420616c6c6f776564000000000000000000604482015290519081900360640190fd5b6016547501000000000000000000000000000000000000000000900460ff161515615056576040805160e560020a62461bcd02815260206004820152601660248201527f45786368616e67696e672069732064697361626c656400000000000000000000604482015290519081900360640190fd5b600e60008d6000191660001916815260200190815260200160002060009054906101000a9004600160a060020a0316600160a060020a0316639dc29fac8e8d6040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050600060405180830381600087803b1580156150e757600080fd5b505af11580156150fb573d6000803e3d6000fd5b5050505061510a8c8c8c612145565b9550859450600093508715615195576151238c8b6119c5565b9250615180615173847384d626b2bb4d0f064067e4bf80fce7055d8f3e7b63907af6c06040518163ffffffff1660e060020a02815260040160206040518083038186803b1580156149bd57600080fd5b879063ffffffff614ec916565b9450615192868663ffffffff61430716565b93505b60008a8152600e60205260408082205481517f867904b4000000000000000000000000000000000000000000000000000000008152600160a060020a038d81166004830152602482018a90529251929091169263867904b49260448084019382900301818387803b15801561520957600080fd5b505af115801561521d573d6000803e3d6000fd5b5050505060008411156153ee5761523e8a8560e960020a622c222902612145565b60e960020a622c2229026000908152600e60209081527f24466f25c15cd38334941647ac559e67e1ead957cc1be398ef066877266eac9254601054604080517feb1edd610000000000000000000000000000000000000000000000000000000081529051959750600160a060020a039283169563867904b495939092169363eb1edd619360048084019492938390030190829087803b1580156152e057600080fd5b505af11580156152f4573d6000803e3d6000fd5b505050506040513d602081101561530a57600080fd5b50516040805160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820186905251604480830192600092919082900301818387803b15801561535757600080fd5b505af115801561536b573d6000803e3d6000fd5b5050601054604080517f22bf55ef000000000000000000000000000000000000000000000000000000008152600481018790529051600160a060020a0390921693506322bf55ef925060248082019260009290919082900301818387803b1580156153d557600080fd5b505af11580156153e9573d6000803e3d6000fd5b505050505b600e60008b6000191660001916815260200190815260200160002060009054906101000a9004600160a060020a0316600160a060020a031663eb6ecc038e8b886040518463ffffffff1660e060020a0281526004018084600160a060020a0316600160a060020a0316815260200183600160a060020a0316600160a060020a031681526020018281526020019350505050600060405180830381600087803b15801561549957600080fd5b505af11580156154ad573d6000803e3d6000fd5b505050506154bf8d8d8d8d898e6156cb565b5060019c9b505050505050505050505050565b600854604080517fdd62ed3e000000000000000000000000000000000000000000000000000000008152600160a060020a03878116600483015288811660248301529151600093929092169163da46098c9188918a9161556b918991879163dd62ed3e9160448082019260209290919082900301818d87803b15801561555757600080fd5b505af11580156149d1573d6000803e3d6000fd5b6040805160e060020a63ffffffff8716028152600160a060020a03948516600482015292909316602483015260448201529051606480830192600092919082900301818387803b1580156155be57600080fd5b505af11580156155d2573d6000803e3d6000fd5b505050506136ef8585858561585f565b6000611d9b8585858561585f565b60006121e883836b033b2e3c9fd0803ce800000061565a565b60006121e883836b033b2e3c9fd0803ce800000061569e565b600061349a82633b9aca0063ffffffff61443216565b60006305f5e10082046005600a82061061565057600a015b600a900492915050565b6000806156808461567487600a870263ffffffff61443216565b9063ffffffff615b3916565b90506005600a825b061061569257600a015b600a9004949350505050565b600080600a83046156b5868663ffffffff61443216565b8115156156be57fe5b0490506005600a82615688565b600480546040805160208082018a90528183018990526060820188905260808201879052600160a060020a0386811660a0808501919091528451808503909101815260c08085018087527f53796e746845786368616e676528616464726573732c627974657333322c756990527f6e743235362c627974657333322c75696e743235362c6164647265737329000060e086015294519384900360fe01842060e060020a63907dff97028552600260248601819052604486018290528e84166064870181905260006084880181905260a48801819052998701978852835160c48801528351949098169863907dff9798939791969295939490938493839260e4909101918a0190808383885b838110156157ee5781810151838201526020016157d6565b50505050905090810190601f16801561581b5780820380516001836020036101000a031916815260200191505b50975050505050505050600060405180830381600087803b15801561583f57600080fd5b505af1158015615853573d6000803e3d6000fd5b50505050505050505050565b6000600160a060020a03841615156158c1576040805160e560020a62461bcd02815260206004820181905260248201527f43616e6e6f74207472616e7366657220746f2074686520302061646472657373604482015290519081900360640190fd5b600160a060020a038416301415615922576040805160e560020a62461bcd02815260206004820152601f60248201527f43616e6e6f74207472616e7366657220746f2074686520636f6e747261637400604482015290519081900360640190fd5b600454600160a060020a0385811691161415615988576040805160e560020a62461bcd02815260206004820152601c60248201527f43616e6e6f74207472616e7366657220746f207468652070726f787900000000604482015290519081900360640190fd5b6008546040805160e060020a6370a08231028152600160a060020a0388811660048301529151919092169163b46310f69188916159eb91889186916370a08231916024808201926020929091908290030181600087803b15801561555757600080fd5b6040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050600060405180830381600087803b158015615a3d57600080fd5b505af1158015615a51573d6000803e3d6000fd5b50506008546040805160e060020a6370a08231028152600160a060020a038981166004830152915191909216935063b46310f692508791615ab891889186916370a08231916024808201926020929091908290030181600087803b15801561156e57600080fd5b6040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050600060405180830381600087803b158015615b0a57600080fd5b505af1158015615b1e573d6000803e3d6000fd5b50505050615b2d858585614330565b613b1185858585615b5c565b600080808311615b4857600080fd5b8284811515615b5357fe5b04949350505050565b6007805460010190819055833b9060009081831115615cf057620186a05a10615b8857620186a0615b8a565b5a5b915085600160a060020a0316828887876040516024018084600160a060020a0316600160a060020a0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015615bf8578181015183820152602001615be0565b50505050905090810190601f168015615c255780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fc0ee0b8a000000000000000000000000000000000000000000000000000000001781529051825192975095508594509250905080838360005b83811015615cac578181015183820152602001615c94565b50505050905090810190601f168015615cd95780820380516001836020036101000a031916815260200191505b5091505060006040518083038160008787f1505050505b6007548114611f8057600080fd5b815481835581811115615d2257600083815260209020615d22918101908301615d27565b505050565b613eab91905b80821115615d415760008155600101615d2d565b509056004f6e6c792074686520636f6e7472616374206f776e6572206d617920706572666f726d207468697320616374696f6e00000000000000000000000000000000004f776e6572206f6e6c792066756e6374696f6e00000000000000000000000000a165627a7a7230582013db7f2ef945de98bb6e1aad7a2961ea3171379aa9c96160599d2cf65d82338f0029000000000000000000000000c011a72400e58ecd99ee497cf89e3775d4bd732f0000000000000000000000005b1b5fea1b99d83ad479df0c222f0492385381dd0000000000000000000000004b9ca5607f1ff8019c1c6a3c2f0cc8de622d5b82000000000000000000000000b64ff7a4a33acdf48d97dab0d764afd0f6176882000000000000000000000000565c9eb432f4ae9633e50e1213ab4f23d8f31f54000000000000000000000000a8cb0b163cefb21f22c72f6a7d243184bd688a5a000000000000000000000000a05e45396703babaa9c276b5e5a9b6e2c175b521000000000000000000000000b671f2210b1f6621a2607ea63e6b2dc3e2464d1f000000000000000000000000971e78e0c92392a4e39099835cf7e6ab535b2227000000000000000000000000ffa72fd80d8a84032d855bfb67036baf45949009000000000000000000000000000000000000000000813f3978f89409843fffea", + "result": "0x4b144999650fdc87b42ed184e73918ac22d70f01" + }, + "empty init code": { + "address": "0x0000000000000000000000000000000000000000", + "salt": "0x0000000000000000000000000000000000000000000000000000000000000000", + "init_code": "0x", + "result": "0xE33C0C7F7df4809055C3ebA6c09CFe4BaF1BD9e0" + } + } +} diff --git a/packages/contracts/test/data/json/libraries/codec/Lib_OVMCodec.test.json b/packages/contracts/test/data/json/libraries/codec/Lib_OVMCodec.test.json new file mode 100644 index 000000000000..b442f4e07c8c --- /dev/null +++ b/packages/contracts/test/data/json/libraries/codec/Lib_OVMCodec.test.json @@ -0,0 +1,22 @@ +{ + "tests": { + "decompressEIP155Transaction": { + "decompression": { + "in": [ + "0x0001f4000064000064121212121212121212121212121212121212121299999999999999999999" + ], + "out": [ + [ + 100, + 100000000, + 500, + "0x1212121212121212121212121212121212121212", + 0, + "0x99999999999999999999", + 420 + ] + ] + } + } + } +} diff --git a/packages/contracts/test/data/json/libraries/rlp/Lib_RLPReader.test.json b/packages/contracts/test/data/json/libraries/rlp/Lib_RLPReader.test.json new file mode 100644 index 000000000000..87a99992b45c --- /dev/null +++ b/packages/contracts/test/data/json/libraries/rlp/Lib_RLPReader.test.json @@ -0,0 +1,316 @@ +{ + "tests": { + "readBool": { + "true": { + "in": [ + "0x01" + ], + "out": [ + true + ] + }, + "false": { + "in": [ + "0x00" + ], + "out": [ + false + ] + }, + "something other than 0 or 1 (should revert)": { + "in": [ + "0x02" + ], + "revert": true + } + }, + "readAddress": { + "valid address": { + "in": [ + "0x941212121212121212121212121212121212121212" + ], + "out": [ + "0x1212121212121212121212121212121212121212" + ] + } + }, + "readBytes": { + "bytestring00": { + "in": [ + "0x00" + ], + "out": [ + "0x00" + ] + }, + "bytestring01": { + "in": [ + "0x01" + ], + "out": [ + "0x01" + ] + }, + "bytestring7F": { + "in": [ + "0x7f" + ], + "out": [ + "0x7f" + ] + } + }, + "readString": { + "emptystring": { + "in": [ + "0x80" + ], + "out": [ + "" + ] + }, + "shortstring": { + "in": [ + "0x83646f67" + ], + "out": [ + "dog" + ] + }, + "shortstring2": { + "in": [ + "0xb74c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c69" + ], + "out": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing eli" + ] + }, + "longstring": { + "in": [ + "0xb8384c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c6974" + ], + "out": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit" + ] + }, + "longstring2": { + "in": [ + "0xb904004c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e20437572616269747572206d6175726973206d61676e612c20737573636970697420736564207665686963756c61206e6f6e2c20696163756c697320666175636962757320746f72746f722e2050726f696e20737573636970697420756c74726963696573206d616c6573756164612e204475697320746f72746f7220656c69742c2064696374756d2071756973207472697374697175652065752c20756c7472696365732061742072697375732e204d6f72626920612065737420696d70657264696574206d6920756c6c616d636f7270657220616c6971756574207375736369706974206e6563206c6f72656d2e2041656e65616e2071756973206c656f206d6f6c6c69732c2076756c70757461746520656c6974207661726975732c20636f6e73657175617420656e696d2e204e756c6c6120756c74726963657320747572706973206a7573746f2c20657420706f73756572652075726e6120636f6e7365637465747572206e65632e2050726f696e206e6f6e20636f6e76616c6c6973206d657475732e20446f6e65632074656d706f7220697073756d20696e206d617572697320636f6e67756520736f6c6c696369747564696e2e20566573746962756c756d20616e746520697073756d207072696d697320696e206661756369627573206f726369206c756374757320657420756c74726963657320706f737565726520637562696c69612043757261653b2053757370656e646973736520636f6e76616c6c69732073656d2076656c206d617373612066617563696275732c2065676574206c6163696e6961206c616375732074656d706f722e204e756c6c61207175697320756c747269636965732070757275732e2050726f696e20617563746f722072686f6e637573206e69626820636f6e64696d656e74756d206d6f6c6c69732e20416c697175616d20636f6e73657175617420656e696d206174206d65747573206c75637475732c206120656c656966656e6420707572757320656765737461732e20437572616269747572206174206e696268206d657475732e204e616d20626962656e64756d2c206e6571756520617420617563746f72207472697374697175652c206c6f72656d206c696265726f20616c697175657420617263752c206e6f6e20696e74657264756d2074656c6c7573206c65637475732073697420616d65742065726f732e20437261732072686f6e6375732c206d65747573206163206f726e617265206375727375732c20646f6c6f72206a7573746f20756c747269636573206d657475732c20617420756c6c616d636f7270657220766f6c7574706174" + ], + "out": [ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mauris magna, suscipit sed vehicula non, iaculis faucibus tortor. Proin suscipit ultricies malesuada. Duis tortor elit, dictum quis tristique eu, ultrices at risus. Morbi a est imperdiet mi ullamcorper aliquet suscipit nec lorem. Aenean quis leo mollis, vulputate elit varius, consequat enim. Nulla ultrices turpis justo, et posuere urna consectetur nec. Proin non convallis metus. Donec tempor ipsum in mauris congue sollicitudin. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse convallis sem vel massa faucibus, eget lacinia lacus tempor. Nulla quis ultricies purus. Proin auctor rhoncus nibh condimentum mollis. Aliquam consequat enim at metus luctus, a eleifend purus egestas. Curabitur at nibh metus. Nam bibendum, neque at auctor tristique, lorem libero aliquet arcu, non interdum tellus lectus sit amet eros. Cras rhoncus, metus ac ornare cursus, dolor justo ultrices metus, at ullamcorper volutpat" + ] + } + }, + "readUint256": { + "zero": { + "in": [ + "0x80" + ], + "out": [ + 0 + ] + }, + "smallint": { + "in": [ + "0x01" + ], + "out": [ + 1 + ] + }, + "smallint2": { + "in": [ + "0x10" + ], + "out": [ + 16 + ] + }, + "smallint3": { + "in": [ + "0x4f" + ], + "out": [ + 79 + ] + }, + "smallint4": { + "in": [ + "0x7f" + ], + "out": [ + 127 + ] + }, + "mediumint1": { + "in": [ + "0x8180" + ], + "out": [ + 128 + ] + }, + "mediumint2": { + "in": [ + "0x8203e8" + ], + "out": [ + 1000 + ] + }, + "mediumint3": { + "in": [ + "0x830186a0" + ], + "out": [ + 100000 + ] + } + }, + "readList": { + "emptylist": { + "in": [ + "0xc0" + ], + "out": [ + [] + ] + }, + "stringlist": { + "in": [ + "0xcc83646f6783676f6483636174" + ], + "out": [ + [ + "0x83646f67", + "0x83676f64", + "0x83636174" + ] + ] + }, + "multilist": { + "in": [ + "0xc6827a77c10401" + ], + "out": [ + [ + "0x827a77", + "0xc104", + "0x01" + ] + ] + }, + "shortListMax1": { + "in": [ + "0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572" + ], + "out": [ + [ + "0x8461736466", + "0x8471776572", + "0x847a786376", + "0x8461736466", + "0x8471776572", + "0x847a786376", + "0x8461736466", + "0x8471776572", + "0x847a786376", + "0x8461736466", + "0x8471776572" + ] + ] + }, + "longList1": { + "in": [ + "0xf840cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376" + ], + "out": [ + [ + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376" + ] + ] + }, + "longList2": { + "in": [ + "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376" + ], + "out": [ + [ + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376", + "0xcf84617364668471776572847a786376" + ] + ] + }, + "listsoflists": { + "in": [ + "0xc4c2c0c0c0" + ], + "out": [ + [ + "0xc2c0c0", + "0xc0" + ] + ] + }, + "listsoflists2": { + "in": [ + "0xc7c0c1c0c3c0c1c0" + ], + "out": [ + [ + "0xc0", + "0xc1c0", + "0xc3c0c1c0" + ] + ] + }, + "dictTest1": { + "in": [ + "0xecca846b6579318476616c31ca846b6579328476616c32ca846b6579338476616c33ca846b6579348476616c34" + ], + "out": [ + [ + "0xca846b6579318476616c31", + "0xca846b6579328476616c32", + "0xca846b6579338476616c33", + "0xca846b6579348476616c34" + ] + ] + } + } + } +} diff --git a/packages/contracts/test/data/json/libraries/rlp/Lib_RLPWriter.test.json b/packages/contracts/test/data/json/libraries/rlp/Lib_RLPWriter.test.json new file mode 100644 index 000000000000..aa3b4c5111ee --- /dev/null +++ b/packages/contracts/test/data/json/libraries/rlp/Lib_RLPWriter.test.json @@ -0,0 +1,151 @@ +{ + "source": "https://github.com/ethereum/tests/blob/develop/RLPTests/rlptest.json", + "notes": "Removed BigInt test, since ethers does not support integers over 10^16: https://github.com/ethers-io/ethers.js/issues/418", + "latestcommit": "b2dcd19973637ac05e17646378dac9cbb2927075", + "date": "2020-01-08", + "tests": { + "emptystring": { + "in": "", + "out": "0x80" + }, + "bytestring00": { + "in": "\u0000", + "out": "0x00" + }, + "bytestring01": { + "in": "\u0001", + "out": "0x01" + }, + "bytestring7F": { + "in": "\u007F", + "out": "0x7f" + }, + "shortstring": { + "in": "dog", + "out": "0x83646f67" + }, + "shortstring2": { + "in": "Lorem ipsum dolor sit amet, consectetur adipisicing eli", + "out": "0xb74c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c69" + }, + "longstring": { + "in": "Lorem ipsum dolor sit amet, consectetur adipisicing elit", + "out": "0xb8384c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c6974" + }, + "longstring2": { + "in": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mauris magna, suscipit sed vehicula non, iaculis faucibus tortor. Proin suscipit ultricies malesuada. Duis tortor elit, dictum quis tristique eu, ultrices at risus. Morbi a est imperdiet mi ullamcorper aliquet suscipit nec lorem. Aenean quis leo mollis, vulputate elit varius, consequat enim. Nulla ultrices turpis justo, et posuere urna consectetur nec. Proin non convallis metus. Donec tempor ipsum in mauris congue sollicitudin. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse convallis sem vel massa faucibus, eget lacinia lacus tempor. Nulla quis ultricies purus. Proin auctor rhoncus nibh condimentum mollis. Aliquam consequat enim at metus luctus, a eleifend purus egestas. Curabitur at nibh metus. Nam bibendum, neque at auctor tristique, lorem libero aliquet arcu, non interdum tellus lectus sit amet eros. Cras rhoncus, metus ac ornare cursus, dolor justo ultrices metus, at ullamcorper volutpat", + "out": "0xb904004c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e20437572616269747572206d6175726973206d61676e612c20737573636970697420736564207665686963756c61206e6f6e2c20696163756c697320666175636962757320746f72746f722e2050726f696e20737573636970697420756c74726963696573206d616c6573756164612e204475697320746f72746f7220656c69742c2064696374756d2071756973207472697374697175652065752c20756c7472696365732061742072697375732e204d6f72626920612065737420696d70657264696574206d6920756c6c616d636f7270657220616c6971756574207375736369706974206e6563206c6f72656d2e2041656e65616e2071756973206c656f206d6f6c6c69732c2076756c70757461746520656c6974207661726975732c20636f6e73657175617420656e696d2e204e756c6c6120756c74726963657320747572706973206a7573746f2c20657420706f73756572652075726e6120636f6e7365637465747572206e65632e2050726f696e206e6f6e20636f6e76616c6c6973206d657475732e20446f6e65632074656d706f7220697073756d20696e206d617572697320636f6e67756520736f6c6c696369747564696e2e20566573746962756c756d20616e746520697073756d207072696d697320696e206661756369627573206f726369206c756374757320657420756c74726963657320706f737565726520637562696c69612043757261653b2053757370656e646973736520636f6e76616c6c69732073656d2076656c206d617373612066617563696275732c2065676574206c6163696e6961206c616375732074656d706f722e204e756c6c61207175697320756c747269636965732070757275732e2050726f696e20617563746f722072686f6e637573206e69626820636f6e64696d656e74756d206d6f6c6c69732e20416c697175616d20636f6e73657175617420656e696d206174206d65747573206c75637475732c206120656c656966656e6420707572757320656765737461732e20437572616269747572206174206e696268206d657475732e204e616d20626962656e64756d2c206e6571756520617420617563746f72207472697374697175652c206c6f72656d206c696265726f20616c697175657420617263752c206e6f6e20696e74657264756d2074656c6c7573206c65637475732073697420616d65742065726f732e20437261732072686f6e6375732c206d65747573206163206f726e617265206375727375732c20646f6c6f72206a7573746f20756c747269636573206d657475732c20617420756c6c616d636f7270657220766f6c7574706174" + }, + "zero": { + "in": 0, + "out": "0x80" + }, + "smallint": { + "in": 1, + "out": "0x01" + }, + "smallint2": { + "in": 16, + "out": "0x10" + }, + "smallint3": { + "in": 79, + "out": "0x4f" + }, + "smallint4": { + "in": 127, + "out": "0x7f" + }, + "mediumint1": { + "in": 128, + "out": "0x8180" + }, + "mediumint2": { + "in": 1000, + "out": "0x8203e8" + }, + "mediumint3": { + "in": 100000, + "out": "0x830186a0" + }, + "emptylist": { + "in": [], + "out": "0xc0" + }, + "stringlist": { + "in": [ "dog", "god", "cat" ], + "out": "0xcc83646f6783676f6483636174" + }, + "multilist": { + "in": [ "zw", [ 4 ], 1 ], + "out": "0xc6827a77c10401" + }, + "shortListMax1": { + "in": [ "asdf", "qwer", "zxcv", "asdf","qwer", "zxcv", "asdf", "qwer", "zxcv", "asdf", "qwer"], + "out": "0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572" + }, + "longList1" : { + "in" : [ + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"] + ], + "out": "0xf840cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376" + }, + "longList2" : { + "in" : [ + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"], + ["asdf","qwer","zxcv"] + ], + "out": "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376" + }, + "listsoflists": { + "in": [ [ [], [] ], [] ], + "out": "0xc4c2c0c0c0" + }, + "listsoflists2": { + "in": [ [], [[]], [ [], [[]] ] ], + "out": "0xc7c0c1c0c3c0c1c0" + }, + "dictTest1" : { + "in" : [ + ["key1", "val1"], + ["key2", "val2"], + ["key3", "val3"], + ["key4", "val4"] + ], + "out" : "0xecca846b6579318476616c31ca846b6579328476616c32ca846b6579338476616c33ca846b6579348476616c34" + } + } +} diff --git a/packages/contracts/test/data/json/libraries/trie/Lib_MerkleTrie.test.json b/packages/contracts/test/data/json/libraries/trie/Lib_MerkleTrie.test.json new file mode 100644 index 000000000000..75c8235a0f20 --- /dev/null +++ b/packages/contracts/test/data/json/libraries/trie/Lib_MerkleTrie.test.json @@ -0,0 +1,340 @@ +{ + "tests": { + "update": { + "basic leaf value updates": { + "in": [ + "0x6b6579316161", + "0x736f6d65206e65772076616c7565", + "0xf8a2a7e68416b65793a03101b4447781f1e6c51ce76c709274fc80bd064f3a58ff981b6015348a826386b847f84580a0582eed8dd051b823d13f8648cdcd08aa2d8dac239f458863c4620e8c4d605debca83206262856176616c32ca83206363856176616c3380808080808080808080808080b0ef83206161aa303132333435363738393031323334353637383930313233343536373839303132333435363738397878", + "0xd582f99275e227a1cf4284899e5ff06ee56da8859be71b553397c69151bc942f" + ], + "out": [ + "0xc6049f657b848e7a811a366d60dbd8fed5edb1432f493fcd11eb882d2fb38470" + ] + }, + "new leaf insertions": { + "in": [ + "0x6b6579346464", + "0x736f6d65206e65772076616c7565", + "0xf871a7e68416b65793a03101b4447781f1e6c51ce76c709274fc80bd064f3a58ff981b6015348a826386b847f84580a0582eed8dd051b823d13f8648cdcd08aa2d8dac239f458863c4620e8c4d605debca83206262856176616c32ca83206363856176616c3380808080808080808080808080", + "0xd582f99275e227a1cf4284899e5ff06ee56da8859be71b553397c69151bc942f" + ], + "out": [ + "0x2d9bfc0b1e73cf420cb79ec039a28f4449de3fe875f455f34c94a867be300c7b" + ] + }, + "modifications to extension node": { + "in": [ + "0x6b6579316162", + "0x736f6d65206e65772076616c7565", + "0xf8a2a7e68416b65793a03101b4447781f1e6c51ce76c709274fc80bd064f3a58ff981b6015348a826386b847f84580a0582eed8dd051b823d13f8648cdcd08aa2d8dac239f458863c4620e8c4d605debca83206262856176616c32ca83206363856176616c3380808080808080808080808080b0ef83206161aa303132333435363738393031323334353637383930313233343536373839303132333435363738397878", + "0xd582f99275e227a1cf4284899e5ff06ee56da8859be71b553397c69151bc942f" + ], + "out": [ + "0x0ef0b67d8f45c0e6a1673541196a121bc12639fae8026ac2594961faaa0dbac5" + ] + }, + "shift existing value to branch": { + "in": [ + "0x6b657931616161", + "0x736f6d65206e65772076616c7565", + "0xf8a2a7e68416b65793a03101b4447781f1e6c51ce76c709274fc80bd064f3a58ff981b6015348a826386b847f84580a0582eed8dd051b823d13f8648cdcd08aa2d8dac239f458863c4620e8c4d605debca83206262856176616c32ca83206363856176616c3380808080808080808080808080b0ef83206161aa303132333435363738393031323334353637383930313233343536373839303132333435363738397878", + "0xd582f99275e227a1cf4284899e5ff06ee56da8859be71b553397c69151bc942f" + ], + "out": [ + "0x4efa4e217b51fa5c79112e45727f7754882db71320275403fb9f2c74686ac577" + ] + }, + "shift new value to branch": { + "in": [ + "0x6b65793161", + "0x736f6d65206e65772076616c7565", + "0xf8a2a7e68416b65793a03101b4447781f1e6c51ce76c709274fc80bd064f3a58ff981b6015348a826386b847f84580a0582eed8dd051b823d13f8648cdcd08aa2d8dac239f458863c4620e8c4d605debca83206262856176616c32ca83206363856176616c3380808080808080808080808080b0ef83206161aa303132333435363738393031323334353637383930313233343536373839303132333435363738397878", + "0xd582f99275e227a1cf4284899e5ff06ee56da8859be71b553397c69151bc942f" + ], + "out": [ + "0x73fb38b2ad097f755eb8c3485035ee04960717956dd5ccd0ea086afe55538772" + ] + }, + "arbitrary update (128 nodes)": { + "in": [ + "0x38306562633864376331633237656437393930613731633839656164323463636431343836336662626466336662356462316339313632636661633436663833", + "0x66623237633466393532353865363964303232623963373766616132643166356339643030336233616365306662353264373163613635393263326666303134", + "0xf9033db853f851808080a01683853733c3f60794d4c72f7b2f72afdb66c78c003d5447007e6570aabbce488080a075779c9fa7a787bd9e9b4793d8570ab8d00a6da215b1149d8adbffe15b72035c80808080808080808080b90154f90151a0ca8487ac08712727a9f015ea79a5425dff3e2827444594ad319899054bea6726a05bc9e58c52524b0e143297bf4641a131fefdf0457deaf17a06a4ee3d5b47e236a03c79e1171977ad0d6147cd8567dc5a427012007fcfb20e0f9e6c53e8d2783bdfa08b4e2951e45c5323519d148fc7224d2bceff6a1109102e877fcb6172b85270c4a0483a71a1dc202bc4793dda2491e0cf6caa80f4e8c41490faf0ccff36f36ab575a0cfc4cc320fdc887c1a6393d3dfa2e10693570fb9e09814b078a4e22788d7b1baa0db9c9f4674af3d18cc1249ac6712663d7d3241a9b7a358d3b7f287a7abbfed77a07e8f510894db4c610cb31efa5a3fa90776649c92edd4abbd550bc06a7c5f0598a0ad558331f2fff09e6c6c11a6e10f28e248729492349d1e44f7c790fc6630fe25a0a328bd791bddc75a9f835d68807b7dfcdaa232816ef0a8f056b104d566bc5b1b80808080808080b853f851808080a0d4bf75bea1883976cf54999f17b869595c833157bac7733ae45905f7894a63ca8080a0809edbfbc8b6e1bbe5bc8731af253337a57ecc4a2432182650f85a46a97e20f780808080808080808080b8b3f8b1a0922c98754d7ef4b203da9439946a6f7aba8339eb4f065cf83200724d36a9e86380a0437d659b7c49ce690feac212b95ebf84253c55aafc410c3b61321ee11a5d83358080a02eed03a131ad24ed59f25a4b433b0a39e6f3e5e95bc7a0b663c9b6edfae9e47aa0b07d0b40ba348e26858be73fed53d3a6e439c4d05a40e04c7fd53167c8f1d2948080a0f7d7d33621813da6bb91701839fc79fd6d261b2a907a43106d2bc978481238a080808080808080b885f883b83f206562633864376331633237656437393930613731633839656164323463636431343836336662626466336662356462316339313632636661633436663833b84066623237633466393532353865363964303232623963373766616132643166356339643030336233616365306662353264373163613635393263326666303134", + "0xce74ff675fd0b952ecb3f02f5360d50d1b96254f21d0930f2ced2f328553f972" + ], + "out": [ + "0xce74ff675fd0b952ecb3f02f5360d50d1b96254f21d0930f2ced2f328553f972" + ] + }, + "arbitrary update (256 nodes)": { + "in": [ + "0x30653837306437643232636366313635333231323139333737396537316666376634373930303139626533613839633037616138343262653134643465363937", + "0x39616533313162356138663533333733353135323439383231386663613165323237313763343764326463366135663738323539316433663462326434326134", + "0xf903d5b853f851808080a0939d6c424a8898660e415e2427e923f6f825296f7d2d03a7e870f4de13bdc8248080a09d9ea16458b048e853ee27c96b095519712020e617aaf03de69c71a19850287880808080808080808080b90154f90151a060e0aead56eb92bea0b9233e611a141493ee03864a5b46b54ead8cf4f3fafb41a0275c4007dd73d30b8290c99035cd2d72e6d9a652853253b8176be4eaa6ce03a9a0ed1f9432a10f62ebdf2748baecdbae01df7e4b72b793692f5b46ccb1b41c081ca01f2a5f3f5c4b597bf354e84a8ce80d9a4ffd274045a06ac636e1a394b877aed0a0bd04555f2a1b7d5dbe5b0fd869b9d2d37374f2d23e4ba4e4e695c173614fcf51a0f238e46cad89131c919d406183ef03ed46231a257231bc89bb640af0868768bca0973f643ff33b27848bf26f2d0d3988c05105715c00c2db106fce906983e62ee9a001bdf81f3c1c1bac6428259d6d4e0edbdd8ceb7c1d14866125a0036def676d40a0d8926874fd8a0e0ab8d46c4407ead6c055444c548e8cc4feca97d4a9bfc65f0ca058fea35b638a9b061e597f1ab17820a04c67436c64c575e9d4d3a50c4209ad5980808080808080b853f851808080a00d8de33b14b40038395424871f1daaeed399dc5ea7873b16fb56fab0beb68c9e8080a0443a68a5b803a8a34906d8664c759a4b00f866ff2d78af2298b110b96884ce2580808080808080808080b8b3f8b18080a018c1c3076c61714d6dc546ac283e35b5876708f8162559b5054e902975436a41a018085b2e94545aae48c1ec8e972ca02c8f6cded9d2f6033c1b0209ad20ff4be2a02cbfcfa4580c95efc154891b19b6458f073126beeeee7e1fb0c232e9bdb7839ea0a862ecc9386c6d0fcad6fedf47ad8c15ee45a88e8a031a6320f7bb22b6bd3ab7a08687183169c39a78988413c75facc0424a563312425ad5249c1bd865de459d4880808080808080808080a3e213a0cb71f0cc92c51e0d8eb9dd47e461f2077bfbe01f2125f181a69ca866f131f0d4b873f871a0d6883f50188ca6cee1d5bce7f2deaa67b04a9c82606f88bc7b597866ecdd41878080808080a0bb16a4c9def487361c336de32752a110a711dda21c1155663772db84392b085e80a0d7a33b3192a85c741c3494463098dfaf7f342ea1def97b44be03091a4e1cf9b68080808080808080b884f882b83e2037306437643232636366313635333231323139333737396537316666376634373930303139626533613839633037616138343262653134643465363937b84039616533313162356138663533333733353135323439383231386663613165323237313763343764326463366135663738323539316433663462326434326134", + "0x1d1c6d6618a09e6d00460ecbb34e07344c1428ada1b33d440e336ae18da193e1" + ], + "out": [ + "0x1d1c6d6618a09e6d00460ecbb34e07344c1428ada1b33d440e336ae18da193e1" + ] + }, + "arbitrary update (512 nodes)": { + "in": [ + "0x62663635326166303465303333633037373634623665646536643637643936393733393364386438373661656433363833373437393933363536303732366134", + "0x34333837346462663832303033646432306561393631613730666336343163653035303761613539393830376262353565396138383631396231373133333065", + "0xf9032fb853f851808080a0172aa06a9c3bf30cc3fa2521909faa0f755519d56eacdf0dadae12ab4b9eaef88080a0ca59486747b7dd466a0059a2ba4ceabd531192e18c460ac60132b56cfc8a48c080808080808080808080b8d3f8d180a05df972283599f8ffdcb8f9d003bd1aa859942764b1e5db1613d914e16ebd122ea0d57d611996f626f1da73a876f1db74d44a1467d20357247c31c8619a903674fca046bb69112b28082bc8fae40d752b083d7ec3103aa1abf0ab036c961db41ef0f3a0ebeac2aabd3939a84e8a8f4647b27f02d4f6b6df962f5b350282bfa9d291773aa083d6cca4848f341a8003764420b2ad3605425cc23d12afcb65933ab606f339cca03c23d875a3225d63d85ef83fc999121284f31889d8201ac0be9cb1a8d5cd073d80808080808080808080b853f851808080a02a991efab0bb245d1d8908fdb29c9aef8243378f9fb22ea5861b35e355ddc2d18080a0a66cfb941cb9f47af573f8738cd2a56a625392de974e5930e24594e9f258714980808080808080808080b8d3f8d180a0a1e1cf55385e1b6da7cc2fb7aeb59c766f154223fd8821a1914ecbc5927f72f8a0b947c9b788bd2f0ae8f3ffa4078721d266ed88ddda976b66199d9a7d1aa2068fa0d4306d3c5bee7448422edc43f806365de24f17a6c6a0e17e1b3260454a23b9f8a0cb1420601892d3ae953e17cd628428766ec281cc442720df72b6b03a648bea2ba07885db0751e3008e64b587a095c99fd6673f189a23cdd818b7d89943aace6984a0b64746e1e804b6c746ff52316a8428ee3ddcb9e6528b5fc7d5e13e71b22069e680808080808080808080b853f851808080a0d12e64290951bd56fa8626a63e05bcf239a0225d602dd9b9a7e478edb77228428080a00471402a244af307ccb5ee16d236b0278d8c668eb80b7c438bbe35e62c1a5abc80808080808080808080b884f882b83e3635326166303465303333633037373634623665646536643637643936393733393364386438373661656433363833373437393933363536303732366134b84034333837346462663832303033646432306561393631613730666336343163653035303761613539393830376262353565396138383631396231373133333065", + "0x922b383ea8414274391a09d26e26862bcb4018838878177f909e7578486d4101" + ], + "out": [ + "0x922b383ea8414274391a09d26e26862bcb4018838878177f909e7578486d4101" + ] + }, + "arbitrary update (1024 nodes)": { + "in": [ + "0x63633939363830316465653630663865353732336635303766613037646236653930643737373566366665623564653232346136313762393533333561663861", + "0x34386665633731636135326230306266316233333262623263303961646137353736333635656165623462343663336431326665346134333763336132636339", + "0xf903d8b853f851808080a07dbe425836ecb64269b04bd8bdaaf162e7dc011bc545ea3c114924791b9715f38080a05daae9e121770c2ce2c8aaae5aef8294266cb421e7394d833973b30d292476b880808080808080808080b8d3f8d180a0321c3ed3b4591371add24ae89ac39364c90085e572082704d679d937b8480b0ea08ee53c6695830154881b03611e3b479c095e010c54e4d2f0d98803242beef8eaa07da013493bb886430b15d341bf459fd8af42367cf7e4f86d9f6a3287704008d0a0b2b02fa967f822b5cb0a99274be4064933cb1b51489298767acd3b1d2d17d869a000b574b33dce2ff6e2834990bfffaf726fff5e66a639510bf85db62b9f72a757a00325ca019c291cf1d02b0b55808a12e248595a94333fe0c20a5b0917964fdf9080808080808080808080b853f851808080a0aec555ba5424e2039fd0fab02bc307a75d3295a79c1f90c05bd9259781b2c1478080a09de84124a9512c6d0dcecc7693c1c71e7dae4e87ba93cdef66120a0f34e2165880808080808080808080b8d3f8d180a0fd5d7c497457334ac50c181c07640067cb02623a774cf3043c6fe6444f54425fa0c775c400a320fbedcce51129dabfd3b76495a644c7d0e83a59c14610c1e47ef8a01f30ff4af3bf01e544840ced373297840864672ec1bea4fe3125878ecf7e97d9a09015fce5cfd1a7271c3d3768be994cccbc8d750154c8bc2e0ce0c3ff4ef9386fa00f087471655a490fe86f60c824f47b25fc607dbfe83a4f987f028ac4eb03a3c1a0b72b82b32748b14079f21520ef9a27290ce7064411664f1ae88f5d9e6d45494480808080808080808080b853f851808080a0657b5ebb555e7d04261deefcde723bcd744c85ac1f887acbec03a315215ab5aa8080a0f244b0b57ca617ab32e2b190a9499040e6a98e2e58ee481d89ec9eaa110c5a1b80808080808080808080b853f85180a01275e04aeba9c0367572783ccb1561695d264293a3bc337fb712bbd58efa14f180808080808080a0c709e24f4afc4d46c3412e18ccd20cd1bf1da620129c42da1938b05c7276d19880808080808080b853f851808080a044f42acab8ddedef537f8b1f56c38a38d4667d3a341503eacbdc46386eb215d48080a0c19dc41cabe37a3da398a2d46ca409803cf77db8b7bcbd6acc90f00f8ee9e0ab80808080808080808080b883f881b83d39363830316465653630663865353732336635303766613037646236653930643737373566366665623564653232346136313762393533333561663861b84034386665633731636135326230306266316233333262623263303961646137353736333635656165623462343663336431326665346134333763336132636339", + "0x7cc1d9e4349a14570903256d0662d5c7e26259c23fce53d4e0d1d05b79144651" + ], + "out": [ + "0x7cc1d9e4349a14570903256d0662d5c7e26259c23fce53d4e0d1d05b79144651" + ] + }, + "arbitrary update (2048 nodes)": { + "in": [ + "0x63616265366136313331376466623239383931636136363563353936643366386534323935336665356530323365356332396163633134653833393030303033", + "0x63303132633333643333393163363537396131383232346564316331356531613935353833333234303032616137383065333632356533393139306238643265", + "0xf903a4b853f851808080a06b1ec163d36f0660cab4ab85a101a2dd24bfa2658e1b722a3a0e3f40ad06a2f28080a05a944280b38ede1983f3dab5166cc620b846e9d3e8425f7d81ce610dd496063380808080808080808080b8d3f8d180a0bfc332079e121621b6a79d574595cca74cef134939aea106bd56202519ebf5baa0b9866e81a81052c8b5f57949466726518aa49ece30ea07fdd5d2834fcfe9676fa0544fed534ae1e285bf78468daf73b18e06fe3af92e30686ddaeae6e2d09642bca0d5227397e6129b675f39f09e9efbc654bf4ff566111be6b1c189c85f9684e86ca0f2ed72bcc8939e9671b1802de95264bccfb9677feed79c9c389191aa2fc1dc72a0d1384e17ccdc5b370fdc94c137a95569b5cd46847499c755f2d269b2dbbc20bc80808080808080808080b853f851808080a0d6d22f3b60400e4091958d2a9e0481c28a5591cc84877c1128ed37bd005fbc8f8080a05b56153cdf09797a3b4c87cadb4d08ba274d864abbda957a2d6320d6ed17dac880808080808080808080b8d3f8d180a042746ed1a4d5569b703154c91a201a1691f76794777cfe693ce357b529f47e16a09a7077c59c45ff2d95732ce9198404c9bae5c996e44271ef7f40b42b2aa7337ca0a5c16713226e147008cae877e7561e3fdd05872e96c729f6cd95f35b272be1cea0790fd15585bfc861cea60558e356f1a80f6da67e21d9b0b89402262d1bfcc585a05a03571e90510329c97a3b2a7720d14851a21b8972e97963c053af4e4e0d1a9ea08d0005d1533fb093fdbad029b4528e50aace6721d9810689d085586770242f5380808080808080808080b853f851808080a07b40b3c18f9cadd46aedac7661cc01579ec5cfe9e60b568cc79ccd84e4b81c7e8080a009e603f66a4b102b5b3c2525fc158ecb695781faba4ac01c5ab20c0b1686722080808080808080808080b873f8718080a0de8f63df18f1f49de180b12a0ced021aa75bc705395bf23f2ca2357c24c6e98580a06ee2f7499d6e5c9e5ee5529d4d40efd76ba7371648816da6c2cedccbfc014e6380a01f54a437431e714f7f9c3c0f79def239851df7d89f9e4520e3dc02bdd349be8180808080808080808080b884f882b83e2065366136313331376466623239383931636136363563353936643366386534323935336665356530323365356332396163633134653833393030303033b84063303132633333643333393163363537396131383232346564316331356531613935353833333234303032616137383065333632356533393139306238643265", + "0x091a8393aaece43e0f6efb3977f15fc6f86709cdd6f8c2ba9245ed2ba841a329" + ], + "out": [ + "0x091a8393aaece43e0f6efb3977f15fc6f86709cdd6f8c2ba9245ed2ba841a329" + ] + } + }, + "verifyInclusionProof": { + "basic inclusion proof (node 1 of 3)": { + "in": [ + "0x6b6579316161", + "0x303132333435363738393031323334353637383930313233343536373839303132333435363738397878", + "0xf8a2a7e68416b65793a03101b4447781f1e6c51ce76c709274fc80bd064f3a58ff981b6015348a826386b847f84580a0582eed8dd051b823d13f8648cdcd08aa2d8dac239f458863c4620e8c4d605debca83206262856176616c32ca83206363856176616c3380808080808080808080808080b0ef83206161aa303132333435363738393031323334353637383930313233343536373839303132333435363738397878", + "0xd582f99275e227a1cf4284899e5ff06ee56da8859be71b553397c69151bc942f" + ], + "out": [ + true + ] + }, + "basic inclusion proof (node 2 of 3)": { + "in": [ + "0x6b6579326262", + "0x6176616c32", + "0xf87da7e68416b65793a03101b4447781f1e6c51ce76c709274fc80bd064f3a58ff981b6015348a826386b847f84580a0582eed8dd051b823d13f8648cdcd08aa2d8dac239f458863c4620e8c4d605debca83206262856176616c32ca83206363856176616c33808080808080808080808080808bca83206262856176616c32", + "0xd582f99275e227a1cf4284899e5ff06ee56da8859be71b553397c69151bc942f" + ], + "out": [ + true + ] + }, + "basic inclusion proof (node 3 of 3)": { + "in": [ + "0x6b6579336363", + "0x6176616c33", + "0xf87da7e68416b65793a03101b4447781f1e6c51ce76c709274fc80bd064f3a58ff981b6015348a826386b847f84580a0582eed8dd051b823d13f8648cdcd08aa2d8dac239f458863c4620e8c4d605debca83206262856176616c32ca83206363856176616c33808080808080808080808080808bca83206363856176616c33", + "0xd582f99275e227a1cf4284899e5ff06ee56da8859be71b553397c69151bc942f" + ], + "out": [ + true + ] + }, + "single long key": { + "in": [ + "0x6b6579316161", + "0x303132333435363738393031323334353637383930313233343536373839303132333435363738397878", + "0xf5b4f387206b6579316161aa303132333435363738393031323334353637383930313233343536373839303132333435363738397878", + "0xf838216fa749aefa91e0b672a9c06d3e6e983f913d7107b5dab4af60b5f5abed" + ], + "out": [ + true + ] + }, + "single short key": { + "in": [ + "0x6b6579316161", + "0x3031323334", + "0xd08fce87206b6579316161853031323334", + "0x37956bab6bba472308146808d5311ac19cb4a7daae5df7efcc0f32badc97f55e" + ], + "out": [ + true + ] + }, + "key in the middle (node 2 of 6)": { + "in": [ + "0x6b657931", + "0x30313233343536373839303132333435363738393031323334353637383930313233343536373839566572795f4c6f6e67", + "0xf90103a7e68416b65793a0f3f387240403976788281c0a6ee5b3fc08360d276039d635bb824ea7e6fed779b873f87180a034d14ccc7685aa2beb64f78b11ee2a335eae82047ef97c79b7dda7f0732b9f4ca05fb052b64e23d177131d9f32e9c5b942209eb7229e9a07c99a5d93245f53af18a09a137197a43a880648d5887cce656a5e6bbbe5e44ecb4f264395ccaddbe1acca80808080808080808080808080b864f862808080808080a057895fdbd71e2c67c2f9274a56811ff5cf458720a7fa713a135e3890f8cafcf8808080808080808080b130313233343536373839303132333435363738393031323334353637383930313233343536373839566572795f4c6f6e67", + "0xcb65032e2f76c48b82b5c24b3db8f670ce73982869d38cd39a624f23d62a9e89" + ], + "out": [ + true + ] + }, + "key in the middle (node 3 of 6)": { + "in": [ + "0x6b6579326262", + "0x6176616c33", + "0xf8c9a7e68416b65793a0f3f387240403976788281c0a6ee5b3fc08360d276039d635bb824ea7e6fed779b873f87180a034d14ccc7685aa2beb64f78b11ee2a335eae82047ef97c79b7dda7f0732b9f4ca05fb052b64e23d177131d9f32e9c5b942209eb7229e9a07c99a5d93245f53af18a09a137197a43a880648d5887cce656a5e6bbbe5e44ecb4f264395ccaddbe1acca80808080808080808080808080a0df808080808080c9823262856176616c338080808080808080808573686f72748ac9823262856176616c33", + "0xcb65032e2f76c48b82b5c24b3db8f670ce73982869d38cd39a624f23d62a9e89" + ], + "out": [ + true + ] + }, + "key in the middle (node 4 of 6)": { + "in": [ + "0x6b657932", + "0x73686f7274", + "0xf8bea7e68416b65793a0f3f387240403976788281c0a6ee5b3fc08360d276039d635bb824ea7e6fed779b873f87180a034d14ccc7685aa2beb64f78b11ee2a335eae82047ef97c79b7dda7f0732b9f4ca05fb052b64e23d177131d9f32e9c5b942209eb7229e9a07c99a5d93245f53af18a09a137197a43a880648d5887cce656a5e6bbbe5e44ecb4f264395ccaddbe1acca80808080808080808080808080a0df808080808080c9823262856176616c338080808080808080808573686f7274", + "0xcb65032e2f76c48b82b5c24b3db8f670ce73982869d38cd39a624f23d62a9e89" + ], + "out": [ + true + ] + }, + "key in the middle (node 5 of 6)": { + "in": [ + "0x6b6579336363", + "0x6176616c33", + "0xf8e5a7e68416b65793a0f3f387240403976788281c0a6ee5b3fc08360d276039d635bb824ea7e6fed779b873f87180a034d14ccc7685aa2beb64f78b11ee2a335eae82047ef97c79b7dda7f0732b9f4ca05fb052b64e23d177131d9f32e9c5b942209eb7229e9a07c99a5d93245f53af18a09a137197a43a880648d5887cce656a5e6bbbe5e44ecb4f264395ccaddbe1acca80808080808080808080808080b83bf839808080808080c9823363856176616c338080808080808080809f313233343536373839303132333435363738393031323334353637383930318ac9823363856176616c33", + "0xcb65032e2f76c48b82b5c24b3db8f670ce73982869d38cd39a624f23d62a9e89" + ], + "out": [ + true + ] + }, + "embedded extension node (node 1 of 3)": { + "in": [ + "0x61", + "0x61", + "0xf8389ad916d780c22061c22062c220638080808080808080808080808098d780c22061c22062c220638080808080808080808080808083c22061", + "0x72e6c01ad0c9a7b517d4bc68a5b323287fe80f0e68f5415b4b95ecbc8ad83978" + ], + "out": [ + true + ] + }, + "embedded extension node (node 2 of 3)": { + "in": [ + "0x62", + "0x62", + "0xf8389ad916d780c22061c22062c220638080808080808080808080808098d780c22061c22062c220638080808080808080808080808083c22062", + "0x72e6c01ad0c9a7b517d4bc68a5b323287fe80f0e68f5415b4b95ecbc8ad83978" + ], + "out": [ + true + ] + }, + "embedded extension node (node 3 of 3)": { + "in": [ + "0x63", + "0x63", + "0xf8389ad916d780c22061c22062c220638080808080808080808080808098d780c22061c22062c220638080808080808080808080808083c22063", + "0x72e6c01ad0c9a7b517d4bc68a5b323287fe80f0e68f5415b4b95ecbc8ad83978" + ], + "out": [ + true + ] + }, + "arbitrary proof (128 nodes)": { + "in": [ + "0x62303236303063643530623533393762316233646561653437336538353661346435383763623634643436393830656434333061343832623832666635343139", + "0x64326331653939666237663661333132666364393263393738366164313935383236333038323066353934616435626566376363643133343463366363663866", + "0xf9029bb853f851808080a0263d78c5fd9968de40bbf3c9e54e46473ef873a6904ddea719e7c3d3dab8add38080a065ee105383f2f9afd87c32dff662715552f56e99619a6743e09386cf62f17fa680808080808080808080b8d3f8d180a0451fb51c00ca685f7a3b19c044491cd8e574f5a971b379249f3cb7a42aa2a13aa079c1b33a8132befd9ee33339a2040bffa955f2d024f81e9c8f8c10401ccbe294a09d80ad4228d7197dea4a8b18f7a99d34f28cb0ac1a5836a7cb93ffbaaf941464a08a56e14745b9622dbc8e80a33e1218e44b16860fd58f951610b963ee32462990a03f7186d3342a4a4084d1e8c22a40675a9df1dc130bd7a31ce2f89fc659de374ba065cbb9b66782fa5c519b78c5b2261ad005c47075b4ee8c08bc71255a4944027680808080808080808080b853f851808080a0e70153be669d9e0419001376857985895f1485f277d814fa41b6171038cae59c8080a01f76b2175e50963b4c2f5f8897eed7a3829cd0727d198138cf723b72ca3468f780808080808080808080b893f891a04ffa3d1d0c9eef905cf8cb924fe74c43715aa85c26c116c91a45e3599ef21e75a0c9b0859699e3d7f8367b4ca50f2b08acf1eea13d1dd0bb9b4155c4f67f4a5eea808080a0abe45f156c2bf6c743021a1aa9701ca27d384413bb25207685e3702791946a5f80a0042d75b1c061f41dcb5589780712929a0dff5ba1574a00fc6dad0ad3b99aa307808080808080808080b885f883b83f203236303063643530623533393762316233646561653437336538353661346435383763623634643436393830656434333061343832623832666635343139b84064326331653939666237663661333132666364393263393738366164313935383236333038323066353934616435626566376363643133343463366363663866", + "0xf450a6e84cd1e88c4736f19e62a46441d7e278d2be7e8031b892c20fdd58d8f0" + ], + "out": [ + true + ] + }, + "arbitrary proof (256 nodes)": { + "in": [ + "0x64323930653331633662626339626130366139636465396635613463613434653737376133636237646165633937616432356661366264306536376431656539", + "0x36376538393266633931613736666130353365653138653439346565626339333231643936346438643166353630373436336565623334636435346665653938", + "0xf90373b853f851808080a0e82a9307013181b63bc631d9a72d8614ef53e14f57e7057ea40248fd0365716b8080a090721eb78858d84cfac57acc5fbe94ae8dba37b4d07c3e32e41929e20d793c6b80808080808080808080b8d3f8d180a0e8c88de9ecbbf4e12cc6aea87816733a25b50897cce68b04586dda7f69de71cca057b16f8b274f592ce9b76dd99444c506c554ef94e89abfc3f494c2c107402825a0e872edcec2088c1b0e28df3c238dee6326f36f2e6433dd6ba19cd1bc87631e5da041aaf5bd0b0f34049bbdbf1075ed79172bfaa5fc01002172fe58fbe7e2ccc6efa0a3167dd56c5070e353a8916d579f925932014ea982310e518d1916135671cc1ca0bf01933a5eb008945c734b8bd48b63177e9ad957bca3d676ed5eebfdb07367fe80808080808080808080b853f851808080a06f261637fdf4fd2ab7c63f93277ca37890e77c78ae8b132be882dfaf9b6293478080a0ab64547cb8ac7ee4550faaa792bdc6a906765b13c05edca5278ec6f34334f14180808080808080808080b8f3f8f18080a065f9749a6a0b992f5a4353e371d9c63d91648992b1eb6ae01ad8f62c965427a6a09512ebc2ead7a32b012bd5c72415541e4f90ffdf9549a96d884f47c9f2383937a06d6aa51d8d27a8cdc37115bfcbad5b489b95765d153594d77b25c41f7541223aa002554946d309fd21844d842c39e46f093e785403a46afb6957ab397b86c18f09a0a2d639fef7fb5dd52c7a2f3eb0703a0feb0558c524cc143d15ff9825c2c0b484a084f5a69d626b19ef0ae2705491bc237e4745d0d4cdd33a7dc3d1382a6eac0a6c80a03fdb322001905e71930066f5eafa499c9a5015db3a05be5d18ae8c2f46871dc680808080808080a3e213a025e631c84989b7d4360ca2eacc18f8e5ce6ecebb6d46ec6ed90e6c1215a0d53eb853f851808080a01cf50a2d534c03dd42e42986faecd8eb25f414d8e95c43bccd93ab0156f1948b8080808080a0b937b43f8140aa909ee07e2926df642ee3fd037391251943e68d7f3e8a45b10080808080808080b884f882b83e2030653331633662626339626130366139636465396635613463613434653737376133636237646165633937616432356661366264306536376431656539b84036376538393266633931613736666130353365653138653439346565626339333231643936346438643166353630373436336565623334636435346665653938", + "0xd4c61c8eac944a1efd2add3ae58fae739e125fb20eedd6982725ae28e2dd8832" + ], + "out": [ + true + ] + }, + "arbitrary proof (512 nodes)": { + "in": [ + "0x30643137666135653037613430366166303734353434616163373133393434636366316138333863336261616530653236643533373837333566383931303664", + "0x30666464376438333431346665323264383534636665306232353031623065613864633337626639643738323765366265373631376333616138666132656362", + "0xf90406b853f851808080a0986c43ec04f20a5f840376e88792825cc36ed22d667afc8a4de8ca51a800ff9e8080a09e30593085f4b2f9105fcbab1535fc3830f002f5cce6cfdb28bb47242a5eb0d480808080808080808080b90154f90151a0c3377f117808ffda9540b34bc2462fd550460a184702a0d2b9bb1c08cb1911b2a0fe5312e04360355ebe6ea01af3c7be6330d9bd830921fbb1c00bc9eee79d01f1a07426a671125a91fe569577350bda466a176b86974a2da7fd5a5b3727cb193adaa0b941e322b523b68ae87d92da26e10118db53eb21e73b22d13a27535950bc327aa0244d5539892b472b1b0e42307b2bdf37deb8f884d5e409e562c877d359e5508fa0386c39ea3a957fd00ec258d8544fa27ed0efcb0710b874ba426373327fcf862aa00eb8c7848c95e74162d0418fa2efe365d1403326d52213790f9986b03685021da0fbabd66454942ba322cf8c3f3188cbe6cfc49d7de84068e3badf309bbe315e87a04a6ca2da03c5336b71f0281e4d4e0028a0a9b5cd10abc1fe966f11f6e260af75a0e6461917b4d216eeb2a47dc9ceae5f0d6bc5ee2778749b4edfad0c20e2be1ca480808080808080b853f851808080a0074b266998de98a026f62521d89dbda085bf10e7e1a461fc68f8740800166d738080a010e6611a79918c6e72cb8febcef11148b099a3bf12d8b849176d891d5d1b27da80808080808080808080b8d3f8d180a00e77c34d01560ddc1f0bec7821ce90d52f7d1155678fc0e4ce8be101abe94950a0e1bcc7aadf8bfa98a8d62997aee2eede55b84e056c56e85cc8e34658c79f9845a04ea9ad8b927af52ea15728141ce4209af93e521cf85a5c30c0d3578bf50bdda5a068c96643aa80297b7ea04ba70b40faeb39aa9b600f066c6c21c4c616aeb7f579a0813ed83afaaafabe055a27a2ca52826e9afcd95a700d55c24472a72486b275cca0b3c8c7ddf792c658c18b6da0c43f2381e35c995544402127de457ad9a69c4cc980808080808080808080b853f851808080a0e3bbd8835493be2266c3a4f4603a3f8318a4295e8f80d3b92b58b854f9f217998080a04b84bac7ffc30073a283ab3fd8d1035225fe2a670f3bc8da6633da2107a6ea1980808080808080808080b853f85180a04864ba68ed6e2baf1614729de3c40162608039dd1a001f4e64f248255a747bce8080a09d6fefed58a095129b74c1e79c16178d14b67fc1f6f82e9f43d9dcda0a9c8b2c808080808080808080808080b884f882b83e2037666135653037613430366166303734353434616163373133393434636366316138333863336261616530653236643533373837333566383931303664b84030666464376438333431346665323264383534636665306232353031623065613864633337626639643738323765366265373631376333616138666132656362", + "0x875642b42ff718ca2298d5c24e3129e470275f7f1bea5e756a620aa6f84d7172" + ], + "out": [ + true + ] + }, + "arbitrary proof (1024 nodes)": { + "in": [ + "0x30613131623633616333643537616662626264643239623066313930663635303161353939646639646338383865326566633662623734326166393731353035", + "0x38303830666232376435303134393465376330666466346633323437396139656638326564383332616337383036646266303665616338353965376230666133", + "0xf90426b853f851808080a0d4e608f94f154c1086f14a3d0888aed6b264db44e295aeafcffec7af109cb3378080a0f35bba5f59720501bc9322f7489dd67e6e7d3182f3a0803d58881ea678c51a4580808080808080808080b90154f90151a0aca67bc56654411de846fb02d7fe66c3834d03519b0f58ecb86ccccc17dc1399a0a9856669cad391a03c193ec6dec2bc15bbcea1acff562aa322181d34bc15eae4a03ec4276daba3e20c341125fd1c239a3a59c68eaa8e662e04da9ee64555889b1ca0e53bd7370aab8439016df7bac1123e86aaab5f7d5fd7f70af271ba448716f627a0c3c137d47a74805600496927e626ea4e79e2abeb2cb7f24a746d9662de860693a09cd8e70d490b419266d209ca8830451e80a35378a57de1a3261c29f36a8ad480a02eed65535212cbad5b39bc59f4cb452839b94e15d852437c9b5075ab34ed78cba07137faf42fdeca8e0e6cad69be7a5d3b29dad2b5f881eae0261106f5e2afb017a0b0900dd08af215ddf59cb4aeff3367d4444bcfec999dc1241721500347dbb7dba03c57e508e13cd3ffec967ede493c43d0563eb2c67c4667bff443ae2546b75b5b80808080808080b853f851808080a051e8a2f385000faf1d92de1b23944ebd993dbed3b6b2db2c20a489a953c3f0828080a0760a75a384b342463c2c480a7875f967b8e2d664449b929cf2e4b1b884adb46e80808080808080808080b8d3f8d180a0ecb828ea580e16d237d4434fa01cd0712d6fda158bd8dc12a44d43736093ca80a02c3e341ba7cbb05876636d05ab2e0374f59b92fe21dfe74309ce1fe56edf692fa054a1b2ea1e057917e392a0c2c429e6b031c3f4a3cd1d9c36f2c45875ab6dfd25a007b648f34e53427c6770f1c556945d34f050f07a14f900fb852e7c514b45b068a0d4687eaa067aa1867147553a6dfc8e9d18c4afac87d44da258ecb35e5f96d89ba0d94e3a9ca51e70cda51dc56181afeb455774020367b71bc2d443c68cf563d6ce80808080808080808080b853f851808080a0185913e6e8315626922bbda00b2bc25841199d74af4083112ec596c446a3f1228080a035640fa9723db26d80b30ddcfca810e4782bb9f15a623d22050c443483ee653180808080808080808080b873f871a04f84c13bcdec814ba4ca136f37f40cb23ec1243577d2c0a06cc09bc8451e58e2a01544eae89eca15f429e589675458d781bcb94ac146fd84b3753acd5f255023c580a0bfcff9408e67a35a633ab460d44cccae0588ff8fccd0ae52311d55bcfa9ef57280808080808080808080808080b884f882b83e2031623633616333643537616662626264643239623066313930663635303161353939646639646338383865326566633662623734326166393731353035b84038303830666232376435303134393465376330666466346633323437396139656638326564383332616337383036646266303665616338353965376230666133", + "0xbe40ba4e41f77aa0c9760c2632971ea92b6c2ddcab3ba6939ab3f644aba1d0c5" + ], + "out": [ + true + ] + }, + "arbitrary proof (2048 nodes)": { + "in": [ + "0x39633962623638323335393839323064623565323666306633636437626665343137366232343163383963333565373061323134373033643136356361616466", + "0x64393730343035346366613034306461346630373835313765316164363863336535316130336334396565373664396532393863396664656665663238333634", + "0xf90446b853f851808080a047cb3fcbe8077e8b5ccb4bd11d4e0385d26d4787259fbecd00406f4e4ceaac3a8080a04e1ee8279d78768445fdca4279172e63bdc4fa45ffe4793833e742dd532f7b3280808080808080808080b90154f90151a085f4a041e77f796039ac0e9b9ec972c7844dceb86b78e0d4d375d23497f67571a07fc1b9fba3de725d8419c6cfdc1c18c881800b320a4f197d944f8aefdcacb839a047b8c3b56ce6ab98642a461be1e87a09670a0e5b10766c11628e4aed02e58d96a0fa9f4f1db6f160f63ad02561c84c2926c0f91e28d592b7e5f25ab10e19247b00a0efd94cabb8fe54c224676c4a2d3fdaef7f797730aff42f05332b9897ad42b7fba0133ecca6da5528773f28e5640bd73c93215158193e5fcd5f57b40bd14cbee2b2a01d3919603586ebd347a0fbd6309adf42915432af91b6e1db6c49d25670754d6fa087b9cbe0cd61776540a84140464b7ba454009f2c18c828923145c419df478364a03a8b63739f9b25d5ec9182054c2511101152c5f7a0f4691ff7a014271c576fe9a082e004fb330f1e80956d1ef078f20efbec693528966d39f5a43ed12db482ef2c80808080808080b853f851808080a013d63cdd329388e9ad63e9e463355ef3f7bcc934aab10df83d0a92c6c0df99248080a0b9200cf83d6c887765012fa60ef295ad3394e34767e1f36dce1e951f08db820880808080808080808080b8d3f8d180a0047ba91080246e4bb0d7b8d6293449da0c4d04547627ffba0c73d9b36c0fc3faa0544c5e09b3c8e026b6752c057796e60978551d6ce77ccb6d26b71541cbf0ca13a02acf313da117de9e79c9fa88722d3146b240fafee0e4b37e8d1d2b4335d3c69da03f3ddc358c86b9b6ee2ba6eaa060ff3ed101626d26fcf25b9aafc867ea3b7bf5a0b65f0b79df2b27069da6070228c218026d501bee60b69b77c370b7450f027c87a0f659a7dea2ce9afe7753880268fbc913caf6d3fc4026d80934761046dcc2920b80808080808080808080b853f851808080a01c635a046d3838114189b399619b8f7d3bd0efe01152ab66a0d84be2686da2d28080a0fb27c1c13e354fe60d19fa2e7df2ea4688c656f4a6303445802e5dcf5fbdd8fe80808080808080808080b893f891a06740882da49a2e1ff126e3ba6fac2d2bb7d6dc8275585f3ede5b64c58bda2b338080a0402217be9e51170cd6a8a04dc94c9d0e8f8bb6c11f8b47a912334c1bba1653e6808080a0f3ef10a49d2164f97ae2fd436ec32ff14158ec1d3a435ac7a57b4388d8a43af680a06d650f375a4af0b5098322bb24a7cc880009bc7d1cdc5e829acb57f88f1f1e7180808080808080b884f882b83e2062623638323335393839323064623565323666306633636437626665343137366232343163383963333565373061323134373033643136356361616466b84064393730343035346366613034306461346630373835313765316164363863336535316130336334396565373664396532393863396664656665663238333634", + "0xcd3b3e76709fd984090ceffa27db7ece94d425d044bee7c68d18b03234915f94" + ], + "out": [ + true + ] + } + }, + "verifyExclusionProof": { + "existing key, different value": { + "in": [ + "0x6b6579316161", + "0x6e6f742074686520636f72726563742076616c7565", + "0xf8a2a7e68416b65793a03101b4447781f1e6c51ce76c709274fc80bd064f3a58ff981b6015348a826386b847f84580a0582eed8dd051b823d13f8648cdcd08aa2d8dac239f458863c4620e8c4d605debca83206262856176616c32ca83206363856176616c3380808080808080808080808080b0ef83206161aa303132333435363738393031323334353637383930313233343536373839303132333435363738397878", + "0xd582f99275e227a1cf4284899e5ff06ee56da8859be71b553397c69151bc942f" + ], + "out": [ + true + ] + }, + "non-existent extension of a leaf": { + "in": [ + "0x6b657931616162", + "0x736f6d65206172626974726172792076616c7565", + "0xf8a2a7e68416b65793a03101b4447781f1e6c51ce76c709274fc80bd064f3a58ff981b6015348a826386b847f84580a0582eed8dd051b823d13f8648cdcd08aa2d8dac239f458863c4620e8c4d605debca83206262856176616c32ca83206363856176616c3380808080808080808080808080b0ef83206161aa303132333435363738393031323334353637383930313233343536373839303132333435363738397878", + "0xd582f99275e227a1cf4284899e5ff06ee56da8859be71b553397c69151bc942f" + ], + "out": [ + true + ] + }, + "non-existent extension of a branch": { + "in": [ + "0x6b6579346464", + "0x736f6d65206172626974726172792076616c7565", + "0xf871a7e68416b65793a03101b4447781f1e6c51ce76c709274fc80bd064f3a58ff981b6015348a826386b847f84580a0582eed8dd051b823d13f8648cdcd08aa2d8dac239f458863c4620e8c4d605debca83206262856176616c32ca83206363856176616c3380808080808080808080808080", + "0xd582f99275e227a1cf4284899e5ff06ee56da8859be71b553397c69151bc942f" + ], + "out": [ + true + ] + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/test/data/json/libraries/utils/Lib_Bytes32Utils.test.json b/packages/contracts/test/data/json/libraries/utils/Lib_Bytes32Utils.test.json new file mode 100644 index 000000000000..1b0feef1d02a --- /dev/null +++ b/packages/contracts/test/data/json/libraries/utils/Lib_Bytes32Utils.test.json @@ -0,0 +1,48 @@ +{ + "tests": { + "toBool": { + "input bytes32 of 0": { + "in": ["0x0000000000000000000000000000000000000000000000000000000000000000"], + "out": [false] + }, + "input bytes32 of 1": { + "in": ["0x0000000000000000000000000000000000000000000000000000000000000001"], + "out": [true] + }, + "input bytes32 > 1": { + "in": ["0x1212121212121212121212121212121212121212121212121212121212121212"], + "out": [true] + }, + "input bytes32 > 1, last byte 0": { + "in": ["0x1212121212121212121212121212121212121212121212121212121212121200"], + "out": [true] + } + }, + "fromBool": { + "input false": { + "in": [false], + "out": ["0x0000000000000000000000000000000000000000000000000000000000000000"] + }, + "input true": { + "in": [true], + "out": ["0x0000000000000000000000000000000000000000000000000000000000000001"] + } + }, + "toAddress": { + "input bytes32 address": { + "in": ["0x0000000000000000000000001212121212121212121212121212121212121212"], + "out": ["0x1212121212121212121212121212121212121212"] + }, + "input full bytes32": { + "in": ["0x1212121212121212121212121212121212121212121212121212121212121212"], + "out": ["0x1212121212121212121212121212121212121212"] + } + }, + "fromAddress": { + "input address": { + "in": ["0x1212121212121212121212121212121212121212"], + "out": ["0x0000000000000000000000001212121212121212121212121212121212121212"] + } + } + } +} diff --git a/packages/contracts/test/data/json/libraries/utils/Lib_BytesUtils.test.json b/packages/contracts/test/data/json/libraries/utils/Lib_BytesUtils.test.json new file mode 100644 index 000000000000..a81609448808 --- /dev/null +++ b/packages/contracts/test/data/json/libraries/utils/Lib_BytesUtils.test.json @@ -0,0 +1,108 @@ +{ + "tests": { + "slice": { + "start zero, length = 0": { + "in": ["0x12345678", 0, 0], + "out": ["0x"] + }, + "start zero, length = input.length": { + "in": ["0x12345678", 0, 4], + "out": ["0x12345678"] + }, + "start zero, length > 0 and length < input.length": { + "in": ["0x12345678", 0, 2], + "out": ["0x1234"] + }, + "start zero, length > input.length": { + "in": ["0x12345678", 0, 5], + "revert": "Read out of bounds" + }, + "start > 0 and <= input.length, length = 0": { + "in": ["0x12345678", 2, 0], + "out": ["0x"] + }, + "start > 0 and <= input.length, length = input.length - start": { + "in": ["0x12345678", 2, 2], + "out": ["0x5678"] + }, + "start > 0 and <= input.length, length < input.length - start": { + "in": ["0x12345678", 2, 1], + "out": ["0x56"] + }, + "start > 0 and <= input.length, length > input.length - start": { + "in": ["0x12345678", 2, 3], + "revert": "Read out of bounds" + }, + "start > input.length": { + "in": ["0x12345678", 5, 1], + "revert":"Read out of bounds" + } + }, + "toBytes32": { + "input.length < 32 bytes": { + "in": ["0x1234"], + "out": ["0x1234000000000000000000000000000000000000000000000000000000000000"] + }, + "input.length = 32 bytes": { + "in": ["0x1234123412341234123412341234123412341234123412341234123412341234"], + "out": ["0x1234123412341234123412341234123412341234123412341234123412341234"] + }, + "input.length > 32 bytes": { + "in": ["0x12341234123412341234123412341234123412341234123412341234123412345678567856785678567856785678567856785678567856785678567856785678"], + "out": ["0x1234123412341234123412341234123412341234123412341234123412341234"] + } + }, + "toUint256": { + "input.length < 32 bytes": { + "in": ["0x000000000000000000000000000000000000000000000000000000001234"], + "out": [305397760] + }, + "input.length = 32 bytes": { + "in": ["0x0000000000000000000000000000000000000000000000000000000000001234"], + "out": [4660] + }, + "input.length > 32 bytes": { + "in": ["0x00000000000000000000000000000000000000000000000000000000000012345678567856785678567856785678567856785678567856785678567856785678"], + "out": [4660] + } + }, + "toNibbles": { + "one byte": { + "in": ["0xff"], + "out": ["0x0f0f"] + }, + "two bytes": { + "in": ["0xffff"], + "out": ["0x0f0f0f0f"] + }, + "four bytes": { + "in": ["0xffffffff"], + "out": ["0x0f0f0f0f0f0f0f0f"] + } + }, + "fromNibbles": { + "two nibbles": { + "in": ["0x0f0f"], + "out": ["0xff"] + }, + "four nibbles": { + "in": ["0x0f0f0f0f"], + "out": ["0xffff"] + }, + "eight nibbles": { + "in": ["0x0f0f0f0f0f0f0f0f"], + "out": ["0xffffffff"] + } + }, + "equal": { + "same inputs": { + "in": ["0x1234", "0x1234"], + "out": [true] + }, + "different inputs": { + "in": ["0x1234", "0x4567"], + "out": [false] + } + } + } +} diff --git a/packages/contracts/test/data/json/libraries/utils/Lib_ECDSAUtils.test.json b/packages/contracts/test/data/json/libraries/utils/Lib_ECDSAUtils.test.json new file mode 100644 index 000000000000..40f15819442f --- /dev/null +++ b/packages/contracts/test/data/json/libraries/utils/Lib_ECDSAUtils.test.json @@ -0,0 +1,126 @@ +{ + "tests": { + "recover": { + "standard hash, valid signature": { + "in": [ + "0xf83d80808094121212121212121212121212121212121212121280a0bc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a6c8080", + false, + "0x01", + "0x057bf1c0edf0a9002a79f8c9b39683f6453a18e73e02364270a2b6ee8117f11a", + "0x5f8181365a222c7b05a84c29a29754e6a925952d3bf4bd65a6259ef37ee048e3" + ], + "out": [ + "0x17ec8597ff92C3F44523bDc65BF0f1bE632917ff" + ] + }, + "standard hash, invalid v parameter": { + "in": [ + "0xf83d80808094121212121212121212121212121212121212121280a0bc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a6c8080", + false, + "0xfc", + "0x057bf1c0edf0a9002a79f8c9b39683f6453a18e73e02364270a2b6ee8117f11a", + "0x5f8181365a222c7b05a84c29a29754e6a925952d3bf4bd65a6259ef37ee048e3" + ], + "out": [ + "0x0000000000000000000000000000000000000000" + ] + }, + "standard hash, invalid r parameter": { + "in": [ + "0xf83d80808094121212121212121212121212121212121212121280a0bc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a6c8080", + false, + "0x01", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x5f8181365a222c7b05a84c29a29754e6a925952d3bf4bd65a6259ef37ee048e3" + ], + "out": [ + "0x0000000000000000000000000000000000000000" + ] + }, + "standard hash, invalid s parameter": { + "in": [ + "0xf83d80808094121212121212121212121212121212121212121280a0bc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a6c8080", + false, + "0x01", + "0x057bf1c0edf0a9002a79f8c9b39683f6453a18e73e02364270a2b6ee8117f11a", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "out": [ + "0x0000000000000000000000000000000000000000" + ] + }, + "standard hash, invalid message": { + "in": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + false, + "0x01", + "0x057bf1c0edf0a9002a79f8c9b39683f6453a18e73e02364270a2b6ee8117f11a", + "0x5f8181365a222c7b05a84c29a29754e6a925952d3bf4bd65a6259ef37ee048e3" + ], + "out": [ + "0x1397890fcfC2D7563Aa01cE93A217b9809D3447B" + ] + }, + "eth signed message hash, valid signature": { + "in": [ + "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006c000000000000000000000000121212121212121212121212121212121212121200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000020bc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a", + true, + "0x01", + "0xe5a2edb71b6d76a8aacd59467d3063fd455ca13a4e9cb57da6f25849d40e4e2a", + "0x5465373d68d521845e3ffd2baf4c51f3d21c990914c09490b32ffc0b322dbf98" + ], + "out": [ + "0x17ec8597ff92C3F44523bDc65BF0f1bE632917ff" + ] + }, + "eth signed message hash, invalid v parameter": { + "in": [ + "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006c000000000000000000000000121212121212121212121212121212121212121200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000020bc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a", + true, + "0x1c", + "0xe5a2edb71b6d76a8aacd59467d3063fd455ca13a4e9cb57da6f25849d40e4e2a", + "0x5465373d68d521845e3ffd2baf4c51f3d21c990914c09490b32ffc0b322dbf98" + ], + "out": [ + "0x0000000000000000000000000000000000000000" + ] + }, + "eth signed message hash, invalid r parameter": { + "in": [ + "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006c000000000000000000000000121212121212121212121212121212121212121200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000020bc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a", + true, + "0x01", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x5465373d68d521845e3ffd2baf4c51f3d21c990914c09490b32ffc0b322dbf98" + ], + "out": [ + "0x0000000000000000000000000000000000000000" + ] + }, + "eth signed message hash, invalid s parameter": { + "in": [ + "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006c000000000000000000000000121212121212121212121212121212121212121200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000020bc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a", + true, + "0x01", + "0xe5a2edb71b6d76a8aacd59467d3063fd455ca13a4e9cb57da6f25849d40e4e2a", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "out": [ + "0x0000000000000000000000000000000000000000" + ] + }, + "eth signed message hash, invalid message": { + "in": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + true, + "0x01", + "0xe5a2edb71b6d76a8aacd59467d3063fd455ca13a4e9cb57da6f25849d40e4e2a", + "0x5465373d68d521845e3ffd2baf4c51f3d21c990914c09490b32ffc0b322dbf98" + ], + "out": [ + "0xf8bd1421f9D28C8F58f33B25a6faB16F3f89b749" + ] + } + } + } +} diff --git a/packages/contracts/test/data/json/safety-checker.test.json b/packages/contracts/test/data/json/safety-checker.test.json new file mode 100644 index 000000000000..8e0bb1fceae4 --- /dev/null +++ b/packages/contracts/test/data/json/safety-checker.test.json @@ -0,0 +1,1112 @@ +{ + "tests": { + "single opcode blacklisted: ADDRESS": { + "in": "0x30", + "out": false + }, + "single opcode blacklisted: BALANCE": { + "in": "0x31", + "out": false + }, + "single opcode blacklisted: BLOCKHASH": { + "in": "0x40", + "out": false + }, + "single opcode blacklisted: CALL": { + "in": "0xf1", + "out": false + }, + "single opcode blacklisted: CALLCODE": { + "in": "0xf2", + "out": false + }, + "single opcode blacklisted: CHAINID": { + "in": "0x46", + "out": false + }, + "single opcode blacklisted: COINBASE": { + "in": "0x41", + "out": false + }, + "single opcode blacklisted: CREATE": { + "in": "0xf0", + "out": false + }, + "single opcode blacklisted: CREATE2": { + "in": "0xf5", + "out": false + }, + "single opcode blacklisted: DELEGATECALL": { + "in": "0xf4", + "out": false + }, + "single opcode blacklisted: DIFFICULTY": { + "in": "0x44", + "out": false + }, + "single opcode blacklisted: EXTCODESIZE": { + "in": "0x3b", + "out": false + }, + "single opcode blacklisted: EXTCODECOPY": { + "in": "0x3c", + "out": false + }, + "single opcode blacklisted: EXTCODEHASH": { + "in": "0x3f", + "out": false + }, + "single opcode blacklisted: GASLIMIT": { + "in": "0x45", + "out": false + }, + "single opcode blacklisted: GASPRICE": { + "in": "0x3a", + "out": false + }, + "single opcode blacklisted: NUMBER": { + "in": "0x43", + "out": false + }, + "single opcode blacklisted: ORIGIN": { + "in": "0x32", + "out": false + }, + "single opcode blacklisted: REVERT": { + "in": "0xfd", + "out": false + }, + "single opcode blacklisted: SELFBALANCE": { + "in": "0x47", + "out": false + }, + "single opcode blacklisted: SELFDESTRUCT": { + "in": "0xff", + "out": false + }, + "single opcode blacklisted: SLOAD": { + "in": "0x54", + "out": false + }, + "single opcode blacklisted: SSTORE": { + "in": "0x55", + "out": false + }, + "single opcode blacklisted: STATICCALL": { + "in": "0xfa", + "out": false + }, + "single opcode blacklisted: TIMESTAMP": { + "in": "0x42", + "out": false + }, + "single opcode whitelisted: ADD": { + "in": "0x01", + "out": true + }, + "single opcode whitelisted: MUL": { + "in": "0x02", + "out": true + }, + "single opcode whitelisted: SUB": { + "in": "0x03", + "out": true + }, + "single opcode whitelisted: DIV": { + "in": "0x04", + "out": true + }, + "single opcode whitelisted: SDIV": { + "in": "0x05", + "out": true + }, + "single opcode whitelisted: MOD": { + "in": "0x06", + "out": true + }, + "single opcode whitelisted: SMOD": { + "in": "0x07", + "out": true + }, + "single opcode whitelisted: ADDMOD": { + "in": "0x08", + "out": true + }, + "single opcode whitelisted: MULMOD": { + "in": "0x09", + "out": true + }, + "single opcode whitelisted: EXP": { + "in": "0x0a", + "out": true + }, + "single opcode whitelisted: SIGNEXTEND": { + "in": "0x0b", + "out": true + }, + "single opcode whitelisted: LT": { + "in": "0x10", + "out": true + }, + "single opcode whitelisted: GT": { + "in": "0x11", + "out": true + }, + "single opcode whitelisted: SLT": { + "in": "0x12", + "out": true + }, + "single opcode whitelisted: SGT": { + "in": "0x13", + "out": true + }, + "single opcode whitelisted: EQ": { + "in": "0x14", + "out": true + }, + "single opcode whitelisted: ISZERO": { + "in": "0x15", + "out": true + }, + "single opcode whitelisted: AND": { + "in": "0x16", + "out": true + }, + "single opcode whitelisted: OR": { + "in": "0x17", + "out": true + }, + "single opcode whitelisted: XOR": { + "in": "0x18", + "out": true + }, + "single opcode whitelisted: NOT": { + "in": "0x19", + "out": true + }, + "single opcode whitelisted: BYTE": { + "in": "0x1a", + "out": true + }, + "single opcode whitelisted: SHL": { + "in": "0x1b", + "out": true + }, + "single opcode whitelisted: SHR": { + "in": "0x1c", + "out": true + }, + "single opcode whitelisted: SAR": { + "in": "0x1d", + "out": true + }, + "single opcode whitelisted: SHA3": { + "in": "0x20", + "out": true + }, + "single opcode whitelisted: CALLVALUE": { + "in": "0x34", + "out": true + }, + "single opcode whitelisted: CALLDATALOAD": { + "in": "0x35", + "out": true + }, + "single opcode whitelisted: CALLDATASIZE": { + "in": "0x36", + "out": true + }, + "single opcode whitelisted: CALLDATACOPY": { + "in": "0x37", + "out": true + }, + "single opcode whitelisted: CODESIZE": { + "in": "0x38", + "out": true + }, + "single opcode whitelisted: CODECOPY": { + "in": "0x39", + "out": true + }, + "single opcode whitelisted: RETURNDATASIZE": { + "in": "0x3d", + "out": true + }, + "single opcode whitelisted: RETURNDATACOPY": { + "in": "0x3e", + "out": true + }, + "single opcode whitelisted: POP": { + "in": "0x50", + "out": true + }, + "single opcode whitelisted: MLOAD": { + "in": "0x51", + "out": true + }, + "single opcode whitelisted: MSTORE": { + "in": "0x52", + "out": true + }, + "single opcode whitelisted: MSTORE8": { + "in": "0x53", + "out": true + }, + "single opcode whitelisted: JUMPI": { + "in": "0x57", + "out": true + }, + "single opcode whitelisted: PC": { + "in": "0x58", + "out": true + }, + "single opcode whitelisted: MSIZE": { + "in": "0x59", + "out": true + }, + "single opcode whitelisted: GAS": { + "in": "0x5a", + "out": true + }, + "single opcode whitelisted: JUMPDEST": { + "in": "0x5b", + "out": true + }, + "single opcode whitelisted: DUP1": { + "in": "0x80", + "out": true + }, + "single opcode whitelisted: DUP2": { + "in": "0x81", + "out": true + }, + "single opcode whitelisted: DUP3": { + "in": "0x82", + "out": true + }, + "single opcode whitelisted: DUP4": { + "in": "0x83", + "out": true + }, + "single opcode whitelisted: DUP5": { + "in": "0x84", + "out": true + }, + "single opcode whitelisted: DUP6": { + "in": "0x85", + "out": true + }, + "single opcode whitelisted: DUP7": { + "in": "0x86", + "out": true + }, + "single opcode whitelisted: DUP8": { + "in": "0x87", + "out": true + }, + "single opcode whitelisted: DUP9": { + "in": "0x88", + "out": true + }, + "single opcode whitelisted: DUP10": { + "in": "0x89", + "out": true + }, + "single opcode whitelisted: DUP11": { + "in": "0x8a", + "out": true + }, + "single opcode whitelisted: DUP12": { + "in": "0x8b", + "out": true + }, + "single opcode whitelisted: DUP13": { + "in": "0x8c", + "out": true + }, + "single opcode whitelisted: DUP14": { + "in": "0x8d", + "out": true + }, + "single opcode whitelisted: DUP15": { + "in": "0x8e", + "out": true + }, + "single opcode whitelisted: DUP16": { + "in": "0x8f", + "out": true + }, + "single opcode whitelisted: SWAP1": { + "in": "0x90", + "out": true + }, + "single opcode whitelisted: SWAP2": { + "in": "0x91", + "out": true + }, + "single opcode whitelisted: SWAP3": { + "in": "0x92", + "out": true + }, + "single opcode whitelisted: SWAP4": { + "in": "0x93", + "out": true + }, + "single opcode whitelisted: SWAP5": { + "in": "0x94", + "out": true + }, + "single opcode whitelisted: SWAP6": { + "in": "0x95", + "out": true + }, + "single opcode whitelisted: SWAP7": { + "in": "0x96", + "out": true + }, + "single opcode whitelisted: SWAP8": { + "in": "0x97", + "out": true + }, + "single opcode whitelisted: SWAP9": { + "in": "0x98", + "out": true + }, + "single opcode whitelisted: SWAP10": { + "in": "0x99", + "out": true + }, + "single opcode whitelisted: SWAP11": { + "in": "0x9a", + "out": true + }, + "single opcode whitelisted: SWAP12": { + "in": "0x9b", + "out": true + }, + "single opcode whitelisted: SWAP13": { + "in": "0x9c", + "out": true + }, + "single opcode whitelisted: SWAP14": { + "in": "0x9d", + "out": true + }, + "single opcode whitelisted: SWAP15": { + "in": "0x9e", + "out": true + }, + "single opcode whitelisted: SWAP16": { + "in": "0x9f", + "out": true + }, + "single opcode whitelisted: LOG0": { + "in": "0xa0", + "out": true + }, + "single opcode whitelisted: LOG1": { + "in": "0xa1", + "out": true + }, + "single opcode whitelisted: LOG2": { + "in": "0xa2", + "out": true + }, + "single opcode whitelisted: LOG3": { + "in": "0xa3", + "out": true + }, + "single opcode whitelisted: LOG4": { + "in": "0xa4", + "out": true + }, + "PUSH opcode whitelisted end: PUSH1": { + "in": "0x6030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH2": { + "in": "0x613030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH3": { + "in": "0x62303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH4": { + "in": "0x6330303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH5": { + "in": "0x643030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH6": { + "in": "0x65303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH7": { + "in": "0x6630303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH8": { + "in": "0x673030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH9": { + "in": "0x68303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH10": { + "in": "0x6930303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH11": { + "in": "0x6a3030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH12": { + "in": "0x6b303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH13": { + "in": "0x6c30303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH14": { + "in": "0x6d3030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH15": { + "in": "0x6e303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH16": { + "in": "0x6f30303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH17": { + "in": "0x703030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH18": { + "in": "0x71303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH19": { + "in": "0x7230303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH20": { + "in": "0x733030303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH21": { + "in": "0x74303030303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH22": { + "in": "0x7530303030303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH23": { + "in": "0x763030303030303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH24": { + "in": "0x77303030303030303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH25": { + "in": "0x7830303030303030303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH26": { + "in": "0x793030303030303030303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH27": { + "in": "0x7a303030303030303030303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH28": { + "in": "0x7b30303030303030303030303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH29": { + "in": "0x7c3030303030303030303030303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH30": { + "in": "0x7d303030303030303030303030303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH31": { + "in": "0x7e30303030303030303030303030303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode whitelisted end: PUSH32": { + "in": "0x7f3030303030303030303030303030303030303030303030303030303030303030", + "out": true + }, + "PUSH opcode blacklisted end: PUSH1": { + "in": "0x603030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH2": { + "in": "0x61303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH3": { + "in": "0x6230303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH4": { + "in": "0x633030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH5": { + "in": "0x64303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH6": { + "in": "0x6530303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH7": { + "in": "0x663030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH8": { + "in": "0x67303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH9": { + "in": "0x6830303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH10": { + "in": "0x693030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH11": { + "in": "0x6a303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH12": { + "in": "0x6b30303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH13": { + "in": "0x6c3030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH14": { + "in": "0x6d303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH15": { + "in": "0x6e30303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH16": { + "in": "0x6f3030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH17": { + "in": "0x70303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH18": { + "in": "0x7130303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH19": { + "in": "0x723030303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH20": { + "in": "0x73303030303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH21": { + "in": "0x7430303030303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH22": { + "in": "0x753030303030303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH23": { + "in": "0x76303030303030303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH24": { + "in": "0x7730303030303030303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH25": { + "in": "0x783030303030303030303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH26": { + "in": "0x79303030303030303030303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH27": { + "in": "0x7a30303030303030303030303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH28": { + "in": "0x7b3030303030303030303030303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH29": { + "in": "0x7c303030303030303030303030303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH30": { + "in": "0x7d30303030303030303030303030303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH31": { + "in": "0x7e3030303030303030303030303030303030303030303030303030303030303030", + "out": false + }, + "PUSH opcode blacklisted end: PUSH32": { + "in": "0x7f303030303030303030303030303030303030303030303030303030303030303030", + "out": false + }, + "multiple opcodes whitelisted": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4", + "out": true + }, + "multiple opcodes blacklisted end: ADDRESS": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a430", + "out": false + }, + "multiple opcodes blacklisted end: BALANCE": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a431", + "out": false + }, + "multiple opcodes blacklisted end: BLOCKHASH": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a440", + "out": false + }, + "multiple opcodes blacklisted end: CALL": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4f1", + "out": false + }, + "multiple opcodes blacklisted end: CALLCODE": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4f2", + "out": false + }, + "multiple opcodes blacklisted end: CHAINID": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a446", + "out": false + }, + "multiple opcodes blacklisted end: COINBASE": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a441", + "out": false + }, + "multiple opcodes blacklisted end: CREATE": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4f0", + "out": false + }, + "multiple opcodes blacklisted end: CREATE2": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4f5", + "out": false + }, + "multiple opcodes blacklisted end: DELEGATECALL": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4f4", + "out": false + }, + "multiple opcodes blacklisted end: DIFFICULTY": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a444", + "out": false + }, + "multiple opcodes blacklisted end: EXTCODESIZE": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a43b", + "out": false + }, + "multiple opcodes blacklisted end: EXTCODECOPY": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a43c", + "out": false + }, + "multiple opcodes blacklisted end: EXTCODEHASH": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a43f", + "out": false + }, + "multiple opcodes blacklisted end: GASLIMIT": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a445", + "out": false + }, + "multiple opcodes blacklisted end: GASPRICE": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a43a", + "out": false + }, + "multiple opcodes blacklisted end: NUMBER": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a443", + "out": false + }, + "multiple opcodes blacklisted end: ORIGIN": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a432", + "out": false + }, + "multiple opcodes blacklisted end: REVERT": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4fd", + "out": false + }, + "multiple opcodes blacklisted end: SELFBALANCE": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a447", + "out": false + }, + "multiple opcodes blacklisted end: SELFDESTRUCT": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4ff", + "out": false + }, + "multiple opcodes blacklisted end: SLOAD": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a454", + "out": false + }, + "multiple opcodes blacklisted end: SSTORE": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a455", + "out": false + }, + "multiple opcodes blacklisted end: STATICCALL": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4fa", + "out": false + }, + "multiple opcodes blacklisted end: TIMESTAMP": { + "in": "0x0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b60306130306230303063303030306430303030306530303030303066303030303030306730303030303030306830303030303030303069303030303030303030306a30303030303030303030306b3030303030303030303030306c303030303030303030303030306d30303030303030303030303030306e3030303030303030303030303030306f303030303030303030303030303030307030303030303030303030303030303030307130303030303030303030303030303030303072303030303030303030303030303030303030307330303030303030303030303030303030303030307430303030303030303030303030303030303030303075303030303030303030303030303030303030303030307630303030303030303030303030303030303030303030307730303030303030303030303030303030303030303030303078303030303030303030303030303030303030303030303030307930303030303030303030303030303030303030303030303030307a3030303030303030303030303030303030303030303030303030307b303030303030303030303030303030303030303030303030303030307c30303030303030303030303030303030303030303030303030303030307d3030303030303030303030303030303030303030303030303030303030307e303030303030303030303030303030303030303030303030303030303030307f3030303030303030303030303030303030303030303030303030303030303030808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a442", + "out": false + }, + "blacklisted in unreachable code": { + "in": "0xfe303140f1f24641f0f5f4443b3c3f453a433247ff5455fa42", + "out": true + }, + "PUSH1 then 1 JUMPDESTs unreachable": { + "in": "0x00605b30", + "out": true + }, + "PUSH2 then 2 JUMPDESTs unreachable": { + "in": "0x00615b5b30", + "out": true + }, + "PUSH3 then 3 JUMPDESTs unreachable": { + "in": "0x00625b5b5b30", + "out": true + }, + "PUSH4 then 4 JUMPDESTs unreachable": { + "in": "0x00635b5b5b5b30", + "out": true + }, + "PUSH5 then 5 JUMPDESTs unreachable": { + "in": "0x00645b5b5b5b5b30", + "out": true + }, + "PUSH6 then 6 JUMPDESTs unreachable": { + "in": "0x00655b5b5b5b5b5b30", + "out": true + }, + "PUSH7 then 7 JUMPDESTs unreachable": { + "in": "0x00665b5b5b5b5b5b5b30", + "out": true + }, + "PUSH8 then 8 JUMPDESTs unreachable": { + "in": "0x00675b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH9 then 9 JUMPDESTs unreachable": { + "in": "0x00685b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH10 then 10 JUMPDESTs unreachable": { + "in": "0x00695b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH11 then 11 JUMPDESTs unreachable": { + "in": "0x006a5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH12 then 12 JUMPDESTs unreachable": { + "in": "0x006b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH13 then 13 JUMPDESTs unreachable": { + "in": "0x006c5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH14 then 14 JUMPDESTs unreachable": { + "in": "0x006d5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH15 then 15 JUMPDESTs unreachable": { + "in": "0x006e5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH16 then 16 JUMPDESTs unreachable": { + "in": "0x006f5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH17 then 17 JUMPDESTs unreachable": { + "in": "0x00705b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH18 then 18 JUMPDESTs unreachable": { + "in": "0x00715b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH19 then 19 JUMPDESTs unreachable": { + "in": "0x00725b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH20 then 20 JUMPDESTs unreachable": { + "in": "0x00735b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH21 then 21 JUMPDESTs unreachable": { + "in": "0x00745b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH22 then 22 JUMPDESTs unreachable": { + "in": "0x00755b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH23 then 23 JUMPDESTs unreachable": { + "in": "0x00765b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH24 then 24 JUMPDESTs unreachable": { + "in": "0x00775b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH25 then 25 JUMPDESTs unreachable": { + "in": "0x00785b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH26 then 26 JUMPDESTs unreachable": { + "in": "0x00795b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH27 then 27 JUMPDESTs unreachable": { + "in": "0x007a5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH28 then 28 JUMPDESTs unreachable": { + "in": "0x007b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH29 then 29 JUMPDESTs unreachable": { + "in": "0x007c5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH30 then 30 JUMPDESTs unreachable": { + "in": "0x007d5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH31 then 31 JUMPDESTs unreachable": { + "in": "0x007e5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH32 then 32 JUMPDESTs unreachable": { + "in": "0x007f5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b30", + "out": true + }, + "PUSH1 then 1 bytes then JUMPDEST reachable": { + "in": "0x0060305b30", + "out": false + }, + "PUSH2 then 2 bytes then JUMPDEST reachable": { + "in": "0x006130305b30", + "out": false + }, + "PUSH3 then 3 bytes then JUMPDEST reachable": { + "in": "0x00623030305b30", + "out": false + }, + "PUSH4 then 4 bytes then JUMPDEST reachable": { + "in": "0x0063303030305b30", + "out": false + }, + "PUSH5 then 5 bytes then JUMPDEST reachable": { + "in": "0x006430303030305b30", + "out": false + }, + "PUSH6 then 6 bytes then JUMPDEST reachable": { + "in": "0x00653030303030305b30", + "out": false + }, + "PUSH7 then 7 bytes then JUMPDEST reachable": { + "in": "0x0066303030303030305b30", + "out": false + }, + "PUSH8 then 8 bytes then JUMPDEST reachable": { + "in": "0x006730303030303030305b30", + "out": false + }, + "PUSH9 then 9 bytes then JUMPDEST reachable": { + "in": "0x00683030303030303030305b30", + "out": false + }, + "PUSH10 then 10 bytes then JUMPDEST reachable": { + "in": "0x0069303030303030303030305b30", + "out": false + }, + "PUSH11 then 11 bytes then JUMPDEST reachable": { + "in": "0x006a30303030303030303030305b30", + "out": false + }, + "PUSH12 then 12 bytes then JUMPDEST reachable": { + "in": "0x006b3030303030303030303030305b30", + "out": false + }, + "PUSH13 then 13 bytes then JUMPDEST reachable": { + "in": "0x006c303030303030303030303030305b30", + "out": false + }, + "PUSH14 then 14 bytes then JUMPDEST reachable": { + "in": "0x006d30303030303030303030303030305b30", + "out": false + }, + "PUSH15 then 15 bytes then JUMPDEST reachable": { + "in": "0x006e3030303030303030303030303030305b30", + "out": false + }, + "PUSH16 then 16 bytes then JUMPDEST reachable": { + "in": "0x006f303030303030303030303030303030305b30", + "out": false + }, + "PUSH17 then 17 bytes then JUMPDEST reachable": { + "in": "0x007030303030303030303030303030303030305b30", + "out": false + }, + "PUSH18 then 18 bytes then JUMPDEST reachable": { + "in": "0x00713030303030303030303030303030303030305b30", + "out": false + }, + "PUSH19 then 19 bytes then JUMPDEST reachable": { + "in": "0x0072303030303030303030303030303030303030305b30", + "out": false + }, + "PUSH20 then 20 bytes then JUMPDEST reachable": { + "in": "0x007330303030303030303030303030303030303030305b30", + "out": false + }, + "PUSH21 then 21 bytes then JUMPDEST reachable": { + "in": "0x00743030303030303030303030303030303030303030305b30", + "out": false + }, + "PUSH22 then 22 bytes then JUMPDEST reachable": { + "in": "0x0075303030303030303030303030303030303030303030305b30", + "out": false + }, + "PUSH23 then 23 bytes then JUMPDEST reachable": { + "in": "0x007630303030303030303030303030303030303030303030305b30", + "out": false + }, + "PUSH24 then 24 bytes then JUMPDEST reachable": { + "in": "0x00773030303030303030303030303030303030303030303030305b30", + "out": false + }, + "PUSH25 then 25 bytes then JUMPDEST reachable": { + "in": "0x0078303030303030303030303030303030303030303030303030305b30", + "out": false + }, + "PUSH26 then 26 bytes then JUMPDEST reachable": { + "in": "0x007930303030303030303030303030303030303030303030303030305b30", + "out": false + }, + "PUSH27 then 27 bytes then JUMPDEST reachable": { + "in": "0x007a3030303030303030303030303030303030303030303030303030305b30", + "out": false + }, + "PUSH28 then 28 bytes then JUMPDEST reachable": { + "in": "0x007b303030303030303030303030303030303030303030303030303030305b30", + "out": false + }, + "PUSH29 then 29 bytes then JUMPDEST reachable": { + "in": "0x007c30303030303030303030303030303030303030303030303030303030305b30", + "out": false + }, + "PUSH30 then 30 bytes then JUMPDEST reachable": { + "in": "0x007d3030303030303030303030303030303030303030303030303030303030305b30", + "out": false + }, + "PUSH31 then 31 bytes then JUMPDEST reachable": { + "in": "0x007e303030303030303030303030303030303030303030303030303030303030305b30", + "out": false + }, + "PUSH32 then 32 bytes then JUMPDEST reachable": { + "in": "0x007f30303030303030303030303030303030303030303030303030303030303030305b30", + "out": false + }, + "blacklisted after reachable JUMPDEST": { + "in": "0x565b303140f1f24641f0f5f4443b3c3f453a433247ff5455fa42", + "out": false + }, + "blacklisted after JUMPI": { + "in": "0x57303140f1f24641f0f5f4443b3c3f453a433247ff5455fa42", + "out": false + }, + "valid alternating reachable/unreachable with STOP": { + "in": "0x565b00303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a400303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a400303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4", + "out": true + }, + "valid alternating reachable/unreachable with RETURN": { + "in": "0x565bf3303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4f3303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4f3303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4", + "out": true + }, + "valid alternating reachable/unreachable with INVALID": { + "in": "0x565bfe303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4fe303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4fe303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4", + "out": true + }, + "invalid alternating reachable/unreachable with STOP": { + "in": "0x575b00303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a400303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a400303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a430", + "out": false + }, + "invalid alternating reachable/unreachable with RETURN": { + "in": "0x575bf3303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4f3303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4f3303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a430", + "out": false + }, + "invalid alternating reachable/unreachable with INVALID": { + "in": "0x575bfe303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4fe303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4fe303140f1f24641f0f5f4443b3c3f453a433247ff5455fa425b0102030405060708090a0b101112131415161718191a1b1c1d203435363738393d3e505152535758595a5b606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a430", + "out": false + }, + "valid EM call": { + "in": "0x336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b", + "out": true + }, + "valid identity precompile call": { + "in": "0x3350600060045af1", + "out": true + }, + "valid EM call, then valid identity precompile call": { + "in": "0x336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b3350600060045af1", + "out": true + }, + "valid EM call, then invalid identity precompile call": { + "in": "0x336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b3350600060035af1", + "out": false + }, + "valid EM call, then invalid opcode (SLOAD)": { + "in": "0x336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b54", + "out": false + }, + "valid identity precompile call, then invalid opcode (SLOAD)": { + "in": "0x3350600060045af154", + "out": false + }, + "invalid EM call (missing final byte)": { + "in": "0x336000905af158601d01573d60011458600c01573d6000803e3d6000FD5b60016000f3", + "out": false + }, + "invalid identity precompile call (missing final byte)": { + "in": "0x3350600060045a", + "out": false + }, + "invalid identity precompile call (First 2 bytes are PUSH2ed)": { + "in": "0x613350600060045af1", + "out": false + } + } +} \ No newline at end of file diff --git a/packages/contracts/test/helpers/codec/bridge.ts b/packages/contracts/test/helpers/codec/bridge.ts new file mode 100644 index 000000000000..7a70787bd6a9 --- /dev/null +++ b/packages/contracts/test/helpers/codec/bridge.ts @@ -0,0 +1,12 @@ +import { getContractInterface } from '../../../src/contract-defs' + +export const getXDomainCalldata = ( + sender: string, + target: string, + message: string, + messageNonce: number +): string => { + return getContractInterface( + 'OVM_L2CrossDomainMessenger' + ).encodeFunctionData('relayMessage', [target, sender, message, messageNonce]) +} diff --git a/packages/contracts/test/helpers/codec/encoding.ts b/packages/contracts/test/helpers/codec/encoding.ts new file mode 100644 index 000000000000..f7e16531fcd6 --- /dev/null +++ b/packages/contracts/test/helpers/codec/encoding.ts @@ -0,0 +1,151 @@ +/* External Imports */ +import { ethers } from 'hardhat' +import { constants, Wallet } from 'ethers' + +/* Internal Imports */ +import { remove0x, fromHexString } from '@eth-optimism/core-utils' + +export interface EIP155Transaction { + nonce: number + gasLimit: number + gasPrice: number + to: string + data: string + chainId: number +} + +export interface SignatureParameters { + messageHash: string + v: string + r: string + s: string +} + +export const DEFAULT_EIP155_TX: EIP155Transaction = { + to: `0x${'12'.repeat(20)}`, + nonce: 100, + gasLimit: 1000000, + gasPrice: 100000000, + data: `0x${'99'.repeat(10)}`, + chainId: 420, +} + +export const getRawSignedComponents = (signed: string): any[] => { + return [signed.slice(130, 132), signed.slice(2, 66), signed.slice(66, 130)] +} + +export const getSignedComponents = (signed: string): any[] => { + return ethers.utils.RLP.decode(signed).slice(-3) +} + +export const encodeCompactTransaction = (transaction: any): string => { + const nonce = ethers.utils.zeroPad(transaction.nonce, 3) + const gasLimit = ethers.utils.zeroPad(transaction.gasLimit, 3) + if (transaction.gasPrice % 1000000 !== 0) + throw Error('gas price must be a multiple of 1000000') + const compressedGasPrice: any = transaction.gasPrice / 1000000 + const gasPrice = ethers.utils.zeroPad(compressedGasPrice, 3) + const to = !transaction.to.length + ? fromHexString(constants.AddressZero) + : fromHexString(transaction.to) + const data = fromHexString(transaction.data) + + return Buffer.concat([ + Buffer.from(gasLimit), + Buffer.from(gasPrice), + Buffer.from(nonce), + Buffer.from(to), + data, + ]).toString('hex') +} + +export const serializeEthSignTransaction = ( + transaction: EIP155Transaction +): string => { + return ethers.utils.defaultAbiCoder.encode( + ['uint256', 'uint256', 'uint256', 'uint256', 'address', 'bytes'], + [ + transaction.nonce, + transaction.gasLimit, + transaction.gasPrice, + transaction.chainId, + transaction.to, + transaction.data, + ] + ) +} + +export const serializeNativeTransaction = ( + transaction: EIP155Transaction +): string => { + return ethers.utils.serializeTransaction(transaction) +} + +export const signEthSignMessage = async ( + wallet: Wallet, + transaction: EIP155Transaction +): Promise => { + const serializedTransaction = serializeEthSignTransaction(transaction) + const transactionHash = ethers.utils.keccak256(serializedTransaction) + const transactionHashBytes = ethers.utils.arrayify(transactionHash) + const transactionSignature = await wallet.signMessage(transactionHashBytes) + + const messageHash = ethers.utils.hashMessage(transactionHashBytes) + const [v, r, s] = getRawSignedComponents(transactionSignature).map( + (component) => { + return remove0x(component) + } + ) + return { + messageHash, + v: '0' + (parseInt(v, 16) - 27), + r, + s, + } +} + +export const signNativeTransaction = async ( + wallet: Wallet, + transaction: EIP155Transaction +): Promise => { + const serializedTransaction = serializeNativeTransaction(transaction) + const transactionSignature = await wallet.signTransaction(transaction) + + const messageHash = ethers.utils.keccak256(serializedTransaction) + const [v, r, s] = getSignedComponents(transactionSignature).map( + (component) => { + return remove0x(component) + } + ) + return { + messageHash, + v: '0' + (parseInt(v, 16) - transaction.chainId * 2 - 8 - 27), + r, + s, + } +} + +export const signTransaction = async ( + wallet: Wallet, + transaction: EIP155Transaction, + transactionType: number +): Promise => { + return transactionType === 2 + ? signEthSignMessage(wallet, transaction) //ETH Signed tx + : signNativeTransaction(wallet, transaction) //Create EOA tx or EIP155 tx +} + +export const encodeSequencerCalldata = async ( + wallet: Wallet, + transaction: EIP155Transaction, + transactionType: number +) => { + const sig = await signTransaction(wallet, transaction, transactionType) + const encodedTransaction = encodeCompactTransaction(transaction) + const dataPrefix = `0x0${transactionType}${sig.r}${sig.s}${sig.v}` + const calldata = + transactionType === 1 + ? `${dataPrefix}${remove0x(sig.messageHash)}` // Create EOA tx + : `${dataPrefix}${encodedTransaction}` // EIP155 tx or ETH Signed Tx + return calldata +} diff --git a/packages/contracts/test/helpers/codec/index.ts b/packages/contracts/test/helpers/codec/index.ts new file mode 100644 index 000000000000..5c9597ea85ac --- /dev/null +++ b/packages/contracts/test/helpers/codec/index.ts @@ -0,0 +1,3 @@ +export * from './revert-flags' +export * from './encoding' +export * from './bridge' diff --git a/packages/contracts/test/helpers/codec/revert-flags.ts b/packages/contracts/test/helpers/codec/revert-flags.ts new file mode 100644 index 000000000000..c0326b25dd9c --- /dev/null +++ b/packages/contracts/test/helpers/codec/revert-flags.ts @@ -0,0 +1,45 @@ +/* External Imports */ +import { ethers } from 'hardhat' + +export const encodeRevertData = ( + flag: number, + data: string = '0x', + nuisanceGasLeft: number = 0, + ovmGasRefund: number = 0 +): string => { + const abiEncoded: string = ethers.utils.defaultAbiCoder.encode( + ['uint256', 'uint256', 'uint256', 'bytes'], + [flag, nuisanceGasLeft, ovmGasRefund, data] + ) + return abiEncoded +} + +export const decodeRevertData = (revertData: string): any => { + const decoded = ethers.utils.defaultAbiCoder.decode( + ['uint256', 'uint256', 'uint256', 'bytes'], + revertData + ) + + return ( + '[revertFlag:' + + Object.keys(REVERT_FLAGS)[decoded[0]] + + ', nuisanceGasLeft:' + + decoded[1] + + ', ovmGasRefund: ' + + decoded[2] + + ', data: ' + + decoded[3] + + ']' + ) +} + +export const REVERT_FLAGS = { + OUT_OF_GAS: 0, + INTENTIONAL_REVERT: 1, + EXCEEDS_NUISANCE_GAS: 2, + INVALID_STATE_ACCESS: 3, + UNSAFE_BYTECODE: 4, + CREATE_COLLISION: 5, + STATIC_VIOLATION: 6, + CREATOR_NOT_ALLOWED: 7, +} diff --git a/packages/contracts/test/helpers/constants.ts b/packages/contracts/test/helpers/constants.ts new file mode 100644 index 000000000000..9c873399d3a2 --- /dev/null +++ b/packages/contracts/test/helpers/constants.ts @@ -0,0 +1,50 @@ +/* External Imports */ +import { ethers } from 'ethers' +import { defaultAccounts } from 'ethereum-waffle' +import { fromHexString, toHexString } from '@eth-optimism/core-utils' +import xor from 'buffer-xor' + +export const DEFAULT_ACCOUNTS = defaultAccounts +export const DEFAULT_ACCOUNTS_HARDHAT = defaultAccounts.map((account) => { + return { + balance: ethers.BigNumber.from(account.balance).toHexString(), + privateKey: account.secretKey, + } +}) + +export const OVM_TX_GAS_LIMIT = 10_000_000 +export const RUN_OVM_TEST_GAS = 20_000_000 +export const FORCE_INCLUSION_PERIOD_SECONDS = 600 +export const FORCE_INCLUSION_PERIOD_BLOCKS = 600 / 12 + +export const NON_NULL_BYTES32 = + '0x1111111111111111111111111111111111111111111111111111111111111111' +export const NON_ZERO_ADDRESS = '0x1111111111111111111111111111111111111111' + +export const VERIFIED_EMPTY_CONTRACT_HASH = + '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470' + +export const STORAGE_XOR_VALUE = + '0xFEEDFACECAFEBEEFFEEDFACECAFEBEEFFEEDFACECAFEBEEFFEEDFACECAFEBEEF' + +export const NUISANCE_GAS_COSTS = { + NUISANCE_GAS_SLOAD: 20000, + NUISANCE_GAS_SSTORE: 20000, + MIN_NUISANCE_GAS_PER_CONTRACT: 30000, + NUISANCE_GAS_PER_CONTRACT_BYTE: 100, + MIN_GAS_FOR_INVALID_STATE_ACCESS: 30000, +} + +// TODO: get this exported/imported somehow in a way that we can do math on it. unfortunately using require('.....artifacts/contract.json') is erroring... +export const Helper_TestRunner_BYTELEN = 3654 + +export const STORAGE_XOR = + '0xfeedfacecafebeeffeedfacecafebeeffeedfacecafebeeffeedfacecafebeef' +export const getStorageXOR = (key: string): string => { + return toHexString(xor(fromHexString(key), fromHexString(STORAGE_XOR))) +} + +export const EMPTY_ACCOUNT_CODE_HASH = + '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470' +export const KECCAK_256_NULL = + '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470' diff --git a/packages/contracts/test/helpers/dummy/accounts.ts b/packages/contracts/test/helpers/dummy/accounts.ts new file mode 100644 index 000000000000..ae32325822f9 --- /dev/null +++ b/packages/contracts/test/helpers/dummy/accounts.ts @@ -0,0 +1,33 @@ +/* External Imports */ +import { BigNumber, constants } from 'ethers' + +/* Internal Imports */ +import { DUMMY_BYTES32 } from './bytes32' +import { NON_ZERO_ADDRESS } from '../constants' +import { OVMAccount } from '../types/ovm-types' + +export const DUMMY_ACCOUNTS: Array<{ + address: string + data: OVMAccount +}> = [ + { + address: '0x1212121212121212121212121212121212121212', + data: { + nonce: BigNumber.from(123), + balance: BigNumber.from(456), + storageRoot: DUMMY_BYTES32[0], + codeHash: DUMMY_BYTES32[1], + ethAddress: constants.AddressZero, + }, + }, + { + address: '0x2121212121212121212121212121212121212121', + data: { + nonce: BigNumber.from(321), + balance: BigNumber.from(654), + storageRoot: DUMMY_BYTES32[2], + codeHash: DUMMY_BYTES32[3], + ethAddress: NON_ZERO_ADDRESS, + }, + }, +] diff --git a/packages/contracts/test/helpers/dummy/batches.ts b/packages/contracts/test/helpers/dummy/batches.ts new file mode 100644 index 000000000000..edecdaf8ced7 --- /dev/null +++ b/packages/contracts/test/helpers/dummy/batches.ts @@ -0,0 +1,36 @@ +import { NON_ZERO_ADDRESS } from '../constants' +import { ethers } from 'hardhat' + +export const DUMMY_BATCH_HEADERS = [ + { + batchIndex: 0, + batchRoot: ethers.constants.HashZero, + batchSize: 0, + prevTotalElements: 0, + extraData: ethers.utils.defaultAbiCoder.encode( + ['uint256', 'address'], + [ethers.constants.HashZero, NON_ZERO_ADDRESS] + ), + }, + { + batchIndex: 1, + batchRoot: ethers.constants.HashZero, + batchSize: 0, + prevTotalElements: 0, + extraData: ethers.utils.defaultAbiCoder.encode( + ['uint256', 'address'], + [ethers.constants.HashZero, NON_ZERO_ADDRESS] + ), + }, +] + +export const DUMMY_BATCH_PROOFS = [ + { + index: 0, + siblings: [ethers.constants.HashZero], + }, + { + index: 1, + siblings: [ethers.constants.HashZero], + }, +] diff --git a/packages/contracts/test/helpers/dummy/bytecode.ts b/packages/contracts/test/helpers/dummy/bytecode.ts new file mode 100644 index 000000000000..a37b4adc2975 --- /dev/null +++ b/packages/contracts/test/helpers/dummy/bytecode.ts @@ -0,0 +1,7 @@ +/* External Imports */ +import { keccak256 } from 'ethers/lib/utils' + +export const DUMMY_BYTECODE = '0x123412341234' +export const DUMMY_BYTECODE_BYTELEN = 6 +export const UNSAFE_BYTECODE = '0x6069606955' +export const DUMMY_BYTECODE_HASH = keccak256(DUMMY_BYTECODE) diff --git a/packages/contracts/test/helpers/dummy/bytes32.ts b/packages/contracts/test/helpers/dummy/bytes32.ts new file mode 100644 index 000000000000..070ac1a0f2fd --- /dev/null +++ b/packages/contracts/test/helpers/dummy/bytes32.ts @@ -0,0 +1,11 @@ +/* External Imports */ +import { ethers } from 'ethers' + +export const DUMMY_BYTES32: string[] = Array.from( + { + length: 10, + }, + (_, i) => { + return ethers.utils.keccak256(`0x0${i}`) + } +) diff --git a/packages/contracts/test/helpers/dummy/context.ts b/packages/contracts/test/helpers/dummy/context.ts new file mode 100644 index 000000000000..a06d28f21300 --- /dev/null +++ b/packages/contracts/test/helpers/dummy/context.ts @@ -0,0 +1,20 @@ +/* Internal Imports */ +import { NON_ZERO_ADDRESS } from '../constants' + +export const DUMMY_CONTEXT = { + GLOBAL: { + ovmCHAINID: 11, + }, + TRANSACTION: { + ovmORIGIN: NON_ZERO_ADDRESS, + ovmTIMESTAMP: 22, + ovmGASLIMIT: 33, + ovmTXGASLIMIT: 44, + ovmQUEUEORIGIN: 55, + }, + MESSAGE: { + ovmCALLER: NON_ZERO_ADDRESS, + ovmADDRESS: NON_ZERO_ADDRESS, + ovmSTATICCTX: true, + }, +} diff --git a/packages/contracts/test/helpers/dummy/index.ts b/packages/contracts/test/helpers/dummy/index.ts new file mode 100644 index 000000000000..232c317b9b4e --- /dev/null +++ b/packages/contracts/test/helpers/dummy/index.ts @@ -0,0 +1,6 @@ +export * from './accounts' +export * from './bytes32' +export * from './context' +export * from './bytecode' +export * from './batches' +export * from './transactions' diff --git a/packages/contracts/test/helpers/dummy/transactions.ts b/packages/contracts/test/helpers/dummy/transactions.ts new file mode 100644 index 000000000000..a2982beb5667 --- /dev/null +++ b/packages/contracts/test/helpers/dummy/transactions.ts @@ -0,0 +1,48 @@ +import { constants, ethers } from 'ethers' + +export interface Transaction { + timestamp: number + blockNumber: number + l1QueueOrigin: number + l1TxOrigin: string + entrypoint: string + gasLimit: number + data: string +} + +export const DUMMY_OVM_TRANSACTIONS: Array = [ + ...Array(10).keys(), +].map((i) => { + return { + timestamp: i, + blockNumber: 0, + l1QueueOrigin: 0, + l1TxOrigin: constants.AddressZero, + entrypoint: constants.AddressZero, + gasLimit: 0, + data: ethers.constants.HashZero, + } +}) + +export const hashTransaction = ({ + timestamp, + blockNumber, + l1QueueOrigin, + l1TxOrigin, + entrypoint, + gasLimit, + data, +}: Transaction): string => { + return ethers.utils.solidityKeccak256( + ['uint256', 'uint256', 'uint8', 'address', 'address', 'uint256', 'bytes'], + [ + timestamp, + blockNumber, + l1QueueOrigin, + l1TxOrigin, + entrypoint, + gasLimit, + data, + ] + ) +} diff --git a/packages/contracts/test/helpers/gas/gas.ts b/packages/contracts/test/helpers/gas/gas.ts new file mode 100644 index 000000000000..9e2be331179f --- /dev/null +++ b/packages/contracts/test/helpers/gas/gas.ts @@ -0,0 +1,25 @@ +import { ethers } from 'hardhat' +import { Contract, Signer } from 'ethers' + +export class GasMeasurement { + GasMeasurementContract: Contract + + public async init(wallet: Signer) { + this.GasMeasurementContract = await ( + await (await ethers.getContractFactory('Helper_GasMeasurer')).deploy() + ).connect(wallet) + } + + public async getGasCost( + targetContract: Contract, + methodName: string, + methodArgs: Array = [] + ): Promise { + const gasCost: number = await this.GasMeasurementContract.callStatic.measureCallGas( + targetContract.address, + targetContract.interface.encodeFunctionData(methodName, methodArgs) + ) + + return gasCost + } +} diff --git a/packages/contracts/test/helpers/gas/index.ts b/packages/contracts/test/helpers/gas/index.ts new file mode 100644 index 000000000000..1a5eaa6e16e3 --- /dev/null +++ b/packages/contracts/test/helpers/gas/index.ts @@ -0,0 +1 @@ +export * from './gas' diff --git a/packages/contracts/test/helpers/index.ts b/packages/contracts/test/helpers/index.ts new file mode 100644 index 000000000000..a2ddca39b51f --- /dev/null +++ b/packages/contracts/test/helpers/index.ts @@ -0,0 +1,9 @@ +export * from './dummy' +export * from './types' +export * from './constants' +export * from './resolver' +export * from './utils' +export * from './codec' +export * from './test-runner' +export * from './trie' +export * from './gas' diff --git a/packages/contracts/test/helpers/resolver/address-manager.ts b/packages/contracts/test/helpers/resolver/address-manager.ts new file mode 100644 index 000000000000..6d67e8c03195 --- /dev/null +++ b/packages/contracts/test/helpers/resolver/address-manager.ts @@ -0,0 +1,20 @@ +/* External Imports */ +import { ethers } from 'hardhat' +import { Contract } from 'ethers' + +export const setProxyTarget = async ( + AddressManager: Contract, + name: string, + target: Contract +): Promise => { + const SimpleProxy: Contract = await ( + await ethers.getContractFactory('Helper_SimpleProxy') + ).deploy() + + await SimpleProxy.setTarget(target.address) + await AddressManager.setAddress(name, SimpleProxy.address) +} + +export const makeAddressManager = async (): Promise => { + return (await ethers.getContractFactory('Lib_AddressManager')).deploy() +} diff --git a/packages/contracts/test/helpers/resolver/index.ts b/packages/contracts/test/helpers/resolver/index.ts new file mode 100644 index 000000000000..52516689c177 --- /dev/null +++ b/packages/contracts/test/helpers/resolver/index.ts @@ -0,0 +1 @@ +export * from './address-manager' diff --git a/packages/contracts/test/helpers/test-runner/index.ts b/packages/contracts/test/helpers/test-runner/index.ts new file mode 100644 index 000000000000..a96988d5facc --- /dev/null +++ b/packages/contracts/test/helpers/test-runner/index.ts @@ -0,0 +1,3 @@ +export * from './test-runner' +export * from './test.types' +export * from './json-test-runner' diff --git a/packages/contracts/test/helpers/test-runner/json-test-runner.ts b/packages/contracts/test/helpers/test-runner/json-test-runner.ts new file mode 100644 index 000000000000..0380ee849f06 --- /dev/null +++ b/packages/contracts/test/helpers/test-runner/json-test-runner.ts @@ -0,0 +1,41 @@ +import { expect } from '../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Contract, BigNumber } from 'ethers' + +const bigNumberify = (arr) => { + return arr.map((el: any) => { + if (typeof el === 'number') { + return BigNumber.from(el) + } else if (Array.isArray(el)) { + return bigNumberify(el) + } else { + return el + } + }) +} + +export const runJsonTest = (contractName: string, json: any): void => { + let contract: Contract + before(async () => { + contract = await (await ethers.getContractFactory(contractName)).deploy() + }) + + for (const [functionName, functionTests] of Object.entries(json)) { + describe(functionName, () => { + for (const [key, test] of Object.entries(functionTests)) { + it(`should run test: ${key}`, async () => { + if (test.revert) { + await expect(contract.functions[functionName](...test.in)).to.be + .reverted + } else { + expect( + await contract.functions[functionName](...test.in) + ).to.deep.equal(bigNumberify(test.out)) + } + }) + } + }) + } +} diff --git a/packages/contracts/test/helpers/test-runner/test-runner.ts b/packages/contracts/test/helpers/test-runner/test-runner.ts new file mode 100644 index 000000000000..ed93796fd760 --- /dev/null +++ b/packages/contracts/test/helpers/test-runner/test-runner.ts @@ -0,0 +1,517 @@ +import { expect } from '../../setup' + +/* External Imports */ +import { ethers } from 'hardhat' +import { Contract, BigNumber, ContractFactory } from 'ethers' +import { cloneDeep, merge } from 'lodash' +import { smoddit, smockit, ModifiableContract } from '@eth-optimism/smock' + +/* Internal Imports */ +import { + TestDefinition, + ParsedTestStep, + TestParameter, + TestStep, + TestStep_CALL, + TestStep_Run, + isRevertFlagError, + isTestStep_SSTORE, + isTestStep_SLOAD, + isTestStep_CALL, + isTestStep_CREATE, + isTestStep_CREATE2, + isTestStep_CREATEEOA, + isTestStep_Context, + isTestStep_evm, + isTestStep_Run, + isTestStep_EXTCODESIZE, + isTestStep_EXTCODEHASH, + isTestStep_EXTCODECOPY, + isTestStep_REVERT, +} from './test.types' +import { encodeRevertData, REVERT_FLAGS } from '../codec' +import { + OVM_TX_GAS_LIMIT, + RUN_OVM_TEST_GAS, + NON_NULL_BYTES32, +} from '../constants' +import { getStorageXOR } from '../' +import { UNSAFE_BYTECODE } from '../dummy' + +export class ExecutionManagerTestRunner { + private snapshot: string + private contracts: { + OVM_SafetyChecker: Contract + OVM_StateManager: ModifiableContract + OVM_ExecutionManager: ModifiableContract + Helper_TestRunner: Contract + Factory__Helper_TestRunner_CREATE: ContractFactory + OVM_DeployerWhitelist: Contract + } = { + OVM_SafetyChecker: undefined, + OVM_StateManager: undefined, + OVM_ExecutionManager: undefined, + Helper_TestRunner: undefined, + Factory__Helper_TestRunner_CREATE: undefined, + OVM_DeployerWhitelist: undefined, + } + + // Default pre-state with contract deployer whitelist NOT initialized. + private defaultPreState = { + StateManager: { + owner: '$OVM_EXECUTION_MANAGER', + accounts: { + ['0x4200000000000000000000000000000000000002']: { + codeHash: NON_NULL_BYTES32, + ethAddress: '$OVM_DEPLOYER_WHITELIST', + }, + }, + contractStorage: { + ['0x4200000000000000000000000000000000000002']: { + '0x0000000000000000000000000000000000000000000000000000000000000010': getStorageXOR( + ethers.constants.HashZero + ), + }, + }, + verifiedContractStorage: { + ['0x4200000000000000000000000000000000000002']: { + '0x0000000000000000000000000000000000000000000000000000000000000010': true, + }, + }, + }, + } + + public run(test: TestDefinition) { + // tslint:disable-next-line:ban-comma-operator + ;(test.preState = merge( + cloneDeep(this.defaultPreState), + cloneDeep(test.preState) + )), + (test.postState = test.postState || {}) + + describe(`OVM_ExecutionManager Test: ${test.name}`, () => { + test.subTests?.map((subTest) => { + this.run({ + ...subTest, + preState: merge( + cloneDeep(test.preState), + cloneDeep(subTest.preState) + ), + postState: merge( + cloneDeep(test.postState), + cloneDeep(subTest.postState) + ), + }) + }) + + test.parameters?.map((parameter) => { + beforeEach(async () => { + await this.initContracts() + }) + + let replacedTest: TestDefinition + let replacedParameter: TestParameter + beforeEach(async () => { + replacedTest = this.setPlaceholderStrings(test) + replacedParameter = this.setPlaceholderStrings(parameter) + }) + + beforeEach(() => { + this.contracts.OVM_StateManager.smodify.set({ + accounts: { + [this.contracts.Helper_TestRunner.address]: { + nonce: 0, + codeHash: NON_NULL_BYTES32, + ethAddress: this.contracts.Helper_TestRunner.address, + }, + }, + }) + }) + + beforeEach(() => { + this.contracts.OVM_ExecutionManager.smodify.set( + replacedTest.preState.ExecutionManager + ) + this.contracts.OVM_StateManager.smodify.set( + replacedTest.preState.StateManager + ) + }) + + afterEach(async () => { + expect( + await this.contracts.OVM_ExecutionManager.smodify.check( + replacedTest.postState.ExecutionManager + ) + ).to.equal(true) + + expect( + await this.contracts.OVM_StateManager.smodify.check( + replacedTest.postState.StateManager + ) + ).to.equal(true) + }) + + let itfn: any = it + if (parameter.focus) { + itfn = it.only + } else if (parameter.skip) { + itfn = it.skip + } + + itfn(`should execute: ${parameter.name}`, async () => { + try { + for (const step of replacedParameter.steps) { + await this.runTestStep(step) + } + } catch (err) { + if (parameter.expectInvalidStateAccess) { + expect(err.toString()).to.contain( + 'VM Exception while processing transaction: revert' + ) + } else { + throw err + } + } + }) + }) + }) + } + + private async initContracts() { + if (this.snapshot) { + await ethers.provider.send('evm_revert', [this.snapshot]) + this.snapshot = await ethers.provider.send('evm_snapshot', []) + return + } + + const AddressManager = await ( + await ethers.getContractFactory('Lib_AddressManager') + ).deploy() + + const SafetyChecker = await ( + await ethers.getContractFactory('OVM_SafetyChecker') + ).deploy() + + const MockSafetyChecker = await smockit(SafetyChecker) + MockSafetyChecker.smocked.isBytecodeSafe.will.return.with( + (bytecode: string) => { + return bytecode !== UNSAFE_BYTECODE + } + ) + + this.contracts.OVM_SafetyChecker = MockSafetyChecker + + await AddressManager.setAddress( + 'OVM_SafetyChecker', + this.contracts.OVM_SafetyChecker.address + ) + + const DeployerWhitelist = await ( + await ethers.getContractFactory('OVM_DeployerWhitelist') + ).deploy() + + this.contracts.OVM_DeployerWhitelist = DeployerWhitelist + + this.contracts.OVM_ExecutionManager = await ( + await smoddit('OVM_ExecutionManager') + ).deploy( + AddressManager.address, + { + minTransactionGasLimit: 0, + maxTransactionGasLimit: 1_000_000_000, + maxGasPerQueuePerEpoch: 1_000_000_000_000, + secondsPerEpoch: 600, + }, + { + ovmCHAINID: 420, + } + ) + + this.contracts.OVM_StateManager = await ( + await smoddit('OVM_StateManager') + ).deploy(await this.contracts.OVM_ExecutionManager.signer.getAddress()) + await this.contracts.OVM_StateManager.setExecutionManager( + this.contracts.OVM_ExecutionManager.address + ) + + this.contracts.Helper_TestRunner = await ( + await ethers.getContractFactory('Helper_TestRunner') + ).deploy() + + this.contracts.Factory__Helper_TestRunner_CREATE = await ethers.getContractFactory( + 'Helper_TestRunner_CREATE' + ) + + this.snapshot = await ethers.provider.send('evm_snapshot', []) + } + + public static getDummyAddress(placeholder: string): string { + return '0x' + (placeholder.split('$DUMMY_OVM_ADDRESS_')[1] + '0').repeat(20) + } + + private setPlaceholderStrings(obj: any) { + const getReplacementString = (kv: string): string => { + if (kv === '$OVM_EXECUTION_MANAGER') { + return this.contracts.OVM_ExecutionManager.address + } else if (kv === '$OVM_STATE_MANAGER') { + return this.contracts.OVM_StateManager.address + } else if (kv === '$OVM_SAFETY_CHECKER') { + return this.contracts.OVM_SafetyChecker.address + } else if (kv === '$OVM_CALL_HELPER') { + return this.contracts.Helper_TestRunner.address + } else if (kv === '$OVM_DEPLOYER_WHITELIST') { + return this.contracts.OVM_DeployerWhitelist.address + } else if (kv.startsWith('$DUMMY_OVM_ADDRESS_')) { + return ExecutionManagerTestRunner.getDummyAddress(kv) + } else { + return kv + } + } + + let ret: any = cloneDeep(obj) + if (Array.isArray(ret)) { + ret = ret.map((element: any) => { + return this.setPlaceholderStrings(element) + }) + } else if (typeof ret === 'object' && ret !== null) { + for (const key of Object.keys(ret)) { + const replacedKey = getReplacementString(key) + + if (replacedKey !== key) { + ret[replacedKey] = ret[key] + delete ret[key] + } + + ret[replacedKey] = this.setPlaceholderStrings(ret[replacedKey]) + } + } else if (typeof ret === 'string') { + ret = getReplacementString(ret) + } + + return ret + } + + private async runTestStep(step: TestStep | TestStep_Run) { + if (isTestStep_Run(step)) { + let calldata: string + if (step.functionParams.data) { + calldata = step.functionParams.data + } else { + const runStep: TestStep_CALL = { + functionName: 'ovmCALL', + functionParams: { + gasLimit: OVM_TX_GAS_LIMIT, + target: ExecutionManagerTestRunner.getDummyAddress( + '$DUMMY_OVM_ADDRESS_1' + ), + subSteps: step.functionParams.subSteps, + }, + expectedReturnStatus: true, + } + + calldata = this.encodeFunctionData(runStep) + } + + const toRun = this.contracts.OVM_ExecutionManager.run( + { + timestamp: step.functionParams.timestamp, + blockNumber: 0, + l1QueueOrigin: step.functionParams.queueOrigin, + l1TxOrigin: step.functionParams.origin, + entrypoint: step.functionParams.entrypoint, + gasLimit: step.functionParams.gasLimit, + data: calldata, + }, + this.contracts.OVM_StateManager.address, + { gasLimit: step.suppliedGas || RUN_OVM_TEST_GAS } + ) + if (!!step.expectedRevertValue) { + await expect(toRun).to.be.revertedWith(step.expectedRevertValue) + } else { + await toRun + } + } else { + await this.contracts.OVM_ExecutionManager.ovmCALL( + OVM_TX_GAS_LIMIT, + ExecutionManagerTestRunner.getDummyAddress('$DUMMY_OVM_ADDRESS_1'), + this.contracts.Helper_TestRunner.interface.encodeFunctionData( + 'runSingleTestStep', + [this.parseTestStep(step)] + ), + { gasLimit: RUN_OVM_TEST_GAS } + ) + } + } + + private parseTestStep(step: TestStep): ParsedTestStep { + return { + functionName: step.functionName, + functionData: this.encodeFunctionData(step), + expectedReturnStatus: this.getReturnStatus(step), + expectedReturnData: this.encodeExpectedReturnData(step), + onlyValidateFlag: this.shouldStepOnlyValidateFlag(step), + } + } + + private shouldStepOnlyValidateFlag(step: TestStep): boolean { + if (!!(step as any).expectedReturnValue) { + if (!!((step as any).expectedReturnValue as any).onlyValidateFlag) { + return true + } + } + return false + } + + private getReturnStatus(step: TestStep): boolean { + if (isTestStep_evm(step)) { + return false + } else if (isTestStep_Context(step)) { + return true + } else if (isTestStep_CALL(step)) { + if ( + isRevertFlagError(step.expectedReturnValue) && + (step.expectedReturnValue.flag === REVERT_FLAGS.INVALID_STATE_ACCESS || + step.expectedReturnValue.flag === REVERT_FLAGS.STATIC_VIOLATION || + step.expectedReturnValue.flag === REVERT_FLAGS.CREATOR_NOT_ALLOWED) + ) { + return step.expectedReturnStatus + } else { + return true + } + } else { + return step.expectedReturnStatus + } + } + + private encodeFunctionData(step: TestStep): string { + if (isTestStep_evm(step)) { + if (isRevertFlagError(step.returnData)) { + return encodeRevertData( + step.returnData.flag, + step.returnData.data, + step.returnData.nuisanceGasLeft, + step.returnData.ovmGasRefund + ) + } else { + return step.returnData || '0x' + } + } + + let functionParams: any[] = [] + if ( + isTestStep_SSTORE(step) || + isTestStep_SLOAD(step) || + isTestStep_EXTCODESIZE(step) || + isTestStep_EXTCODEHASH(step) || + isTestStep_EXTCODECOPY(step) || + isTestStep_CREATEEOA(step) + ) { + functionParams = Object.values(step.functionParams) + } else if (isTestStep_CALL(step)) { + functionParams = [ + step.functionParams.gasLimit, + step.functionParams.target, + step.functionParams.calldata || + this.contracts.Helper_TestRunner.interface.encodeFunctionData( + 'runMultipleTestSteps', + [ + step.functionParams.subSteps.map((subStep) => { + return this.parseTestStep(subStep) + }), + ] + ), + ] + } else if (isTestStep_CREATE(step)) { + functionParams = [ + this.contracts.Factory__Helper_TestRunner_CREATE.getDeployTransaction( + step.functionParams.bytecode || '0x', + step.functionParams.subSteps?.map((subStep) => { + return this.parseTestStep(subStep) + }) || [] + ).data, + ] + } else if (isTestStep_CREATE2(step)) { + functionParams = [ + this.contracts.Factory__Helper_TestRunner_CREATE.getDeployTransaction( + step.functionParams.bytecode || '0x', + step.functionParams.subSteps?.map((subStep) => { + return this.parseTestStep(subStep) + }) || [] + ).data, + step.functionParams.salt, + ] + } else if (isTestStep_REVERT(step)) { + functionParams = [step.revertData || '0x'] + } + + return this.contracts.OVM_ExecutionManager.interface.encodeFunctionData( + step.functionName, + functionParams + ) + } + + private encodeExpectedReturnData(step: TestStep): string { + if (isTestStep_evm(step)) { + return '0x' + } + + if (isRevertFlagError(step.expectedReturnValue)) { + return encodeRevertData( + step.expectedReturnValue.flag, + step.expectedReturnValue.data, + step.expectedReturnValue.nuisanceGasLeft, + step.expectedReturnValue.ovmGasRefund + ) + } + + if (isTestStep_REVERT(step)) { + return step.expectedReturnValue || '0x' + } + + let returnData: any[] = [] + if (isTestStep_CALL(step)) { + if (step.expectedReturnValue === '0x00') { + return step.expectedReturnValue + } else if ( + typeof step.expectedReturnValue === 'string' || + step.expectedReturnValue === undefined + ) { + returnData = [ + step.expectedReturnStatus, + step.expectedReturnValue || '0x', + ] + } else { + returnData = [ + step.expectedReturnValue.ovmSuccess, + step.expectedReturnValue.returnData, + ] + } + } else if (BigNumber.isBigNumber(step.expectedReturnValue)) { + returnData = [step.expectedReturnValue.toHexString()] + } else if (step.expectedReturnValue !== undefined) { + if (step.expectedReturnValue === '0x00') { + return step.expectedReturnValue + } else { + returnData = [step.expectedReturnValue] + } + } + + if (isTestStep_CREATE(step) || isTestStep_CREATE2(step)) { + if (!isRevertFlagError(step.expectedReturnValue)) { + if (typeof step.expectedReturnValue === 'string') { + returnData = [step.expectedReturnValue, '0x'] + } else { + returnData = [ + step.expectedReturnValue.address, + step.expectedReturnValue.revertData || '0x', + ] + } + } + } + + return this.contracts.OVM_ExecutionManager.interface.encodeFunctionResult( + step.functionName, + returnData + ) + } +} diff --git a/packages/contracts/test/helpers/test-runner/test.types.ts b/packages/contracts/test/helpers/test-runner/test.types.ts new file mode 100644 index 000000000000..fa799dd6b4e1 --- /dev/null +++ b/packages/contracts/test/helpers/test-runner/test.types.ts @@ -0,0 +1,310 @@ +/* External Imports */ +import { BigNumber } from 'ethers' + +export type ContextOpcode = + | 'ovmCALLER' + | 'ovmNUMBER' + | 'ovmADDRESS' + | 'ovmL1TXORIGIN' + | 'ovmL1QUEUEORIGIN' + | 'ovmTIMESTAMP' + | 'ovmGASLIMIT' + | 'ovmCHAINID' + | 'ovmGETNONCE' + +type CallOpcode = 'ovmCALL' | 'ovmSTATICCALL' | 'ovmDELEGATECALL' + +type RevertFlagError = { + flag: number + nuisanceGasLeft?: number + ovmGasRefund?: number + data?: string + onlyValidateFlag?: boolean +} + +interface TestStep_evm { + functionName: 'evmRETURN' | 'evmREVERT' | 'evmINVALID' + returnData?: string | RevertFlagError +} + +interface TestStep_Context { + functionName: ContextOpcode + expectedReturnValue: string | number | BigNumber +} + +interface TestStep_REVERT { + functionName: 'ovmREVERT' + revertData?: string + expectedReturnStatus: boolean + expectedReturnValue?: string | RevertFlagError +} + +interface TestStep_EXTCODESIZE { + functionName: 'ovmEXTCODESIZE' + functionParams: { + address: string + } + expectedReturnStatus: boolean + expectedReturnValue: number | RevertFlagError +} + +interface TestStep_EXTCODEHASH { + functionName: 'ovmEXTCODEHASH' + functionParams: { + address: string + } + expectedReturnStatus: boolean + expectedReturnValue: string | RevertFlagError +} + +interface TestStep_EXTCODECOPY { + functionName: 'ovmEXTCODECOPY' + functionParams: { + address: string + offset: number + length: number + } + expectedReturnStatus: boolean + expectedReturnValue: string | RevertFlagError +} + +interface TestStep_SSTORE { + functionName: 'ovmSSTORE' + functionParams: { + key: string + value: string + } + expectedReturnStatus: boolean + expectedReturnValue?: RevertFlagError +} + +interface TestStep_SLOAD { + functionName: 'ovmSLOAD' + functionParams: { + key: string + } + expectedReturnStatus: boolean + expectedReturnValue: string | RevertFlagError +} + +interface TestStep_INCREMENTNONCE { + functionName: 'ovmINCREMENTNONCE' + expectedReturnStatus: boolean + expectedReturnValue?: RevertFlagError +} + +export interface TestStep_CALL { + functionName: CallOpcode + functionParams: { + gasLimit: number | BigNumber + target: string + calldata?: string + subSteps?: TestStep[] + } + expectedReturnStatus: boolean + expectedReturnValue?: + | string + | RevertFlagError + | { ovmSuccess: boolean; returnData: string } +} + +interface TestStep_CREATE { + functionName: 'ovmCREATE' + functionParams: { + bytecode?: string + subSteps?: TestStep[] + } + expectedReturnStatus: boolean + expectedReturnValue: + | string + | { + address: string + revertData: string + } + | RevertFlagError +} + +interface TestStep_CREATE2 { + functionName: 'ovmCREATE2' + functionParams: { + salt: string + bytecode?: string + subSteps?: TestStep[] + } + expectedReturnStatus: boolean + expectedReturnValue: + | string + | { + address: string + revertData: string + } + | RevertFlagError +} + +interface TestStep_CREATEEOA { + functionName: 'ovmCREATEEOA' + functionParams: { + _messageHash: string + _v: number + _r: string + _s: string + } + expectedReturnStatus: boolean + expectedReturnValue: string | RevertFlagError +} + +export interface TestStep_Run { + functionName: 'run' + suppliedGas?: number + functionParams: { + timestamp: number + queueOrigin: number + entrypoint: string + origin: string + msgSender: string + gasLimit: number + data?: string + subSteps?: TestStep[] + } + expectedRevertValue?: string +} + +export type TestStep = + | TestStep_Context + | TestStep_SSTORE + | TestStep_SLOAD + | TestStep_INCREMENTNONCE + | TestStep_CALL + | TestStep_CREATE + | TestStep_CREATE2 + | TestStep_CREATEEOA + | TestStep_EXTCODESIZE + | TestStep_EXTCODEHASH + | TestStep_EXTCODECOPY + | TestStep_REVERT + | TestStep_evm + +export interface ParsedTestStep { + functionName: string + functionData: string + expectedReturnStatus: boolean + expectedReturnData: string + onlyValidateFlag: boolean +} + +export const isRevertFlagError = ( + expectedReturnValue: any +): expectedReturnValue is RevertFlagError => { + return ( + typeof expectedReturnValue === 'object' && + expectedReturnValue !== null && + expectedReturnValue.flag !== undefined + ) +} + +export const isTestStep_evm = (step: TestStep): step is TestStep_evm => { + return ['evmRETURN', 'evmREVERT', 'evmINVALID'].includes(step.functionName) +} + +export const isTestStep_Context = ( + step: TestStep +): step is TestStep_Context => { + return [ + 'ovmCALLER', + 'ovmNUMBER', + 'ovmADDRESS', + 'ovmNUMBER', + 'ovmL1TXORIGIN', + 'ovmTIMESTAMP', + 'ovmGASLIMIT', + 'ovmCHAINID', + 'ovmL1QUEUEORIGIN', + 'ovmGETNONCE', + ].includes(step.functionName) +} + +export const isTestStep_SSTORE = (step: TestStep): step is TestStep_SSTORE => { + return step.functionName === 'ovmSSTORE' +} + +export const isTestStep_SLOAD = (step: TestStep): step is TestStep_SLOAD => { + return step.functionName === 'ovmSLOAD' +} + +export const isTestStep_INCREMENTNONCE = ( + step: TestStep +): step is TestStep_INCREMENTNONCE => { + return step.functionName === 'ovmINCREMENTNONCE' +} + +export const isTestStep_EXTCODESIZE = ( + step: TestStep +): step is TestStep_EXTCODESIZE => { + return step.functionName === 'ovmEXTCODESIZE' +} + +export const isTestStep_EXTCODEHASH = ( + step: TestStep +): step is TestStep_EXTCODEHASH => { + return step.functionName === 'ovmEXTCODEHASH' +} + +export const isTestStep_EXTCODECOPY = ( + step: TestStep +): step is TestStep_EXTCODECOPY => { + return step.functionName === 'ovmEXTCODECOPY' +} + +export const isTestStep_REVERT = (step: TestStep): step is TestStep_REVERT => { + return step.functionName === 'ovmREVERT' +} + +export const isTestStep_CALL = (step: TestStep): step is TestStep_CALL => { + return ['ovmCALL', 'ovmSTATICCALL', 'ovmDELEGATECALL'].includes( + step.functionName + ) +} + +export const isTestStep_CREATE = (step: TestStep): step is TestStep_CREATE => { + return step.functionName === 'ovmCREATE' +} + +export const isTestStep_CREATEEOA = ( + step: TestStep +): step is TestStep_CREATEEOA => { + return step.functionName === 'ovmCREATEEOA' +} + +export const isTestStep_CREATE2 = ( + step: TestStep +): step is TestStep_CREATE2 => { + return step.functionName === 'ovmCREATE2' +} + +export const isTestStep_Run = ( + step: TestStep | TestStep_Run +): step is TestStep_Run => { + return step.functionName === 'run' +} + +interface TestState { + ExecutionManager: any + StateManager: any +} + +export interface TestParameter { + name: string + steps: Array + expectInvalidStateAccess?: boolean + focus?: boolean + skip?: boolean +} + +export interface TestDefinition { + name: string + focus?: boolean + preState?: Partial + postState?: Partial + parameters?: TestParameter[] + subTests?: TestDefinition[] +} diff --git a/packages/contracts/test/helpers/trie/index.ts b/packages/contracts/test/helpers/trie/index.ts new file mode 100644 index 000000000000..fb8e3eb0c6ca --- /dev/null +++ b/packages/contracts/test/helpers/trie/index.ts @@ -0,0 +1 @@ +export * from './trie-test-generator' diff --git a/packages/contracts/test/helpers/trie/trie-test-generator.ts b/packages/contracts/test/helpers/trie/trie-test-generator.ts new file mode 100644 index 000000000000..e9dcefe6e4e2 --- /dev/null +++ b/packages/contracts/test/helpers/trie/trie-test-generator.ts @@ -0,0 +1,261 @@ +/* External Imports */ +import * as rlp from 'rlp' +import { default as seedbytes } from 'random-bytes-seed' +import { SecureTrie, BaseTrie } from 'merkle-patricia-tree' +import { fromHexString, toHexString } from '@eth-optimism/core-utils' +import { ethers } from 'ethers' + +export interface TrieNode { + key: string + val: string +} + +export interface InclusionProofTest { + key: string + val: string + proof: string + root: string +} + +export interface NodeUpdateTest extends InclusionProofTest { + newRoot: string +} + +export interface EthereumAccount { + address?: string + nonce: number + balance: number + codeHash: string + storageRoot?: string + storage?: TrieNode[] +} + +export interface AccountProofTest { + address: string + account: EthereumAccount + accountTrieWitness: string + accountTrieRoot: string +} + +export interface AccountUpdateTest extends AccountProofTest { + newAccountTrieRoot: string +} + +const rlpEncodeAccount = (account: EthereumAccount): string => { + return toHexString( + rlp.encode([ + account.nonce, + account.balance, + account.storageRoot || ethers.constants.HashZero, + account.codeHash || ethers.constants.HashZero, + ]) + ) +} + +const rlpDecodeAccount = (encoded: string): EthereumAccount => { + const decoded = rlp.decode(fromHexString(encoded)) as any + return { + nonce: decoded[0].length ? parseInt(decoded[0], 16) : 0, + balance: decoded[1].length ? parseInt(decoded[1], 16) : 0, + storageRoot: decoded[2].length + ? toHexString(decoded[2]) + : ethers.constants.HashZero, + codeHash: decoded[3].length + ? toHexString(decoded[3]) + : ethers.constants.HashZero, + } +} + +const makeTrie = async ( + nodes: TrieNode[], + secure?: boolean +): Promise<{ + trie: SecureTrie | BaseTrie + TrieClass: any +}> => { + const TrieClass = secure ? SecureTrie : BaseTrie + const trie = new TrieClass() + + for (const node of nodes) { + await trie.put(fromHexString(node.key), fromHexString(node.val)) + } + + return { + trie, + TrieClass, + } +} + +export class TrieTestGenerator { + constructor( + public _TrieClass: any, + public _trie: SecureTrie | BaseTrie, + public _nodes: TrieNode[], + public _subGenerators?: TrieTestGenerator[] + ) {} + + static async fromNodes(opts: { + nodes: TrieNode[] + secure?: boolean + }): Promise { + const { trie, TrieClass } = await makeTrie(opts.nodes, opts.secure) + + return new TrieTestGenerator(TrieClass, trie, opts.nodes) + } + + static async fromRandom(opts: { + seed: string + nodeCount: number + secure?: boolean + keySize?: number + valSize?: number + }): Promise { + const getRandomBytes = seedbytes(opts.seed) + const nodes: TrieNode[] = [...Array(opts.nodeCount)].map(() => { + return { + key: toHexString(getRandomBytes(opts.keySize || 32)), + val: toHexString(getRandomBytes(opts.valSize || 32)), + } + }) + + return TrieTestGenerator.fromNodes({ + nodes, + secure: opts.secure, + }) + } + + static async fromAccounts(opts: { + accounts: EthereumAccount[] + secure?: boolean + }): Promise { + const subGenerators: TrieTestGenerator[] = [] + + for (const account of opts.accounts) { + if (account.storage) { + const subGenerator = await TrieTestGenerator.fromNodes({ + nodes: account.storage, + secure: opts.secure, + }) + + account.storageRoot = toHexString(subGenerator._trie.root) + subGenerators.push(subGenerator) + } + } + + const nodes = opts.accounts.map((account) => { + return { + key: account.address, + val: rlpEncodeAccount(account), + } + }) + + const { trie, TrieClass } = await makeTrie(nodes, opts.secure) + + return new TrieTestGenerator(TrieClass, trie, nodes, subGenerators) + } + + public async makeInclusionProofTest( + key: string | number + ): Promise { + if (typeof key === 'number') { + key = this._nodes[key].key + } + + const trie = this._trie.copy() + + const proof = await this.prove(key) + const val = await trie.get(fromHexString(key)) + + return { + proof: toHexString(rlp.encode(proof)), + key: toHexString(key), + val: toHexString(val), + root: toHexString(trie.root), + } + } + + public async makeAllInclusionProofTests(): Promise { + return Promise.all( + this._nodes.map(async (node) => { + return this.makeInclusionProofTest(node.key) + }) + ) + } + + public async makeNodeUpdateTest( + key: string | number, + val: string + ): Promise { + if (typeof key === 'number') { + key = this._nodes[key].key + } + + const trie = this._trie.copy() + + const proof = await this.prove(key) + const oldRoot = trie.root + + await trie.put(fromHexString(key), fromHexString(val)) + const newRoot = trie.root + + return { + proof: toHexString(rlp.encode(proof)), + key: toHexString(key), + val: toHexString(val), + root: toHexString(oldRoot), + newRoot: toHexString(newRoot), + } + } + + public async makeAccountProofTest( + address: string | number + ): Promise { + if (typeof address === 'number') { + address = this._nodes[address].key + } + + const trie = this._trie.copy() + + const proof = await this.prove(address) + const account = await trie.get(fromHexString(address)) + + return { + address, + account: rlpDecodeAccount(toHexString(account)), + accountTrieWitness: toHexString(rlp.encode(proof)), + accountTrieRoot: toHexString(trie.root), + } + } + + public async makeAccountUpdateTest( + address: string | number, + account: EthereumAccount + ): Promise { + if (typeof address === 'number') { + address = this._nodes[address].key + } + + const trie = this._trie.copy() + + const proof = await this.prove(address) + const oldRoot = trie.root + + await trie.put( + fromHexString(address), + fromHexString(rlpEncodeAccount(account)) + ) + const newRoot = trie.root + + return { + address, + account, + accountTrieWitness: toHexString(rlp.encode(proof)), + accountTrieRoot: toHexString(oldRoot), + newAccountTrieRoot: toHexString(newRoot), + } + } + + private async prove(key: string): Promise { + return this._TrieClass.prove(this._trie, fromHexString(key)) + } +} diff --git a/packages/contracts/test/helpers/types/index.ts b/packages/contracts/test/helpers/types/index.ts new file mode 100644 index 000000000000..ca874584fbbe --- /dev/null +++ b/packages/contracts/test/helpers/types/index.ts @@ -0,0 +1 @@ +export * from './ovm-types' diff --git a/packages/contracts/test/helpers/types/ovm-types.ts b/packages/contracts/test/helpers/types/ovm-types.ts new file mode 100644 index 000000000000..73de4f75446b --- /dev/null +++ b/packages/contracts/test/helpers/types/ovm-types.ts @@ -0,0 +1,10 @@ +/* External Imports */ +import { BigNumber } from 'ethers' + +export interface OVMAccount { + nonce: number | BigNumber + balance: number | BigNumber + storageRoot: string + codeHash: string + ethAddress: string +} diff --git a/packages/contracts/test/helpers/utils/custom-deployer.ts b/packages/contracts/test/helpers/utils/custom-deployer.ts new file mode 100644 index 000000000000..92d5063c77dc --- /dev/null +++ b/packages/contracts/test/helpers/utils/custom-deployer.ts @@ -0,0 +1,23 @@ +/* External Imports */ +import { Signer } from 'ethers' +import { toHexString } from '@eth-optimism/core-utils' + +export const deployContractCode = async ( + code: string, + signer: Signer, + gasLimit: number +): Promise => { + // "Magic" prefix to be prepended to the contract code. Contains a series of opcodes that will + // copy the given code into memory and return it, thereby storing at the contract address. + const prefix = '0x600D380380600D6000396000f3' + const deployCode = prefix + toHexString(code).slice(2) + + const response = await signer.sendTransaction({ + to: null, + data: deployCode, + gasLimit, + }) + + const result = await response.wait() + return result.contractAddress +} diff --git a/packages/contracts/test/helpers/utils/eth-time.ts b/packages/contracts/test/helpers/utils/eth-time.ts new file mode 100644 index 000000000000..1400dc18a31c --- /dev/null +++ b/packages/contracts/test/helpers/utils/eth-time.ts @@ -0,0 +1,40 @@ +export const getEthTime = async (provider: any): Promise => { + return (await provider.getBlock('latest')).timestamp +} + +export const setEthTime = async ( + provider: any, + time: number +): Promise => { + await provider.send('evm_setNextBlockTimestamp', [time]) +} + +export const increaseEthTime = async ( + provider: any, + amount: number +): Promise => { + await setEthTime(provider, (await getEthTime(provider)) + amount) + await mineBlock(provider) +} + +export const mineBlock = async ( + provider: any, + timestamp?: number +): Promise => { + await provider.send('evm_mine', timestamp ? [timestamp] : []) +} + +export const getBlockTime = async ( + provider: any, + block?: number +): Promise => { + await mineBlock(provider) + if (!!block) { + block = await getNextBlockNumber(provider) + } + return (await provider.getBlock(block)).timestamp +} + +export const getNextBlockNumber = async (provider: any): Promise => { + return (await provider.getBlock('latest')).number + 1 +} diff --git a/packages/contracts/test/helpers/utils/index.ts b/packages/contracts/test/helpers/utils/index.ts new file mode 100644 index 000000000000..a2aad3026886 --- /dev/null +++ b/packages/contracts/test/helpers/utils/index.ts @@ -0,0 +1,3 @@ +export * from './eth-time' +export * from './sol-utils' +export * from './custom-deployer' diff --git a/packages/contracts/test/helpers/utils/sol-utils.ts b/packages/contracts/test/helpers/utils/sol-utils.ts new file mode 100644 index 000000000000..dc17b4327eff --- /dev/null +++ b/packages/contracts/test/helpers/utils/sol-utils.ts @@ -0,0 +1,22 @@ +import { ethers } from 'ethers' + +const errorABI = new ethers.utils.Interface([ + { + type: 'function', + inputs: [ + { + type: 'string', + }, + ], + name: 'Error', + stateMutability: 'pure', + }, +]) + +export const decodeSolidityError = (err: string): string => { + return errorABI.decodeFunctionData('Error', err)[0] +} + +export const encodeSolidityError = (message: string): string => { + return errorABI.encodeFunctionData('Error', [message]) +} diff --git a/packages/contracts/test/setup.ts b/packages/contracts/test/setup.ts new file mode 100644 index 000000000000..3b89f5789445 --- /dev/null +++ b/packages/contracts/test/setup.ts @@ -0,0 +1,10 @@ +/* External Imports */ +import chai = require('chai') +import Mocha from 'mocha' +import { solidity } from 'ethereum-waffle' + +chai.use(solidity) +const should = chai.should() +const expect = chai.expect + +export { should, expect, Mocha } diff --git a/packages/contracts/tsconfig.build.json b/packages/contracts/tsconfig.build.json new file mode 100644 index 000000000000..7ade983395d0 --- /dev/null +++ b/packages/contracts/tsconfig.build.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.build.json", + + "compilerOptions": { + "rootDir": "./src", + "outDir": "./dist" + }, + + "include": [ + "src/**/*" + ] +} diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json new file mode 100644 index 000000000000..77c80113a45c --- /dev/null +++ b/packages/contracts/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "resolveJsonModule": true + }, + "include": ["./test"], + "files": ["./hardhat.config.ts"] +} diff --git a/packages/contracts/tslint.json b/packages/contracts/tslint.json new file mode 100644 index 000000000000..9727d8b9fa81 --- /dev/null +++ b/packages/contracts/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tslint.base.json", + "rules": { + "array-type": false, + "class-name": false + } +} diff --git a/packages/contracts/yarn.lock b/packages/contracts/yarn.lock new file mode 100644 index 000000000000..437f273c9a7a --- /dev/null +++ b/packages/contracts/yarn.lock @@ -0,0 +1,8594 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@babel/code-frame@^7.0.0": + version "7.12.13" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.13.tgz#dcfc826beef65e75c50e21d3837d7d95798dd658" + integrity sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g== + dependencies: + "@babel/highlight" "^7.12.13" + +"@babel/helper-validator-identifier@^7.12.11": + version "7.12.11" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz#c9a1f021917dcb5ccf0d4e453e399022981fc9ed" + integrity sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw== + +"@babel/highlight@^7.12.13": + version "7.12.13" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.12.13.tgz#8ab538393e00370b26271b01fa08f7f27f2e795c" + integrity sha512-kocDQvIbgMKlWxXe9fof3TQ+gkIPOUSEYhJjqUjvKMez3krV7vbzYCDq39Oj11UAVK7JqPVGQPlgE85dPNlQww== + dependencies: + "@babel/helper-validator-identifier" "^7.12.11" + chalk "^2.0.0" + js-tokens "^4.0.0" + +"@ensdomains/ens@^0.4.4": + version "0.4.5" + resolved "https://registry.yarnpkg.com/@ensdomains/ens/-/ens-0.4.5.tgz#e0aebc005afdc066447c6e22feb4eda89a5edbfc" + integrity sha512-JSvpj1iNMFjK6K+uVl4unqMoa9rf5jopb8cya5UGBWz23Nw8hSNT7efgUx4BTlAPAgpNlEioUfeTyQ6J9ZvTVw== + dependencies: + bluebird "^3.5.2" + eth-ens-namehash "^2.0.8" + solc "^0.4.20" + testrpc "0.0.1" + web3-utils "^1.0.0-beta.31" + +"@ensdomains/resolver@^0.2.4": + version "0.2.4" + resolved "https://registry.yarnpkg.com/@ensdomains/resolver/-/resolver-0.2.4.tgz#c10fe28bf5efbf49bff4666d909aed0265efbc89" + integrity sha512-bvaTH34PMCbv6anRa9I/0zjLJgY4EuznbEMgbV77JBCQ9KNC46rzi0avuxpOfu+xDjPEtSFGqVEOr5GlUSGudA== + +"@eth-optimism/core-utils@^0.1.10": + version "0.1.10" + resolved "https://registry.yarnpkg.com/@eth-optimism/core-utils/-/core-utils-0.1.10.tgz#bbed838cb7c9354e8b90029c47b7556ceaa756bf" + integrity sha512-RyZ79yP1gJP8Clx6AqvoDiJzbOVQccsyj0OobwiNfO4gUU1Lpmz37zXsQITSO+3bKWj+ipxg2baZnJwfoTxl5g== + dependencies: + "@ethersproject/abstract-provider" "^5.0.9" + colors "^1.4.0" + debug "^4.3.1" + ethers "^5.0.31" + pino "^6.11.1" + +"@eth-optimism/dev@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@eth-optimism/dev/-/dev-1.1.1.tgz#7bae95b975c1d6641b4ae550cb3ec631c667a56b" + integrity sha512-BiKvjL8VoS2OsPHobyTe533XoZkYYBKUKhw9tkHskylD+s+/UwcgkkimrxQ67aJgLE22GW9YCdF2eeB3UcNwgA== + dependencies: + "@types/chai" "^4.2.15" + "@types/chai-as-promised" "^7.1.3" + "@types/mocha" "^8.2.0" + "@types/node" "^14.14.27" + chai "^4.3.0" + chai-as-promised "^7.1.1" + mocha "^8.3.0" + prettier "^2.2.1" + rimraf "^3.0.2" + ts-node "^9.1.1" + tslint "^6.1.3" + tslint-config-prettier "^1.18.0" + tslint-no-focused-test "^0.5.0" + tslint-plugin-prettier "^2.3.0" + typescript "^4.1.5" + +"@eth-optimism/plugins@^1.0.0-alpha.2": + version "1.0.0-alpha.2" + resolved "https://registry.yarnpkg.com/@eth-optimism/plugins/-/plugins-1.0.0-alpha.2.tgz#dc5ad1395944d63e6a592832b2360be59481e092" + integrity sha512-OrwMtgJuO4gZjCJX9rtZZQr3Fn+ksbhF9nKyB4+qggJXoatkJmj1+2UHNzuhfG2LaRu35PmJQYiV316K1YTyeg== + dependencies: + node-fetch "^2.6.1" + +"@eth-optimism/smock@^1.0.0-alpha.3": + version "1.0.0-alpha.3" + resolved "https://registry.yarnpkg.com/@eth-optimism/smock/-/smock-1.0.0-alpha.3.tgz#5f3e8f137407c4c62f06aed60bac3dc282632f89" + integrity sha512-TKqbmElCWQ0qM6qj8JajqOijZVKl47L/5v2NnEWBJERKZ6zkuFxT0Y8HtUCM3r4ZEURuXFbRxRLP/ZTrOG6axg== + dependencies: + "@eth-optimism/core-utils" "^0.1.10" + "@ethersproject/abi" "^5.0.13" + "@ethersproject/abstract-provider" "^5.0.10" + bn.js "^5.2.0" + +"@eth-optimism/solc@^0.6.12-alpha.1": + version "0.6.12-alpha.1" + resolved "https://registry.yarnpkg.com/@eth-optimism/solc/-/solc-0.6.12-alpha.1.tgz#041876f83b34c6afe2f19dfe9626568df6ed8590" + integrity sha512-Ky73mo+2iNJs/VTaT751nMeZ7hXns0TBAlffTOxIOsScjAZ/zi/KWsDUo3r89aV2JKXcYAU/bLidxF40MVJeUw== + dependencies: + command-exists "^1.2.8" + commander "3.0.2" + follow-redirects "^1.12.1" + fs-extra "^0.30.0" + js-sha3 "0.8.0" + memorystream "^0.3.1" + require-from-string "^2.0.0" + semver "^5.5.0" + tmp "0.0.33" + +"@ethereum-waffle/chai@^3.3.0": + version "3.3.1" + resolved "https://registry.yarnpkg.com/@ethereum-waffle/chai/-/chai-3.3.1.tgz#3f20b810d0fa516f19af93c50c3be1091333fa8e" + integrity sha512-+vepCjttfOzCSnmiVEmd1bR8ctA2wYVrtWa8bDLhnTpj91BIIHotNDTwpeq7fyjrOCIBTN3Ai8ACfjNoatc4OA== + dependencies: + "@ethereum-waffle/provider" "^3.3.1" + ethers "^5.0.0" + +"@ethereum-waffle/compiler@^3.3.0": + version "3.3.1" + resolved "https://registry.yarnpkg.com/@ethereum-waffle/compiler/-/compiler-3.3.1.tgz#946128fd565aa4347075fd716dbd0f3f38189280" + integrity sha512-X/TeQugt94AQwXEdCjIQxcXYGawNulVBYEBE7nloj4wE/RBxNolXwjoVNjcS4kuiMMbKkdO0JkL5sn6ixx8bDg== + dependencies: + "@resolver-engine/imports" "^0.3.3" + "@resolver-engine/imports-fs" "^0.3.3" + "@typechain/ethers-v5" "^2.0.0" + "@types/mkdirp" "^0.5.2" + "@types/node-fetch" "^2.5.5" + ethers "^5.0.1" + mkdirp "^0.5.1" + node-fetch "^2.6.0" + solc "^0.6.3" + ts-generator "^0.1.1" + typechain "^3.0.0" + +"@ethereum-waffle/ens@^3.2.4": + version "3.2.4" + resolved "https://registry.yarnpkg.com/@ethereum-waffle/ens/-/ens-3.2.4.tgz#c486be4879ea7107e1ff01b24851a5e44f5946ce" + integrity sha512-lkRVPCEkk7KOwH9MqFMB+gL0X8cZNsm+MnKpP9CNbAyhFos2sCDGcY8t6BA12KBK6pdMuuRXPxYL9WfPl9bqSQ== + dependencies: + "@ensdomains/ens" "^0.4.4" + "@ensdomains/resolver" "^0.2.4" + ethers "^5.0.1" + +"@ethereum-waffle/mock-contract@^3.2.2": + version "3.2.2" + resolved "https://registry.yarnpkg.com/@ethereum-waffle/mock-contract/-/mock-contract-3.2.2.tgz#5749b03cbb4850150f81cf66151c4523eb7436f0" + integrity sha512-H60Cc5C7sYNU4LuPMSKDh8YIaN9/fkwEjznY78CEbOosO+lMlFYdA+5VZjeDGDuYKfsBqsocQdkj1CRyoi1KNw== + dependencies: + "@ethersproject/abi" "^5.0.1" + ethers "^5.0.1" + +"@ethereum-waffle/provider@^3.3.0", "@ethereum-waffle/provider@^3.3.1": + version "3.3.2" + resolved "https://registry.yarnpkg.com/@ethereum-waffle/provider/-/provider-3.3.2.tgz#33677baf6af5cbb087c3072d84f38c152968ebb1" + integrity sha512-ilz6cXK0ylSKCmZktTMpY4gjo0CN6rb86JfN7+RZYk6tKtZA6sXoOe95skWEQkGf1fZk7G817fTzLb0CmFDp1g== + dependencies: + "@ethereum-waffle/ens" "^3.2.4" + ethers "^5.0.1" + ganache-core "^2.13.2" + patch-package "^6.2.2" + postinstall-postinstall "^2.1.0" + +"@ethersproject/abi@5.0.0-beta.153": + version "5.0.0-beta.153" + resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.0.0-beta.153.tgz#43a37172b33794e4562999f6e2d555b7599a8eee" + integrity sha512-aXweZ1Z7vMNzJdLpR1CZUAIgnwjrZeUSvN9syCwlBaEBUFJmFY+HHnfuTI5vIhVs/mRkfJVrbEyl51JZQqyjAg== + dependencies: + "@ethersproject/address" ">=5.0.0-beta.128" + "@ethersproject/bignumber" ">=5.0.0-beta.130" + "@ethersproject/bytes" ">=5.0.0-beta.129" + "@ethersproject/constants" ">=5.0.0-beta.128" + "@ethersproject/hash" ">=5.0.0-beta.128" + "@ethersproject/keccak256" ">=5.0.0-beta.127" + "@ethersproject/logger" ">=5.0.0-beta.129" + "@ethersproject/properties" ">=5.0.0-beta.131" + "@ethersproject/strings" ">=5.0.0-beta.130" + +"@ethersproject/abi@5.0.12", "@ethersproject/abi@^5.0.1", "@ethersproject/abi@^5.0.10": + version "5.0.12" + resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.0.12.tgz#9aebe6aedc05ce45bb6c41b06d80bd195b7de77c" + integrity sha512-Ujr/3bwyYYjXLDQfebeiiTuvOw9XtUKM8av6YkoBeMXyGQM9GkjrQlwJMNwGTmqjATH/ZNbRgCh98GjOLiIB1Q== + dependencies: + "@ethersproject/address" "^5.0.9" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/constants" "^5.0.8" + "@ethersproject/hash" "^5.0.10" + "@ethersproject/keccak256" "^5.0.7" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/strings" "^5.0.8" + +"@ethersproject/abi@^5.0.13": + version "5.0.13" + resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.0.13.tgz#600a559c3730467716595658beaa2894b4352bcc" + integrity sha512-2coOH3D7ra1lwamKEH0HVc+Jbcsw5yfeCgmY8ekhCDualEiyyovD2qDcMBBcY3+kjoLHVTmo7ost6MNClxdOrg== + dependencies: + "@ethersproject/address" "^5.0.9" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/constants" "^5.0.8" + "@ethersproject/hash" "^5.0.10" + "@ethersproject/keccak256" "^5.0.7" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/strings" "^5.0.8" + +"@ethersproject/abstract-provider@5.0.9", "@ethersproject/abstract-provider@^5.0.8", "@ethersproject/abstract-provider@^5.0.9": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.0.9.tgz#a55410b73e3994842884eb82b1f43e3a9f653eea" + integrity sha512-X9fMkqpeu9ayC3JyBkeeZhn35P4xQkpGX/l+FrxDtEW9tybf/UWXSMi8bGThpPtfJ6q6U2LDetXSpSwK4TfYQQ== + dependencies: + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/networks" "^5.0.7" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/transactions" "^5.0.9" + "@ethersproject/web" "^5.0.12" + +"@ethersproject/abstract-provider@^5.0.10": + version "5.0.10" + resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.0.10.tgz#a533aed39a5f27312745c8c4c40fa25fc884831c" + integrity sha512-OSReY5iz94iIaPlRvLiJP8YVIvQLx4aUvMMnHWSaA/vTU8QHZmgNlt4OBdYV1+aFY8Xl+VRYiWBHq72ZDKXXCQ== + dependencies: + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/networks" "^5.0.7" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/transactions" "^5.0.9" + "@ethersproject/web" "^5.0.12" + +"@ethersproject/abstract-signer@5.0.13", "@ethersproject/abstract-signer@^5.0.10": + version "5.0.13" + resolved "https://registry.yarnpkg.com/@ethersproject/abstract-signer/-/abstract-signer-5.0.13.tgz#59b4d0367d6327ec53bc269c6730c44a4a3b043c" + integrity sha512-VBIZEI5OK0TURoCYyw0t3w+TEO4kdwnI9wvt4kqUwyxSn3YCRpXYVl0Xoe7XBR/e5+nYOi2MyFGJ3tsFwONecQ== + dependencies: + "@ethersproject/abstract-provider" "^5.0.8" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + +"@ethersproject/address@5.0.10", "@ethersproject/address@>=5.0.0-beta.128", "@ethersproject/address@^5.0.9": + version "5.0.10" + resolved "https://registry.yarnpkg.com/@ethersproject/address/-/address-5.0.10.tgz#2bc69fdff4408e0570471cd19dee577ab06a10d0" + integrity sha512-70vqESmW5Srua1kMDIN6uVfdneZMaMyRYH4qPvkAXGkbicrCOsA9m01vIloA4wYiiF+HLEfL1ENKdn5jb9xiAw== + dependencies: + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/keccak256" "^5.0.7" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/rlp" "^5.0.7" + +"@ethersproject/base64@5.0.8", "@ethersproject/base64@^5.0.7": + version "5.0.8" + resolved "https://registry.yarnpkg.com/@ethersproject/base64/-/base64-5.0.8.tgz#1bc4b4b8c59c1debf972c7164b96c0b8964a20a1" + integrity sha512-PNbpHOMgZpZ1skvQl119pV2YkCPXmZTxw+T92qX0z7zaMFPypXWTZBzim+hUceb//zx4DFjeGT4aSjZRTOYThg== + dependencies: + "@ethersproject/bytes" "^5.0.9" + +"@ethersproject/basex@5.0.8", "@ethersproject/basex@^5.0.7": + version "5.0.8" + resolved "https://registry.yarnpkg.com/@ethersproject/basex/-/basex-5.0.8.tgz#6867fad20047aa29fbd4b880f27894ed04cc7bb8" + integrity sha512-PCVKZIShBQUqAXjJSvaCidThPvL0jaaQZcewJc0sf8Xx05BizaOS8r3jdPdpNdY+/qZtRDqwHTSKjvR/xssyLQ== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/properties" "^5.0.7" + +"@ethersproject/bignumber@5.0.14", "@ethersproject/bignumber@>=5.0.0-beta.130", "@ethersproject/bignumber@^5.0.13": + version "5.0.14" + resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.0.14.tgz#605bc61dcbd4a8c6df8b5a7a77c0210273f3de8a" + integrity sha512-Q4TjMq9Gg3Xzj0aeJWqJgI3tdEiPiET7Y5OtNtjTAODZ2kp4y9jMNg97zVcvPedFvGROdpGDyCI77JDFodUzOw== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + bn.js "^4.4.0" + +"@ethersproject/bytes@5.0.10", "@ethersproject/bytes@>=5.0.0-beta.129", "@ethersproject/bytes@^5.0.9": + version "5.0.10" + resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.0.10.tgz#aa49afe7491ba24ff76fa33d98677351263f9ba4" + integrity sha512-vpu0v1LZ1j1s9kERQIMnVU69MyHEzUff7nqK9XuCU4vx+AM8n9lU2gj7jtJIvGSt9HzatK/6I6bWusI5nyuaTA== + dependencies: + "@ethersproject/logger" "^5.0.8" + +"@ethersproject/constants@5.0.9", "@ethersproject/constants@>=5.0.0-beta.128", "@ethersproject/constants@^5.0.8": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/constants/-/constants-5.0.9.tgz#81ac44c3bf612de63eb1c490b314ea1b932cda9f" + integrity sha512-2uAKH89UcaJP/Sc+54u92BtJtZ4cPgcS1p0YbB1L3tlkavwNvth+kNCUplIB1Becqs7BOZr0B/3dMNjhJDy4Dg== + dependencies: + "@ethersproject/bignumber" "^5.0.13" + +"@ethersproject/contracts@5.0.11", "@ethersproject/contracts@^5.0.5": + version "5.0.11" + resolved "https://registry.yarnpkg.com/@ethersproject/contracts/-/contracts-5.0.11.tgz#e6cc57698a05be2329cb2ca3d7e87686f95e438a" + integrity sha512-FTUUd/6x00dYL2VufE2VowZ7h3mAyBfCQMGwI3tKDIWka+C0CunllFiKrlYCdiHFuVeMotR65dIcnzbLn72MCw== + dependencies: + "@ethersproject/abi" "^5.0.10" + "@ethersproject/abstract-provider" "^5.0.8" + "@ethersproject/abstract-signer" "^5.0.10" + "@ethersproject/address" "^5.0.9" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/constants" "^5.0.8" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + +"@ethersproject/hardware-wallets@^5.0.8": + version "5.0.13" + resolved "https://registry.yarnpkg.com/@ethersproject/hardware-wallets/-/hardware-wallets-5.0.13.tgz#7134da1067b909a6851f03cef791bbdac388c798" + integrity sha512-XgJyNMoV1/1L7KLJT/OV5/NISmnQr2ROpdeO0wGDCGE5Xm9Qfx4jQDAmAIUUvSoGucWFxWTZF8hRuf8V5+VwsQ== + dependencies: + "@ledgerhq/hw-app-eth" "5.27.2" + "@ledgerhq/hw-transport" "5.26.0" + "@ledgerhq/hw-transport-u2f" "5.26.0" + ethers "^5.0.25" + optionalDependencies: + "@ledgerhq/hw-transport-node-hid" "5.26.0" + +"@ethersproject/hash@5.0.11", "@ethersproject/hash@>=5.0.0-beta.128", "@ethersproject/hash@^5.0.10": + version "5.0.11" + resolved "https://registry.yarnpkg.com/@ethersproject/hash/-/hash-5.0.11.tgz#da89517438bbbf8a39df56fff09f0a71669ae7a7" + integrity sha512-H3KJ9fk33XWJ2djAW03IL7fg3DsDMYjO1XijiUb1hJ85vYfhvxu0OmsU7d3tg2Uv1H1kFSo8ghr3WFQ8c+NL3g== + dependencies: + "@ethersproject/abstract-signer" "^5.0.10" + "@ethersproject/address" "^5.0.9" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/keccak256" "^5.0.7" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/strings" "^5.0.8" + +"@ethersproject/hdnode@5.0.9", "@ethersproject/hdnode@^5.0.8": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/hdnode/-/hdnode-5.0.9.tgz#ce65b430d3d3f0cd3c8f9dfaaf376b55881d9dba" + integrity sha512-S5UMmIC6XfFtqhUK4uTjD8GPNzSbE+sZ/0VMqFnA3zAJ+cEFZuEyhZDYnl2ItGJzjT4jsy+uEy1SIl3baYK1PQ== + dependencies: + "@ethersproject/abstract-signer" "^5.0.10" + "@ethersproject/basex" "^5.0.7" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/pbkdf2" "^5.0.7" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/sha2" "^5.0.7" + "@ethersproject/signing-key" "^5.0.8" + "@ethersproject/strings" "^5.0.8" + "@ethersproject/transactions" "^5.0.9" + "@ethersproject/wordlists" "^5.0.8" + +"@ethersproject/json-wallets@5.0.11", "@ethersproject/json-wallets@^5.0.10": + version "5.0.11" + resolved "https://registry.yarnpkg.com/@ethersproject/json-wallets/-/json-wallets-5.0.11.tgz#86fdc41b7762acb443d6a896f6c61231ab2aee5d" + integrity sha512-0GhWScWUlXXb4qJNp0wmkU95QS3YdN9UMOfMSEl76CRANWWrmyzxcBVSXSBu5iQ0/W8wO+xGlJJ3tpA6v3mbIw== + dependencies: + "@ethersproject/abstract-signer" "^5.0.10" + "@ethersproject/address" "^5.0.9" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/hdnode" "^5.0.8" + "@ethersproject/keccak256" "^5.0.7" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/pbkdf2" "^5.0.7" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/random" "^5.0.7" + "@ethersproject/strings" "^5.0.8" + "@ethersproject/transactions" "^5.0.9" + aes-js "3.0.0" + scrypt-js "3.0.1" + +"@ethersproject/keccak256@5.0.8", "@ethersproject/keccak256@>=5.0.0-beta.127", "@ethersproject/keccak256@^5.0.7": + version "5.0.8" + resolved "https://registry.yarnpkg.com/@ethersproject/keccak256/-/keccak256-5.0.8.tgz#13aaf69e1c8bd15fc59a2ebd055c0878f2a059c8" + integrity sha512-zoGbwXcWWs9MX4NOAZ7N0hhgIRl4Q/IO/u9c/RHRY4WqDy3Ywm0OLamEV53QDwhjwn3YiiVwU1Ve5j7yJ0a/KQ== + dependencies: + "@ethersproject/bytes" "^5.0.9" + js-sha3 "0.5.7" + +"@ethersproject/logger@5.0.9", "@ethersproject/logger@>=5.0.0-beta.129", "@ethersproject/logger@^5.0.8": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/logger/-/logger-5.0.9.tgz#0e6a0b3ecc938713016954daf4ac7967467aa763" + integrity sha512-kV3Uamv3XOH99Xf3kpIG3ZkS7mBNYcLDM00JSDtNgNB4BihuyxpQzIZPRIDmRi+95Z/R1Bb0X2kUNHa/kJoVrw== + +"@ethersproject/networks@5.0.8", "@ethersproject/networks@^5.0.7": + version "5.0.8" + resolved "https://registry.yarnpkg.com/@ethersproject/networks/-/networks-5.0.8.tgz#37e6f8c058f2d540373ea5939056cd3de069132e" + integrity sha512-PYpptlO2Tu5f/JEBI5hdlMds5k1DY1QwVbh3LKPb3un9dQA2bC51vd2/gRWAgSBpF3kkmZOj4FhD7ATLX4H+DA== + dependencies: + "@ethersproject/logger" "^5.0.8" + +"@ethersproject/pbkdf2@5.0.8", "@ethersproject/pbkdf2@^5.0.7": + version "5.0.8" + resolved "https://registry.yarnpkg.com/@ethersproject/pbkdf2/-/pbkdf2-5.0.8.tgz#06a086b1ac04c75e6846afd6cf6170a49a634411" + integrity sha512-UlmAMGbIPaS2xXsI38FbePVTfJMuU9jnwcqVn3p88HxPF4kD897ha+l3TNsBqJqf32UbQL5GImnf1oJkSKq4vQ== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/sha2" "^5.0.7" + +"@ethersproject/properties@5.0.8", "@ethersproject/properties@>=5.0.0-beta.131", "@ethersproject/properties@^5.0.7": + version "5.0.8" + resolved "https://registry.yarnpkg.com/@ethersproject/properties/-/properties-5.0.8.tgz#e45d28d25402c73394873dbf058f856c966cae01" + integrity sha512-zEnLMze2Eu2VDPj/05QwCwMKHh506gpT9PP9KPVd4dDB+5d6AcROUYVLoIIQgBYK7X/Gw0UJmG3oVtnxOQafAw== + dependencies: + "@ethersproject/logger" "^5.0.8" + +"@ethersproject/providers@5.0.23": + version "5.0.23" + resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.0.23.tgz#1e26512303d60bbd557242532fdb5fa3c5d5fb73" + integrity sha512-eJ94z2tgPaUgUmxwd3BVkIzkgkbNIkY6wRPVas04LVaBTycObQbgj794aaUu2bfk7+Bn2B/gjUZtJW1ybxh9/A== + dependencies: + "@ethersproject/abstract-provider" "^5.0.8" + "@ethersproject/abstract-signer" "^5.0.10" + "@ethersproject/address" "^5.0.9" + "@ethersproject/basex" "^5.0.7" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/constants" "^5.0.8" + "@ethersproject/hash" "^5.0.10" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/networks" "^5.0.7" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/random" "^5.0.7" + "@ethersproject/rlp" "^5.0.7" + "@ethersproject/sha2" "^5.0.7" + "@ethersproject/strings" "^5.0.8" + "@ethersproject/transactions" "^5.0.9" + "@ethersproject/web" "^5.0.12" + bech32 "1.1.4" + ws "7.2.3" + +"@ethersproject/random@5.0.8", "@ethersproject/random@^5.0.7": + version "5.0.8" + resolved "https://registry.yarnpkg.com/@ethersproject/random/-/random-5.0.8.tgz#8d3726be48e95467abce9b23c93adbb1de009dda" + integrity sha512-4rHtotmd9NjklW0eDvByicEkL+qareIyFSbG1ShC8tPJJSAC0g55oQWzw+3nfdRCgBHRuEE7S8EcPcTVPvZ9cA== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + +"@ethersproject/rlp@5.0.8", "@ethersproject/rlp@^5.0.7": + version "5.0.8" + resolved "https://registry.yarnpkg.com/@ethersproject/rlp/-/rlp-5.0.8.tgz#ff54e206d0ae28640dd054f2bcc7070f06f9dfbe" + integrity sha512-E4wdFs8xRNJfzNHmnkC8w5fPeT4Wd1U2cust3YeT16/46iSkLT8nn8ilidC6KhR7hfuSZE4UqSPzyk76p7cdZg== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + +"@ethersproject/sha2@5.0.8", "@ethersproject/sha2@^5.0.7": + version "5.0.8" + resolved "https://registry.yarnpkg.com/@ethersproject/sha2/-/sha2-5.0.8.tgz#9903c67e562739d8b312820b0a265b9c9bf35fc3" + integrity sha512-ILP1ZgyvDj4rrdE+AXrTv9V88m7x87uga2VZ/FeULKPumOEw/4bGnJz/oQ8zDnDvVYRCJ+48VaQBS2CFLbk1ww== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + hash.js "1.1.3" + +"@ethersproject/signing-key@5.0.10", "@ethersproject/signing-key@^5.0.8": + version "5.0.10" + resolved "https://registry.yarnpkg.com/@ethersproject/signing-key/-/signing-key-5.0.10.tgz#05e26e04f0aa5360dc78674d7331bacea8fea5c1" + integrity sha512-w5it3GbFOvN6e0mTd5gDNj+bwSe6L9jqqYjU+uaYS8/hAEp4qYLk5p8ZjbJJkNn7u1p0iwocp8X9oH/OdK8apA== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + elliptic "6.5.4" + +"@ethersproject/solidity@5.0.9": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/solidity/-/solidity-5.0.9.tgz#49100fbe9f364ac56f7ff7c726f4f3d151901134" + integrity sha512-LIxSAYEQgLRXE3mRPCq39ou61kqP8fDrGqEeNcaNJS3aLbmAOS8MZp56uK++WsdI9hj8sNsFh78hrAa6zR9Jag== + dependencies: + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/keccak256" "^5.0.7" + "@ethersproject/sha2" "^5.0.7" + "@ethersproject/strings" "^5.0.8" + +"@ethersproject/strings@5.0.9", "@ethersproject/strings@>=5.0.0-beta.130", "@ethersproject/strings@^5.0.8": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/strings/-/strings-5.0.9.tgz#8e2eb2918b140231e1d1b883d77e43213a8ac280" + integrity sha512-ogxBpcUpdO524CYs841MoJHgHxEPUy0bJFDS4Ezg8My+WYVMfVAOlZSLss0Rurbeeam8CpUVDzM4zUn09SU66Q== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/constants" "^5.0.8" + "@ethersproject/logger" "^5.0.8" + +"@ethersproject/transactions@5.0.10", "@ethersproject/transactions@^5.0.0-beta.135", "@ethersproject/transactions@^5.0.9": + version "5.0.10" + resolved "https://registry.yarnpkg.com/@ethersproject/transactions/-/transactions-5.0.10.tgz#d50cafd80d27206336f80114bc0f18bc18687331" + integrity sha512-Tqpp+vKYQyQdJQQk4M73tDzO7ODf2D42/sJOcKlDAAbdSni13v6a+31hUdo02qYXhVYwIs+ZjHnO4zKv5BNk8w== + dependencies: + "@ethersproject/address" "^5.0.9" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/constants" "^5.0.8" + "@ethersproject/keccak256" "^5.0.7" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/rlp" "^5.0.7" + "@ethersproject/signing-key" "^5.0.8" + +"@ethersproject/units@5.0.10": + version "5.0.10" + resolved "https://registry.yarnpkg.com/@ethersproject/units/-/units-5.0.10.tgz#9cca3b65cd0c92fab1bd33f2abd233546dd61987" + integrity sha512-eaiHi9ham5lbC7qpqxpae7OY/nHJUnRUnFFuEwi2VB5Nwe3Np468OAV+e+HR+jAK4fHXQE6PFBTxWGtnZuO37g== + dependencies: + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/constants" "^5.0.8" + "@ethersproject/logger" "^5.0.8" + +"@ethersproject/wallet@5.0.11": + version "5.0.11" + resolved "https://registry.yarnpkg.com/@ethersproject/wallet/-/wallet-5.0.11.tgz#9891936089d1b91e22ed59f850bc344b1544bf26" + integrity sha512-2Fg/DOvUltR7aZTOyWWlQhru+SKvq2UE3uEhXSyCFgMqDQNuc2nHXh1SHJtN65jsEbjVIppOe1Q7EQMvhmeeRw== + dependencies: + "@ethersproject/abstract-provider" "^5.0.8" + "@ethersproject/abstract-signer" "^5.0.10" + "@ethersproject/address" "^5.0.9" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/hash" "^5.0.10" + "@ethersproject/hdnode" "^5.0.8" + "@ethersproject/json-wallets" "^5.0.10" + "@ethersproject/keccak256" "^5.0.7" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/random" "^5.0.7" + "@ethersproject/signing-key" "^5.0.8" + "@ethersproject/transactions" "^5.0.9" + "@ethersproject/wordlists" "^5.0.8" + +"@ethersproject/web@5.0.13", "@ethersproject/web@^5.0.12": + version "5.0.13" + resolved "https://registry.yarnpkg.com/@ethersproject/web/-/web-5.0.13.tgz#5a92ac6d835d2ebce95b6b645a86668736e2f532" + integrity sha512-G3x/Ns7pQm21ALnWLbdBI5XkW/jrsbXXffI9hKNPHqf59mTxHYtlNiSwxdoTSwCef3Hn7uvGZpaSgTyxs7IufQ== + dependencies: + "@ethersproject/base64" "^5.0.7" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/strings" "^5.0.8" + +"@ethersproject/wordlists@5.0.9", "@ethersproject/wordlists@^5.0.8": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/wordlists/-/wordlists-5.0.9.tgz#f16cc0b317637c3ae9c689ebd7bc2cbbffadd013" + integrity sha512-Sn6MTjZkfbriod6GG6+p43W09HOXT4gwcDVNj0YoPYlo4Zq2Fk6b1CU9KUX3c6aI17PrgYb4qwZm5BMuORyqyQ== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/hash" "^5.0.10" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/strings" "^5.0.8" + +"@ledgerhq/cryptoassets@^5.27.2": + version "5.44.1" + resolved "https://registry.yarnpkg.com/@ledgerhq/cryptoassets/-/cryptoassets-5.44.1.tgz#15c4aeae21049e899fe1af711150deb2540f5e55" + integrity sha512-UhAL5kH81VgU2DGXjrz+tX3fXwYtJWSrDkna01lBl56Js8S57n/s47fajpU93K2msYqjJ5hhKaNgSvjNSmeMoA== + dependencies: + invariant "2" + +"@ledgerhq/devices@^5.26.0", "@ledgerhq/devices@^5.43.0": + version "5.43.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/devices/-/devices-5.43.0.tgz#9b8ca838a7f8ece74098dc84aa6468eb7651972d" + integrity sha512-/M5ZLUBdBK7Vl2T4yNJbES3Z4w55LbPdxD9rcOBAKH/5V3V0obQv6MUasP9b7DSkwGSSLCOGZLohoT2NxK2D2A== + dependencies: + "@ledgerhq/errors" "^5.43.0" + "@ledgerhq/logs" "^5.43.0" + rxjs "^6.6.3" + semver "^7.3.4" + +"@ledgerhq/errors@^5.26.0", "@ledgerhq/errors@^5.43.0": + version "5.43.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-5.43.0.tgz#6bec77ebc31c4333a7f8d13b1f3f4d739b859b75" + integrity sha512-ZjKlUQbIn/DHXAefW3Y1VyDrlVhVqqGnXzrqbOXuDbZ2OAIfSe/A1mrlCbWt98jP/8EJQBuCzBOtnmpXIL/nYg== + +"@ledgerhq/hw-app-eth@5.27.2": + version "5.27.2" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-5.27.2.tgz#65a2ed613a69340e0cd69c942147455ec513d006" + integrity sha512-llNdrE894cCN8j6yxJEUniciyLVcLmu5N0UmIJLOObztG+5rOF4bX54h4SreTWK+E10Z0CzHSeyE5Lz/tVcqqQ== + dependencies: + "@ledgerhq/cryptoassets" "^5.27.2" + "@ledgerhq/errors" "^5.26.0" + "@ledgerhq/hw-transport" "^5.26.0" + bignumber.js "^9.0.1" + rlp "^2.2.6" + +"@ledgerhq/hw-transport-node-hid-noevents@^5.26.0": + version "5.43.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid-noevents/-/hw-transport-node-hid-noevents-5.43.0.tgz#42faf14019f5cc4e46335539d0e6e05d5acfc470" + integrity sha512-3TqeVTFslJdaAPgQh9qqRN6MuEkDNA9talEdm6k6osB3aIG3I67TNMTOY32nWdyeGx9VuEw0guUN1KJpxWQ1rg== + dependencies: + "@ledgerhq/devices" "^5.43.0" + "@ledgerhq/errors" "^5.43.0" + "@ledgerhq/hw-transport" "^5.43.0" + "@ledgerhq/logs" "^5.43.0" + node-hid "2.1.1" + +"@ledgerhq/hw-transport-node-hid@5.26.0": + version "5.26.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid/-/hw-transport-node-hid-5.26.0.tgz#69bc4f8067cdd9c09ef4aed0e0b3c58328936e4b" + integrity sha512-qhaefZVZatJ6UuK8Wb6WSFNOLWc2mxcv/xgsfKi5HJCIr4bPF/ecIeN+7fRcEaycxj4XykY6Z4A7zDVulfFH4w== + dependencies: + "@ledgerhq/devices" "^5.26.0" + "@ledgerhq/errors" "^5.26.0" + "@ledgerhq/hw-transport" "^5.26.0" + "@ledgerhq/hw-transport-node-hid-noevents" "^5.26.0" + "@ledgerhq/logs" "^5.26.0" + lodash "^4.17.20" + node-hid "1.3.0" + usb "^1.6.3" + +"@ledgerhq/hw-transport-u2f@5.26.0": + version "5.26.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-u2f/-/hw-transport-u2f-5.26.0.tgz#b7d9d13193eb82b051fd7a838cd652372f907ec5" + integrity sha512-QTxP1Rsh+WZ184LUOelYVLeaQl3++V3I2jFik+l9JZtakwEHjD0XqOT750xpYNL/vfHsy31Wlz+oicdxGzFk+w== + dependencies: + "@ledgerhq/errors" "^5.26.0" + "@ledgerhq/hw-transport" "^5.26.0" + "@ledgerhq/logs" "^5.26.0" + u2f-api "0.2.7" + +"@ledgerhq/hw-transport@5.26.0": + version "5.26.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-5.26.0.tgz#bfedc3d48400ad2fe48278d9444344b72aa9d0fe" + integrity sha512-NFeJOJmyEfAX8uuIBTpocWHcz630sqPcXbu864Q+OCBm4EK5UOKV1h/pX7e0xgNIKY8zhJ/O4p4cIZp9tnXLHQ== + dependencies: + "@ledgerhq/devices" "^5.26.0" + "@ledgerhq/errors" "^5.26.0" + events "^3.2.0" + +"@ledgerhq/hw-transport@^5.26.0", "@ledgerhq/hw-transport@^5.43.0": + version "5.43.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-5.43.0.tgz#dc9863706d31bae96aed66f193b8922a876cbf82" + integrity sha512-0S+TGmiEJOqgM2MWnolZQPVKU3oRtoDj4yUFUZts9Owbgby+hmo4dIKTvv0vs8mwknQbOZByUgh3MQOQiK70MQ== + dependencies: + "@ledgerhq/devices" "^5.43.0" + "@ledgerhq/errors" "^5.43.0" + events "^3.2.0" + +"@ledgerhq/logs@^5.26.0", "@ledgerhq/logs@^5.43.0": + version "5.43.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/logs/-/logs-5.43.0.tgz#031bad4b8a3525c5e14210afde0bc09c79564026" + integrity sha512-QWfQjea3ekh9ZU+JeL2tJC9cTKLZ/JrcS0JGatLejpRYxQajvnHvHfh0dbHOKXEaXfCskEPTZ3f1kzuts742GA== + +"@nomiclabs/ethereumjs-vm@4.2.2": + version "4.2.2" + resolved "https://registry.yarnpkg.com/@nomiclabs/ethereumjs-vm/-/ethereumjs-vm-4.2.2.tgz#2f8817113ca0fb6c44c1b870d0a809f0e026a6cc" + integrity sha512-8WmX94mMcJaZ7/m7yBbyuS6B+wuOul+eF+RY9fBpGhNaUpyMR/vFIcDojqcWQ4Yafe1tMKY5LDu2yfT4NZgV4Q== + dependencies: + async "^2.1.2" + async-eventemitter "^0.2.2" + core-js-pure "^3.0.1" + ethereumjs-account "^3.0.0" + ethereumjs-block "^2.2.2" + ethereumjs-blockchain "^4.0.3" + ethereumjs-common "^1.5.0" + ethereumjs-tx "^2.1.2" + ethereumjs-util "^6.2.0" + fake-merkle-patricia-tree "^1.0.1" + functional-red-black-tree "^1.0.1" + merkle-patricia-tree "3.0.0" + rustbn.js "~0.2.0" + safe-buffer "^5.1.1" + util.promisify "^1.0.0" + +"@nomiclabs/hardhat-ethers@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.0.1.tgz#f86a6fa210dbe6270adffccc75e93ed60a856904" + integrity sha512-uTFHDhhvJ+UjfvvMeQxD3ZALuzuI3FXzTYT1Z5N3ebyZL5z4Ogwt55GB0R9tdKY0p5HhDhBjU/gsCjUEwIVoaw== + +"@nomiclabs/hardhat-waffle@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-waffle/-/hardhat-waffle-2.0.1.tgz#5d43654fba780720c5033dea240fe14f70ef4bd2" + integrity sha512-2YR2V5zTiztSH9n8BYWgtv3Q+EL0N5Ltm1PAr5z20uAY4SkkfylJ98CIqt18XFvxTD5x4K2wKBzddjV9ViDAZQ== + dependencies: + "@types/sinon-chai" "^3.2.3" + "@types/web3" "1.0.19" + +"@openzeppelin/contracts@^3.3.0": + version "3.4.0" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.0.tgz#9a1669ad5f9fdfb6e273bb5a4fed10cb4cc35eb0" + integrity sha512-qh+EiHWzfY/9CORr+eRUkeEUP1WiFUcq3974bLHwyYzLBUtK6HPaMkIUHi74S1rDTZ0sNz42DwPc5A4IJvN3rg== + +"@resolver-engine/core@^0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@resolver-engine/core/-/core-0.3.3.tgz#590f77d85d45bc7ecc4e06c654f41345db6ca967" + integrity sha512-eB8nEbKDJJBi5p5SrvrvILn4a0h42bKtbCTri3ZxCGt6UvoQyp7HnGOfki944bUjBSHKK3RvgfViHn+kqdXtnQ== + dependencies: + debug "^3.1.0" + is-url "^1.2.4" + request "^2.85.0" + +"@resolver-engine/fs@^0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@resolver-engine/fs/-/fs-0.3.3.tgz#fbf83fa0c4f60154a82c817d2fe3f3b0c049a973" + integrity sha512-wQ9RhPUcny02Wm0IuJwYMyAG8fXVeKdmhm8xizNByD4ryZlx6PP6kRen+t/haF43cMfmaV7T3Cx6ChOdHEhFUQ== + dependencies: + "@resolver-engine/core" "^0.3.3" + debug "^3.1.0" + +"@resolver-engine/imports-fs@^0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@resolver-engine/imports-fs/-/imports-fs-0.3.3.tgz#4085db4b8d3c03feb7a425fbfcf5325c0d1e6c1b" + integrity sha512-7Pjg/ZAZtxpeyCFlZR5zqYkz+Wdo84ugB5LApwriT8XFeQoLwGUj4tZFFvvCuxaNCcqZzCYbonJgmGObYBzyCA== + dependencies: + "@resolver-engine/fs" "^0.3.3" + "@resolver-engine/imports" "^0.3.3" + debug "^3.1.0" + +"@resolver-engine/imports@^0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@resolver-engine/imports/-/imports-0.3.3.tgz#badfb513bb3ff3c1ee9fd56073e3144245588bcc" + integrity sha512-anHpS4wN4sRMwsAbMXhMfOD/y4a4Oo0Cw/5+rue7hSwGWsDOQaAU1ClK1OxjUC35/peazxEl8JaSRRS+Xb8t3Q== + dependencies: + "@resolver-engine/core" "^0.3.3" + debug "^3.1.0" + hosted-git-info "^2.6.0" + path-browserify "^1.0.0" + url "^0.11.0" + +"@sentry/core@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.30.0.tgz#6b203664f69e75106ee8b5a2fe1d717379b331f3" + integrity sha512-TmfrII8w1PQZSZgPpUESqjB+jC6MvZJZdLtE/0hZ+SrnKhW3x5WlYLvTXZpcWePYBku7rl2wn1RZu6uT0qCTeg== + dependencies: + "@sentry/hub" "5.30.0" + "@sentry/minimal" "5.30.0" + "@sentry/types" "5.30.0" + "@sentry/utils" "5.30.0" + tslib "^1.9.3" + +"@sentry/hub@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.30.0.tgz#2453be9b9cb903404366e198bd30c7ca74cdc100" + integrity sha512-2tYrGnzb1gKz2EkMDQcfLrDTvmGcQPuWxLnJKXJvYTQDGLlEvi2tWz1VIHjunmOvJrB5aIQLhm+dcMRwFZDCqQ== + dependencies: + "@sentry/types" "5.30.0" + "@sentry/utils" "5.30.0" + tslib "^1.9.3" + +"@sentry/minimal@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.30.0.tgz#ce3d3a6a273428e0084adcb800bc12e72d34637b" + integrity sha512-BwWb/owZKtkDX+Sc4zCSTNcvZUq7YcH3uAVlmh/gtR9rmUvbzAA3ewLuB3myi4wWRAMEtny6+J/FN/x+2wn9Xw== + dependencies: + "@sentry/hub" "5.30.0" + "@sentry/types" "5.30.0" + tslib "^1.9.3" + +"@sentry/node@^5.18.1": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.30.0.tgz#4ca479e799b1021285d7fe12ac0858951c11cd48" + integrity sha512-Br5oyVBF0fZo6ZS9bxbJZG4ApAjRqAnqFFurMVJJdunNb80brh7a5Qva2kjhm+U6r9NJAB5OmDyPkA1Qnt+QVg== + dependencies: + "@sentry/core" "5.30.0" + "@sentry/hub" "5.30.0" + "@sentry/tracing" "5.30.0" + "@sentry/types" "5.30.0" + "@sentry/utils" "5.30.0" + cookie "^0.4.1" + https-proxy-agent "^5.0.0" + lru_map "^0.3.3" + tslib "^1.9.3" + +"@sentry/tracing@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-5.30.0.tgz#501d21f00c3f3be7f7635d8710da70d9419d4e1f" + integrity sha512-dUFowCr0AIMwiLD7Fs314Mdzcug+gBVo/+NCMyDw8tFxJkwWAKl7Qa2OZxLQ0ZHjakcj1hNKfCQJ9rhyfOl4Aw== + dependencies: + "@sentry/hub" "5.30.0" + "@sentry/minimal" "5.30.0" + "@sentry/types" "5.30.0" + "@sentry/utils" "5.30.0" + tslib "^1.9.3" + +"@sentry/types@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.30.0.tgz#19709bbe12a1a0115bc790b8942917da5636f402" + integrity sha512-R8xOqlSTZ+htqrfteCWU5Nk0CDN5ApUTvrlvBuiH1DyP6czDZ4ktbZB0hAgBlVcK0U+qpD3ag3Tqqpa5Q67rPw== + +"@sentry/utils@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.30.0.tgz#9a5bd7ccff85ccfe7856d493bffa64cabc41e980" + integrity sha512-zaYmoH0NWWtvnJjC9/CBseXMtKHm/tm40sz3YfJRxeQjyzRqNQPgivpd9R/oDJCYj999mzdW382p/qi2ypjLww== + dependencies: + "@sentry/types" "5.30.0" + tslib "^1.9.3" + +"@sindresorhus/is@^0.14.0": + version "0.14.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" + integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ== + +"@solidity-parser/parser@^0.11.0": + version "0.11.1" + resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.11.1.tgz#fa840af64840c930f24a9c82c08d4a092a068add" + integrity sha512-H8BSBoKE8EubJa0ONqecA2TviT3TnHeC4NpgnAHSUiuhZoQBfPB4L2P9bs8R6AoTW10Endvh3vc+fomVMIDIYQ== + +"@szmarczak/http-timer@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421" + integrity sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA== + dependencies: + defer-to-connect "^1.0.1" + +"@typechain/ethers-v5@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@typechain/ethers-v5/-/ethers-v5-1.0.0.tgz#9156c9a2b078f9bb00a339631221e42c26b218df" + integrity sha512-CWxLmlmfM7NMT6OSq8UXZM7mSkHU1xrbNi40Hvj26S97jKnwERmNbiERgy4fXXOdVqb+zCshnZQ9X+P5WndLMA== + dependencies: + ethers "^5.0.2" + +"@typechain/ethers-v5@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@typechain/ethers-v5/-/ethers-v5-2.0.0.tgz#cd3ca1590240d587ca301f4c029b67bfccd08810" + integrity sha512-0xdCkyGOzdqh4h5JSf+zoWx85IusEjDcPIwNEHP8mrWSnCae4rvrqB+/gtpdNfX7zjlFlZiMeePn2r63EI3Lrw== + dependencies: + ethers "^5.0.2" + +"@typechain/hardhat@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@typechain/hardhat/-/hardhat-1.0.1.tgz#6e53956c15b2aff073413cfcdb3f5339b0a85f2e" + integrity sha512-gRETPlvLdN95PIP3PVktEtQSnSMJMWxaxNKI34KFPYEuW4QLLm6UrUCHWmulhB1eUQ1EhYRAda7kEhcJOQ/M1g== + +"@types/abstract-leveldown@*": + version "5.0.1" + resolved "https://registry.yarnpkg.com/@types/abstract-leveldown/-/abstract-leveldown-5.0.1.tgz#3c7750d0186b954c7f2d2f6acc8c3c7ba0c3412e" + integrity sha512-wYxU3kp5zItbxKmeRYCEplS2MW7DzyBnxPGj+GJVHZEUZiK/nn5Ei1sUFgURDh+X051+zsGe28iud3oHjrYWQQ== + +"@types/bn.js@*": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.0.tgz#32c5d271503a12653c62cf4d2b45e6eab8cebc68" + integrity sha512-QSSVYj7pYFN49kW77o2s9xTCwZ8F2xLbjLLSEVh8D2F4JUhZtPAGOFLTD+ffqksBx/u4cE/KImFjyhqCjn/LIA== + dependencies: + "@types/node" "*" + +"@types/bn.js@^4.11.3", "@types/bn.js@^4.11.5": + version "4.11.6" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-4.11.6.tgz#c306c70d9358aaea33cd4eda092a742b9505967c" + integrity sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg== + dependencies: + "@types/node" "*" + +"@types/chai-as-promised@^7.1.3": + version "7.1.3" + resolved "https://registry.yarnpkg.com/@types/chai-as-promised/-/chai-as-promised-7.1.3.tgz#779166b90fda611963a3adbfd00b339d03b747bd" + integrity sha512-FQnh1ohPXJELpKhzjuDkPLR2BZCAqed+a6xV4MI/T3XzHfd2FlarfUGUdZYgqYe8oxkYn0fchHEeHfHqdZ96sg== + dependencies: + "@types/chai" "*" + +"@types/chai@*", "@types/chai@^4.2.15": + version "4.2.15" + resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.15.tgz#b7a6d263c2cecf44b6de9a051cf496249b154553" + integrity sha512-rYff6FI+ZTKAPkJUoyz7Udq3GaoDZnxYDEvdEdFZASiA7PoErltHezDishqQiSDWrGxvxmplH304jyzQmjp0AQ== + +"@types/glob@^7.1.3": + version "7.1.3" + resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.3.tgz#e6ba80f36b7daad2c685acd9266382e68985c183" + integrity sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w== + dependencies: + "@types/minimatch" "*" + "@types/node" "*" + +"@types/levelup@^4.3.0": + version "4.3.0" + resolved "https://registry.yarnpkg.com/@types/levelup/-/levelup-4.3.0.tgz#4f55585e05a33caa08c1439c344bbba93e947327" + integrity sha512-h82BoajhjU/zwLoM4BUBX/SCodCFi1ae/ZlFOYh5Z4GbHeaXj9H709fF1LYl/StrK8KSwnJOeMRPo9lnC6sz4w== + dependencies: + "@types/abstract-leveldown" "*" + "@types/node" "*" + +"@types/lodash@^4.14.161": + version "4.14.168" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.168.tgz#fe24632e79b7ade3f132891afff86caa5e5ce008" + integrity sha512-oVfRvqHV/V6D1yifJbVRU3TMp8OT6o6BG+U9MkwuJ3U8/CsDHvalRpsxBqivn71ztOFZBTfJMvETbqHiaNSj7Q== + +"@types/lru-cache@^5.1.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-5.1.0.tgz#57f228f2b80c046b4a1bd5cac031f81f207f4f03" + integrity sha512-RaE0B+14ToE4l6UqdarKPnXwVDuigfFv+5j9Dze/Nqr23yyuqdNvzcZi3xB+3Agvi5R4EOgAksfv3lXX4vBt9w== + +"@types/minimatch@*": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" + integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== + +"@types/mkdirp@^0.5.2": + version "0.5.2" + resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-0.5.2.tgz#503aacfe5cc2703d5484326b1b27efa67a339c1f" + integrity sha512-U5icWpv7YnZYGsN4/cmh3WD2onMY0aJIiTE6+51TwJCttdHvtCYmkBNOobHlXwrJRL0nkH9jH4kD+1FAdMN4Tg== + dependencies: + "@types/node" "*" + +"@types/mocha@^8.2.0": + version "8.2.1" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.1.tgz#f3f3ae4590c5386fc7c543aae9b78d4cf30ffee9" + integrity sha512-NysN+bNqj6E0Hv4CTGWSlPzMW6vTKjDpOteycDkV4IWBsO+PU48JonrPzV9ODjiI2XrjmA05KInLgF5ivZ/YGQ== + +"@types/node-fetch@^2.5.5": + version "2.5.8" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.8.tgz#e199c835d234c7eb0846f6618012e558544ee2fb" + integrity sha512-fbjI6ja0N5ZA8TV53RUqzsKNkl9fv8Oj3T7zxW7FGv1GSH7gwJaNF8dzCjrqKaxKeUpTz4yT1DaJFq/omNpGfw== + dependencies: + "@types/node" "*" + form-data "^3.0.0" + +"@types/node@*": + version "14.14.28" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.28.tgz#cade4b64f8438f588951a6b35843ce536853f25b" + integrity sha512-lg55ArB+ZiHHbBBttLpzD07akz0QPrZgUODNakeC09i62dnrywr9mFErHuaPlB6I7z+sEbK+IYmplahvplCj2g== + +"@types/node@^12.12.6": + version "12.20.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.1.tgz#63d36c10e162666f0107f247cdca76542c3c7472" + integrity sha512-tCkE96/ZTO+cWbln2xfyvd6ngHLanvVlJ3e5BeirJ3BYI5GbAyubIrmV4JjjugDly5D9fHjOL5MNsqsCnqwW6g== + +"@types/node@^14.14.27": + version "14.14.31" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.31.tgz#72286bd33d137aa0d152d47ec7c1762563d34055" + integrity sha512-vFHy/ezP5qI0rFgJ7aQnjDXwAMrG0KqqIH7tQG5PPv3BWBayOPIQNBjVc/P6hhdZfMx51REc6tfDNXHUio893g== + +"@types/pbkdf2@^3.0.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@types/pbkdf2/-/pbkdf2-3.1.0.tgz#039a0e9b67da0cdc4ee5dab865caa6b267bb66b1" + integrity sha512-Cf63Rv7jCQ0LaL8tNXmEyqTHuIJxRdlS5vMh1mj5voN4+QFhVZnlZruezqpWYDiJ8UTzhP0VmeLXCmBk66YrMQ== + dependencies: + "@types/node" "*" + +"@types/prettier@^1.13.2": + version "1.19.1" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.19.1.tgz#33509849f8e679e4add158959fdb086440e9553f" + integrity sha512-5qOlnZscTn4xxM5MeGXAMOsIOIKIbh9e85zJWfBRVPlRMEVawzoPhINYbRGkBZCI8LxvBe7tJCdWiarA99OZfQ== + +"@types/prettier@^2.1.1": + version "2.2.3" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.3.tgz#ef65165aea2924c9359205bf748865b8881753c0" + integrity sha512-PijRCG/K3s3w1We6ynUKdxEc5AcuuH3NBmMDP8uvKVp6X43UY7NQlTzczakXP3DJR0F4dfNQIGjU2cUeRYs2AA== + +"@types/resolve@^0.0.8": + version "0.0.8" + resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-0.0.8.tgz#f26074d238e02659e323ce1a13d041eee280e194" + integrity sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ== + dependencies: + "@types/node" "*" + +"@types/secp256k1@^4.0.1": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@types/secp256k1/-/secp256k1-4.0.1.tgz#fb3aa61a1848ad97d7425ff9dcba784549fca5a4" + integrity sha512-+ZjSA8ELlOp8SlKi0YLB2tz9d5iPNEmOBd+8Rz21wTMdaXQIa9b6TEnD6l5qKOCypE7FSyPyck12qZJxSDNoog== + dependencies: + "@types/node" "*" + +"@types/sinon-chai@^3.2.3": + version "3.2.5" + resolved "https://registry.yarnpkg.com/@types/sinon-chai/-/sinon-chai-3.2.5.tgz#df21ae57b10757da0b26f512145c065f2ad45c48" + integrity sha512-bKQqIpew7mmIGNRlxW6Zli/QVyc3zikpGzCa797B/tRnD9OtHvZ/ts8sYXV+Ilj9u3QRaUEM8xrjgd1gwm1BpQ== + dependencies: + "@types/chai" "*" + "@types/sinon" "*" + +"@types/sinon@*": + version "9.0.10" + resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-9.0.10.tgz#7fb9bcb6794262482859cab66d59132fca18fcf7" + integrity sha512-/faDC0erR06wMdybwI/uR8wEKV/E83T0k4sepIpB7gXuy2gzx2xiOjmztq6a2Y6rIGJ04D+6UU0VBmWy+4HEMA== + dependencies: + "@types/sinonjs__fake-timers" "*" + +"@types/sinonjs__fake-timers@*": + version "6.0.2" + resolved "https://registry.yarnpkg.com/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-6.0.2.tgz#3a84cf5ec3249439015e14049bd3161419bf9eae" + integrity sha512-dIPoZ3g5gcx9zZEszaxLSVTvMReD3xxyyDnQUjA6IYDG9Ba2AV0otMPs+77sG9ojB4Qr2N2Vk5RnKeuA0X/0bg== + +"@types/underscore@*": + version "1.10.24" + resolved "https://registry.yarnpkg.com/@types/underscore/-/underscore-1.10.24.tgz#dede004deed3b3f99c4db0bdb9ee21cae25befdd" + integrity sha512-T3NQD8hXNW2sRsSbLNjF/aBo18MyJlbw0lSpQHB/eZZtScPdexN4HSa8cByYwTw9Wy7KuOFr81mlDQcQQaZ79w== + +"@types/web3@1.0.19": + version "1.0.19" + resolved "https://registry.yarnpkg.com/@types/web3/-/web3-1.0.19.tgz#46b85d91d398ded9ab7c85a5dd57cb33ac558924" + integrity sha512-fhZ9DyvDYDwHZUp5/STa9XW2re0E8GxoioYJ4pEUZ13YHpApSagixj7IAdoYH5uAK+UalGq6Ml8LYzmgRA/q+A== + dependencies: + "@types/bn.js" "*" + "@types/underscore" "*" + +"@ungap/promise-all-settled@1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" + integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== + +"@yarnpkg/lockfile@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31" + integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ== + +abort-controller@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" + integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== + dependencies: + event-target-shim "^5.0.0" + +abstract-leveldown@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-3.0.0.tgz#5cb89f958a44f526779d740d1440e743e0c30a57" + integrity sha512-KUWx9UWGQD12zsmLNj64/pndaz4iJh/Pj7nopgkfDG6RlCcbMZvT6+9l7dchK4idog2Is8VdC/PvNbFuFmalIQ== + dependencies: + xtend "~4.0.0" + +abstract-leveldown@^2.4.1, abstract-leveldown@~2.7.1: + version "2.7.2" + resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-2.7.2.tgz#87a44d7ebebc341d59665204834c8b7e0932cc93" + integrity sha512-+OVvxH2rHVEhWLdbudP6p0+dNMXu8JA1CbhP19T8paTYAcX7oJ4OVjT+ZUVpv7mITxXHqDMej+GdqXBmXkw09w== + dependencies: + xtend "~4.0.0" + +abstract-leveldown@^5.0.0, abstract-leveldown@~5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-5.0.0.tgz#f7128e1f86ccabf7d2893077ce5d06d798e386c6" + integrity sha512-5mU5P1gXtsMIXg65/rsYGsi93+MlogXZ9FA8JnwKurHQg64bfXwGYVdVdijNTVNOlAsuIiOwHdvFFD5JqCJQ7A== + dependencies: + xtend "~4.0.0" + +abstract-leveldown@^6.2.1: + version "6.3.0" + resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-6.3.0.tgz#d25221d1e6612f820c35963ba4bd739928f6026a" + integrity sha512-TU5nlYgta8YrBMNpc9FwQzRbiXsj49gsALsXadbGHt9CROPzX5fB0rWDR5mtdpOOKa5XqRFpbj1QroPAoPzVjQ== + dependencies: + buffer "^5.5.0" + immediate "^3.2.3" + level-concat-iterator "~2.0.0" + level-supports "~1.0.0" + xtend "~4.0.0" + +abstract-leveldown@~2.6.0: + version "2.6.3" + resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-2.6.3.tgz#1c5e8c6a5ef965ae8c35dfb3a8770c476b82c4b8" + integrity sha512-2++wDf/DYqkPR3o5tbfdhF96EfMApo1GpPfzOsR/ZYXdkSmELlvOOEAl9iKkRsktMPHdGjO4rtkBpf2I7TiTeA== + dependencies: + xtend "~4.0.0" + +abstract-leveldown@~6.2.1: + version "6.2.3" + resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-6.2.3.tgz#036543d87e3710f2528e47040bc3261b77a9a8eb" + integrity sha512-BsLm5vFMRUrrLeCcRc+G0t2qOaTzpoJQLOubq2XM72eNpjF5UdU5o/5NvlNhx95XHcAvcl8OMXr4mlg/fRgUXQ== + dependencies: + buffer "^5.5.0" + immediate "^3.2.3" + level-concat-iterator "~2.0.0" + level-supports "~1.0.0" + xtend "~4.0.0" + +accepts@~1.3.7: + version "1.3.7" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" + integrity sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA== + dependencies: + mime-types "~2.1.24" + negotiator "0.6.2" + +adm-zip@^0.4.16: + version "0.4.16" + resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.16.tgz#cf4c508fdffab02c269cbc7f471a875f05570365" + integrity sha512-TFi4HBKSGfIKsK5YCkKaaFG2m4PEDyViZmEwof3MTIgzimHLto6muaHVpbrljdIvIrFZzEq/p4nafOeLcYegrg== + +aes-js@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d" + integrity sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0= + +aes-js@^3.1.1: + version "3.1.2" + resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.1.2.tgz#db9aabde85d5caabbfc0d4f2a4446960f627146a" + integrity sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ== + +agent-base@6: + version "6.0.2" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" + integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== + dependencies: + debug "4" + +ajv@^6.12.3: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ansi-colors@3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.3.tgz#57d35b8686e851e2cc04c403f1c00203976a1813" + integrity sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw== + +ansi-colors@4.1.1, ansi-colors@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== + +ansi-escapes@^4.3.0: + version "4.3.1" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.1.tgz#a5c47cc43181f1f38ffd7076837700d395522a61" + integrity sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA== + dependencies: + type-fest "^0.11.0" + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= + +ansi-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" + integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= + +ansi-regex@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" + integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + +ansi-regex@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" + integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4= + +ansi-styles@^3.2.0, ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +anymatch@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.1.tgz#c55ecf02185e2469259399310c173ce31233b142" + integrity sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +aproba@^1.0.3: + version "1.2.0" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" + integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw== + +are-we-there-yet@~1.1.2: + version "1.1.5" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21" + integrity sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w== + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.6" + +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + +arr-diff@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" + integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA= + +arr-flatten@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" + integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== + +arr-union@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" + integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ= + +array-back@^1.0.3, array-back@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-1.0.4.tgz#644ba7f095f7ffcf7c43b5f0dc39d3c1f03c063b" + integrity sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs= + dependencies: + typical "^2.6.0" + +array-back@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-2.0.0.tgz#6877471d51ecc9c9bfa6136fb6c7d5fe69748022" + integrity sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw== + dependencies: + typical "^2.6.1" + +array-flatten@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" + integrity sha1-ml9pkFGx5wczKPKgCJaLZOopVdI= + +array-unique@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" + integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= + +asn1.js@^5.2.0: + version "5.4.1" + resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07" + integrity sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA== + dependencies: + bn.js "^4.0.0" + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + safer-buffer "^2.1.0" + +asn1@~0.2.3: + version "0.2.4" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" + integrity sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg== + dependencies: + safer-buffer "~2.1.0" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU= + +assertion-error@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" + integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== + +assign-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" + integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= + +async-eventemitter@^0.2.2: + version "0.2.4" + resolved "https://registry.yarnpkg.com/async-eventemitter/-/async-eventemitter-0.2.4.tgz#f5e7c8ca7d3e46aab9ec40a292baf686a0bafaca" + integrity sha512-pd20BwL7Yt1zwDFy+8MX8F1+WCT8aQeKj0kQnTrH9WaeRETlRamVhD0JtRPmrV4GfOJ2F9CvdQkZeZhnh2TuHw== + dependencies: + async "^2.4.0" + +async-limiter@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" + integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== + +async@2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.2.tgz#18330ea7e6e313887f5d2f2a904bac6fe4dd5381" + integrity sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg== + dependencies: + lodash "^4.17.11" + +async@^1.4.2: + version "1.5.2" + resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" + integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo= + +async@^2.0.1, async@^2.1.2, async@^2.4.0, async@^2.5.0, async@^2.6.1: + version "2.6.3" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" + integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== + dependencies: + lodash "^4.17.14" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= + +atob@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" + integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== + +atomic-sleep@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/atomic-sleep/-/atomic-sleep-1.0.0.tgz#eb85b77a601fc932cfe432c5acd364a9e2c9075b" + integrity sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ== + +aws-sign2@~0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + integrity sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg= + +aws4@^1.8.0: + version "1.11.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" + integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== + +babel-code-frame@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" + integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s= + dependencies: + chalk "^1.1.3" + esutils "^2.0.2" + js-tokens "^3.0.2" + +babel-core@^6.0.14, babel-core@^6.26.0: + version "6.26.3" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.3.tgz#b2e2f09e342d0f0c88e2f02e067794125e75c207" + integrity sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA== + dependencies: + babel-code-frame "^6.26.0" + babel-generator "^6.26.0" + babel-helpers "^6.24.1" + babel-messages "^6.23.0" + babel-register "^6.26.0" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + convert-source-map "^1.5.1" + debug "^2.6.9" + json5 "^0.5.1" + lodash "^4.17.4" + minimatch "^3.0.4" + path-is-absolute "^1.0.1" + private "^0.1.8" + slash "^1.0.0" + source-map "^0.5.7" + +babel-generator@^6.26.0: + version "6.26.1" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.1.tgz#1844408d3b8f0d35a404ea7ac180f087a601bd90" + integrity sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA== + dependencies: + babel-messages "^6.23.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + detect-indent "^4.0.0" + jsesc "^1.3.0" + lodash "^4.17.4" + source-map "^0.5.7" + trim-right "^1.0.1" + +babel-helper-builder-binary-assignment-operator-visitor@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz#cce4517ada356f4220bcae8a02c2b346f9a56664" + integrity sha1-zORReto1b0IgvK6KAsKzRvmlZmQ= + dependencies: + babel-helper-explode-assignable-expression "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-call-delegate@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz#ece6aacddc76e41c3461f88bfc575bd0daa2df8d" + integrity sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340= + dependencies: + babel-helper-hoist-variables "^6.24.1" + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-define-map@^6.24.1: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz#a5f56dab41a25f97ecb498c7ebaca9819f95be5f" + integrity sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8= + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" + +babel-helper-explode-assignable-expression@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz#f25b82cf7dc10433c55f70592d5746400ac22caa" + integrity sha1-8luCz33BBDPFX3BZLVdGQArCLKo= + dependencies: + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-function-name@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" + integrity sha1-00dbjAPtmCQqJbSDUasYOZ01gKk= + dependencies: + babel-helper-get-function-arity "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-get-function-arity@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" + integrity sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0= + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-hoist-variables@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz#1ecb27689c9d25513eadbc9914a73f5408be7a76" + integrity sha1-HssnaJydJVE+rbyZFKc/VAi+enY= + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-optimise-call-expression@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz#f7a13427ba9f73f8f4fa993c54a97882d1244257" + integrity sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc= + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-regex@^6.24.1: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz#325c59f902f82f24b74faceed0363954f6495e72" + integrity sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI= + dependencies: + babel-runtime "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" + +babel-helper-remap-async-to-generator@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" + integrity sha1-XsWBgnrXI/7N04HxySg5BnbkVRs= + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-replace-supers@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz#bf6dbfe43938d17369a213ca8a8bf74b6a90ab1a" + integrity sha1-v22/5Dk40XNpohPKiov3S2qQqxo= + dependencies: + babel-helper-optimise-call-expression "^6.24.1" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helpers@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" + integrity sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI= + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-messages@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" + integrity sha1-8830cDhYA1sqKVHG7F7fbGLyYw4= + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-check-es2015-constants@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" + integrity sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o= + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-syntax-async-functions@^6.8.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" + integrity sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU= + +babel-plugin-syntax-exponentiation-operator@^6.8.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de" + integrity sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4= + +babel-plugin-syntax-trailing-function-commas@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" + integrity sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM= + +babel-plugin-transform-async-to-generator@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761" + integrity sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E= + dependencies: + babel-helper-remap-async-to-generator "^6.24.1" + babel-plugin-syntax-async-functions "^6.8.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-arrow-functions@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221" + integrity sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE= + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz#bbc51b49f964d70cb8d8e0b94e820246ce3a6141" + integrity sha1-u8UbSflk1wy42OC5ToICRs46YUE= + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-block-scoping@^6.23.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz#d70f5299c1308d05c12f463813b0a09e73b1895f" + integrity sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8= + dependencies: + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" + +babel-plugin-transform-es2015-classes@^6.23.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db" + integrity sha1-WkxYpQyclGHlZLSyo7+ryXolhNs= + dependencies: + babel-helper-define-map "^6.24.1" + babel-helper-function-name "^6.24.1" + babel-helper-optimise-call-expression "^6.24.1" + babel-helper-replace-supers "^6.24.1" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-computed-properties@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz#6fe2a8d16895d5634f4cd999b6d3480a308159b3" + integrity sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM= + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-destructuring@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" + integrity sha1-mXux8auWf2gtKwh2/jWNYOdlxW0= + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-duplicate-keys@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz#73eb3d310ca969e3ef9ec91c53741a6f1576423e" + integrity sha1-c+s9MQypaePvnskcU3QabxV2Qj4= + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-for-of@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz#f47c95b2b613df1d3ecc2fdb7573623c75248691" + integrity sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE= + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-function-name@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz#834c89853bc36b1af0f3a4c5dbaa94fd8eacaa8b" + integrity sha1-g0yJhTvDaxrw86TF26qU/Y6sqos= + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-literals@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz#4f54a02d6cd66cf915280019a31d31925377ca2e" + integrity sha1-T1SgLWzWbPkVKAAZox0xklN3yi4= + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-modules-amd@^6.22.0, babel-plugin-transform-es2015-modules-amd@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154" + integrity sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ= + dependencies: + babel-plugin-transform-es2015-modules-commonjs "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-modules-commonjs@^6.23.0, babel-plugin-transform-es2015-modules-commonjs@^6.24.1: + version "6.26.2" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz#58a793863a9e7ca870bdc5a881117ffac27db6f3" + integrity sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q== + dependencies: + babel-plugin-transform-strict-mode "^6.24.1" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-types "^6.26.0" + +babel-plugin-transform-es2015-modules-systemjs@^6.23.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" + integrity sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM= + dependencies: + babel-helper-hoist-variables "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-modules-umd@^6.23.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz#ac997e6285cd18ed6176adb607d602344ad38468" + integrity sha1-rJl+YoXNGO1hdq22B9YCNErThGg= + dependencies: + babel-plugin-transform-es2015-modules-amd "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-object-super@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz#24cef69ae21cb83a7f8603dad021f572eb278f8d" + integrity sha1-JM72muIcuDp/hgPa0CH1cusnj40= + dependencies: + babel-helper-replace-supers "^6.24.1" + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-parameters@^6.23.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" + integrity sha1-V6w1GrScrxSpfNE7CfZv3wpiXys= + dependencies: + babel-helper-call-delegate "^6.24.1" + babel-helper-get-function-arity "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-shorthand-properties@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz#24f875d6721c87661bbd99a4622e51f14de38aa0" + integrity sha1-JPh11nIch2YbvZmkYi5R8U3jiqA= + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-spread@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz#d6d68a99f89aedc4536c81a542e8dd9f1746f8d1" + integrity sha1-1taKmfia7cRTbIGlQujdnxdG+NE= + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-sticky-regex@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz#00c1cdb1aca71112cdf0cf6126c2ed6b457ccdbc" + integrity sha1-AMHNsaynERLN8M9hJsLta0V8zbw= + dependencies: + babel-helper-regex "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-template-literals@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz#a84b3450f7e9f8f1f6839d6d687da84bb1236d8d" + integrity sha1-qEs0UPfp+PH2g51taH2oS7EjbY0= + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-typeof-symbol@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz#dec09f1cddff94b52ac73d505c84df59dcceb372" + integrity sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I= + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-unicode-regex@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz#d38b12f42ea7323f729387f18a7c5ae1faeb35e9" + integrity sha1-04sS9C6nMj9yk4fxinxa4frrNek= + dependencies: + babel-helper-regex "^6.24.1" + babel-runtime "^6.22.0" + regexpu-core "^2.0.0" + +babel-plugin-transform-exponentiation-operator@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz#2ab0c9c7f3098fa48907772bb813fe41e8de3a0e" + integrity sha1-KrDJx/MJj6SJB3cruBP+QejeOg4= + dependencies: + babel-helper-builder-binary-assignment-operator-visitor "^6.24.1" + babel-plugin-syntax-exponentiation-operator "^6.8.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-regenerator@^6.22.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz#e0703696fbde27f0a3efcacf8b4dca2f7b3a8f2f" + integrity sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8= + dependencies: + regenerator-transform "^0.10.0" + +babel-plugin-transform-strict-mode@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758" + integrity sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g= + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-preset-env@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.7.0.tgz#dea79fa4ebeb883cd35dab07e260c1c9c04df77a" + integrity sha512-9OR2afuKDneX2/q2EurSftUYM0xGu4O2D9adAhVfADDhrYDaxXV0rBbevVYoY9n6nyX1PmQW/0jtpJvUNr9CHg== + dependencies: + babel-plugin-check-es2015-constants "^6.22.0" + babel-plugin-syntax-trailing-function-commas "^6.22.0" + babel-plugin-transform-async-to-generator "^6.22.0" + babel-plugin-transform-es2015-arrow-functions "^6.22.0" + babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" + babel-plugin-transform-es2015-block-scoping "^6.23.0" + babel-plugin-transform-es2015-classes "^6.23.0" + babel-plugin-transform-es2015-computed-properties "^6.22.0" + babel-plugin-transform-es2015-destructuring "^6.23.0" + babel-plugin-transform-es2015-duplicate-keys "^6.22.0" + babel-plugin-transform-es2015-for-of "^6.23.0" + babel-plugin-transform-es2015-function-name "^6.22.0" + babel-plugin-transform-es2015-literals "^6.22.0" + babel-plugin-transform-es2015-modules-amd "^6.22.0" + babel-plugin-transform-es2015-modules-commonjs "^6.23.0" + babel-plugin-transform-es2015-modules-systemjs "^6.23.0" + babel-plugin-transform-es2015-modules-umd "^6.23.0" + babel-plugin-transform-es2015-object-super "^6.22.0" + babel-plugin-transform-es2015-parameters "^6.23.0" + babel-plugin-transform-es2015-shorthand-properties "^6.22.0" + babel-plugin-transform-es2015-spread "^6.22.0" + babel-plugin-transform-es2015-sticky-regex "^6.22.0" + babel-plugin-transform-es2015-template-literals "^6.22.0" + babel-plugin-transform-es2015-typeof-symbol "^6.23.0" + babel-plugin-transform-es2015-unicode-regex "^6.22.0" + babel-plugin-transform-exponentiation-operator "^6.22.0" + babel-plugin-transform-regenerator "^6.22.0" + browserslist "^3.2.6" + invariant "^2.2.2" + semver "^5.3.0" + +babel-register@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071" + integrity sha1-btAhFz4vy0htestFxgCahW9kcHE= + dependencies: + babel-core "^6.26.0" + babel-runtime "^6.26.0" + core-js "^2.5.0" + home-or-tmp "^2.0.0" + lodash "^4.17.4" + mkdirp "^0.5.1" + source-map-support "^0.4.15" + +babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" + integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.11.0" + +babel-template@^6.24.1, babel-template@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" + integrity sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI= + dependencies: + babel-runtime "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + lodash "^4.17.4" + +babel-traverse@^6.24.1, babel-traverse@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" + integrity sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4= + dependencies: + babel-code-frame "^6.26.0" + babel-messages "^6.23.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + debug "^2.6.8" + globals "^9.18.0" + invariant "^2.2.2" + lodash "^4.17.4" + +babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" + integrity sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc= + dependencies: + babel-runtime "^6.26.0" + esutils "^2.0.2" + lodash "^4.17.4" + to-fast-properties "^1.0.3" + +babelify@^7.3.0: + version "7.3.0" + resolved "https://registry.yarnpkg.com/babelify/-/babelify-7.3.0.tgz#aa56aede7067fd7bd549666ee16dc285087e88e5" + integrity sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU= + dependencies: + babel-core "^6.0.14" + object-assign "^4.0.0" + +babylon@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" + integrity sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ== + +backoff@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/backoff/-/backoff-2.5.0.tgz#f616eda9d3e4b66b8ca7fca79f695722c5f8e26f" + integrity sha1-9hbtqdPktmuMp/ynn2lXIsX44m8= + dependencies: + precond "0.2" + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= + +base-x@^3.0.2, base-x@^3.0.8: + version "3.0.8" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.8.tgz#1e1106c2537f0162e8b52474a557ebb09000018d" + integrity sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA== + dependencies: + safe-buffer "^5.0.1" + +base64-js@^1.3.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +base@^0.11.1: + version "0.11.2" + resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" + integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg== + dependencies: + cache-base "^1.0.1" + class-utils "^0.3.5" + component-emitter "^1.2.1" + define-property "^1.0.0" + isobject "^3.0.1" + mixin-deep "^1.2.0" + pascalcase "^0.1.1" + +bcrypt-pbkdf@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" + integrity sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4= + dependencies: + tweetnacl "^0.14.3" + +bech32@1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" + integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== + +bignumber.js@^9.0.0, bignumber.js@^9.0.1: + version "9.0.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.1.tgz#8d7ba124c882bfd8e43260c67475518d0689e4e5" + integrity sha512-IdZR9mh6ahOBv/hYGiXyVuyCetmGJhtYkqLBpTStdhEGjegpPlUawydyaF3pbIOFynJTpllEs+NP+CS9jKFLjA== + +binary-extensions@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" + integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== + +bindings@^1.4.0, bindings@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" + integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== + dependencies: + file-uri-to-path "1.0.0" + +bip39@2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/bip39/-/bip39-2.5.0.tgz#51cbd5179460504a63ea3c000db3f787ca051235" + integrity sha512-xwIx/8JKoT2+IPJpFEfXoWdYwP7UVAoUxxLNfGCfVowaJE7yg1Y5B1BVPqlUNsBq5/nGwmFkwRJ8xDW4sX8OdA== + dependencies: + create-hash "^1.1.0" + pbkdf2 "^3.0.9" + randombytes "^2.0.1" + safe-buffer "^5.0.1" + unorm "^1.3.3" + +bl@^4.0.3: + version "4.1.0" + resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" + integrity sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w== + dependencies: + buffer "^5.5.0" + inherits "^2.0.4" + readable-stream "^3.4.0" + +blakejs@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/blakejs/-/blakejs-1.1.0.tgz#69df92ef953aa88ca51a32df6ab1c54a155fc7a5" + integrity sha1-ad+S75U6qIylGjLfarHFShVfx6U= + +bluebird@^3.5.0, bluebird@^3.5.2: + version "3.7.2" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" + integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== + +bn.js@4.11.6: + version "4.11.6" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215" + integrity sha1-UzRK2xRhehP26N0s4okF0cC6MhU= + +bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.10.0, bn.js@^4.11.0, bn.js@^4.11.1, bn.js@^4.11.6, bn.js@^4.11.8, bn.js@^4.11.9, bn.js@^4.4.0, bn.js@^4.8.0: + version "4.11.9" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828" + integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw== + +bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.1.2: + version "5.1.3" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.3.tgz#beca005408f642ebebea80b042b4d18d2ac0ee6b" + integrity sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ== + +bn.js@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" + integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== + +body-parser@1.19.0, body-parser@^1.16.0: + version "1.19.0" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" + integrity sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw== + dependencies: + bytes "3.1.0" + content-type "~1.0.4" + debug "2.6.9" + depd "~1.1.2" + http-errors "1.7.2" + iconv-lite "0.4.24" + on-finished "~2.3.0" + qs "6.7.0" + raw-body "2.4.0" + type-is "~1.6.17" + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@^2.3.1: + version "2.3.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" + integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== + dependencies: + arr-flatten "^1.1.0" + array-unique "^0.3.2" + extend-shallow "^2.0.1" + fill-range "^4.0.0" + isobject "^3.0.1" + repeat-element "^1.1.2" + snapdragon "^0.8.1" + snapdragon-node "^2.0.1" + split-string "^3.0.2" + to-regex "^3.0.1" + +braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +brorand@^1.0.1, brorand@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" + integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8= + +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + +browserify-aes@^1.0.0, browserify-aes@^1.0.4, browserify-aes@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.2.0.tgz#326734642f403dabc3003209853bb70ad428ef48" + integrity sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA== + dependencies: + buffer-xor "^1.0.3" + cipher-base "^1.0.0" + create-hash "^1.1.0" + evp_bytestokey "^1.0.3" + inherits "^2.0.1" + safe-buffer "^5.0.1" + +browserify-cipher@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.1.tgz#8d6474c1b870bfdabcd3bcfcc1934a10e94f15f0" + integrity sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w== + dependencies: + browserify-aes "^1.0.4" + browserify-des "^1.0.0" + evp_bytestokey "^1.0.0" + +browserify-des@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/browserify-des/-/browserify-des-1.0.2.tgz#3af4f1f59839403572f1c66204375f7a7f703e9c" + integrity sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A== + dependencies: + cipher-base "^1.0.1" + des.js "^1.0.0" + inherits "^2.0.1" + safe-buffer "^5.1.2" + +browserify-rsa@^4.0.0, browserify-rsa@^4.0.1: + version "4.1.0" + resolved "https://registry.yarnpkg.com/browserify-rsa/-/browserify-rsa-4.1.0.tgz#b2fd06b5b75ae297f7ce2dc651f918f5be158c8d" + integrity sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog== + dependencies: + bn.js "^5.0.0" + randombytes "^2.0.1" + +browserify-sign@^4.0.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.2.1.tgz#eaf4add46dd54be3bb3b36c0cf15abbeba7956c3" + integrity sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg== + dependencies: + bn.js "^5.1.1" + browserify-rsa "^4.0.1" + create-hash "^1.2.0" + create-hmac "^1.1.7" + elliptic "^6.5.3" + inherits "^2.0.4" + parse-asn1 "^5.1.5" + readable-stream "^3.6.0" + safe-buffer "^5.2.0" + +browserslist@^3.2.6: + version "3.2.8" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-3.2.8.tgz#b0005361d6471f0f5952797a76fc985f1f978fc6" + integrity sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ== + dependencies: + caniuse-lite "^1.0.30000844" + electron-to-chromium "^1.3.47" + +bs58@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" + integrity sha1-vhYedsNU9veIrkBx9j806MTwpCo= + dependencies: + base-x "^3.0.2" + +bs58check@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" + integrity sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA== + dependencies: + bs58 "^4.0.0" + create-hash "^1.1.0" + safe-buffer "^5.1.2" + +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== + +buffer-reverse@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/buffer-reverse/-/buffer-reverse-1.0.1.tgz#49283c8efa6f901bc01fa3304d06027971ae2f60" + integrity sha1-SSg8jvpvkBvAH6MwTQYCeXGuL2A= + +buffer-to-arraybuffer@^0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz#6064a40fa76eb43c723aba9ef8f6e1216d10511a" + integrity sha1-YGSkD6dutDxyOrqe+PbhIW0QURo= + +buffer-xor@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" + integrity sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk= + +buffer-xor@^2.0.1, buffer-xor@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-2.0.2.tgz#34f7c64f04c777a1f8aac5e661273bb9dd320289" + integrity sha512-eHslX0bin3GB+Lx2p7lEYRShRewuNZL3fUl4qlVJGGiwoPGftmt8JQgk2Y9Ji5/01TnVDo33E5b5O3vUB1HdqQ== + dependencies: + safe-buffer "^5.1.1" + +buffer@^5.0.5, buffer@^5.2.1, buffer@^5.5.0, buffer@^5.6.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" + integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.1.13" + +bufferutil@^4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.3.tgz#66724b756bed23cd7c28c4d306d7994f9943cc6b" + integrity sha512-yEYTwGndELGvfXsImMBLop58eaGW+YdONi1fNjTINSY98tmMmFijBG6WXgdkfuLNt4imzQNtIE+eBp1PVpMCSw== + dependencies: + node-gyp-build "^4.2.0" + +builtin-modules@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" + integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8= + +bytes@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" + integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg== + +bytewise-core@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/bytewise-core/-/bytewise-core-1.2.3.tgz#3fb410c7e91558eb1ab22a82834577aa6bd61d42" + integrity sha1-P7QQx+kVWOsasiqCg0V3qmvWHUI= + dependencies: + typewise-core "^1.2" + +bytewise@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/bytewise/-/bytewise-1.1.0.tgz#1d13cbff717ae7158094aa881b35d081b387253e" + integrity sha1-HRPL/3F65xWAlKqIGzXQgbOHJT4= + dependencies: + bytewise-core "^1.2.2" + typewise "^1.0.3" + +cache-base@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" + integrity sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ== + dependencies: + collection-visit "^1.0.0" + component-emitter "^1.2.1" + get-value "^2.0.6" + has-value "^1.0.0" + isobject "^3.0.1" + set-value "^2.0.0" + to-object-path "^0.3.0" + union-value "^1.0.0" + unset-value "^1.0.0" + +cacheable-request@^6.0.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-6.1.0.tgz#20ffb8bd162ba4be11e9567d823db651052ca912" + integrity sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg== + dependencies: + clone-response "^1.0.2" + get-stream "^5.1.0" + http-cache-semantics "^4.0.0" + keyv "^3.0.0" + lowercase-keys "^2.0.0" + normalize-url "^4.1.0" + responselike "^1.0.2" + +cachedown@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/cachedown/-/cachedown-1.0.0.tgz#d43f036e4510696b31246d7db31ebf0f7ac32d15" + integrity sha1-1D8DbkUQaWsxJG19sx6/D3rDLRU= + dependencies: + abstract-leveldown "^2.4.1" + lru-cache "^3.2.0" + +call-bind@^1.0.0, call-bind@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" + integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== + dependencies: + function-bind "^1.1.1" + get-intrinsic "^1.0.2" + +camelcase@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" + integrity sha1-MvxLn82vhF/N9+c7uXysImHwqwo= + +camelcase@^5.0.0: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + +camelcase@^6.0.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809" + integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg== + +caniuse-lite@^1.0.30000844: + version "1.0.30001187" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001187.tgz#5706942631f83baa5a0218b7dfa6ced29f845438" + integrity sha512-w7/EP1JRZ9552CyrThUnay2RkZ1DXxKe/Q2swTC4+LElLh9RRYrL1Z+27LlakB8kzY0fSmHw9mc7XYDUKAKWMA== + +caseless@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= + +chai-as-promised@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/chai-as-promised/-/chai-as-promised-7.1.1.tgz#08645d825deb8696ee61725dbf590c012eb00ca0" + integrity sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA== + dependencies: + check-error "^1.0.2" + +chai@^4.3.0, chai@^4.3.1: + version "4.3.1" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.1.tgz#6fc6af447610709818e5c45116207d60b8a49cfd" + integrity sha512-JClPZFGRcSl7X8dYzlCJY7v+X1fBA+9Y339Y8EqhBVfp0QC1hTnaf7nMfR+XZ74clkBC64b0iEw2cWKHt3EVqA== + dependencies: + assertion-error "^1.1.0" + check-error "^1.0.2" + deep-eql "^3.0.1" + get-func-name "^2.0.0" + pathval "^1.1.1" + type-detect "^4.0.5" + +chalk@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg= + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +chalk@^2.0.0, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +chalk@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" + integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +check-error@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" + integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII= + +checkpoint-store@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/checkpoint-store/-/checkpoint-store-1.1.0.tgz#04e4cb516b91433893581e6d4601a78e9552ea06" + integrity sha1-BOTLUWuRQziTWB5tRgGnjpVS6gY= + dependencies: + functional-red-black-tree "^1.0.1" + +chokidar@3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.3.0.tgz#12c0714668c55800f659e262d4962a97faf554a6" + integrity sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A== + dependencies: + anymatch "~3.1.1" + braces "~3.0.2" + glob-parent "~5.1.0" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.2.0" + optionalDependencies: + fsevents "~2.1.1" + +chokidar@3.5.1, chokidar@^3.4.0: + version "3.5.1" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.1.tgz#ee9ce7bbebd2b79f49f304799d5468e31e14e68a" + integrity sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw== + dependencies: + anymatch "~3.1.1" + braces "~3.0.2" + glob-parent "~5.1.0" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.5.0" + optionalDependencies: + fsevents "~2.3.1" + +chownr@^1.1.1: + version "1.1.4" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" + integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== + +ci-info@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" + integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== + +cids@^0.7.1: + version "0.7.5" + resolved "https://registry.yarnpkg.com/cids/-/cids-0.7.5.tgz#60a08138a99bfb69b6be4ceb63bfef7a396b28b2" + integrity sha512-zT7mPeghoWAu+ppn8+BS1tQ5qGmbMfB4AregnQjA/qHY3GC1m1ptI9GkWNlgeu38r7CuRdXB47uY2XgAYt6QVA== + dependencies: + buffer "^5.5.0" + class-is "^1.1.0" + multibase "~0.6.0" + multicodec "^1.0.0" + multihashes "~0.4.15" + +cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" + integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q== + dependencies: + inherits "^2.0.1" + safe-buffer "^5.0.1" + +class-is@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/class-is/-/class-is-1.1.0.tgz#9d3c0fba0440d211d843cec3dedfa48055005825" + integrity sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw== + +class-utils@^0.3.5: + version "0.3.6" + resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" + integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg== + dependencies: + arr-union "^3.1.0" + define-property "^0.2.5" + isobject "^3.0.0" + static-extend "^0.1.1" + +cliui@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" + integrity sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0= + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + wrap-ansi "^2.0.0" + +cliui@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" + integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== + dependencies: + string-width "^3.1.0" + strip-ansi "^5.2.0" + wrap-ansi "^5.1.0" + +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" + +clone-response@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.2.tgz#d1dc973920314df67fbeb94223b4ee350239e96b" + integrity sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws= + dependencies: + mimic-response "^1.0.0" + +clone@2.1.2, clone@^2.0.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" + integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= + +collection-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" + integrity sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA= + dependencies: + map-visit "^1.0.0" + object-visit "^1.0.0" + +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +colors@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" + integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== + +combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + +command-exists@^1.2.8: + version "1.2.9" + resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69" + integrity sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w== + +command-line-args@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-4.0.7.tgz#f8d1916ecb90e9e121eda6428e41300bfb64cc46" + integrity sha512-aUdPvQRAyBvQd2n7jXcsMDz68ckBJELXNzBybCHOibUWEg0mWTnaYCSRU8h9R+aNRSvDihJtssSRCiDRpLaezA== + dependencies: + array-back "^2.0.0" + find-replace "^1.0.3" + typical "^2.6.1" + +commander@3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/commander/-/commander-3.0.2.tgz#6837c3fb677ad9933d1cfba42dd14d5117d6b39e" + integrity sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow== + +commander@^2.12.1: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + +component-emitter@^1.2.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" + integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + +concat-stream@^1.5.1: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" + integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== + dependencies: + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= + +content-disposition@0.5.3: + version "0.5.3" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd" + integrity sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g== + dependencies: + safe-buffer "5.1.2" + +content-hash@^2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/content-hash/-/content-hash-2.5.2.tgz#bbc2655e7c21f14fd3bfc7b7d4bfe6e454c9e211" + integrity sha512-FvIQKy0S1JaWV10sMsA7TRx8bpU+pqPkhbsfvOJAdjRXvYxEckAwQWGwtRjiaJfh+E0DvcWUGqcdjwMGFjsSdw== + dependencies: + cids "^0.7.1" + multicodec "^0.5.5" + multihashes "^0.4.15" + +content-type@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" + integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== + +convert-source-map@^1.5.1: + version "1.7.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442" + integrity sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA== + dependencies: + safe-buffer "~5.1.1" + +cookie-signature@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" + integrity sha1-4wOogrNCzD7oylE6eZmXNNqzriw= + +cookie@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" + integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== + +cookie@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1" + integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA== + +cookiejar@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.2.tgz#dd8a235530752f988f9a0844f3fc589e3111125c" + integrity sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA== + +copy-descriptor@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" + integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= + +copyfiles@^2.3.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/copyfiles/-/copyfiles-2.4.1.tgz#d2dcff60aaad1015f09d0b66e7f0f1c5cd3c5da5" + integrity sha512-fereAvAvxDrQDOXybk3Qu3dPbOoKoysFMWtkY3mv5BsL8//OSZVL5DCLYqgRfY5cWirgRzlC+WSrxp6Bo3eNZg== + dependencies: + glob "^7.0.5" + minimatch "^3.0.3" + mkdirp "^1.0.4" + noms "0.0.0" + through2 "^2.0.1" + untildify "^4.0.0" + yargs "^16.1.0" + +core-js-pure@^3.0.1: + version "3.8.3" + resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.8.3.tgz#10e9e3b2592ecaede4283e8f3ad7020811587c02" + integrity sha512-V5qQZVAr9K0xu7jXg1M7qTEwuxUgqr7dUOezGaNa7i+Xn9oXAU/d1fzqD9ObuwpVQOaorO5s70ckyi1woP9lVA== + +core-js@^2.4.0, core-js@^2.5.0: + version "2.6.12" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" + integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== + +core-util-is@1.0.2, core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= + +cors@^2.8.1: + version "2.8.5" + resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" + integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== + dependencies: + object-assign "^4" + vary "^1" + +create-ecdh@^4.0.0: + version "4.0.4" + resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e" + integrity sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A== + dependencies: + bn.js "^4.1.0" + elliptic "^6.5.3" + +create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" + integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== + dependencies: + cipher-base "^1.0.1" + inherits "^2.0.1" + md5.js "^1.3.4" + ripemd160 "^2.0.1" + sha.js "^2.4.0" + +create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" + integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== + dependencies: + cipher-base "^1.0.3" + create-hash "^1.1.0" + inherits "^2.0.1" + ripemd160 "^2.0.0" + safe-buffer "^5.0.1" + sha.js "^2.4.8" + +create-require@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" + integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== + +cross-fetch@^2.1.0, cross-fetch@^2.1.1: + version "2.2.3" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-2.2.3.tgz#e8a0b3c54598136e037f8650f8e823ccdfac198e" + integrity sha512-PrWWNH3yL2NYIb/7WF/5vFG3DCQiXDOVf8k3ijatbrtnwNuhMWLC7YF7uqf53tbTFDzHIUD8oITw4Bxt8ST3Nw== + dependencies: + node-fetch "2.1.2" + whatwg-fetch "2.0.4" + +cross-spawn@^6.0.5: + version "6.0.5" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" + integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== + dependencies: + nice-try "^1.0.4" + path-key "^2.0.1" + semver "^5.5.0" + shebang-command "^1.2.0" + which "^1.2.9" + +crypto-browserify@3.12.0: + version "3.12.0" + resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" + integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== + dependencies: + browserify-cipher "^1.0.0" + browserify-sign "^4.0.0" + create-ecdh "^4.0.0" + create-hash "^1.1.0" + create-hmac "^1.1.0" + diffie-hellman "^5.0.0" + inherits "^2.0.1" + pbkdf2 "^3.0.3" + public-encrypt "^4.0.0" + randombytes "^2.0.0" + randomfill "^1.0.3" + +crypto-js@^3.1.9-1: + version "3.3.0" + resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.3.0.tgz#846dd1cce2f68aacfa156c8578f926a609b7976b" + integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q== + +d@1, d@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.1.tgz#8698095372d58dbee346ffd0c7093f99f8f9eb5a" + integrity sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA== + dependencies: + es5-ext "^0.10.50" + type "^1.0.1" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + integrity sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA= + dependencies: + assert-plus "^1.0.0" + +debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + +debug@3.2.6: + version "3.2.6" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" + integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== + dependencies: + ms "^2.1.1" + +debug@4, debug@4.3.1, debug@^4.1.1, debug@^4.3.1: + version "4.3.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee" + integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ== + dependencies: + ms "2.1.2" + +debug@^3.1.0: + version "3.2.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" + integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== + dependencies: + ms "^2.1.1" + +decamelize@^1.1.1, decamelize@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= + +decamelize@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" + integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== + +decode-uri-component@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" + integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= + +decompress-response@^3.2.0, decompress-response@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" + integrity sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M= + dependencies: + mimic-response "^1.0.0" + +decompress-response@^4.2.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-4.2.1.tgz#414023cc7a302da25ce2ec82d0d5238ccafd8986" + integrity sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw== + dependencies: + mimic-response "^2.0.0" + +deep-eql@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df" + integrity sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw== + dependencies: + type-detect "^4.0.0" + +deep-equal@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a" + integrity sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g== + dependencies: + is-arguments "^1.0.4" + is-date-object "^1.0.1" + is-regex "^1.0.4" + object-is "^1.0.1" + object-keys "^1.1.1" + regexp.prototype.flags "^1.2.0" + +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + +defer-to-connect@^1.0.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.1.3.tgz#331ae050c08dcf789f8c83a7b81f0ed94f4ac591" + integrity sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ== + +deferred-leveldown@~1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/deferred-leveldown/-/deferred-leveldown-1.2.2.tgz#3acd2e0b75d1669924bc0a4b642851131173e1eb" + integrity sha512-uukrWD2bguRtXilKt6cAWKyoXrTSMo5m7crUdLfWQmu8kIm88w3QZoUL+6nhpfKVmhHANER6Re3sKoNoZ3IKMA== + dependencies: + abstract-leveldown "~2.6.0" + +deferred-leveldown@~4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/deferred-leveldown/-/deferred-leveldown-4.0.2.tgz#0b0570087827bf480a23494b398f04c128c19a20" + integrity sha512-5fMC8ek8alH16QiV0lTCis610D1Zt1+LA4MS4d63JgS32lrCjTFDUFz2ao09/j2I4Bqb5jL4FZYwu7Jz0XO1ww== + dependencies: + abstract-leveldown "~5.0.0" + inherits "^2.0.3" + +deferred-leveldown@~5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/deferred-leveldown/-/deferred-leveldown-5.3.0.tgz#27a997ad95408b61161aa69bd489b86c71b78058" + integrity sha512-a59VOT+oDy7vtAbLRCZwWgxu2BaCfd5Hk7wxJd48ei7I+nsg8Orlb9CLG0PMZienk9BSUKgeAqkO2+Lw+1+Ukw== + dependencies: + abstract-leveldown "~6.2.1" + inherits "^2.0.3" + +define-properties@^1.1.2, define-properties@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" + integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== + dependencies: + object-keys "^1.0.12" + +define-property@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" + integrity sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY= + dependencies: + is-descriptor "^0.1.0" + +define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" + integrity sha1-dp66rz9KY6rTr56NMEybvnm/sOY= + dependencies: + is-descriptor "^1.0.0" + +define-property@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" + integrity sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ== + dependencies: + is-descriptor "^1.0.2" + isobject "^3.0.1" + +defined@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" + integrity sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM= + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= + +delegates@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= + +depd@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" + integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= + +des.js@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.1.tgz#5382142e1bdc53f85d86d53e5f4aa7deb91e0843" + integrity sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA== + dependencies: + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + +destroy@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" + integrity sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA= + +detect-indent@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" + integrity sha1-920GQ1LN9Docts5hnE7jqUdd4gg= + dependencies: + repeating "^2.0.0" + +detect-libc@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" + integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= + +diff@3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== + +diff@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" + integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== + +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + +diffie-hellman@^5.0.0: + version "5.0.3" + resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" + integrity sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg== + dependencies: + bn.js "^4.1.0" + miller-rabin "^4.0.0" + randombytes "^2.0.0" + +dom-walk@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.2.tgz#0c548bef048f4d1f2a97249002236060daa3fd84" + integrity sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w== + +dotignore@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/dotignore/-/dotignore-0.1.2.tgz#f942f2200d28c3a76fbdd6f0ee9f3257c8a2e905" + integrity sha512-UGGGWfSauusaVJC+8fgV+NVvBXkCTmVv7sk6nojDZZvuOUNGUy0Zk4UpHQD6EDjS0jpBwcACvH4eofvyzBcRDw== + dependencies: + minimatch "^3.0.4" + +duplexer3@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" + integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI= + +ecc-jsbn@~0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" + integrity sha1-OoOpBOVDUyh4dMVkt1SThoSamMk= + dependencies: + jsbn "~0.1.0" + safer-buffer "^2.1.0" + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= + +electron-to-chromium@^1.3.47: + version "1.3.667" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.667.tgz#18ca4f243ec163c3e354e506ba22ef46d31d925e" + integrity sha512-Ot1pPtAVb5nd7jeVF651zmfLFilRVFomlDzwXmdlWe5jyzOGa6mVsQ06XnAurT7wWfg5VEIY+LopbAdD/bpo5w== + +elliptic@6.5.4, elliptic@^6.4.0, elliptic@^6.5.2, elliptic@^6.5.3: + version "6.5.4" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" + integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== + dependencies: + bn.js "^4.11.9" + brorand "^1.1.0" + hash.js "^1.0.0" + hmac-drbg "^1.0.1" + inherits "^2.0.4" + minimalistic-assert "^1.0.1" + minimalistic-crypto-utils "^1.0.1" + +emoji-regex@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" + integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +encodeurl@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" + integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= + +encoding-down@5.0.4, encoding-down@~5.0.0: + version "5.0.4" + resolved "https://registry.yarnpkg.com/encoding-down/-/encoding-down-5.0.4.tgz#1e477da8e9e9d0f7c8293d320044f8b2cd8e9614" + integrity sha512-8CIZLDcSKxgzT+zX8ZVfgNbu8Md2wq/iqa1Y7zyVR18QBEAc0Nmzuvj/N5ykSKpfGzjM8qxbaFntLPwnVoUhZw== + dependencies: + abstract-leveldown "^5.0.0" + inherits "^2.0.3" + level-codec "^9.0.0" + level-errors "^2.0.0" + xtend "^4.0.1" + +encoding-down@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/encoding-down/-/encoding-down-6.3.0.tgz#b1c4eb0e1728c146ecaef8e32963c549e76d082b" + integrity sha512-QKrV0iKR6MZVJV08QY0wp1e7vF6QbhnbQhb07bwpEyuz4uZiZgPlEGdkCROuFkUwdxlFaiPIhjyarH1ee/3vhw== + dependencies: + abstract-leveldown "^6.2.1" + inherits "^2.0.3" + level-codec "^9.0.0" + level-errors "^2.0.0" + +encoding@^0.1.11: + version "0.1.13" + resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9" + integrity sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A== + dependencies: + iconv-lite "^0.6.2" + +end-of-stream@^1.1.0, end-of-stream@^1.4.1: + version "1.4.4" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" + integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== + dependencies: + once "^1.4.0" + +enquirer@^2.3.0: + version "2.3.6" + resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" + integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== + dependencies: + ansi-colors "^4.1.1" + +env-paths@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.0.tgz#cdca557dc009152917d6166e2febe1f039685e43" + integrity sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA== + +errno@~0.1.1: + version "0.1.8" + resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.8.tgz#8bb3e9c7d463be4976ff888f76b4809ebc2e811f" + integrity sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A== + dependencies: + prr "~1.0.1" + +error-ex@^1.2.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== + dependencies: + is-arrayish "^0.2.1" + +es-abstract@^1.18.0-next.1: + version "1.18.0-next.2" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.0-next.2.tgz#088101a55f0541f595e7e057199e27ddc8f3a5c2" + integrity sha512-Ih4ZMFHEtZupnUh6497zEL4y2+w8+1ljnCyaTa+adcoafI1GOvMwFlDjBLfWR7y9VLfrjRJe9ocuHY1PSR9jjw== + dependencies: + call-bind "^1.0.2" + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + get-intrinsic "^1.0.2" + has "^1.0.3" + has-symbols "^1.0.1" + is-callable "^1.2.2" + is-negative-zero "^2.0.1" + is-regex "^1.1.1" + object-inspect "^1.9.0" + object-keys "^1.1.1" + object.assign "^4.1.2" + string.prototype.trimend "^1.0.3" + string.prototype.trimstart "^1.0.3" + +es-to-primitive@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" + integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== + dependencies: + is-callable "^1.1.4" + is-date-object "^1.0.1" + is-symbol "^1.0.2" + +es5-ext@^0.10.35, es5-ext@^0.10.50: + version "0.10.53" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.53.tgz#93c5a3acfdbef275220ad72644ad02ee18368de1" + integrity sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q== + dependencies: + es6-iterator "~2.0.3" + es6-symbol "~3.1.3" + next-tick "~1.0.0" + +es6-iterator@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" + integrity sha1-p96IkUGgWpSwhUQDstCg+/qY87c= + dependencies: + d "1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" + +es6-symbol@^3.1.1, es6-symbol@~3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.3.tgz#bad5d3c1bcdac28269f4cb331e431c78ac705d18" + integrity sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA== + dependencies: + d "^1.0.1" + ext "^1.1.2" + +escalade@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" + integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= + +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + +escape-string-regexp@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +eslint-plugin-prettier@^2.2.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.7.0.tgz#b4312dcf2c1d965379d7f9d5b5f8aaadc6a45904" + integrity sha512-CStQYJgALoQBw3FsBzH0VOVDRnJ/ZimUlpLm226U8qgqYJfPOY/CPK6wyRInMxh73HSKg5wyRwdS4BVYYHwokA== + dependencies: + fast-diff "^1.1.1" + jest-docblock "^21.0.0" + +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + +esutils@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== + +etag@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" + integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= + +eth-block-tracker@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/eth-block-tracker/-/eth-block-tracker-3.0.1.tgz#95cd5e763c7293e0b1b2790a2a39ac2ac188a5e1" + integrity sha512-WUVxWLuhMmsfenfZvFO5sbl1qFY2IqUlw/FPVmjjdElpqLsZtSG+wPe9Dz7W/sB6e80HgFKknOmKk2eNlznHug== + dependencies: + eth-query "^2.1.0" + ethereumjs-tx "^1.3.3" + ethereumjs-util "^5.1.3" + ethjs-util "^0.1.3" + json-rpc-engine "^3.6.0" + pify "^2.3.0" + tape "^4.6.3" + +eth-ens-namehash@2.0.8, eth-ens-namehash@^2.0.8: + version "2.0.8" + resolved "https://registry.yarnpkg.com/eth-ens-namehash/-/eth-ens-namehash-2.0.8.tgz#229ac46eca86d52e0c991e7cb2aef83ff0f68bcf" + integrity sha1-IprEbsqG1S4MmR58sq74P/D2i88= + dependencies: + idna-uts46-hx "^2.3.1" + js-sha3 "^0.5.7" + +eth-json-rpc-infura@^3.1.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/eth-json-rpc-infura/-/eth-json-rpc-infura-3.2.1.tgz#26702a821067862b72d979c016fd611502c6057f" + integrity sha512-W7zR4DZvyTn23Bxc0EWsq4XGDdD63+XPUCEhV2zQvQGavDVC4ZpFDK4k99qN7bd7/fjj37+rxmuBOBeIqCA5Mw== + dependencies: + cross-fetch "^2.1.1" + eth-json-rpc-middleware "^1.5.0" + json-rpc-engine "^3.4.0" + json-rpc-error "^2.0.0" + +eth-json-rpc-middleware@^1.5.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/eth-json-rpc-middleware/-/eth-json-rpc-middleware-1.6.0.tgz#5c9d4c28f745ccb01630f0300ba945f4bef9593f" + integrity sha512-tDVCTlrUvdqHKqivYMjtFZsdD7TtpNLBCfKAcOpaVs7orBMS/A8HWro6dIzNtTZIR05FAbJ3bioFOnZpuCew9Q== + dependencies: + async "^2.5.0" + eth-query "^2.1.2" + eth-tx-summary "^3.1.2" + ethereumjs-block "^1.6.0" + ethereumjs-tx "^1.3.3" + ethereumjs-util "^5.1.2" + ethereumjs-vm "^2.1.0" + fetch-ponyfill "^4.0.0" + json-rpc-engine "^3.6.0" + json-rpc-error "^2.0.0" + json-stable-stringify "^1.0.1" + promise-to-callback "^1.0.0" + tape "^4.6.3" + +eth-lib@0.2.8: + version "0.2.8" + resolved "https://registry.yarnpkg.com/eth-lib/-/eth-lib-0.2.8.tgz#b194058bef4b220ad12ea497431d6cb6aa0623c8" + integrity sha512-ArJ7x1WcWOlSpzdoTBX8vkwlkSQ85CjjifSZtV4co64vWxSV8geWfPI9x4SVYu3DSxnX4yWFVTtGL+j9DUFLNw== + dependencies: + bn.js "^4.11.6" + elliptic "^6.4.0" + xhr-request-promise "^0.1.2" + +eth-lib@^0.1.26: + version "0.1.29" + resolved "https://registry.yarnpkg.com/eth-lib/-/eth-lib-0.1.29.tgz#0c11f5060d42da9f931eab6199084734f4dbd1d9" + integrity sha512-bfttrr3/7gG4E02HoWTDUcDDslN003OlOoBxk9virpAZQ1ja/jDgwkWB8QfJF7ojuEowrqy+lzp9VcJG7/k5bQ== + dependencies: + bn.js "^4.11.6" + elliptic "^6.4.0" + nano-json-stream-parser "^0.1.2" + servify "^0.1.12" + ws "^3.0.0" + xhr-request-promise "^0.1.2" + +eth-query@^2.0.2, eth-query@^2.1.0, eth-query@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/eth-query/-/eth-query-2.1.2.tgz#d6741d9000106b51510c72db92d6365456a6da5e" + integrity sha1-1nQdkAAQa1FRDHLbktY2VFam2l4= + dependencies: + json-rpc-random-id "^1.0.0" + xtend "^4.0.1" + +eth-sig-util@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eth-sig-util/-/eth-sig-util-3.0.0.tgz#75133b3d7c20a5731af0690c385e184ab942b97e" + integrity sha512-4eFkMOhpGbTxBQ3AMzVf0haUX2uTur7DpWiHzWyTURa28BVJJtOkcb9Ok5TV0YvEPG61DODPW7ZUATbJTslioQ== + dependencies: + buffer "^5.2.1" + elliptic "^6.4.0" + ethereumjs-abi "0.6.5" + ethereumjs-util "^5.1.1" + tweetnacl "^1.0.0" + tweetnacl-util "^0.15.0" + +eth-sig-util@^1.4.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/eth-sig-util/-/eth-sig-util-1.4.2.tgz#8d958202c7edbaae839707fba6f09ff327606210" + integrity sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA= + dependencies: + ethereumjs-abi "git+https://github.com/ethereumjs/ethereumjs-abi.git" + ethereumjs-util "^5.1.1" + +eth-sig-util@^2.5.2: + version "2.5.4" + resolved "https://registry.yarnpkg.com/eth-sig-util/-/eth-sig-util-2.5.4.tgz#577b01fe491b6bf59b0464be09633e20c1677bc5" + integrity sha512-aCMBwp8q/4wrW4QLsF/HYBOSA7TpLKmkVwP3pYQNkEEseW2Rr8Z5Uxc9/h6HX+OG3tuHo+2bINVSihIeBfym6A== + dependencies: + ethereumjs-abi "0.6.8" + ethereumjs-util "^5.1.1" + tweetnacl "^1.0.3" + tweetnacl-util "^0.15.0" + +eth-tx-summary@^3.1.2: + version "3.2.4" + resolved "https://registry.yarnpkg.com/eth-tx-summary/-/eth-tx-summary-3.2.4.tgz#e10eb95eb57cdfe549bf29f97f1e4f1db679035c" + integrity sha512-NtlDnaVZah146Rm8HMRUNMgIwG/ED4jiqk0TME9zFheMl1jOp6jL1m0NKGjJwehXQ6ZKCPr16MTr+qspKpEXNg== + dependencies: + async "^2.1.2" + clone "^2.0.0" + concat-stream "^1.5.1" + end-of-stream "^1.1.0" + eth-query "^2.0.2" + ethereumjs-block "^1.4.1" + ethereumjs-tx "^1.1.1" + ethereumjs-util "^5.0.1" + ethereumjs-vm "^2.6.0" + through2 "^2.0.3" + +ethashjs@~0.0.7: + version "0.0.8" + resolved "https://registry.yarnpkg.com/ethashjs/-/ethashjs-0.0.8.tgz#227442f1bdee409a548fb04136e24c874f3aa6f9" + integrity sha512-/MSbf/r2/Ld8o0l15AymjOTlPqpN8Cr4ByUEA9GtR4x0yAh3TdtDzEg29zMjXCNPI7u6E5fOQdj/Cf9Tc7oVNw== + dependencies: + async "^2.1.2" + buffer-xor "^2.0.1" + ethereumjs-util "^7.0.2" + miller-rabin "^4.0.0" + +ethereum-bloom-filters@^1.0.6: + version "1.0.9" + resolved "https://registry.yarnpkg.com/ethereum-bloom-filters/-/ethereum-bloom-filters-1.0.9.tgz#4a59dead803af0c9e33834170bd7695df67061ec" + integrity sha512-GiK/RQkAkcVaEdxKVkPcG07PQ5vD7v2MFSHgZmBJSfMzNRHimntdBithsHAT89tAXnIpzVDWt8iaCD1DvkaxGg== + dependencies: + js-sha3 "^0.8.0" + +ethereum-common@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/ethereum-common/-/ethereum-common-0.2.0.tgz#13bf966131cce1eeade62a1b434249bb4cb120ca" + integrity sha512-XOnAR/3rntJgbCdGhqdaLIxDLWKLmsZOGhHdBKadEr6gEnJLH52k93Ou+TUdFaPN3hJc3isBZBal3U/XZ15abA== + +ethereum-common@^0.0.18: + version "0.0.18" + resolved "https://registry.yarnpkg.com/ethereum-common/-/ethereum-common-0.0.18.tgz#2fdc3576f232903358976eb39da783213ff9523f" + integrity sha1-L9w1dvIykDNYl26znaeDIT/5Uj8= + +ethereum-cryptography@^0.1.2, ethereum-cryptography@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz#8d6143cfc3d74bf79bbd8edecdf29e4ae20dd191" + integrity sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ== + dependencies: + "@types/pbkdf2" "^3.0.0" + "@types/secp256k1" "^4.0.1" + blakejs "^1.1.0" + browserify-aes "^1.2.0" + bs58check "^2.1.2" + create-hash "^1.2.0" + create-hmac "^1.1.7" + hash.js "^1.1.7" + keccak "^3.0.0" + pbkdf2 "^3.0.17" + randombytes "^2.1.0" + safe-buffer "^5.1.2" + scrypt-js "^3.0.0" + secp256k1 "^4.0.1" + setimmediate "^1.0.5" + +ethereum-waffle@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/ethereum-waffle/-/ethereum-waffle-3.3.0.tgz#166a0cc1d3b2925f117b20ef0951b3fe72e38e79" + integrity sha512-4xm3RWAPCu5LlaVxYEg0tG3L7g5ovBw1GY/UebrzZ+OTx22vcPjI+bvelFlGBpkdnO5yOIFXjH2eK59tNAe9IA== + dependencies: + "@ethereum-waffle/chai" "^3.3.0" + "@ethereum-waffle/compiler" "^3.3.0" + "@ethereum-waffle/mock-contract" "^3.2.2" + "@ethereum-waffle/provider" "^3.3.0" + ethers "^5.0.1" + +ethereumjs-abi@0.6.5: + version "0.6.5" + resolved "https://registry.yarnpkg.com/ethereumjs-abi/-/ethereumjs-abi-0.6.5.tgz#5a637ef16ab43473fa72a29ad90871405b3f5241" + integrity sha1-WmN+8Wq0NHP6cqKa2QhxQFs/UkE= + dependencies: + bn.js "^4.10.0" + ethereumjs-util "^4.3.0" + +ethereumjs-abi@0.6.8, ethereumjs-abi@^0.6.8: + version "0.6.8" + resolved "https://registry.yarnpkg.com/ethereumjs-abi/-/ethereumjs-abi-0.6.8.tgz#71bc152db099f70e62f108b7cdfca1b362c6fcae" + integrity sha512-Tx0r/iXI6r+lRsdvkFDlut0N08jWMnKRZ6Gkq+Nmw75lZe4e6o3EkSnkaBP5NF6+m5PTGAr9JP43N3LyeoglsA== + dependencies: + bn.js "^4.11.8" + ethereumjs-util "^6.0.0" + +"ethereumjs-abi@git+https://github.com/ethereumjs/ethereumjs-abi.git": + version "0.6.8" + resolved "git+https://github.com/ethereumjs/ethereumjs-abi.git#1a27c59c15ab1e95ee8e5c4ed6ad814c49cc439e" + dependencies: + bn.js "^4.11.8" + ethereumjs-util "^6.0.0" + +ethereumjs-account@3.0.0, ethereumjs-account@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ethereumjs-account/-/ethereumjs-account-3.0.0.tgz#728f060c8e0c6e87f1e987f751d3da25422570a9" + integrity sha512-WP6BdscjiiPkQfF9PVfMcwx/rDvfZTjFKY0Uwc09zSQr9JfIVH87dYIJu0gNhBhpmovV4yq295fdllS925fnBA== + dependencies: + ethereumjs-util "^6.0.0" + rlp "^2.2.1" + safe-buffer "^5.1.1" + +ethereumjs-account@^2.0.3: + version "2.0.5" + resolved "https://registry.yarnpkg.com/ethereumjs-account/-/ethereumjs-account-2.0.5.tgz#eeafc62de544cb07b0ee44b10f572c9c49e00a84" + integrity sha512-bgDojnXGjhMwo6eXQC0bY6UK2liSFUSMwwylOmQvZbSl/D7NXQ3+vrGO46ZeOgjGfxXmgIeVNDIiHw7fNZM4VA== + dependencies: + ethereumjs-util "^5.0.0" + rlp "^2.0.0" + safe-buffer "^5.1.1" + +ethereumjs-block@2.2.2, ethereumjs-block@^2.2.2, ethereumjs-block@~2.2.0, ethereumjs-block@~2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/ethereumjs-block/-/ethereumjs-block-2.2.2.tgz#c7654be7e22df489fda206139ecd63e2e9c04965" + integrity sha512-2p49ifhek3h2zeg/+da6XpdFR3GlqY3BIEiqxGF8j9aSRIgkb7M1Ky+yULBKJOu8PAZxfhsYA+HxUk2aCQp3vg== + dependencies: + async "^2.0.1" + ethereumjs-common "^1.5.0" + ethereumjs-tx "^2.1.1" + ethereumjs-util "^5.0.0" + merkle-patricia-tree "^2.1.2" + +ethereumjs-block@^1.2.2, ethereumjs-block@^1.4.1, ethereumjs-block@^1.6.0: + version "1.7.1" + resolved "https://registry.yarnpkg.com/ethereumjs-block/-/ethereumjs-block-1.7.1.tgz#78b88e6cc56de29a6b4884ee75379b6860333c3f" + integrity sha512-B+sSdtqm78fmKkBq78/QLKJbu/4Ts4P2KFISdgcuZUPDm9x+N7qgBPIIFUGbaakQh8bzuquiRVbdmvPKqbILRg== + dependencies: + async "^2.0.1" + ethereum-common "0.2.0" + ethereumjs-tx "^1.2.2" + ethereumjs-util "^5.0.0" + merkle-patricia-tree "^2.1.2" + +ethereumjs-blockchain@^4.0.3: + version "4.0.4" + resolved "https://registry.yarnpkg.com/ethereumjs-blockchain/-/ethereumjs-blockchain-4.0.4.tgz#30f2228dc35f6dcf94423692a6902604ae34960f" + integrity sha512-zCxaRMUOzzjvX78DTGiKjA+4h2/sF0OYL1QuPux0DHpyq8XiNoF5GYHtb++GUxVlMsMfZV7AVyzbtgcRdIcEPQ== + dependencies: + async "^2.6.1" + ethashjs "~0.0.7" + ethereumjs-block "~2.2.2" + ethereumjs-common "^1.5.0" + ethereumjs-util "^6.1.0" + flow-stoplight "^1.0.0" + level-mem "^3.0.1" + lru-cache "^5.1.1" + rlp "^2.2.2" + semaphore "^1.1.0" + +ethereumjs-common@1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/ethereumjs-common/-/ethereumjs-common-1.5.0.tgz#d3e82fc7c47c0cef95047f431a99485abc9bb1cd" + integrity sha512-SZOjgK1356hIY7MRj3/ma5qtfr/4B5BL+G4rP/XSMYr2z1H5el4RX5GReYCKmQmYI/nSBmRnwrZ17IfHuG0viQ== + +ethereumjs-common@^1.1.0, ethereumjs-common@^1.3.2, ethereumjs-common@^1.5.0: + version "1.5.2" + resolved "https://registry.yarnpkg.com/ethereumjs-common/-/ethereumjs-common-1.5.2.tgz#2065dbe9214e850f2e955a80e650cb6999066979" + integrity sha512-hTfZjwGX52GS2jcVO6E2sx4YuFnf0Fhp5ylo4pEPhEffNln7vS59Hr5sLnp3/QCazFLluuBZ+FZ6J5HTp0EqCA== + +ethereumjs-tx@2.1.2, ethereumjs-tx@^2.1.1, ethereumjs-tx@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ethereumjs-tx/-/ethereumjs-tx-2.1.2.tgz#5dfe7688bf177b45c9a23f86cf9104d47ea35fed" + integrity sha512-zZEK1onCeiORb0wyCXUvg94Ve5It/K6GD1K+26KfFKodiBiS6d9lfCXlUKGBBdQ+bv7Day+JK0tj1K+BeNFRAw== + dependencies: + ethereumjs-common "^1.5.0" + ethereumjs-util "^6.0.0" + +ethereumjs-tx@^1.1.1, ethereumjs-tx@^1.2.0, ethereumjs-tx@^1.2.2, ethereumjs-tx@^1.3.3: + version "1.3.7" + resolved "https://registry.yarnpkg.com/ethereumjs-tx/-/ethereumjs-tx-1.3.7.tgz#88323a2d875b10549b8347e09f4862b546f3d89a" + integrity sha512-wvLMxzt1RPhAQ9Yi3/HKZTn0FZYpnsmQdbKYfUUpi4j1SEIcbkd9tndVjcPrufY3V7j2IebOpC00Zp2P/Ay2kA== + dependencies: + ethereum-common "^0.0.18" + ethereumjs-util "^5.0.0" + +ethereumjs-util@6.2.1, ethereumjs-util@^6.0.0, ethereumjs-util@^6.1.0, ethereumjs-util@^6.2.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz#fcb4e4dd5ceacb9d2305426ab1a5cd93e3163b69" + integrity sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw== + dependencies: + "@types/bn.js" "^4.11.3" + bn.js "^4.11.0" + create-hash "^1.1.2" + elliptic "^6.5.2" + ethereum-cryptography "^0.1.3" + ethjs-util "0.1.6" + rlp "^2.2.3" + +ethereumjs-util@^4.3.0: + version "4.5.1" + resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-4.5.1.tgz#f4bf9b3b515a484e3cc8781d61d9d980f7c83bd0" + integrity sha512-WrckOZ7uBnei4+AKimpuF1B3Fv25OmoRgmYCpGsP7u8PFxXAmAgiJSYT2kRWnt6fVIlKaQlZvuwXp7PIrmn3/w== + dependencies: + bn.js "^4.8.0" + create-hash "^1.1.2" + elliptic "^6.5.2" + ethereum-cryptography "^0.1.3" + rlp "^2.0.0" + +ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1, ethereumjs-util@^5.1.2, ethereumjs-util@^5.1.3, ethereumjs-util@^5.1.5, ethereumjs-util@^5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-5.2.1.tgz#a833f0e5fca7e5b361384dc76301a721f537bf65" + integrity sha512-v3kT+7zdyCm1HIqWlLNrHGqHGLpGYIhjeHxQjnDXjLT2FyGJDsd3LWMYUo7pAFRrk86CR3nUJfhC81CCoJNNGQ== + dependencies: + bn.js "^4.11.0" + create-hash "^1.1.2" + elliptic "^6.5.2" + ethereum-cryptography "^0.1.3" + ethjs-util "^0.1.3" + rlp "^2.0.0" + safe-buffer "^5.1.1" + +ethereumjs-util@^7.0.2, ethereumjs-util@^7.0.8: + version "7.0.8" + resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.0.8.tgz#5258762b7b17e3d828e41834948363ff0a703ffd" + integrity sha512-JJt7tDpCAmDPw/sGoFYeq0guOVqT3pTE9xlEbBmc/nlCij3JRCoS2c96SQ6kXVHOT3xWUNLDm5QCJLQaUnVAtQ== + dependencies: + "@types/bn.js" "^4.11.3" + bn.js "^5.1.2" + create-hash "^1.1.2" + ethereum-cryptography "^0.1.3" + ethjs-util "0.1.6" + rlp "^2.2.4" + +ethereumjs-vm@4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/ethereumjs-vm/-/ethereumjs-vm-4.2.0.tgz#e885e861424e373dbc556278f7259ff3fca5edab" + integrity sha512-X6qqZbsY33p5FTuZqCnQ4+lo957iUJMM6Mpa6bL4UW0dxM6WmDSHuI4j/zOp1E2TDKImBGCJA9QPfc08PaNubA== + dependencies: + async "^2.1.2" + async-eventemitter "^0.2.2" + core-js-pure "^3.0.1" + ethereumjs-account "^3.0.0" + ethereumjs-block "^2.2.2" + ethereumjs-blockchain "^4.0.3" + ethereumjs-common "^1.5.0" + ethereumjs-tx "^2.1.2" + ethereumjs-util "^6.2.0" + fake-merkle-patricia-tree "^1.0.1" + functional-red-black-tree "^1.0.1" + merkle-patricia-tree "^2.3.2" + rustbn.js "~0.2.0" + safe-buffer "^5.1.1" + util.promisify "^1.0.0" + +ethereumjs-vm@^2.1.0, ethereumjs-vm@^2.3.4, ethereumjs-vm@^2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/ethereumjs-vm/-/ethereumjs-vm-2.6.0.tgz#76243ed8de031b408793ac33907fb3407fe400c6" + integrity sha512-r/XIUik/ynGbxS3y+mvGnbOKnuLo40V5Mj1J25+HEO63aWYREIqvWeRO/hnROlMBE5WoniQmPmhiaN0ctiHaXw== + dependencies: + async "^2.1.2" + async-eventemitter "^0.2.2" + ethereumjs-account "^2.0.3" + ethereumjs-block "~2.2.0" + ethereumjs-common "^1.1.0" + ethereumjs-util "^6.0.0" + fake-merkle-patricia-tree "^1.0.1" + functional-red-black-tree "^1.0.1" + merkle-patricia-tree "^2.3.2" + rustbn.js "~0.2.0" + safe-buffer "^5.1.1" + +ethereumjs-wallet@0.6.5: + version "0.6.5" + resolved "https://registry.yarnpkg.com/ethereumjs-wallet/-/ethereumjs-wallet-0.6.5.tgz#685e9091645cee230ad125c007658833991ed474" + integrity sha512-MDwjwB9VQVnpp/Dc1XzA6J1a3wgHQ4hSvA1uWNatdpOrtCbPVuQSKSyRnjLvS0a+KKMw2pvQ9Ybqpb3+eW8oNA== + dependencies: + aes-js "^3.1.1" + bs58check "^2.1.2" + ethereum-cryptography "^0.1.3" + ethereumjs-util "^6.0.0" + randombytes "^2.0.6" + safe-buffer "^5.1.2" + scryptsy "^1.2.1" + utf8 "^3.0.0" + uuid "^3.3.2" + +ethers@^5.0.0, ethers@^5.0.1, ethers@^5.0.2, ethers@^5.0.25, ethers@^5.0.31: + version "5.0.31" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.0.31.tgz#60e3b1425864fe5d2babc147ede01be8382a7d2a" + integrity sha512-zpq0YbNFLFn+t+ibS8UkVWFeK5w6rVMSvbSHrHAQslfazovLnQ/mc2gdN5+6P45/k8fPgHrfHrYvJ4XvyK/S1A== + dependencies: + "@ethersproject/abi" "5.0.12" + "@ethersproject/abstract-provider" "5.0.9" + "@ethersproject/abstract-signer" "5.0.13" + "@ethersproject/address" "5.0.10" + "@ethersproject/base64" "5.0.8" + "@ethersproject/basex" "5.0.8" + "@ethersproject/bignumber" "5.0.14" + "@ethersproject/bytes" "5.0.10" + "@ethersproject/constants" "5.0.9" + "@ethersproject/contracts" "5.0.11" + "@ethersproject/hash" "5.0.11" + "@ethersproject/hdnode" "5.0.9" + "@ethersproject/json-wallets" "5.0.11" + "@ethersproject/keccak256" "5.0.8" + "@ethersproject/logger" "5.0.9" + "@ethersproject/networks" "5.0.8" + "@ethersproject/pbkdf2" "5.0.8" + "@ethersproject/properties" "5.0.8" + "@ethersproject/providers" "5.0.23" + "@ethersproject/random" "5.0.8" + "@ethersproject/rlp" "5.0.8" + "@ethersproject/sha2" "5.0.8" + "@ethersproject/signing-key" "5.0.10" + "@ethersproject/solidity" "5.0.9" + "@ethersproject/strings" "5.0.9" + "@ethersproject/transactions" "5.0.10" + "@ethersproject/units" "5.0.10" + "@ethersproject/wallet" "5.0.11" + "@ethersproject/web" "5.0.13" + "@ethersproject/wordlists" "5.0.9" + +ethjs-unit@0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/ethjs-unit/-/ethjs-unit-0.1.6.tgz#c665921e476e87bce2a9d588a6fe0405b2c41699" + integrity sha1-xmWSHkduh7ziqdWIpv4EBbLEFpk= + dependencies: + bn.js "4.11.6" + number-to-bn "1.7.0" + +ethjs-util@0.1.6, ethjs-util@^0.1.3: + version "0.1.6" + resolved "https://registry.yarnpkg.com/ethjs-util/-/ethjs-util-0.1.6.tgz#f308b62f185f9fe6237132fb2a9818866a5cd536" + integrity sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w== + dependencies: + is-hex-prefixed "1.0.0" + strip-hex-prefix "1.0.0" + +event-target-shim@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" + integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== + +eventemitter3@4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.4.tgz#b5463ace635a083d018bdc7c917b4c5f10a85384" + integrity sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ== + +events@^3.0.0, events@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.2.0.tgz#93b87c18f8efcd4202a461aec4dfc0556b639379" + integrity sha512-/46HWwbfCX2xTawVfkKLGxMifJYQBWMwY1mjywRtb4c9x8l5NP3KoJtnIOiL1hfdRkIuYhETxQlo62IF8tcnlg== + +evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" + integrity sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA== + dependencies: + md5.js "^1.3.4" + safe-buffer "^5.1.1" + +expand-brackets@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" + integrity sha1-t3c14xXOMPa27/D4OwQVGiJEliI= + dependencies: + debug "^2.3.3" + define-property "^0.2.5" + extend-shallow "^2.0.1" + posix-character-classes "^0.1.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +expand-template@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/expand-template/-/expand-template-2.0.3.tgz#6e14b3fcee0f3a6340ecb57d2e8918692052a47c" + integrity sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg== + +express@^4.14.0: + version "4.17.1" + resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134" + integrity sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g== + dependencies: + accepts "~1.3.7" + array-flatten "1.1.1" + body-parser "1.19.0" + content-disposition "0.5.3" + content-type "~1.0.4" + cookie "0.4.0" + cookie-signature "1.0.6" + debug "2.6.9" + depd "~1.1.2" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + finalhandler "~1.1.2" + fresh "0.5.2" + merge-descriptors "1.0.1" + methods "~1.1.2" + on-finished "~2.3.0" + parseurl "~1.3.3" + path-to-regexp "0.1.7" + proxy-addr "~2.0.5" + qs "6.7.0" + range-parser "~1.2.1" + safe-buffer "5.1.2" + send "0.17.1" + serve-static "1.14.1" + setprototypeof "1.1.1" + statuses "~1.5.0" + type-is "~1.6.18" + utils-merge "1.0.1" + vary "~1.1.2" + +ext@^1.1.2: + version "1.4.0" + resolved "https://registry.yarnpkg.com/ext/-/ext-1.4.0.tgz#89ae7a07158f79d35517882904324077e4379244" + integrity sha512-Key5NIsUxdqKg3vIsdw9dSuXpPCQ297y6wBjL30edxwPgt2E44WcWBZey/ZvUc6sERLTxKdyCu4gZFmUbk1Q7A== + dependencies: + type "^2.0.0" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + integrity sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8= + dependencies: + is-extendable "^0.1.0" + +extend-shallow@^3.0.0, extend-shallow@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" + integrity sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg= + dependencies: + assign-symbols "^1.0.0" + is-extendable "^1.0.1" + +extend@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + +extglob@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" + integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== + dependencies: + array-unique "^0.3.2" + define-property "^1.0.0" + expand-brackets "^2.1.4" + extend-shallow "^2.0.1" + fragment-cache "^0.2.1" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + integrity sha1-lpGEQOMEGnpBT4xS48V06zw+HgU= + +extsprintf@^1.2.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" + integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= + +fake-merkle-patricia-tree@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/fake-merkle-patricia-tree/-/fake-merkle-patricia-tree-1.0.1.tgz#4b8c3acfb520afadf9860b1f14cd8ce3402cddd3" + integrity sha1-S4w6z7Ugr635hgsfFM2M40As3dM= + dependencies: + checkpoint-store "^1.1.0" + +fast-deep-equal@^3.1.1: + version "3.1.3" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== + +fast-diff@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" + integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== + +fast-json-stable-stringify@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== + +fast-redact@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/fast-redact/-/fast-redact-3.0.0.tgz#ac2f9e36c9f4976f5db9fb18c6ffbaf308cf316d" + integrity sha512-a/S/Hp6aoIjx7EmugtzLqXmcNsyFszqbt6qQ99BdG61QjBZF6shNis0BYR6TsZOQ1twYc0FN2Xdhwwbv6+KD0w== + +fast-safe-stringify@^2.0.7: + version "2.0.7" + resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz#124aa885899261f68aedb42a7c080de9da608743" + integrity sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA== + +fetch-ponyfill@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/fetch-ponyfill/-/fetch-ponyfill-4.1.0.tgz#ae3ce5f732c645eab87e4ae8793414709b239893" + integrity sha1-rjzl9zLGReq4fkroeTQUcJsjmJM= + dependencies: + node-fetch "~1.7.1" + +file-uri-to-path@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" + integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== + +fill-range@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" + integrity sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc= + dependencies: + extend-shallow "^2.0.1" + is-number "^3.0.0" + repeat-string "^1.6.1" + to-regex-range "^2.1.0" + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +finalhandler@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" + integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA== + dependencies: + debug "2.6.9" + encodeurl "~1.0.2" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.3" + statuses "~1.5.0" + unpipe "~1.0.0" + +find-replace@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/find-replace/-/find-replace-1.0.3.tgz#b88e7364d2d9c959559f388c66670d6130441fa0" + integrity sha1-uI5zZNLZyVlVnziMZmcNYTBEH6A= + dependencies: + array-back "^1.0.4" + test-value "^2.1.0" + +find-up@3.0.0, find-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" + integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== + dependencies: + locate-path "^3.0.0" + +find-up@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + +find-up@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + integrity sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8= + dependencies: + path-exists "^2.0.0" + pinkie-promise "^2.0.0" + +find-up@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" + integrity sha1-RdG35QbHF93UgndaK3eSCjwMV6c= + dependencies: + locate-path "^2.0.0" + +find-yarn-workspace-root@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-1.2.1.tgz#40eb8e6e7c2502ddfaa2577c176f221422f860db" + integrity sha512-dVtfb0WuQG+8Ag2uWkbG79hOUzEsRrhBzgfn86g2sJPkzmcpGdghbNTfUKGTxymFrY/tLIodDzLoW9nOJ4FY8Q== + dependencies: + fs-extra "^4.0.3" + micromatch "^3.1.4" + +flat@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/flat/-/flat-4.1.1.tgz#a392059cc382881ff98642f5da4dde0a959f309b" + integrity sha512-FmTtBsHskrU6FJ2VxCnsDb84wu9zhmO3cUX2kGFb5tuwhfXxGciiT0oRY+cck35QmG+NmGh5eLz6lLCpWTqwpA== + dependencies: + is-buffer "~2.0.3" + +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + +flatstr@^1.0.12: + version "1.0.12" + resolved "https://registry.yarnpkg.com/flatstr/-/flatstr-1.0.12.tgz#c2ba6a08173edbb6c9640e3055b95e287ceb5931" + integrity sha512-4zPxDyhCyiN2wIAtSLI6gc82/EjqZc1onI4Mz/l0pWrAlsSfYH/2ZIcU+e3oA2wDwbzIWNKwa23F8rh6+DRWkw== + +flow-stoplight@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/flow-stoplight/-/flow-stoplight-1.0.0.tgz#4a292c5bcff8b39fa6cc0cb1a853d86f27eeff7b" + integrity sha1-SiksW8/4s5+mzAyxqFPYbyfu/3s= + +follow-redirects@^1.12.1: + version "1.13.2" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.2.tgz#dd73c8effc12728ba5cf4259d760ea5fb83e3147" + integrity sha512-6mPTgLxYm3r6Bkkg0vNM0HTjfGrOEtsfbhagQvbxDEsEkpNhw582upBaoRZylzen6krEmxXJgt9Ju6HiI4O7BA== + +for-each@^0.3.3, for-each@~0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" + integrity sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw== + dependencies: + is-callable "^1.1.3" + +for-in@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= + +form-data@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" + integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + +form-data@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" + integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.6" + mime-types "^2.1.12" + +forwarded@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" + integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ= + +fp-ts@1.19.3: + version "1.19.3" + resolved "https://registry.yarnpkg.com/fp-ts/-/fp-ts-1.19.3.tgz#261a60d1088fbff01f91256f91d21d0caaaaa96f" + integrity sha512-H5KQDspykdHuztLTg+ajGN0Z2qUjcEf3Ybxc6hLt0k7/zPkn29XnKnxlBPyW2XIddWrGaJBzBl4VLYOtk39yZg== + +fp-ts@^1.0.0: + version "1.19.5" + resolved "https://registry.yarnpkg.com/fp-ts/-/fp-ts-1.19.5.tgz#3da865e585dfa1fdfd51785417357ac50afc520a" + integrity sha512-wDNqTimnzs8QqpldiId9OavWK2NptormjXnRJTQecNjzwfyp6P/8s/zG8e4h3ja3oqkKaY72UlTjQYt/1yXf9A== + +fragment-cache@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" + integrity sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk= + dependencies: + map-cache "^0.2.2" + +fresh@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" + integrity sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac= + +fs-constants@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" + integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== + +fs-extra@^0.30.0: + version "0.30.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.30.0.tgz#f233ffcc08d4da7d432daa449776989db1df93f0" + integrity sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A= + dependencies: + graceful-fs "^4.1.2" + jsonfile "^2.1.0" + klaw "^1.0.0" + path-is-absolute "^1.0.0" + rimraf "^2.2.8" + +fs-extra@^4.0.2, fs-extra@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94" + integrity sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + +fs-extra@^7.0.0, fs-extra@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" + integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + +fs-minipass@^1.2.5: + version "1.2.7" + resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" + integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA== + dependencies: + minipass "^2.6.0" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= + +fsevents@~2.1.1: + version "2.1.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" + integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== + +fsevents@~2.3.1: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + +function-bind@^1.1.1, function-bind@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== + +functional-red-black-tree@^1.0.1, functional-red-black-tree@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" + integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= + +ganache-core@^2.13.2: + version "2.13.2" + resolved "https://registry.yarnpkg.com/ganache-core/-/ganache-core-2.13.2.tgz#27e6fc5417c10e6e76e2e646671869d7665814a3" + integrity sha512-tIF5cR+ANQz0+3pHWxHjIwHqFXcVo0Mb+kcsNhglNFALcYo49aQpnS9dqHartqPfMFjiHh/qFoD3mYK0d/qGgw== + dependencies: + abstract-leveldown "3.0.0" + async "2.6.2" + bip39 "2.5.0" + cachedown "1.0.0" + clone "2.1.2" + debug "3.2.6" + encoding-down "5.0.4" + eth-sig-util "3.0.0" + ethereumjs-abi "0.6.8" + ethereumjs-account "3.0.0" + ethereumjs-block "2.2.2" + ethereumjs-common "1.5.0" + ethereumjs-tx "2.1.2" + ethereumjs-util "6.2.1" + ethereumjs-vm "4.2.0" + heap "0.2.6" + keccak "3.0.1" + level-sublevel "6.6.4" + levelup "3.1.1" + lodash "4.17.20" + lru-cache "5.1.1" + merkle-patricia-tree "3.0.0" + patch-package "6.2.2" + seedrandom "3.0.1" + source-map-support "0.5.12" + tmp "0.1.0" + web3-provider-engine "14.2.1" + websocket "1.0.32" + optionalDependencies: + ethereumjs-wallet "0.6.5" + web3 "1.2.11" + +gauge@~2.7.3: + version "2.7.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" + integrity sha1-LANAXHU4w51+s3sxcCLjJfsBi/c= + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + wide-align "^1.1.0" + +get-caller-file@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" + integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w== + +get-caller-file@^2.0.1, get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +get-func-name@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" + integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE= + +get-intrinsic@^1.0.2: + version "1.1.1" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" + integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== + dependencies: + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.1" + +get-stream@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" + integrity sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= + +get-stream@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" + integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== + dependencies: + pump "^3.0.0" + +get-stream@^5.1.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" + integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== + dependencies: + pump "^3.0.0" + +get-value@^2.0.3, get-value@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" + integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg= + +getpass@^0.1.1: + version "0.1.7" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" + integrity sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo= + dependencies: + assert-plus "^1.0.0" + +github-from-package@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" + integrity sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4= + +glob-parent@~5.1.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" + integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ== + dependencies: + is-glob "^4.0.1" + +glob@7.1.3: + version "7.1.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" + integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@7.1.6, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.6, glob@~7.1.6: + version "7.1.6" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" + integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +global@~4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/global/-/global-4.4.0.tgz#3e7b105179006a323ed71aafca3e9c57a5cc6406" + integrity sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w== + dependencies: + min-document "^2.19.0" + process "^0.11.10" + +globals@^9.18.0: + version "9.18.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" + integrity sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ== + +got@9.6.0: + version "9.6.0" + resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85" + integrity sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q== + dependencies: + "@sindresorhus/is" "^0.14.0" + "@szmarczak/http-timer" "^1.1.2" + cacheable-request "^6.0.0" + decompress-response "^3.3.0" + duplexer3 "^0.1.4" + get-stream "^4.1.0" + lowercase-keys "^1.0.1" + mimic-response "^1.0.1" + p-cancelable "^1.0.0" + to-readable-stream "^1.0.0" + url-parse-lax "^3.0.0" + +got@^7.1.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/got/-/got-7.1.0.tgz#05450fd84094e6bbea56f451a43a9c289166385a" + integrity sha512-Y5WMo7xKKq1muPsxD+KmrR8DH5auG7fBdDVueZwETwV6VytKyU9OX/ddpq2/1hp1vIPvVb4T81dKQz3BivkNLw== + dependencies: + decompress-response "^3.2.0" + duplexer3 "^0.1.4" + get-stream "^3.0.0" + is-plain-obj "^1.1.0" + is-retry-allowed "^1.0.0" + is-stream "^1.0.0" + isurl "^1.0.0-alpha5" + lowercase-keys "^1.0.0" + p-cancelable "^0.3.0" + p-timeout "^1.1.1" + safe-buffer "^5.0.1" + timed-out "^4.0.0" + url-parse-lax "^1.0.0" + url-to-options "^1.0.1" + +graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: + version "4.2.6" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee" + integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ== + +growl@1.10.5: + version "1.10.5" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" + integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== + +har-schema@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= + +har-validator@~5.1.3: + version "5.1.5" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.5.tgz#1f0803b9f8cb20c0fa13822df1ecddb36bde1efd" + integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== + dependencies: + ajv "^6.12.3" + har-schema "^2.0.0" + +hardhat@^2.0.8: + version "2.0.10" + resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.0.10.tgz#9b50da13b6915bb9b61b7f38f8f2b9b352447462" + integrity sha512-ZAcC+9Nb1AEb22/2hWj/zLPyIRLD9y1O3LW2KhbONpxn1bf0qWLW8QegB9J3KP9Bvt8LbW9pWuSyRQJU0vUWqA== + dependencies: + "@nomiclabs/ethereumjs-vm" "4.2.2" + "@sentry/node" "^5.18.1" + "@solidity-parser/parser" "^0.11.0" + "@types/bn.js" "^4.11.5" + "@types/lru-cache" "^5.1.0" + abort-controller "^3.0.0" + adm-zip "^0.4.16" + ansi-escapes "^4.3.0" + chalk "^2.4.2" + chokidar "^3.4.0" + ci-info "^2.0.0" + debug "^4.1.1" + enquirer "^2.3.0" + env-paths "^2.2.0" + eth-sig-util "^2.5.2" + ethereum-cryptography "^0.1.2" + ethereumjs-abi "^0.6.8" + ethereumjs-account "^3.0.0" + ethereumjs-block "^2.2.2" + ethereumjs-common "^1.5.0" + ethereumjs-tx "^2.1.2" + ethereumjs-util "^6.2.0" + find-up "^2.1.0" + fp-ts "1.19.3" + fs-extra "^7.0.1" + glob "^7.1.3" + immutable "^4.0.0-rc.12" + io-ts "1.10.4" + lodash "^4.17.11" + merkle-patricia-tree "3.0.0" + mocha "^7.1.2" + node-fetch "^2.6.0" + qs "^6.7.0" + raw-body "^2.4.1" + resolve "1.17.0" + semver "^6.3.0" + slash "^3.0.0" + solc "0.7.3" + source-map-support "^0.5.13" + stacktrace-parser "^0.1.10" + "true-case-path" "^2.2.1" + tsort "0.0.1" + uuid "^3.3.2" + ws "^7.2.1" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + integrity sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE= + dependencies: + ansi-regex "^2.0.0" + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +has-symbol-support-x@^1.4.1: + version "1.4.2" + resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz#1409f98bc00247da45da67cee0a36f282ff26455" + integrity sha512-3ToOva++HaW+eCpgqZrCfN51IPB+7bJNVT6CUATzueB5Heb8o6Nam0V3HG5dlDvZU1Gn5QLcbahiKw/XVk5JJw== + +has-symbols@^1.0.0, has-symbols@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" + integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg== + +has-to-string-tag-x@^1.2.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz#a045ab383d7b4b2012a00148ab0aa5f290044d4d" + integrity sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw== + dependencies: + has-symbol-support-x "^1.4.1" + +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= + +has-value@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" + integrity sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8= + dependencies: + get-value "^2.0.3" + has-values "^0.1.4" + isobject "^2.0.0" + +has-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" + integrity sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc= + dependencies: + get-value "^2.0.6" + has-values "^1.0.0" + isobject "^3.0.0" + +has-values@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" + integrity sha1-bWHeldkd/Km5oCCJrThL/49it3E= + +has-values@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" + integrity sha1-lbC2P+whRmGab+V/51Yo1aOe/k8= + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + +has@^1.0.3, has@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" + integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== + dependencies: + function-bind "^1.1.1" + +hash-base@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.0.tgz#55c381d9e06e1d2997a883b4a3fddfe7f0d3af33" + integrity sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA== + dependencies: + inherits "^2.0.4" + readable-stream "^3.6.0" + safe-buffer "^5.2.0" + +hash.js@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.3.tgz#340dedbe6290187151c1ea1d777a3448935df846" + integrity sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA== + dependencies: + inherits "^2.0.3" + minimalistic-assert "^1.0.0" + +hash.js@^1.0.0, hash.js@^1.0.3, hash.js@^1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" + integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== + dependencies: + inherits "^2.0.3" + minimalistic-assert "^1.0.1" + +he@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + +heap@0.2.6: + version "0.2.6" + resolved "https://registry.yarnpkg.com/heap/-/heap-0.2.6.tgz#087e1f10b046932fc8594dd9e6d378afc9d1e5ac" + integrity sha1-CH4fELBGky/IWU3Z5tN4r8nR5aw= + +hmac-drbg@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" + integrity sha1-0nRXAQJabHdabFRXk+1QL8DGSaE= + dependencies: + hash.js "^1.0.3" + minimalistic-assert "^1.0.0" + minimalistic-crypto-utils "^1.0.1" + +home-or-tmp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" + integrity sha1-42w/LSyufXRqhX440Y1fMqeILbg= + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.1" + +hosted-git-info@^2.1.4, hosted-git-info@^2.6.0: + version "2.8.8" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" + integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg== + +http-cache-semantics@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz#49e91c5cbf36c9b94bcfcd71c23d5249ec74e390" + integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== + +http-errors@1.7.2: + version "1.7.2" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.2.tgz#4f5029cf13239f31036e5b2e55292bcfbcc85c8f" + integrity sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg== + dependencies: + depd "~1.1.2" + inherits "2.0.3" + setprototypeof "1.1.1" + statuses ">= 1.5.0 < 2" + toidentifier "1.0.0" + +http-errors@1.7.3, http-errors@~1.7.2: + version "1.7.3" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.3.tgz#6c619e4f9c60308c38519498c14fbb10aacebb06" + integrity sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw== + dependencies: + depd "~1.1.2" + inherits "2.0.4" + setprototypeof "1.1.1" + statuses ">= 1.5.0 < 2" + toidentifier "1.0.0" + +http-https@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/http-https/-/http-https-1.0.0.tgz#2f908dd5f1db4068c058cd6e6d4ce392c913389b" + integrity sha1-L5CN1fHbQGjAWM1ubUzjkskTOJs= + +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + integrity sha1-muzZJRFHcvPZW2WmCruPfBj7rOE= + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +https-proxy-agent@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2" + integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA== + dependencies: + agent-base "6" + debug "4" + +iconv-lite@0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + +iconv-lite@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.2.tgz#ce13d1875b0c3a674bd6a04b7f76b01b1b6ded01" + integrity sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ== + dependencies: + safer-buffer ">= 2.1.2 < 3.0.0" + +idna-uts46-hx@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/idna-uts46-hx/-/idna-uts46-hx-2.3.1.tgz#a1dc5c4df37eee522bf66d969cc980e00e8711f9" + integrity sha512-PWoF9Keq6laYdIRwwCdhTPl60xRqAloYNMQLiyUnG42VjT53oW07BXIRM+NK7eQjzXjAk2gUvX9caRxlnF9TAA== + dependencies: + punycode "2.1.0" + +ieee754@^1.1.13: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + +immediate@^3.2.3: + version "3.3.0" + resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.3.0.tgz#1aef225517836bcdf7f2a2de2600c79ff0269266" + integrity sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q== + +immediate@~3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.2.3.tgz#d140fa8f614659bd6541233097ddaac25cdd991c" + integrity sha1-0UD6j2FGWb1lQSMwl92qwlzdmRw= + +immutable@^4.0.0-rc.12: + version "4.0.0-rc.12" + resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.0.0-rc.12.tgz#ca59a7e4c19ae8d9bf74a97bdf0f6e2f2a5d0217" + integrity sha512-0M2XxkZLx/mi3t8NVwIm1g8nHoEmM9p9UBl/G9k4+hm0kBgOVdMV/B3CY5dQ8qG8qc80NN4gDV4HQv6FTJ5q7A== + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.1, inherits@~2.0.3, inherits@~2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +inherits@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= + +ini@~1.3.0: + version "1.3.8" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" + integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== + +invariant@2, invariant@^2.2.2: + version "2.2.4" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" + integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== + dependencies: + loose-envify "^1.0.0" + +invert-kv@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" + integrity sha1-EEqOSqym09jNFXqO+L+rLXo//bY= + +io-ts@1.10.4: + version "1.10.4" + resolved "https://registry.yarnpkg.com/io-ts/-/io-ts-1.10.4.tgz#cd5401b138de88e4f920adbcb7026e2d1967e6e2" + integrity sha512-b23PteSnYXSONJ6JQXRAlvJhuw8KOtkqa87W4wDtvMrud/DTJd5X+NpOOI+O/zZwVq6v0VLAaJ+1EDViKEuN9g== + dependencies: + fp-ts "^1.0.0" + +ipaddr.js@1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" + integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== + +is-accessor-descriptor@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" + integrity sha1-qeEss66Nh2cn7u84Q/igiXtcmNY= + dependencies: + kind-of "^3.0.2" + +is-accessor-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656" + integrity sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ== + dependencies: + kind-of "^6.0.0" + +is-arguments@^1.0.4: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.0.tgz#62353031dfbee07ceb34656a6bde59efecae8dd9" + integrity sha512-1Ij4lOMPl/xB5kBDn7I+b2ttPMKa8szhEIrXDuXQD/oe3HJLTLhqhgGspwgyGd6MOywBUqVvYicF72lkgDnIHg== + dependencies: + call-bind "^1.0.0" + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== + +is-buffer@~2.0.3: + version "2.0.5" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.5.tgz#ebc252e400d22ff8d77fa09888821a24a658c191" + integrity sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ== + +is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.3.tgz#8b1e0500b73a1d76c70487636f368e519de8db8e" + integrity sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ== + +is-ci@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" + integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w== + dependencies: + ci-info "^2.0.0" + +is-core-module@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a" + integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ== + dependencies: + has "^1.0.3" + +is-data-descriptor@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" + integrity sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y= + dependencies: + kind-of "^3.0.2" + +is-data-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7" + integrity sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ== + dependencies: + kind-of "^6.0.0" + +is-date-object@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.2.tgz#bda736f2cd8fd06d32844e7743bfa7494c3bfd7e" + integrity sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g== + +is-descriptor@^0.1.0: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" + integrity sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg== + dependencies: + is-accessor-descriptor "^0.1.6" + is-data-descriptor "^0.1.4" + kind-of "^5.0.0" + +is-descriptor@^1.0.0, is-descriptor@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec" + integrity sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg== + dependencies: + is-accessor-descriptor "^1.0.0" + is-data-descriptor "^1.0.0" + kind-of "^6.0.2" + +is-extendable@^0.1.0, is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + integrity sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik= + +is-extendable@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" + integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== + dependencies: + is-plain-object "^2.0.4" + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= + +is-finite@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.1.0.tgz#904135c77fb42c0641d6aa1bcdbc4daa8da082f3" + integrity sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w== + +is-fn@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fn/-/is-fn-1.0.0.tgz#9543d5de7bcf5b08a22ec8a20bae6e286d510d8c" + integrity sha1-lUPV3nvPWwiiLsiiC65uKG1RDYw= + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs= + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-function@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.2.tgz#4f097f30abf6efadac9833b17ca5dc03f8144e08" + integrity sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ== + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" + integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== + dependencies: + is-extglob "^2.1.1" + +is-hex-prefixed@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz#7d8d37e6ad77e5d127148913c573e082d777f554" + integrity sha1-fY035q135dEnFIkTxXPggtd39VQ= + +is-negative-zero@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.1.tgz#3de746c18dda2319241a53675908d8f766f11c24" + integrity sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w== + +is-number@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + integrity sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU= + dependencies: + kind-of "^3.0.2" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-object@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-object/-/is-object-1.0.2.tgz#a56552e1c665c9e950b4a025461da87e72f86fcf" + integrity sha512-2rRIahhZr2UWb45fIOuvZGpFtz0TyOZLf32KxBbSoUCeZR495zCKlWUKKUByk3geS2eAs7ZAABt0Y/Rx0GiQGA== + +is-plain-obj@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" + integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4= + +is-plain-obj@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== + +is-plain-object@^2.0.3, is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== + dependencies: + isobject "^3.0.1" + +is-regex@^1.0.4, is-regex@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.2.tgz#81c8ebde4db142f2cf1c53fc86d6a45788266251" + integrity sha512-axvdhb5pdhEVThqJzYXwMlVuZwC+FF2DpcOhTS+y/8jVq4trxyPgfcwIxIKiyeuLlSQYKkmUaPQJ8ZE4yNKXDg== + dependencies: + call-bind "^1.0.2" + has-symbols "^1.0.1" + +is-regex@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.5.tgz#39d589a358bf18967f726967120b8fc1aed74eae" + integrity sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ== + dependencies: + has "^1.0.3" + +is-retry-allowed@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz#d778488bd0a4666a3be8a1482b9f2baafedea8b4" + integrity sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg== + +is-stream@^1.0.0, is-stream@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= + +is-symbol@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937" + integrity sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ== + dependencies: + has-symbols "^1.0.1" + +is-typedarray@^1.0.0, is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= + +is-url@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/is-url/-/is-url-1.2.4.tgz#04a4df46d28c4cff3d73d01ff06abeb318a1aa52" + integrity sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww== + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= + +is-windows@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" + integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8= + +isarray@1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + integrity sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk= + dependencies: + isarray "1.0.0" + +isobject@^3.0.0, isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= + +isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= + +isurl@^1.0.0-alpha5: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isurl/-/isurl-1.0.0.tgz#b27f4f49f3cdaa3ea44a0a5b7f3462e6edc39d67" + integrity sha512-1P/yWsxPlDtn7QeRD+ULKQPaIaN6yF368GZ2vDfv0AL0NwpStafjWCDDdn0k8wgFMWpVAqG7oJhxHnlud42i9w== + dependencies: + has-to-string-tag-x "^1.2.0" + is-object "^1.0.1" + +jest-docblock@^21.0.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" + integrity sha512-5IZ7sY9dBAYSV+YjQ0Ovb540Ku7AO9Z5o2Cg789xj167iQuZ2cG+z0f3Uct6WeYLbU6aQiM2pCs7sZ+4dotydw== + +js-sha3@0.5.7, js-sha3@^0.5.7: + version "0.5.7" + resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.5.7.tgz#0d4ffd8002d5333aabaf4a23eed2f6374c9f28e7" + integrity sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc= + +js-sha3@0.8.0, js-sha3@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" + integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== + +"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== + +js-tokens@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" + integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= + +js-yaml@3.13.1: + version "3.13.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" + integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +js-yaml@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.0.0.tgz#f426bc0ff4b4051926cd588c71113183409a121f" + integrity sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q== + dependencies: + argparse "^2.0.1" + +js-yaml@^3.13.1: + version "3.14.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" + integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +jsbn@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= + +jsesc@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" + integrity sha1-RsP+yMGJKxKwgz25vHYiF226s0s= + +jsesc@~0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" + integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= + +json-buffer@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.0.tgz#5b1f397afc75d677bde8bcfc0e47e1f9a3d9a898" + integrity sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg= + +json-rpc-engine@^3.4.0, json-rpc-engine@^3.6.0: + version "3.8.0" + resolved "https://registry.yarnpkg.com/json-rpc-engine/-/json-rpc-engine-3.8.0.tgz#9d4ff447241792e1d0a232f6ef927302bb0c62a9" + integrity sha512-6QNcvm2gFuuK4TKU1uwfH0Qd/cOSb9c1lls0gbnIhciktIUQJwz6NQNAW4B1KiGPenv7IKu97V222Yo1bNhGuA== + dependencies: + async "^2.0.1" + babel-preset-env "^1.7.0" + babelify "^7.3.0" + json-rpc-error "^2.0.0" + promise-to-callback "^1.0.0" + safe-event-emitter "^1.0.1" + +json-rpc-error@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/json-rpc-error/-/json-rpc-error-2.0.0.tgz#a7af9c202838b5e905c7250e547f1aff77258a02" + integrity sha1-p6+cICg4tekFxyUOVH8a/3cligI= + dependencies: + inherits "^2.0.1" + +json-rpc-random-id@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-rpc-random-id/-/json-rpc-random-id-1.0.1.tgz#ba49d96aded1444dbb8da3d203748acbbcdec8c8" + integrity sha1-uknZat7RRE27jaPSA3SKy7zeyMg= + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json-schema@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + integrity sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM= + +json-stable-stringify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" + integrity sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8= + dependencies: + jsonify "~0.0.0" + +json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= + +json5@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + integrity sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE= + +jsonfile@^2.1.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" + integrity sha1-NzaitCi4e72gzIO1P6PWM6NcKug= + optionalDependencies: + graceful-fs "^4.1.6" + +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= + optionalDependencies: + graceful-fs "^4.1.6" + +jsonify@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" + integrity sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM= + +jsprim@^1.2.2: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" + integrity sha1-MT5mvB5cwG5Di8G3SZwuXFastqI= + dependencies: + assert-plus "1.0.0" + extsprintf "1.3.0" + json-schema "0.2.3" + verror "1.10.0" + +keccak@3.0.1, keccak@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.1.tgz#ae30a0e94dbe43414f741375cff6d64c8bea0bff" + integrity sha512-epq90L9jlFWCW7+pQa6JOnKn2Xgl2mtI664seYR6MHskvI9agt7AnDqmAlp9TqU4/caMYbA08Hi5DMZAl5zdkA== + dependencies: + node-addon-api "^2.0.0" + node-gyp-build "^4.2.0" + +keyv@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9" + integrity sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA== + dependencies: + json-buffer "3.0.0" + +kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + integrity sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ= + dependencies: + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + integrity sha1-IIE989cSkosgc3hpGkUGb65y3Vc= + dependencies: + is-buffer "^1.1.5" + +kind-of@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" + integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== + +kind-of@^6.0.0, kind-of@^6.0.2: + version "6.0.3" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== + +klaw-sync@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c" + integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ== + dependencies: + graceful-fs "^4.1.11" + +klaw@^1.0.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" + integrity sha1-QIhDO0azsbolnXh4XY6W9zugJDk= + optionalDependencies: + graceful-fs "^4.1.9" + +lcid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" + integrity sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU= + dependencies: + invert-kv "^1.0.0" + +level-codec@^9.0.0: + version "9.0.2" + resolved "https://registry.yarnpkg.com/level-codec/-/level-codec-9.0.2.tgz#fd60df8c64786a80d44e63423096ffead63d8cbc" + integrity sha512-UyIwNb1lJBChJnGfjmO0OR+ezh2iVu1Kas3nvBS/BzGnx79dv6g7unpKIDNPMhfdTEGoc7mC8uAu51XEtX+FHQ== + dependencies: + buffer "^5.6.0" + +level-codec@~7.0.0: + version "7.0.1" + resolved "https://registry.yarnpkg.com/level-codec/-/level-codec-7.0.1.tgz#341f22f907ce0f16763f24bddd681e395a0fb8a7" + integrity sha512-Ua/R9B9r3RasXdRmOtd+t9TCOEIIlts+TN/7XTT2unhDaL6sJn83S3rUyljbr6lVtw49N3/yA0HHjpV6Kzb2aQ== + +level-concat-iterator@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/level-concat-iterator/-/level-concat-iterator-2.0.1.tgz#1d1009cf108340252cb38c51f9727311193e6263" + integrity sha512-OTKKOqeav2QWcERMJR7IS9CUo1sHnke2C0gkSmcR7QuEtFNLLzHQAvnMw8ykvEcv0Qtkg0p7FOwP1v9e5Smdcw== + +level-errors@^1.0.3: + version "1.1.2" + resolved "https://registry.yarnpkg.com/level-errors/-/level-errors-1.1.2.tgz#4399c2f3d3ab87d0625f7e3676e2d807deff404d" + integrity sha512-Sw/IJwWbPKF5Ai4Wz60B52yj0zYeqzObLh8k1Tk88jVmD51cJSKWSYpRyhVIvFzZdvsPqlH5wfhp/yxdsaQH4w== + dependencies: + errno "~0.1.1" + +level-errors@^2.0.0, level-errors@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/level-errors/-/level-errors-2.0.1.tgz#2132a677bf4e679ce029f517c2f17432800c05c8" + integrity sha512-UVprBJXite4gPS+3VznfgDSU8PTRuVX0NXwoWW50KLxd2yw4Y1t2JUR5In1itQnudZqRMT9DlAM3Q//9NCjCFw== + dependencies: + errno "~0.1.1" + +level-errors@~1.0.3: + version "1.0.5" + resolved "https://registry.yarnpkg.com/level-errors/-/level-errors-1.0.5.tgz#83dbfb12f0b8a2516bdc9a31c4876038e227b859" + integrity sha512-/cLUpQduF6bNrWuAC4pwtUKA5t669pCsCi2XbmojG2tFeOr9j6ShtdDCtFFQO1DRt+EVZhx9gPzP9G2bUaG4ig== + dependencies: + errno "~0.1.1" + +level-iterator-stream@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/level-iterator-stream/-/level-iterator-stream-2.0.3.tgz#ccfff7c046dcf47955ae9a86f46dfa06a31688b4" + integrity sha512-I6Heg70nfF+e5Y3/qfthJFexhRw/Gi3bIymCoXAlijZdAcLaPuWSJs3KXyTYf23ID6g0o2QF62Yh+grOXY3Rig== + dependencies: + inherits "^2.0.1" + readable-stream "^2.0.5" + xtend "^4.0.0" + +level-iterator-stream@~1.3.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/level-iterator-stream/-/level-iterator-stream-1.3.1.tgz#e43b78b1a8143e6fa97a4f485eb8ea530352f2ed" + integrity sha1-5Dt4sagUPm+pek9IXrjqUwNS8u0= + dependencies: + inherits "^2.0.1" + level-errors "^1.0.3" + readable-stream "^1.0.33" + xtend "^4.0.0" + +level-iterator-stream@~3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/level-iterator-stream/-/level-iterator-stream-3.0.1.tgz#2c98a4f8820d87cdacab3132506815419077c730" + integrity sha512-nEIQvxEED9yRThxvOrq8Aqziy4EGzrxSZK+QzEFAVuJvQ8glfyZ96GB6BoI4sBbLfjMXm2w4vu3Tkcm9obcY0g== + dependencies: + inherits "^2.0.1" + readable-stream "^2.3.6" + xtend "^4.0.0" + +level-iterator-stream@~4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/level-iterator-stream/-/level-iterator-stream-4.0.2.tgz#7ceba69b713b0d7e22fcc0d1f128ccdc8a24f79c" + integrity sha512-ZSthfEqzGSOMWoUGhTXdX9jv26d32XJuHz/5YnuHZzH6wldfWMOVwI9TBtKcya4BKTyTt3XVA0A3cF3q5CY30Q== + dependencies: + inherits "^2.0.4" + readable-stream "^3.4.0" + xtend "^4.0.2" + +level-mem@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/level-mem/-/level-mem-3.0.1.tgz#7ce8cf256eac40f716eb6489654726247f5a89e5" + integrity sha512-LbtfK9+3Ug1UmvvhR2DqLqXiPW1OJ5jEh0a3m9ZgAipiwpSxGj/qaVVy54RG5vAQN1nCuXqjvprCuKSCxcJHBg== + dependencies: + level-packager "~4.0.0" + memdown "~3.0.0" + +level-mem@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/level-mem/-/level-mem-5.0.1.tgz#c345126b74f5b8aa376dc77d36813a177ef8251d" + integrity sha512-qd+qUJHXsGSFoHTziptAKXoLX87QjR7v2KMbqncDXPxQuCdsQlzmyX+gwrEHhlzn08vkf8TyipYyMmiC6Gobzg== + dependencies: + level-packager "^5.0.3" + memdown "^5.0.0" + +level-packager@^5.0.3: + version "5.1.1" + resolved "https://registry.yarnpkg.com/level-packager/-/level-packager-5.1.1.tgz#323ec842d6babe7336f70299c14df2e329c18939" + integrity sha512-HMwMaQPlTC1IlcwT3+swhqf/NUO+ZhXVz6TY1zZIIZlIR0YSn8GtAAWmIvKjNY16ZkEg/JcpAuQskxsXqC0yOQ== + dependencies: + encoding-down "^6.3.0" + levelup "^4.3.2" + +level-packager@~4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/level-packager/-/level-packager-4.0.1.tgz#7e7d3016af005be0869bc5fa8de93d2a7f56ffe6" + integrity sha512-svCRKfYLn9/4CoFfi+d8krOtrp6RoX8+xm0Na5cgXMqSyRru0AnDYdLl+YI8u1FyS6gGZ94ILLZDE5dh2but3Q== + dependencies: + encoding-down "~5.0.0" + levelup "^3.0.0" + +level-post@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/level-post/-/level-post-1.0.7.tgz#19ccca9441a7cc527879a0635000f06d5e8f27d0" + integrity sha512-PWYqG4Q00asOrLhX7BejSajByB4EmG2GaKHfj3h5UmmZ2duciXLPGYWIjBzLECFWUGOZWlm5B20h/n3Gs3HKew== + dependencies: + ltgt "^2.1.2" + +level-sublevel@6.6.4: + version "6.6.4" + resolved "https://registry.yarnpkg.com/level-sublevel/-/level-sublevel-6.6.4.tgz#f7844ae893919cd9d69ae19d7159499afd5352ba" + integrity sha512-pcCrTUOiO48+Kp6F1+UAzF/OtWqLcQVTVF39HLdZ3RO8XBoXt+XVPKZO1vVr1aUoxHZA9OtD2e1v7G+3S5KFDA== + dependencies: + bytewise "~1.1.0" + level-codec "^9.0.0" + level-errors "^2.0.0" + level-iterator-stream "^2.0.3" + ltgt "~2.1.1" + pull-defer "^0.2.2" + pull-level "^2.0.3" + pull-stream "^3.6.8" + typewiselite "~1.0.0" + xtend "~4.0.0" + +level-supports@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/level-supports/-/level-supports-1.0.1.tgz#2f530a596834c7301622521988e2c36bb77d122d" + integrity sha512-rXM7GYnW8gsl1vedTJIbzOrRv85c/2uCMpiiCzO2fndd06U/kUXEEU9evYn4zFggBOg36IsBW8LzqIpETwwQzg== + dependencies: + xtend "^4.0.2" + +level-ws@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/level-ws/-/level-ws-0.0.0.tgz#372e512177924a00424b0b43aef2bb42496d228b" + integrity sha1-Ny5RIXeSSgBCSwtDrvK7QkltIos= + dependencies: + readable-stream "~1.0.15" + xtend "~2.1.1" + +level-ws@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/level-ws/-/level-ws-1.0.0.tgz#19a22d2d4ac57b18cc7c6ecc4bd23d899d8f603b" + integrity sha512-RXEfCmkd6WWFlArh3X8ONvQPm8jNpfA0s/36M4QzLqrLEIt1iJE9WBHLZ5vZJK6haMjJPJGJCQWfjMNnRcq/9Q== + dependencies: + inherits "^2.0.3" + readable-stream "^2.2.8" + xtend "^4.0.1" + +level-ws@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/level-ws/-/level-ws-2.0.0.tgz#207a07bcd0164a0ec5d62c304b4615c54436d339" + integrity sha512-1iv7VXx0G9ec1isqQZ7y5LmoZo/ewAsyDHNA8EFDW5hqH2Kqovm33nSFkSdnLLAK+I5FlT+lo5Cw9itGe+CpQA== + dependencies: + inherits "^2.0.3" + readable-stream "^3.1.0" + xtend "^4.0.1" + +levelup@3.1.1, levelup@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/levelup/-/levelup-3.1.1.tgz#c2c0b3be2b4dc316647c53b42e2f559e232d2189" + integrity sha512-9N10xRkUU4dShSRRFTBdNaBxofz+PGaIZO962ckboJZiNmLuhVT6FZ6ZKAsICKfUBO76ySaYU6fJWX/jnj3Lcg== + dependencies: + deferred-leveldown "~4.0.0" + level-errors "~2.0.0" + level-iterator-stream "~3.0.0" + xtend "~4.0.0" + +levelup@^1.2.1: + version "1.3.9" + resolved "https://registry.yarnpkg.com/levelup/-/levelup-1.3.9.tgz#2dbcae845b2bb2b6bea84df334c475533bbd82ab" + integrity sha512-VVGHfKIlmw8w1XqpGOAGwq6sZm2WwWLmlDcULkKWQXEA5EopA8OBNJ2Ck2v6bdk8HeEZSbCSEgzXadyQFm76sQ== + dependencies: + deferred-leveldown "~1.2.1" + level-codec "~7.0.0" + level-errors "~1.0.3" + level-iterator-stream "~1.3.0" + prr "~1.0.1" + semver "~5.4.1" + xtend "~4.0.0" + +levelup@^4.3.2: + version "4.4.0" + resolved "https://registry.yarnpkg.com/levelup/-/levelup-4.4.0.tgz#f89da3a228c38deb49c48f88a70fb71f01cafed6" + integrity sha512-94++VFO3qN95cM/d6eBXvd894oJE0w3cInq9USsyQzzoJxmiYzPAocNcuGCPGGjoXqDVJcr3C1jzt1TSjyaiLQ== + dependencies: + deferred-leveldown "~5.3.0" + level-errors "~2.0.0" + level-iterator-stream "~4.0.0" + level-supports "~1.0.0" + xtend "~4.0.0" + +lines-and-columns@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00" + integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= + +load-json-file@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + integrity sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA= + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + pinkie-promise "^2.0.0" + strip-bom "^2.0.0" + +locate-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" + integrity sha1-K1aLJl7slExtnA3pw9u7ygNUzY4= + dependencies: + p-locate "^2.0.0" + path-exists "^3.0.0" + +locate-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" + integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== + dependencies: + p-locate "^3.0.0" + path-exists "^3.0.0" + +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +lodash.assign@^4.0.3, lodash.assign@^4.0.6: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" + integrity sha1-DZnzzNem0mHRm9rrkkUAXShYCOc= + +lodash@4.17.20, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.20, lodash@^4.17.4: + version "4.17.20" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" + integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== + +log-symbols@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-3.0.0.tgz#f3a08516a5dea893336a7dee14d18a1cfdab77c4" + integrity sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ== + dependencies: + chalk "^2.4.2" + +log-symbols@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.0.0.tgz#69b3cc46d20f448eccdb75ea1fa733d9e821c920" + integrity sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA== + dependencies: + chalk "^4.0.0" + +looper@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/looper/-/looper-2.0.0.tgz#66cd0c774af3d4fedac53794f742db56da8f09ec" + integrity sha1-Zs0Md0rz1P7axTeU90LbVtqPCew= + +looper@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/looper/-/looper-3.0.0.tgz#2efa54c3b1cbaba9b94aee2e5914b0be57fbb749" + integrity sha1-LvpUw7HLq6m5Su4uWRSwvlf7t0k= + +loose-envify@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" + integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== + dependencies: + js-tokens "^3.0.0 || ^4.0.0" + +lowercase-keys@^1.0.0, lowercase-keys@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" + integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA== + +lowercase-keys@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" + integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== + +lru-cache@5.1.1, lru-cache@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" + integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== + dependencies: + yallist "^3.0.2" + +lru-cache@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-3.2.0.tgz#71789b3b7f5399bec8565dda38aa30d2a097efee" + integrity sha1-cXibO39Tmb7IVl3aOKow0qCX7+4= + dependencies: + pseudomap "^1.0.1" + +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + +lru_map@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd" + integrity sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0= + +ltgt@^2.1.2, ltgt@~2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.2.1.tgz#f35ca91c493f7b73da0e07495304f17b31f87ee5" + integrity sha1-81ypHEk/e3PaDgdJUwTxezH4fuU= + +ltgt@~2.1.1: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.1.3.tgz#10851a06d9964b971178441c23c9e52698eece34" + integrity sha1-EIUaBtmWS5cReEQcI8nlJpjuzjQ= + +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + +map-cache@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" + integrity sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8= + +map-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" + integrity sha1-7Nyo8TFE5mDxtb1B8S80edmN+48= + dependencies: + object-visit "^1.0.0" + +md5.js@^1.3.4: + version "1.3.5" + resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" + integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== + dependencies: + hash-base "^3.0.0" + inherits "^2.0.1" + safe-buffer "^5.1.2" + +media-typer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= + +memdown@^1.0.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/memdown/-/memdown-1.4.1.tgz#b4e4e192174664ffbae41361aa500f3119efe215" + integrity sha1-tOThkhdGZP+65BNhqlAPMRnv4hU= + dependencies: + abstract-leveldown "~2.7.1" + functional-red-black-tree "^1.0.1" + immediate "^3.2.3" + inherits "~2.0.1" + ltgt "~2.2.0" + safe-buffer "~5.1.1" + +memdown@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/memdown/-/memdown-5.1.0.tgz#608e91a9f10f37f5b5fe767667a8674129a833cb" + integrity sha512-B3J+UizMRAlEArDjWHTMmadet+UKwHd3UjMgGBkZcKAxAYVPS9o0Yeiha4qvz7iGiL2Sb3igUft6p7nbFWctpw== + dependencies: + abstract-leveldown "~6.2.1" + functional-red-black-tree "~1.0.1" + immediate "~3.2.3" + inherits "~2.0.1" + ltgt "~2.2.0" + safe-buffer "~5.2.0" + +memdown@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/memdown/-/memdown-3.0.0.tgz#93aca055d743b20efc37492e9e399784f2958309" + integrity sha512-tbV02LfZMWLcHcq4tw++NuqMO+FZX8tNJEiD2aNRm48ZZusVg5N8NART+dmBkepJVye986oixErf7jfXboMGMA== + dependencies: + abstract-leveldown "~5.0.0" + functional-red-black-tree "~1.0.1" + immediate "~3.2.3" + inherits "~2.0.1" + ltgt "~2.2.0" + safe-buffer "~5.1.1" + +memorystream@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2" + integrity sha1-htcJCzDORV1j+64S3aUaR93K+bI= + +merge-descriptors@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" + integrity sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E= + +merkle-patricia-tree@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/merkle-patricia-tree/-/merkle-patricia-tree-3.0.0.tgz#448d85415565df72febc33ca362b8b614f5a58f8" + integrity sha512-soRaMuNf/ILmw3KWbybaCjhx86EYeBbD8ph0edQCTed0JN/rxDt1EBN52Ajre3VyGo+91f8+/rfPIRQnnGMqmQ== + dependencies: + async "^2.6.1" + ethereumjs-util "^5.2.0" + level-mem "^3.0.1" + level-ws "^1.0.0" + readable-stream "^3.0.6" + rlp "^2.0.0" + semaphore ">=1.0.1" + +merkle-patricia-tree@^2.1.2, merkle-patricia-tree@^2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/merkle-patricia-tree/-/merkle-patricia-tree-2.3.2.tgz#982ca1b5a0fde00eed2f6aeed1f9152860b8208a" + integrity sha512-81PW5m8oz/pz3GvsAwbauj7Y00rqm81Tzad77tHBwU7pIAtN+TJnMSOJhxBKflSVYhptMMb9RskhqHqrSm1V+g== + dependencies: + async "^1.4.2" + ethereumjs-util "^5.0.0" + level-ws "0.0.0" + levelup "^1.2.1" + memdown "^1.0.0" + readable-stream "^2.0.0" + rlp "^2.0.0" + semaphore ">=1.0.1" + +merkle-patricia-tree@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/merkle-patricia-tree/-/merkle-patricia-tree-4.1.0.tgz#010636c4cfd68682df33a2e3186b7d0be7b98b9d" + integrity sha512-vmP1J7FwIpprFMVjjSMM1JAwFce85Q+tp0TYIedYv8qaMh2oLUZ3ETXn9wbgi9S6elySzKzGa+Ai6VNKGEwSlg== + dependencies: + "@types/levelup" "^4.3.0" + ethereumjs-util "^7.0.8" + level-mem "^5.0.1" + level-ws "^2.0.0" + readable-stream "^3.6.0" + rlp "^2.2.3" + semaphore-async-await "^1.5.1" + +merkletreejs@^0.2.12: + version "0.2.13" + resolved "https://registry.yarnpkg.com/merkletreejs/-/merkletreejs-0.2.13.tgz#56ab4cd4dff7fde018815cec0283f454558057e2" + integrity sha512-hnM1XX0C+3yfAytRiX7FKC+bYg+GC83aQq7EytAp6nbcUBRdXU6/AVkmNdsAaJJ9IaKZt0w76r0QeWY/Fq+uFw== + dependencies: + buffer-reverse "^1.0.1" + crypto-js "^3.1.9-1" + treeify "^1.1.0" + +methods@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" + integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4= + +micromatch@^3.1.4: + version "3.1.10" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" + integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + braces "^2.3.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + extglob "^2.0.4" + fragment-cache "^0.2.1" + kind-of "^6.0.2" + nanomatch "^1.2.9" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.2" + +miller-rabin@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" + integrity sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA== + dependencies: + bn.js "^4.0.0" + brorand "^1.0.1" + +mime-db@1.46.0: + version "1.46.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.46.0.tgz#6267748a7f799594de3cbc8cde91def349661cee" + integrity sha512-svXaP8UQRZ5K7or+ZmfNhg2xX3yKDMUzqadsSqi4NCH/KomcH75MAMYAGVlvXn4+b/xOPhS3I2uHKRUzvjY7BQ== + +mime-types@^2.1.12, mime-types@^2.1.16, mime-types@~2.1.19, mime-types@~2.1.24: + version "2.1.29" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.29.tgz#1d4ab77da64b91f5f72489df29236563754bb1b2" + integrity sha512-Y/jMt/S5sR9OaqteJtslsFZKWOIIqMACsJSiHghlCAyhf7jfVYjKBmLiX8OgpWeW+fjJ2b+Az69aPFPkUOY6xQ== + dependencies: + mime-db "1.46.0" + +mime@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" + integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== + +mimic-response@^1.0.0, mimic-response@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" + integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== + +mimic-response@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-2.1.0.tgz#d13763d35f613d09ec37ebb30bac0469c0ee8f43" + integrity sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA== + +min-document@^2.19.0: + version "2.19.0" + resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.0.tgz#7bd282e3f5842ed295bb748cdd9f1ffa2c824685" + integrity sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU= + dependencies: + dom-walk "^0.1.0" + +minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" + integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== + +minimalistic-crypto-utils@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" + integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= + +minimatch@3.0.4, minimatch@^3.0.3, minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== + dependencies: + brace-expansion "^1.1.7" + +minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.5, minimist@~1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" + integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + +minipass@^2.6.0, minipass@^2.8.6, minipass@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6" + integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg== + dependencies: + safe-buffer "^5.1.2" + yallist "^3.0.0" + +minizlib@^1.2.1: + version "1.3.3" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" + integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q== + dependencies: + minipass "^2.9.0" + +mixin-deep@^1.2.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566" + integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA== + dependencies: + for-in "^1.0.2" + is-extendable "^1.0.1" + +mkdirp-classic@^0.5.2, mkdirp-classic@^0.5.3: + version "0.5.3" + resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" + integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A== + +mkdirp-promise@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/mkdirp-promise/-/mkdirp-promise-5.0.1.tgz#e9b8f68e552c68a9c1713b84883f7a1dd039b8a1" + integrity sha1-6bj2jlUsaKnBcTuEiD96HdA5uKE= + dependencies: + mkdirp "*" + +mkdirp@*, mkdirp@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== + +mkdirp@0.5.5, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.3: + version "0.5.5" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" + integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== + dependencies: + minimist "^1.2.5" + +mocha@^7.1.2: + version "7.2.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.2.0.tgz#01cc227b00d875ab1eed03a75106689cfed5a604" + integrity sha512-O9CIypScywTVpNaRrCAgoUnJgozpIofjKUYmJhiCIJMiuYnLI6otcb1/kpW9/n/tJODHGZ7i8aLQoDVsMtOKQQ== + dependencies: + ansi-colors "3.2.3" + browser-stdout "1.3.1" + chokidar "3.3.0" + debug "3.2.6" + diff "3.5.0" + escape-string-regexp "1.0.5" + find-up "3.0.0" + glob "7.1.3" + growl "1.10.5" + he "1.2.0" + js-yaml "3.13.1" + log-symbols "3.0.0" + minimatch "3.0.4" + mkdirp "0.5.5" + ms "2.1.1" + node-environment-flags "1.0.6" + object.assign "4.1.0" + strip-json-comments "2.0.1" + supports-color "6.0.0" + which "1.3.1" + wide-align "1.1.3" + yargs "13.3.2" + yargs-parser "13.1.2" + yargs-unparser "1.6.0" + +mocha@^8.3.0: + version "8.3.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-8.3.0.tgz#a83a7432d382ae1ca29686062d7fdc2c36f63fe5" + integrity sha512-TQqyC89V1J/Vxx0DhJIXlq9gbbL9XFNdeLQ1+JsnZsVaSOV1z3tWfw0qZmQJGQRIfkvZcs7snQnZnOCKoldq1Q== + dependencies: + "@ungap/promise-all-settled" "1.1.2" + ansi-colors "4.1.1" + browser-stdout "1.3.1" + chokidar "3.5.1" + debug "4.3.1" + diff "5.0.0" + escape-string-regexp "4.0.0" + find-up "5.0.0" + glob "7.1.6" + growl "1.10.5" + he "1.2.0" + js-yaml "4.0.0" + log-symbols "4.0.0" + minimatch "3.0.4" + ms "2.1.3" + nanoid "3.1.20" + serialize-javascript "5.0.1" + strip-json-comments "3.1.1" + supports-color "8.1.1" + which "2.0.2" + wide-align "1.1.3" + workerpool "6.1.0" + yargs "16.2.0" + yargs-parser "20.2.4" + yargs-unparser "2.0.0" + +mock-fs@^4.1.0: + version "4.13.0" + resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-4.13.0.tgz#31c02263673ec3789f90eb7b6963676aa407a598" + integrity sha512-DD0vOdofJdoaRNtnWcrXe6RQbpHkPPmtqGq14uRX0F8ZKJ5nv89CVTYl/BZdppDxBDaV0hl75htg3abpEWlPZA== + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= + +ms@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" + integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== + +ms@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +ms@2.1.3, ms@^2.1.1: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +multibase@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/multibase/-/multibase-0.7.0.tgz#1adfc1c50abe05eefeb5091ac0c2728d6b84581b" + integrity sha512-TW8q03O0f6PNFTQDvh3xxH03c8CjGaaYrjkl9UQPG6rz53TQzzxJVCIWVjzcbN/Q5Y53Zd0IBQBMVktVgNx4Fg== + dependencies: + base-x "^3.0.8" + buffer "^5.5.0" + +multibase@~0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/multibase/-/multibase-0.6.1.tgz#b76df6298536cc17b9f6a6db53ec88f85f8cc12b" + integrity sha512-pFfAwyTjbbQgNc3G7D48JkJxWtoJoBMaR4xQUOuB8RnCgRqaYmWNFeJTTvrJ2w51bjLq2zTby6Rqj9TQ9elSUw== + dependencies: + base-x "^3.0.8" + buffer "^5.5.0" + +multicodec@^0.5.5: + version "0.5.7" + resolved "https://registry.yarnpkg.com/multicodec/-/multicodec-0.5.7.tgz#1fb3f9dd866a10a55d226e194abba2dcc1ee9ffd" + integrity sha512-PscoRxm3f+88fAtELwUnZxGDkduE2HD9Q6GHUOywQLjOGT/HAdhjLDYNZ1e7VR0s0TP0EwZ16LNUTFpoBGivOA== + dependencies: + varint "^5.0.0" + +multicodec@^1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/multicodec/-/multicodec-1.0.4.tgz#46ac064657c40380c28367c90304d8ed175a714f" + integrity sha512-NDd7FeS3QamVtbgfvu5h7fd1IlbaC4EQ0/pgU4zqE2vdHCmBGsUa0TiM8/TdSeG6BMPC92OOCf8F1ocE/Wkrrg== + dependencies: + buffer "^5.6.0" + varint "^5.0.0" + +multihashes@^0.4.15, multihashes@~0.4.15: + version "0.4.21" + resolved "https://registry.yarnpkg.com/multihashes/-/multihashes-0.4.21.tgz#dc02d525579f334a7909ade8a122dabb58ccfcb5" + integrity sha512-uVSvmeCWf36pU2nB4/1kzYZjsXD9vofZKpgudqkceYY5g2aZZXJ5r9lxuzoRLl1OAp28XljXsEJ/X/85ZsKmKw== + dependencies: + buffer "^5.5.0" + multibase "^0.7.0" + varint "^5.0.0" + +nan@2.13.2: + version "2.13.2" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.13.2.tgz#f51dc7ae66ba7d5d55e1e6d4d8092e802c9aefe7" + integrity sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw== + +nan@^2.14.0: + version "2.14.2" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19" + integrity sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ== + +nano-json-stream-parser@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz#0cc8f6d0e2b622b479c40d499c46d64b755c6f5f" + integrity sha1-DMj20OK2IrR5xA1JnEbWS3Vcb18= + +nanoid@3.1.20: + version "3.1.20" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.20.tgz#badc263c6b1dcf14b71efaa85f6ab4c1d6cfc788" + integrity sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw== + +nanomatch@^1.2.9: + version "1.2.13" + resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" + integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + define-property "^2.0.2" + extend-shallow "^3.0.2" + fragment-cache "^0.2.1" + is-windows "^1.0.2" + kind-of "^6.0.2" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +napi-build-utils@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.2.tgz#b1fddc0b2c46e380a0b7a76f984dd47c41a13806" + integrity sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg== + +negotiator@0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb" + integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw== + +next-tick@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" + integrity sha1-yobR/ogoFpsBICCOPchCS524NCw= + +nice-try@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" + integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== + +node-abi@^2.18.0, node-abi@^2.7.0: + version "2.19.3" + resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.19.3.tgz#252f5dcab12dad1b5503b2d27eddd4733930282d" + integrity sha512-9xZrlyfvKhWme2EXFKQhZRp1yNWT/uI1luYPr3sFl+H4keYY4xR+1jO7mvTTijIsHf1M+QDe9uWuKeEpLInIlg== + dependencies: + semver "^5.4.1" + +node-addon-api@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32" + integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA== + +node-addon-api@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.1.0.tgz#98b21931557466c6729e51cb77cd39c965f42239" + integrity sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw== + +node-environment-flags@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.6.tgz#a30ac13621f6f7d674260a54dede048c3982c088" + integrity sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw== + dependencies: + object.getownpropertydescriptors "^2.0.3" + semver "^5.7.0" + +node-fetch@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5" + integrity sha1-q4hOjn5X44qUR1POxwb3iNF2i7U= + +node-fetch@^2.6.0, node-fetch@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" + integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== + +node-fetch@~1.7.1: + version "1.7.3" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" + integrity sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ== + dependencies: + encoding "^0.1.11" + is-stream "^1.0.1" + +node-gyp-build@^4.2.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.2.3.tgz#ce6277f853835f718829efb47db20f3e4d9c4739" + integrity sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg== + +node-hid@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/node-hid/-/node-hid-1.3.0.tgz#346a468505cee13d69ccd760052cbaf749f66a41" + integrity sha512-BA6G4V84kiNd1uAChub/Z/5s/xS3EHBCxotQ0nyYrUG65mXewUDHE1tWOSqA2dp3N+mV0Ffq9wo2AW9t4p/G7g== + dependencies: + bindings "^1.5.0" + nan "^2.14.0" + node-abi "^2.18.0" + prebuild-install "^5.3.4" + +node-hid@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/node-hid/-/node-hid-2.1.1.tgz#f83c8aa0bb4e6758b5f7383542477da93f67359d" + integrity sha512-Skzhqow7hyLZU93eIPthM9yjot9lszg9xrKxESleEs05V2NcbUptZc5HFqzjOkSmL0sFlZFr3kmvaYebx06wrw== + dependencies: + bindings "^1.5.0" + node-addon-api "^3.0.2" + prebuild-install "^6.0.0" + +noms@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/noms/-/noms-0.0.0.tgz#da8ebd9f3af9d6760919b27d9cdc8092a7332859" + integrity sha1-2o69nzr51nYJGbJ9nNyAkqczKFk= + dependencies: + inherits "^2.0.1" + readable-stream "~1.0.31" + +noop-logger@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/noop-logger/-/noop-logger-0.1.1.tgz#94a2b1633c4f1317553007d8966fd0e841b6a4c2" + integrity sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI= + +normalize-package-data@^2.3.2: + version "2.5.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" + integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== + dependencies: + hosted-git-info "^2.1.4" + resolve "^1.10.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +normalize-url@^4.1.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129" + integrity sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ== + +npmlog@^4.0.1: + version "4.1.2" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" + integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.7.3" + set-blocking "~2.0.0" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= + +number-to-bn@1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/number-to-bn/-/number-to-bn-1.7.0.tgz#bb3623592f7e5f9e0030b1977bd41a0c53fe1ea0" + integrity sha1-uzYjWS9+X54AMLGXe9QaDFP+HqA= + dependencies: + bn.js "4.11.6" + strip-hex-prefix "1.0.0" + +oauth-sign@~0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" + integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== + +object-assign@^4, object-assign@^4.0.0, object-assign@^4.1.0, object-assign@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= + +object-copy@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" + integrity sha1-fn2Fi3gb18mRpBupde04EnVOmYw= + dependencies: + copy-descriptor "^0.1.0" + define-property "^0.2.5" + kind-of "^3.0.3" + +object-inspect@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.9.0.tgz#c90521d74e1127b67266ded3394ad6116986533a" + integrity sha512-i3Bp9iTqwhaLZBxGkRfo5ZbE07BQRT7MGu8+nNgwW9ItGp1TzCTw2DLEoWwjClxBjOFI/hWljTAmYGCEwmtnOw== + +object-inspect@~1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67" + integrity sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw== + +object-is@^1.0.1: + version "1.1.4" + resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.4.tgz#63d6c83c00a43f4cbc9434eb9757c8a5b8565068" + integrity sha512-1ZvAZ4wlF7IyPVOcE1Omikt7UpaFlOQq0HlSti+ZvDH3UiD2brwGMwDbyV43jao2bKJ+4+WdPJHSd7kgzKYVqg== + dependencies: + call-bind "^1.0.0" + define-properties "^1.1.3" + +object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" + integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== + +object-keys@~0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-0.4.0.tgz#28a6aae7428dd2c3a92f3d95f21335dd204e0336" + integrity sha1-KKaq50KN0sOpLz2V8hM13SBOAzY= + +object-visit@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" + integrity sha1-95xEk68MU3e1n+OdOV5BBC3QRbs= + dependencies: + isobject "^3.0.0" + +object.assign@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" + integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w== + dependencies: + define-properties "^1.1.2" + function-bind "^1.1.1" + has-symbols "^1.0.0" + object-keys "^1.0.11" + +object.assign@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940" + integrity sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ== + dependencies: + call-bind "^1.0.0" + define-properties "^1.1.3" + has-symbols "^1.0.1" + object-keys "^1.1.1" + +object.getownpropertydescriptors@^2.0.3, object.getownpropertydescriptors@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.1.tgz#0dfda8d108074d9c563e80490c883b6661091544" + integrity sha512-6DtXgZ/lIZ9hqx4GtZETobXLR/ZLaa0aqV0kzbn80Rf8Z2e/XFnhA0I7p07N2wH8bBBltr2xQPi6sbKWAY2Eng== + dependencies: + call-bind "^1.0.0" + define-properties "^1.1.3" + es-abstract "^1.18.0-next.1" + +object.pick@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" + integrity sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c= + dependencies: + isobject "^3.0.1" + +oboe@2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/oboe/-/oboe-2.1.4.tgz#20c88cdb0c15371bb04119257d4fdd34b0aa49f6" + integrity sha1-IMiM2wwVNxuwQRklfU/dNLCqSfY= + dependencies: + http-https "^1.0.0" + +on-finished@~2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + integrity sha1-IPEzZIGwg811M3mSoWlxqi2QaUc= + dependencies: + ee-first "1.1.1" + +once@^1.3.0, once@^1.3.1, once@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + dependencies: + wrappy "1" + +os-homedir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= + +os-locale@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-1.4.0.tgz#20f9f17ae29ed345e8bde583b13d2009803c14d9" + integrity sha1-IPnxeuKe00XoveWDsT0gCYA8FNk= + dependencies: + lcid "^1.0.0" + +os-tmpdir@^1.0.1, os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= + +p-cancelable@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-0.3.0.tgz#b9e123800bcebb7ac13a479be195b507b98d30fa" + integrity sha512-RVbZPLso8+jFeq1MfNvgXtCRED2raz/dKpacfTNxsx6pLEpEomM7gah6VeHSYV3+vo0OAi4MkArtQcWWXuQoyw== + +p-cancelable@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-1.1.0.tgz#d078d15a3af409220c886f1d9a0ca2e441ab26cc" + integrity sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw== + +p-finally@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= + +p-limit@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" + integrity sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q== + dependencies: + p-try "^1.0.0" + +p-limit@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" + integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + dependencies: + p-try "^2.0.0" + +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" + integrity sha1-IKAQOyIqcMj9OcwuWAaA893l7EM= + dependencies: + p-limit "^1.1.0" + +p-locate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" + integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== + dependencies: + p-limit "^2.0.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + +p-timeout@^1.1.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-1.2.1.tgz#5eb3b353b7fce99f101a1038880bb054ebbea386" + integrity sha1-XrOzU7f86Z8QGhA4iAuwVOu+o4Y= + dependencies: + p-finally "^1.0.0" + +p-try@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" + integrity sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M= + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +parse-asn1@^5.0.0, parse-asn1@^5.1.5: + version "5.1.6" + resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.6.tgz#385080a3ec13cb62a62d39409cb3e88844cdaed4" + integrity sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw== + dependencies: + asn1.js "^5.2.0" + browserify-aes "^1.0.0" + evp_bytestokey "^1.0.0" + pbkdf2 "^3.0.3" + safe-buffer "^5.1.1" + +parse-headers@^2.0.0: + version "2.0.3" + resolved "https://registry.yarnpkg.com/parse-headers/-/parse-headers-2.0.3.tgz#5e8e7512383d140ba02f0c7aa9f49b4399c92515" + integrity sha512-QhhZ+DCCit2Coi2vmAKbq5RGTRcQUOE2+REgv8vdyu7MnYx2eZztegqtTx99TZ86GTIwqiy3+4nQTWZ2tgmdCA== + +parse-json@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + integrity sha1-9ID0BDTvgHQfhGkJn43qGPVaTck= + dependencies: + error-ex "^1.2.0" + +parseurl@~1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" + integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== + +pascalcase@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" + integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= + +patch-package@6.2.2, patch-package@^6.2.2: + version "6.2.2" + resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.2.2.tgz#71d170d650c65c26556f0d0fbbb48d92b6cc5f39" + integrity sha512-YqScVYkVcClUY0v8fF0kWOjDYopzIM8e3bj/RU1DPeEF14+dCGm6UeOYm4jvCyxqIEQ5/eJzmbWfDWnUleFNMg== + dependencies: + "@yarnpkg/lockfile" "^1.1.0" + chalk "^2.4.2" + cross-spawn "^6.0.5" + find-yarn-workspace-root "^1.2.1" + fs-extra "^7.0.1" + is-ci "^2.0.0" + klaw-sync "^6.0.0" + minimist "^1.2.0" + rimraf "^2.6.3" + semver "^5.6.0" + slash "^2.0.0" + tmp "^0.0.33" + +path-browserify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd" + integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g== + +path-exists@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + integrity sha1-D+tsZPD8UY2adU3V77YscCJ2H0s= + dependencies: + pinkie-promise "^2.0.0" + +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + +path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + +path-key@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= + +path-parse@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" + integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== + +path-to-regexp@0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" + integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w= + +path-type@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + integrity sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE= + dependencies: + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +pathval@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" + integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== + +pbkdf2@^3.0.17, pbkdf2@^3.0.3, pbkdf2@^3.0.9: + version "3.1.1" + resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.1.tgz#cb8724b0fada984596856d1a6ebafd3584654b94" + integrity sha512-4Ejy1OPxi9f2tt1rRV7Go7zmfDQ+ZectEQz3VGUQhgq62HtIRPDyG/JtnwIxs6x3uNMwo2V7q1fMvKjb+Tnpqg== + dependencies: + create-hash "^1.1.2" + create-hmac "^1.1.4" + ripemd160 "^2.0.1" + safe-buffer "^5.0.1" + sha.js "^2.4.8" + +performance-now@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= + +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.2.2" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" + integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== + +pify@^2.0.0, pify@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + integrity sha1-ITXW36ejWMBprJsXh3YogihFD/o= + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA= + +pino-std-serializers@^3.1.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-3.2.0.tgz#b56487c402d882eb96cd67c257868016b61ad671" + integrity sha512-EqX4pwDPrt3MuOAAUBMU0Tk5kR/YcCM5fNPEzgCO2zJ5HfX0vbiH9HbJglnyeQsN96Kznae6MWD47pZB5avTrg== + +pino@^6.11.1: + version "6.11.2" + resolved "https://registry.yarnpkg.com/pino/-/pino-6.11.2.tgz#2f3d119c526651aab4ec3d280844785d52d0b690" + integrity sha512-bmzxwbrIPxQUlAuMkF4PWVErUGERU4z37HazlhflKFg08crsNE3fACGN6gPwg5xtKOK47Ux5cZm8YCuLV4wWJg== + dependencies: + fast-redact "^3.0.0" + fast-safe-stringify "^2.0.7" + flatstr "^1.0.12" + pino-std-serializers "^3.1.0" + quick-format-unescaped "4.0.1" + sonic-boom "^1.0.2" + +posix-character-classes@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" + integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= + +postinstall-postinstall@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz#4f7f77441ef539d1512c40bd04c71b06a4704ca3" + integrity sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ== + +prebuild-install@^5.3.3, prebuild-install@^5.3.4: + version "5.3.6" + resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-5.3.6.tgz#7c225568d864c71d89d07f8796042733a3f54291" + integrity sha512-s8Aai8++QQGi4sSbs/M1Qku62PFK49Jm1CbgXklGz4nmHveDq0wzJkg7Na5QbnO1uNH8K7iqx2EQ/mV0MZEmOg== + dependencies: + detect-libc "^1.0.3" + expand-template "^2.0.3" + github-from-package "0.0.0" + minimist "^1.2.3" + mkdirp-classic "^0.5.3" + napi-build-utils "^1.0.1" + node-abi "^2.7.0" + noop-logger "^0.1.1" + npmlog "^4.0.1" + pump "^3.0.0" + rc "^1.2.7" + simple-get "^3.0.3" + tar-fs "^2.0.0" + tunnel-agent "^0.6.0" + which-pm-runs "^1.0.0" + +prebuild-install@^6.0.0: + version "6.0.1" + resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-6.0.1.tgz#5902172f7a40eb67305b96c2a695db32636ee26d" + integrity sha512-7GOJrLuow8yeiyv75rmvZyeMGzl8mdEX5gY69d6a6bHWmiPevwqFw+tQavhK0EYMaSg3/KD24cWqeQv1EWsqDQ== + dependencies: + detect-libc "^1.0.3" + expand-template "^2.0.3" + github-from-package "0.0.0" + minimist "^1.2.3" + mkdirp-classic "^0.5.3" + napi-build-utils "^1.0.1" + node-abi "^2.7.0" + noop-logger "^0.1.1" + npmlog "^4.0.1" + pump "^3.0.0" + rc "^1.2.7" + simple-get "^3.0.3" + tar-fs "^2.0.0" + tunnel-agent "^0.6.0" + which-pm-runs "^1.0.0" + +precond@0.2: + version "0.2.3" + resolved "https://registry.yarnpkg.com/precond/-/precond-0.2.3.tgz#aa9591bcaa24923f1e0f4849d240f47efc1075ac" + integrity sha1-qpWRvKokkj8eD0hJ0kD0fvwQdaw= + +prepend-http@^1.0.1: + version "1.0.4" + resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" + integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= + +prepend-http@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" + integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= + +prettier@^1.14.2: + version "1.19.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" + integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== + +prettier@^2.1.2, prettier@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5" + integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q== + +private@^0.1.6, private@^0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" + integrity sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg== + +process-nextick-args@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== + +process@^0.11.10: + version "0.11.10" + resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" + integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= + +promise-to-callback@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/promise-to-callback/-/promise-to-callback-1.0.0.tgz#5d2a749010bfb67d963598fcd3960746a68feef7" + integrity sha1-XSp0kBC/tn2WNZj805YHRqaP7vc= + dependencies: + is-fn "^1.0.0" + set-immediate-shim "^1.0.1" + +proxy-addr@~2.0.5: + version "2.0.6" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.6.tgz#fdc2336505447d3f2f2c638ed272caf614bbb2bf" + integrity sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw== + dependencies: + forwarded "~0.1.2" + ipaddr.js "1.9.1" + +prr@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" + integrity sha1-0/wRS6BplaRexok/SEzrHXj19HY= + +pseudomap@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= + +psl@^1.1.28: + version "1.8.0" + resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" + integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ== + +public-encrypt@^4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" + integrity sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q== + dependencies: + bn.js "^4.1.0" + browserify-rsa "^4.0.0" + create-hash "^1.1.0" + parse-asn1 "^5.0.0" + randombytes "^2.0.1" + safe-buffer "^5.1.2" + +pull-cat@^1.1.9: + version "1.1.11" + resolved "https://registry.yarnpkg.com/pull-cat/-/pull-cat-1.1.11.tgz#b642dd1255da376a706b6db4fa962f5fdb74c31b" + integrity sha1-tkLdElXaN2pwa220+pYvX9t0wxs= + +pull-defer@^0.2.2: + version "0.2.3" + resolved "https://registry.yarnpkg.com/pull-defer/-/pull-defer-0.2.3.tgz#4ee09c6d9e227bede9938db80391c3dac489d113" + integrity sha512-/An3KE7mVjZCqNhZsr22k1Tx8MACnUnHZZNPSJ0S62td8JtYr/AiRG42Vz7Syu31SoTLUzVIe61jtT/pNdjVYA== + +pull-level@^2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pull-level/-/pull-level-2.0.4.tgz#4822e61757c10bdcc7cf4a03af04c92734c9afac" + integrity sha512-fW6pljDeUThpq5KXwKbRG3X7Ogk3vc75d5OQU/TvXXui65ykm+Bn+fiktg+MOx2jJ85cd+sheufPL+rw9QSVZg== + dependencies: + level-post "^1.0.7" + pull-cat "^1.1.9" + pull-live "^1.0.1" + pull-pushable "^2.0.0" + pull-stream "^3.4.0" + pull-window "^2.1.4" + stream-to-pull-stream "^1.7.1" + +pull-live@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/pull-live/-/pull-live-1.0.1.tgz#a4ecee01e330155e9124bbbcf4761f21b38f51f5" + integrity sha1-pOzuAeMwFV6RJLu89HYfIbOPUfU= + dependencies: + pull-cat "^1.1.9" + pull-stream "^3.4.0" + +pull-pushable@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/pull-pushable/-/pull-pushable-2.2.0.tgz#5f2f3aed47ad86919f01b12a2e99d6f1bd776581" + integrity sha1-Xy867UethpGfAbEqLpnW8b13ZYE= + +pull-stream@^3.2.3, pull-stream@^3.4.0, pull-stream@^3.6.8: + version "3.6.14" + resolved "https://registry.yarnpkg.com/pull-stream/-/pull-stream-3.6.14.tgz#529dbd5b86131f4a5ed636fdf7f6af00781357ee" + integrity sha512-KIqdvpqHHaTUA2mCYcLG1ibEbu/LCKoJZsBWyv9lSYtPkJPBq8m3Hxa103xHi6D2thj5YXa0TqK3L3GUkwgnew== + +pull-window@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/pull-window/-/pull-window-2.1.4.tgz#fc3b86feebd1920c7ae297691e23f705f88552f0" + integrity sha1-/DuG/uvRkgx64pdpHiP3BfiFUvA= + dependencies: + looper "^2.0.0" + +pump@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" + integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +punycode@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" + integrity sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0= + +punycode@2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.0.tgz#5f863edc89b96db09074bad7947bf09056ca4e7d" + integrity sha1-X4Y+3Im5bbCQdLrXlHvwkFbKTn0= + +punycode@^2.1.0, punycode@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" + integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== + +qs@6.7.0: + version "6.7.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" + integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== + +qs@^6.7.0: + version "6.9.6" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.6.tgz#26ed3c8243a431b2924aca84cc90471f35d5a0ee" + integrity sha512-TIRk4aqYLNoJUbd+g2lEdz5kLWIuTMRagAXxl78Q0RiVjAOugHmeKNGdd3cwo/ktpf9aL9epCfFqWDEKysUlLQ== + +qs@~6.5.2: + version "6.5.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" + integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== + +query-string@^5.0.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.1.1.tgz#a78c012b71c17e05f2e3fa2319dd330682efb3cb" + integrity sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw== + dependencies: + decode-uri-component "^0.2.0" + object-assign "^4.1.0" + strict-uri-encode "^1.0.0" + +querystring@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" + integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= + +quick-format-unescaped@4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/quick-format-unescaped/-/quick-format-unescaped-4.0.1.tgz#437a5ea1a0b61deb7605f8ab6a8fd3858dbeb701" + integrity sha512-RyYpQ6Q5/drsJyOhrWHYMWTedvjTIat+FTwv0K4yoUxzvekw2aRHMQJLlnvt8UantkZg2++bEzD9EdxXqkWf4A== + +random-bytes-seed@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/random-bytes-seed/-/random-bytes-seed-1.0.3.tgz#126f1201dba2ec70cd0784f94a810396cad24a15" + integrity sha512-O+eniMt8Sj2iAn2q1x5VEirS/XvbtwYcXNDbOAcRtGN+OhC48cmzS5ksf9qEHRVKC1I8A4qzjucNVElddofB0A== + +randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.0.6, randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + +randomfill@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/randomfill/-/randomfill-1.0.4.tgz#c92196fc86ab42be983f1bf31778224931d61458" + integrity sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw== + dependencies: + randombytes "^2.0.5" + safe-buffer "^5.1.0" + +range-parser@~1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" + integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== + +raw-body@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.0.tgz#a1ce6fb9c9bc356ca52e89256ab59059e13d0332" + integrity sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q== + dependencies: + bytes "3.1.0" + http-errors "1.7.2" + iconv-lite "0.4.24" + unpipe "1.0.0" + +raw-body@^2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.1.tgz#30ac82f98bb5ae8c152e67149dac8d55153b168c" + integrity sha512-9WmIKF6mkvA0SLmA2Knm9+qj89e+j1zqgyn8aXGd7+nAduPoqgI9lO57SAZNn/Byzo5P7JhXTyg9PzaJbH73bA== + dependencies: + bytes "3.1.0" + http-errors "1.7.3" + iconv-lite "0.4.24" + unpipe "1.0.0" + +rc@^1.2.7: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + +read-pkg-up@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + integrity sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI= + dependencies: + find-up "^1.0.0" + read-pkg "^1.0.0" + +read-pkg@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + integrity sha1-9f+qXs0pyzHAR0vKfXVra7KePyg= + dependencies: + load-json-file "^1.0.0" + normalize-package-data "^2.3.2" + path-type "^1.0.0" + +readable-stream@^1.0.33: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + integrity sha1-fPTFTvZI44EwhMY23SB54WbAgdk= + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@^2.0.0, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.2.2, readable-stream@^2.2.8, readable-stream@^2.2.9, readable-stream@^2.3.6, readable-stream@~2.3.6: + version "2.3.7" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" + integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + +readable-stream@^3.0.6, readable-stream@^3.1.0, readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" + integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +readable-stream@~1.0.15, readable-stream@~1.0.31: + version "1.0.34" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" + integrity sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw= + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readdirp@~3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.2.0.tgz#c30c33352b12c96dfb4b895421a49fd5a9593839" + integrity sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ== + dependencies: + picomatch "^2.0.4" + +readdirp@~3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.5.0.tgz#9ba74c019b15d365278d2e91bb8c48d7b4d42c9e" + integrity sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ== + dependencies: + picomatch "^2.2.1" + +regenerate@^1.2.1: + version "1.4.2" + resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" + integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== + +regenerator-runtime@^0.11.0: + version "0.11.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" + integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== + +regenerator-transform@^0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.10.1.tgz#1e4996837231da8b7f3cf4114d71b5691a0680dd" + integrity sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q== + dependencies: + babel-runtime "^6.18.0" + babel-types "^6.19.0" + private "^0.1.6" + +regex-not@^1.0.0, regex-not@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" + integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== + dependencies: + extend-shallow "^3.0.2" + safe-regex "^1.1.0" + +regexp.prototype.flags@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.3.1.tgz#7ef352ae8d159e758c0eadca6f8fcb4eef07be26" + integrity sha512-JiBdRBq91WlY7uRJ0ds7R+dU02i6LKi8r3BuQhNXn+kmeLN+EfHhfjqMRis1zJxnlu88hq/4dx0P2OP3APRTOA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + +regexpu-core@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240" + integrity sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA= + dependencies: + regenerate "^1.2.1" + regjsgen "^0.2.0" + regjsparser "^0.1.4" + +regjsgen@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" + integrity sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc= + +regjsparser@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.1.5.tgz#7ee8f84dc6fa792d3fd0ae228d24bd949ead205c" + integrity sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw= + dependencies: + jsesc "~0.5.0" + +repeat-element@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce" + integrity sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g== + +repeat-string@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + integrity sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo= + dependencies: + is-finite "^1.0.0" + +request@^2.79.0, request@^2.85.0: + version "2.88.2" + resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" + integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.8.0" + caseless "~0.12.0" + combined-stream "~1.0.6" + extend "~3.0.2" + forever-agent "~0.6.1" + form-data "~2.3.2" + har-validator "~5.1.3" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.19" + oauth-sign "~0.9.0" + performance-now "^2.1.0" + qs "~6.5.2" + safe-buffer "^5.1.2" + tough-cookie "~2.5.0" + tunnel-agent "^0.6.0" + uuid "^3.3.2" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= + +require-from-string@^1.1.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-1.2.1.tgz#529c9ccef27380adfec9a2f965b649bbee636418" + integrity sha1-UpyczvJzgK3+yaL5ZbZJu+5jZBg= + +require-from-string@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" + integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== + +require-main-filename@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" + integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE= + +require-main-filename@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" + integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== + +resolve-url@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" + integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= + +resolve@1.17.0, resolve@~1.17.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" + integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + dependencies: + path-parse "^1.0.6" + +resolve@^1.10.0, resolve@^1.3.2, resolve@^1.8.1: + version "1.20.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" + integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== + dependencies: + is-core-module "^2.2.0" + path-parse "^1.0.6" + +responselike@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7" + integrity sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec= + dependencies: + lowercase-keys "^1.0.0" + +resumer@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759" + integrity sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k= + dependencies: + through "~2.3.4" + +ret@~0.1.10: + version "0.1.15" + resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" + integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== + +rimraf@^2.2.8, rimraf@^2.6.3: + version "2.7.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" + integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== + dependencies: + glob "^7.1.3" + +rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== + dependencies: + glob "^7.1.3" + +ripemd160@^2.0.0, ripemd160@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" + integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== + dependencies: + hash-base "^3.0.0" + inherits "^2.0.1" + +rlp@^2.0.0, rlp@^2.2.1, rlp@^2.2.2, rlp@^2.2.3, rlp@^2.2.4, rlp@^2.2.6: + version "2.2.6" + resolved "https://registry.yarnpkg.com/rlp/-/rlp-2.2.6.tgz#c80ba6266ac7a483ef1e69e8e2f056656de2fb2c" + integrity sha512-HAfAmL6SDYNWPUOJNrM500x4Thn4PZsEy5pijPh40U9WfNk0z15hUYzO9xVIMAdIHdFtD8CBDHd75Td1g36Mjg== + dependencies: + bn.js "^4.11.1" + +rustbn.js@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/rustbn.js/-/rustbn.js-0.2.0.tgz#8082cb886e707155fd1cb6f23bd591ab8d55d0ca" + integrity sha512-4VlvkRUuCJvr2J6Y0ImW7NvTCriMi7ErOAqWk1y69vAdoNIzCF3yPmgeNzx+RQTLEDFq5sHfscn1MwHxP9hNfA== + +rxjs@^6.6.3: + version "6.6.3" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552" + integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ== + dependencies: + tslib "^1.9.0" + +safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + +safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +safe-event-emitter@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/safe-event-emitter/-/safe-event-emitter-1.0.1.tgz#5b692ef22329ed8f69fdce607e50ca734f6f20af" + integrity sha512-e1wFe99A91XYYxoQbcq2ZJUWurxEyP8vfz7A7vuUe1s95q8r5ebraVaA1BukYJcpM6V16ugWoD9vngi8Ccu5fg== + dependencies: + events "^3.0.0" + +safe-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" + integrity sha1-QKNmnzsHfR6UPURinhV91IAjvy4= + dependencies: + ret "~0.1.10" + +"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +scrypt-js@3.0.1, scrypt-js@^3.0.0, scrypt-js@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-3.0.1.tgz#d314a57c2aef69d1ad98a138a21fe9eafa9ee312" + integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== + +scryptsy@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/scryptsy/-/scryptsy-1.2.1.tgz#a3225fa4b2524f802700761e2855bdf3b2d92163" + integrity sha1-oyJfpLJST4AnAHYeKFW987LZIWM= + dependencies: + pbkdf2 "^3.0.3" + +secp256k1@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.2.tgz#15dd57d0f0b9fdb54ac1fa1694f40e5e9a54f4a1" + integrity sha512-UDar4sKvWAksIlfX3xIaQReADn+WFnHvbVujpcbr+9Sf/69odMwy2MUsz5CKLQgX9nsIyrjuxL2imVyoNHa3fg== + dependencies: + elliptic "^6.5.2" + node-addon-api "^2.0.0" + node-gyp-build "^4.2.0" + +seedrandom@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.1.tgz#eb3dde015bcf55df05a233514e5df44ef9dce083" + integrity sha512-1/02Y/rUeU1CJBAGLebiC5Lbo5FnB22gQbIFFYTLkwvp1xdABZJH1sn4ZT1MzXmPpzv+Rf/Lu2NcsLJiK4rcDg== + +semaphore-async-await@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/semaphore-async-await/-/semaphore-async-await-1.5.1.tgz#857bef5e3644601ca4b9570b87e9df5ca12974fa" + integrity sha1-hXvvXjZEYBykuVcLh+nfXKEpdPo= + +semaphore@>=1.0.1, semaphore@^1.0.3, semaphore@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/semaphore/-/semaphore-1.1.0.tgz#aaad8b86b20fe8e9b32b16dc2ee682a8cd26a8aa" + integrity sha512-O4OZEaNtkMd/K0i6js9SL+gqy0ZCBMgUvlSqHKi4IBdjhe7wB8pwztUk1BbZ1fmrvpwFrPbHzqd2w5pTcJH6LA== + +"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.6.0, semver@^5.7.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + +semver@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" + integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + +semver@^7.3.4: + version "7.3.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97" + integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw== + dependencies: + lru-cache "^6.0.0" + +semver@~5.4.1: + version "5.4.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" + integrity sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg== + +send@0.17.1: + version "0.17.1" + resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8" + integrity sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg== + dependencies: + debug "2.6.9" + depd "~1.1.2" + destroy "~1.0.4" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "~1.7.2" + mime "1.6.0" + ms "2.1.1" + on-finished "~2.3.0" + range-parser "~1.2.1" + statuses "~1.5.0" + +serialize-javascript@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-5.0.1.tgz#7886ec848049a462467a97d3d918ebb2aaf934f4" + integrity sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA== + dependencies: + randombytes "^2.1.0" + +serve-static@1.14.1: + version "1.14.1" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.1.tgz#666e636dc4f010f7ef29970a88a674320898b2f9" + integrity sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg== + dependencies: + encodeurl "~1.0.2" + escape-html "~1.0.3" + parseurl "~1.3.3" + send "0.17.1" + +servify@^0.1.12: + version "0.1.12" + resolved "https://registry.yarnpkg.com/servify/-/servify-0.1.12.tgz#142ab7bee1f1d033b66d0707086085b17c06db95" + integrity sha512-/xE6GvsKKqyo1BAY+KxOWXcLpPsUUyji7Qg3bVD7hh1eRze5bR1uYiuDA/k3Gof1s9BTzQZEJK8sNcNGFIzeWw== + dependencies: + body-parser "^1.16.0" + cors "^2.8.1" + express "^4.14.0" + request "^2.79.0" + xhr "^2.3.3" + +set-blocking@^2.0.0, set-blocking@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= + +set-immediate-shim@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" + integrity sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E= + +set-value@^2.0.0, set-value@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b" + integrity sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw== + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.3" + split-string "^3.0.1" + +setimmediate@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" + integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= + +setprototypeof@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683" + integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw== + +sha.js@^2.4.0, sha.js@^2.4.8: + version "2.4.11" + resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" + integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ== + dependencies: + inherits "^2.0.1" + safe-buffer "^5.0.1" + +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= + dependencies: + shebang-regex "^1.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= + +signal-exit@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" + integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== + +simple-concat@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.1.tgz#f46976082ba35c2263f1c8ab5edfe26c41c9552f" + integrity sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q== + +simple-get@^2.7.0: + version "2.8.1" + resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-2.8.1.tgz#0e22e91d4575d87620620bc91308d57a77f44b5d" + integrity sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw== + dependencies: + decompress-response "^3.3.0" + once "^1.3.1" + simple-concat "^1.0.0" + +simple-get@^3.0.3: + version "3.1.0" + resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-3.1.0.tgz#b45be062435e50d159540b576202ceec40b9c6b3" + integrity sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA== + dependencies: + decompress-response "^4.2.0" + once "^1.3.1" + simple-concat "^1.0.0" + +slash@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" + integrity sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU= + +slash@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44" + integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A== + +slash@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" + integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== + +snapdragon-node@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" + integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw== + dependencies: + define-property "^1.0.0" + isobject "^3.0.0" + snapdragon-util "^3.0.1" + +snapdragon-util@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" + integrity sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ== + dependencies: + kind-of "^3.2.0" + +snapdragon@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d" + integrity sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg== + dependencies: + base "^0.11.1" + debug "^2.2.0" + define-property "^0.2.5" + extend-shallow "^2.0.1" + map-cache "^0.2.2" + source-map "^0.5.6" + source-map-resolve "^0.5.0" + use "^3.1.0" + +solc@0.7.3: + version "0.7.3" + resolved "https://registry.yarnpkg.com/solc/-/solc-0.7.3.tgz#04646961bd867a744f63d2b4e3c0701ffdc7d78a" + integrity sha512-GAsWNAjGzIDg7VxzP6mPjdurby3IkGCjQcM8GFYZT6RyaoUZKmMU6Y7YwG+tFGhv7dwZ8rmR4iwFDrrD99JwqA== + dependencies: + command-exists "^1.2.8" + commander "3.0.2" + follow-redirects "^1.12.1" + fs-extra "^0.30.0" + js-sha3 "0.8.0" + memorystream "^0.3.1" + require-from-string "^2.0.0" + semver "^5.5.0" + tmp "0.0.33" + +solc@^0.4.20: + version "0.4.26" + resolved "https://registry.yarnpkg.com/solc/-/solc-0.4.26.tgz#5390a62a99f40806b86258c737c1cf653cc35cb5" + integrity sha512-o+c6FpkiHd+HPjmjEVpQgH7fqZ14tJpXhho+/bQXlXbliLIS/xjXb42Vxh+qQY1WCSTMQ0+a5vR9vi0MfhU6mA== + dependencies: + fs-extra "^0.30.0" + memorystream "^0.3.1" + require-from-string "^1.1.0" + semver "^5.3.0" + yargs "^4.7.1" + +solc@^0.6.3: + version "0.6.12" + resolved "https://registry.yarnpkg.com/solc/-/solc-0.6.12.tgz#48ac854e0c729361b22a7483645077f58cba080e" + integrity sha512-Lm0Ql2G9Qc7yPP2Ba+WNmzw2jwsrd3u4PobHYlSOxaut3TtUbj9+5ZrT6f4DUpNPEoBaFUOEg9Op9C0mk7ge9g== + dependencies: + command-exists "^1.2.8" + commander "3.0.2" + fs-extra "^0.30.0" + js-sha3 "0.8.0" + memorystream "^0.3.1" + require-from-string "^2.0.0" + semver "^5.5.0" + tmp "0.0.33" + +sonic-boom@^1.0.2: + version "1.4.0" + resolved "https://registry.yarnpkg.com/sonic-boom/-/sonic-boom-1.4.0.tgz#d6d35196c32609b46193145afc1174a8c692d21e" + integrity sha512-1xUAszhQBOrjk7uisbStQZYkZxD3vkYlCUw5qzOblWQ1ILN5v0dVPAs+QPgszzoPmbdWx6jyT9XiLJ95JdlLiQ== + dependencies: + atomic-sleep "^1.0.0" + flatstr "^1.0.12" + +source-map-resolve@^0.5.0: + version "0.5.3" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a" + integrity sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw== + dependencies: + atob "^2.1.2" + decode-uri-component "^0.2.0" + resolve-url "^0.2.1" + source-map-url "^0.4.0" + urix "^0.1.0" + +source-map-support@0.5.12: + version "0.5.12" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.12.tgz#b4f3b10d51857a5af0138d3ce8003b201613d599" + integrity sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map-support@^0.4.15: + version "0.4.18" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" + integrity sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA== + dependencies: + source-map "^0.5.6" + +source-map-support@^0.5.13, source-map-support@^0.5.17: + version "0.5.19" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" + integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map-url@^0.4.0: + version "0.4.1" + resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.1.tgz#0af66605a745a5a2f91cf1bbf8a7afbc283dec56" + integrity sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw== + +source-map@^0.5.6, source-map@^0.5.7: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +spdx-correct@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" + integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== + dependencies: + spdx-expression-parse "^3.0.0" + spdx-license-ids "^3.0.0" + +spdx-exceptions@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" + integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== + +spdx-expression-parse@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" + integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" + +spdx-license-ids@^3.0.0: + version "3.0.7" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.7.tgz#e9c18a410e5ed7e12442a549fbd8afa767038d65" + integrity sha512-U+MTEOO0AiDzxwFvoa4JVnMV6mZlJKk2sBLt90s7G0Gd0Mlknc7kxEn3nuDPNZRta7O2uy8oLcZLVT+4sqNZHQ== + +split-string@^3.0.1, split-string@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" + integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw== + dependencies: + extend-shallow "^3.0.0" + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= + +sshpk@^1.7.0: + version "1.16.1" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877" + integrity sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg== + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + bcrypt-pbkdf "^1.0.0" + dashdash "^1.12.0" + ecc-jsbn "~0.1.1" + getpass "^0.1.1" + jsbn "~0.1.0" + safer-buffer "^2.0.2" + tweetnacl "~0.14.0" + +stacktrace-parser@^0.1.10: + version "0.1.10" + resolved "https://registry.yarnpkg.com/stacktrace-parser/-/stacktrace-parser-0.1.10.tgz#29fb0cae4e0d0b85155879402857a1639eb6051a" + integrity sha512-KJP1OCML99+8fhOHxwwzyWrlUuVX5GQ0ZpJTd1DFXhdkrvg1szxfHhawXUZ3g9TkXORQd4/WG68jMlQZ2p8wlg== + dependencies: + type-fest "^0.7.1" + +static-extend@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" + integrity sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY= + dependencies: + define-property "^0.2.5" + object-copy "^0.1.0" + +"statuses@>= 1.5.0 < 2", statuses@~1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" + integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= + +stream-to-pull-stream@^1.7.1: + version "1.7.3" + resolved "https://registry.yarnpkg.com/stream-to-pull-stream/-/stream-to-pull-stream-1.7.3.tgz#4161aa2d2eb9964de60bfa1af7feaf917e874ece" + integrity sha512-6sNyqJpr5dIOQdgNy/xcDWwDuzAsAwVzhzrWlAPAQ7Lkjx/rv0wgvxEyKwTq6FmNd5rjTrELt/CLmaSw7crMGg== + dependencies: + looper "^3.0.0" + pull-stream "^3.2.3" + +strict-uri-encode@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" + integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM= + +string-width@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M= + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +"string-width@^1.0.2 || 2": + version "2.1.1" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" + integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" + +string-width@^3.0.0, string-width@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" + integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== + dependencies: + emoji-regex "^7.0.1" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^5.1.0" + +string-width@^4.1.0, string-width@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" + integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.0" + +string.prototype.trim@~1.2.1: + version "1.2.3" + resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.2.3.tgz#d23a22fde01c1e6571a7fadcb9be11decd8061a7" + integrity sha512-16IL9pIBA5asNOSukPfxX2W68BaBvxyiRK16H3RA/lWW9BDosh+w7f+LhomPHpXJ82QEe7w7/rY/S1CV97raLg== + dependencies: + call-bind "^1.0.0" + define-properties "^1.1.3" + es-abstract "^1.18.0-next.1" + +string.prototype.trimend@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.3.tgz#a22bd53cca5c7cf44d7c9d5c732118873d6cd18b" + integrity sha512-ayH0pB+uf0U28CtjlLvL7NaohvR1amUvVZk+y3DYb0Ey2PUV5zPkkKy9+U1ndVEIXO8hNg18eIv9Jntbii+dKw== + dependencies: + call-bind "^1.0.0" + define-properties "^1.1.3" + +string.prototype.trimstart@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.3.tgz#9b4cb590e123bb36564401d59824298de50fd5aa" + integrity sha512-oBIBUy5lea5tt0ovtOFiEQaBkoBBkyJhZXzJYrSmDo5IUUqbOPvVezuRs/agBIdZ2p2Eo1FD6bD9USyBLfl3xg== + dependencies: + call-bind "^1.0.0" + define-properties "^1.1.3" + +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + integrity sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ= + +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= + dependencies: + ansi-regex "^2.0.0" + +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= + dependencies: + ansi-regex "^3.0.0" + +strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" + integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== + dependencies: + ansi-regex "^4.1.0" + +strip-ansi@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" + integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== + dependencies: + ansi-regex "^5.0.0" + +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + integrity sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4= + dependencies: + is-utf8 "^0.2.0" + +strip-hex-prefix@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz#0c5f155fef1151373377de9dbb588da05500e36f" + integrity sha1-DF8VX+8RUTczd96du1iNoFUA428= + dependencies: + is-hex-prefixed "1.0.0" + +strip-json-comments@2.0.1, strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + +strip-json-comments@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + +supports-color@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.0.0.tgz#76cfe742cf1f41bb9b1c29ad03068c05b4c0e40a" + integrity sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg== + dependencies: + has-flag "^3.0.0" + +supports-color@8.1.1: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +swarm-js@^0.1.40: + version "0.1.40" + resolved "https://registry.yarnpkg.com/swarm-js/-/swarm-js-0.1.40.tgz#b1bc7b6dcc76061f6c772203e004c11997e06b99" + integrity sha512-yqiOCEoA4/IShXkY3WKwP5PvZhmoOOD8clsKA7EEcRILMkTEYHCQ21HDCAcVpmIxZq4LyZvWeRJ6quIyHk1caA== + dependencies: + bluebird "^3.5.0" + buffer "^5.0.5" + eth-lib "^0.1.26" + fs-extra "^4.0.2" + got "^7.1.0" + mime-types "^2.1.16" + mkdirp-promise "^5.0.1" + mock-fs "^4.1.0" + setimmediate "^1.0.5" + tar "^4.0.2" + xhr-request "^1.0.1" + +tape@^4.6.3: + version "4.13.3" + resolved "https://registry.yarnpkg.com/tape/-/tape-4.13.3.tgz#51b3d91c83668c7a45b1a594b607dee0a0b46278" + integrity sha512-0/Y20PwRIUkQcTCSi4AASs+OANZZwqPKaipGCEwp10dQMipVvSZwUUCi01Y/OklIGyHKFhIcjock+DKnBfLAFw== + dependencies: + deep-equal "~1.1.1" + defined "~1.0.0" + dotignore "~0.1.2" + for-each "~0.3.3" + function-bind "~1.1.1" + glob "~7.1.6" + has "~1.0.3" + inherits "~2.0.4" + is-regex "~1.0.5" + minimist "~1.2.5" + object-inspect "~1.7.0" + resolve "~1.17.0" + resumer "~0.0.0" + string.prototype.trim "~1.2.1" + through "~2.3.8" + +tar-fs@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.1.tgz#489a15ab85f1f0befabb370b7de4f9eb5cbe8784" + integrity sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng== + dependencies: + chownr "^1.1.1" + mkdirp-classic "^0.5.2" + pump "^3.0.0" + tar-stream "^2.1.4" + +tar-stream@^2.1.4: + version "2.2.0" + resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-2.2.0.tgz#acad84c284136b060dc3faa64474aa9aebd77287" + integrity sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ== + dependencies: + bl "^4.0.3" + end-of-stream "^1.4.1" + fs-constants "^1.0.0" + inherits "^2.0.3" + readable-stream "^3.1.1" + +tar@^4.0.2: + version "4.4.13" + resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.13.tgz#43b364bc52888d555298637b10d60790254ab525" + integrity sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA== + dependencies: + chownr "^1.1.1" + fs-minipass "^1.2.5" + minipass "^2.8.6" + minizlib "^1.2.1" + mkdirp "^0.5.0" + safe-buffer "^5.1.2" + yallist "^3.0.3" + +test-value@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/test-value/-/test-value-2.1.0.tgz#11da6ff670f3471a73b625ca4f3fdcf7bb748291" + integrity sha1-Edpv9nDzRxpztiXKTz/c97t0gpE= + dependencies: + array-back "^1.0.3" + typical "^2.6.0" + +testrpc@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/testrpc/-/testrpc-0.0.1.tgz#83e2195b1f5873aec7be1af8cbe6dcf39edb7aed" + integrity sha512-afH1hO+SQ/VPlmaLUFj2636QMeDvPCeQMc/9RBMW0IfjNe9gFD9Ra3ShqYkB7py0do1ZcCna/9acHyzTJ+GcNA== + +through2@^2.0.1, through2@^2.0.3: + version "2.0.5" + resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" + integrity sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ== + dependencies: + readable-stream "~2.3.6" + xtend "~4.0.1" + +through@~2.3.4, through@~2.3.8: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= + +timed-out@^4.0.0, timed-out@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" + integrity sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8= + +tmp@0.0.33, tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== + dependencies: + os-tmpdir "~1.0.2" + +tmp@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.1.0.tgz#ee434a4e22543082e294ba6201dcc6eafefa2877" + integrity sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw== + dependencies: + rimraf "^2.6.3" + +to-fast-properties@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" + integrity sha1-uDVx+k2MJbguIxsG46MFXeTKGkc= + +to-object-path@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" + integrity sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68= + dependencies: + kind-of "^3.0.2" + +to-readable-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/to-readable-stream/-/to-readable-stream-1.0.0.tgz#ce0aa0c2f3df6adf852efb404a783e77c0475771" + integrity sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q== + +to-regex-range@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" + integrity sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg= + dependencies: + is-number "^3.0.0" + repeat-string "^1.6.1" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +to-regex@^3.0.1, to-regex@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" + integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== + dependencies: + define-property "^2.0.2" + extend-shallow "^3.0.2" + regex-not "^1.0.2" + safe-regex "^1.1.0" + +toidentifier@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" + integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== + +tough-cookie@~2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" + integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== + dependencies: + psl "^1.1.28" + punycode "^2.1.1" + +treeify@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/treeify/-/treeify-1.1.0.tgz#4e31c6a463accd0943879f30667c4fdaff411bb8" + integrity sha512-1m4RA7xVAJrSGrrXGs0L3YTwyvBs2S8PbRHaLZAkFw7JR8oIFwYtysxlBZhYIa7xSyiYJKZ3iGrrk55cGA3i9A== + +trim-right@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" + integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= + +"true-case-path@^2.2.1": + version "2.2.1" + resolved "https://registry.yarnpkg.com/true-case-path/-/true-case-path-2.2.1.tgz#c5bf04a5bbec3fd118be4084461b3a27c4d796bf" + integrity sha512-0z3j8R7MCjy10kc/g+qg7Ln3alJTodw9aDuVWZa3uiWqfuBMKeAeP2ocWcxoyM3D73yz3Jt/Pu4qPr4wHSdB/Q== + +ts-essentials@^1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-1.0.4.tgz#ce3b5dade5f5d97cf69889c11bf7d2da8555b15a" + integrity sha512-q3N1xS4vZpRouhYHDPwO0bDW3EZ6SK9CrrDHxi/D6BPReSjpVgWIOpLS2o0gSBZm+7q/wyKp6RVM1AeeW7uyfQ== + +ts-essentials@^6.0.3: + version "6.0.7" + resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-6.0.7.tgz#5f4880911b7581a873783740ce8b94da163d18a6" + integrity sha512-2E4HIIj4tQJlIHuATRHayv0EfMGK3ris/GRk1E3CFnsZzeNV+hUmelbaTZHLtXaZppM5oLhHRtO04gINC4Jusw== + +ts-generator@0.0.8, ts-generator@^0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/ts-generator/-/ts-generator-0.0.8.tgz#7bd48ca064db026d9520bcb682b69efc20971d6a" + integrity sha512-Gi+aZCELpVL7Mqb+GuMgM+n8JZ/arZZib1iD/R9Ok8JDjOCOCrqS9b1lr72ku7J45WeDCFZxyJoRsiQvhokCnw== + dependencies: + "@types/mkdirp" "^0.5.2" + "@types/prettier" "^1.13.2" + "@types/resolve" "^0.0.8" + chalk "^2.4.1" + glob "^7.1.2" + mkdirp "^0.5.1" + prettier "^1.14.2" + resolve "^1.8.1" + ts-essentials "^1.0.0" + +ts-generator@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ts-generator/-/ts-generator-0.1.1.tgz#af46f2fb88a6db1f9785977e9590e7bcd79220ab" + integrity sha512-N+ahhZxTLYu1HNTQetwWcx3so8hcYbkKBHTr4b4/YgObFTIKkOSSsaa+nal12w8mfrJAyzJfETXawbNjSfP2gQ== + dependencies: + "@types/mkdirp" "^0.5.2" + "@types/prettier" "^2.1.1" + "@types/resolve" "^0.0.8" + chalk "^2.4.1" + glob "^7.1.2" + mkdirp "^0.5.1" + prettier "^2.1.2" + resolve "^1.8.1" + ts-essentials "^1.0.0" + +ts-node@^9.1.1: + version "9.1.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-9.1.1.tgz#51a9a450a3e959401bda5f004a72d54b936d376d" + integrity sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg== + dependencies: + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + source-map-support "^0.5.17" + yn "3.1.1" + +tslib@^1.13.0, tslib@^1.7.1, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: + version "1.14.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" + integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== + +tslint-config-prettier@^1.18.0: + version "1.18.0" + resolved "https://registry.yarnpkg.com/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz#75f140bde947d35d8f0d238e0ebf809d64592c37" + integrity sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg== + +tslint-no-focused-test@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/tslint-no-focused-test/-/tslint-no-focused-test-0.5.0.tgz#e0a93ef3fa64bd91c7e7437d1f183204880a8ed5" + integrity sha512-YK0PSY5XAdJaTzVIXxnUGyvB5VAi+H9yTc3e40YVtu8Ix3+zLSz4ufvX6rXT3nWpim0DR6fxXoL/Zk8JI641Vg== + +tslint-plugin-prettier@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/tslint-plugin-prettier/-/tslint-plugin-prettier-2.3.0.tgz#73fe71bf9f03842ac48c104122ca9b1de012ecf4" + integrity sha512-F9e4K03yc9xuvv+A0v1EmjcnDwpz8SpCD8HzqSDe0eyg34cBinwn9JjmnnRrNAs4HdleRQj7qijp+P/JTxt4vA== + dependencies: + eslint-plugin-prettier "^2.2.0" + lines-and-columns "^1.1.6" + tslib "^1.7.1" + +tslint@^6.1.3: + version "6.1.3" + resolved "https://registry.yarnpkg.com/tslint/-/tslint-6.1.3.tgz#5c23b2eccc32487d5523bd3a470e9aa31789d904" + integrity sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg== + dependencies: + "@babel/code-frame" "^7.0.0" + builtin-modules "^1.1.1" + chalk "^2.3.0" + commander "^2.12.1" + diff "^4.0.1" + glob "^7.1.1" + js-yaml "^3.13.1" + minimatch "^3.0.4" + mkdirp "^0.5.3" + resolve "^1.3.2" + semver "^5.3.0" + tslib "^1.13.0" + tsutils "^2.29.0" + +tsort@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/tsort/-/tsort-0.0.1.tgz#e2280f5e817f8bf4275657fd0f9aebd44f5a2786" + integrity sha1-4igPXoF/i/QnVlf9D5rr1E9aJ4Y= + +tsutils@^2.29.0: + version "2.29.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99" + integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA== + dependencies: + tslib "^1.8.1" + +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + integrity sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0= + dependencies: + safe-buffer "^5.0.1" + +tweetnacl-util@^0.15.0: + version "0.15.1" + resolved "https://registry.yarnpkg.com/tweetnacl-util/-/tweetnacl-util-0.15.1.tgz#b80fcdb5c97bcc508be18c44a4be50f022eea00b" + integrity sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw== + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= + +tweetnacl@^1.0.0, tweetnacl@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" + integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== + +type-detect@^4.0.0, type-detect@^4.0.5: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== + +type-fest@^0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1" + integrity sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ== + +type-fest@^0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.7.1.tgz#8dda65feaf03ed78f0a3f9678f1869147f7c5c48" + integrity sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg== + +type-is@~1.6.17, type-is@~1.6.18: + version "1.6.18" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" + integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== + dependencies: + media-typer "0.3.0" + mime-types "~2.1.24" + +type@^1.0.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/type/-/type-1.2.0.tgz#848dd7698dafa3e54a6c479e759c4bc3f18847a0" + integrity sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg== + +type@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/type/-/type-2.3.0.tgz#ada7c045f07ead08abf9e2edd29be1a0c0661132" + integrity sha512-rgPIqOdfK/4J9FhiVrZ3cveAjRRo5rsQBAIhnylX874y1DX/kEKSVdLsnuHB6l1KTjHyU01VjiMBHgU2adejyg== + +typechain@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/typechain/-/typechain-2.0.0.tgz#62143b48cdf8f95a777f1b76617af077b2d44eee" + integrity sha512-O+hsAUwtBpqCfoq46Grm52OEdm0GBEu78LxrEzkkGdwUdCoCZpNb2HPzPoNB1MXiRnNhEOGMFyf05UbT2/bUEw== + dependencies: + command-line-args "^4.0.7" + debug "^4.1.1" + fs-extra "^7.0.0" + js-sha3 "^0.8.0" + lodash "^4.17.15" + ts-essentials "^6.0.3" + ts-generator "^0.0.8" + +typechain@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/typechain/-/typechain-3.0.0.tgz#d5a47700831f238e43f7429b987b4bb54849b92e" + integrity sha512-ft4KVmiN3zH4JUFu2WJBrwfHeDf772Tt2d8bssDTo/YcckKW2D+OwFrHXRC6hJvO3mHjFQTihoMV6fJOi0Hngg== + dependencies: + command-line-args "^4.0.7" + debug "^4.1.1" + fs-extra "^7.0.0" + js-sha3 "^0.8.0" + lodash "^4.17.15" + ts-essentials "^6.0.3" + ts-generator "^0.1.1" + +typedarray-to-buffer@^3.1.5: + version "3.1.5" + resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" + integrity sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q== + dependencies: + is-typedarray "^1.0.0" + +typedarray@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= + +typescript@^4.1.5: + version "4.2.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.2.tgz#1450f020618f872db0ea17317d16d8da8ddb8c4c" + integrity sha512-tbb+NVrLfnsJy3M59lsDgrzWIflR4d4TIUjz+heUnHZwdF7YsrMTKoRERiIvI2lvBG95dfpLxB21WZhys1bgaQ== + +typewise-core@^1.2, typewise-core@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/typewise-core/-/typewise-core-1.2.0.tgz#97eb91805c7f55d2f941748fa50d315d991ef195" + integrity sha1-l+uRgFx/VdL5QXSPpQ0xXZke8ZU= + +typewise@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/typewise/-/typewise-1.0.3.tgz#1067936540af97937cc5dcf9922486e9fa284651" + integrity sha1-EGeTZUCvl5N8xdz5kiSG6fooRlE= + dependencies: + typewise-core "^1.2.0" + +typewiselite@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/typewiselite/-/typewiselite-1.0.0.tgz#c8882fa1bb1092c06005a97f34ef5c8508e3664e" + integrity sha1-yIgvobsQksBgBal/NO9chQjjZk4= + +typical@^2.6.0, typical@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/typical/-/typical-2.6.1.tgz#5c080e5d661cbbe38259d2e70a3c7253e873881d" + integrity sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0= + +u2f-api@0.2.7: + version "0.2.7" + resolved "https://registry.yarnpkg.com/u2f-api/-/u2f-api-0.2.7.tgz#17bf196b242f6bf72353d9858e6a7566cc192720" + integrity sha512-fqLNg8vpvLOD5J/z4B6wpPg4Lvowz1nJ9xdHcCzdUPKcFE/qNCceV2gNZxSJd5vhAZemHr/K/hbzVA0zxB5mkg== + +ultron@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c" + integrity sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og== + +underscore@1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.9.1.tgz#06dce34a0e68a7babc29b365b8e74b8925203961" + integrity sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg== + +union-value@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847" + integrity sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg== + dependencies: + arr-union "^3.1.0" + get-value "^2.0.6" + is-extendable "^0.1.1" + set-value "^2.0.1" + +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== + +unorm@^1.3.3: + version "1.6.0" + resolved "https://registry.yarnpkg.com/unorm/-/unorm-1.6.0.tgz#029b289661fba714f1a9af439eb51d9b16c205af" + integrity sha512-b2/KCUlYZUeA7JFUuRJZPUtr4gZvBh7tavtv4fvk4+KV9pfGiR6CQAQAWl49ZpR3ts2dk4FYkP7EIgDJoiOLDA== + +unpipe@1.0.0, unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= + +unset-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" + integrity sha1-g3aHP30jNRef+x5vw6jtDfyKtVk= + dependencies: + has-value "^0.3.1" + isobject "^3.0.0" + +untildify@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/untildify/-/untildify-4.0.0.tgz#2bc947b953652487e4600949fb091e3ae8cd919b" + integrity sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw== + +uri-js@^4.2.2: + version "4.4.1" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== + dependencies: + punycode "^2.1.0" + +urix@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" + integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= + +url-parse-lax@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-1.0.0.tgz#7af8f303645e9bd79a272e7a14ac68bc0609da73" + integrity sha1-evjzA2Rem9eaJy56FKxovAYJ2nM= + dependencies: + prepend-http "^1.0.1" + +url-parse-lax@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-3.0.0.tgz#16b5cafc07dbe3676c1b1999177823d6503acb0c" + integrity sha1-FrXK/Afb42dsGxmZF3gj1lA6yww= + dependencies: + prepend-http "^2.0.0" + +url-set-query@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/url-set-query/-/url-set-query-1.0.0.tgz#016e8cfd7c20ee05cafe7795e892bd0702faa339" + integrity sha1-AW6M/Xwg7gXK/neV6JK9BwL6ozk= + +url-to-options@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/url-to-options/-/url-to-options-1.0.1.tgz#1505a03a289a48cbd7a434efbaeec5055f5633a9" + integrity sha1-FQWgOiiaSMvXpDTvuu7FBV9WM6k= + +url@^0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" + integrity sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE= + dependencies: + punycode "1.3.2" + querystring "0.2.0" + +usb@^1.6.3: + version "1.6.5" + resolved "https://registry.yarnpkg.com/usb/-/usb-1.6.5.tgz#482dc18468a6ed7b33d92ef88500630c68da3c7d" + integrity sha512-gLVrerQce+F+TSkWgzXACV07nOw+uBlv0gT3svsqTWWxNDe3ESQBIhss3qonIDArMvWPJp6z3I4hXEDYTmPlHQ== + dependencies: + bindings "^1.4.0" + nan "2.13.2" + prebuild-install "^5.3.3" + +use@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" + integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== + +utf-8-validate@^5.0.2: + version "5.0.4" + resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.4.tgz#72a1735983ddf7a05a43a9c6b67c5ce1c910f9b8" + integrity sha512-MEF05cPSq3AwJ2C7B7sHAA6i53vONoZbMGX8My5auEVm6W+dJ2Jd/TZPyGJ5CH42V2XtbI5FD28HeHeqlPzZ3Q== + dependencies: + node-gyp-build "^4.2.0" + +utf8@3.0.0, utf8@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1" + integrity sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ== + +util-deprecate@^1.0.1, util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= + +util.promisify@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.1.1.tgz#77832f57ced2c9478174149cae9b96e9918cd54b" + integrity sha512-/s3UsZUrIfa6xDhr7zZhnE9SLQ5RIXyYfiVnMMyMDzOc8WhWN4Nbh36H842OyurKbCDAesZOJaVyvmSl6fhGQw== + dependencies: + call-bind "^1.0.0" + define-properties "^1.1.3" + for-each "^0.3.3" + has-symbols "^1.0.1" + object.getownpropertydescriptors "^2.1.1" + +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= + +uuid@3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" + integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA== + +uuid@^3.3.2: + version "3.4.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" + integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== + +validate-npm-package-license@^3.0.1: + version "3.0.4" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" + integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== + dependencies: + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" + +varint@^5.0.0: + version "5.0.2" + resolved "https://registry.yarnpkg.com/varint/-/varint-5.0.2.tgz#5b47f8a947eb668b848e034dcfa87d0ff8a7f7a4" + integrity sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow== + +vary@^1, vary@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" + integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= + +verror@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" + integrity sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA= + dependencies: + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" + +web3-bzz@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-bzz/-/web3-bzz-1.2.11.tgz#41bc19a77444bd5365744596d778b811880f707f" + integrity sha512-XGpWUEElGypBjeFyUhTkiPXFbDVD6Nr/S5jznE3t8cWUA0FxRf1n3n/NuIZeb0H9RkN2Ctd/jNma/k8XGa3YKg== + dependencies: + "@types/node" "^12.12.6" + got "9.6.0" + swarm-js "^0.1.40" + underscore "1.9.1" + +web3-core-helpers@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-core-helpers/-/web3-core-helpers-1.2.11.tgz#84c681ed0b942c0203f3b324a245a127e8c67a99" + integrity sha512-PEPoAoZd5ME7UfbnCZBdzIerpe74GEvlwT4AjOmHeCVZoIFk7EqvOZDejJHt+feJA6kMVTdd0xzRNN295UhC1A== + dependencies: + underscore "1.9.1" + web3-eth-iban "1.2.11" + web3-utils "1.2.11" + +web3-core-method@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-core-method/-/web3-core-method-1.2.11.tgz#f880137d1507a0124912bf052534f168b8d8fbb6" + integrity sha512-ff0q76Cde94HAxLDZ6DbdmKniYCQVtvuaYh+rtOUMB6kssa5FX0q3vPmixi7NPooFnbKmmZCM6NvXg4IreTPIw== + dependencies: + "@ethersproject/transactions" "^5.0.0-beta.135" + underscore "1.9.1" + web3-core-helpers "1.2.11" + web3-core-promievent "1.2.11" + web3-core-subscriptions "1.2.11" + web3-utils "1.2.11" + +web3-core-promievent@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-core-promievent/-/web3-core-promievent-1.2.11.tgz#51fe97ca0ddec2f99bf8c3306a7a8e4b094ea3cf" + integrity sha512-il4McoDa/Ox9Agh4kyfQ8Ak/9ABYpnF8poBLL33R/EnxLsJOGQG2nZhkJa3I067hocrPSjEdlPt/0bHXsln4qA== + dependencies: + eventemitter3 "4.0.4" + +web3-core-requestmanager@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-core-requestmanager/-/web3-core-requestmanager-1.2.11.tgz#fe6eb603fbaee18530293a91f8cf26d8ae28c45a" + integrity sha512-oFhBtLfOiIbmfl6T6gYjjj9igOvtyxJ+fjS+byRxiwFJyJ5BQOz4/9/17gWR1Cq74paTlI7vDGxYfuvfE/mKvA== + dependencies: + underscore "1.9.1" + web3-core-helpers "1.2.11" + web3-providers-http "1.2.11" + web3-providers-ipc "1.2.11" + web3-providers-ws "1.2.11" + +web3-core-subscriptions@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-core-subscriptions/-/web3-core-subscriptions-1.2.11.tgz#beca908fbfcb050c16f45f3f0f4c205e8505accd" + integrity sha512-qEF/OVqkCvQ7MPs1JylIZCZkin0aKK9lDxpAtQ1F8niEDGFqn7DT8E/vzbIa0GsOjL2fZjDhWJsaW+BSoAW1gg== + dependencies: + eventemitter3 "4.0.4" + underscore "1.9.1" + web3-core-helpers "1.2.11" + +web3-core@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-core/-/web3-core-1.2.11.tgz#1043cacc1becb80638453cc5b2a14be9050288a7" + integrity sha512-CN7MEYOY5ryo5iVleIWRE3a3cZqVaLlIbIzDPsvQRUfzYnvzZQRZBm9Mq+ttDi2STOOzc1MKylspz/o3yq/LjQ== + dependencies: + "@types/bn.js" "^4.11.5" + "@types/node" "^12.12.6" + bignumber.js "^9.0.0" + web3-core-helpers "1.2.11" + web3-core-method "1.2.11" + web3-core-requestmanager "1.2.11" + web3-utils "1.2.11" + +web3-eth-abi@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth-abi/-/web3-eth-abi-1.2.11.tgz#a887494e5d447c2926d557a3834edd66e17af9b0" + integrity sha512-PkRYc0+MjuLSgg03QVWqWlQivJqRwKItKtEpRUaxUAeLE7i/uU39gmzm2keHGcQXo3POXAbOnMqkDvOep89Crg== + dependencies: + "@ethersproject/abi" "5.0.0-beta.153" + underscore "1.9.1" + web3-utils "1.2.11" + +web3-eth-accounts@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth-accounts/-/web3-eth-accounts-1.2.11.tgz#a9e3044da442d31903a7ce035a86d8fa33f90520" + integrity sha512-6FwPqEpCfKIh3nSSGeo3uBm2iFSnFJDfwL3oS9pyegRBXNsGRVpgiW63yhNzL0796StsvjHWwQnQHsZNxWAkGw== + dependencies: + crypto-browserify "3.12.0" + eth-lib "0.2.8" + ethereumjs-common "^1.3.2" + ethereumjs-tx "^2.1.1" + scrypt-js "^3.0.1" + underscore "1.9.1" + uuid "3.3.2" + web3-core "1.2.11" + web3-core-helpers "1.2.11" + web3-core-method "1.2.11" + web3-utils "1.2.11" + +web3-eth-contract@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth-contract/-/web3-eth-contract-1.2.11.tgz#917065902bc27ce89da9a1da26e62ef663663b90" + integrity sha512-MzYuI/Rq2o6gn7vCGcnQgco63isPNK5lMAan2E51AJLknjSLnOxwNY3gM8BcKoy4Z+v5Dv00a03Xuk78JowFow== + dependencies: + "@types/bn.js" "^4.11.5" + underscore "1.9.1" + web3-core "1.2.11" + web3-core-helpers "1.2.11" + web3-core-method "1.2.11" + web3-core-promievent "1.2.11" + web3-core-subscriptions "1.2.11" + web3-eth-abi "1.2.11" + web3-utils "1.2.11" + +web3-eth-ens@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth-ens/-/web3-eth-ens-1.2.11.tgz#26d4d7f16d6cbcfff918e39832b939edc3162532" + integrity sha512-dbW7dXP6HqT1EAPvnniZVnmw6TmQEKF6/1KgAxbo8iBBYrVTMDGFQUUnZ+C4VETGrwwaqtX4L9d/FrQhZ6SUiA== + dependencies: + content-hash "^2.5.2" + eth-ens-namehash "2.0.8" + underscore "1.9.1" + web3-core "1.2.11" + web3-core-helpers "1.2.11" + web3-core-promievent "1.2.11" + web3-eth-abi "1.2.11" + web3-eth-contract "1.2.11" + web3-utils "1.2.11" + +web3-eth-iban@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth-iban/-/web3-eth-iban-1.2.11.tgz#f5f73298305bc7392e2f188bf38a7362b42144ef" + integrity sha512-ozuVlZ5jwFC2hJY4+fH9pIcuH1xP0HEFhtWsR69u9uDIANHLPQQtWYmdj7xQ3p2YT4bQLq/axKhZi7EZVetmxQ== + dependencies: + bn.js "^4.11.9" + web3-utils "1.2.11" + +web3-eth-personal@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth-personal/-/web3-eth-personal-1.2.11.tgz#a38b3942a1d87a62070ce0622a941553c3d5aa70" + integrity sha512-42IzUtKq9iHZ8K9VN0vAI50iSU9tOA1V7XU2BhF/tb7We2iKBVdkley2fg26TxlOcKNEHm7o6HRtiiFsVK4Ifw== + dependencies: + "@types/node" "^12.12.6" + web3-core "1.2.11" + web3-core-helpers "1.2.11" + web3-core-method "1.2.11" + web3-net "1.2.11" + web3-utils "1.2.11" + +web3-eth@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth/-/web3-eth-1.2.11.tgz#4c81fcb6285b8caf544058fba3ae802968fdc793" + integrity sha512-REvxW1wJ58AgHPcXPJOL49d1K/dPmuw4LjPLBPStOVkQjzDTVmJEIsiLwn2YeuNDd4pfakBwT8L3bz1G1/wVsQ== + dependencies: + underscore "1.9.1" + web3-core "1.2.11" + web3-core-helpers "1.2.11" + web3-core-method "1.2.11" + web3-core-subscriptions "1.2.11" + web3-eth-abi "1.2.11" + web3-eth-accounts "1.2.11" + web3-eth-contract "1.2.11" + web3-eth-ens "1.2.11" + web3-eth-iban "1.2.11" + web3-eth-personal "1.2.11" + web3-net "1.2.11" + web3-utils "1.2.11" + +web3-net@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-net/-/web3-net-1.2.11.tgz#eda68ef25e5cdb64c96c39085cdb74669aabbe1b" + integrity sha512-sjrSDj0pTfZouR5BSTItCuZ5K/oZPVdVciPQ6981PPPIwJJkCMeVjD7I4zO3qDPCnBjBSbWvVnLdwqUBPtHxyg== + dependencies: + web3-core "1.2.11" + web3-core-method "1.2.11" + web3-utils "1.2.11" + +web3-provider-engine@14.2.1: + version "14.2.1" + resolved "https://registry.yarnpkg.com/web3-provider-engine/-/web3-provider-engine-14.2.1.tgz#ef351578797bf170e08d529cb5b02f8751329b95" + integrity sha512-iSv31h2qXkr9vrL6UZDm4leZMc32SjWJFGOp/D92JXfcEboCqraZyuExDkpxKw8ziTufXieNM7LSXNHzszYdJw== + dependencies: + async "^2.5.0" + backoff "^2.5.0" + clone "^2.0.0" + cross-fetch "^2.1.0" + eth-block-tracker "^3.0.0" + eth-json-rpc-infura "^3.1.0" + eth-sig-util "^1.4.2" + ethereumjs-block "^1.2.2" + ethereumjs-tx "^1.2.0" + ethereumjs-util "^5.1.5" + ethereumjs-vm "^2.3.4" + json-rpc-error "^2.0.0" + json-stable-stringify "^1.0.1" + promise-to-callback "^1.0.0" + readable-stream "^2.2.9" + request "^2.85.0" + semaphore "^1.0.3" + ws "^5.1.1" + xhr "^2.2.0" + xtend "^4.0.1" + +web3-providers-http@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-providers-http/-/web3-providers-http-1.2.11.tgz#1cd03442c61670572d40e4dcdf1faff8bd91e7c6" + integrity sha512-psh4hYGb1+ijWywfwpB2cvvOIMISlR44F/rJtYkRmQ5jMvG4FOCPlQJPiHQZo+2cc3HbktvvSJzIhkWQJdmvrA== + dependencies: + web3-core-helpers "1.2.11" + xhr2-cookies "1.1.0" + +web3-providers-ipc@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-providers-ipc/-/web3-providers-ipc-1.2.11.tgz#d16d6c9be1be6e0b4f4536c4acc16b0f4f27ef21" + integrity sha512-yhc7Y/k8hBV/KlELxynWjJDzmgDEDjIjBzXK+e0rHBsYEhdCNdIH5Psa456c+l0qTEU2YzycF8VAjYpWfPnBpQ== + dependencies: + oboe "2.1.4" + underscore "1.9.1" + web3-core-helpers "1.2.11" + +web3-providers-ws@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-providers-ws/-/web3-providers-ws-1.2.11.tgz#a1dfd6d9778d840561d9ec13dd453046451a96bb" + integrity sha512-ZxnjIY1Er8Ty+cE4migzr43zA/+72AF1myzsLaU5eVgdsfV7Jqx7Dix1hbevNZDKFlSoEyq/3j/jYalh3So1Zg== + dependencies: + eventemitter3 "4.0.4" + underscore "1.9.1" + web3-core-helpers "1.2.11" + websocket "^1.0.31" + +web3-shh@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-shh/-/web3-shh-1.2.11.tgz#f5d086f9621c9a47e98d438010385b5f059fd88f" + integrity sha512-B3OrO3oG1L+bv3E1sTwCx66injW1A8hhwpknDUbV+sw3fehFazA06z9SGXUefuFI1kVs4q2vRi0n4oCcI4dZDg== + dependencies: + web3-core "1.2.11" + web3-core-method "1.2.11" + web3-core-subscriptions "1.2.11" + web3-net "1.2.11" + +web3-utils@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.2.11.tgz#af1942aead3fb166ae851a985bed8ef2c2d95a82" + integrity sha512-3Tq09izhD+ThqHEaWYX4VOT7dNPdZiO+c/1QMA0s5X2lDFKK/xHJb7cyTRRVzN2LvlHbR7baS1tmQhSua51TcQ== + dependencies: + bn.js "^4.11.9" + eth-lib "0.2.8" + ethereum-bloom-filters "^1.0.6" + ethjs-unit "0.1.6" + number-to-bn "1.7.0" + randombytes "^2.1.0" + underscore "1.9.1" + utf8 "3.0.0" + +web3-utils@^1.0.0-beta.31: + version "1.3.4" + resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.3.4.tgz#9b1aa30d7549f860b573e7bb7e690999e7192198" + integrity sha512-/vC2v0MaZNpWooJfpRw63u0Y3ag2gNjAWiLtMSL6QQLmCqCy4SQIndMt/vRyx0uMoeGt1YTwSXEcHjUzOhLg0A== + dependencies: + bn.js "^4.11.9" + eth-lib "0.2.8" + ethereum-bloom-filters "^1.0.6" + ethjs-unit "0.1.6" + number-to-bn "1.7.0" + randombytes "^2.1.0" + underscore "1.9.1" + utf8 "3.0.0" + +web3@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3/-/web3-1.2.11.tgz#50f458b2e8b11aa37302071c170ed61cff332975" + integrity sha512-mjQ8HeU41G6hgOYm1pmeH0mRAeNKJGnJEUzDMoerkpw7QUQT4exVREgF1MYPvL/z6vAshOXei25LE/t/Bxl8yQ== + dependencies: + web3-bzz "1.2.11" + web3-core "1.2.11" + web3-eth "1.2.11" + web3-eth-personal "1.2.11" + web3-net "1.2.11" + web3-shh "1.2.11" + web3-utils "1.2.11" + +websocket@1.0.32: + version "1.0.32" + resolved "https://registry.yarnpkg.com/websocket/-/websocket-1.0.32.tgz#1f16ddab3a21a2d929dec1687ab21cfdc6d3dbb1" + integrity sha512-i4yhcllSP4wrpoPMU2N0TQ/q0O94LRG/eUQjEAamRltjQ1oT1PFFKOG4i877OlJgCG8rw6LrrowJp+TYCEWF7Q== + dependencies: + bufferutil "^4.0.1" + debug "^2.2.0" + es5-ext "^0.10.50" + typedarray-to-buffer "^3.1.5" + utf-8-validate "^5.0.2" + yaeti "^0.0.6" + +websocket@^1.0.31: + version "1.0.33" + resolved "https://registry.yarnpkg.com/websocket/-/websocket-1.0.33.tgz#407f763fc58e74a3fa41ca3ae5d78d3f5e3b82a5" + integrity sha512-XwNqM2rN5eh3G2CUQE3OHZj+0xfdH42+OFK6LdC2yqiC0YU8e5UK0nYre220T0IyyN031V/XOvtHvXozvJYFWA== + dependencies: + bufferutil "^4.0.1" + debug "^2.2.0" + es5-ext "^0.10.50" + typedarray-to-buffer "^3.1.5" + utf-8-validate "^5.0.2" + yaeti "^0.0.6" + +whatwg-fetch@2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f" + integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng== + +which-module@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f" + integrity sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8= + +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= + +which-pm-runs@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.0.0.tgz#670b3afbc552e0b55df6b7780ca74615f23ad1cb" + integrity sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs= + +which@1.3.1, which@^1.2.9: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + +which@2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +wide-align@1.1.3, wide-align@^1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" + integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== + dependencies: + string-width "^1.0.2 || 2" + +window-size@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.2.0.tgz#b4315bb4214a3d7058ebeee892e13fa24d98b075" + integrity sha1-tDFbtCFKPXBY6+7okuE/ok2YsHU= + +workerpool@6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.1.0.tgz#a8e038b4c94569596852de7a8ea4228eefdeb37b" + integrity sha512-toV7q9rWNYha963Pl/qyeZ6wG+3nnsyvolaNUS8+R5Wtw6qJPTxIlOP1ZSvcGhEJw+l3HMMmtiNo9Gl61G4GVg== + +wrap-ansi@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" + integrity sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU= + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + +wrap-ansi@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" + integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== + dependencies: + ansi-styles "^3.2.0" + string-width "^3.0.0" + strip-ansi "^5.0.0" + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + +ws@7.2.3: + version "7.2.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.3.tgz#a5411e1fb04d5ed0efee76d26d5c46d830c39b46" + integrity sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ== + +ws@^3.0.0: + version "3.3.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2" + integrity sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA== + dependencies: + async-limiter "~1.0.0" + safe-buffer "~5.1.0" + ultron "~1.1.0" + +ws@^5.1.1: + version "5.2.2" + resolved "https://registry.yarnpkg.com/ws/-/ws-5.2.2.tgz#dffef14866b8e8dc9133582514d1befaf96e980f" + integrity sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA== + dependencies: + async-limiter "~1.0.0" + +ws@^7.2.1: + version "7.4.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.3.tgz#1f9643de34a543b8edb124bdcbc457ae55a6e5cd" + integrity sha512-hr6vCR76GsossIRsr8OLR9acVVm1jyfEWvhbNjtgPOrfvAlKzvyeg/P6r8RuDjRyrcQoPQT7K0DGEPc7Ae6jzA== + +xhr-request-promise@^0.1.2: + version "0.1.3" + resolved "https://registry.yarnpkg.com/xhr-request-promise/-/xhr-request-promise-0.1.3.tgz#2d5f4b16d8c6c893be97f1a62b0ed4cf3ca5f96c" + integrity sha512-YUBytBsuwgitWtdRzXDDkWAXzhdGB8bYm0sSzMPZT7Z2MBjMSTHFsyCT1yCRATY+XC69DUrQraRAEgcoCRaIPg== + dependencies: + xhr-request "^1.1.0" + +xhr-request@^1.0.1, xhr-request@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/xhr-request/-/xhr-request-1.1.0.tgz#f4a7c1868b9f198723444d82dcae317643f2e2ed" + integrity sha512-Y7qzEaR3FDtL3fP30k9wO/e+FBnBByZeybKOhASsGP30NIkRAAkKD/sCnLvgEfAIEC1rcmK7YG8f4oEnIrrWzA== + dependencies: + buffer-to-arraybuffer "^0.0.5" + object-assign "^4.1.1" + query-string "^5.0.1" + simple-get "^2.7.0" + timed-out "^4.0.1" + url-set-query "^1.0.0" + xhr "^2.0.4" + +xhr2-cookies@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/xhr2-cookies/-/xhr2-cookies-1.1.0.tgz#7d77449d0999197f155cb73b23df72505ed89d48" + integrity sha1-fXdEnQmZGX8VXLc7I99yUF7YnUg= + dependencies: + cookiejar "^2.1.1" + +xhr@^2.0.4, xhr@^2.2.0, xhr@^2.3.3: + version "2.6.0" + resolved "https://registry.yarnpkg.com/xhr/-/xhr-2.6.0.tgz#b69d4395e792b4173d6b7df077f0fc5e4e2b249d" + integrity sha512-/eCGLb5rxjx5e3mF1A7s+pLlR6CGyqWN91fv1JgER5mVWg1MZmlhBvy9kjcsOdRk8RrIujotWyJamfyrp+WIcA== + dependencies: + global "~4.4.0" + is-function "^1.0.1" + parse-headers "^2.0.0" + xtend "^4.0.0" + +xtend@^4.0.0, xtend@^4.0.1, xtend@^4.0.2, xtend@~4.0.0, xtend@~4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" + integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== + +xtend@~2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-2.1.2.tgz#6efecc2a4dad8e6962c4901b337ce7ba87b5d28b" + integrity sha1-bv7MKk2tjmlixJAbM3znuoe10os= + dependencies: + object-keys "~0.4.0" + +y18n@^3.2.1: + version "3.2.2" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.2.tgz#85c901bd6470ce71fc4bb723ad209b70f7f28696" + integrity sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ== + +y18n@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4" + integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ== + +y18n@^5.0.5: + version "5.0.5" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.5.tgz#8769ec08d03b1ea2df2500acef561743bbb9ab18" + integrity sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg== + +yaeti@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/yaeti/-/yaeti-0.0.6.tgz#f26f484d72684cf42bedfb76970aa1608fbf9577" + integrity sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc= + +yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" + integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== + +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + +yargs-parser@13.1.2, yargs-parser@^13.1.2: + version "13.1.2" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" + integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + +yargs-parser@20.2.4: + version "20.2.4" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" + integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== + +yargs-parser@^2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-2.4.1.tgz#85568de3cf150ff49fa51825f03a8c880ddcc5c4" + integrity sha1-hVaN488VD/SfpRgl8DqMiA3cxcQ= + dependencies: + camelcase "^3.0.0" + lodash.assign "^4.0.6" + +yargs-parser@^20.2.2: + version "20.2.5" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.5.tgz#5d37729146d3f894f39fc94b6796f5b239513186" + integrity sha512-jYRGS3zWy20NtDtK2kBgo/TlAoy5YUuhD9/LZ7z7W4j1Fdw2cqD0xEEclf8fxc8xjD6X5Qr+qQQwCEsP8iRiYg== + +yargs-unparser@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-1.6.0.tgz#ef25c2c769ff6bd09e4b0f9d7c605fb27846ea9f" + integrity sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw== + dependencies: + flat "^4.1.0" + lodash "^4.17.15" + yargs "^13.3.0" + +yargs-unparser@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" + integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== + dependencies: + camelcase "^6.0.0" + decamelize "^4.0.0" + flat "^5.0.2" + is-plain-obj "^2.1.0" + +yargs@13.3.2, yargs@^13.3.0: + version "13.3.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.2.tgz#ad7ffefec1aa59565ac915f82dccb38a9c31a2dd" + integrity sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw== + dependencies: + cliui "^5.0.0" + find-up "^3.0.0" + get-caller-file "^2.0.1" + require-directory "^2.1.1" + require-main-filename "^2.0.0" + set-blocking "^2.0.0" + string-width "^3.0.0" + which-module "^2.0.0" + y18n "^4.0.0" + yargs-parser "^13.1.2" + +yargs@16.2.0, yargs@^16.1.0: + version "16.2.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== + dependencies: + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" + +yargs@^4.7.1: + version "4.8.1" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-4.8.1.tgz#c0c42924ca4aaa6b0e6da1739dfb216439f9ddc0" + integrity sha1-wMQpJMpKqmsObaFznfshZDn53cA= + dependencies: + cliui "^3.2.0" + decamelize "^1.1.1" + get-caller-file "^1.0.1" + lodash.assign "^4.0.3" + os-locale "^1.4.0" + read-pkg-up "^1.0.1" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^1.0.1" + which-module "^1.0.0" + window-size "^0.2.0" + y18n "^3.2.1" + yargs-parser "^2.4.1" + +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== diff --git a/packages/data-transport-layer/src/utils/contracts.ts b/packages/data-transport-layer/src/utils/contracts.ts index 36f5f5c0ec91..09a741f6ca53 100644 --- a/packages/data-transport-layer/src/utils/contracts.ts +++ b/packages/data-transport-layer/src/utils/contracts.ts @@ -1,7 +1,7 @@ /* Imports: External */ import { constants, Contract, Signer } from 'ethers' import { JsonRpcProvider } from '@ethersproject/providers' -import { getContractInterface } from '@eth-optimism/contracts/build/src/contract-defs' +import { getContractInterface } from '@eth-optimism/contracts' export const loadContract = ( name: string, diff --git a/yarn.lock b/yarn.lock index dbaba166338f..271fb72db156 100644 --- a/yarn.lock +++ b/yarn.lock @@ -51,20 +51,6 @@ ethers "5.0.0" ganache-core "^2.12.1" -"@eth-optimism/contracts@^0.1.6": - version "0.1.11" - resolved "https://registry.yarnpkg.com/@eth-optimism/contracts/-/contracts-0.1.11.tgz#d33354b69e1bdaf11eac799a1f4dfb17295a04e7" - integrity sha512-Ak4VoPwn9ZTH7Th5Ioh9HxGt9mtriOuiH1YuOtRihnhmmsJ0DO5k5dqdzbckUKYDW1s3sA7N6Yw3pbtZ9qiVWw== - dependencies: - "@eth-optimism/core-utils" "^0.1.8" - "@eth-optimism/dev" "^1.1.1" - "@ethersproject/abstract-provider" "^5.0.8" - "@ethersproject/contracts" "^5.0.5" - "@ethersproject/hardware-wallets" "^5.0.8" - "@openzeppelin/contracts" "^3.3.0" - ganache-core "^2.12.1" - glob "^7.1.6" - "@eth-optimism/core-utils@0.0.1-alpha.30": version "0.0.1-alpha.30" resolved "https://registry.yarnpkg.com/@eth-optimism/core-utils/-/core-utils-0.0.1-alpha.30.tgz#31462596753df182e89cea63e19bf621c07ad898" @@ -1703,6 +1689,13 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== +"@typechain/ethers-v5@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@typechain/ethers-v5/-/ethers-v5-1.0.0.tgz#9156c9a2b078f9bb00a339631221e42c26b218df" + integrity sha512-CWxLmlmfM7NMT6OSq8UXZM7mSkHU1xrbNi40Hvj26S97jKnwERmNbiERgy4fXXOdVqb+zCshnZQ9X+P5WndLMA== + dependencies: + ethers "^5.0.2" + "@typechain/ethers-v5@^2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/@typechain/ethers-v5/-/ethers-v5-2.0.0.tgz#cd3ca1590240d587ca301f4c029b67bfccd08810" @@ -1710,6 +1703,11 @@ dependencies: ethers "^5.0.2" +"@typechain/hardhat@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@typechain/hardhat/-/hardhat-1.0.1.tgz#6e53956c15b2aff073413cfcdb3f5339b0a85f2e" + integrity sha512-gRETPlvLdN95PIP3PVktEtQSnSMJMWxaxNKI34KFPYEuW4QLLm6UrUCHWmulhB1eUQ1EhYRAda7kEhcJOQ/M1g== + "@types/abstract-leveldown@*": version "5.0.1" resolved "https://registry.yarnpkg.com/@types/abstract-leveldown/-/abstract-leveldown-5.0.1.tgz#3c7750d0186b954c7f2d2f6acc8c3c7ba0c3412e" @@ -1785,7 +1783,7 @@ "@types/qs" "*" "@types/serve-static" "*" -"@types/glob@*": +"@types/glob@*", "@types/glob@^7.1.3": version "7.1.3" resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.3.tgz#e6ba80f36b7daad2c685acd9266382e68985c183" integrity sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w== @@ -1909,6 +1907,11 @@ "@types/pino-std-serializers" "*" "@types/sonic-boom" "*" +"@types/prettier@^1.13.2": + version "1.19.1" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.19.1.tgz#33509849f8e679e4add158959fdb086440e9553f" + integrity sha512-5qOlnZscTn4xxM5MeGXAMOsIOIKIbh9e85zJWfBRVPlRMEVawzoPhINYbRGkBZCI8LxvBe7tJCdWiarA99OZfQ== + "@types/prettier@^2.1.1": version "2.2.3" resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.3.tgz#ef65165aea2924c9359205bf748865b8881753c0" @@ -3224,6 +3227,11 @@ buffer-from@^1.0.0, buffer-from@^1.1.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== +buffer-reverse@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/buffer-reverse/-/buffer-reverse-1.0.1.tgz#49283c8efa6f901bc01fa3304d06027971ae2f60" + integrity sha1-SSg8jvpvkBvAH6MwTQYCeXGuL2A= + buffer-to-arraybuffer@^0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz#6064a40fa76eb43c723aba9ef8f6e1216d10511a" @@ -3234,7 +3242,7 @@ buffer-xor@^1.0.3: resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" integrity sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk= -buffer-xor@^2.0.1: +buffer-xor@^2.0.1, buffer-xor@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-2.0.2.tgz#34f7c64f04c777a1f8aac5e661273bb9dd320289" integrity sha512-eHslX0bin3GB+Lx2p7lEYRShRewuNZL3fUl4qlVJGGiwoPGftmt8JQgk2Y9Ji5/01TnVDo33E5b5O3vUB1HdqQ== @@ -3427,7 +3435,7 @@ chai-as-promised@^7.1.1: dependencies: check-error "^1.0.2" -chai@^4.2.0, chai@^4.3.0, chai@^4.3.4: +chai@^4.2.0, chai@^4.3.0, chai@^4.3.1, chai@^4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.4.tgz#b55e655b31e1eac7099be4c08c21964fce2e6c49" integrity sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA== @@ -3905,6 +3913,19 @@ copy-descriptor@^0.1.0: resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= +copyfiles@^2.3.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/copyfiles/-/copyfiles-2.4.1.tgz#d2dcff60aaad1015f09d0b66e7f0f1c5cd3c5da5" + integrity sha512-fereAvAvxDrQDOXybk3Qu3dPbOoKoysFMWtkY3mv5BsL8//OSZVL5DCLYqgRfY5cWirgRzlC+WSrxp6Bo3eNZg== + dependencies: + glob "^7.0.5" + minimatch "^3.0.3" + mkdirp "^1.0.4" + noms "0.0.0" + through2 "^2.0.1" + untildify "^4.0.0" + yargs "^16.1.0" + core-js-pure@^3.0.1: version "3.9.1" resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.9.1.tgz#677b322267172bd490e4464696f790cbc355bec5" @@ -4020,6 +4041,11 @@ crypto-browserify@3.12.0: randombytes "^2.0.0" randomfill "^1.0.3" +crypto-js@^3.1.9-1: + version "3.3.0" + resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.3.0.tgz#846dd1cce2f68aacfa156c8578f926a609b7976b" + integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q== + currently-unhandled@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" @@ -4934,7 +4960,7 @@ ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1, ethereum rlp "^2.0.0" safe-buffer "^5.1.1" -ethereumjs-util@^7.0.2: +ethereumjs-util@^7.0.2, ethereumjs-util@^7.0.8: version "7.0.9" resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.0.9.tgz#2038baeb30f370a3e576ec175bd70bbbb6807d42" integrity sha512-cRqvYYKJoitq6vMKMf8pXeVwvTrX+dRD0JwHaYqm8jvogK14tqIoCWH/KUHcRwnVxVXEYF/o6pup5jRG4V0xzg== @@ -5808,7 +5834,7 @@ glob@7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" -glob@7.1.6, glob@^7.0.0, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@~7.1.6: +glob@7.1.6, glob@^7.0.0, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@~7.1.6: version "7.1.6" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== @@ -5922,7 +5948,7 @@ hard-rejection@^2.1.0: resolved "https://registry.yarnpkg.com/hard-rejection/-/hard-rejection-2.1.0.tgz#1c6eda5c1685c63942766d79bb40ae773cecd883" integrity sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA== -hardhat@^2.0.9, hardhat@^2.1.1, hardhat@^2.1.2: +hardhat@^2.0.8, hardhat@^2.0.9, hardhat@^2.1.1, hardhat@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.1.2.tgz#a2128b71b0fb216ffc978c85a2030835b4e306ea" integrity sha512-42iOheDsDl6Gr7sBfpA0S+bQUIcXSDEUrrqmnFEcBHx9qBoQad3s212y2ODmmkdLt+PqqTM+Mq8N3bZDTdjoLg== @@ -7100,7 +7126,15 @@ level-mem@^3.0.1: level-packager "~4.0.0" memdown "~3.0.0" -level-packager@^5.1.0: +level-mem@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/level-mem/-/level-mem-5.0.1.tgz#c345126b74f5b8aa376dc77d36813a177ef8251d" + integrity sha512-qd+qUJHXsGSFoHTziptAKXoLX87QjR7v2KMbqncDXPxQuCdsQlzmyX+gwrEHhlzn08vkf8TyipYyMmiC6Gobzg== + dependencies: + level-packager "^5.0.3" + memdown "^5.0.0" + +level-packager@^5.0.3, level-packager@^5.1.0: version "5.1.1" resolved "https://registry.yarnpkg.com/level-packager/-/level-packager-5.1.1.tgz#323ec842d6babe7336f70299c14df2e329c18939" integrity sha512-HMwMaQPlTC1IlcwT3+swhqf/NUO+ZhXVz6TY1zZIIZlIR0YSn8GtAAWmIvKjNY16ZkEg/JcpAuQskxsXqC0yOQ== @@ -7163,6 +7197,15 @@ level-ws@^1.0.0: readable-stream "^2.2.8" xtend "^4.0.1" +level-ws@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/level-ws/-/level-ws-2.0.0.tgz#207a07bcd0164a0ec5d62c304b4615c54436d339" + integrity sha512-1iv7VXx0G9ec1isqQZ7y5LmoZo/ewAsyDHNA8EFDW5hqH2Kqovm33nSFkSdnLLAK+I5FlT+lo5Cw9itGe+CpQA== + dependencies: + inherits "^2.0.3" + readable-stream "^3.1.0" + xtend "^4.0.1" + level@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/level/-/level-6.0.1.tgz#dc34c5edb81846a6de5079eac15706334b0d7cd6" @@ -7545,6 +7588,18 @@ memdown@^4.0.0: ltgt "~2.2.0" safe-buffer "~5.1.1" +memdown@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/memdown/-/memdown-5.1.0.tgz#608e91a9f10f37f5b5fe767667a8674129a833cb" + integrity sha512-B3J+UizMRAlEArDjWHTMmadet+UKwHd3UjMgGBkZcKAxAYVPS9o0Yeiha4qvz7iGiL2Sb3igUft6p7nbFWctpw== + dependencies: + abstract-leveldown "~6.2.1" + functional-red-black-tree "~1.0.1" + immediate "~3.2.3" + inherits "~2.0.1" + ltgt "~2.2.0" + safe-buffer "~5.2.0" + memdown@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/memdown/-/memdown-3.0.0.tgz#93aca055d743b20efc37492e9e399784f2958309" @@ -7637,6 +7692,28 @@ merkle-patricia-tree@^2.1.2, merkle-patricia-tree@^2.3.2: rlp "^2.0.0" semaphore ">=1.0.1" +merkle-patricia-tree@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/merkle-patricia-tree/-/merkle-patricia-tree-4.1.0.tgz#010636c4cfd68682df33a2e3186b7d0be7b98b9d" + integrity sha512-vmP1J7FwIpprFMVjjSMM1JAwFce85Q+tp0TYIedYv8qaMh2oLUZ3ETXn9wbgi9S6elySzKzGa+Ai6VNKGEwSlg== + dependencies: + "@types/levelup" "^4.3.0" + ethereumjs-util "^7.0.8" + level-mem "^5.0.1" + level-ws "^2.0.0" + readable-stream "^3.6.0" + rlp "^2.2.3" + semaphore-async-await "^1.5.1" + +merkletreejs@^0.2.12: + version "0.2.15" + resolved "https://registry.yarnpkg.com/merkletreejs/-/merkletreejs-0.2.15.tgz#db8a2e6ba90d2f98a60b92568f4b745fb226b3d7" + integrity sha512-gm10hydsqnArQ7sH+og1LFQRv9MMzS3Vayb66Ly4UAhPq1nvMEni6nrOaM6//7J4QNfx2dTPcuDFCABwjIDh4w== + dependencies: + buffer-reverse "^1.0.1" + crypto-js "^3.1.9-1" + treeify "^1.1.0" + methods@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" @@ -7731,7 +7808,7 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= -minimatch@3.0.4, minimatch@^3.0.4: +minimatch@3.0.4, minimatch@^3.0.3, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== @@ -8269,6 +8346,14 @@ node-hid@2.1.1: node-addon-api "^3.0.2" prebuild-install "^6.0.0" +noms@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/noms/-/noms-0.0.0.tgz#da8ebd9f3af9d6760919b27d9cdc8092a7332859" + integrity sha1-2o69nzr51nYJGbJ9nNyAkqczKFk= + dependencies: + inherits "^2.0.1" + readable-stream "~1.0.31" + noop-logger@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/noop-logger/-/noop-logger-0.1.1.tgz#94a2b1633c4f1317553007d8966fd0e841b6a4c2" @@ -9097,7 +9182,7 @@ prepend-http@^2.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= -prettier@^1.16.4: +prettier@^1.14.2, prettier@^1.16.4: version "1.19.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== @@ -9327,6 +9412,11 @@ quick-lru@^4.0.1: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" integrity sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g== +random-bytes-seed@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/random-bytes-seed/-/random-bytes-seed-1.0.3.tgz#126f1201dba2ec70cd0784f94a810396cad24a15" + integrity sha512-O+eniMt8Sj2iAn2q1x5VEirS/XvbtwYcXNDbOAcRtGN+OhC48cmzS5ksf9qEHRVKC1I8A4qzjucNVElddofB0A== + randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.0.6, randombytes@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" @@ -9479,7 +9569,7 @@ read@1, read@~1.0.1: dependencies: mute-stream "~0.0.4" -readable-stream@3, readable-stream@^3.0.0, readable-stream@^3.0.2, readable-stream@^3.0.6, readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.6.0: +readable-stream@3, readable-stream@^3.0.0, readable-stream@^3.0.2, readable-stream@^3.0.6, readable-stream@^3.1.0, readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== @@ -9511,7 +9601,7 @@ readable-stream@^2.0.0, readable-stream@^2.0.5, readable-stream@^2.0.6, readable string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@~1.0.15: +readable-stream@~1.0.15, readable-stream@~1.0.31: version "1.0.34" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" integrity sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw= @@ -9879,6 +9969,11 @@ seedrandom@3.0.1: resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.1.tgz#eb3dde015bcf55df05a233514e5df44ef9dce083" integrity sha512-1/02Y/rUeU1CJBAGLebiC5Lbo5FnB22gQbIFFYTLkwvp1xdABZJH1sn4ZT1MzXmPpzv+Rf/Lu2NcsLJiK4rcDg== +semaphore-async-await@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/semaphore-async-await/-/semaphore-async-await-1.5.1.tgz#857bef5e3644601ca4b9570b87e9df5ca12974fa" + integrity sha1-hXvvXjZEYBykuVcLh+nfXKEpdPo= + semaphore@>=1.0.1, semaphore@^1.0.3, semaphore@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/semaphore/-/semaphore-1.1.0.tgz#aaad8b86b20fe8e9b32b16dc2ee682a8cd26a8aa" @@ -10710,7 +10805,7 @@ text-extensions@^1.0.0: resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.9.0.tgz#1853e45fee39c945ce6f6c36b2d659b5aabc2a26" integrity sha512-wiBrwC1EhBelW12Zy26JeOUkQ5mRu+5o8rpsJk5+2t+Y5vE7e842qtZDQ2g1NpX/29HdyFeJ4nSIhI47ENSxlQ== -through2@^2.0.0, through2@^2.0.3: +through2@^2.0.0, through2@^2.0.1, through2@^2.0.3: version "2.0.5" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" integrity sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ== @@ -10811,6 +10906,11 @@ tr46@^2.0.2: dependencies: punycode "^2.1.1" +treeify@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/treeify/-/treeify-1.1.0.tgz#4e31c6a463accd0943879f30667c4fdaff411bb8" + integrity sha512-1m4RA7xVAJrSGrrXGs0L3YTwyvBs2S8PbRHaLZAkFw7JR8oIFwYtysxlBZhYIa7xSyiYJKZ3iGrrk55cGA3i9A== + trim-newlines@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" @@ -10846,6 +10946,21 @@ ts-essentials@^6.0.3: resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-6.0.7.tgz#5f4880911b7581a873783740ce8b94da163d18a6" integrity sha512-2E4HIIj4tQJlIHuATRHayv0EfMGK3ris/GRk1E3CFnsZzeNV+hUmelbaTZHLtXaZppM5oLhHRtO04gINC4Jusw== +ts-generator@0.0.8, ts-generator@^0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/ts-generator/-/ts-generator-0.0.8.tgz#7bd48ca064db026d9520bcb682b69efc20971d6a" + integrity sha512-Gi+aZCELpVL7Mqb+GuMgM+n8JZ/arZZib1iD/R9Ok8JDjOCOCrqS9b1lr72ku7J45WeDCFZxyJoRsiQvhokCnw== + dependencies: + "@types/mkdirp" "^0.5.2" + "@types/prettier" "^1.13.2" + "@types/resolve" "^0.0.8" + chalk "^2.4.1" + glob "^7.1.2" + mkdirp "^0.5.1" + prettier "^1.14.2" + resolve "^1.8.1" + ts-essentials "^1.0.0" + ts-generator@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/ts-generator/-/ts-generator-0.1.1.tgz#af46f2fb88a6db1f9785977e9590e7bcd79220ab" @@ -11052,6 +11167,19 @@ type@^2.0.0: resolved "https://registry.yarnpkg.com/type/-/type-2.5.0.tgz#0a2e78c2e77907b252abe5f298c1b01c63f0db3d" integrity sha512-180WMDQaIMm3+7hGXWf12GtdniDEy7nYcyFMKJn/eZz/6tSLXrUN9V0wKSbMjej0I1WHWbpREDEKHtqPQa9NNw== +typechain@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/typechain/-/typechain-2.0.0.tgz#62143b48cdf8f95a777f1b76617af077b2d44eee" + integrity sha512-O+hsAUwtBpqCfoq46Grm52OEdm0GBEu78LxrEzkkGdwUdCoCZpNb2HPzPoNB1MXiRnNhEOGMFyf05UbT2/bUEw== + dependencies: + command-line-args "^4.0.7" + debug "^4.1.1" + fs-extra "^7.0.0" + js-sha3 "^0.8.0" + lodash "^4.17.15" + ts-essentials "^6.0.3" + ts-generator "^0.0.8" + typechain@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/typechain/-/typechain-3.0.0.tgz#d5a47700831f238e43f7429b987b4bb54849b92e" @@ -11201,6 +11329,11 @@ unset-value@^1.0.0: has-value "^0.3.1" isobject "^3.0.0" +untildify@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/untildify/-/untildify-4.0.0.tgz#2bc947b953652487e4600949fb091e3ae8cd919b" + integrity sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw== + upath@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/upath/-/upath-2.0.1.tgz#50c73dea68d6f6b990f51d279ce6081665d61a8b" @@ -12003,7 +12136,7 @@ yargs@13.3.2, yargs@^13.3.0: y18n "^4.0.0" yargs-parser "^13.1.2" -yargs@16.2.0, yargs@^16.2.0: +yargs@16.2.0, yargs@^16.1.0, yargs@^16.2.0: version "16.2.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==