From 84c09bacb93dca375fa5f4439cf0ba7e90ecbdf3 Mon Sep 17 00:00:00 2001 From: daveroga Date: Fri, 16 Sep 2022 12:19:49 +0200 Subject: [PATCH 01/19] feat: add test admin --- package.json | 1 + test/administrator.test.mjs | 59 ++ test/contracts.mjs | 12 + test/contracts/Challenges.json | 1804 ++++++++++++++++++++++++++++++++ test/contracts/Proposers.json | 468 +++++++++ test/contracts/Shield.json | 1245 ++++++++++++++++++++++ test/contracts/State.json | 1609 ++++++++++++++++++++++++++++ 7 files changed, 5198 insertions(+) create mode 100644 test/administrator.test.mjs create mode 100644 test/contracts.mjs create mode 100644 test/contracts/Challenges.json create mode 100644 test/contracts/Proposers.json create mode 100644 test/contracts/Shield.json create mode 100644 test/contracts/State.json diff --git a/package.json b/package.json index d2a207216..817f6de5b 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "test-erc1155-tokens": "npx hardhat test --bail --no-compile --grep ERC1155", "test-erc20-cli": "npx hardhat test --no-compile --bail test/client/erc20.test.mjs ", "ping-pong": "npx hardhat test --bail --no-compile test/ping-pong/ping-pong.test.mjs", + "test-administrator": "npx hardhat test --bail --no-compile test/administrator.test.mjs ", "test-optimist-sync": "npx hardhat test --no-compile --bail test/optimist-resync.test.mjs", "test-adversary": "CHALLENGE_TYPE=${CHALLENGE_TYPE} npx hardhat test --no-compile --bail test/adversary.test.mjs", "test-all-adversary": "for CHALLENGE_TYPE in IncorrectTreeRoot IncorrectLeafCount IncorrectTreeRoot IncorrectLeafCount; do CHALLENGE_TYPE=${CHALLENGE_TYPE} npm run test-adversary; sleep 5; done", diff --git a/test/administrator.test.mjs b/test/administrator.test.mjs new file mode 100644 index 000000000..d9e58cb85 --- /dev/null +++ b/test/administrator.test.mjs @@ -0,0 +1,59 @@ +/* This test relies on nightfall_3/cli + */ + +/* eslint-disable no-await-in-loop */ +import chai from 'chai'; +import chaiHttp from 'chai-http'; +import config from 'config'; +import chaiAsPromised from 'chai-as-promised'; +import Nf3 from '../cli/lib/nf3.mjs'; +import contractABIs from './contracts.mjs'; + +const { expect } = chai; +chai.use(chaiHttp); +chai.use(chaiAsPromised); + +const environment = config.ENVIRONMENTS[process.env.ENVIRONMENT] || config.ENVIRONMENTS.localhost; + +const { mnemonics, signingKeys } = config.TEST_OPTIONS; + +const getContractInstance = async (contractName, nf3) => { + const abi = contractABIs[contractName]; + const contractAddress = await nf3.getContractAddress(contractName); + const contractInstance = new nf3.web3.eth.Contract(abi, contractAddress); + return { contractAddress, contractInstance }; +}; + +describe(`Testing Administrator`, () => { + let nf3User; + let stateContractInstance; + + before(async () => { + nf3User = new Nf3(signingKeys.user1, environment); + + await nf3User.init(mnemonics.user1); + + if (!(await nf3User.healthcheck('client'))) throw new Error('Healthcheck failed'); + + ({ contractInstance: stateContractInstance } = await getContractInstance('State', nf3User)); + }); + + describe(`Basic tests`, () => { + it('Be able to get owner of the State contract and check that is the multisig', async () => { + const owner = await stateContractInstance.methods.owner().call(); + const multisigAddress = await nf3User.getContractAddress('SimpleMultiSig'); + console.log(owner, multisigAddress); + expect(owner.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); + }); + + /* it('Be able to transfer ownership of contracts from multisig to a specific one', async () => { + // TODO: calls to multisig to change contracts ownership + const owner = await stateContractInstance.methods.owner().call(); + expect(owner.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); + }); */ + }); + + after(async () => { + nf3User.close(); + }); +}); diff --git a/test/contracts.mjs b/test/contracts.mjs new file mode 100644 index 000000000..4e46451a8 --- /dev/null +++ b/test/contracts.mjs @@ -0,0 +1,12 @@ +import Shield from './contracts/Shield.json' assert { type: 'json' }; +import Proposers from './contracts/Proposers.json' assert { type: 'json' }; +import Challenges from './contracts/Challenges.json' assert { type: 'json' }; +import State from './contracts/State.json' assert { type: 'json' }; + +// ignore unused exports default +export default { + Shield, + Proposers, + Challenges, + State, +}; diff --git a/test/contracts/Challenges.json b/test/contracts/Challenges.json new file mode 100644 index 000000000..4c0b654ad --- /dev/null +++ b/test/contracts/Challenges.json @@ -0,0 +1,1804 @@ +[ + { + "anonymous": false, + "inputs": [], + "name": "BlockProposed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "commitHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "CommittedToChallenge", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "withdrawTransactionHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "paidBy", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "InstantWithdrawalRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "NewBootChallengerSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "NewBootProposerSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "proposer", + "type": "address" + } + ], + "name": "NewCurrentProposer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "leafIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "leafValue", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + } + ], + "name": "NewLeaf", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "minLeafIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32[]", + "name": "leafValues", + "type": "bytes32[]" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + } + ], + "name": "NewLeaves", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + } + ], + "name": "Rollback", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "ercAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ShieldBalanceTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "TransactionSubmitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "enum Structures.TransactionTypes", + "name": "txType", + "type": "uint8" + } + ], + "name": "VkChanged", + "type": "event" + }, + { + "inputs": [], + "name": "_owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "committers", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBootChallenger", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBootProposer", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMaticAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "transactionType", + "type": "uint256" + } + ], + "name": "getRestriction", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum Structures.TransactionTypes", + "name": "txType", + "type": "uint8" + } + ], + "name": "getVerificationKey", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_vk", + "type": "uint256[]" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "_txType", + "type": "uint8" + } + ], + "name": "registerVerificationKey", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddr", + "type": "address" + } + ], + "name": "removeRestriction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "challenger", + "type": "address" + } + ], + "name": "setBootChallenger", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "proposer", + "type": "address" + } + ], + "name": "setBootProposer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_maticAddress", + "type": "address" + } + ], + "name": "setMaticAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "depositAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "setRestriction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "stateAddress", + "type": "address" + } + ], + "name": "setStateContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "state", + "outputs": [ + { + "internalType": "contract State", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum Structures.TransactionTypes", + "name": "", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "vks", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "priorBlockL2", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction[]", + "name": "priorBlockTransactions", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "blockL2", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction[]", + "name": "transactions", + "type": "tuple[]" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + } + ], + "name": "challengeLeafCountCorrect", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "priorBlockL2", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction[]", + "name": "priorBlockTransactions", + "type": "tuple[]" + }, + { + "internalType": "bytes32[33]", + "name": "frontierPriorBlock", + "type": "bytes32[33]" + }, + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "blockL2", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction[]", + "name": "transactions", + "type": "tuple[]" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + } + ], + "name": "challengeNewRootCorrect", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "block1", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "block2", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction[]", + "name": "transactions1", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction[]", + "name": "transactions2", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "transaction1Index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "transaction2Index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "commitment1Index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "commitment2Index", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + } + ], + "name": "challengeCommitment", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "block1", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "block2", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction[]", + "name": "transactions1", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction[]", + "name": "transactions2", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "transaction1Index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "transaction2Index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nullifier1Index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nullifier2Index", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + } + ], + "name": "challengeNullifier", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "blockL2", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction[]", + "name": "transactions", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "transactionIndex", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block[4]", + "name": "blockL2ContainingHistoricRoot", + "type": "tuple[4]" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction[][4]", + "name": "transactionsOfblockL2ContainingHistoricRoot", + "type": "tuple[][4]" + }, + { + "internalType": "uint256[8]", + "name": "uncompressedProof", + "type": "uint256[8]" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + } + ], + "name": "challengeProofVerification", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "blockL2", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction[]", + "name": "transactions", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "transactionIndex", + "type": "uint256" + } + ], + "name": "challengeHistoricRoot", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "commitHash", + "type": "bytes32" + } + ], + "name": "commitToChallenge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/test/contracts/Proposers.json b/test/contracts/Proposers.json new file mode 100644 index 000000000..a4c6e2868 --- /dev/null +++ b/test/contracts/Proposers.json @@ -0,0 +1,468 @@ +[ + { + "anonymous": false, + "inputs": [], + "name": "BlockProposed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "commitHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "CommittedToChallenge", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "withdrawTransactionHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "paidBy", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "InstantWithdrawalRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "NewBootChallengerSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "NewBootProposerSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "proposer", + "type": "address" + } + ], + "name": "NewCurrentProposer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "leafIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "leafValue", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + } + ], + "name": "NewLeaf", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "minLeafIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32[]", + "name": "leafValues", + "type": "bytes32[]" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + } + ], + "name": "NewLeaves", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + } + ], + "name": "Rollback", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "ercAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ShieldBalanceTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "TransactionSubmitted", + "type": "event" + }, + { + "inputs": [], + "name": "_owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBootChallenger", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBootProposer", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMaticAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "transactionType", + "type": "uint256" + } + ], + "name": "getRestriction", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddr", + "type": "address" + } + ], + "name": "removeRestriction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "challenger", + "type": "address" + } + ], + "name": "setBootChallenger", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "proposer", + "type": "address" + } + ], + "name": "setBootProposer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_maticAddress", + "type": "address" + } + ], + "name": "setMaticAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "depositAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "setRestriction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "stateAddress", + "type": "address" + } + ], + "name": "setStateContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "state", + "outputs": [ + { + "internalType": "contract State", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "changeCurrentProposer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "name": "registerProposer", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "deRegisterProposer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawBond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "name": "updateProposer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/test/contracts/Shield.json b/test/contracts/Shield.json new file mode 100644 index 000000000..14fa6ecfd --- /dev/null +++ b/test/contracts/Shield.json @@ -0,0 +1,1245 @@ +[ + { + "anonymous": false, + "inputs": [], + "name": "BlockProposed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "commitHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "CommittedToChallenge", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "withdrawTransactionHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "paidBy", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "InstantWithdrawalRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "NewBootChallengerSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "NewBootProposerSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "proposer", + "type": "address" + } + ], + "name": "NewCurrentProposer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "leafIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "leafValue", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + } + ], + "name": "NewLeaf", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "minLeafIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32[]", + "name": "leafValues", + "type": "bytes32[]" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + } + ], + "name": "NewLeaves", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + } + ], + "name": "Rollback", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "ercAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ShieldBalanceTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "TransactionSubmitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "enum Structures.TransactionTypes", + "name": "txType", + "type": "uint8" + } + ], + "name": "VkChanged", + "type": "event" + }, + { + "inputs": [], + "name": "_owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "advancedFeeWithdrawals", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "advancedWithdrawals", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBootChallenger", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBootProposer", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMaticAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "transactionType", + "type": "uint256" + } + ], + "name": "getRestriction", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum Structures.TransactionTypes", + "name": "txType", + "type": "uint8" + } + ], + "name": "getVerificationKey", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_vk", + "type": "uint256[]" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "_txType", + "type": "uint8" + } + ], + "name": "registerVerificationKey", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddr", + "type": "address" + } + ], + "name": "removeRestriction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "challenger", + "type": "address" + } + ], + "name": "setBootChallenger", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "proposer", + "type": "address" + } + ], + "name": "setBootProposer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_maticAddress", + "type": "address" + } + ], + "name": "setMaticAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "depositAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "setRestriction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "stateAddress", + "type": "address" + } + ], + "name": "setStateContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "state", + "outputs": [ + { + "internalType": "contract State", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum Structures.TransactionTypes", + "name": "", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "vks", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "withdrawn", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction", + "name": "t", + "type": "tuple" + } + ], + "name": "submitTransaction", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "b", + "type": "tuple" + } + ], + "name": "requestBlockPayment", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "onERC721Received", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_id", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "onERC1155Received", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "b", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction", + "name": "t", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "bytes32[]", + "name": "siblingPath", + "type": "bytes32[]" + } + ], + "name": "isValidWithdrawal", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "b", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction", + "name": "t", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "bytes32[]", + "name": "siblingPath", + "type": "bytes32[]" + } + ], + "name": "finaliseWithdrawal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction", + "name": "withdrawTransaction", + "type": "tuple" + } + ], + "name": "advanceWithdrawal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "b", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction", + "name": "t", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "bytes32[]", + "name": "siblingPath", + "type": "bytes32[]" + } + ], + "name": "setAdvanceWithdrawalFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + } +] diff --git a/test/contracts/State.json b/test/contracts/State.json new file mode 100644 index 000000000..26d195775 --- /dev/null +++ b/test/contracts/State.json @@ -0,0 +1,1609 @@ +[ + { + "anonymous": false, + "inputs": [], + "name": "BlockProposed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "commitHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "CommittedToChallenge", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "withdrawTransactionHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "paidBy", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "InstantWithdrawalRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "NewBootChallengerSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "NewBootProposerSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "proposer", + "type": "address" + } + ], + "name": "NewCurrentProposer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "leafIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "leafValue", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + } + ], + "name": "NewLeaf", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "minLeafIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32[]", + "name": "leafValues", + "type": "bytes32[]" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + } + ], + "name": "NewLeaves", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + } + ], + "name": "Rollback", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "ercAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ShieldBalanceTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "TransactionSubmitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "_owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "blockHashes", + "outputs": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "bondAccounts", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "challengesAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "claimedBlockStakes", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "currentProposer", + "outputs": [ + { + "internalType": "address", + "name": "thisAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "previousAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "nextAddress", + "type": "address" + }, + { + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "feeBook", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBootChallenger", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBootProposer", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMaticAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "transactionType", + "type": "uint256" + } + ], + "name": "getRestriction", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "pendingWithdrawals", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proposerStartBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "proposers", + "outputs": [ + { + "internalType": "address", + "name": "thisAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "previousAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "nextAddress", + "type": "address" + }, + { + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proposersAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddr", + "type": "address" + } + ], + "name": "removeRestriction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "challenger", + "type": "address" + } + ], + "name": "setBootChallenger", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "proposer", + "type": "address" + } + ], + "name": "setBootProposer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_maticAddress", + "type": "address" + } + ], + "name": "setMaticAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "depositAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "setRestriction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "shieldAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_proposersAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_challengesAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_shieldAddress", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "b", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction[]", + "name": "t", + "type": "tuple[]" + } + ], + "name": "proposeBlock", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "blockNumberL2ToRollbackTo", + "type": "uint256" + } + ], + "name": "emitRollback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "thisAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "previousAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "nextAddress", + "type": "address" + }, + { + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "internalType": "struct Structures.LinkedAddress", + "name": "proposer", + "type": "tuple" + } + ], + "name": "setProposer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "getProposer", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "thisAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "previousAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "nextAddress", + "type": "address" + }, + { + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "internalType": "struct Structures.LinkedAddress", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "deleteProposer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "proposer", + "type": "address" + } + ], + "name": "setCurrentProposer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentProposer", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "thisAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "previousAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "nextAddress", + "type": "address" + }, + { + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "internalType": "struct Structures.LinkedAddress", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + } + ], + "name": "getFeeBookInfo", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feePaymentsEth", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feePaymentsMatic", + "type": "uint256" + } + ], + "name": "setFeeBookInfo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "internalType": "struct Structures.BlockData", + "name": "bd", + "type": "tuple" + } + ], + "name": "pushBlockData", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "popBlockData", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "internalType": "struct Structures.BlockData", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + } + ], + "name": "getBlockData", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "internalType": "struct Structures.BlockData", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllBlockData", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "internalType": "struct Structures.BlockData[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getNumberOfL2Blocks", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLatestBlockHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountEth", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountMatic", + "type": "uint256" + } + ], + "name": "addPendingWithdrawal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sb", + "type": "uint256" + } + ], + "name": "setProposerStartBlock", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getProposerStartBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "proposer", + "type": "address" + } + ], + "name": "removeProposer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "name": "updateProposer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "b", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction[]", + "name": "ts", + "type": "tuple[]" + } + ], + "name": "areBlockAndTransactionsReal", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "leafCount", + "type": "uint48" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "blockNumberL2", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "previousBlockHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionHashesRoot", + "type": "bytes32" + } + ], + "internalType": "struct Structures.Block", + "name": "b", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint112", + "name": "value", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "fee", + "type": "uint112" + }, + { + "internalType": "enum Structures.TransactionTypes", + "name": "transactionType", + "type": "uint8" + }, + { + "internalType": "enum Structures.TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "uint64[4]", + "name": "historicRootBlockNumberL2", + "type": "uint64[4]" + }, + { + "internalType": "bytes32", + "name": "tokenId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "ercAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recipientAddress", + "type": "bytes32" + }, + { + "internalType": "bytes32[3]", + "name": "commitments", + "type": "bytes32[3]" + }, + { + "internalType": "bytes32[4]", + "name": "nullifiers", + "type": "bytes32[4]" + }, + { + "internalType": "bytes32[2]", + "name": "compressedSecrets", + "type": "bytes32[2]" + }, + { + "internalType": "uint256[4]", + "name": "proof", + "type": "uint256[4]" + } + ], + "internalType": "struct Structures.Transaction", + "name": "t", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "bytes32[]", + "name": "siblingPath", + "type": "bytes32[]" + } + ], + "name": "areBlockAndTransactionReal", + "outputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "setBondAccount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "getBondAccount", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "internalType": "struct Structures.TimeLockedBond", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "challengerAddr", + "type": "address" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "numRemoved", + "type": "uint256" + } + ], + "name": "rewardChallenger", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "updateBondAccountTime", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + } + ], + "name": "isBlockStakeWithdrawn", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + } + ], + "name": "setBlockStakeWithdrawn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] From 426ac04599778c119e64672ea39d0970f09e8d4f Mon Sep 17 00:00:00 2001 From: daveroga Date: Fri, 16 Sep 2022 12:28:28 +0200 Subject: [PATCH 02/19] feat: add test admin --- .babelrc.json | 3 +++ package.json | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 .babelrc.json diff --git a/.babelrc.json b/.babelrc.json new file mode 100644 index 000000000..fe4b2709f --- /dev/null +++ b/.babelrc.json @@ -0,0 +1,3 @@ +{ + "plugins": ["@babel/plugin-syntax-import-assertions"] +} diff --git a/package.json b/package.json index 817f6de5b..a16b3a41b 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,11 @@ "version": "0.0.1", "description": "Optimistic Nightfall", "main": "./nightfall-client/src/index.mjs", + "babel": { + "plugins": [ + "@babel/plugin-syntax-import-assertions" + ] + }, "scripts": { "lint": "eslint . --ext js,mjs,jsx,ts,tsx && find-unused-exports", "prepare": "husky install", From 78b57cc8ff112ef7863ea9f4c7480a8e6366a6a3 Mon Sep 17 00:00:00 2001 From: daveroga Date: Sun, 18 Sep 2022 09:50:48 +0200 Subject: [PATCH 03/19] fix: plugin balbel import assertions --- .babelrc.json | 3 --- .eslintrc.js | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-) delete mode 100644 .babelrc.json diff --git a/.babelrc.json b/.babelrc.json deleted file mode 100644 index fe4b2709f..000000000 --- a/.babelrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["@babel/plugin-syntax-import-assertions"] -} diff --git a/.eslintrc.js b/.eslintrc.js index 0bcb57f9e..5d8fffe95 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,13 +9,18 @@ module.exports = { 'func-names': 'off', 'no-sparse-arrays': 'off', }, - parser: 'babel-eslint', // Uses babel-eslint transforms. + parser: '@babel/eslint-parser', parserOptions: { ecmaFeatures: { jsx: true, }, ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features sourceType: 'module', // Allows for the use of imports + babelOptions: { + plugins: ['@babel/plugin-syntax-import-assertions'], + babelrc: false, + configFile: false, + }, }, settings: { 'import/resolver': { From 492a28f830c4aa115b0a031def135c71f92e9e47 Mon Sep 17 00:00:00 2001 From: daveroga Date: Mon, 19 Sep 2022 15:25:21 +0200 Subject: [PATCH 04/19] feat: add tests --- test/administrator.test.mjs | 123 +++++++++++++++++++++++++++++++++--- 1 file changed, 115 insertions(+), 8 deletions(-) diff --git a/test/administrator.test.mjs b/test/administrator.test.mjs index d9e58cb85..ecaea969d 100644 --- a/test/administrator.test.mjs +++ b/test/administrator.test.mjs @@ -21,36 +21,143 @@ const getContractInstance = async (contractName, nf3) => { const abi = contractABIs[contractName]; const contractAddress = await nf3.getContractAddress(contractName); const contractInstance = new nf3.web3.eth.Contract(abi, contractAddress); - return { contractAddress, contractInstance }; + return contractInstance; }; describe(`Testing Administrator`, () => { let nf3User; let stateContractInstance; + let proposersContractInstance; + let shieldContractInstance; + let challengesContractInstance; before(async () => { nf3User = new Nf3(signingKeys.user1, environment); await nf3User.init(mnemonics.user1); - if (!(await nf3User.healthcheck('client'))) throw new Error('Healthcheck failed'); + stateContractInstance = await getContractInstance('State', nf3User); + proposersContractInstance = await getContractInstance('Proposers', nf3User); + shieldContractInstance = await getContractInstance('Shield', nf3User); + challengesContractInstance = await getContractInstance('Challenges', nf3User); - ({ contractInstance: stateContractInstance } = await getContractInstance('State', nf3User)); + if (!(await nf3User.healthcheck('client'))) throw new Error('Healthcheck failed'); }); describe(`Basic tests`, () => { - it('Be able to get owner of the State contract and check that is the multisig', async () => { - const owner = await stateContractInstance.methods.owner().call(); + it('Owner of the State, Proposers, Shield and Challenges contract should be the multisig', async function () { + const ownerState = await stateContractInstance.methods.owner().call(); + const ownerShield = await shieldContractInstance.methods.owner().call(); + const ownerProposers = await proposersContractInstance.methods.owner().call(); + const ownerChallenges = await challengesContractInstance.methods.owner().call(); const multisigAddress = await nf3User.getContractAddress('SimpleMultiSig'); - console.log(owner, multisigAddress); - expect(owner.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); + + if (ownerState.toUpperCase() !== multisigAddress.toUpperCase()) this.skip(); + // console.log(ownerState, multisigAddress); + expect(ownerState.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); + expect(ownerShield.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); + expect(ownerProposers.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); + expect(ownerChallenges.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); }); /* it('Be able to transfer ownership of contracts from multisig to a specific one', async () => { - // TODO: calls to multisig to change contracts ownership + // TODO: calls to multisig to change contracts ownership. Now you can do it manually through nightfall-administrator const owner = await stateContractInstance.methods.owner().call(); expect(owner.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); }); */ + + it('Set boot proposer', async () => { + await shieldContractInstance.methods + .setBootProposer(nf3User.ethereumAddress) + .send({ from: nf3User.ethereumAddress }); + const bootProposer = await shieldContractInstance.methods.getBootProposer().call(); + + expect(bootProposer.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); + }); + + it('Set boot challenger', async () => { + await shieldContractInstance.methods + .setBootChallenger(nf3User.ethereumAddress) + .send({ from: nf3User.ethereumAddress }); + const bootChallenger = await shieldContractInstance.methods.getBootChallenger().call(); + + expect(bootChallenger.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); + }); + + it('Set restriction', async () => { + await shieldContractInstance.methods + .setRestriction(nf3User.ethereumAddress, 10, 100) + .send({ from: nf3User.ethereumAddress }); + const restrictionDeposit = await shieldContractInstance.methods + .getRestriction(nf3User.ethereumAddress, 0) + .call(); + const restrictionWithdraw = await shieldContractInstance.methods + .getRestriction(nf3User.ethereumAddress, 1) + .call(); + + expect(Number(restrictionDeposit)).to.be.equal(10); + expect(Number(restrictionWithdraw)).to.be.equal(100); + }); + + it('Remove restriction', async () => { + await shieldContractInstance.methods + .removeRestriction(nf3User.ethereumAddress) + .send({ from: nf3User.ethereumAddress }); + const restrictionDeposit = await shieldContractInstance.methods + .getRestriction(nf3User.ethereumAddress, 0) + .call(); + const restrictionWithdraw = await shieldContractInstance.methods + .getRestriction(nf3User.ethereumAddress, 1) + .call(); + + expect(Number(restrictionDeposit)).to.be.equal(0); + expect(Number(restrictionWithdraw)).to.be.equal(0); + }); + + it('Set MATIC address', async () => { + await shieldContractInstance.methods + .setMaticAddress(nf3User.ethereumAddress) + .send({ from: nf3User.ethereumAddress }); + const maticAddress = await shieldContractInstance.methods.getMaticAddress().call(); + + expect(maticAddress.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); + }); + + it('Pause State contract', async () => { + const paused1 = await stateContractInstance.methods.paused().call(); + await stateContractInstance.methods.pause().send({ from: nf3User.ethereumAddress }); + const paused2 = await stateContractInstance.methods.paused().call(); + + expect(paused1).to.be.equal(false); + expect(paused2).to.be.equal(true); + }); + + it('Unpause State contract', async () => { + const paused1 = await stateContractInstance.methods.paused().call(); + await stateContractInstance.methods.unpause().send({ from: nf3User.ethereumAddress }); + const paused2 = await stateContractInstance.methods.paused().call(); + + expect(paused1).to.be.equal(true); + expect(paused2).to.be.equal(false); + }); + + it('Pause Shield contract', async () => { + const paused1 = await shieldContractInstance.methods.paused().call(); + await shieldContractInstance.methods.pause().send({ from: nf3User.ethereumAddress }); + const paused2 = await shieldContractInstance.methods.paused().call(); + + expect(paused1).to.be.equal(false); + expect(paused2).to.be.equal(true); + }); + + it('Unpause Shield contract', async () => { + const paused1 = await shieldContractInstance.methods.paused().call(); + await shieldContractInstance.methods.unpause().send({ from: nf3User.ethereumAddress }); + const paused2 = await shieldContractInstance.methods.paused().call(); + + expect(paused1).to.be.equal(true); + expect(paused2).to.be.equal(false); + }); }); after(async () => { From 60507cc34e5785ec67ccfa11c785e352a6c5413d Mon Sep 17 00:00:00 2001 From: daveroga Date: Tue, 20 Sep 2022 11:01:40 +0200 Subject: [PATCH 05/19] feat: add multisig helper --- test/administrator.test.mjs | 67 ++++++++- test/contracts.mjs | 2 + test/contracts/SimpleMultiSig.json | 151 +++++++++++++++++++ test/multisig/multisig.mjs | 227 +++++++++++++++++++++++++++++ 4 files changed, 441 insertions(+), 6 deletions(-) create mode 100644 test/contracts/SimpleMultiSig.json create mode 100644 test/multisig/multisig.mjs diff --git a/test/administrator.test.mjs b/test/administrator.test.mjs index ecaea969d..c99cb47a0 100644 --- a/test/administrator.test.mjs +++ b/test/administrator.test.mjs @@ -8,6 +8,7 @@ import config from 'config'; import chaiAsPromised from 'chai-as-promised'; import Nf3 from '../cli/lib/nf3.mjs'; import contractABIs from './contracts.mjs'; +import { MultiSig } from './multisig/multisig.mjs'; const { expect } = chai; chai.use(chaiHttp); @@ -15,7 +16,7 @@ chai.use(chaiAsPromised); const environment = config.ENVIRONMENTS[process.env.ENVIRONMENT] || config.ENVIRONMENTS.localhost; -const { mnemonics, signingKeys } = config.TEST_OPTIONS; +const { mnemonics, signingKeys, addresses } = config.TEST_OPTIONS; const getContractInstance = async (contractName, nf3) => { const abi = contractABIs[contractName]; @@ -30,6 +31,8 @@ describe(`Testing Administrator`, () => { let proposersContractInstance; let shieldContractInstance; let challengesContractInstance; + let multisigContractInstance; + let multisig; before(async () => { nf3User = new Nf3(signingKeys.user1, environment); @@ -40,8 +43,21 @@ describe(`Testing Administrator`, () => { proposersContractInstance = await getContractInstance('Proposers', nf3User); shieldContractInstance = await getContractInstance('Shield', nf3User); challengesContractInstance = await getContractInstance('Challenges', nf3User); + multisigContractInstance = await getContractInstance('SimpleMultiSig', nf3User); if (!(await nf3User.healthcheck('client'))) throw new Error('Healthcheck failed'); + multisig = new MultiSig( + nf3User.web3, + { + state: stateContractInstance, + proposers: proposersContractInstance, + shield: shieldContractInstance, + challenges: challengesContractInstance, + multisig: multisigContractInstance, + }, + 2, + await nf3User.web3.eth.getChainId(), + ); }); describe(`Basic tests`, () => { @@ -50,21 +66,33 @@ describe(`Testing Administrator`, () => { const ownerShield = await shieldContractInstance.methods.owner().call(); const ownerProposers = await proposersContractInstance.methods.owner().call(); const ownerChallenges = await challengesContractInstance.methods.owner().call(); - const multisigAddress = await nf3User.getContractAddress('SimpleMultiSig'); + const multisigAddress = multisigContractInstance.options.address; - if (ownerState.toUpperCase() !== multisigAddress.toUpperCase()) this.skip(); - // console.log(ownerState, multisigAddress); expect(ownerState.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); expect(ownerShield.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); expect(ownerProposers.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); expect(ownerChallenges.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); }); - /* it('Be able to transfer ownership of contracts from multisig to a specific one', async () => { + it('Be able to transfer ownership of contracts from multisig to a specific one', async () => { // TODO: calls to multisig to change contracts ownership. Now you can do it manually through nightfall-administrator + await multisig.transferOwnership( + signingKeys.user1, + signingKeys.user1, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + const approved = await multisig.transferOwnership( + signingKeys.user1, + signingKeys.user2, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + + await multisig.executeMultiSigTransactions(approved, signingKeys.user1); const owner = await stateContractInstance.methods.owner().call(); expect(owner.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); - }); */ + }); it('Set boot proposer', async () => { await shieldContractInstance.methods @@ -158,6 +186,33 @@ describe(`Testing Administrator`, () => { expect(paused1).to.be.equal(true); expect(paused2).to.be.equal(false); }); + + it('Restore multisig', async () => { + const multisigAddress = multisigContractInstance.options.address; + await Promise.all([ + shieldContractInstance.methods + .transferOwnership(multisigAddress) + .send({ from: nf3User.ethereumAddress }), + stateContractInstance.methods + .transferOwnership(multisigAddress) + .send({ from: nf3User.ethereumAddress }), + proposersContractInstance.methods + .transferOwnership(multisigAddress) + .send({ from: nf3User.ethereumAddress }), + challengesContractInstance.methods + .transferOwnership(multisigAddress) + .send({ from: nf3User.ethereumAddress }), + ]); + + const ownerState = await stateContractInstance.methods.owner().call(); + const ownerShield = await shieldContractInstance.methods.owner().call(); + const ownerProposers = await proposersContractInstance.methods.owner().call(); + const ownerChallenges = await challengesContractInstance.methods.owner().call(); + expect(ownerState.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); + expect(ownerShield.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); + expect(ownerProposers.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); + expect(ownerChallenges.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); + }); }); after(async () => { diff --git a/test/contracts.mjs b/test/contracts.mjs index 4e46451a8..8bed6f43b 100644 --- a/test/contracts.mjs +++ b/test/contracts.mjs @@ -2,6 +2,7 @@ import Shield from './contracts/Shield.json' assert { type: 'json' }; import Proposers from './contracts/Proposers.json' assert { type: 'json' }; import Challenges from './contracts/Challenges.json' assert { type: 'json' }; import State from './contracts/State.json' assert { type: 'json' }; +import SimpleMultiSig from './contracts/SimpleMultiSig.json' assert { type: 'json' }; // ignore unused exports default export default { @@ -9,4 +10,5 @@ export default { Proposers, Challenges, State, + SimpleMultiSig, }; diff --git a/test/contracts/SimpleMultiSig.json b/test/contracts/SimpleMultiSig.json new file mode 100644 index 000000000..ebb1c0620 --- /dev/null +++ b/test/contracts/SimpleMultiSig.json @@ -0,0 +1,151 @@ +[ + { + "inputs": [ + { + "internalType": "uint256", + "name": "threshold_", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "owners_", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "nonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "ownersArr", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "threshold", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [], + "name": "owners", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "threshold_", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "owners_", + "type": "address[]" + } + ], + "name": "setOwners", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8[]", + "name": "sigV", + "type": "uint8[]" + }, + { + "internalType": "bytes32[]", + "name": "sigR", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "sigS", + "type": "bytes32[]" + }, + { + "internalType": "address", + "name": "destination", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "address", + "name": "executor", + "type": "address" + }, + { + "internalType": "uint256", + "name": "gasLimit", + "type": "uint256" + } + ], + "name": "execute", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/test/multisig/multisig.mjs b/test/multisig/multisig.mjs new file mode 100644 index 000000000..12ddb9e0e --- /dev/null +++ b/test/multisig/multisig.mjs @@ -0,0 +1,227 @@ +/* ignore unused exports */ +import config from 'config'; +import { ecsign } from 'ethereumjs-util'; +import logger from 'common-files/utils/logger.mjs'; + +const { WEB3_OPTIONS } = config; + +// eslint-disable-next-line import/prefer-default-export +export class MultiSig { + transactions = []; + + contractInstancesOwnables = []; + + MULTISIG_CONSTANTS = {}; + + SIGNATURE_THRESHOLD = 2; + + web3; + + constructor(web3Provider, contractInstances, signatureThreshold, chainId) { + // constants used to create a mutlisig data structure + const EIP712DOMAINTYPE_HASH = + '0xd87cd6ef79d4e2b95e15ce8abf732db51ec771f1ca2edccf22a46c729ac56472'; + // keccak256("Simple MultiSig") + const NAME_HASH = '0xb7a0bfa1b79f2443f4d73ebb9259cddbcd510b18be6fc4da7d1aa7b1786e73e6'; + // keccak256("1") + const VERSION_HASH = '0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6'; + // keccak256("MultiSigTransaction(address destination,uint256 value,bytes data,uint256 nonce,address executor,uint256 gasLimit)") + const TXTYPE_HASH = '0x3ee892349ae4bbe61dce18f95115b5dc02daf49204cc602458cd4c1f540d56d7'; + const SALT = '0x251543af6a222378665a76fe38dbceae4871a070b7fdaf5c6c30cf758dc33cc0'; + // compute the EIP-712 domain separator + const domainSeparatorABI = ['bytes32', 'bytes32', 'bytes32', 'uint', 'address', 'bytes32']; + const domainSeparator = [ + EIP712DOMAINTYPE_HASH, + NAME_HASH, + VERSION_HASH, + chainId, + contractInstances.multisig.options.address, + SALT, + ]; + this.contractInstancesOwnables.push( + contractInstances.shield, + contractInstances.state, + contractInstances.proposers, + contractInstances.challenges, + ); + this.SIGNATURE_THRESHOLD = signatureThreshold; + this.web3 = web3Provider; + const domainSeparatorEncoded = this.web3.eth.abi.encodeParameters( + domainSeparatorABI, + domainSeparator, + ); + const DOMAIN_SEPARATOR = this.web3.utils.soliditySha3({ + t: 'bytes', + v: domainSeparatorEncoded, + }); + this.MULTISIG_CONSTANTS.domainSeparator = DOMAIN_SEPARATOR; + this.MULTISIG_CONSTANTS.txTypeHash = TXTYPE_HASH; + this.MULTISIG_CONSTANTS.multiSigInstance = contractInstances.multisig; + this.MULTISIG_CONSTANTS.txInputHashABI = [ + 'bytes32', + 'address', + 'uint', + 'bytes32', + 'uint', + 'address', + 'uint', + ]; + } + + async sendTransaction(unsignedTransaction, signingKey, contractAddress) { + const tx = { + from: this.web3.eth.accounts.privateKeyToAccount(signingKey).address, + to: contractAddress, + data: unsignedTransaction, + gas: WEB3_OPTIONS.gas, + gasPrice: await this.web3.eth.getGasPrice(), + }; + const signed = await this.web3.eth.accounts.signTransaction(tx, signingKey); + return this.web3.eth.sendSignedTransaction(signed.rawTransaction); + } + + /** + Function to save a signed transaction, ready for the multisig + */ + async saveSigned(signed) { + this.transactions.push({ _id: signed.messageHash.concat(signed.by.slice(2)), ...signed }); + } + + /** + Function to get the signatures + */ + async getSigned(messageHash) { + return this.transactions.filter(t => t.messageHash === messageHash); + } + + /** + Function to check that there are enough transactions to send some signed data + */ + async checkThreshold(messageHash) { + return this.transactions.filter(t => t.messageHash === messageHash).length; + } + + // This function saves a signed transaction and will return the array of so-far signed + // transactions + async addSignedTransaction(signed) { + // save the signed transaction until we meet the signature threshold, only if it's actually signed + if (signed.r) { + try { + await this.saveSigned(signed); + } catch (err) { + if (err.message.includes('duplicate key')) + console.log('You have already signed this message - no action taken'); + else throw new Error(err); + } + } + const numberOfSignatures = await this.checkThreshold(signed.messageHash); + logger.info(`Number of signatures for this transaction is ${numberOfSignatures}`); + if (numberOfSignatures === this.SIGNATURE_THRESHOLD) logger.info(`Signature threshold reached`); + const signedArray = (await this.getSigned(signed.messageHash)).sort((a, b) => { + const x = BigInt(a.by); + const y = BigInt(b.by); + return x < y ? -1 : x > y ? 1 : 0; // eslint-disable-line no-nested-ternary + }); + return signedArray; + } + + // This function creates the multisig message hash, which is signed (approved) by the key-holders. + // It's worth looking at the multisig contract to see where this all comes from. + async createMultiSigMessageHash(destination, value, data, _nonce, executor, gasLimit) { + const { domainSeparator, txTypeHash, multiSigInstance, txInputHashABI } = + this.MULTISIG_CONSTANTS; + let nonce = _nonce; + // get the current multisig nonce if it's not provided (requires blockchain connection) + if (!_nonce) nonce = await multiSigInstance.methods.nonce().call(); + // compute the hashes to sign over note, sometimes we want a keccak hash over encoded parameter + // and sometimes over encodedPacked parameters. Hence the two slightly different approaches used. + const dataHash = this.web3.utils.soliditySha3({ t: 'bytes', v: data }); + const txInput = [txTypeHash, destination, value, dataHash, nonce, executor, gasLimit]; + const txInputEncoded = this.web3.eth.abi.encodeParameters(txInputHashABI, txInput); + const txInputHash = this.web3.utils.soliditySha3({ t: 'bytes', v: txInputEncoded }); // this is a hash of encoded params + const totalHash = this.web3.utils.soliditySha3( + { t: 'string', v: '\x19\x01' }, + { t: 'bytes32', v: domainSeparator }, + { t: 'bytes32', v: txInputHash }, + ); // this is a hash of encoded, packed params + return totalHash; + } + + // function enabling an approver to sign (approve) a multisig transaction + async addMultiSigSignature( + unsignedTransactionData, + signingKey, + contractAddress, + executorAddress, + nonce, + ) { + // compute a signature over the unsigned transaction data + const messageHash = await this.createMultiSigMessageHash( + contractAddress, + 0, + unsignedTransactionData, + nonce, // eslint-disable-line no-param-reassign + executorAddress, + WEB3_OPTIONS.gas, + ); + if (!signingKey) return this.addSignedTransaction({ messageHash }); // if no signing key is given, don't create a new signed transaction + const { r, s, v } = ecsign( + Buffer.from(messageHash.slice(2), 'hex'), + Buffer.from(signingKey.slice(2), 'hex'), + ); + const signed = { + messageHash, + r: `0x${r.toString('hex').padStart(64, '0')}`, + s: `0x${s.toString('hex').padStart(64, '0')}`, + v: `0x${v.toString(16)}`, + by: this.web3.eth.accounts.privateKeyToAccount(signingKey).address, + contractAddress, + data: unsignedTransactionData, + }; + return this.addSignedTransaction(signed); + } + + async executeMultiSigTransaction(signedArray, executor) { + const { multiSigInstance } = this.MULTISIG_CONSTANTS; + // execute the multisig + const multiSigTransaction = multiSigInstance.methods + .execute( + signedArray.map(s => s.v), + signedArray.map(s => s.r), + signedArray.map(s => s.s), + signedArray[0].contractAddress, + 0, + signedArray[0].data, + this.web3.eth.accounts.privateKeyToAccount(executor).address, + WEB3_OPTIONS.gas, + ) + .encodeABI(); + return this.sendTransaction(multiSigTransaction, executor, multiSigInstance.options.address); + } + + async executeMultiSigTransactions(approved, executor) { + for (const approval of approved) { + console.log('Executing multisig transaction'); + // eslint-disable-next-line no-await-in-loop + await this.executeMultiSigTransaction(approval.slice(0, this.SIGNATURE_THRESHOLD), executor); + } + } + + transferOwnership(newOwnerPrivateKey, signingKey, executorAddress, nonce) { + console.log('NONCE:', nonce); + const newOwner = this.web3.eth.accounts.privateKeyToAccount(newOwnerPrivateKey, true).address; + return Promise.all( + this.contractInstancesOwnables.map(async (ownable, i) => { + const contractInstance = ownable; + const data = contractInstance.methods.transferOwnership(newOwner).encodeABI(); + return this.addMultiSigSignature( + data, + signingKey, + contractInstance.options.address, + executorAddress, + nonce + i, + ); + }), + ); + } +} From e9928acd27ccd509100de8edaba6fd1280e27e67 Mon Sep 17 00:00:00 2001 From: daveroga Date: Wed, 21 Sep 2022 09:42:09 +0200 Subject: [PATCH 06/19] fix: some logs --- test/multisig/multisig.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/multisig/multisig.mjs b/test/multisig/multisig.mjs index 12ddb9e0e..55e8a48a9 100644 --- a/test/multisig/multisig.mjs +++ b/test/multisig/multisig.mjs @@ -201,14 +201,14 @@ export class MultiSig { async executeMultiSigTransactions(approved, executor) { for (const approval of approved) { - console.log('Executing multisig transaction'); + logger.info('Executing multisig transaction'); // eslint-disable-next-line no-await-in-loop await this.executeMultiSigTransaction(approval.slice(0, this.SIGNATURE_THRESHOLD), executor); } } transferOwnership(newOwnerPrivateKey, signingKey, executorAddress, nonce) { - console.log('NONCE:', nonce); + logger.info(`transferOwnership: nonce is ${nonce}`); const newOwner = this.web3.eth.accounts.privateKeyToAccount(newOwnerPrivateKey, true).address; return Promise.all( this.contractInstancesOwnables.map(async (ownable, i) => { From 6f4282bc3f746064ad0d15a0c676dec52d0226fd Mon Sep 17 00:00:00 2001 From: daveroga Date: Wed, 21 Sep 2022 23:56:40 +0200 Subject: [PATCH 07/19] fix: add all tests admin --- test/{ => multisig}/administrator.test.mjs | 175 ++++++++++++++++- test/multisig/contract-transactions.mjs | 178 ++++++++++++++++++ test/{ => multisig}/contracts.mjs | 0 test/{ => multisig}/contracts/Challenges.json | 0 test/{ => multisig}/contracts/Proposers.json | 0 test/{ => multisig}/contracts/Shield.json | 0 .../contracts/SimpleMultiSig.json | 0 test/{ => multisig}/contracts/State.json | 0 test/multisig/multisig.mjs | 45 +---- 9 files changed, 355 insertions(+), 43 deletions(-) rename test/{ => multisig}/administrator.test.mjs (57%) create mode 100644 test/multisig/contract-transactions.mjs rename test/{ => multisig}/contracts.mjs (100%) rename test/{ => multisig}/contracts/Challenges.json (100%) rename test/{ => multisig}/contracts/Proposers.json (100%) rename test/{ => multisig}/contracts/Shield.json (100%) rename test/{ => multisig}/contracts/SimpleMultiSig.json (100%) rename test/{ => multisig}/contracts/State.json (100%) diff --git a/test/administrator.test.mjs b/test/multisig/administrator.test.mjs similarity index 57% rename from test/administrator.test.mjs rename to test/multisig/administrator.test.mjs index c99cb47a0..6248d9101 100644 --- a/test/administrator.test.mjs +++ b/test/multisig/administrator.test.mjs @@ -6,10 +6,11 @@ import chai from 'chai'; import chaiHttp from 'chai-http'; import config from 'config'; import chaiAsPromised from 'chai-as-promised'; -import Nf3 from '../cli/lib/nf3.mjs'; +import Nf3 from '../../cli/lib/nf3.mjs'; import contractABIs from './contracts.mjs'; -import { MultiSig } from './multisig/multisig.mjs'; +import { ContractMultiSig } from './contract-transactions.mjs'; +const { WEB3_OPTIONS } = config; const { expect } = chai; chai.use(chaiHttp); chai.use(chaiAsPromised); @@ -32,7 +33,7 @@ describe(`Testing Administrator`, () => { let shieldContractInstance; let challengesContractInstance; let multisigContractInstance; - let multisig; + let contractMultiSig; before(async () => { nf3User = new Nf3(signingKeys.user1, environment); @@ -46,7 +47,7 @@ describe(`Testing Administrator`, () => { multisigContractInstance = await getContractInstance('SimpleMultiSig', nf3User); if (!(await nf3User.healthcheck('client'))) throw new Error('Healthcheck failed'); - multisig = new MultiSig( + contractMultiSig = new ContractMultiSig( nf3User.web3, { state: stateContractInstance, @@ -57,6 +58,7 @@ describe(`Testing Administrator`, () => { }, 2, await nf3User.web3.eth.getChainId(), + WEB3_OPTIONS.gas, ); }); @@ -74,22 +76,178 @@ describe(`Testing Administrator`, () => { expect(ownerChallenges.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); }); + it('Set restriction with the multisig', async () => { + await contractMultiSig.setTokenRestrictions( + nf3User.ethereumAddress, // simulate a token address + 10, + 100, + signingKeys.user1, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + const approved = await contractMultiSig.setTokenRestrictions( + nf3User.ethereumAddress, // simulate a token address + 10, + 100, + signingKeys.user2, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + + await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + const restrictionDeposit = await shieldContractInstance.methods + .getRestriction(nf3User.ethereumAddress, 0) + .call(); + const restrictionWithdraw = await shieldContractInstance.methods + .getRestriction(nf3User.ethereumAddress, 1) + .call(); + + expect(Number(restrictionDeposit)).to.be.equal(10); + expect(Number(restrictionWithdraw)).to.be.equal(100); + }); + + it('Remove restriction with the multisig', async () => { + await contractMultiSig.removeTokenRestrictions( + nf3User.ethereumAddress, // simulate a token address + signingKeys.user1, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + const approved = await contractMultiSig.removeTokenRestrictions( + nf3User.ethereumAddress, // simulate a token address + signingKeys.user2, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + + await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + const restrictionDeposit = await shieldContractInstance.methods + .getRestriction(nf3User.ethereumAddress, 0) + .call(); + const restrictionWithdraw = await shieldContractInstance.methods + .getRestriction(nf3User.ethereumAddress, 1) + .call(); + + expect(Number(restrictionDeposit)).to.be.equal(0); + expect(Number(restrictionWithdraw)).to.be.equal(0); + }); + + it('Set boot proposer with the multisig', async () => { + await contractMultiSig.setBootProposer( + signingKeys.user1, + signingKeys.user1, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + const approved = await contractMultiSig.setBootProposer( + signingKeys.user1, + signingKeys.user2, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + + await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + const bootProposer = await shieldContractInstance.methods.getBootProposer().call(); + + expect(bootProposer.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); + }); + + it('Set boot challenger with the multisig', async () => { + await contractMultiSig.setBootChallenger( + signingKeys.user1, + signingKeys.user1, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + const approved = await contractMultiSig.setBootChallenger( + signingKeys.user1, + signingKeys.user2, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + + await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + const bootChallenger = await shieldContractInstance.methods.getBootChallenger().call(); + + expect(bootChallenger.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); + }); + + it('Set MATIC address with the multisig', async () => { + await contractMultiSig.setMaticAddress( + addresses.user1, + signingKeys.user1, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + const approved = await contractMultiSig.setMaticAddress( + addresses.user1, + signingKeys.user2, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + + await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + const maticAddress = await shieldContractInstance.methods.getMaticAddress().call(); + + expect(maticAddress.toUpperCase()).to.be.equal(addresses.user1.toUpperCase()); + }); + /* it('Pause contracts with the multisig', async () => { + const paused1 = await stateContractInstance.methods.paused().call(); + await contractMultiSig.pauseContracts( + signingKeys.user1, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + const approved = await contractMultiSig.pauseContracts( + signingKeys.user2, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + + await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + + const paused2 = await stateContractInstance.methods.paused().call(); + + expect(paused1).to.be.equal(false); + expect(paused2).to.be.equal(true); + }); + + it('Unpause contracts with the multisig', async () => { + const paused1 = await stateContractInstance.methods.paused().call(); + await contractMultiSig.unpauseContracts( + signingKeys.user1, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + const approved = await contractMultiSig.unpauseContracts( + signingKeys.user2, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + + await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + + const paused2 = await stateContractInstance.methods.paused().call(); + + expect(paused1).to.be.equal(true); + expect(paused2).to.be.equal(false); + }); + it('Be able to transfer ownership of contracts from multisig to a specific one', async () => { - // TODO: calls to multisig to change contracts ownership. Now you can do it manually through nightfall-administrator - await multisig.transferOwnership( + await contractMultiSig.transferOwnership( signingKeys.user1, signingKeys.user1, addresses.user1, await multisigContractInstance.methods.nonce().call(), ); - const approved = await multisig.transferOwnership( + const approved = await contractMultiSig.transferOwnership( signingKeys.user1, signingKeys.user2, addresses.user1, await multisigContractInstance.methods.nonce().call(), ); - await multisig.executeMultiSigTransactions(approved, signingKeys.user1); + await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); const owner = await stateContractInstance.methods.owner().call(); expect(owner.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); }); @@ -213,6 +371,7 @@ describe(`Testing Administrator`, () => { expect(ownerProposers.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); expect(ownerChallenges.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); }); + */ }); after(async () => { diff --git a/test/multisig/contract-transactions.mjs b/test/multisig/contract-transactions.mjs new file mode 100644 index 000000000..29261ce94 --- /dev/null +++ b/test/multisig/contract-transactions.mjs @@ -0,0 +1,178 @@ +/* ignore unused exports */ +import logger from 'common-files/utils/logger.mjs'; +import { MultiSig } from './multisig.mjs'; + +// eslint-disable-next-line import/prefer-default-export +export class ContractMultiSig { + multiSig; + + web3; + + contractInstances = []; + + contractInstancesOwnables = []; + + contractInstancesPausables = []; + + constructor(web3Provider, contractInstances, signatureThreshold, chainId, gasLimit) { + this.web3 = web3Provider; + this.multiSig = new MultiSig( + this.web3, + contractInstances.multisig, + signatureThreshold, + chainId, + gasLimit, + ); + this.contractInstances = contractInstances; + this.contractInstancesOwnables.push( + contractInstances.shield, + contractInstances.state, + contractInstances.proposers, + contractInstances.challenges, + ); + this.contractInstancesPausables.push(contractInstances.shield, contractInstances.state); + } + + transferOwnership(newOwnerPrivateKey, signingKey, executorAddress, nonce) { + logger.info(`transferOwnership: nonce is ${nonce}`); + const newOwner = this.web3.eth.accounts.privateKeyToAccount(newOwnerPrivateKey, true).address; + return Promise.all( + this.contractInstancesOwnables.map(async (ownable, i) => { + const contractInstance = ownable; + const data = contractInstance.methods.transferOwnership(newOwner).encodeABI(); + return this.multiSig.addMultiSigSignature( + data, + signingKey, + contractInstance.options.address, + executorAddress, + nonce + i, + ); + }), + ); + } + + /** + This function sets the restriction data that the Shield contract is currently using + */ + async setTokenRestrictions( + tokenAddress, + depositRestriction, + withdrawRestriction, + signingKey, + executorAddress, + nonce, + ) { + const data = this.contractInstances.shield.methods + .setRestriction(tokenAddress, depositRestriction, withdrawRestriction) + .encodeABI(); + return Promise.all([ + this.multiSig.addMultiSigSignature( + data, + signingKey, + this.contractInstances.shield.options.address, + executorAddress, + nonce, + ), + ]); + } + + /** + This function removes the restriction data that the Shield contract is currently using + */ + async removeTokenRestrictions(tokenAddress, signingKey, executorAddress, nonce) { + const data = this.contractInstances.shield.methods.removeRestriction(tokenAddress).encodeABI(); + return Promise.all([ + this.multiSig.addMultiSigSignature( + data, + signingKey, + this.contractInstances.shield.options.address, + executorAddress, + nonce, + ), + ]); + } + + pauseContracts(signingKey, executorAddress, nonce) { + logger.info('All pausable contracts being paused'); + return Promise.all( + this.contractInstancesPausables.map(async (pausable, i) => { + const contractInstance = pausable; + const data = contractInstance.methods.pause().encodeABI(); + return this.multiSig.addMultiSigSignature( + data, + signingKey, + contractInstance.options.address, + executorAddress, + nonce + i, + ); + }), + ); + } + + unpauseContracts(signingKey, executorAddress, nonce) { + logger.info('All pausable contracts being unpaused'); + return Promise.all( + this.contractInstancesPausables.map(async (pausable, i) => { + const contractInstance = pausable; + const data = contractInstance.methods.unpause().encodeABI(); + return this.multiSig.addMultiSigSignature( + data, + signingKey, + contractInstance.options.address, + executorAddress, + nonce + i, + ); + }), + ); + } + + async setBootProposer(newProposerPrivateKey, signingKey, executorAddress, nonce) { + const newProposer = this.web3.eth.accounts.privateKeyToAccount( + newProposerPrivateKey, + true, + ).address; + const shieldContractInstance = this.contractInstances.shield; + const data = shieldContractInstance.methods.setBootProposer(newProposer).encodeABI(); + return Promise.all([ + this.multiSig.addMultiSigSignature( + data, + signingKey, + shieldContractInstance.options.address, + executorAddress, + nonce, + ), + ]); + } + + async setBootChallenger(newChallengerPrivateKey, signingKey, executorAddress, nonce) { + const newChallenger = this.web3.eth.accounts.privateKeyToAccount( + newChallengerPrivateKey, + true, + ).address; + const shieldContractInstance = this.contractInstances.shield; + const data = shieldContractInstance.methods.setBootChallenger(newChallenger).encodeABI(); + return Promise.all([ + this.multiSig.addMultiSigSignature( + data, + signingKey, + shieldContractInstance.options.address, + executorAddress, + nonce, + ), + ]); + } + + async setMaticAddress(newMaticAddress, signingKey, executorAddress, nonce) { + const shieldContractInstance = this.contractInstances.shield; + const data = shieldContractInstance.methods.setMaticAddress(newMaticAddress).encodeABI(); + return Promise.all([ + this.multiSig.addMultiSigSignature( + data, + signingKey, + shieldContractInstance.options.address, + executorAddress, + nonce, + ), + ]); + } +} diff --git a/test/contracts.mjs b/test/multisig/contracts.mjs similarity index 100% rename from test/contracts.mjs rename to test/multisig/contracts.mjs diff --git a/test/contracts/Challenges.json b/test/multisig/contracts/Challenges.json similarity index 100% rename from test/contracts/Challenges.json rename to test/multisig/contracts/Challenges.json diff --git a/test/contracts/Proposers.json b/test/multisig/contracts/Proposers.json similarity index 100% rename from test/contracts/Proposers.json rename to test/multisig/contracts/Proposers.json diff --git a/test/contracts/Shield.json b/test/multisig/contracts/Shield.json similarity index 100% rename from test/contracts/Shield.json rename to test/multisig/contracts/Shield.json diff --git a/test/contracts/SimpleMultiSig.json b/test/multisig/contracts/SimpleMultiSig.json similarity index 100% rename from test/contracts/SimpleMultiSig.json rename to test/multisig/contracts/SimpleMultiSig.json diff --git a/test/contracts/State.json b/test/multisig/contracts/State.json similarity index 100% rename from test/contracts/State.json rename to test/multisig/contracts/State.json diff --git a/test/multisig/multisig.mjs b/test/multisig/multisig.mjs index 55e8a48a9..b3d7777ef 100644 --- a/test/multisig/multisig.mjs +++ b/test/multisig/multisig.mjs @@ -1,23 +1,20 @@ /* ignore unused exports */ -import config from 'config'; import { ecsign } from 'ethereumjs-util'; import logger from 'common-files/utils/logger.mjs'; -const { WEB3_OPTIONS } = config; - // eslint-disable-next-line import/prefer-default-export export class MultiSig { transactions = []; - contractInstancesOwnables = []; - MULTISIG_CONSTANTS = {}; SIGNATURE_THRESHOLD = 2; web3; - constructor(web3Provider, contractInstances, signatureThreshold, chainId) { + gas; + + constructor(web3Provider, multiSigContractInstance, signatureThreshold, chainId, gasLimit) { // constants used to create a mutlisig data structure const EIP712DOMAINTYPE_HASH = '0xd87cd6ef79d4e2b95e15ce8abf732db51ec771f1ca2edccf22a46c729ac56472'; @@ -35,17 +32,13 @@ export class MultiSig { NAME_HASH, VERSION_HASH, chainId, - contractInstances.multisig.options.address, + multiSigContractInstance.options.address, SALT, ]; - this.contractInstancesOwnables.push( - contractInstances.shield, - contractInstances.state, - contractInstances.proposers, - contractInstances.challenges, - ); + this.SIGNATURE_THRESHOLD = signatureThreshold; this.web3 = web3Provider; + this.gas = gasLimit; const domainSeparatorEncoded = this.web3.eth.abi.encodeParameters( domainSeparatorABI, domainSeparator, @@ -56,7 +49,7 @@ export class MultiSig { }); this.MULTISIG_CONSTANTS.domainSeparator = DOMAIN_SEPARATOR; this.MULTISIG_CONSTANTS.txTypeHash = TXTYPE_HASH; - this.MULTISIG_CONSTANTS.multiSigInstance = contractInstances.multisig; + this.MULTISIG_CONSTANTS.multiSigInstance = multiSigContractInstance; this.MULTISIG_CONSTANTS.txInputHashABI = [ 'bytes32', 'address', @@ -73,7 +66,7 @@ export class MultiSig { from: this.web3.eth.accounts.privateKeyToAccount(signingKey).address, to: contractAddress, data: unsignedTransaction, - gas: WEB3_OPTIONS.gas, + gas: this.gas, gasPrice: await this.web3.eth.getGasPrice(), }; const signed = await this.web3.eth.accounts.signTransaction(tx, signingKey); @@ -162,7 +155,7 @@ export class MultiSig { unsignedTransactionData, nonce, // eslint-disable-line no-param-reassign executorAddress, - WEB3_OPTIONS.gas, + this.gas, ); if (!signingKey) return this.addSignedTransaction({ messageHash }); // if no signing key is given, don't create a new signed transaction const { r, s, v } = ecsign( @@ -193,7 +186,7 @@ export class MultiSig { 0, signedArray[0].data, this.web3.eth.accounts.privateKeyToAccount(executor).address, - WEB3_OPTIONS.gas, + this.gas, ) .encodeABI(); return this.sendTransaction(multiSigTransaction, executor, multiSigInstance.options.address); @@ -206,22 +199,4 @@ export class MultiSig { await this.executeMultiSigTransaction(approval.slice(0, this.SIGNATURE_THRESHOLD), executor); } } - - transferOwnership(newOwnerPrivateKey, signingKey, executorAddress, nonce) { - logger.info(`transferOwnership: nonce is ${nonce}`); - const newOwner = this.web3.eth.accounts.privateKeyToAccount(newOwnerPrivateKey, true).address; - return Promise.all( - this.contractInstancesOwnables.map(async (ownable, i) => { - const contractInstance = ownable; - const data = contractInstance.methods.transferOwnership(newOwner).encodeABI(); - return this.addMultiSigSignature( - data, - signingKey, - contractInstance.options.address, - executorAddress, - nonce + i, - ); - }), - ); - } } From 0460d31eb8f1e005b1d7cfbcf2464dc5ed1358e1 Mon Sep 17 00:00:00 2001 From: daveroga Date: Thu, 22 Sep 2022 09:47:20 +0200 Subject: [PATCH 08/19] fix: some updates --- test/multisig/administrator.test.mjs | 4 +- test/multisig/contract-transactions.mjs | 178 ------------------------ 2 files changed, 2 insertions(+), 180 deletions(-) delete mode 100644 test/multisig/contract-transactions.mjs diff --git a/test/multisig/administrator.test.mjs b/test/multisig/administrator.test.mjs index 6248d9101..e124992b4 100644 --- a/test/multisig/administrator.test.mjs +++ b/test/multisig/administrator.test.mjs @@ -8,7 +8,7 @@ import config from 'config'; import chaiAsPromised from 'chai-as-promised'; import Nf3 from '../../cli/lib/nf3.mjs'; import contractABIs from './contracts.mjs'; -import { ContractMultiSig } from './contract-transactions.mjs'; +import { NightfallMultiSig } from './nightfall-multisig.mjs'; const { WEB3_OPTIONS } = config; const { expect } = chai; @@ -47,7 +47,7 @@ describe(`Testing Administrator`, () => { multisigContractInstance = await getContractInstance('SimpleMultiSig', nf3User); if (!(await nf3User.healthcheck('client'))) throw new Error('Healthcheck failed'); - contractMultiSig = new ContractMultiSig( + contractMultiSig = new NightfallMultiSig( nf3User.web3, { state: stateContractInstance, diff --git a/test/multisig/contract-transactions.mjs b/test/multisig/contract-transactions.mjs deleted file mode 100644 index 29261ce94..000000000 --- a/test/multisig/contract-transactions.mjs +++ /dev/null @@ -1,178 +0,0 @@ -/* ignore unused exports */ -import logger from 'common-files/utils/logger.mjs'; -import { MultiSig } from './multisig.mjs'; - -// eslint-disable-next-line import/prefer-default-export -export class ContractMultiSig { - multiSig; - - web3; - - contractInstances = []; - - contractInstancesOwnables = []; - - contractInstancesPausables = []; - - constructor(web3Provider, contractInstances, signatureThreshold, chainId, gasLimit) { - this.web3 = web3Provider; - this.multiSig = new MultiSig( - this.web3, - contractInstances.multisig, - signatureThreshold, - chainId, - gasLimit, - ); - this.contractInstances = contractInstances; - this.contractInstancesOwnables.push( - contractInstances.shield, - contractInstances.state, - contractInstances.proposers, - contractInstances.challenges, - ); - this.contractInstancesPausables.push(contractInstances.shield, contractInstances.state); - } - - transferOwnership(newOwnerPrivateKey, signingKey, executorAddress, nonce) { - logger.info(`transferOwnership: nonce is ${nonce}`); - const newOwner = this.web3.eth.accounts.privateKeyToAccount(newOwnerPrivateKey, true).address; - return Promise.all( - this.contractInstancesOwnables.map(async (ownable, i) => { - const contractInstance = ownable; - const data = contractInstance.methods.transferOwnership(newOwner).encodeABI(); - return this.multiSig.addMultiSigSignature( - data, - signingKey, - contractInstance.options.address, - executorAddress, - nonce + i, - ); - }), - ); - } - - /** - This function sets the restriction data that the Shield contract is currently using - */ - async setTokenRestrictions( - tokenAddress, - depositRestriction, - withdrawRestriction, - signingKey, - executorAddress, - nonce, - ) { - const data = this.contractInstances.shield.methods - .setRestriction(tokenAddress, depositRestriction, withdrawRestriction) - .encodeABI(); - return Promise.all([ - this.multiSig.addMultiSigSignature( - data, - signingKey, - this.contractInstances.shield.options.address, - executorAddress, - nonce, - ), - ]); - } - - /** - This function removes the restriction data that the Shield contract is currently using - */ - async removeTokenRestrictions(tokenAddress, signingKey, executorAddress, nonce) { - const data = this.contractInstances.shield.methods.removeRestriction(tokenAddress).encodeABI(); - return Promise.all([ - this.multiSig.addMultiSigSignature( - data, - signingKey, - this.contractInstances.shield.options.address, - executorAddress, - nonce, - ), - ]); - } - - pauseContracts(signingKey, executorAddress, nonce) { - logger.info('All pausable contracts being paused'); - return Promise.all( - this.contractInstancesPausables.map(async (pausable, i) => { - const contractInstance = pausable; - const data = contractInstance.methods.pause().encodeABI(); - return this.multiSig.addMultiSigSignature( - data, - signingKey, - contractInstance.options.address, - executorAddress, - nonce + i, - ); - }), - ); - } - - unpauseContracts(signingKey, executorAddress, nonce) { - logger.info('All pausable contracts being unpaused'); - return Promise.all( - this.contractInstancesPausables.map(async (pausable, i) => { - const contractInstance = pausable; - const data = contractInstance.methods.unpause().encodeABI(); - return this.multiSig.addMultiSigSignature( - data, - signingKey, - contractInstance.options.address, - executorAddress, - nonce + i, - ); - }), - ); - } - - async setBootProposer(newProposerPrivateKey, signingKey, executorAddress, nonce) { - const newProposer = this.web3.eth.accounts.privateKeyToAccount( - newProposerPrivateKey, - true, - ).address; - const shieldContractInstance = this.contractInstances.shield; - const data = shieldContractInstance.methods.setBootProposer(newProposer).encodeABI(); - return Promise.all([ - this.multiSig.addMultiSigSignature( - data, - signingKey, - shieldContractInstance.options.address, - executorAddress, - nonce, - ), - ]); - } - - async setBootChallenger(newChallengerPrivateKey, signingKey, executorAddress, nonce) { - const newChallenger = this.web3.eth.accounts.privateKeyToAccount( - newChallengerPrivateKey, - true, - ).address; - const shieldContractInstance = this.contractInstances.shield; - const data = shieldContractInstance.methods.setBootChallenger(newChallenger).encodeABI(); - return Promise.all([ - this.multiSig.addMultiSigSignature( - data, - signingKey, - shieldContractInstance.options.address, - executorAddress, - nonce, - ), - ]); - } - - async setMaticAddress(newMaticAddress, signingKey, executorAddress, nonce) { - const shieldContractInstance = this.contractInstances.shield; - const data = shieldContractInstance.methods.setMaticAddress(newMaticAddress).encodeABI(); - return Promise.all([ - this.multiSig.addMultiSigSignature( - data, - signingKey, - shieldContractInstance.options.address, - executorAddress, - nonce, - ), - ]); - } -} From 1999320cd6e641ddf8ff73651471109677f96598 Mon Sep 17 00:00:00 2001 From: daveroga Date: Thu, 22 Sep 2022 09:48:04 +0200 Subject: [PATCH 09/19] fix: some updates --- test/multisig/nightfall-multisig.mjs | 203 +++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 test/multisig/nightfall-multisig.mjs diff --git a/test/multisig/nightfall-multisig.mjs b/test/multisig/nightfall-multisig.mjs new file mode 100644 index 000000000..23da6146d --- /dev/null +++ b/test/multisig/nightfall-multisig.mjs @@ -0,0 +1,203 @@ +/* ignore unused exports */ +import logger from 'common-files/utils/logger.mjs'; +import { MultiSig } from './multisig.mjs'; + +// eslint-disable-next-line import/prefer-default-export +export class NightfallMultiSig { + multiSig; // MultiSig instance + + web3; // web3 instance + + contractInstances = []; // instances of the contracts + + contractsOwnables = ['shield', 'state', 'proposers', 'challenges']; // ownable contracts + + contractsPausables = ['shield', 'state']; // pausable contracts + + constructor(web3Instance, contractInstances, signatureThreshold, chainId, gasLimit) { + this.web3 = web3Instance; + this.multiSig = new MultiSig( + this.web3, + contractInstances.multisig, + signatureThreshold, + chainId, + gasLimit, + ); + this.contractInstances = contractInstances; + } + + contractInstancesOwnables() { + const contractInstancesResult = []; + this.contractsOwnables.forEach(contract => + contractInstancesResult.push(this.contractInstances[contract]), + ); + } + + contractInstancesPausables() { + const contractInstancesResult = []; + this.contractsPausables.forEach(contract => + contractInstancesResult.push(this.contractInstances[contract]), + ); + } + + /** + This function transfers the ownership of the contracts that are ownable + */ + transferOwnership(newOwnerPrivateKey, signingKey, executorAddress, nonce) { + logger.info(`transferOwnership: nonce is ${nonce}`); + const newOwner = this.web3.eth.accounts.privateKeyToAccount(newOwnerPrivateKey, true).address; + return Promise.all( + this.contractInstancesOwnables().map(async (ownable, i) => { + const contractInstance = ownable; + const data = contractInstance.methods.transferOwnership(newOwner).encodeABI(); + return this.multiSig.addMultiSigSignature( + data, + signingKey, + contractInstance.options.address, + executorAddress, + nonce + i, + ); + }), + ); + } + + /** + This function sets the restriction data that the Shield contract is currently using + */ + async setTokenRestrictions( + tokenAddress, + depositRestriction, + withdrawRestriction, + signingKey, + executorAddress, + nonce, + ) { + const data = this.contractInstances.shield.methods + .setRestriction(tokenAddress, depositRestriction, withdrawRestriction) + .encodeABI(); + return Promise.all([ + this.multiSig.addMultiSigSignature( + data, + signingKey, + this.contractInstances.shield.options.address, + executorAddress, + nonce, + ), + ]); + } + + /** + This function removes the restriction data that the Shield contract is currently using + */ + async removeTokenRestrictions(tokenAddress, signingKey, executorAddress, nonce) { + const data = this.contractInstances.shield.methods.removeRestriction(tokenAddress).encodeABI(); + return Promise.all([ + this.multiSig.addMultiSigSignature( + data, + signingKey, + this.contractInstances.shield.options.address, + executorAddress, + nonce, + ), + ]); + } + + /** + This function pauses contracts that are pausable + */ + pauseContracts(signingKey, executorAddress, nonce) { + logger.info('All pausable contracts being paused'); + return Promise.all( + this.contractInstancesPausables().map(async (pausable, i) => { + const contractInstance = pausable; + const data = contractInstance.methods.pause().encodeABI(); + return this.multiSig.addMultiSigSignature( + data, + signingKey, + contractInstance.options.address, + executorAddress, + nonce + i, + ); + }), + ); + } + + /** + This function unpauses contracts that are pausable + */ + unpauseContracts(signingKey, executorAddress, nonce) { + logger.info('All pausable contracts being unpaused'); + return Promise.all( + this.contractInstancesPausables().map(async (pausable, i) => { + const contractInstance = pausable; + const data = contractInstance.methods.unpause().encodeABI(); + return this.multiSig.addMultiSigSignature( + data, + signingKey, + contractInstance.options.address, + executorAddress, + nonce + i, + ); + }), + ); + } + + /** + This function sets the boot proposer + */ + async setBootProposer(newProposerPrivateKey, signingKey, executorAddress, nonce) { + const newProposer = this.web3.eth.accounts.privateKeyToAccount( + newProposerPrivateKey, + true, + ).address; + const shieldContractInstance = this.contractInstances.shield; + const data = shieldContractInstance.methods.setBootProposer(newProposer).encodeABI(); + return Promise.all([ + this.multiSig.addMultiSigSignature( + data, + signingKey, + shieldContractInstance.options.address, + executorAddress, + nonce, + ), + ]); + } + + /** + This function sets the boot challenger + */ + async setBootChallenger(newChallengerPrivateKey, signingKey, executorAddress, nonce) { + const newChallenger = this.web3.eth.accounts.privateKeyToAccount( + newChallengerPrivateKey, + true, + ).address; + const shieldContractInstance = this.contractInstances.shield; + const data = shieldContractInstance.methods.setBootChallenger(newChallenger).encodeABI(); + return Promise.all([ + this.multiSig.addMultiSigSignature( + data, + signingKey, + shieldContractInstance.options.address, + executorAddress, + nonce, + ), + ]); + } + + /** + This function sets the Matic address + */ + async setMaticAddress(newMaticAddress, signingKey, executorAddress, nonce) { + const shieldContractInstance = this.contractInstances.shield; + const data = shieldContractInstance.methods.setMaticAddress(newMaticAddress).encodeABI(); + return Promise.all([ + this.multiSig.addMultiSigSignature( + data, + signingKey, + shieldContractInstance.options.address, + executorAddress, + nonce, + ), + ]); + } +} From f86e0c3e09d5b0fe380a131c71fd16b9ffdcaf69 Mon Sep 17 00:00:00 2001 From: daveroga Date: Thu, 22 Sep 2022 10:22:07 +0200 Subject: [PATCH 10/19] fix: return missing --- test/multisig/nightfall-multisig.mjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/multisig/nightfall-multisig.mjs b/test/multisig/nightfall-multisig.mjs index 23da6146d..b04d9a944 100644 --- a/test/multisig/nightfall-multisig.mjs +++ b/test/multisig/nightfall-multisig.mjs @@ -31,6 +31,7 @@ export class NightfallMultiSig { this.contractsOwnables.forEach(contract => contractInstancesResult.push(this.contractInstances[contract]), ); + return contractInstancesResult; } contractInstancesPausables() { @@ -38,6 +39,7 @@ export class NightfallMultiSig { this.contractsPausables.forEach(contract => contractInstancesResult.push(this.contractInstances[contract]), ); + return contractInstancesResult; } /** From d3ad03b9be5035f785c206934c1792db78def189 Mon Sep 17 00:00:00 2001 From: Westlad Date: Thu, 22 Sep 2022 11:30:30 +0100 Subject: [PATCH 11/19] fix: nonce initialisation for multisig --- .../src/services/contract-transactions.mjs | 28 ++++++++++++++----- .../src/services/helpers.mjs | 19 ++++++++++--- nightfall-administrator/src/ui/get-info.mjs | 5 ---- nightfall-administrator/src/ui/menu.mjs | 12 -------- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/nightfall-administrator/src/services/contract-transactions.mjs b/nightfall-administrator/src/services/contract-transactions.mjs index 09c10b4e9..dc19a18b9 100644 --- a/nightfall-administrator/src/services/contract-transactions.mjs +++ b/nightfall-administrator/src/services/contract-transactions.mjs @@ -2,7 +2,7 @@ import config from 'config'; import { waitForContract, web3 } from '../../../common-files/utils/contract.mjs'; import logger from '../../../common-files/utils/logger.mjs'; import constants from '../../../common-files/constants/index.mjs'; -import { addMultiSigSignature } from './helpers.mjs'; +import { addMultiSigSignature, getMultiSigNonce } from './helpers.mjs'; const { RESTRICTIONS } = config; const { SHIELD_CONTRACT_NAME } = constants; @@ -40,7 +40,9 @@ export async function setTokenRestrictions( return false; } -export async function removeTokenRestrictions(tokenName, signingKey, executorAddress, nonce) { +export async function removeTokenRestrictions(tokenName, signingKey, executorAddress, _nonce) { + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await getMultiSigNonce(); const shieldContractInstance = await waitForContract(SHIELD_CONTRACT_NAME); for (const token of RESTRICTIONS.tokens[process.env.ETH_NETWORK]) { if (token.name === tokenName) { @@ -59,8 +61,11 @@ export async function removeTokenRestrictions(tokenName, signingKey, executorAdd return false; } -export function pauseContracts(signingKey, executorAddress, nonce) { +export async function pauseContracts(signingKey, executorAddress, _nonce) { logger.info('All pausable contracts being paused'); + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await getMultiSigNonce(); + console.log('*!NONCE', nonce); return Promise.all( pausables.map(async (pausable, i) => { const contractInstance = await waitForContract(pausable); @@ -76,8 +81,11 @@ export function pauseContracts(signingKey, executorAddress, nonce) { ); } -export function unpauseContracts(signingKey, executorAddress, nonce) { +export async function unpauseContracts(signingKey, executorAddress, _nonce) { logger.info('All pausable contracts being unpaused'); + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await getMultiSigNonce(); + console.log('*!NONCE', nonce); return Promise.all( pausables.map(async (pausable, i) => { const contractInstance = await waitForContract(pausable); @@ -93,7 +101,9 @@ export function unpauseContracts(signingKey, executorAddress, nonce) { ); } -export function transferOwnership(newOwnerPrivateKey, signingKey, executorAddress, nonce) { +export async function transferOwnership(newOwnerPrivateKey, signingKey, executorAddress, _nonce) { + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await getMultiSigNonce(); const newOwner = web3.eth.accounts.privateKeyToAccount(newOwnerPrivateKey, true).address; return Promise.all( ownables.map(async (ownable, i) => { @@ -110,7 +120,9 @@ export function transferOwnership(newOwnerPrivateKey, signingKey, executorAddres ); } -export async function setBootProposer(newProposerPrivateKey, signingKey, executorAddress, nonce) { +export async function setBootProposer(newProposerPrivateKey, signingKey, executorAddress, _nonce) { + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await getMultiSigNonce(); const newProposer = web3.eth.accounts.privateKeyToAccount(newProposerPrivateKey, true).address; const shieldContractInstance = await waitForContract(SHIELD_CONTRACT_NAME); const data = shieldContractInstance.methods.setBootProposer(newProposer).encodeABI(); @@ -129,8 +141,10 @@ export async function setBootChallenger( newChallengerPrivateKey, signingKey, executorAddress, - nonce, + _nonce, ) { + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await getMultiSigNonce(); const newChallenger = web3.eth.accounts.privateKeyToAccount( newChallengerPrivateKey, true, diff --git a/nightfall-administrator/src/services/helpers.mjs b/nightfall-administrator/src/services/helpers.mjs index dd82eab93..8e045878f 100644 --- a/nightfall-administrator/src/services/helpers.mjs +++ b/nightfall-administrator/src/services/helpers.mjs @@ -7,6 +7,17 @@ import { checkThreshold, saveSigned, getSigned } from './database.mjs'; const { RESTRICTIONS, WEB3_OPTIONS, MULTISIG } = config; const { SIGNATURE_THRESHOLD } = MULTISIG; const MULTISIG_CONSTANTS = {}; + +/** + Read the nonce from the multisig contract + */ +export async function getMultiSigNonce() { + const { multiSigInstance } = MULTISIG_CONSTANTS; + if (!multiSigInstance) throw new Error('No multisig instance'); + const nonce = await multiSigInstance.methods.nonce().call(); + return Number(nonce); +} + /** * Read the names of tokens from the config */ @@ -67,11 +78,11 @@ export async function addSignedTransaction(signed) { * This function creates the multisig message hash, which is signed (approved) by the key-holders. * It's worth looking at the multisig contract to see where this all comes from. */ -async function createMultiSigMessageHash(destination, value, data, _nonce, executor, gasLimit) { - const { domainSeparator, txTypeHash, multiSigInstance, txInputHashABI } = MULTISIG_CONSTANTS; - let nonce = _nonce; +async function createMultiSigMessageHash(destination, value, data, nonce, executor, gasLimit) { + const { domainSeparator, txTypeHash, txInputHashABI } = MULTISIG_CONSTANTS; // get the current multisig nonce if it's not provided (requires blockchain connection) - if (!_nonce) nonce = await multiSigInstance.methods.nonce().call(); + if (!Number.isInteger(nonce)) throw new Error(`Nonce is not an integer: ${nonce}`); + console.log('*!GOT nonce', nonce, nonce + 1); // compute the hashes to sign over note, sometimes we want a keccak hash over encoded parameter // and sometimes over encodedPacked parameters. Hence the two slightly different approaches used. const dataHash = web3.utils.soliditySha3({ t: 'bytes', v: data }); diff --git a/nightfall-administrator/src/ui/get-info.mjs b/nightfall-administrator/src/ui/get-info.mjs index 41f2d1ba0..c1b3a52df 100644 --- a/nightfall-administrator/src/ui/get-info.mjs +++ b/nightfall-administrator/src/ui/get-info.mjs @@ -31,8 +31,6 @@ async function start() { tokenName, depositRestriction, withdrawRestriction, - pause, - unpause, newEthereumSigningKey, executorAddress, nonce, @@ -73,13 +71,10 @@ async function start() { break; } case 'Unpause contracts': { - if (!unpause) break; - logger.info('CALLING unpauseContracts'); approved = await unpauseContracts(ethereumSigningKey, executorAddress, nonce); break; } case 'Pause contracts': { - if (!pause) break; approved = await pauseContracts(ethereumSigningKey, executorAddress, nonce); break; } diff --git a/nightfall-administrator/src/ui/menu.mjs b/nightfall-administrator/src/ui/menu.mjs index 848cd555c..af68b9f55 100644 --- a/nightfall-administrator/src/ui/menu.mjs +++ b/nightfall-administrator/src/ui/menu.mjs @@ -113,18 +113,6 @@ export async function askQuestions(approved) { when: answers => answers.task === 'Set token restrictions', validate: input => Number.isInteger(Number(input)) && Number(input) > 0, }, - { - name: 'pause', - type: 'confirm', - message: 'Pause contracts?', - when: answers => answers.task === 'Pause contracts', - }, - { - name: 'unpause', - type: 'confirm', - message: 'Unpause contracts?', - when: answers => answers.task === 'Unpause contracts', - }, { name: 'amount', type: 'input', From 4808b16213a22e483fb071e50585d6e4c492a810 Mon Sep 17 00:00:00 2001 From: Westlad Date: Thu, 22 Sep 2022 11:36:26 +0100 Subject: [PATCH 12/19] fix: remove consol logging --- nightfall-administrator/src/services/contract-transactions.mjs | 2 -- nightfall-administrator/src/services/helpers.mjs | 1 - 2 files changed, 3 deletions(-) diff --git a/nightfall-administrator/src/services/contract-transactions.mjs b/nightfall-administrator/src/services/contract-transactions.mjs index dc19a18b9..3542123ca 100644 --- a/nightfall-administrator/src/services/contract-transactions.mjs +++ b/nightfall-administrator/src/services/contract-transactions.mjs @@ -65,7 +65,6 @@ export async function pauseContracts(signingKey, executorAddress, _nonce) { logger.info('All pausable contracts being paused'); let nonce = _nonce; if (!Number.isInteger(nonce)) nonce = await getMultiSigNonce(); - console.log('*!NONCE', nonce); return Promise.all( pausables.map(async (pausable, i) => { const contractInstance = await waitForContract(pausable); @@ -85,7 +84,6 @@ export async function unpauseContracts(signingKey, executorAddress, _nonce) { logger.info('All pausable contracts being unpaused'); let nonce = _nonce; if (!Number.isInteger(nonce)) nonce = await getMultiSigNonce(); - console.log('*!NONCE', nonce); return Promise.all( pausables.map(async (pausable, i) => { const contractInstance = await waitForContract(pausable); diff --git a/nightfall-administrator/src/services/helpers.mjs b/nightfall-administrator/src/services/helpers.mjs index 8e045878f..e30b6c248 100644 --- a/nightfall-administrator/src/services/helpers.mjs +++ b/nightfall-administrator/src/services/helpers.mjs @@ -82,7 +82,6 @@ async function createMultiSigMessageHash(destination, value, data, nonce, execut const { domainSeparator, txTypeHash, txInputHashABI } = MULTISIG_CONSTANTS; // get the current multisig nonce if it's not provided (requires blockchain connection) if (!Number.isInteger(nonce)) throw new Error(`Nonce is not an integer: ${nonce}`); - console.log('*!GOT nonce', nonce, nonce + 1); // compute the hashes to sign over note, sometimes we want a keccak hash over encoded parameter // and sometimes over encodedPacked parameters. Hence the two slightly different approaches used. const dataHash = web3.utils.soliditySha3({ t: 'bytes', v: data }); From 551e8fa06a6de6c9b5d4918ee319c97c104ec226 Mon Sep 17 00:00:00 2001 From: daveroga Date: Thu, 22 Sep 2022 14:29:45 +0200 Subject: [PATCH 13/19] fix: nonce issue fixed by Duncan --- test/multisig/administrator.test.mjs | 104 +++++++++++++-------------- test/multisig/multisig.mjs | 16 +++++ test/multisig/nightfall-multisig.mjs | 41 ++++++++--- 3 files changed, 100 insertions(+), 61 deletions(-) diff --git a/test/multisig/administrator.test.mjs b/test/multisig/administrator.test.mjs index e124992b4..fdf1c5527 100644 --- a/test/multisig/administrator.test.mjs +++ b/test/multisig/administrator.test.mjs @@ -76,6 +76,46 @@ describe(`Testing Administrator`, () => { expect(ownerChallenges.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); }); + it('Set boot proposer with the multisig', async () => { + await contractMultiSig.setBootProposer( + signingKeys.user1, + signingKeys.user1, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + const approved = await contractMultiSig.setBootProposer( + signingKeys.user1, + signingKeys.user2, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + + await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + const bootProposer = await shieldContractInstance.methods.getBootProposer().call(); + + expect(bootProposer.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); + }); + + it('Set boot challenger with the multisig', async () => { + await contractMultiSig.setBootChallenger( + signingKeys.user1, + signingKeys.user1, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + const approved = await contractMultiSig.setBootChallenger( + signingKeys.user1, + signingKeys.user2, + addresses.user1, + await multisigContractInstance.methods.nonce().call(), + ); + + await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + const bootChallenger = await shieldContractInstance.methods.getBootChallenger().call(); + + expect(bootChallenger.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); + }); + it('Set restriction with the multisig', async () => { await contractMultiSig.setTokenRestrictions( nf3User.ethereumAddress, // simulate a token address @@ -132,46 +172,6 @@ describe(`Testing Administrator`, () => { expect(Number(restrictionWithdraw)).to.be.equal(0); }); - it('Set boot proposer with the multisig', async () => { - await contractMultiSig.setBootProposer( - signingKeys.user1, - signingKeys.user1, - addresses.user1, - await multisigContractInstance.methods.nonce().call(), - ); - const approved = await contractMultiSig.setBootProposer( - signingKeys.user1, - signingKeys.user2, - addresses.user1, - await multisigContractInstance.methods.nonce().call(), - ); - - await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); - const bootProposer = await shieldContractInstance.methods.getBootProposer().call(); - - expect(bootProposer.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); - }); - - it('Set boot challenger with the multisig', async () => { - await contractMultiSig.setBootChallenger( - signingKeys.user1, - signingKeys.user1, - addresses.user1, - await multisigContractInstance.methods.nonce().call(), - ); - const approved = await contractMultiSig.setBootChallenger( - signingKeys.user1, - signingKeys.user2, - addresses.user1, - await multisigContractInstance.methods.nonce().call(), - ); - - await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); - const bootChallenger = await shieldContractInstance.methods.getBootChallenger().call(); - - expect(bootChallenger.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); - }); - it('Set MATIC address with the multisig', async () => { await contractMultiSig.setMaticAddress( addresses.user1, @@ -191,7 +191,8 @@ describe(`Testing Administrator`, () => { expect(maticAddress.toUpperCase()).to.be.equal(addresses.user1.toUpperCase()); }); - /* it('Pause contracts with the multisig', async () => { + + it('Pause contracts with the multisig', async () => { const paused1 = await stateContractInstance.methods.paused().call(); await contractMultiSig.pauseContracts( signingKeys.user1, @@ -232,7 +233,7 @@ describe(`Testing Administrator`, () => { expect(paused1).to.be.equal(true); expect(paused2).to.be.equal(false); }); - + it('Be able to transfer ownership of contracts from multisig to a specific one', async () => { await contractMultiSig.transferOwnership( signingKeys.user1, @@ -252,7 +253,7 @@ describe(`Testing Administrator`, () => { expect(owner.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); }); - it('Set boot proposer', async () => { + it('Set boot proposer without multisig', async () => { await shieldContractInstance.methods .setBootProposer(nf3User.ethereumAddress) .send({ from: nf3User.ethereumAddress }); @@ -261,7 +262,7 @@ describe(`Testing Administrator`, () => { expect(bootProposer.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); }); - it('Set boot challenger', async () => { + it('Set boot challenger without multisig', async () => { await shieldContractInstance.methods .setBootChallenger(nf3User.ethereumAddress) .send({ from: nf3User.ethereumAddress }); @@ -270,7 +271,7 @@ describe(`Testing Administrator`, () => { expect(bootChallenger.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); }); - it('Set restriction', async () => { + it('Set restriction without multisig', async () => { await shieldContractInstance.methods .setRestriction(nf3User.ethereumAddress, 10, 100) .send({ from: nf3User.ethereumAddress }); @@ -285,7 +286,7 @@ describe(`Testing Administrator`, () => { expect(Number(restrictionWithdraw)).to.be.equal(100); }); - it('Remove restriction', async () => { + it('Remove restriction without multisig', async () => { await shieldContractInstance.methods .removeRestriction(nf3User.ethereumAddress) .send({ from: nf3User.ethereumAddress }); @@ -300,7 +301,7 @@ describe(`Testing Administrator`, () => { expect(Number(restrictionWithdraw)).to.be.equal(0); }); - it('Set MATIC address', async () => { + it('Set MATIC address without multisig', async () => { await shieldContractInstance.methods .setMaticAddress(nf3User.ethereumAddress) .send({ from: nf3User.ethereumAddress }); @@ -309,7 +310,7 @@ describe(`Testing Administrator`, () => { expect(maticAddress.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); }); - it('Pause State contract', async () => { + it('Pause State contract without multisig', async () => { const paused1 = await stateContractInstance.methods.paused().call(); await stateContractInstance.methods.pause().send({ from: nf3User.ethereumAddress }); const paused2 = await stateContractInstance.methods.paused().call(); @@ -318,7 +319,7 @@ describe(`Testing Administrator`, () => { expect(paused2).to.be.equal(true); }); - it('Unpause State contract', async () => { + it('Unpause State contract without multisig', async () => { const paused1 = await stateContractInstance.methods.paused().call(); await stateContractInstance.methods.unpause().send({ from: nf3User.ethereumAddress }); const paused2 = await stateContractInstance.methods.paused().call(); @@ -327,7 +328,7 @@ describe(`Testing Administrator`, () => { expect(paused2).to.be.equal(false); }); - it('Pause Shield contract', async () => { + it('Pause Shield contract without multisig', async () => { const paused1 = await shieldContractInstance.methods.paused().call(); await shieldContractInstance.methods.pause().send({ from: nf3User.ethereumAddress }); const paused2 = await shieldContractInstance.methods.paused().call(); @@ -336,7 +337,7 @@ describe(`Testing Administrator`, () => { expect(paused2).to.be.equal(true); }); - it('Unpause Shield contract', async () => { + it('Unpause Shield contract without multisig', async () => { const paused1 = await shieldContractInstance.methods.paused().call(); await shieldContractInstance.methods.unpause().send({ from: nf3User.ethereumAddress }); const paused2 = await shieldContractInstance.methods.paused().call(); @@ -371,7 +372,6 @@ describe(`Testing Administrator`, () => { expect(ownerProposers.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); expect(ownerChallenges.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); }); - */ }); after(async () => { diff --git a/test/multisig/multisig.mjs b/test/multisig/multisig.mjs index b3d7777ef..696f3fb9c 100644 --- a/test/multisig/multisig.mjs +++ b/test/multisig/multisig.mjs @@ -61,6 +61,19 @@ export class MultiSig { ]; } + /** + Read the nonce from the multisig contract + */ + async getMultiSigNonce() { + const { multiSigInstance } = this.MULTISIG_CONSTANTS; + if (!multiSigInstance) throw new Error('No multisig instance'); + const nonce = await multiSigInstance.methods.nonce().call(); + return Number(nonce); + } + + /** + Function to send signed transaction + */ async sendTransaction(unsignedTransaction, signingKey, contractAddress) { const tx = { from: this.web3.eth.accounts.privateKeyToAccount(signingKey).address, @@ -192,6 +205,9 @@ export class MultiSig { return this.sendTransaction(multiSigTransaction, executor, multiSigInstance.options.address); } + /** + * Execute multisig transaction + */ async executeMultiSigTransactions(approved, executor) { for (const approval of approved) { logger.info('Executing multisig transaction'); diff --git a/test/multisig/nightfall-multisig.mjs b/test/multisig/nightfall-multisig.mjs index b04d9a944..b746e56cb 100644 --- a/test/multisig/nightfall-multisig.mjs +++ b/test/multisig/nightfall-multisig.mjs @@ -45,8 +45,10 @@ export class NightfallMultiSig { /** This function transfers the ownership of the contracts that are ownable */ - transferOwnership(newOwnerPrivateKey, signingKey, executorAddress, nonce) { - logger.info(`transferOwnership: nonce is ${nonce}`); + async transferOwnership(newOwnerPrivateKey, signingKey, executorAddress, _nonce) { + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); + const newOwner = this.web3.eth.accounts.privateKeyToAccount(newOwnerPrivateKey, true).address; return Promise.all( this.contractInstancesOwnables().map(async (ownable, i) => { @@ -72,8 +74,11 @@ export class NightfallMultiSig { withdrawRestriction, signingKey, executorAddress, - nonce, + _nonce, ) { + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); + const data = this.contractInstances.shield.methods .setRestriction(tokenAddress, depositRestriction, withdrawRestriction) .encodeABI(); @@ -91,7 +96,10 @@ export class NightfallMultiSig { /** This function removes the restriction data that the Shield contract is currently using */ - async removeTokenRestrictions(tokenAddress, signingKey, executorAddress, nonce) { + async removeTokenRestrictions(tokenAddress, signingKey, executorAddress, _nonce) { + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); + const data = this.contractInstances.shield.methods.removeRestriction(tokenAddress).encodeABI(); return Promise.all([ this.multiSig.addMultiSigSignature( @@ -107,7 +115,10 @@ export class NightfallMultiSig { /** This function pauses contracts that are pausable */ - pauseContracts(signingKey, executorAddress, nonce) { + async pauseContracts(signingKey, executorAddress, _nonce) { + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); + logger.info('All pausable contracts being paused'); return Promise.all( this.contractInstancesPausables().map(async (pausable, i) => { @@ -127,7 +138,10 @@ export class NightfallMultiSig { /** This function unpauses contracts that are pausable */ - unpauseContracts(signingKey, executorAddress, nonce) { + async unpauseContracts(signingKey, executorAddress, _nonce) { + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); + logger.info('All pausable contracts being unpaused'); return Promise.all( this.contractInstancesPausables().map(async (pausable, i) => { @@ -147,7 +161,10 @@ export class NightfallMultiSig { /** This function sets the boot proposer */ - async setBootProposer(newProposerPrivateKey, signingKey, executorAddress, nonce) { + async setBootProposer(newProposerPrivateKey, signingKey, executorAddress, _nonce) { + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); + const newProposer = this.web3.eth.accounts.privateKeyToAccount( newProposerPrivateKey, true, @@ -168,7 +185,10 @@ export class NightfallMultiSig { /** This function sets the boot challenger */ - async setBootChallenger(newChallengerPrivateKey, signingKey, executorAddress, nonce) { + async setBootChallenger(newChallengerPrivateKey, signingKey, executorAddress, _nonce) { + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); + const newChallenger = this.web3.eth.accounts.privateKeyToAccount( newChallengerPrivateKey, true, @@ -189,7 +209,10 @@ export class NightfallMultiSig { /** This function sets the Matic address */ - async setMaticAddress(newMaticAddress, signingKey, executorAddress, nonce) { + async setMaticAddress(newMaticAddress, signingKey, executorAddress, _nonce) { + let nonce = _nonce; + if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); + const shieldContractInstance = this.contractInstances.shield; const data = shieldContractInstance.methods.setMaticAddress(newMaticAddress).encodeABI(); return Promise.all([ From e1a036fd764903226a57cd76aa4155db9ba767e5 Mon Sep 17 00:00:00 2001 From: daveroga Date: Thu, 22 Sep 2022 14:32:40 +0200 Subject: [PATCH 14/19] fix: check nonce --- test/multisig/multisig.mjs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/multisig/multisig.mjs b/test/multisig/multisig.mjs index 696f3fb9c..46ba4e38f 100644 --- a/test/multisig/multisig.mjs +++ b/test/multisig/multisig.mjs @@ -133,12 +133,10 @@ export class MultiSig { // This function creates the multisig message hash, which is signed (approved) by the key-holders. // It's worth looking at the multisig contract to see where this all comes from. - async createMultiSigMessageHash(destination, value, data, _nonce, executor, gasLimit) { - const { domainSeparator, txTypeHash, multiSigInstance, txInputHashABI } = - this.MULTISIG_CONSTANTS; - let nonce = _nonce; + async createMultiSigMessageHash(destination, value, data, nonce, executor, gasLimit) { + const { domainSeparator, txTypeHash, txInputHashABI } = this.MULTISIG_CONSTANTS; // get the current multisig nonce if it's not provided (requires blockchain connection) - if (!_nonce) nonce = await multiSigInstance.methods.nonce().call(); + if (!Number.isInteger(nonce)) throw new Error(`Nonce is not an integer: ${nonce}`); // compute the hashes to sign over note, sometimes we want a keccak hash over encoded parameter // and sometimes over encodedPacked parameters. Hence the two slightly different approaches used. const dataHash = this.web3.utils.soliditySha3({ t: 'bytes', v: data }); From fb3a62b9847b653571620a454341b4be5046fdcd Mon Sep 17 00:00:00 2001 From: daveroga Date: Thu, 22 Sep 2022 16:55:53 +0200 Subject: [PATCH 15/19] fix: pass previous transactions for final usability --- test/multisig/administrator.test.mjs | 53 ++++++++++++++++++---------- test/multisig/multisig.mjs | 30 ++++++++-------- test/multisig/nightfall-multisig.mjs | 29 +++++++++++---- 3 files changed, 73 insertions(+), 39 deletions(-) diff --git a/test/multisig/administrator.test.mjs b/test/multisig/administrator.test.mjs index fdf1c5527..3494c86f9 100644 --- a/test/multisig/administrator.test.mjs +++ b/test/multisig/administrator.test.mjs @@ -18,6 +18,8 @@ chai.use(chaiAsPromised); const environment = config.ENVIRONMENTS[process.env.ENVIRONMENT] || config.ENVIRONMENTS.localhost; const { mnemonics, signingKeys, addresses } = config.TEST_OPTIONS; +const amount1 = 10; +const amount2 = 100; const getContractInstance = async (contractName, nf3) => { const abi = contractABIs[contractName]; @@ -77,19 +79,20 @@ describe(`Testing Administrator`, () => { }); it('Set boot proposer with the multisig', async () => { - await contractMultiSig.setBootProposer( + const transactions = await contractMultiSig.setBootProposer( signingKeys.user1, signingKeys.user1, addresses.user1, await multisigContractInstance.methods.nonce().call(), + [], ); const approved = await contractMultiSig.setBootProposer( signingKeys.user1, signingKeys.user2, addresses.user1, await multisigContractInstance.methods.nonce().call(), + transactions, ); - await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); const bootProposer = await shieldContractInstance.methods.getBootProposer().call(); @@ -97,17 +100,19 @@ describe(`Testing Administrator`, () => { }); it('Set boot challenger with the multisig', async () => { - await contractMultiSig.setBootChallenger( + const transactions = await contractMultiSig.setBootChallenger( signingKeys.user1, signingKeys.user1, addresses.user1, await multisigContractInstance.methods.nonce().call(), + [], ); const approved = await contractMultiSig.setBootChallenger( signingKeys.user1, signingKeys.user2, addresses.user1, await multisigContractInstance.methods.nonce().call(), + transactions, ); await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); @@ -117,21 +122,23 @@ describe(`Testing Administrator`, () => { }); it('Set restriction with the multisig', async () => { - await contractMultiSig.setTokenRestrictions( + const transactions = await contractMultiSig.setTokenRestrictions( nf3User.ethereumAddress, // simulate a token address - 10, - 100, + amount1, + amount2, signingKeys.user1, addresses.user1, await multisigContractInstance.methods.nonce().call(), + [], ); const approved = await contractMultiSig.setTokenRestrictions( nf3User.ethereumAddress, // simulate a token address - 10, - 100, + amount1, + amount2, signingKeys.user2, addresses.user1, await multisigContractInstance.methods.nonce().call(), + transactions, ); await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); @@ -142,22 +149,24 @@ describe(`Testing Administrator`, () => { .getRestriction(nf3User.ethereumAddress, 1) .call(); - expect(Number(restrictionDeposit)).to.be.equal(10); - expect(Number(restrictionWithdraw)).to.be.equal(100); + expect(Number(restrictionDeposit)).to.be.equal(amount1); + expect(Number(restrictionWithdraw)).to.be.equal(amount2); }); it('Remove restriction with the multisig', async () => { - await contractMultiSig.removeTokenRestrictions( + const transactions = await contractMultiSig.removeTokenRestrictions( nf3User.ethereumAddress, // simulate a token address signingKeys.user1, addresses.user1, await multisigContractInstance.methods.nonce().call(), + [], ); const approved = await contractMultiSig.removeTokenRestrictions( nf3User.ethereumAddress, // simulate a token address signingKeys.user2, addresses.user1, await multisigContractInstance.methods.nonce().call(), + transactions, ); await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); @@ -173,17 +182,19 @@ describe(`Testing Administrator`, () => { }); it('Set MATIC address with the multisig', async () => { - await contractMultiSig.setMaticAddress( + const transactions = await contractMultiSig.setMaticAddress( addresses.user1, signingKeys.user1, addresses.user1, await multisigContractInstance.methods.nonce().call(), + [], ); const approved = await contractMultiSig.setMaticAddress( addresses.user1, signingKeys.user2, addresses.user1, await multisigContractInstance.methods.nonce().call(), + transactions, ); await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); @@ -194,15 +205,17 @@ describe(`Testing Administrator`, () => { it('Pause contracts with the multisig', async () => { const paused1 = await stateContractInstance.methods.paused().call(); - await contractMultiSig.pauseContracts( + const transactions = await contractMultiSig.pauseContracts( signingKeys.user1, addresses.user1, await multisigContractInstance.methods.nonce().call(), + [], ); const approved = await contractMultiSig.pauseContracts( signingKeys.user2, addresses.user1, await multisigContractInstance.methods.nonce().call(), + transactions, ); await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); @@ -215,15 +228,17 @@ describe(`Testing Administrator`, () => { it('Unpause contracts with the multisig', async () => { const paused1 = await stateContractInstance.methods.paused().call(); - await contractMultiSig.unpauseContracts( + const transactions = await contractMultiSig.unpauseContracts( signingKeys.user1, addresses.user1, await multisigContractInstance.methods.nonce().call(), + [], ); const approved = await contractMultiSig.unpauseContracts( signingKeys.user2, addresses.user1, await multisigContractInstance.methods.nonce().call(), + transactions, ); await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); @@ -235,17 +250,19 @@ describe(`Testing Administrator`, () => { }); it('Be able to transfer ownership of contracts from multisig to a specific one', async () => { - await contractMultiSig.transferOwnership( + const transactions = await contractMultiSig.transferOwnership( signingKeys.user1, signingKeys.user1, addresses.user1, await multisigContractInstance.methods.nonce().call(), + [], ); const approved = await contractMultiSig.transferOwnership( signingKeys.user1, signingKeys.user2, addresses.user1, await multisigContractInstance.methods.nonce().call(), + transactions, ); await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); @@ -273,7 +290,7 @@ describe(`Testing Administrator`, () => { it('Set restriction without multisig', async () => { await shieldContractInstance.methods - .setRestriction(nf3User.ethereumAddress, 10, 100) + .setRestriction(nf3User.ethereumAddress, amount1, amount2) .send({ from: nf3User.ethereumAddress }); const restrictionDeposit = await shieldContractInstance.methods .getRestriction(nf3User.ethereumAddress, 0) @@ -282,8 +299,8 @@ describe(`Testing Administrator`, () => { .getRestriction(nf3User.ethereumAddress, 1) .call(); - expect(Number(restrictionDeposit)).to.be.equal(10); - expect(Number(restrictionWithdraw)).to.be.equal(100); + expect(Number(restrictionDeposit)).to.be.equal(amount1); + expect(Number(restrictionWithdraw)).to.be.equal(amount2); }); it('Remove restriction without multisig', async () => { diff --git a/test/multisig/multisig.mjs b/test/multisig/multisig.mjs index 46ba4e38f..b3e34fd48 100644 --- a/test/multisig/multisig.mjs +++ b/test/multisig/multisig.mjs @@ -4,8 +4,6 @@ import logger from 'common-files/utils/logger.mjs'; // eslint-disable-next-line import/prefer-default-export export class MultiSig { - transactions = []; - MULTISIG_CONSTANTS = {}; SIGNATURE_THRESHOLD = 2; @@ -89,41 +87,44 @@ export class MultiSig { /** Function to save a signed transaction, ready for the multisig */ - async saveSigned(signed) { - this.transactions.push({ _id: signed.messageHash.concat(signed.by.slice(2)), ...signed }); + // eslint-disable-next-line class-methods-use-this + async saveSigned(signed, transactions) { + transactions.push({ _id: signed.messageHash.concat(signed.by.slice(2)), ...signed }); } /** Function to get the signatures */ - async getSigned(messageHash) { - return this.transactions.filter(t => t.messageHash === messageHash); + // eslint-disable-next-line class-methods-use-this + async getSigned(messageHash, transactions) { + return transactions.filter(t => t.messageHash === messageHash); } /** Function to check that there are enough transactions to send some signed data */ - async checkThreshold(messageHash) { - return this.transactions.filter(t => t.messageHash === messageHash).length; + // eslint-disable-next-line class-methods-use-this + async checkThreshold(messageHash, transactions) { + return transactions.filter(t => t.messageHash === messageHash).length; } // This function saves a signed transaction and will return the array of so-far signed // transactions - async addSignedTransaction(signed) { + async addSignedTransaction(signed, transactions) { // save the signed transaction until we meet the signature threshold, only if it's actually signed if (signed.r) { try { - await this.saveSigned(signed); + await this.saveSigned(signed, transactions); } catch (err) { if (err.message.includes('duplicate key')) console.log('You have already signed this message - no action taken'); else throw new Error(err); } } - const numberOfSignatures = await this.checkThreshold(signed.messageHash); + const numberOfSignatures = await this.checkThreshold(signed.messageHash, transactions); logger.info(`Number of signatures for this transaction is ${numberOfSignatures}`); if (numberOfSignatures === this.SIGNATURE_THRESHOLD) logger.info(`Signature threshold reached`); - const signedArray = (await this.getSigned(signed.messageHash)).sort((a, b) => { + const signedArray = (await this.getSigned(signed.messageHash, transactions)).sort((a, b) => { const x = BigInt(a.by); const y = BigInt(b.by); return x < y ? -1 : x > y ? 1 : 0; // eslint-disable-line no-nested-ternary @@ -158,6 +159,7 @@ export class MultiSig { contractAddress, executorAddress, nonce, + transactions, ) { // compute a signature over the unsigned transaction data const messageHash = await this.createMultiSigMessageHash( @@ -168,7 +170,7 @@ export class MultiSig { executorAddress, this.gas, ); - if (!signingKey) return this.addSignedTransaction({ messageHash }); // if no signing key is given, don't create a new signed transaction + if (!signingKey) return this.addSignedTransaction({ messageHash }, transactions); // if no signing key is given, don't create a new signed transaction const { r, s, v } = ecsign( Buffer.from(messageHash.slice(2), 'hex'), Buffer.from(signingKey.slice(2), 'hex'), @@ -182,7 +184,7 @@ export class MultiSig { contractAddress, data: unsignedTransactionData, }; - return this.addSignedTransaction(signed); + return this.addSignedTransaction(signed, transactions); } async executeMultiSigTransaction(signedArray, executor) { diff --git a/test/multisig/nightfall-multisig.mjs b/test/multisig/nightfall-multisig.mjs index b746e56cb..51d46e8e9 100644 --- a/test/multisig/nightfall-multisig.mjs +++ b/test/multisig/nightfall-multisig.mjs @@ -45,7 +45,7 @@ export class NightfallMultiSig { /** This function transfers the ownership of the contracts that are ownable */ - async transferOwnership(newOwnerPrivateKey, signingKey, executorAddress, _nonce) { + async transferOwnership(newOwnerPrivateKey, signingKey, executorAddress, _nonce, transactions) { let nonce = _nonce; if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); @@ -60,6 +60,7 @@ export class NightfallMultiSig { contractInstance.options.address, executorAddress, nonce + i, + transactions.flat(), ); }), ); @@ -75,6 +76,7 @@ export class NightfallMultiSig { signingKey, executorAddress, _nonce, + transactions, ) { let nonce = _nonce; if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); @@ -89,6 +91,7 @@ export class NightfallMultiSig { this.contractInstances.shield.options.address, executorAddress, nonce, + transactions.flat(), ), ]); } @@ -96,7 +99,7 @@ export class NightfallMultiSig { /** This function removes the restriction data that the Shield contract is currently using */ - async removeTokenRestrictions(tokenAddress, signingKey, executorAddress, _nonce) { + async removeTokenRestrictions(tokenAddress, signingKey, executorAddress, _nonce, transactions) { let nonce = _nonce; if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); @@ -108,6 +111,7 @@ export class NightfallMultiSig { this.contractInstances.shield.options.address, executorAddress, nonce, + transactions.flat(), ), ]); } @@ -115,7 +119,7 @@ export class NightfallMultiSig { /** This function pauses contracts that are pausable */ - async pauseContracts(signingKey, executorAddress, _nonce) { + async pauseContracts(signingKey, executorAddress, _nonce, transactions) { let nonce = _nonce; if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); @@ -130,6 +134,7 @@ export class NightfallMultiSig { contractInstance.options.address, executorAddress, nonce + i, + transactions.flat(), ); }), ); @@ -138,7 +143,7 @@ export class NightfallMultiSig { /** This function unpauses contracts that are pausable */ - async unpauseContracts(signingKey, executorAddress, _nonce) { + async unpauseContracts(signingKey, executorAddress, _nonce, transactions) { let nonce = _nonce; if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); @@ -153,6 +158,7 @@ export class NightfallMultiSig { contractInstance.options.address, executorAddress, nonce + i, + transactions.flat(), ); }), ); @@ -161,7 +167,7 @@ export class NightfallMultiSig { /** This function sets the boot proposer */ - async setBootProposer(newProposerPrivateKey, signingKey, executorAddress, _nonce) { + async setBootProposer(newProposerPrivateKey, signingKey, executorAddress, _nonce, transactions) { let nonce = _nonce; if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); @@ -178,6 +184,7 @@ export class NightfallMultiSig { shieldContractInstance.options.address, executorAddress, nonce, + transactions.flat(), ), ]); } @@ -185,7 +192,13 @@ export class NightfallMultiSig { /** This function sets the boot challenger */ - async setBootChallenger(newChallengerPrivateKey, signingKey, executorAddress, _nonce) { + async setBootChallenger( + newChallengerPrivateKey, + signingKey, + executorAddress, + _nonce, + transactions, + ) { let nonce = _nonce; if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); @@ -202,6 +215,7 @@ export class NightfallMultiSig { shieldContractInstance.options.address, executorAddress, nonce, + transactions.flat(), ), ]); } @@ -209,7 +223,7 @@ export class NightfallMultiSig { /** This function sets the Matic address */ - async setMaticAddress(newMaticAddress, signingKey, executorAddress, _nonce) { + async setMaticAddress(newMaticAddress, signingKey, executorAddress, _nonce, transactions) { let nonce = _nonce; if (!Number.isInteger(nonce)) nonce = await this.multiSig.getMultiSigNonce(); @@ -222,6 +236,7 @@ export class NightfallMultiSig { shieldContractInstance.options.address, executorAddress, nonce, + transactions.flat(), ), ]); } From 18b25e7e231c773630343c5c052a403820992006 Mon Sep 17 00:00:00 2001 From: daveroga Date: Fri, 23 Sep 2022 16:44:55 +0200 Subject: [PATCH 16/19] fix: add contracts abi calls --- .eslintrc.js | 7 +- cli/lib/nf3.mjs | 13 + package.json | 5 - test/multisig/administrator.test.mjs | 3 +- test/multisig/contracts.mjs | 14 - test/multisig/contracts/Challenges.json | 1804 ------------------- test/multisig/contracts/Proposers.json | 468 ----- test/multisig/contracts/Shield.json | 1245 ------------- test/multisig/contracts/SimpleMultiSig.json | 151 -- test/multisig/contracts/State.json | 1609 ----------------- 10 files changed, 15 insertions(+), 5304 deletions(-) delete mode 100644 test/multisig/contracts.mjs delete mode 100644 test/multisig/contracts/Challenges.json delete mode 100644 test/multisig/contracts/Proposers.json delete mode 100644 test/multisig/contracts/Shield.json delete mode 100644 test/multisig/contracts/SimpleMultiSig.json delete mode 100644 test/multisig/contracts/State.json diff --git a/.eslintrc.js b/.eslintrc.js index 5d8fffe95..0bcb57f9e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,18 +9,13 @@ module.exports = { 'func-names': 'off', 'no-sparse-arrays': 'off', }, - parser: '@babel/eslint-parser', + parser: 'babel-eslint', // Uses babel-eslint transforms. parserOptions: { ecmaFeatures: { jsx: true, }, ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features sourceType: 'module', // Allows for the use of imports - babelOptions: { - plugins: ['@babel/plugin-syntax-import-assertions'], - babelrc: false, - configFile: false, - }, }, settings: { 'import/resolver': { diff --git a/cli/lib/nf3.mjs b/cli/lib/nf3.mjs index 29c3b2165..96d03dd73 100644 --- a/cli/lib/nf3.mjs +++ b/cli/lib/nf3.mjs @@ -338,6 +338,19 @@ class Nf3 { return res.data.address.toLowerCase(); } + /** + Returns the abi of a Nightfall_3 contract calling the client. + @method + @async + @param {string} contractName - the name of the smart contract in question. Possible + values are 'Shield', 'State', 'Proposers', 'Challengers'. + @returns {Promise} Resolves into the Ethereum abi of the contract + */ + async getContractAbi(contractName) { + const res = await axios.get(`${this.clientBaseUrl}/contract-abi/${contractName}`); + return res.data.abi; + } + /** Returns the address of a Nightfall_3 contract calling the optimist. @method diff --git a/package.json b/package.json index a16b3a41b..817f6de5b 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,6 @@ "version": "0.0.1", "description": "Optimistic Nightfall", "main": "./nightfall-client/src/index.mjs", - "babel": { - "plugins": [ - "@babel/plugin-syntax-import-assertions" - ] - }, "scripts": { "lint": "eslint . --ext js,mjs,jsx,ts,tsx && find-unused-exports", "prepare": "husky install", diff --git a/test/multisig/administrator.test.mjs b/test/multisig/administrator.test.mjs index 3494c86f9..4e0fcdec0 100644 --- a/test/multisig/administrator.test.mjs +++ b/test/multisig/administrator.test.mjs @@ -7,7 +7,6 @@ import chaiHttp from 'chai-http'; import config from 'config'; import chaiAsPromised from 'chai-as-promised'; import Nf3 from '../../cli/lib/nf3.mjs'; -import contractABIs from './contracts.mjs'; import { NightfallMultiSig } from './nightfall-multisig.mjs'; const { WEB3_OPTIONS } = config; @@ -22,7 +21,7 @@ const amount1 = 10; const amount2 = 100; const getContractInstance = async (contractName, nf3) => { - const abi = contractABIs[contractName]; + const abi = nf3.getContractAbi(contractName); const contractAddress = await nf3.getContractAddress(contractName); const contractInstance = new nf3.web3.eth.Contract(abi, contractAddress); return contractInstance; diff --git a/test/multisig/contracts.mjs b/test/multisig/contracts.mjs deleted file mode 100644 index 8bed6f43b..000000000 --- a/test/multisig/contracts.mjs +++ /dev/null @@ -1,14 +0,0 @@ -import Shield from './contracts/Shield.json' assert { type: 'json' }; -import Proposers from './contracts/Proposers.json' assert { type: 'json' }; -import Challenges from './contracts/Challenges.json' assert { type: 'json' }; -import State from './contracts/State.json' assert { type: 'json' }; -import SimpleMultiSig from './contracts/SimpleMultiSig.json' assert { type: 'json' }; - -// ignore unused exports default -export default { - Shield, - Proposers, - Challenges, - State, - SimpleMultiSig, -}; diff --git a/test/multisig/contracts/Challenges.json b/test/multisig/contracts/Challenges.json deleted file mode 100644 index 4c0b654ad..000000000 --- a/test/multisig/contracts/Challenges.json +++ /dev/null @@ -1,1804 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [], - "name": "BlockProposed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "commitHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "CommittedToChallenge", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "withdrawTransactionHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "paidBy", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "InstantWithdrawalRequested", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "NewBootChallengerSet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "NewBootProposerSet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "proposer", - "type": "address" - } - ], - "name": "NewCurrentProposer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "leafIndex", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "leafValue", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - } - ], - "name": "NewLeaf", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "minLeafIndex", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32[]", - "name": "leafValues", - "type": "bytes32[]" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - } - ], - "name": "NewLeaves", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - } - ], - "name": "Rollback", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "ercAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "ShieldBalanceTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "TransactionSubmitted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "enum Structures.TransactionTypes", - "name": "txType", - "type": "uint8" - } - ], - "name": "VkChanged", - "type": "event" - }, - { - "inputs": [], - "name": "_owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "committers", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getBootChallenger", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getBootProposer", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getMaticAddress", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenAddr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "transactionType", - "type": "uint256" - } - ], - "name": "getRestriction", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "enum Structures.TransactionTypes", - "name": "txType", - "type": "uint8" - } - ], - "name": "getVerificationKey", - "outputs": [ - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256[]", - "name": "_vk", - "type": "uint256[]" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "_txType", - "type": "uint8" - } - ], - "name": "registerVerificationKey", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenAddr", - "type": "address" - } - ], - "name": "removeRestriction", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "challenger", - "type": "address" - } - ], - "name": "setBootChallenger", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "proposer", - "type": "address" - } - ], - "name": "setBootProposer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_maticAddress", - "type": "address" - } - ], - "name": "setMaticAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenAddr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "depositAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "withdrawAmount", - "type": "uint256" - } - ], - "name": "setRestriction", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "stateAddress", - "type": "address" - } - ], - "name": "setStateContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "state", - "outputs": [ - { - "internalType": "contract State", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "enum Structures.TransactionTypes", - "name": "", - "type": "uint8" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "vks", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "priorBlockL2", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction[]", - "name": "priorBlockTransactions", - "type": "tuple[]" - }, - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "blockL2", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction[]", - "name": "transactions", - "type": "tuple[]" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - } - ], - "name": "challengeLeafCountCorrect", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "priorBlockL2", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction[]", - "name": "priorBlockTransactions", - "type": "tuple[]" - }, - { - "internalType": "bytes32[33]", - "name": "frontierPriorBlock", - "type": "bytes32[33]" - }, - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "blockL2", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction[]", - "name": "transactions", - "type": "tuple[]" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - } - ], - "name": "challengeNewRootCorrect", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "block1", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "block2", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction[]", - "name": "transactions1", - "type": "tuple[]" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction[]", - "name": "transactions2", - "type": "tuple[]" - }, - { - "internalType": "uint256", - "name": "transaction1Index", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "transaction2Index", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "commitment1Index", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "commitment2Index", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - } - ], - "name": "challengeCommitment", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "block1", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "block2", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction[]", - "name": "transactions1", - "type": "tuple[]" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction[]", - "name": "transactions2", - "type": "tuple[]" - }, - { - "internalType": "uint256", - "name": "transaction1Index", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "transaction2Index", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "nullifier1Index", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "nullifier2Index", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - } - ], - "name": "challengeNullifier", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "blockL2", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction[]", - "name": "transactions", - "type": "tuple[]" - }, - { - "internalType": "uint256", - "name": "transactionIndex", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block[4]", - "name": "blockL2ContainingHistoricRoot", - "type": "tuple[4]" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction[][4]", - "name": "transactionsOfblockL2ContainingHistoricRoot", - "type": "tuple[][4]" - }, - { - "internalType": "uint256[8]", - "name": "uncompressedProof", - "type": "uint256[8]" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - } - ], - "name": "challengeProofVerification", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "blockL2", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction[]", - "name": "transactions", - "type": "tuple[]" - }, - { - "internalType": "uint256", - "name": "transactionIndex", - "type": "uint256" - } - ], - "name": "challengeHistoricRoot", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "commitHash", - "type": "bytes32" - } - ], - "name": "commitToChallenge", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/test/multisig/contracts/Proposers.json b/test/multisig/contracts/Proposers.json deleted file mode 100644 index a4c6e2868..000000000 --- a/test/multisig/contracts/Proposers.json +++ /dev/null @@ -1,468 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [], - "name": "BlockProposed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "commitHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "CommittedToChallenge", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "withdrawTransactionHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "paidBy", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "InstantWithdrawalRequested", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "NewBootChallengerSet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "NewBootProposerSet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "proposer", - "type": "address" - } - ], - "name": "NewCurrentProposer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "leafIndex", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "leafValue", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - } - ], - "name": "NewLeaf", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "minLeafIndex", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32[]", - "name": "leafValues", - "type": "bytes32[]" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - } - ], - "name": "NewLeaves", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - } - ], - "name": "Rollback", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "ercAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "ShieldBalanceTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "TransactionSubmitted", - "type": "event" - }, - { - "inputs": [], - "name": "_owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getBootChallenger", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getBootProposer", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getMaticAddress", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenAddr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "transactionType", - "type": "uint256" - } - ], - "name": "getRestriction", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenAddr", - "type": "address" - } - ], - "name": "removeRestriction", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "challenger", - "type": "address" - } - ], - "name": "setBootChallenger", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "proposer", - "type": "address" - } - ], - "name": "setBootProposer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_maticAddress", - "type": "address" - } - ], - "name": "setMaticAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenAddr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "depositAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "withdrawAmount", - "type": "uint256" - } - ], - "name": "setRestriction", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "stateAddress", - "type": "address" - } - ], - "name": "setStateContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "state", - "outputs": [ - { - "internalType": "contract State", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "changeCurrentProposer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "url", - "type": "string" - } - ], - "name": "registerProposer", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "deRegisterProposer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "withdrawBond", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "url", - "type": "string" - } - ], - "name": "updateProposer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/test/multisig/contracts/Shield.json b/test/multisig/contracts/Shield.json deleted file mode 100644 index 14fa6ecfd..000000000 --- a/test/multisig/contracts/Shield.json +++ /dev/null @@ -1,1245 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [], - "name": "BlockProposed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "commitHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "CommittedToChallenge", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "withdrawTransactionHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "paidBy", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "InstantWithdrawalRequested", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "NewBootChallengerSet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "NewBootProposerSet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "proposer", - "type": "address" - } - ], - "name": "NewCurrentProposer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "leafIndex", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "leafValue", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - } - ], - "name": "NewLeaf", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "minLeafIndex", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32[]", - "name": "leafValues", - "type": "bytes32[]" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - } - ], - "name": "NewLeaves", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Paused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - } - ], - "name": "Rollback", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "ercAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "ShieldBalanceTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "TransactionSubmitted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Unpaused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "enum Structures.TransactionTypes", - "name": "txType", - "type": "uint8" - } - ], - "name": "VkChanged", - "type": "event" - }, - { - "inputs": [], - "name": "_owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "advancedFeeWithdrawals", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "advancedWithdrawals", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getBootChallenger", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getBootProposer", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getMaticAddress", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenAddr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "transactionType", - "type": "uint256" - } - ], - "name": "getRestriction", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "enum Structures.TransactionTypes", - "name": "txType", - "type": "uint8" - } - ], - "name": "getVerificationKey", - "outputs": [ - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "paused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256[]", - "name": "_vk", - "type": "uint256[]" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "_txType", - "type": "uint8" - } - ], - "name": "registerVerificationKey", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenAddr", - "type": "address" - } - ], - "name": "removeRestriction", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "challenger", - "type": "address" - } - ], - "name": "setBootChallenger", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "proposer", - "type": "address" - } - ], - "name": "setBootProposer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_maticAddress", - "type": "address" - } - ], - "name": "setMaticAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenAddr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "depositAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "withdrawAmount", - "type": "uint256" - } - ], - "name": "setRestriction", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "stateAddress", - "type": "address" - } - ], - "name": "setStateContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "state", - "outputs": [ - { - "internalType": "contract State", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "unpause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "enum Structures.TransactionTypes", - "name": "", - "type": "uint8" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "vks", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "withdrawn", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction", - "name": "t", - "type": "tuple" - } - ], - "name": "submitTransaction", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "b", - "type": "tuple" - } - ], - "name": "requestBlockPayment", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "_from", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_tokenId", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "onERC721Received", - "outputs": [ - { - "internalType": "bytes4", - "name": "", - "type": "bytes4" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_operator", - "type": "address" - }, - { - "internalType": "address", - "name": "_from", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_value", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "_data", - "type": "bytes" - } - ], - "name": "onERC1155Received", - "outputs": [ - { - "internalType": "bytes4", - "name": "", - "type": "bytes4" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "b", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction", - "name": "t", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - }, - { - "internalType": "bytes32[]", - "name": "siblingPath", - "type": "bytes32[]" - } - ], - "name": "isValidWithdrawal", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "b", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction", - "name": "t", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - }, - { - "internalType": "bytes32[]", - "name": "siblingPath", - "type": "bytes32[]" - } - ], - "name": "finaliseWithdrawal", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction", - "name": "withdrawTransaction", - "type": "tuple" - } - ], - "name": "advanceWithdrawal", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "b", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction", - "name": "t", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - }, - { - "internalType": "bytes32[]", - "name": "siblingPath", - "type": "bytes32[]" - } - ], - "name": "setAdvanceWithdrawalFee", - "outputs": [], - "stateMutability": "payable", - "type": "function" - } -] diff --git a/test/multisig/contracts/SimpleMultiSig.json b/test/multisig/contracts/SimpleMultiSig.json deleted file mode 100644 index ebb1c0620..000000000 --- a/test/multisig/contracts/SimpleMultiSig.json +++ /dev/null @@ -1,151 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "uint256", - "name": "threshold_", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "owners_", - "type": "address[]" - }, - { - "internalType": "uint256", - "name": "chainId", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "nonce", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "ownersArr", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "threshold", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - }, - { - "inputs": [], - "name": "owners", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "threshold_", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "owners_", - "type": "address[]" - } - ], - "name": "setOwners", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint8[]", - "name": "sigV", - "type": "uint8[]" - }, - { - "internalType": "bytes32[]", - "name": "sigR", - "type": "bytes32[]" - }, - { - "internalType": "bytes32[]", - "name": "sigS", - "type": "bytes32[]" - }, - { - "internalType": "address", - "name": "destination", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "internalType": "address", - "name": "executor", - "type": "address" - }, - { - "internalType": "uint256", - "name": "gasLimit", - "type": "uint256" - } - ], - "name": "execute", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/test/multisig/contracts/State.json b/test/multisig/contracts/State.json deleted file mode 100644 index 26d195775..000000000 --- a/test/multisig/contracts/State.json +++ /dev/null @@ -1,1609 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [], - "name": "BlockProposed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "commitHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "CommittedToChallenge", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "withdrawTransactionHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "paidBy", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "InstantWithdrawalRequested", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "NewBootChallengerSet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "NewBootProposerSet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "proposer", - "type": "address" - } - ], - "name": "NewCurrentProposer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "leafIndex", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "leafValue", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - } - ], - "name": "NewLeaf", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "minLeafIndex", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32[]", - "name": "leafValues", - "type": "bytes32[]" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - } - ], - "name": "NewLeaves", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Paused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - } - ], - "name": "Rollback", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "ercAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "ShieldBalanceTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "TransactionSubmitted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Unpaused", - "type": "event" - }, - { - "inputs": [], - "name": "_owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "blockHashes", - "outputs": [ - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "time", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "bondAccounts", - "outputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "time", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "challengesAddress", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "claimedBlockStakes", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "currentProposer", - "outputs": [ - { - "internalType": "address", - "name": "thisAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "previousAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "nextAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "url", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "feeBook", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getBootChallenger", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getBootProposer", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getMaticAddress", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenAddr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "transactionType", - "type": "uint256" - } - ], - "name": "getRestriction", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "paused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "pendingWithdrawals", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "proposerStartBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "proposers", - "outputs": [ - { - "internalType": "address", - "name": "thisAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "previousAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "nextAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "url", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "proposersAddress", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenAddr", - "type": "address" - } - ], - "name": "removeRestriction", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "challenger", - "type": "address" - } - ], - "name": "setBootChallenger", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "proposer", - "type": "address" - } - ], - "name": "setBootProposer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_maticAddress", - "type": "address" - } - ], - "name": "setMaticAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenAddr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "depositAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "withdrawAmount", - "type": "uint256" - } - ], - "name": "setRestriction", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "shieldAddress", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "unpause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - }, - { - "inputs": [], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_proposersAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "_challengesAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "_shieldAddress", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "b", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction[]", - "name": "t", - "type": "tuple[]" - } - ], - "name": "proposeBlock", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "blockNumberL2ToRollbackTo", - "type": "uint256" - } - ], - "name": "emitRollback", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "components": [ - { - "internalType": "address", - "name": "thisAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "previousAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "nextAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "url", - "type": "string" - } - ], - "internalType": "struct Structures.LinkedAddress", - "name": "proposer", - "type": "tuple" - } - ], - "name": "setProposer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "getProposer", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "thisAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "previousAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "nextAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "url", - "type": "string" - } - ], - "internalType": "struct Structures.LinkedAddress", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "deleteProposer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "proposer", - "type": "address" - } - ], - "name": "setCurrentProposer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentProposer", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "thisAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "previousAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "nextAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "url", - "type": "string" - } - ], - "internalType": "struct Structures.LinkedAddress", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - } - ], - "name": "getFeeBookInfo", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "feePaymentsEth", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "feePaymentsMatic", - "type": "uint256" - } - ], - "name": "setFeeBookInfo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "time", - "type": "uint256" - } - ], - "internalType": "struct Structures.BlockData", - "name": "bd", - "type": "tuple" - } - ], - "name": "pushBlockData", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "popBlockData", - "outputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "time", - "type": "uint256" - } - ], - "internalType": "struct Structures.BlockData", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - } - ], - "name": "getBlockData", - "outputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "time", - "type": "uint256" - } - ], - "internalType": "struct Structures.BlockData", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getAllBlockData", - "outputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "time", - "type": "uint256" - } - ], - "internalType": "struct Structures.BlockData[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getNumberOfL2Blocks", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getLatestBlockHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amountEth", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountMatic", - "type": "uint256" - } - ], - "name": "addPendingWithdrawal", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "withdraw", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "sb", - "type": "uint256" - } - ], - "name": "setProposerStartBlock", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "getProposerStartBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "proposer", - "type": "address" - } - ], - "name": "removeProposer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "string", - "name": "url", - "type": "string" - } - ], - "name": "updateProposer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "b", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction[]", - "name": "ts", - "type": "tuple[]" - } - ], - "name": "areBlockAndTransactionsReal", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint48", - "name": "leafCount", - "type": "uint48" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "blockNumberL2", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "previousBlockHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "transactionHashesRoot", - "type": "bytes32" - } - ], - "internalType": "struct Structures.Block", - "name": "b", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint112", - "name": "value", - "type": "uint112" - }, - { - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "internalType": "enum Structures.TransactionTypes", - "name": "transactionType", - "type": "uint8" - }, - { - "internalType": "enum Structures.TokenType", - "name": "tokenType", - "type": "uint8" - }, - { - "internalType": "uint64[4]", - "name": "historicRootBlockNumberL2", - "type": "uint64[4]" - }, - { - "internalType": "bytes32", - "name": "tokenId", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "ercAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipientAddress", - "type": "bytes32" - }, - { - "internalType": "bytes32[3]", - "name": "commitments", - "type": "bytes32[3]" - }, - { - "internalType": "bytes32[4]", - "name": "nullifiers", - "type": "bytes32[4]" - }, - { - "internalType": "bytes32[2]", - "name": "compressedSecrets", - "type": "bytes32[2]" - }, - { - "internalType": "uint256[4]", - "name": "proof", - "type": "uint256[4]" - } - ], - "internalType": "struct Structures.Transaction", - "name": "t", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - }, - { - "internalType": "bytes32[]", - "name": "siblingPath", - "type": "bytes32[]" - } - ], - "name": "areBlockAndTransactionReal", - "outputs": [], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "setBondAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "getBondAccount", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "time", - "type": "uint256" - } - ], - "internalType": "struct Structures.TimeLockedBond", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "challengerAddr", - "type": "address" - }, - { - "internalType": "address", - "name": "proposer", - "type": "address" - }, - { - "internalType": "uint256", - "name": "numRemoved", - "type": "uint256" - } - ], - "name": "rewardChallenger", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "time", - "type": "uint256" - } - ], - "name": "updateBondAccountTime", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - } - ], - "name": "isBlockStakeWithdrawn", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - } - ], - "name": "setBlockStakeWithdrawn", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] From 2b3e991890adaad260851f67ae244829f8949aa5 Mon Sep 17 00:00:00 2001 From: daveroga Date: Fri, 23 Sep 2022 17:17:25 +0200 Subject: [PATCH 17/19] fix: await missing --- test/multisig/administrator.test.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/multisig/administrator.test.mjs b/test/multisig/administrator.test.mjs index 4e0fcdec0..f8a6163bb 100644 --- a/test/multisig/administrator.test.mjs +++ b/test/multisig/administrator.test.mjs @@ -21,7 +21,7 @@ const amount1 = 10; const amount2 = 100; const getContractInstance = async (contractName, nf3) => { - const abi = nf3.getContractAbi(contractName); + const abi = await nf3.getContractAbi(contractName); const contractAddress = await nf3.getContractAddress(contractName); const contractInstance = new nf3.web3.eth.Contract(abi, contractAddress); return contractInstance; @@ -37,11 +37,14 @@ describe(`Testing Administrator`, () => { let contractMultiSig; before(async () => { + console.log('1'); nf3User = new Nf3(signingKeys.user1, environment); await nf3User.init(mnemonics.user1); + console.log('2'); stateContractInstance = await getContractInstance('State', nf3User); + console.log('3'); proposersContractInstance = await getContractInstance('Proposers', nf3User); shieldContractInstance = await getContractInstance('Shield', nf3User); challengesContractInstance = await getContractInstance('Challenges', nf3User); From adc13009655bd367ace3742b91418c0580873cb2 Mon Sep 17 00:00:00 2001 From: daveroga Date: Sat, 24 Sep 2022 01:01:15 +0200 Subject: [PATCH 18/19] fix: rename some variables --- test/multisig/administrator.test.mjs | 217 +++++++++++++-------------- 1 file changed, 107 insertions(+), 110 deletions(-) diff --git a/test/multisig/administrator.test.mjs b/test/multisig/administrator.test.mjs index f8a6163bb..e4c942564 100644 --- a/test/multisig/administrator.test.mjs +++ b/test/multisig/administrator.test.mjs @@ -29,36 +29,33 @@ const getContractInstance = async (contractName, nf3) => { describe(`Testing Administrator`, () => { let nf3User; - let stateContractInstance; - let proposersContractInstance; - let shieldContractInstance; - let challengesContractInstance; - let multisigContractInstance; - let contractMultiSig; + let stateContract; + let proposersContract; + let shieldContract; + let challengesContract; + let multisigContract; + let nfMultiSig; before(async () => { - console.log('1'); nf3User = new Nf3(signingKeys.user1, environment); await nf3User.init(mnemonics.user1); - console.log('2'); - stateContractInstance = await getContractInstance('State', nf3User); - console.log('3'); - proposersContractInstance = await getContractInstance('Proposers', nf3User); - shieldContractInstance = await getContractInstance('Shield', nf3User); - challengesContractInstance = await getContractInstance('Challenges', nf3User); - multisigContractInstance = await getContractInstance('SimpleMultiSig', nf3User); + stateContract = await getContractInstance('State', nf3User); + proposersContract = await getContractInstance('Proposers', nf3User); + shieldContract = await getContractInstance('Shield', nf3User); + challengesContract = await getContractInstance('Challenges', nf3User); + multisigContract = await getContractInstance('SimpleMultiSig', nf3User); if (!(await nf3User.healthcheck('client'))) throw new Error('Healthcheck failed'); - contractMultiSig = new NightfallMultiSig( + nfMultiSig = new NightfallMultiSig( nf3User.web3, { - state: stateContractInstance, - proposers: proposersContractInstance, - shield: shieldContractInstance, - challenges: challengesContractInstance, - multisig: multisigContractInstance, + state: stateContract, + proposers: proposersContract, + shield: shieldContract, + challenges: challengesContract, + multisig: multisigContract, }, 2, await nf3User.web3.eth.getChainId(), @@ -68,11 +65,11 @@ describe(`Testing Administrator`, () => { describe(`Basic tests`, () => { it('Owner of the State, Proposers, Shield and Challenges contract should be the multisig', async function () { - const ownerState = await stateContractInstance.methods.owner().call(); - const ownerShield = await shieldContractInstance.methods.owner().call(); - const ownerProposers = await proposersContractInstance.methods.owner().call(); - const ownerChallenges = await challengesContractInstance.methods.owner().call(); - const multisigAddress = multisigContractInstance.options.address; + const ownerState = await stateContract.methods.owner().call(); + const ownerShield = await shieldContract.methods.owner().call(); + const ownerProposers = await proposersContract.methods.owner().call(); + const ownerChallenges = await challengesContract.methods.owner().call(); + const multisigAddress = multisigContract.options.address; expect(ownerState.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); expect(ownerShield.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); @@ -81,73 +78,73 @@ describe(`Testing Administrator`, () => { }); it('Set boot proposer with the multisig', async () => { - const transactions = await contractMultiSig.setBootProposer( + const transactions = await nfMultiSig.setBootProposer( signingKeys.user1, signingKeys.user1, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), [], ); - const approved = await contractMultiSig.setBootProposer( + const approved = await nfMultiSig.setBootProposer( signingKeys.user1, signingKeys.user2, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), transactions, ); - await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); - const bootProposer = await shieldContractInstance.methods.getBootProposer().call(); + await nfMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + const bootProposer = await shieldContract.methods.getBootProposer().call(); expect(bootProposer.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); }); it('Set boot challenger with the multisig', async () => { - const transactions = await contractMultiSig.setBootChallenger( + const transactions = await nfMultiSig.setBootChallenger( signingKeys.user1, signingKeys.user1, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), [], ); - const approved = await contractMultiSig.setBootChallenger( + const approved = await nfMultiSig.setBootChallenger( signingKeys.user1, signingKeys.user2, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), transactions, ); - await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); - const bootChallenger = await shieldContractInstance.methods.getBootChallenger().call(); + await nfMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + const bootChallenger = await shieldContract.methods.getBootChallenger().call(); expect(bootChallenger.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); }); it('Set restriction with the multisig', async () => { - const transactions = await contractMultiSig.setTokenRestrictions( + const transactions = await nfMultiSig.setTokenRestrictions( nf3User.ethereumAddress, // simulate a token address amount1, amount2, signingKeys.user1, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), [], ); - const approved = await contractMultiSig.setTokenRestrictions( + const approved = await nfMultiSig.setTokenRestrictions( nf3User.ethereumAddress, // simulate a token address amount1, amount2, signingKeys.user2, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), transactions, ); - await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); - const restrictionDeposit = await shieldContractInstance.methods + await nfMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + const restrictionDeposit = await shieldContract.methods .getRestriction(nf3User.ethereumAddress, 0) .call(); - const restrictionWithdraw = await shieldContractInstance.methods + const restrictionWithdraw = await shieldContract.methods .getRestriction(nf3User.ethereumAddress, 1) .call(); @@ -156,26 +153,26 @@ describe(`Testing Administrator`, () => { }); it('Remove restriction with the multisig', async () => { - const transactions = await contractMultiSig.removeTokenRestrictions( + const transactions = await nfMultiSig.removeTokenRestrictions( nf3User.ethereumAddress, // simulate a token address signingKeys.user1, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), [], ); - const approved = await contractMultiSig.removeTokenRestrictions( + const approved = await nfMultiSig.removeTokenRestrictions( nf3User.ethereumAddress, // simulate a token address signingKeys.user2, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), transactions, ); - await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); - const restrictionDeposit = await shieldContractInstance.methods + await nfMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + const restrictionDeposit = await shieldContract.methods .getRestriction(nf3User.ethereumAddress, 0) .call(); - const restrictionWithdraw = await shieldContractInstance.methods + const restrictionWithdraw = await shieldContract.methods .getRestriction(nf3User.ethereumAddress, 1) .call(); @@ -184,120 +181,120 @@ describe(`Testing Administrator`, () => { }); it('Set MATIC address with the multisig', async () => { - const transactions = await contractMultiSig.setMaticAddress( + const transactions = await nfMultiSig.setMaticAddress( addresses.user1, signingKeys.user1, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), [], ); - const approved = await contractMultiSig.setMaticAddress( + const approved = await nfMultiSig.setMaticAddress( addresses.user1, signingKeys.user2, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), transactions, ); - await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); - const maticAddress = await shieldContractInstance.methods.getMaticAddress().call(); + await nfMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + const maticAddress = await shieldContract.methods.getMaticAddress().call(); expect(maticAddress.toUpperCase()).to.be.equal(addresses.user1.toUpperCase()); }); it('Pause contracts with the multisig', async () => { - const paused1 = await stateContractInstance.methods.paused().call(); - const transactions = await contractMultiSig.pauseContracts( + const paused1 = await stateContract.methods.paused().call(); + const transactions = await nfMultiSig.pauseContracts( signingKeys.user1, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), [], ); - const approved = await contractMultiSig.pauseContracts( + const approved = await nfMultiSig.pauseContracts( signingKeys.user2, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), transactions, ); - await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + await nfMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); - const paused2 = await stateContractInstance.methods.paused().call(); + const paused2 = await stateContract.methods.paused().call(); expect(paused1).to.be.equal(false); expect(paused2).to.be.equal(true); }); it('Unpause contracts with the multisig', async () => { - const paused1 = await stateContractInstance.methods.paused().call(); - const transactions = await contractMultiSig.unpauseContracts( + const paused1 = await stateContract.methods.paused().call(); + const transactions = await nfMultiSig.unpauseContracts( signingKeys.user1, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), [], ); - const approved = await contractMultiSig.unpauseContracts( + const approved = await nfMultiSig.unpauseContracts( signingKeys.user2, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), transactions, ); - await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + await nfMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); - const paused2 = await stateContractInstance.methods.paused().call(); + const paused2 = await stateContract.methods.paused().call(); expect(paused1).to.be.equal(true); expect(paused2).to.be.equal(false); }); it('Be able to transfer ownership of contracts from multisig to a specific one', async () => { - const transactions = await contractMultiSig.transferOwnership( + const transactions = await nfMultiSig.transferOwnership( signingKeys.user1, signingKeys.user1, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), [], ); - const approved = await contractMultiSig.transferOwnership( + const approved = await nfMultiSig.transferOwnership( signingKeys.user1, signingKeys.user2, addresses.user1, - await multisigContractInstance.methods.nonce().call(), + await multisigContract.methods.nonce().call(), transactions, ); - await contractMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); - const owner = await stateContractInstance.methods.owner().call(); + await nfMultiSig.multiSig.executeMultiSigTransactions(approved, signingKeys.user1); + const owner = await stateContract.methods.owner().call(); expect(owner.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); }); it('Set boot proposer without multisig', async () => { - await shieldContractInstance.methods + await shieldContract.methods .setBootProposer(nf3User.ethereumAddress) .send({ from: nf3User.ethereumAddress }); - const bootProposer = await shieldContractInstance.methods.getBootProposer().call(); + const bootProposer = await shieldContract.methods.getBootProposer().call(); expect(bootProposer.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); }); it('Set boot challenger without multisig', async () => { - await shieldContractInstance.methods + await shieldContract.methods .setBootChallenger(nf3User.ethereumAddress) .send({ from: nf3User.ethereumAddress }); - const bootChallenger = await shieldContractInstance.methods.getBootChallenger().call(); + const bootChallenger = await shieldContract.methods.getBootChallenger().call(); expect(bootChallenger.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); }); it('Set restriction without multisig', async () => { - await shieldContractInstance.methods + await shieldContract.methods .setRestriction(nf3User.ethereumAddress, amount1, amount2) .send({ from: nf3User.ethereumAddress }); - const restrictionDeposit = await shieldContractInstance.methods + const restrictionDeposit = await shieldContract.methods .getRestriction(nf3User.ethereumAddress, 0) .call(); - const restrictionWithdraw = await shieldContractInstance.methods + const restrictionWithdraw = await shieldContract.methods .getRestriction(nf3User.ethereumAddress, 1) .call(); @@ -306,13 +303,13 @@ describe(`Testing Administrator`, () => { }); it('Remove restriction without multisig', async () => { - await shieldContractInstance.methods + await shieldContract.methods .removeRestriction(nf3User.ethereumAddress) .send({ from: nf3User.ethereumAddress }); - const restrictionDeposit = await shieldContractInstance.methods + const restrictionDeposit = await shieldContract.methods .getRestriction(nf3User.ethereumAddress, 0) .call(); - const restrictionWithdraw = await shieldContractInstance.methods + const restrictionWithdraw = await shieldContract.methods .getRestriction(nf3User.ethereumAddress, 1) .call(); @@ -321,71 +318,71 @@ describe(`Testing Administrator`, () => { }); it('Set MATIC address without multisig', async () => { - await shieldContractInstance.methods + await shieldContract.methods .setMaticAddress(nf3User.ethereumAddress) .send({ from: nf3User.ethereumAddress }); - const maticAddress = await shieldContractInstance.methods.getMaticAddress().call(); + const maticAddress = await shieldContract.methods.getMaticAddress().call(); expect(maticAddress.toUpperCase()).to.be.equal(nf3User.ethereumAddress.toUpperCase()); }); it('Pause State contract without multisig', async () => { - const paused1 = await stateContractInstance.methods.paused().call(); - await stateContractInstance.methods.pause().send({ from: nf3User.ethereumAddress }); - const paused2 = await stateContractInstance.methods.paused().call(); + const paused1 = await stateContract.methods.paused().call(); + await stateContract.methods.pause().send({ from: nf3User.ethereumAddress }); + const paused2 = await stateContract.methods.paused().call(); expect(paused1).to.be.equal(false); expect(paused2).to.be.equal(true); }); it('Unpause State contract without multisig', async () => { - const paused1 = await stateContractInstance.methods.paused().call(); - await stateContractInstance.methods.unpause().send({ from: nf3User.ethereumAddress }); - const paused2 = await stateContractInstance.methods.paused().call(); + const paused1 = await stateContract.methods.paused().call(); + await stateContract.methods.unpause().send({ from: nf3User.ethereumAddress }); + const paused2 = await stateContract.methods.paused().call(); expect(paused1).to.be.equal(true); expect(paused2).to.be.equal(false); }); it('Pause Shield contract without multisig', async () => { - const paused1 = await shieldContractInstance.methods.paused().call(); - await shieldContractInstance.methods.pause().send({ from: nf3User.ethereumAddress }); - const paused2 = await shieldContractInstance.methods.paused().call(); + const paused1 = await shieldContract.methods.paused().call(); + await shieldContract.methods.pause().send({ from: nf3User.ethereumAddress }); + const paused2 = await shieldContract.methods.paused().call(); expect(paused1).to.be.equal(false); expect(paused2).to.be.equal(true); }); it('Unpause Shield contract without multisig', async () => { - const paused1 = await shieldContractInstance.methods.paused().call(); - await shieldContractInstance.methods.unpause().send({ from: nf3User.ethereumAddress }); - const paused2 = await shieldContractInstance.methods.paused().call(); + const paused1 = await shieldContract.methods.paused().call(); + await shieldContract.methods.unpause().send({ from: nf3User.ethereumAddress }); + const paused2 = await shieldContract.methods.paused().call(); expect(paused1).to.be.equal(true); expect(paused2).to.be.equal(false); }); it('Restore multisig', async () => { - const multisigAddress = multisigContractInstance.options.address; + const multisigAddress = multisigContract.options.address; await Promise.all([ - shieldContractInstance.methods + shieldContract.methods .transferOwnership(multisigAddress) .send({ from: nf3User.ethereumAddress }), - stateContractInstance.methods + stateContract.methods .transferOwnership(multisigAddress) .send({ from: nf3User.ethereumAddress }), - proposersContractInstance.methods + proposersContract.methods .transferOwnership(multisigAddress) .send({ from: nf3User.ethereumAddress }), - challengesContractInstance.methods + challengesContract.methods .transferOwnership(multisigAddress) .send({ from: nf3User.ethereumAddress }), ]); - const ownerState = await stateContractInstance.methods.owner().call(); - const ownerShield = await shieldContractInstance.methods.owner().call(); - const ownerProposers = await proposersContractInstance.methods.owner().call(); - const ownerChallenges = await challengesContractInstance.methods.owner().call(); + const ownerState = await stateContract.methods.owner().call(); + const ownerShield = await shieldContract.methods.owner().call(); + const ownerProposers = await proposersContract.methods.owner().call(); + const ownerChallenges = await challengesContract.methods.owner().call(); expect(ownerState.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); expect(ownerShield.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); expect(ownerProposers.toUpperCase()).to.be.equal(multisigAddress.toUpperCase()); From f651650fa1f5d54bc779568e73a1be3cb6c1b0f4 Mon Sep 17 00:00:00 2001 From: daveroga Date: Tue, 27 Sep 2022 16:15:25 +0200 Subject: [PATCH 19/19] fix: hardhat admin test --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 817f6de5b..7b0514bca 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "test-erc1155-tokens": "npx hardhat test --bail --no-compile --grep ERC1155", "test-erc20-cli": "npx hardhat test --no-compile --bail test/client/erc20.test.mjs ", "ping-pong": "npx hardhat test --bail --no-compile test/ping-pong/ping-pong.test.mjs", - "test-administrator": "npx hardhat test --bail --no-compile test/administrator.test.mjs ", + "test-administrator": "npx hardhat test --bail --no-compile test/multisig/administrator.test.mjs ", "test-optimist-sync": "npx hardhat test --no-compile --bail test/optimist-resync.test.mjs", "test-adversary": "CHALLENGE_TYPE=${CHALLENGE_TYPE} npx hardhat test --no-compile --bail test/adversary.test.mjs", "test-all-adversary": "for CHALLENGE_TYPE in IncorrectTreeRoot IncorrectLeafCount IncorrectTreeRoot IncorrectLeafCount; do CHALLENGE_TYPE=${CHALLENGE_TYPE} npm run test-adversary; sleep 5; done",