diff --git a/README.md b/README.md index 9a71e22..6a8143c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Proposal 42 +# Proposal 43 Unregister cheating relayer and withdraw his balance to Governance diff --git a/contracts/libraries/Base58.sol b/contracts/libraries/Base58.sol index 22f5904..776aad6 100644 --- a/contracts/libraries/Base58.sol +++ b/contracts/libraries/Base58.sol @@ -10,50 +10,12 @@ pragma solidity ^0.8.7; library Base58 { bytes constant ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; - /** - * @notice encode is used to encode the given bytes in base58 standard. - * @param data_ raw data, passed in as bytes. - * @return base58 encoded data_, returned as bytes. - */ - function encode(bytes memory data_) public pure returns (bytes memory) { - unchecked { - uint256 size = data_.length; - uint256 zeroCount; - while (zeroCount < size && data_[zeroCount] == 0) { - zeroCount++; - } - size = zeroCount + ((size - zeroCount) * 8351) / 6115 + 1; - bytes memory slot = new bytes(size); - uint32 carry; - int256 m; - int256 high = int256(size) - 1; - for (uint256 i = 0; i < data_.length; i++) { - m = int256(size - 1); - for (carry = uint8(data_[i]); m > high || carry != 0; m--) { - carry = carry + 256 * uint8(slot[uint256(m)]); - slot[uint256(m)] = bytes1(uint8(carry % 58)); - carry /= 58; - } - high = m; - } - uint256 n; - for (n = zeroCount; n < size && slot[n] == 0; n++) {} - size = slot.length - (n - zeroCount); - bytes memory out = new bytes(size); - for (uint256 i = 0; i < size; i++) { - uint256 j = i + n - zeroCount; - out[i] = ALPHABET[uint8(slot[j])]; - } - return out; - } - } - /** * @notice decode is used to decode the given string in base58 standard. * @param data_ data encoded with base58, passed in as bytes. * @return raw data, returned as bytes. */ - function decode(bytes memory data_) public pure returns (bytes memory) { + function decode(bytes memory data_) internal pure returns (bytes memory) { unchecked { uint256 zero = 49; uint256 b58sz = data_.length; @@ -102,30 +64,12 @@ library Base58 { } } - /** - * @notice encodeToString is used to encode the given byte in base58 standard. - * @param data_ raw data, passed in as bytes. - * @return base58 encoded data_, returned as a string. - */ - function encodeToString(bytes memory data_) public pure returns (string memory) { - return string(encode(data_)); - } - - /** - * @notice encodeFromString is used to encode the given string in base58 standard. - * @param data_ raw data, passed in as a string. - * @return base58 encoded data_, returned as bytes. - */ - function encodeFromString(string memory data_) public pure returns (bytes memory) { - return encode(bytes(data_)); - } - /** * @notice decode is used to decode the given string in base58 standard. * @param data_ data encoded with base58, passed in as string. * @return raw data, returned as bytes. */ - function decodeFromString(string memory data_) public pure returns (bytes memory) { + function decodeFromString(string memory data_) internal pure returns (bytes memory) { return decode(bytes(data_)); } @@ -136,7 +80,7 @@ library Base58 { * @param end_ end index. * @return slice data */ - function slice(bytes memory data_, uint256 start_, uint256 end_) public pure returns (bytes memory) { + function slice(bytes memory data_, uint256 start_, uint256 end_) private pure returns (bytes memory) { unchecked { bytes memory ret = new bytes(end_ - start_); for (uint256 i = 0; i < end_ - start_; i++) { diff --git a/hardhat.config.js b/hardhat.config.js index 4ad8ca5..b4ae26c 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -1,4 +1,5 @@ require("@nomicfoundation/hardhat-toolbox"); +require("hardhat-gas-reporter"); require("dotenv").config(); /** @type import('hardhat/config').HardhatUserConfig */ @@ -24,9 +25,9 @@ module.exports = { }, hardhat: { forking: { - url: "https://eth.llamarpc.com", + url: "https://rpc.mevblocker.io/fast", enabled: true, - blockNumber: 18820230, + blockNumber: 18836511, accounts: [process.env.REAL_PK], }, chainId: 1, @@ -41,4 +42,7 @@ module.exports = { etherscan: { apiKey: process.env.ETHERSCAN_KEY, }, + gasReporter: { + enabled: false + } }; diff --git a/package-lock.json b/package-lock.json index 7319946..b81a216 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "proposal-42", + "name": "proposal-43", "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "proposal-42", + "name": "proposal-43", "version": "1.0.0", "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index f148bfb..22cc71d 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "proposal-42", + "name": "proposal-43", "version": "1.0.0", "description": "", "main": "hardhat.config.js", diff --git a/test/Proposal.js b/test/Proposal.js index 7f4a0ab..c3f6be7 100644 --- a/test/Proposal.js +++ b/test/Proposal.js @@ -36,7 +36,7 @@ async function deployAndExecuteProposal() { const proposal = await proposalFactory.deploy(); const deployedProposalAddr = await proposal.getAddress(); - const bigStakerAddr = "0xE4143f6377AEcd7193b9731d1C28815b57C4f5Ab"; + const bigStakerAddr = "0xAd0dC9b5bf4308Cc26C1d44E1BEB2d30c43Bca1b"; await getManyEth(bigStakerAddr); const stakerSigner = await ethers.getImpersonatedSigner(bigStakerAddr); const governanceContract = await ethers.getContractAt( @@ -52,7 +52,7 @@ async function deployAndExecuteProposal() { await governanceContract.execute(proposalId); await time.increase(60 * 60 * 24 * 4); - return await getRelayerRegistry(); + return governanceContract; } describe("Proposal results check", function () {