From 294531c763a51ae8322e7e3a7ec287dad730aa99 Mon Sep 17 00:00:00 2001 From: raulk Date: Tue, 24 Sep 2024 19:00:32 +0200 Subject: [PATCH] chore: remove Python requirement for contracts development. (#1144) --- contracts/Makefile | 20 +-- contracts/hardhat.config.ts | 30 +++-- .../scripts/python/build_selector_library.py | 122 ------------------ contracts/tasks/gen-selector-library.ts | 73 +++++++++++ contracts/tasks/index.ts | 1 + contracts/tasks/lib/deployments.ts | 2 +- contracts/tasks/lib/selectors.ts | 8 +- contracts/test/helpers/SelectorLibrary.sol | 61 +-------- .../NumberContractFacetEight.sol | 0 .../NumberContractFacetSeven.sol | 0 .../test/integration/GatewayDiamond.t.sol | 11 +- .../test/integration/SubnetActorDiamond.t.sol | 11 +- fendermint/rocksdb/src/kvstore.rs | 6 +- fendermint/storage/src/im.rs | 7 +- 14 files changed, 132 insertions(+), 220 deletions(-) delete mode 100644 contracts/scripts/python/build_selector_library.py create mode 100644 contracts/tasks/gen-selector-library.ts rename contracts/test/helpers/{ => contracts}/NumberContractFacetEight.sol (100%) rename contracts/test/helpers/{ => contracts}/NumberContractFacetSeven.sol (100%) diff --git a/contracts/Makefile b/contracts/Makefile index bb76e795c..5a7d03a2a 100644 --- a/contracts/Makefile +++ b/contracts/Makefile @@ -1,13 +1,13 @@ # Targets that are commands. COMMANDS := deploy-stack gen compile-abi rust-binding slither lint fmt deps build \ test install-dev install-npm-package install-eth-abi storage clean coverage \ - prepare build-selector-library forge + prepare forge # Targets that are prerequisite commands. PREREQ_COMMANDS := pnpm # Targets that are not commands. -NON_COMMANDS := node_modules +NON_COMMANDS := node_modules test/helpers/SelectorLibrary.sol # Declare commands and prerequisite commands as phony targets. .PHONY: $(COMMANDS) $(PREREQ_COMMANDS) @@ -77,17 +77,9 @@ build: node_modules | forge forge build FOUNDRY_SRC=sdk forge build -test: node_modules | forge +test: node_modules test/helpers/SelectorLibrary.sol | forge forge test -vvv --ffi -install-dev: install-npm-package install-eth-abi - -install-npm-package: node_modules - pnpm install --save-dev - -install-eth-abi: - curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py && rm get-pip.py && python3 -m pip install eth_abi - storage: rm -rf ./cache rm -rf ./cache_hardhat @@ -108,10 +100,10 @@ coverage: node_modules | forge fi ./tools/check_coverage.sh -prepare: build-selector-library fmt lint test slither +prepare: test/helpers/SelectorLibrary.sol fmt lint test slither -build-selector-library: | forge - python3 scripts/python/build_selector_library.py +test/helpers/SelectorLibrary.sol: | forge + pnpm exec hardhat gen-selector-library pnpm exec prettier -w test/helpers/SelectorLibrary.sol # Forge is used by the ipc-solidity-actors compilation steps. diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index 1de63b39a..3f3650f04 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -14,6 +14,7 @@ import './extensions' // Load environment variables from .env file. import { config as dotenvConfig } from 'dotenv' + dotenvConfig({ path: './.env' }) // Import our tasks. @@ -29,17 +30,7 @@ const networkDefinition = (chainId: number, url: string) => ({ saveDeployments: true, }) -const config: HardhatUserConfig = { - defaultNetwork: 'calibrationnet', - networks: { - // Static networks. - mainnet: networkDefinition(314, 'https://api.node.glif.io/rpc/v1'), - calibrationnet: networkDefinition(314159, 'https://api.calibration.node.glif.io/rpc/v1'), - localnet: networkDefinition(31415926, 'http://localhost:8545'), - // Auto uses RPC_URL provided by the user, and an optional CHAIN_ID. - // If provided, Hardhat will assert that the chain ID matches the one returned by the RPC. - auto: networkDefinition(parseInt(process.env.CHAIN_ID, 10), process.env.RPC_URL!), - }, +let config: HardhatUserConfig = { solidity: { compilers: [ { @@ -67,4 +58,21 @@ const config: HardhatUserConfig = { }, } +// Only add the network configurations if we have a private key. +// Some targets don't require networks, e.g. gen-selector-library. +if (process.env.PRIVATE_KEY) { + config = Object.assign(config, { + defaultNetwork: 'calibrationnet', + networks: { + // Static networks. + mainnet: networkDefinition(314, 'https://api.node.glif.io/rpc/v1'), + calibrationnet: networkDefinition(314159, 'https://api.calibration.node.glif.io/rpc/v1'), + localnet: networkDefinition(31415926, 'http://localhost:8545'), + // Auto uses RPC_URL provided by the user, and an optional CHAIN_ID. + // If provided, Hardhat will assert that the chain ID matches the one returned by the RPC. + auto: networkDefinition(parseInt(process.env.CHAIN_ID, 10), process.env.RPC_URL!), + }, + }) +} + export default config diff --git a/contracts/scripts/python/build_selector_library.py b/contracts/scripts/python/build_selector_library.py deleted file mode 100644 index ec839d80d..000000000 --- a/contracts/scripts/python/build_selector_library.py +++ /dev/null @@ -1,122 +0,0 @@ -import argparse -import glob -import json -import os -import subprocess -import sys -from eth_abi import encode -from json.decoder import JSONDecodeError - -def writeToFile(selector_storage_content): - # Define the file path - file_path = 'test/helpers/SelectorLibrary.sol' - - # Write the content to the file - with open(file_path, 'w') as file: - file.write(selector_storage_content) - - -def generate_solidity_function(contract_selectors): - solidity_code = "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity ^0.8.19;\n" - solidity_code += "library SelectorLibrary {\n" - solidity_code += " function resolveSelectors(string memory facetName) public pure returns (bytes4[] memory facetSelectors) {\n" - - for contract_name, selectors in contract_selectors.items(): - solidity_code += f' if (keccak256(abi.encodePacked(facetName)) == keccak256(abi.encodePacked("{contract_name}"))) {{\n' - solidity_code += f' return abi.decode(hex"{selectors}", (bytes4[]));\n' - solidity_code += " }\n" - - solidity_code += " revert(\"Selector not found\");\n" - solidity_code += " }\n" - solidity_code += "}\n" - return solidity_code - -def format_selector(selector_bytes): - hex_str = selector_bytes.hex() - if len(hex_str) % 2 != 0: - hex_str = '0' + hex_str # Add a leading zero if the length is odd - return hex_str - -def parse_selectors(encoded_selectors): - # Assuming the encoded selectors are in the format provided in your example - decoded = bytes.fromhex(encoded_selectors[2:]) # Skip the "0x" prefix - return [format_selector(decoded[i:i+4]) for i in range(0, len(decoded), 4)] # Return in chunks of 4 bytes - -def get_selectors(contract): - """This function gets the selectors of the functions of the target contract.""" - - res = subprocess.run( - ["forge", "inspect", contract, "methodIdentifiers"], capture_output=True) - res = res.stdout.decode() - try: - res = json.loads(res) - except JSONDecodeError as e: - print("failed to load JSON:", e) - print("forge output:", res) - print("contract:", contract) - sys.exit(1) - - selectors = [] - for signature in res: - selector = res[signature] - selectors.append(bytes.fromhex(selector)) - - enc = encode(["bytes4[]"], [selectors]) - return "" + enc.hex() - -def main(): - contract_selectors = {} - filepaths_to_target = [ - 'contracts/GatewayDiamond.sol', - 'contracts/SubnetActorDiamond.sol', - 'contracts/SubnetRegistryDiamond.sol', - 'contracts/OwnershipFacet.sol', - 'contracts/diamond/DiamondCutFacet.sol', - 'contracts/diamond/DiamondLoupeFacet.sol', - 'contracts/gateway/GatewayGetterFacet.sol', - 'contracts/gateway/GatewayManagerFacet.sol', - 'contracts/gateway/GatewayMessengerFacet.sol', - 'contracts/gateway/router/CheckpointingFacet.sol', - 'contracts/gateway/router/TopDownFinalityFacet.sol', - 'contracts/gateway/router/XnetMessagingFacet.sol', - 'contracts/subnet/SubnetActorGetterFacet.sol', - 'contracts/subnet/SubnetActorManagerFacet.sol', - 'contracts/subnet/SubnetActorPauseFacet.sol', - 'contracts/subnet/SubnetActorRewardFacet.sol', - 'contracts/subnet/SubnetActorCheckpointingFacet.sol', - 'contracts/subnetregistry/RegisterSubnetFacet.sol', - 'contracts/subnetregistry/SubnetGetterFacet.sol', - 'test/helpers/ERC20PresetFixedSupply.sol', - 'test/helpers/NumberContractFacetEight.sol', - 'test/helpers/NumberContractFacetSeven.sol', - 'test/helpers/SelectorLibrary.sol', - 'test/helpers/TestUtils.sol', - 'test/mocks/SubnetActorMock.sol', - ] - - for filepath in filepaths_to_target: - - # Extract just the contract name (without path and .sol extension) - contract_name = os.path.splitext(os.path.basename(filepath))[0] - - #skip lib or interfaces - if contract_name.startswith("Lib") or contract_name.startswith("I") or contract_name.endswith("Helper"): - continue - - # Format full path - # Call get_selectors for each contract - try: - selectors = get_selectors(filepath + ':' + contract_name) - if selectors: - contract_selectors[contract_name] = selectors - except Exception as oops: - print(f"Error processing {filepath}: {oops}") - - - # Print the final JSON - solidity_library_code = generate_solidity_function(contract_selectors) - writeToFile(solidity_library_code) - -if __name__ == "__main__": - main() - diff --git a/contracts/tasks/gen-selector-library.ts b/contracts/tasks/gen-selector-library.ts new file mode 100644 index 000000000..31a4e045b --- /dev/null +++ b/contracts/tasks/gen-selector-library.ts @@ -0,0 +1,73 @@ +import { task } from 'hardhat/config' +import '@nomiclabs/hardhat-ethers' +import * as fs from 'fs' +import { HardhatRuntimeEnvironment } from 'hardhat/types' +import { selectors } from './lib' + +task('gen-selector-library', 'Generates a Solidity library with contract selectors for tests').setAction( + async (_args, hre: HardhatRuntimeEnvironment) => { + await hre.run('compile') + + // ridiculously, this appears to be the only way to get hardhat to compile a specific subtree + // we are only updating the in-memory representation of the config, so it won't write this value out to disk + // be careful if you compose this task with other tasks in larger scripts! + hre.config.paths.sources = './test/mocks' + await hre.run('compile') + + const contracts: string[] = [ + 'OwnershipFacet', + 'DiamondCutFacet', + 'DiamondLoupeFacet', + 'GatewayGetterFacet', + 'GatewayManagerFacet', + 'GatewayMessengerFacet', + 'CheckpointingFacet', + 'TopDownFinalityFacet', + 'XnetMessagingFacet', + 'SubnetActorGetterFacet', + 'SubnetActorManagerFacet', + 'SubnetActorPauseFacet', + 'SubnetActorRewardFacet', + 'SubnetActorCheckpointingFacet', + 'RegisterSubnetFacet', + 'SubnetGetterFacet', + 'SubnetActorMock', + ] + + const resolveSelectors = async (contractName: string) => { + console.log(`Resolving selectors for ${contractName}...`) + const artifact = await hre.artifacts.readArtifact(contractName) + const iface = new hre.ethers.utils.Interface(artifact.abi) + const encodedSelectors = hre.ethers.utils.defaultAbiCoder + .encode(['bytes4[]'], [selectors({ interface: iface })]) + .slice(2) + return [contractName, encodedSelectors] + } + + const allSelectors = Object.fromEntries(await Promise.all(contracts.map(resolveSelectors))) + + // Codegen. + let code = `// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.19; + +library SelectorLibrary { + function resolveSelectors(string memory facetName) public pure returns (bytes4[] memory facetSelectors) {` + + for (const [contractName, selector] of Object.entries(allSelectors)) { + code += ` + if (keccak256(abi.encodePacked(facetName)) == keccak256(abi.encodePacked("${contractName}"))) { + return abi.decode(hex"${selector}", (bytes4[])); + }` + } + + code += ` + revert(string.concat("Selectors not found for facet: ", facetName)); + } +} +` + // Write the generated code to a file. + const outputPath = 'test/helpers/SelectorLibrary.sol' + fs.writeFileSync(outputPath, code) + console.log(`Selector library written to ${outputPath}`) + }, +) diff --git a/contracts/tasks/index.ts b/contracts/tasks/index.ts index 4e88a17eb..901e611bc 100644 --- a/contracts/tasks/index.ts +++ b/contracts/tasks/index.ts @@ -5,3 +5,4 @@ import './deploy-registry' import './deploy' import './upgrade' import './validator-gater' +import './gen-selector-library' diff --git a/contracts/tasks/lib/deployments.ts b/contracts/tasks/lib/deployments.ts index dc15c970f..4fbcb15b4 100644 --- a/contracts/tasks/lib/deployments.ts +++ b/contracts/tasks/lib/deployments.ts @@ -105,7 +105,7 @@ export class Deployments { (contract: Contract) => contract.address, ) } - + get contracts(): { [key: string]: Contract } { return this._contracts } diff --git a/contracts/tasks/lib/selectors.ts b/contracts/tasks/lib/selectors.ts index 78a4f8a45..d81e040a8 100644 --- a/contracts/tasks/lib/selectors.ts +++ b/contracts/tasks/lib/selectors.ts @@ -1,6 +1,10 @@ -import {Contract} from "ethers"; +import {Interface} from "ethers/lib/utils"; -export function selectors(contract: Contract) { +interface ContractLike { + interface: Interface; +} + +export function selectors(contract: ContractLike) { return Object.keys(contract.interface.functions) .filter((sig) => sig !== 'init(bytes)') .map((sig) => contract.interface.getSighash(sig)) diff --git a/contracts/test/helpers/SelectorLibrary.sol b/contracts/test/helpers/SelectorLibrary.sol index 9798f01c1..4259f877c 100644 --- a/contracts/test/helpers/SelectorLibrary.sol +++ b/contracts/test/helpers/SelectorLibrary.sol @@ -1,28 +1,8 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.19; + library SelectorLibrary { function resolveSelectors(string memory facetName) public pure returns (bytes4[] memory facetSelectors) { - if (keccak256(abi.encodePacked(facetName)) == keccak256(abi.encodePacked("GatewayDiamond"))) { - return - abi.decode( - hex"00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - (bytes4[]) - ); - } - if (keccak256(abi.encodePacked(facetName)) == keccak256(abi.encodePacked("SubnetActorDiamond"))) { - return - abi.decode( - hex"00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - (bytes4[]) - ); - } - if (keccak256(abi.encodePacked(facetName)) == keccak256(abi.encodePacked("SubnetRegistryDiamond"))) { - return - abi.decode( - hex"00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - (bytes4[]) - ); - } if (keccak256(abi.encodePacked(facetName)) == keccak256(abi.encodePacked("OwnershipFacet"))) { return abi.decode( @@ -135,48 +115,13 @@ library SelectorLibrary { (bytes4[]) ); } - if (keccak256(abi.encodePacked(facetName)) == keccak256(abi.encodePacked("ERC20PresetFixedSupply"))) { - return - abi.decode( - hex"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000bdd62ed3e00000000000000000000000000000000000000000000000000000000095ea7b30000000000000000000000000000000000000000000000000000000070a082310000000000000000000000000000000000000000000000000000000042966c680000000000000000000000000000000000000000000000000000000079cc679000000000000000000000000000000000000000000000000000000000313ce5670000000000000000000000000000000000000000000000000000000006fdde030000000000000000000000000000000000000000000000000000000095d89b410000000000000000000000000000000000000000000000000000000018160ddd00000000000000000000000000000000000000000000000000000000a9059cbb0000000000000000000000000000000000000000000000000000000023b872dd00000000000000000000000000000000000000000000000000000000", - (bytes4[]) - ); - } - if (keccak256(abi.encodePacked(facetName)) == keccak256(abi.encodePacked("NumberContractFacetEight"))) { - return - abi.decode( - hex"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000167e0badb00000000000000000000000000000000000000000000000000000000", - (bytes4[]) - ); - } - if (keccak256(abi.encodePacked(facetName)) == keccak256(abi.encodePacked("NumberContractFacetSeven"))) { - return - abi.decode( - hex"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000167e0badb00000000000000000000000000000000000000000000000000000000", - (bytes4[]) - ); - } - if (keccak256(abi.encodePacked(facetName)) == keccak256(abi.encodePacked("SelectorLibrary"))) { - return - abi.decode( - hex"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000166e2898c00000000000000000000000000000000000000000000000000000000", - (bytes4[]) - ); - } - if (keccak256(abi.encodePacked(facetName)) == keccak256(abi.encodePacked("TestUtils"))) { - return - abi.decode( - hex"00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000008997da8d4000000000000000000000000000000000000000000000000000000005727dc5c0000000000000000000000000000000000000000000000000000000003a507be000000000000000000000000000000000000000000000000000000007a308a4c00000000000000000000000000000000000000000000000000000000eeeac01e00000000000000000000000000000000000000000000000000000000bc9e2bcf00000000000000000000000000000000000000000000000000000000f6caf0ac00000000000000000000000000000000000000000000000000000000573081a200000000000000000000000000000000000000000000000000000000", - (bytes4[]) - ); - } if (keccak256(abi.encodePacked(facetName)) == keccak256(abi.encodePacked("SubnetActorMock"))) { return abi.decode( - hex"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001210fd4261000000000000000000000000000000000000000000000000000000004e71d92d00000000000000000000000000000000000000000000000000000000350a14bf00000000000000000000000000000000000000000000000000000000c7ebdaef000000000000000000000000000000000000000000000000000000006170b1620000000000000000000000000000000000000000000000000000000041c0e1b500000000000000000000000000000000000000000000000000000000d66d9e19000000000000000000000000000000000000000000000000000000008456cb59000000000000000000000000000000000000000000000000000000005c975abb000000000000000000000000000000000000000000000000000000000b7fbe600000000000000000000000000000000000000000000000000000000066783c9b00000000000000000000000000000000000000000000000000000000da5d09ee00000000000000000000000000000000000000000000000000000000dcda8973000000000000000000000000000000000000000000000000000000003a4b66f10000000000000000000000000000000000000000000000000000000079979f57000000000000000000000000000000000000000000000000000000003f4ba83a000000000000000000000000000000000000000000000000000000002e17de7800000000000000000000000000000000000000000000000000000000cc2dc2b900000000000000000000000000000000000000000000000000000000", + hex"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001210fd4261000000000000000000000000000000000000000000000000000000004e71d92d00000000000000000000000000000000000000000000000000000000350a14bf00000000000000000000000000000000000000000000000000000000c7ebdaef000000000000000000000000000000000000000000000000000000003ae247130000000000000000000000000000000000000000000000000000000041c0e1b500000000000000000000000000000000000000000000000000000000d66d9e19000000000000000000000000000000000000000000000000000000008456cb59000000000000000000000000000000000000000000000000000000005c975abb000000000000000000000000000000000000000000000000000000004d9013a10000000000000000000000000000000000000000000000000000000066783c9b00000000000000000000000000000000000000000000000000000000da5d09ee00000000000000000000000000000000000000000000000000000000dcda897300000000000000000000000000000000000000000000000000000000a694fc3a0000000000000000000000000000000000000000000000000000000079979f57000000000000000000000000000000000000000000000000000000003f4ba83a000000000000000000000000000000000000000000000000000000002e17de7800000000000000000000000000000000000000000000000000000000cc2dc2b900000000000000000000000000000000000000000000000000000000", (bytes4[]) ); } - revert("Selector not found"); + revert(string.concat("Selectors not found for facet: ", facetName)); } } diff --git a/contracts/test/helpers/NumberContractFacetEight.sol b/contracts/test/helpers/contracts/NumberContractFacetEight.sol similarity index 100% rename from contracts/test/helpers/NumberContractFacetEight.sol rename to contracts/test/helpers/contracts/NumberContractFacetEight.sol diff --git a/contracts/test/helpers/NumberContractFacetSeven.sol b/contracts/test/helpers/contracts/NumberContractFacetSeven.sol similarity index 100% rename from contracts/test/helpers/NumberContractFacetSeven.sol rename to contracts/test/helpers/contracts/NumberContractFacetSeven.sol diff --git a/contracts/test/integration/GatewayDiamond.t.sol b/contracts/test/integration/GatewayDiamond.t.sol index 55139d1e3..928e5549f 100644 --- a/contracts/test/integration/GatewayDiamond.t.sol +++ b/contracts/test/integration/GatewayDiamond.t.sol @@ -4,8 +4,8 @@ pragma solidity ^0.8.23; import "forge-std/Test.sol"; import "../../contracts/errors/IPCErrors.sol"; -import {NumberContractFacetSeven} from "../helpers/NumberContractFacetSeven.sol"; -import {NumberContractFacetEight} from "../helpers/NumberContractFacetEight.sol"; +import {NumberContractFacetSeven} from "../helpers/contracts/NumberContractFacetSeven.sol"; +import {NumberContractFacetEight} from "../helpers/contracts/NumberContractFacetEight.sol"; import {EMPTY_BYTES, METHOD_SEND} from "../../contracts/constants/Constants.sol"; import {IERC165} from "../../contracts/interfaces/IERC165.sol"; import {IDiamond} from "../../contracts/interfaces/IDiamond.sol"; @@ -127,7 +127,9 @@ contract GatewayActorDiamondTest is Test, IntegrationTestBase { DiamondCutFacet gwDiamondCutter = DiamondCutFacet(address(gatewayDiamond)); IDiamond.FacetCut[] memory gwDiamondCut = new IDiamond.FacetCut[](1); - bytes4[] memory ncGetterSelectors = SelectorLibrary.resolveSelectors("NumberContractFacetSeven"); + + bytes4[] memory ncGetterSelectors = new bytes4[](1); + ncGetterSelectors[0] = NumberContractFacetSeven.getNum.selector; gwDiamondCut[0] = ( IDiamond.FacetCut({ @@ -146,7 +148,8 @@ contract GatewayActorDiamondTest is Test, IntegrationTestBase { NumberContractFacetSeven gwNumberContract = NumberContractFacetSeven(address(gatewayDiamond)); assert(gwNumberContract.getNum() == 7); - ncGetterSelectors = SelectorLibrary.resolveSelectors("NumberContractFacetEight"); + ncGetterSelectors = new bytes4[](1); + ncGetterSelectors[0] = NumberContractFacetEight.getNum.selector; gwDiamondCut[0] = ( IDiamond.FacetCut({ diff --git a/contracts/test/integration/SubnetActorDiamond.t.sol b/contracts/test/integration/SubnetActorDiamond.t.sol index aacd3f9a2..ff2bcdf45 100644 --- a/contracts/test/integration/SubnetActorDiamond.t.sol +++ b/contracts/test/integration/SubnetActorDiamond.t.sol @@ -6,8 +6,8 @@ import {Test} from "forge-std/Test.sol"; import "forge-std/console.sol"; import {TestUtils} from "../helpers/TestUtils.sol"; import {SelectorLibrary} from "../helpers/SelectorLibrary.sol"; -import {NumberContractFacetSeven} from "../helpers/NumberContractFacetSeven.sol"; -import {NumberContractFacetEight} from "../helpers/NumberContractFacetEight.sol"; +import {NumberContractFacetSeven} from "../helpers/contracts/NumberContractFacetSeven.sol"; +import {NumberContractFacetEight} from "../helpers/contracts/NumberContractFacetEight.sol"; import {METHOD_SEND} from "../../contracts/constants/Constants.sol"; import {ConsensusType} from "../../contracts/enums/ConsensusType.sol"; import {BottomUpMsgBatch, IpcEnvelope, BottomUpCheckpoint, MAX_MSGS_PER_BATCH} from "../../contracts/structs/CrossNet.sol"; @@ -1097,7 +1097,9 @@ contract SubnetActorDiamondTest is Test, IntegrationTestBase { DiamondCutFacet saDiamondCutter = DiamondCutFacet(address(saDiamond)); IDiamond.FacetCut[] memory saDiamondCut = new IDiamond.FacetCut[](1); - bytes4[] memory ncGetterSelectors = SelectorLibrary.resolveSelectors("NumberContractFacetSeven"); + + bytes4[] memory ncGetterSelectors = new bytes4[](1); + ncGetterSelectors[0] = NumberContractFacetSeven.getNum.selector; saDiamondCut[0] = ( IDiamond.FacetCut({ @@ -1116,7 +1118,8 @@ contract SubnetActorDiamondTest is Test, IntegrationTestBase { NumberContractFacetSeven saNumberContract = NumberContractFacetSeven(address(saDiamond)); assert(saNumberContract.getNum() == 7); - ncGetterSelectors = SelectorLibrary.resolveSelectors("NumberContractFacetEight"); + ncGetterSelectors = new bytes4[](1); + ncGetterSelectors[0] = NumberContractFacetEight.getNum.selector; saDiamondCut[0] = ( IDiamond.FacetCut({ facetAddress: address(ncFacetB), diff --git a/fendermint/rocksdb/src/kvstore.rs b/fendermint/rocksdb/src/kvstore.rs index 945065fa4..254d51f4c 100644 --- a/fendermint/rocksdb/src/kvstore.rs +++ b/fendermint/rocksdb/src/kvstore.rs @@ -85,7 +85,8 @@ where S: KVStore>, S::Namespace: AsRef, { - type Tx<'a> = RocksDbReadTx<'a> + type Tx<'a> + = RocksDbReadTx<'a> where Self: 'a; @@ -103,7 +104,8 @@ where S: KVStore>, S::Namespace: AsRef, { - type Tx<'a> = RocksDbWriteTx<'a> + type Tx<'a> + = RocksDbWriteTx<'a> where Self: 'a; diff --git a/fendermint/storage/src/im.rs b/fendermint/storage/src/im.rs index 8719914af..94da2d785 100644 --- a/fendermint/storage/src/im.rs +++ b/fendermint/storage/src/im.rs @@ -67,7 +67,10 @@ impl KVReadable for InMemoryBackend where S::Repr: Hash + Eq, { - type Tx<'a> = Transaction<'a, S, Read> where Self: 'a; + type Tx<'a> + = Transaction<'a, S, Read> + where + Self: 'a; /// Take a fresh snapshot, to isolate the effects of any further writes /// to the datastore from this read transaction. @@ -86,7 +89,7 @@ where S::Repr: Hash + Eq, { type Tx<'a> - = Transaction<'a, S, Write> + = Transaction<'a, S, Write> where Self: 'a;