diff --git a/.github/workflows/mainnet_fork_tests.yml b/.github/workflows/mainnet_fork_tests.yml new file mode 100644 index 000000000..351ccdfba --- /dev/null +++ b/.github/workflows/mainnet_fork_tests.yml @@ -0,0 +1,56 @@ +name: Mainnet Fork Tests + +on: + pull_request: + types: + - opened + - synchronize + - reopened + - edited + - closed + branches: + - main + - develop + paths: + - "src/**" + +permissions: + contents: read + security-events: write + +jobs: + tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: "3.12" + + - name: Setup poetry + run: > + curl -sSL https://install.python-poetry.org | python - && + echo "$POETRY_HOME/bin" >> "$GITHUB_PATH" + env: + POETRY_HOME: "/opt/poetry" + POETRY_VERSION: 1.3.2 + + - name: Install Python dependencies + run: | + poetry install --no-interaction --with=dev + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + + - name: Mainnet Fork Tests + run: poetry run pytest -m 'fork' -n auto tests + env: + EXECUTION_CLIENT_URI: ${{ secrets.EXECUTION_CLIENT_URI }} + CONSENSUS_CLIENT_URI: ${{ secrets.CONSENSUS_CLIENT_URI }} + KEYS_API_URI: ${{ secrets.KEYS_API_URI }} + LIDO_LOCATOR_ADDRESS: "0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Eb" + CSM_MODULE_ADDRESS: "0xdA7dE2ECdDfccC6c3AF10108Db212ACBBf9EA83F" + diff --git a/assets/HashConsensus.json b/assets/HashConsensus.json index d286ffdf6..a727f71ea 100644 --- a/assets/HashConsensus.json +++ b/assets/HashConsensus.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"uint256","name":"slotsPerEpoch","type":"uint256"},{"internalType":"uint256","name":"secondsPerSlot","type":"uint256"},{"internalType":"uint256","name":"genesisTime","type":"uint256"},{"internalType":"uint256","name":"epochsPerFrame","type":"uint256"},{"internalType":"uint256","name":"fastLaneLengthSlots","type":"uint256"},{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"reportProcessor","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AddressCannotBeZero","type":"error"},{"inputs":[],"name":"AdminCannotBeZero","type":"error"},{"inputs":[],"name":"ConsensusReportAlreadyProcessing","type":"error"},{"inputs":[],"name":"DuplicateMember","type":"error"},{"inputs":[],"name":"DuplicateReport","type":"error"},{"inputs":[],"name":"EmptyReport","type":"error"},{"inputs":[],"name":"EpochsPerFrameCannotBeZero","type":"error"},{"inputs":[],"name":"FastLanePeriodCannotBeLongerThanFrame","type":"error"},{"inputs":[],"name":"InitialEpochAlreadyArrived","type":"error"},{"inputs":[],"name":"InitialEpochIsYetToArrive","type":"error"},{"inputs":[],"name":"InitialEpochRefSlotCannotBeEarlierThanProcessingSlot","type":"error"},{"inputs":[],"name":"InvalidSlot","type":"error"},{"inputs":[],"name":"NewProcessorCannotBeTheSame","type":"error"},{"inputs":[],"name":"NonFastLaneMemberCannotReportWithinFastLaneInterval","type":"error"},{"inputs":[],"name":"NonMember","type":"error"},{"inputs":[],"name":"NumericOverflow","type":"error"},{"inputs":[{"internalType":"uint256","name":"minQuorum","type":"uint256"},{"internalType":"uint256","name":"receivedQuorum","type":"uint256"}],"name":"QuorumTooSmall","type":"error"},{"inputs":[],"name":"ReportProcessorCannotBeZero","type":"error"},{"inputs":[],"name":"StaleReport","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"received","type":"uint256"}],"name":"UnexpectedConsensusVersion","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"refSlot","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"report","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"support","type":"uint256"}],"name":"ConsensusReached","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fastLaneLengthSlots","type":"uint256"}],"name":"FastLaneConfigSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newInitialEpoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newEpochsPerFrame","type":"uint256"}],"name":"FrameConfigSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"newTotalMembers","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newQuorum","type":"uint256"}],"name":"MemberAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"newTotalMembers","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newQuorum","type":"uint256"}],"name":"MemberRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newQuorum","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalMembers","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"prevQuorum","type":"uint256"}],"name":"QuorumSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"processor","type":"address"},{"indexed":true,"internalType":"address","name":"prevProcessor","type":"address"}],"name":"ReportProcessorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"refSlot","type":"uint256"},{"indexed":true,"internalType":"address","name":"member","type":"address"},{"indexed":false,"internalType":"bytes32","name":"report","type":"bytes32"}],"name":"ReportReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DISABLE_CONSENSUS_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGE_FAST_LANE_CONFIG_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGE_FRAME_CONFIG_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGE_MEMBERS_AND_QUORUM_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGE_REPORT_PROCESSOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"quorum","type":"uint256"}],"name":"addMember","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disableConsensus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getChainConfig","outputs":[{"internalType":"uint256","name":"slotsPerEpoch","type":"uint256"},{"internalType":"uint256","name":"secondsPerSlot","type":"uint256"},{"internalType":"uint256","name":"genesisTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getConsensusState","outputs":[{"internalType":"uint256","name":"refSlot","type":"uint256"},{"internalType":"bytes32","name":"consensusReport","type":"bytes32"},{"internalType":"bool","name":"isReportProcessing","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getConsensusStateForMember","outputs":[{"components":[{"internalType":"uint256","name":"currentFrameRefSlot","type":"uint256"},{"internalType":"bytes32","name":"currentFrameConsensusReport","type":"bytes32"},{"internalType":"bool","name":"isMember","type":"bool"},{"internalType":"bool","name":"isFastLane","type":"bool"},{"internalType":"bool","name":"canReport","type":"bool"},{"internalType":"uint256","name":"lastMemberReportRefSlot","type":"uint256"},{"internalType":"bytes32","name":"currentFrameMemberReport","type":"bytes32"}],"internalType":"struct HashConsensus.MemberConsensusState","name":"result","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentFrame","outputs":[{"internalType":"uint256","name":"refSlot","type":"uint256"},{"internalType":"uint256","name":"reportProcessingDeadlineSlot","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFastLaneMembers","outputs":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"lastReportedRefSlots","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFrameConfig","outputs":[{"internalType":"uint256","name":"initialEpoch","type":"uint256"},{"internalType":"uint256","name":"epochsPerFrame","type":"uint256"},{"internalType":"uint256","name":"fastLaneLengthSlots","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInitialRefSlot","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getIsFastLaneMember","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getIsMember","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMembers","outputs":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"lastReportedRefSlots","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getQuorum","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReportVariants","outputs":[{"internalType":"bytes32[]","name":"variants","type":"bytes32[]"},{"internalType":"uint256[]","name":"support","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"quorum","type":"uint256"}],"name":"removeMember","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fastLaneLengthSlots","type":"uint256"}],"name":"setFastLaneLengthSlots","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"epochsPerFrame","type":"uint256"},{"internalType":"uint256","name":"fastLaneLengthSlots","type":"uint256"}],"name":"setFrameConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"quorum","type":"uint256"}],"name":"setQuorum","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newProcessor","type":"address"}],"name":"setReportProcessor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"slot","type":"uint256"},{"internalType":"bytes32","name":"report","type":"bytes32"},{"internalType":"uint256","name":"consensusVersion","type":"uint256"}],"name":"submitReport","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"initialEpoch","type":"uint256"}],"name":"updateInitialEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"slotsPerEpoch","type":"uint256","internalType":"uint256"},{"name":"secondsPerSlot","type":"uint256","internalType":"uint256"},{"name":"genesisTime","type":"uint256","internalType":"uint256"},{"name":"epochsPerFrame","type":"uint256","internalType":"uint256"},{"name":"fastLaneLengthSlots","type":"uint256","internalType":"uint256"},{"name":"admin","type":"address","internalType":"address"},{"name":"reportProcessor","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"DEFAULT_ADMIN_ROLE","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"DISABLE_CONSENSUS_ROLE","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"MANAGE_FAST_LANE_CONFIG_ROLE","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"MANAGE_FRAME_CONFIG_ROLE","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"MANAGE_MEMBERS_AND_QUORUM_ROLE","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"MANAGE_REPORT_PROCESSOR_ROLE","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"addMember","inputs":[{"name":"addr","type":"address","internalType":"address"},{"name":"quorum","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"disableConsensus","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"getChainConfig","inputs":[],"outputs":[{"name":"slotsPerEpoch","type":"uint256","internalType":"uint256"},{"name":"secondsPerSlot","type":"uint256","internalType":"uint256"},{"name":"genesisTime","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"getConsensusState","inputs":[],"outputs":[{"name":"refSlot","type":"uint256","internalType":"uint256"},{"name":"consensusReport","type":"bytes32","internalType":"bytes32"},{"name":"isReportProcessing","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"getConsensusStateForMember","inputs":[{"name":"addr","type":"address","internalType":"address"}],"outputs":[{"name":"result","type":"tuple","internalType":"struct HashConsensus.MemberConsensusState","components":[{"name":"currentFrameRefSlot","type":"uint256","internalType":"uint256"},{"name":"currentFrameConsensusReport","type":"bytes32","internalType":"bytes32"},{"name":"isMember","type":"bool","internalType":"bool"},{"name":"isFastLane","type":"bool","internalType":"bool"},{"name":"canReport","type":"bool","internalType":"bool"},{"name":"lastMemberReportRefSlot","type":"uint256","internalType":"uint256"},{"name":"currentFrameMemberReport","type":"bytes32","internalType":"bytes32"}]}],"stateMutability":"view"},{"type":"function","name":"getCurrentFrame","inputs":[],"outputs":[{"name":"refSlot","type":"uint256","internalType":"uint256"},{"name":"reportProcessingDeadlineSlot","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"getFastLaneMembers","inputs":[],"outputs":[{"name":"addresses","type":"address[]","internalType":"address[]"},{"name":"lastReportedRefSlots","type":"uint256[]","internalType":"uint256[]"}],"stateMutability":"view"},{"type":"function","name":"getFrameConfig","inputs":[],"outputs":[{"name":"initialEpoch","type":"uint256","internalType":"uint256"},{"name":"epochsPerFrame","type":"uint256","internalType":"uint256"},{"name":"fastLaneLengthSlots","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"getInitialRefSlot","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"getIsFastLaneMember","inputs":[{"name":"addr","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"getIsMember","inputs":[{"name":"addr","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"getMembers","inputs":[],"outputs":[{"name":"addresses","type":"address[]","internalType":"address[]"},{"name":"lastReportedRefSlots","type":"uint256[]","internalType":"uint256[]"}],"stateMutability":"view"},{"type":"function","name":"getQuorum","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"getReportProcessor","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getReportVariants","inputs":[],"outputs":[{"name":"variants","type":"bytes32[]","internalType":"bytes32[]"},{"name":"support","type":"uint256[]","internalType":"uint256[]"}],"stateMutability":"view"},{"type":"function","name":"getRoleAdmin","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"getRoleMember","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"index","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getRoleMemberCount","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"grantRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"hasRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"removeMember","inputs":[{"name":"addr","type":"address","internalType":"address"},{"name":"quorum","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"renounceRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"callerConfirmation","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"revokeRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setFastLaneLengthSlots","inputs":[{"name":"fastLaneLengthSlots","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setFrameConfig","inputs":[{"name":"epochsPerFrame","type":"uint256","internalType":"uint256"},{"name":"fastLaneLengthSlots","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setQuorum","inputs":[{"name":"quorum","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setReportProcessor","inputs":[{"name":"newProcessor","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"submitReport","inputs":[{"name":"slot","type":"uint256","internalType":"uint256"},{"name":"report","type":"bytes32","internalType":"bytes32"},{"name":"consensusVersion","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"supportsInterface","inputs":[{"name":"interfaceId","type":"bytes4","internalType":"bytes4"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"updateInitialEpoch","inputs":[{"name":"initialEpoch","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"event","name":"ConsensusLost","inputs":[{"name":"refSlot","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"ConsensusReached","inputs":[{"name":"refSlot","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"report","type":"bytes32","indexed":false,"internalType":"bytes32"},{"name":"support","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"FastLaneConfigSet","inputs":[{"name":"fastLaneLengthSlots","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"FrameConfigSet","inputs":[{"name":"newInitialEpoch","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"newEpochsPerFrame","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"name":"version","type":"uint64","indexed":false,"internalType":"uint64"}],"anonymous":false},{"type":"event","name":"MemberAdded","inputs":[{"name":"addr","type":"address","indexed":true,"internalType":"address"},{"name":"newTotalMembers","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"newQuorum","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"MemberRemoved","inputs":[{"name":"addr","type":"address","indexed":true,"internalType":"address"},{"name":"newTotalMembers","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"newQuorum","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"QuorumSet","inputs":[{"name":"newQuorum","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"totalMembers","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"prevQuorum","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"ReportProcessorSet","inputs":[{"name":"processor","type":"address","indexed":true,"internalType":"address"},{"name":"prevProcessor","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"ReportReceived","inputs":[{"name":"refSlot","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"member","type":"address","indexed":true,"internalType":"address"},{"name":"report","type":"bytes32","indexed":false,"internalType":"bytes32"}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"previousAdminRole","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"newAdminRole","type":"bytes32","indexed":true,"internalType":"bytes32"}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"sender","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"sender","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"error","name":"AccessControlBadConfirmation","inputs":[]},{"type":"error","name":"AccessControlUnauthorizedAccount","inputs":[{"name":"account","type":"address","internalType":"address"},{"name":"neededRole","type":"bytes32","internalType":"bytes32"}]},{"type":"error","name":"AddressCannotBeZero","inputs":[]},{"type":"error","name":"AdminCannotBeZero","inputs":[]},{"type":"error","name":"ConsensusReportAlreadyProcessing","inputs":[]},{"type":"error","name":"DuplicateMember","inputs":[]},{"type":"error","name":"DuplicateReport","inputs":[]},{"type":"error","name":"EmptyReport","inputs":[]},{"type":"error","name":"EpochsPerFrameCannotBeZero","inputs":[]},{"type":"error","name":"FastLanePeriodCannotBeLongerThanFrame","inputs":[]},{"type":"error","name":"InitialEpochAlreadyArrived","inputs":[]},{"type":"error","name":"InitialEpochIsYetToArrive","inputs":[]},{"type":"error","name":"InitialEpochRefSlotCannotBeEarlierThanProcessingSlot","inputs":[]},{"type":"error","name":"InvalidChainConfig","inputs":[]},{"type":"error","name":"InvalidInitialization","inputs":[]},{"type":"error","name":"InvalidSlot","inputs":[]},{"type":"error","name":"NewProcessorCannotBeTheSame","inputs":[]},{"type":"error","name":"NonFastLaneMemberCannotReportWithinFastLaneInterval","inputs":[]},{"type":"error","name":"NonMember","inputs":[]},{"type":"error","name":"NotInitializing","inputs":[]},{"type":"error","name":"NumericOverflow","inputs":[]},{"type":"error","name":"QuorumTooSmall","inputs":[{"name":"minQuorum","type":"uint256","internalType":"uint256"},{"name":"receivedQuorum","type":"uint256","internalType":"uint256"}]},{"type":"error","name":"ReportProcessorCannotBeZero","inputs":[]},{"type":"error","name":"SafeCastOverflowedUintDowncast","inputs":[{"name":"bits","type":"uint8","internalType":"uint8"},{"name":"value","type":"uint256","internalType":"uint256"}]},{"type":"error","name":"StaleReport","inputs":[]},{"type":"error","name":"UnexpectedConsensusVersion","inputs":[{"name":"expected","type":"uint256","internalType":"uint256"},{"name":"received","type":"uint256","internalType":"uint256"}]}] \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 201c3743d..09fa6315a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,6 +57,7 @@ markers = [ "integration: tests with using providers", "possible_integration: tests with using providers, but can be run using mocks", "e2e: complex tests with using providers and real Ethereum network", + "fork: tests with using forked Ethereum network", ] addopts = "-s -vv --pdbcls pudb.debugger:Debugger" diff --git a/src/modules/accounting/accounting.py b/src/modules/accounting/accounting.py index 6369d9409..d41350ce5 100644 --- a/src/modules/accounting/accounting.py +++ b/src/modules/accounting/accounting.py @@ -298,7 +298,8 @@ def _get_slots_elapsed_from_last_report(self, blockstamp: ReferenceBlockStamp): if last_ref_slot: slots_elapsed = blockstamp.ref_slot - last_ref_slot else: - slots_elapsed = blockstamp.ref_slot - frame_config.initial_epoch * chain_conf.slots_per_epoch + # https://github.com/lidofinance/core/blob/master/contracts/0.8.9/oracle/HashConsensus.sol#L667 + slots_elapsed = blockstamp.ref_slot - (frame_config.initial_epoch * chain_conf.slots_per_epoch - 1) return slots_elapsed diff --git a/src/modules/csm/csm.py b/src/modules/csm/csm.py index 190199dcc..c1243081c 100644 --- a/src/modules/csm/csm.py +++ b/src/modules/csm/csm.py @@ -397,9 +397,7 @@ def converter(self, blockstamp: BlockStamp) -> Web3Converter: return Web3Converter(self.get_chain_config(blockstamp), self.get_frame_config(blockstamp)) def _get_module_id(self) -> StakingModuleId: - modules: list[StakingModule] = self.w3.lido_contracts.staking_router.get_staking_modules( - self._receive_last_finalized_slot().block_hash - ) + modules: list[StakingModule] = self.w3.lido_contracts.staking_router.get_staking_modules() for mod in modules: if mod.staking_module_address == self.w3.csm.module.address: diff --git a/src/modules/csm/state.py b/src/modules/csm/state.py index 701133160..03526b523 100644 --- a/src/modules/csm/state.py +++ b/src/modules/csm/state.py @@ -8,7 +8,7 @@ from src.types import EpochNumber, ValidatorIndex from src.utils.range import sequence -from src.variables import CACHE_PATH +from src import variables logger = logging.getLogger(__name__) @@ -81,7 +81,7 @@ def commit(self) -> None: @classmethod def file(cls) -> Path: - return CACHE_PATH / Path("cache").with_suffix(cls.EXTENSION) + return variables.CACHE_PATH / Path("cache").with_suffix(cls.EXTENSION) @property def buffer(self) -> Path: diff --git a/src/utils/slot.py b/src/utils/slot.py index fd04c3497..d567900fe 100644 --- a/src/utils/slot.py +++ b/src/utils/slot.py @@ -59,7 +59,7 @@ def _get_non_missed_slot_header( # Exception case can be when all slots are missed in range [slot, last_finalized_slot_number] it will mean that # block response of CL node contradicts itself, because few moments ago we got existed `last_finalized_slot_number` if slot > last_finalized_slot_number: - raise ValueError('`slot` should be less or equal `last_finalized_slot_number`') + raise ValueError(f'{slot=} should be less or equal {last_finalized_slot_number=}') slot_is_missing = False existing_header = None @@ -106,6 +106,7 @@ def get_prev_non_missed_slot( ): raise InconsistentData( "Parent root next to `slot` existing header doesn't match the expected slot.\n" + f'Expected {slot=}, Got {parent_header.data.header.message.slot=}' 'Probably, a problem with the consensus node.' ) diff --git a/tests/fork/__init__.py b/tests/fork/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/fork/conftest.py b/tests/fork/conftest.py new file mode 100644 index 000000000..b381013d3 --- /dev/null +++ b/tests/fork/conftest.py @@ -0,0 +1,447 @@ +import json +import subprocess +import time +from contextlib import contextmanager +from pathlib import Path +from typing import get_args, cast + +import pytest +from _pytest.nodes import Item +from eth_account import Account +from faker.proxy import Faker +from web3 import Web3 +from web3.middleware import construct_simple_cache_middleware +from web3.types import RPCEndpoint +from web3_multi_provider import MultiProvider + +from src import variables +from src.main import logger, ipfs_providers +from src.modules.submodules.consensus import ConsensusModule +from src.modules.submodules.oracle_module import BaseModule +from src.modules.submodules.types import FrameConfig +from src.providers.consensus.client import ConsensusClient, LiteralState +from src.providers.consensus.types import BlockDetailsResponse, BlockRootResponse +from src.providers.execution.contracts.base_oracle import BaseOracleContract +from src.providers.execution.contracts.hash_consensus import HashConsensusContract +from src.providers.ipfs import MultiIPFSProvider, CID +from src.types import SlotNumber, BlockRoot, BlockStamp +from src.utils.blockstamp import build_blockstamp +from src.utils.cache import clear_global_cache +from src.utils.slot import get_next_non_missed_slot +from src.variables import ( + HTTP_REQUEST_TIMEOUT_CONSENSUS, + HTTP_REQUEST_RETRY_COUNT_CONSENSUS, + HTTP_REQUEST_SLEEP_BEFORE_RETRY_IN_SECONDS_CONSENSUS, +) +from src.web3py.contract_tweak import tweak_w3_contracts +from src.web3py.extensions import KeysAPIClientModule, LidoContracts, LidoValidatorsProvider, TransactionUtils, LazyCSM + +logger = logger.getChild("fork") + + +class TestRunningException(Exception): + pass + + +@pytest.hookimpl(hookwrapper=True) +def pytest_collection_modifyitems(items: list[Item]): + yield + if any(not item.get_closest_marker("fork") for item in items): + for item in items: + if item.get_closest_marker("fork"): + item.add_marker( + pytest.mark.skip( + reason="fork tests are take a lot of time and skipped if any other tests are selected" + ) + ) + + +# +# Global +# + + +@pytest.fixture(autouse=True) +def clean_global_cache_after_test(): + yield + logger.info("TESTRUN Clear global LRU functions cache (Autoused)") + clear_global_cache() + + +@pytest.fixture(autouse=True) +def set_delay_and_sleep(monkeypatch): + with monkeypatch.context(): + monkeypatch.setattr( + variables, + "SUBMIT_DATA_DELAY_IN_SLOTS", + 0, + ) + monkeypatch.setattr( + variables, + "CYCLE_SLEEP_IN_SECONDS", + 0, + ) + logger.info("TESTRUN Set SUBMIT_DATA_DELAY_IN_SLOTS and CYCLE_SLEEP_IN_SECONDS to 0") + yield + + +@pytest.fixture(autouse=True) +def set_cache_path(monkeypatch, testrun_path): + with monkeypatch.context(): + monkeypatch.setattr( + variables, + "CACHE_PATH", + Path(testrun_path), + ) + logger.info(f"TESTRUN Set CACHE_PATH to {testrun_path}") + yield + + +@pytest.fixture +def testrun_path(worker_id, testrun_uid): + path = f"./testrun_{worker_id}_{testrun_uid}" + subprocess.run(['mkdir', path], check=True) + yield path + subprocess.run(['rm', '-rf', path], check=True) + + +# +# Utils +# + + +@pytest.fixture +def account_from(monkeypatch): + + @contextmanager + def _use(pk: str): + with monkeypatch.context(): + monkeypatch.setattr( + variables, + "ACCOUNT", + Account.from_key(private_key=pk), # pylint: disable=no-value-for-parameter + ) + logger.info(f"TESTRUN Switched to ACCOUNT {variables.ACCOUNT.address}") + yield + + return _use + + +def first_slot_of_epoch(epoch: int) -> SlotNumber: + return SlotNumber(epoch * 32 - 31) + + +# +# Common +# + + +@pytest.fixture +def real_cl_client(): + return ConsensusClient( + variables.CONSENSUS_CLIENT_URI, + HTTP_REQUEST_TIMEOUT_CONSENSUS, + HTTP_REQUEST_RETRY_COUNT_CONSENSUS, + HTTP_REQUEST_SLEEP_BEFORE_RETRY_IN_SECONDS_CONSENSUS, + ) + + +@pytest.fixture +def real_finalized_slot(real_cl_client: ConsensusClient) -> SlotNumber: + finalized_slot = SlotNumber(int(real_cl_client.get_block_header('finalized').data.header.message.slot)) + logger.info(f"TESTRUN True finalized slot on CL: {finalized_slot}") + return finalized_slot + + +@pytest.fixture(params=[-24], ids=["initial epoch 24 epochs before real finalized epoch"]) +def initial_epoch(request, real_finalized_slot: SlotNumber) -> int: + return (real_finalized_slot // 32) + request.param + + +@pytest.fixture(params=[8], ids=["8 epochs per frame"]) +def epochs_per_frame(request): + return request.param + + +@pytest.fixture(params=[0], ids=["fast lane length 0"]) +def fast_lane_length_slots(request): + return request.param + + +@pytest.fixture +def frame_config(initial_epoch, epochs_per_frame, fast_lane_length_slots): + _frame_config = FrameConfig( + initial_epoch=initial_epoch, + epochs_per_frame=epochs_per_frame, + fast_lane_length_slots=fast_lane_length_slots, + ) + logger.info(f"TESTRUN Frame config: {_frame_config}") + return _frame_config + + +@pytest.fixture(params=[-2], ids=["fork 2 epochs before initial epoch"]) +def blockstamp_for_forking( + request, frame_config: FrameConfig, real_cl_client: ConsensusClient, real_finalized_slot: SlotNumber +) -> BlockStamp: + slot_to_fork = first_slot_of_epoch(frame_config.initial_epoch + request.param) + existing = get_next_non_missed_slot( + real_cl_client, + slot_to_fork, + real_finalized_slot, + ) + blockstamp = build_blockstamp(existing) + logger.info(f"TESTRUN Blockstamp to fork: {blockstamp}") + return blockstamp + + +@pytest.fixture() +def forked_el_client(blockstamp_for_forking: BlockStamp, testrun_path: str): + port = Faker().random_int(min=10000, max=20000) + cli_params = [ + 'anvil', + '--port', + str(port), + '--config-out', + f'{testrun_path}/localhost.json', + '--auto-impersonate', + '-f', + variables.EXECUTION_CLIENT_URI[0], + '--fork-block-number', + str(blockstamp_for_forking.block_number), + ] + with subprocess.Popen(cli_params, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) as process: + time.sleep(5) + logger.info(f"TESTRUN Started fork on {port=} from {blockstamp_for_forking.block_number=}") + web3 = Web3(MultiProvider([f'http://127.0.0.1:{port}'], request_kwargs={'timeout': 5 * 60})) + tweak_w3_contracts(web3) + web3.middleware_onion.add(construct_simple_cache_middleware()) + web3.provider.make_request(RPCEndpoint('anvil_setBlockTimestampInterval'), [12]) + web3.provider.make_request(RPCEndpoint('evm_setAutomine'), [True]) + # TODO: tx execution should somehow change corresponding block on CL + yield web3 + process.terminate() + process.wait() + + +@pytest.fixture() +def web3(forked_el_client, patched_cl_client, mocked_ipfs_client): + kac = KeysAPIClientModule(variables.KEYS_API_URI, forked_el_client) + forked_el_client.attach_modules( + { + 'lido_contracts': LidoContracts, + 'lido_validators': LidoValidatorsProvider, + 'transaction': TransactionUtils, + "csm": LazyCSM, # type: ignore[dict-item] + 'cc': lambda: patched_cl_client, # type: ignore[dict-item] + 'kac': lambda: kac, # type: ignore[dict-item] + "ipfs": lambda: mocked_ipfs_client, + } + ) + yield forked_el_client + + +@pytest.fixture() +def mocked_ipfs_client(monkeypatch): + def _publish(self, content: bytes, name: str | None = None) -> CID: + return CID('Qm' + 'f' * 46) + + with monkeypatch.context(): + monkeypatch.setattr(MultiIPFSProvider, 'publish', _publish) + ipfs = MultiIPFSProvider(ipfs_providers()) + yield ipfs + + +@pytest.fixture() +def accounts_from_fork(forked_el_client, testrun_path): + with open(f'{testrun_path}/localhost.json') as f: + data = json.load(f) + addresses = data['available_accounts'] + private_keys = data['private_keys'] + return [forked_el_client.to_checksum_address(address) for address in addresses], private_keys + + +@pytest.fixture +def running_finalized_slots(request): + slots = request.getfixturevalue(request.param.__name__) + iterator = iter(slots) + current = slots[0] + logger.info(f"TESTRUN Running finalized slots: {slots}") + + def switch() -> SlotNumber | None: + nonlocal current + try: + current = next(iterator) + except StopIteration: + current = None + logger.info(f"TESTRUN Switched finalized to slot {current}") + return current + + return switch, lambda: current + + +@pytest.fixture() +def patched_cl_client(monkeypatch, forked_el_client, real_cl_client, real_finalized_slot, running_finalized_slots): + + _, current = running_finalized_slots + + class PatchedConsensusClient(ConsensusClient): + + def get_block_root(self, state_id: SlotNumber | BlockRoot | LiteralState) -> BlockRootResponse: + + if state_id == 'genesis' or state_id not in get_args(LiteralState): + return super().get_block_root(state_id) + + mocked_finalized_slot = current() + if not mocked_finalized_slot: + raise TestRunningException("Run out of running slots") + + slot_to_find = None + + if state_id == 'finalized': + slot_to_find = mocked_finalized_slot + + if state_id == 'justified': + # one epoch ahead of current slot + possible_justified = SlotNumber(first_slot_of_epoch((mocked_finalized_slot // 32) + 1)) + slot_to_find = possible_justified + + if state_id == 'head': + # two epochs ahead of current slot + possible_head = SlotNumber(first_slot_of_epoch((mocked_finalized_slot // 32) + 2)) + slot_to_find = possible_head + + if slot_to_find is None: + raise TestRunningException(f"Unknown state_id: {state_id}") + + existing = get_next_non_missed_slot( + self, + slot_to_find, + real_finalized_slot, + ).message.slot + + return self.get_block_root(SlotNumber(int(existing))) + + def get_block_details(self, state_id: SlotNumber | BlockRoot) -> BlockDetailsResponse: + """ + Method to get patched CL block details with EL data from forked client + """ + slot_details = super().get_block_details(state_id) + block_from_fork = None + while not block_from_fork: + try: + block_from_fork = forked_el_client.eth.get_block( + int(slot_details.message.body.execution_payload.block_number) + ) + except Exception as e: # pylint: disable=broad-exception-caught + logger.debug(f"TESTRUN FORKED CLIENT: {e}") + if not block_from_fork: + latest_el = int(forked_el_client.eth.get_block('latest')['number']) + from_cl = int(slot_details.message.body.execution_payload.block_number) + diff = from_cl - latest_el + if diff < 0: + raise TestRunningException(f"TESTRUN Latest block {latest_el} is ahead block {from_cl}") + for _ in range(diff): + forked_el_client.provider.make_request(RPCEndpoint('evm_mine'), []) + time.sleep(0.2) + + slot_details.message.body.execution_payload.block_number = block_from_fork['number'] + slot_details.message.body.execution_payload.block_hash = block_from_fork['hash'].hex() + slot_details.message.body.execution_payload.timestamp = block_from_fork['timestamp'] + return slot_details + + yield PatchedConsensusClient( + variables.CONSENSUS_CLIENT_URI, + HTTP_REQUEST_TIMEOUT_CONSENSUS, + HTTP_REQUEST_RETRY_COUNT_CONSENSUS, + HTTP_REQUEST_SLEEP_BEFORE_RETRY_IN_SECONDS_CONSENSUS, + ) + + +@pytest.fixture() +def module(request) -> BaseModule | ConsensusModule: + module = request.getfixturevalue(request.param.__name__) + yield module + + +@pytest.fixture() +def report_contract(module): + yield module.report_contract + + +@pytest.fixture() +def hash_consensus_bin(): + raise TestRunningException("TESTRUN `hash_consensus_bin` fixture should be overriden on tests level") + + +@pytest.fixture() +def new_hash_consensus( + forked_el_client, + real_cl_client, + frame_config, + accounts_from_fork, + report_contract: BaseOracleContract, + hash_consensus_bin, +): + addresses, _ = accounts_from_fork + admin, *_ = addresses + + HashConsensus = forked_el_client.eth.contract( + ContractFactoryClass=HashConsensusContract, bytecode=hash_consensus_bin + ) + new_consensus_address = forked_el_client.eth.wait_for_transaction_receipt( + HashConsensus.constructor( + slotsPerEpoch=32, + secondsPerSlot=12, + genesisTime=int(real_cl_client.get_genesis().genesis_time), + epochsPerFrame=frame_config.epochs_per_frame, + fastLaneLengthSlots=frame_config.fast_lane_length_slots, + admin=admin, + reportProcessor=report_contract.address, + ).transact({'from': admin}) + ).contractAddress + + new_consensus = cast( + HashConsensusContract, + forked_el_client.eth.contract( + address=new_consensus_address, ContractFactoryClass=HashConsensusContract, decode_tuples=True + ), + ) + + DEFAULT_ADMIN_ROLE = "0x" + new_consensus.functions.DEFAULT_ADMIN_ROLE().call().hex() + default_admin = new_consensus.functions.getRoleMember(bytes(32), 0).call() + new_consensus.functions.updateInitialEpoch(frame_config.initial_epoch).transact({'from': default_admin}) + + oracle_admin = report_contract.functions.getRoleMember(DEFAULT_ADMIN_ROLE, 0).call() + forked_el_client.provider.make_request('anvil_setBalance', [oracle_admin, hex(10**18)]) + + MANAGE_CONSENSUS_CONTRACT_ROLE = "0x" + report_contract.functions.MANAGE_CONSENSUS_CONTRACT_ROLE().call().hex() + report_contract.functions.grantRole(MANAGE_CONSENSUS_CONTRACT_ROLE, admin).transact({'from': oracle_admin}) + report_contract.functions.setConsensusContract(new_consensus_address).transact({'from': admin}) + + storage_slot = forked_el_client.keccak(text="lido.BaseOracle.lastProcessingRefSlot") + forked_el_client.provider.make_request('anvil_setStorageAt', [report_contract.address, storage_slot, bytes(32)]) + + yield new_consensus + + +@pytest.fixture() +def set_oracle_members(new_hash_consensus: HashConsensusContract, accounts_from_fork): + addresses, private_keys = accounts_from_fork + + def _set_members(count: int = 2): + + DEFAULT_ADMIN_ROLE = "0x" + new_hash_consensus.functions.DEFAULT_ADMIN_ROLE().call().hex() + MANAGE_MEMBERS_AND_QUORUM_ROLE = ( + "0x" + new_hash_consensus.functions.MANAGE_MEMBERS_AND_QUORUM_ROLE().call().hex() + ) + + admin = new_hash_consensus.functions.getRoleMember(DEFAULT_ADMIN_ROLE, 0).call() + new_hash_consensus.functions.grantRole(MANAGE_MEMBERS_AND_QUORUM_ROLE, admin).transact({'from': admin}) + + for address in addresses[:count]: + current_quorum = new_hash_consensus.functions.getQuorum().call() + new_hash_consensus.functions.addMember(address, current_quorum + 1).transact({'from': admin}) + + return [(addresses[i], private_keys[i]) for i in range(count)] + + return _set_members diff --git a/tests/fork/contracts/csm/HashConsensus_bin b/tests/fork/contracts/csm/HashConsensus_bin new file mode 100644 index 000000000..3e9282390 --- /dev/null +++ b/tests/fork/contracts/csm/HashConsensus_bin @@ -0,0 +1 @@ +60e060405234801562000010575f80fd5b50604051620036f6380380620036f68339810160408190526200003391620005aa565b865f03620000545760405163fb305deb60e01b815260040160405180910390fd5b855f03620000755760405163fb305deb60e01b815260040160405180910390fd5b6200008087620001a3565b6001600160401b03166080526200009786620001a3565b6001600160401b031660a052620000ae85620001a3565b6001600160401b031660c0526001600160a01b038216620000e257604051636b35b1b760e01b815260040160405180910390fd5b6001600160a01b0381166200010a5760405163154f6dd160e31b815260040160405180910390fd5b620001165f83620001e1565b505f6200012a6001600160401b036200023e565b90506200017581868660405180606001604052805f6001600160401b031681526020015f6001600160401b031681526020015f6001600160401b03168152506200025460201b60201c565b50600880546001600160a01b0319166001600160a01b03929092169190911790555062000671945050505050565b5f6001600160401b03821115620001dd57604080516306dfcc6560e41b815260048101919091526024810183905260440160405180910390fd5b5090565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e823717059320008162000210858562000406565b9050801562000234575f858152602083905260409020620002329085620004d6565b505b9150505b92915050565b5f620002386200024e83620004f3565b62000525565b825f03620002755760405163ef3d10c160e01b815260040160405180910390fd5b6080516200028d906001600160401b03168462000621565b821115620002ae576040516385b552e160e01b815260040160405180910390fd5b6040518060600160405280620002ca86620001a360201b60201c565b6001600160401b03168152602001620002e385620001a3565b6001600160401b03168152602001620002fc84620001a3565b6001600160401b0390811690915281515f805460208501516040909501518416600160801b02600160801b600160c01b031995851668010000000000000000026001600160801b0319909216938516939093171793909316179091558151168414158062000377575080602001516001600160401b03168314155b15620003b75760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b0316821462000400576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15b50505050565b5f8281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff16620004cc575f848152602082815260408083206001600160a01b03871684529091529020805460ff19166001179055620004813390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4600191505062000238565b5f91505062000238565b5f620004ec836001600160a01b0384166200053f565b9392505050565b5f60a0516001600160401b031660c0516001600160401b0316836200051991906200063b565b62000238919062000651565b5f6080516001600160401b03168262000238919062000651565b5f8181526001830160205260408120546200058657508154600181810184555f84815260208082209093018490558454848252828601909352604090209190915562000238565b505f62000238565b80516001600160a01b0381168114620005a5575f80fd5b919050565b5f805f805f805f60e0888a031215620005c1575f80fd5b8751965060208801519550604088015194506060880151935060808801519250620005ef60a089016200058e565b9150620005ff60c089016200058e565b905092959891949750929550565b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176200023857620002386200060d565b818103818111156200023857620002386200060d565b5f826200066c57634e487b7160e01b5f52601260045260245ffd5b500490565b60805160a05160c05161301b620006db5f395f81816103d1015281816117c70152612c8201525f81816103ad0152818161179d0152612c4e01525f81816103890152818161128a015281816119c70152818161252b015281816125c70152612ae0015261301b5ff3fe608060405234801561000f575f80fd5b5060043610610213575f3560e01c80636fb1bf661161011f578063ad231cb2116100a9578063d547741f11610079578063d547741f14610619578063e33a8d391461062c578063e76cd4e01461063f578063ea87627d14610652578063fb4209ac14610677575f80fd5b8063ad231cb2146105e3578063c1ba4e59146105eb578063c26c12eb146105fe578063ca15c87314610606575f80fd5b806398041ea3116100ef57806398041ea31461058757806399229f581461059a5780639eab5253146105ad578063a1e07cac146105b5578063a217fddf146105dc575f80fd5b80636fb1bf66146104d157806372f79b13146105135780639010d07c1461053057806391d1485414610543575f80fd5b8063323a41f6116101a0578063606c0c9411610170578063606c0c941461037c5780636095012f1461040f57806360a50a5c1461041757806360e618011461043e5780636d058268146104ac575f80fd5b8063323a41f61461032d57806334aa67531461034057806336568abe14610353578063433ab1f314610366575f80fd5b806320b4d751116101e657806320b4d7511461029c578063239c327f146102af578063248a9ca3146102d65780632f2ff15d146103045780632fd2d75014610317575f80fd5b806301ffc9a714610217578063115a57c41461023f57806316f6f03e146102745780631951c03714610289575b5f80fd5b61022a610225366004612ca7565b61069e565b60405190151581526020015b60405180910390f35b6102667f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe81565b604051908152602001610236565b610287610282366004612ce9565b6106c8565b005b61022a610297366004612d11565b610701565b61022a6102aa366004612d11565b610720565b6102667f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d671781565b6102666102e4366004612d2a565b5f9081525f80516020612fef833981519152602052604090206001015490565b610287610312366004612d41565b61075e565b61031f610794565b604051610236929190612da5565b61028761033b366004612d2a565b6108db565b61028761034e366004612df2565b61099e565b610287610361366004612d41565b610a5e565b61036e610a91565b604051610236929190612e12565b6103f46001600160401b037f00000000000000000000000000000000000000000000000000000000000000008116917f00000000000000000000000000000000000000000000000000000000000000008216917f00000000000000000000000000000000000000000000000000000000000000001690565b60408051938452602084019290925290820152606001610236565b610266610aa6565b6102667f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc081565b61045161044c366004612d11565b610ab8565b60405161023691905f60e082019050825182526020830151602083015260408301511515604083015260608301511515606083015260808301511515608083015260a083015160a083015260c083015160c083015292915050565b6008546001600160a01b03165b6040516001600160a01b039091168152602001610236565b604080516060810182525f546001600160401b03808216808452600160401b8304821660208501819052600160801b90930490911692909301829052906103f4565b61051b610c59565b60408051928352602083019190915201610236565b6104b961053e366004612df2565b610c79565b61022a610551366004612d41565b5f9182525f80516020612fef833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b610287610595366004612ce9565b610cb9565b6102876105a8366004612d2a565b610ced565b61036e610d24565b6102667f66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a5181565b6102665f81565b610287610d30565b6102876105f9366004612d2a565b610d41565b600554610266565b610266610614366004612d2a565b610d52565b610287610627366004612d41565b610d89565b61028761063a366004612e53565b610db9565b61028761064d366004612d11565b610dc4565b61065a610df7565b604080519384526020840192909252151590820152606001610236565b6102667fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e81565b5f6001600160e01b03198216635a05180f60e01b14806106c257506106c282610e2b565b92915050565b7f66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a516106f281610e5f565b6106fc8383610e69565b505050565b6001600160a01b0381165f9081526003602052604081205415156106c2565b6001600160a01b0381165f908152600360205260408120548015801590610757575061075760018203610751611157565b516111bd565b9392505050565b5f8281525f80516020612fef833981519152602052604090206001015461078481610e5f565b61078e83836111f6565b50505050565b60608061079f611157565b602001516004546001600160401b0316146107b8579091565b600754806001600160401b038111156107d3576107d3612e7c565b6040519080825280602002602001820160405280156107fc578160200160208202803683370190505b509250806001600160401b0381111561081757610817612e7c565b604051908082528060200260200182016040528015610840578160200160208202803683370190505b5091505f5b818110156108d5575f81815260066020908152604091829020825180840190935280548084526001909101546001600160401b031691830191909152855186908490811061089557610895612e90565b60200260200101818152505080602001516001600160401b03168483815181106108c1576108c1612e90565b602090810291909101015250600101610845565b50509091565b5f6108e581610e5f565b604080516060810182525f546001600160401b03808216808452600160401b830482166020850152600160801b9092041692820192909252906109274261124b565b10610945576040516329d1e0ff60e01b815260040160405180910390fd5b61096b8382602001516001600160401b031683604001516001600160401b03168461125d565b610973611414565b61097b61147f565b6020015110156106fc576040516323ca23a760e21b815260040160405180910390fd5b7f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe6109c881610e5f565b604080516060810182525f80546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252429190610a0e9083906114e2565b604080516060810182525f546001600160401b038082168352600160401b820481166020840152600160801b9091041691810191909152909150610a579082908790879061125d565b5050505050565b6001600160a01b0381163314610a875760405163334bd91960e11b815260040160405180910390fd5b6106fc82826114f6565b606080610a9e6001611542565b915091509091565b5f610aaf61147f565b60200151905090565b6040805160e0810182525f80825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905290610af8611157565b602081018051845251600554919250610b109161170e565b50506020808401919091526001600160a01b0384165f908152600390915260409081902054801580159285019290925290610c5257806001900390505f60018281548110610b6057610b60612e90565b5f918252602091829020604080518082019091529101546001600160401b03808216808452600160401b909204168284015260a087018190529185015190925014610bab575f610bc9565b6020808201516001600160401b03165f908152600690915260409020545b60c08501525f610bd84261179a565b905083604001518111158015610bf85750610bf1611414565b8460200151115b151560808601528351610c0c9084906111bd565b15801560608701819052610c21575084608001515b15610c4f575f546020850151610c4791600160801b90046001600160401b031690612eb8565b811160808601525b50505b5050919050565b5f805f610c64611157565b90508060200151816040015192509250509091565b5f8281527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000602081905260408220610cb19084611804565b949350505050565b7f66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a51610ce381610e5f565b6106fc838361180f565b7f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d6717610d1781610e5f565b610d2082611987565b5050565b606080610a9e5f611542565b600154610d3f905f1990611a94565b565b600154610d4f908290611a94565b50565b5f8181527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200060208190526040822061075790611bb0565b5f8281525f80516020612fef8339815191526020526040902060010154610daf81610e5f565b61078e83836114f6565b6106fc838383611bb9565b7fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e610dee81610e5f565b610d2082612101565b5f805f610e02611157565b602001519250610e148360055461170e565b50909250839050610e23611414565b149050909192565b5f6001600160e01b03198216637965db0b60e01b14806106c257506301ffc9a760e01b6001600160e01b03198316146106c2565b610d4f8133612300565b5f610e7383612360565b600180549192505f91610e869190612ecb565b905080821115610e9857610e98612ede565b5f60018381548110610eac57610eac612e90565b5f918252602091829020604080518082019091529101546001600160401b038082168352600160401b90910416918101919091529050828214610ff6575f60028381548110610efd57610efd612e90565b5f91825260209091200154600280546001600160a01b039092169250829186908110610f2b57610f2b612e90565b905f5260205f20015f6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060018381548110610f6957610f69612e90565b905f5260205f200160018581548110610f8457610f84612e90565b5f91825260209091208254910180546001600160401b0392831667ffffffffffffffff1982168117835593546001600160801b0319909116909317600160401b93849004909216909202179055610fdc846001612eb8565b6001600160a01b039091165f908152600360205260409020555b600180548061100757611007612ef2565b5f8281526020902081015f1990810180546001600160801b0319169055019055600280548061103857611038612ef2565b5f82815260208082205f19908401810180546001600160a01b03191690559092019092556001600160a01b038716808352600382526040808420939093558251858152918201879052917fa182730913550d27dc6c5813fad297cb0785871bec3d0152c5650e59c5d39d60910160405180910390a280516001600160401b03161561114d575f6110c6611157565b90508060200151825f01516001600160401b03161480156110f1575080602001516110ef611414565b105b1561114b576020808301516001600160401b039081165f90815260069092526040822060010180549092916111269116612f06565b91906101000a8154816001600160401b0302191690836001600160401b031602179055505b505b610a578483611a94565b61117860405180606001604052805f81526020015f81526020015f81525090565b6111b842604080516060810182525f546001600160401b038082168352600160401b820481166020840152600160801b90910416918101919091526123a1565b905090565b6001545f9081806111ce85846123d5565b91509150805f141580156111ec57506111ec8683600184038661240f565b9695505050505050565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000816112238585612450565b90508015610cb1575f8581526020839052604090206112429085612509565b50949350505050565b5f6106c26112588361179a565b61251d565b825f0361127d5760405163ef3d10c160e01b815260040160405180910390fd5b6112b06001600160401b037f00000000000000000000000000000000000000000000000000000000000000001684612f1e565b8211156112d0576040516385b552e160e01b815260040160405180910390fd5b60405180606001604052806112e486612551565b6001600160401b031681526020016112fb85612551565b6001600160401b0316815260200161131284612551565b6001600160401b0390811690915281515f805460208501516040909501518416600160801b0267ffffffffffffffff60801b19958516600160401b026001600160801b03199092169385169390931717939093161790915581511684141580611388575080602001516001600160401b03168314155b156113c75760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b0316821461078e576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a150505050565b60085460408051630d61356760e21b815290515f926001600160a01b031691633584d59c9160048083019260209291908290030181865afa15801561145b573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111b89190612f35565b6114a060405180606001604052805f81526020015f81526020015f81525090565b604080516060810182525f80546001600160401b038082168452600160401b820481166020850152600160801b90910416928201929092526111b8919061258a565b5f6107576114f08484612661565b836126c2565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e823717059320008161152385856126f1565b90508015610cb1575f8581526020839052604090206112429085612782565b60015460609081905f80851561156e5761156461155d611157565b51846123d5565b9092509050611571565b50815b61157b8282612ecb565b6001600160401b0381111561159257611592612e7c565b6040519080825280602002602001820160405280156115bb578160200160208202803683370190505b50945084516001600160401b038111156115d7576115d7612e7c565b604051908082528060200260200182016040528015611600578160200160208202803683370190505b509350815b81811015611705575f6116188583612f60565b90505f6001828154811061162e5761162e612e90565b5f9182526020808320604080518082019091529201546001600160401b038082168452600160401b9091041690820152915061166a8685612ecb565b90506002838154811061167f5761167f612e90565b905f5260205f20015f9054906101000a90046001600160a01b03168982815181106116ac576116ac612e90565b60200260200101906001600160a01b031690816001600160a01b031681525050815f01516001600160401b03168882815181106116eb576116eb612e90565b602002602001018181525050505050806001019050611605565b50505050915091565b6004545f90819081906001600160401b0316851461173457505f91505f19905081611793565b50506007545f91505f19908290815b81811015611790575f818152600660205260409020600101546001600160401b0316868110611787575f828152600660205260409020549550909350915082611790565b50600101611743565b50505b9250925092565b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160401b03167f00000000000000000000000000000000000000000000000000000000000000006001600160401b0316836117fa9190612ecb565b6106c29190612f73565b5f6107578383612796565b6001600160a01b0382165f908152600360205260409020541561184557604051637670720160e11b815260040160405180910390fd5b6001600160a01b03821661186c576040516303988b8160e61b815260040160405180910390fd5b6040805180820182525f808252602080830182815260018054808201825581855294517fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6909501805492516001600160401b03908116600160401b026001600160801b031990941696169590951791909117909355600280548085019091557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0388166001600160a01b03199091168117909155925483835260039091529083902081905591517fe17e0e2cd88e2144dd54f3d823c30d4569092bcac1aabaec1129883e9cc12d2e906119759084908690918252602082015260400190565b60405180910390a26106fc8282611a94565b604080516060810182525f546001600160401b038082168352600160401b8204811660208401819052600160801b9092041692820192909252906119ec907f000000000000000000000000000000000000000000000000000000000000000090612f86565b6001600160401b0316821115611a15576040516385b552e160e01b815260040160405180910390fd5b80604001516001600160401b03168214610d2057611a3282612551565b5f80546001600160401b0392909216600160801b0267ffffffffffffffff60801b199092169190911790556040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15050565b611a9f600282612f73565b8211611ae457611ab0600282612f73565b611abb906001612eb8565b604051632b2dd84d60e01b81526004810191909152602481018390526044015b60405180910390fd5b600554828114611b8e57611b475f198414611b1f577f66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a51611b41565b7f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc05b33612300565b600583905560408051848152602081018490529081018290527f9f40cfd22fe91777c78f252bd21a710f3fb007dc2f321876891e7644ba0ae1759060600160405180910390a15b5f546001600160401b0316611ba24261124b565b106106fc576106fc836127bc565b5f6106c2825490565b825f03611bd957604051631258e44360e01b815260040160405180910390fd5b6001600160401b03831115611c015760405163aac8f00960e01b815260040160405180910390fd5b81611c1e5760405162bf199760e01b815260040160405180910390fd5b5f611c2833612360565b90505f60018281548110611c3e57611c3e612e90565b5f9182526020808320604080518082019091529201546001600160401b038082168452600160401b90910416908201529150611c7861286c565b9050808414611ca457604051632a37dd3d60e11b81526004810182905260248101859052604401611adb565b425f611caf8261179a565b604080516060810182525f80546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252919250611cf484836123a1565b905080602001518a14611d1a57604051631258e44360e01b815260040160405180910390fd5b8060400151831115611d3f57604051637c01d16560e11b815260040160405180910390fd5b81604001516001600160401b03168160200151611d5c9190612eb8565b8311158015611d755750611d7387825f01516111bd565b155b15611d9357604051633e1ca93d60e01b815260040160405180910390fd5b611d9b611414565b8a11611dd75785516001600160401b03168a03611dcb57604051631cf7e8a160e31b815260040160405180910390fd5b50505050505050505050565b6004545f906001600160401b03168b14611e0e57506004805467ffffffffffffffff19166001600160401b038c161790555f611e13565b506007545b5f805b82826001600160401b0316108015611e4557506001600160401b0382165f908152600660205260409020548c14155b15611e5a57611e5382612fb1565b9150611e16565b88516001600160401b03168d03611f325760208901516001600160401b0381168411611e8857611e88612ede565b806001600160401b0316836001600160401b031603611eba5760405163fd10cf7360e01b815260040160405180910390fd5b6001600160401b038082165f9081526006602052604081206001018054919290918391611ee79116612f06565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b031690506001600554611f249190612ecb565b8103611f2f57600192505b50505b5f83836001600160401b03161015611fa0576001600160401b038084165f90815260066020526040812060010180549092611f6d9116612fb1565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b03169050612000565b506040805180820182528d8152600160208083018281526001600160401b038781165f9081526006909352949091209251835551918101805467ffffffffffffffff19169290931691909117909155611ff884612fd6565b600781905593505b60405180604001604052808f6001600160401b03168152602001846001600160401b031681525060018c8154811061203a5761203a612e90565b5f91825260209182902083519101805493909201516001600160401b03908116600160401b026001600160801b031990941691161791909117905561207c3390565b6001600160a01b03168e7f92f77576dabd7bad26f75c36abb3021b5bbb66a3e5688570a0355daddd4174888f6040516120b791815260200190565b60405180910390a360055481106120e2576120dd858e856001600160401b0316846128b3565b6120f1565b81156120f1576120f18561299b565b5050505050505050505050505050565b6008546001600160a01b0390811690821661212f5760405163154f6dd160e31b815260040160405180910390fd5b806001600160a01b0316826001600160a01b0316036121615760405163f1b3699f60e01b815260040160405180910390fd5b600880546001600160a01b0319166001600160a01b03848116918217909255604051918316917f3b59429457a41af89ea682ac9ed8abb8e99eb5c7d3363d5eedfc6bff6271a81e905f90a35f6121b5611157565b90505f60045f0160089054906101000a90046001600160401b03166001600160401b031690505f836001600160a01b0316633584d59c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612218573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061223c9190612f35565b90505f856001600160a01b0316633584d59c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561227b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061229f9190612f35565b90508360200151821080156122b75750836020015181105b80156122c65750836020015183145b156122f857600454600160801b90046001600160401b03165f908152600660205260409020546122f68582612a07565b505b505050505050565b5f8281525f80516020612fef833981519152602090815260408083206001600160a01b038516845290915290205460ff16610d205760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401611adb565b6001600160a01b0381165f9081526003602052604081205480820361239857604051638d35f2ed60e01b815260040160405180910390fd5b5f190192915050565b6123c260405180606001604052805f81526020015f81526020015f81525090565b6107576123cf8484612661565b8361258a565b6005545f9081908381106123ee575f9250839150612407565b6123f88486612f60565b92506124048184612eb8565b91505b509250929050565b5f8161241b8585612ecb565b6124259190612f60565b82856124318289612eb8565b61243b9190612ecb565b6124459190612f60565b111595945050505050565b5f8281525f80516020612fef833981519152602081815260408084206001600160a01b038616855290915282205460ff16612500575f848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556124b63390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506106c2565b5f9150506106c2565b5f610757836001600160a01b038416612a86565b5f6106c26001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683612f73565b5f6001600160401b0382111561258657604080516306dfcc6560e41b8152600481019190915260248101839052604401611adb565b5090565b6125ab60405180606001604052805f81526020015f81526020015f81525090565b5f6125b684846126c2565b90505f6125c282612ad2565b90505f7f000000000000000000000000000000000000000000000000000000000000000085602001516125f59190612f86565b612608906001600160401b031683612eb8565b905060405180606001604052808781526020016001846126289190612ecb565b6001600160401b031681526020015f612642600185612ecb565b61264c9190612ecb565b6001600160401b031690529695505050505050565b5f8061266c8461124b565b83519091506001600160401b031681101561269a5760405163668441f560e11b815260040160405180910390fd5b602083015183516001600160401b03918216916126b8911683612ecb565b610cb19190612f73565b5f81602001516001600160401b0316836126dc9190612f1e565b825161075791906001600160401b0316612eb8565b5f8281525f80516020612fef833981519152602081815260408084206001600160a01b038616855290915282205460ff1615612500575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506106c2565b5f610757836001600160a01b038416612b06565b5f825f0182815481106127ab576127ab612e90565b905f5260205f200154905092915050565b604080516060810182525f80546001600160401b038082168452600160401b820481166020850152600160801b90910416928201929092524291906128029083906123a1565b905080604001516128128361179a565b111561281d57505050565b806020015161282a611414565b1061283457505050565b5f805f61284584602001518761170e565b9250925092505f82126128635761285e848484846128b3565b6122f8565b6122f88461299b565b60085460408051635be2042560e01b815290515f926001600160a01b031691635be204259160048083019260209291908290030181865afa15801561145b573d5f803e3d5ffd5b6020840151600454600160401b90046001600160401b03161415806128ea5750600454600160801b90046001600160401b03168214155b1561078e576020840151600480546001600160401b03858116600160801b0267ffffffffffffffff60801b19918516600160401b02919091167fffffffffffffffff00000000000000000000000000000000ffffffffffffffff909216919091171790556040517f2b6bc782c916fa763822f1e50c6db0f95dade36d6541a8a4cbe070735b8b226d906129899086908590918252602082015260400190565b60405180910390a261078e8484612a07565b6020810151600454600160401b90046001600160401b031603610d4f57600480546fffffffffffffffff00000000000000001916905560208101516040517fde3f4ea5aa67881831e8fad2b0855d47e75aa63a2fae6ef657ffd5f856c4a613905f90a2610d4f81612be0565b600854602083015160408401516001600160a01b039092169163063f36ad918491612a3190612c40565b6040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064015f604051808303815f87803b158015612a74575f80fd5b505af11580156122f8573d5f803e3d5ffd5b5f818152600183016020526040812054612acb57508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556106c2565b505f6106c2565b5f6106c26001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683612f1e565b5f8181526001830160205260408120548015612500575f612b28600183612ecb565b85549091505f90612b3b90600190612ecb565b9050808214612b9a575f865f018281548110612b5957612b59612e90565b905f5260205f200154905080875f018481548110612b7957612b79612e90565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080612bab57612bab612ef2565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f9055600193505050506106c2565b600854602082015160405163d438121760e01b81526001600160a01b039092169163d438121791612c179160040190815260200190565b5f604051808303815f87803b158015612c2e575f80fd5b505af1158015610a57573d5f803e3d5ffd5b5f612c746001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683612f1e565b6106c2906001600160401b037f000000000000000000000000000000000000000000000000000000000000000016612eb8565b5f60208284031215612cb7575f80fd5b81356001600160e01b031981168114610757575f80fd5b80356001600160a01b0381168114612ce4575f80fd5b919050565b5f8060408385031215612cfa575f80fd5b612d0383612cce565b946020939093013593505050565b5f60208284031215612d21575f80fd5b61075782612cce565b5f60208284031215612d3a575f80fd5b5035919050565b5f8060408385031215612d52575f80fd5b82359150612d6260208401612cce565b90509250929050565b5f815180845260208085019450602084015f5b83811015612d9a57815187529582019590820190600101612d7e565b509495945050505050565b604080825283519082018190525f906020906060840190828701845b82811015612ddd57815184529284019290840190600101612dc1565b50505083810360208501526111ec8186612d6b565b5f8060408385031215612e03575f80fd5b50508035926020909101359150565b604080825283519082018190525f906020906060840190828701845b82811015612ddd5781516001600160a01b031684529284019290840190600101612e2e565b5f805f60608486031215612e65575f80fd5b505081359360208301359350604090920135919050565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b808201808211156106c2576106c2612ea4565b818103818111156106c2576106c2612ea4565b634e487b7160e01b5f52600160045260245ffd5b634e487b7160e01b5f52603160045260245ffd5b5f6001600160401b0382168061239857612398612ea4565b80820281158282048414176106c2576106c2612ea4565b5f60208284031215612f45575f80fd5b5051919050565b634e487b7160e01b5f52601260045260245ffd5b5f82612f6e57612f6e612f4c565b500690565b5f82612f8157612f81612f4c565b500490565b6001600160401b03818116838216028082169190828114612fa957612fa9612ea4565b505092915050565b5f6001600160401b03808316818103612fcc57612fcc612ea4565b6001019392505050565b5f60018201612fe757612fe7612ea4565b506001019056fe02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800a164736f6c6343000818000a \ No newline at end of file diff --git a/tests/fork/contracts/lido/HashConsensus_bin b/tests/fork/contracts/lido/HashConsensus_bin new file mode 100644 index 000000000..fead30ac3 --- /dev/null +++ b/tests/fork/contracts/lido/HashConsensus_bin @@ -0,0 +1 @@ +60e06040523480156200001157600080fd5b5060405162003b0a38038062003b0a83398101604081905262000034916200060f565b86620000535760405163fb305deb60e01b815260040160405180910390fd5b85620000725760405163fb305deb60e01b815260040160405180910390fd5b6200008887620001c760201b62000e281760201c565b6001600160401b0316608052620000ab86620001c7602090811b62000e2817901c565b6001600160401b031660a052620000ce85620001c7602090811b62000e2817901c565b6001600160401b031660c0526001600160a01b0382166200010257604051636b35b1b760e01b815260040160405180910390fd5b6001600160a01b0381166200012a5760405163154f6dd160e31b815260040160405180910390fd5b6200013760008362000238565b60006200014b6001600160401b0362000248565b905062000199818686604051806060016040528060006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b03168152506200026560201b60201c565b50600880546001600160a01b0319166001600160a01b039290921691909117905550620006ec945050505050565b60006001600160401b03821115620002345760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b606482015260840160405180910390fd5b5090565b62000244828262000431565b5050565b60006200025f620002598362000492565b620004c5565b92915050565b82620002845760405163ef3d10c160e01b815260040160405180910390fd5b6080516200029c906001600160401b0316846200068d565b821115620002bd576040516385b552e160e01b815260040160405180910390fd5b6040518060600160405280620002de86620001c760201b62000e281760201c565b6001600160401b031681526020016200030285620001c760201b62000e281760201c565b6001600160401b031681526020016200032684620001c760201b62000e281760201c565b6001600160401b0390811690915281516000805460208501516040909501518416600160801b02600160801b600160c01b031995851668010000000000000000026001600160801b03199092169385169390931717939093161790915581511684141580620003a2575080602001516001600160401b03168314155b15620003e25760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b031682146200042b576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15b50505050565b620004488282620004e060201b62000e941760201c565b6200048d817f8f8c450dae5029cd48cd91dd9db65da48fb742893edfc7941250f6721d93cbbe6000858152602091825260409020919062000f0a62000582821b17901c565b505050565b600060a0516001600160401b031660c0516001600160401b031683620004b99190620006af565b6200025f9190620006c9565b60006080516001600160401b0316826200025f9190620006c9565b600082815260008051602062003aea833981519152602090815260408083206001600160a01b038516845290915290205460ff166200024457600082815260008051602062003aea833981519152602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600062000599836001600160a01b038416620005a0565b9392505050565b6000818152600183016020526040812054620005e9575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556200025f565b5060006200025f565b80516001600160a01b03811681146200060a57600080fd5b919050565b600080600080600080600060e0888a0312156200062b57600080fd5b87519650602088015195506040880151945060608801519350608088015192506200065960a08901620005f2565b91506200066960c08901620005f2565b905092959891949750929550565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615620006aa57620006aa62000677565b500290565b600082821015620006c457620006c462000677565b500390565b600082620006e757634e487b7160e01b600052601260045260246000fd5b500490565b60805160a05160c05161338f6200075b600039600081816103c0015281816119230152612e6401526000818161039c015281816118f90152612e30015260008181610378015281816113cc01528181611b2701528181612777015281816127e00152612ca3015261338f6000f3fe608060405234801561001057600080fd5b506004361061021c5760003560e01c80636fb1bf6611610125578063ad231cb2116100ad578063d547741f1161007c578063d547741f146105c8578063e33a8d39146105db578063e76cd4e0146105ee578063ea87627d14610601578063fb4209ac1461062657600080fd5b8063ad231cb214610592578063c1ba4e591461059a578063c26c12eb146105ad578063ca15c873146105b557600080fd5b806398041ea3116100f457806398041ea31461054757806399229f581461055a5780639eab52531461056d578063a1e07cac14610575578063a217fddf1461058a57600080fd5b80636fb1bf66146104c157806372f79b13146105045780639010d07c1461052157806391d148541461053457600080fd5b8063323a41f6116101a8578063606c0c9411610177578063606c0c941461036b5780636095012f146103fe57806360a50a5c1461040657806360e618011461042d5780636d0582681461049c57600080fd5b8063323a41f61461031c57806334aa67531461032f57806336568abe14610342578063433ab1f31461035557600080fd5b806320b4d751116101ef57806320b4d751146102a6578063239c327f146102b9578063248a9ca3146102e05780632f2ff15d146102f35780632fd2d7501461030657600080fd5b806301ffc9a714610221578063115a57c41461024957806316f6f03e1461027e5780631951c03714610293575b600080fd5b61023461022f366004612e89565b61064d565b60405190151581526020015b60405180910390f35b6102707f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe81565b604051908152602001610240565b61029161028c366004612ecf565b610678565b005b6102346102a1366004612ef9565b6106a0565b6102346102b4366004612ef9565b6106c0565b6102707f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d671781565b6102706102ee366004612f14565b6106ff565b610291610301366004612f2d565b610721565b61030e61073e565b604051610240929190612f94565b61029161032a366004612f14565b61088f565b61029161033d366004612fe1565b610955565b610291610350366004612f2d565b610a18565b61035d610a9b565b604051610240929190613003565b6103e36001600160401b037f00000000000000000000000000000000000000000000000000000000000000008116917f00000000000000000000000000000000000000000000000000000000000000008216917f00000000000000000000000000000000000000000000000000000000000000001690565b60408051938452602084019290925290820152606001610240565b610270610ab0565b6102707f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc081565b61044061043b366004612ef9565b610ac3565b6040516102409190600060e082019050825182526020830151602083015260408301511515604083015260608301511515606083015260808301511515608083015260a083015160a083015260c083015160c083015292915050565b6008546001600160a01b03165b6040516001600160a01b039091168152602001610240565b604080516060810182526000546001600160401b03808216808452600160401b8304821660208501819052600160801b90930490911692909301829052906103e3565b61050c610c6c565b60408051928352602083019190915201610240565b6104a961052f366004612fe1565b610c8e565b610234610542366004612f2d565b610cb3565b610291610555366004612ecf565b610ceb565b610291610568366004612f14565b610d0e565b61035d610d42565b6102706000805160206132fa83398151915281565b610270600081565b610291610d4f565b6102916105a8366004612f14565b610d61565b600554610270565b6102706105c3366004612f14565b610d72565b6102916105d6366004612f2d565b610d96565b6102916105e9366004613045565b610db3565b6102916105fc366004612ef9565b610dbe565b610609610df2565b604080519384526020840192909252151590820152606001610240565b6102707fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e81565b60006001600160e01b03198216635a05180f60e01b1480610672575061067282610f1f565b92915050565b6000805160206132fa8339815191526106918133610f54565b61069b8383610fb8565b505050565b6001600160a01b0381166000908152600360205260408120541515610672565b6001600160a01b03811660009081526003602052604081205480158015906106f857506106f8600182036106f26112ba565b51611324565b9392505050565b600090815260008051602061333a833981519152602052604090206001015490565b61072a826106ff565b6107348133610f54565b61069b838361135f565b6060806107496112ba565b602001516004546001600160401b031614610762579091565b600754806001600160401b0381111561077d5761077d613071565b6040519080825280602002602001820160405280156107a6578160200160208202803683370190505b509250806001600160401b038111156107c1576107c1613071565b6040519080825280602002602001820160405280156107ea578160200160208202803683370190505b50915060005b8181101561088957600081815260066020908152604091829020825180840190935280548084526001909101546001600160401b031691830191909152855186908490811061084157610841613087565b60200260200101818152505080602001516001600160401b031684838151811061086d5761086d613087565b602090810291909101015250610882816130b3565b90506107f0565b50509091565b600061089b8133610f54565b604080516060810182526000546001600160401b03808216808452600160401b830482166020850152600160801b9092041692820192909252906108de4261138e565b106108fc576040516329d1e0ff60e01b815260040160405180910390fd5b6109228382602001516001600160401b031683604001516001600160401b0316846113a1565b61092a611558565b6109326115d5565b60200151101561069b576040516323ca23a760e21b815260040160405180910390fd5b7f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe6109808133610f54565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b90910416928201929092524291906109c790839061163c565b604080516060810182526000546001600160401b038082168352600160401b820481166020840152600160801b9091041691810191909152909150610a11908290879087906113a1565b5050505050565b6001600160a01b0381163314610a8d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610a978282611651565b5050565b606080610aa86001611680565b915091509091565b6000610aba6115d5565b60200151905090565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905290610b046112ba565b602081018051845251600554919250610b1c9161185a565b50506020808401919091526001600160a01b0384166000908152600390915260409081902054801580159285019290925290610c655780600190039050600060018281548110610b6e57610b6e613087565b6000918252602091829020604080518082019091529101546001600160401b03808216808452600160401b909204168284015260a087018190529185015190925014610bbb576000610bda565b6020808201516001600160401b03166000908152600690915260409020545b60c08501526000610bea426118f5565b905083604001518111158015610c0a5750610c03611558565b8460200151115b151560808601528351610c1e908490611324565b15801560608701819052610c33575084608001515b15610c62576000546020850151610c5a91600160801b90046001600160401b0316906130ce565b811160808601525b50505b5050919050565b6000806000610c796112ba565b90508060200151816040015192509250509091565b600082815260008051602061331a833981519152602052604081206106f89083611960565b600091825260008051602061333a833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6000805160206132fa833981519152610d048133610f54565b61069b838361196c565b7f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d6717610d398133610f54565b610a9782611ae6565b606080610aa86000611680565b600154610d5f9060001990611bf5565b565b600154610d6f908290611bf5565b50565b600081815260008051602061331a8339815191526020526040812061067290611cfc565b610d9f826106ff565b610da98133610f54565b61069b8383611651565b61069b838383611d06565b7fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e610de98133610f54565b610a978261225f565b6000806000610dff6112ba565b602001519250610e118360055461185a565b50909250839050610e20611558565b149050909192565b60006001600160401b03821115610e905760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b6064820152608401610a84565b5090565b610e9e8282610cb3565b610a9757600082815260008051602061333a833981519152602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b60006106f8836001600160a01b038416612488565b60006001600160e01b03198216637965db0b60e01b148061067257506301ffc9a760e01b6001600160e01b0319831614610672565b610f5e8282610cb3565b610a9757610f76816001600160a01b031660146124d7565b610f818360206124d7565b604051602001610f92929190613112565b60408051601f198184030181529082905262461bcd60e51b8252610a8491600401613187565b6000610fc383612672565b60018054919250600091610fd791906131ba565b905080821115610fe957610fe96131d1565b600060018381548110610ffe57610ffe613087565b6000918252602091829020604080518082019091529101546001600160401b038082168352600160401b909104169181019190915290508282146111525760006002838154811061105157611051613087565b600091825260209091200154600280546001600160a01b03909216925082918690811061108057611080613087565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600183815481106110c1576110c1613087565b90600052602060002001600185815481106110de576110de613087565b600091825260209091208254910180546001600160401b0392831667ffffffffffffffff1982168117835593546001600160801b0319909116909317600160401b938490049092169092021790556111378460016130ce565b6001600160a01b039091166000908152600360205260409020555b6001805480611163576111636131e7565b600082815260209020810160001990810180546001600160801b03191690550190556002805480611196576111966131e7565b60008281526020808220600019908401810180546001600160a01b03191690559092019092556001600160a01b038716808352600382526040808420939093558251858152918201879052917fa182730913550d27dc6c5813fad297cb0785871bec3d0152c5650e59c5d39d60910160405180910390a280516001600160401b0316156112b05760006112276112ba565b9050806020015182600001516001600160401b031614801561125357508060200151611251611558565b105b156112ae576020808301516001600160401b039081166000908152600690925260408220600101805490929161128991166131fd565b91906101000a8154816001600160401b0302191690836001600160401b031602179055505b505b610a118483611bf5565b6112de60405180606001604052806000815260200160008152602001600081525090565b61131f42604080516060810182526000546001600160401b038082168352600160401b820481166020840152600160801b90910416918101919091526126b3565b905090565b600154600090818061133685846126ea565b9150915080600014158015611355575061135586836001840386612726565b9695505050505050565b6113698282610e94565b600082815260008051602061331a8339815191526020526040902061069b9082610f0a565b600061067261139c836118f5565b612768565b826113bf5760405163ef3d10c160e01b815260040160405180910390fd5b6113f26001600160401b037f00000000000000000000000000000000000000000000000000000000000000001684613216565b821115611412576040516385b552e160e01b815260040160405180910390fd5b604051806060016040528061142686610e28565b6001600160401b0316815260200161143d85610e28565b6001600160401b0316815260200161145484610e28565b6001600160401b0390811690915281516000805460208501516040909501518416600160801b0267ffffffffffffffff60801b19958516600160401b026001600160801b031990921693851693909317179390931617909155815116841415806114cb575080602001516001600160401b03168314155b1561150a5760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b03168214611552576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15b50505050565b60085460408051630d61356760e21b815290516000926001600160a01b031691633584d59c916004808301926020929190829003018186803b15801561159d57600080fd5b505afa1580156115b1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131f9190613235565b6115f960405180606001604052806000815260200160008152602001600081525090565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b909104169282019290925261131f919061279d565b60006106f861164b848461287b565b836128e5565b61165b8282612915565b600082815260008051602061331a8339815191526020526040902061069b9082612989565b600154606090819060008085156116ad576116a361169c6112ba565b51846126ea565b90925090506116b0565b50815b6116ba82826131ba565b6001600160401b038111156116d1576116d1613071565b6040519080825280602002602001820160405280156116fa578160200160208202803683370190505b50945084516001600160401b0381111561171657611716613071565b60405190808252806020026020018201604052801561173f578160200160208202803683370190505b509350815b818110156118515760006117588583613264565b905060006001828154811061176f5761176f613087565b60009182526020808320604080518082019091529201546001600160401b038082168452600160401b909104169082015291506117ac86856131ba565b9050600283815481106117c1576117c1613087565b9060005260206000200160009054906101000a90046001600160a01b03168982815181106117f1576117f1613087565b60200260200101906001600160a01b031690816001600160a01b03168152505081600001516001600160401b031688828151811061183157611831613087565b6020026020010181815250505050508061184a906130b3565b9050611744565b50505050915091565b600454600090819081906001600160401b031685146118835750600091506000199050816118ee565b505060075460009150600019908290815b818110156118eb576000818152600660205260409020600101546001600160401b03168681106118da5760008281526006602052604090205495509093509150826118eb565b506118e4816130b3565b9050611894565b50505b9250925092565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160401b03167f00000000000000000000000000000000000000000000000000000000000000006001600160401b03168361195691906131ba565b6106729190613278565b60006106f8838361299e565b6001600160a01b038216600090815260036020526040902054156119a357604051637670720160e11b815260040160405180910390fd5b6001600160a01b0382166119ca576040516303988b8160e61b815260040160405180910390fd5b6040805180820182526000808252602080830182815260018054808201825581855294517fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6909501805492516001600160401b03908116600160401b026001600160801b031990941696169590951791909117909355600280548085019091557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0388166001600160a01b03199091168117909155925483835260039091529083902081905591517fe17e0e2cd88e2144dd54f3d823c30d4569092bcac1aabaec1129883e9cc12d2e90611ad49084908690918252602082015260400190565b60405180910390a261069b8282611bf5565b604080516060810182526000546001600160401b038082168352600160401b8204811660208401819052600160801b909204169282019290925290611b4c907f00000000000000000000000000000000000000000000000000000000000000009061328c565b6001600160401b0316821115611b75576040516385b552e160e01b815260040160405180910390fd5b80604001516001600160401b03168214610a9757611b9282610e28565b600080546001600160401b0392909216600160801b0267ffffffffffffffff60801b199092169190911790556040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15050565b611c00600282613278565b8211611c4057611c11600282613278565b611c1c9060016130ce565b604051632b2dd84d60e01b8152600481019190915260248101839052604401610a84565b600554828114611cd957611c926000198414611c6a576000805160206132fa833981519152611c8c565b7f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc05b33610f54565b600583905560408051848152602081018490529081018290527f9f40cfd22fe91777c78f252bd21a710f3fb007dc2f321876891e7644ba0ae1759060600160405180910390a15b6000546001600160401b0316611cee4261138e565b1061069b5761069b836129c8565b6000610672825490565b82611d2457604051631258e44360e01b815260040160405180910390fd5b6001600160401b03831115611d4c5760405163aac8f00960e01b815260040160405180910390fd5b81611d695760405162bf199760e01b815260040160405180910390fd5b6000611d7433612672565b9050600060018281548110611d8b57611d8b613087565b60009182526020808320604080518082019091529201546001600160401b038082168452600160401b90910416908201529150611dc6612a7c565b9050808414611df257604051632a37dd3d60e11b81526004810182905260248101859052604401610a84565b426000611dfe826118f5565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252919250611e4484836126b3565b905080602001518a14611e6a57604051631258e44360e01b815260040160405180910390fd5b8060400151831115611e8f57604051637c01d16560e11b815260040160405180910390fd5b81604001516001600160401b03168160200151611eac91906130ce565b8311158015611ec65750611ec4878260000151611324565b155b15611ee457604051633e1ca93d60e01b815260040160405180910390fd5b611eec611558565b8a11611f295785516001600160401b03168a1415611f1d57604051631cf7e8a160e31b815260040160405180910390fd5b50505050505050505050565b6004546000906001600160401b03168b14611f6257506004805467ffffffffffffffff19166001600160401b038c161790556000611f67565b506007545b6000805b82826001600160401b0316108015611f9b57506001600160401b0382166000908152600660205260409020548c14155b15611fb057611fa9826132bb565b9150611f6b565b88516001600160401b03168d141561208c5760208901516001600160401b0381168411611fdf57611fdf6131d1565b806001600160401b0316836001600160401b031614156120125760405163fd10cf7360e01b815260040160405180910390fd5b6001600160401b038082166000908152600660205260408120600101805491929091839161204091166131fd565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b03169050600160055461207d91906131ba565b81141561208957600192505b50505b600083836001600160401b031610156120fc576001600160401b038084166000908152600660205260408120600101805490926120c991166132bb565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b0316905061215d565b506040805180820182528d8152600160208083018281526001600160401b0387811660009081526006909352949091209251835551918101805467ffffffffffffffff19169290931691909117909155612155846130b3565b600781905593505b60405180604001604052808f6001600160401b03168152602001846001600160401b031681525060018c8154811061219757612197613087565b600091825260209182902083519101805493909201516001600160401b03908116600160401b026001600160801b03199094169116179190911790556121da3390565b6001600160a01b03168e7f92f77576dabd7bad26f75c36abb3021b5bbb66a3e5688570a0355daddd4174888f60405161221591815260200190565b60405180910390a360055481106122405761223b858e856001600160401b031684612ac1565b61224f565b811561224f5761224f85612ba2565b5050505050505050505050505050565b6008546001600160a01b0390811690821661228d5760405163154f6dd160e31b815260040160405180910390fd5b806001600160a01b0316826001600160a01b031614156122c05760405163f1b3699f60e01b815260040160405180910390fd5b600880546001600160a01b0319166001600160a01b03848116918217909255604051918316917f3b59429457a41af89ea682ac9ed8abb8e99eb5c7d3363d5eedfc6bff6271a81e90600090a360006123166112ba565b90506000600460000160089054906101000a90046001600160401b03166001600160401b031690506000836001600160a01b0316633584d59c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561237957600080fd5b505afa15801561238d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b19190613235565b90506000856001600160a01b0316633584d59c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156123ee57600080fd5b505afa158015612402573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124269190613235565b905083602001518210801561243e5750836020015181105b801561244d5750836020015183145b1561248057600454600160801b90046001600160401b031660009081526006602052604090205461247e8582612c10565b505b505050505050565b60008181526001830160205260408120546124cf57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610672565b506000610672565b606060006124e6836002613216565b6124f19060026130ce565b6001600160401b0381111561250857612508613071565b6040519080825280601f01601f191660200182016040528015612532576020820181803683370190505b509050600360fc1b8160008151811061254d5761254d613087565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061257c5761257c613087565b60200101906001600160f81b031916908160001a90535060006125a0846002613216565b6125ab9060016130ce565b90505b6001811115612623576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106125df576125df613087565b1a60f81b8282815181106125f5576125f5613087565b60200101906001600160f81b031916908160001a90535060049490941c9361261c816132e2565b90506125ae565b5083156106f85760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a84565b6001600160a01b038116600090815260036020526040812054806126a957604051638d35f2ed60e01b815260040160405180910390fd5b6000190192915050565b6126d760405180606001604052806000815260200160008152602001600081525090565b6106f86126e4848461287b565b8361279d565b6005546000908190838110612705576000925083915061271e565b61270f8486613264565b925061271b81846130ce565b91505b509250929050565b60008161273385856131ba565b61273d9190613264565b828561274982896130ce565b61275391906131ba565b61275d9190613264565b111595945050505050565b60006106726001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683613278565b6127c160405180606001604052806000815260200160008152602001600081525090565b60006127cd84846128e5565b905060006127da82612c94565b905060007f0000000000000000000000000000000000000000000000000000000000000000856020015161280e919061328c565b612821906001600160401b0316836130ce565b9050604051806060016040528087815260200160018461284191906131ba565b6001600160401b03168152602001600061285c6001856131ba565b61286691906131ba565b6001600160401b031690529695505050505050565b6000806128878461138e565b83519091506001600160401b03168110156128b55760405163668441f560e11b815260040160405180910390fd5b602083015183516001600160401b03918216916128d39116836131ba565b6128dd9190613278565b949350505050565b600081602001516001600160401b0316836129009190613216565b82516106f891906001600160401b03166130ce565b61291f8282610cb3565b15610a9757600082815260008051602061333a833981519152602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006106f8836001600160a01b038416612cc9565b60008260000182815481106129b5576129b5613087565b9060005260206000200154905092915050565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252429190612a0f9083906126b3565b90508060400151612a1f836118f5565b1115612a2a57505050565b8060200151612a37611558565b10612a4157505050565b6000806000612a5484602001518761185a565b92509250925060008212612a7357612a6e84848484612ac1565b612480565b61248084612ba2565b60085460408051635be2042560e01b815290516000926001600160a01b031691635be20425916004808301926020929190829003018186803b15801561159d57600080fd5b6020840151600454600160401b90046001600160401b0316141580612af85750600454600160801b90046001600160401b03168214155b15611552576020840151600480546001600160401b03858116600160801b0267ffffffffffffffff60801b19918516600160401b029190911677ffffffffffffffffffffffffffffffff000000000000000019909216919091171790556040517f2b6bc782c916fa763822f1e50c6db0f95dade36d6541a8a4cbe070735b8b226d90612b909086908590918252602082015260400190565b60405180910390a26115528484612c10565b6020810151600454600160401b90046001600160401b03161415610d6f57600480546fffffffffffffffff00000000000000001916905560208101516040517fde3f4ea5aa67881831e8fad2b0855d47e75aa63a2fae6ef657ffd5f856c4a61390600090a2610d6f81612dbc565b600854602083015160408401516001600160a01b039092169163063f36ad918491612c3a90612e21565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401600060405180830381600087803b158015612c8057600080fd5b505af1158015612480573d6000803e3d6000fd5b60006106726001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683613216565b60008181526001830160205260408120548015612db2576000612ced6001836131ba565b8554909150600090612d01906001906131ba565b9050818114612d66576000866000018281548110612d2157612d21613087565b9060005260206000200154905080876000018481548110612d4457612d44613087565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612d7757612d776131e7565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610672565b6000915050610672565b600854602082015160405163d438121760e01b81526001600160a01b039092169163d438121791612df39160040190815260200190565b600060405180830381600087803b158015612e0d57600080fd5b505af1158015610a11573d6000803e3d6000fd5b6000612e566001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683613216565b610672906001600160401b037f0000000000000000000000000000000000000000000000000000000000000000166130ce565b600060208284031215612e9b57600080fd5b81356001600160e01b0319811681146106f857600080fd5b80356001600160a01b0381168114612eca57600080fd5b919050565b60008060408385031215612ee257600080fd5b612eeb83612eb3565b946020939093013593505050565b600060208284031215612f0b57600080fd5b6106f882612eb3565b600060208284031215612f2657600080fd5b5035919050565b60008060408385031215612f4057600080fd5b82359150612f5060208401612eb3565b90509250929050565b600081518084526020808501945080840160005b83811015612f8957815187529582019590820190600101612f6d565b509495945050505050565b604080825283519082018190526000906020906060840190828701845b82811015612fcd57815184529284019290840190600101612fb1565b505050838103828501526113558186612f59565b60008060408385031215612ff457600080fd5b50508035926020909101359150565b604080825283519082018190526000906020906060840190828701845b82811015612fcd5781516001600160a01b031684529284019290840190600101613020565b60008060006060848603121561305a57600080fd5b505081359360208301359350604090920135919050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156130c7576130c761309d565b5060010190565b600082198211156130e1576130e161309d565b500190565b60005b838110156131015781810151838201526020016130e9565b838111156115525750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161314a8160178501602088016130e6565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161317b8160288401602088016130e6565b01602801949350505050565b60208152600082518060208401526131a68160408501602087016130e6565b601f01601f19169190910160400192915050565b6000828210156131cc576131cc61309d565b500390565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b60006001600160401b038216806126a9576126a961309d565b60008160001904831182151516156132305761323061309d565b500290565b60006020828403121561324757600080fd5b5051919050565b634e487b7160e01b600052601260045260246000fd5b6000826132735761327361324e565b500690565b6000826132875761328761324e565b500490565b60006001600160401b03808316818516818304811182151516156132b2576132b261309d565b02949350505050565b60006001600160401b03808316818114156132d8576132d861309d565b6001019392505050565b6000816132f1576132f161309d565b50600019019056fe66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a518f8c450dae5029cd48cd91dd9db65da48fb742893edfc7941250f6721d93cbbe9a627a5d4aa7c17f87ff26e3fe9a42c2b6c559e8b41a42282d0ecebb17c0e4d3a264697066735822122098f321a15e730c34a6d98fbc280e4f867ee1796f076d47af61947cde4af9e1a564736f6c634300080900339a627a5d4aa7c17f87ff26e3fe9a42c2b6c559e8b41a42282d0ecebb17c0e4d3 \ No newline at end of file diff --git a/tests/fork/test_csm_oracle_cycle.py b/tests/fork/test_csm_oracle_cycle.py new file mode 100644 index 000000000..c36d99d70 --- /dev/null +++ b/tests/fork/test_csm_oracle_cycle.py @@ -0,0 +1,80 @@ +import pytest + +from src.modules.csm.csm import CSOracle +from src.modules.submodules.types import FrameConfig +from src.utils.range import sequence +from src.web3py.types import Web3 +from tests.fork.conftest import first_slot_of_epoch + + +@pytest.fixture() +def hash_consensus_bin(): + with open('tests/fork/contracts/csm/HashConsensus_bin', 'r') as f: + yield f.read() + + +@pytest.fixture() +def csm_module(web3: Web3): + yield CSOracle(web3) + + +@pytest.fixture +def start_before_initial_epoch(frame_config: FrameConfig): + _from = frame_config.initial_epoch - 1 + _to = frame_config.initial_epoch + 4 + return [first_slot_of_epoch(i) for i in sequence(_from, _to)] + + +@pytest.fixture +def start_after_initial_epoch(frame_config: FrameConfig): + _from = frame_config.initial_epoch + 1 + _to = frame_config.initial_epoch + 4 + return [first_slot_of_epoch(i) for i in sequence(_from, _to)] + + +@pytest.fixture +def missed_initial_frame(frame_config: FrameConfig): + _from = frame_config.initial_epoch + frame_config.epochs_per_frame + 1 + _to = _from + 4 + return [first_slot_of_epoch(i) for i in sequence(_from, _to)] + + +@pytest.mark.fork +@pytest.mark.parametrize( + 'module', + [csm_module], + indirect=True, +) +@pytest.mark.parametrize( + 'running_finalized_slots', + [start_before_initial_epoch, start_after_initial_epoch, missed_initial_frame], + indirect=True, +) +def test_csm_module_report(module, set_oracle_members, running_finalized_slots, account_from): + assert module.report_contract.get_last_processing_ref_slot() == 0, "Last processing ref slot should be 0" + members = set_oracle_members(count=2) + + report_frame = None + to_distribute_before_report = module.w3.csm.fee_distributor.shares_to_distribute() + + switch_finalized, _ = running_finalized_slots + # pylint:disable=duplicate-code + while switch_finalized(): + for _, private_key in members: + # NOTE: reporters using the same cache + with account_from(private_key): + module.cycle_handler() + report_frame = module.get_initial_or_current_frame( + module._receive_last_finalized_slot() # pylint: disable=protected-access + ) + + last_processing_after_report = module.w3.csm.oracle.get_last_processing_ref_slot() + assert ( + last_processing_after_report == report_frame.ref_slot + ), "Last processing ref slot should equal to initial ref slot" + + to_distribute_after_report = module.w3.csm.fee_distributor.shares_to_distribute() + assert to_distribute_after_report < to_distribute_before_report, "Shares to distribute should decrease" + + nos_count = int(module.w3.csm.module.functions.getNodeOperatorsCount().call()) + assert to_distribute_after_report <= nos_count, "Dust after distribution should be less or equal to NOs count" diff --git a/tests/fork/test_lido_oracle_cycle.py b/tests/fork/test_lido_oracle_cycle.py new file mode 100644 index 000000000..d13c68bb4 --- /dev/null +++ b/tests/fork/test_lido_oracle_cycle.py @@ -0,0 +1,76 @@ +import pytest + +from src.modules.accounting.accounting import Accounting +from src.modules.ejector.ejector import Ejector +from src.modules.submodules.types import FrameConfig +from src.utils.range import sequence +from tests.fork.conftest import first_slot_of_epoch + + +@pytest.fixture() +def hash_consensus_bin(): + with open('tests/fork/contracts/lido/HashConsensus_bin', 'r') as f: + yield f.read() + + +@pytest.fixture +def accounting_module(web3): + yield Accounting(web3) + + +@pytest.fixture +def ejector_module(web3): + yield Ejector(web3) + + +@pytest.fixture +def start_before_initial_epoch(frame_config: FrameConfig): + _from = frame_config.initial_epoch - 1 + _to = frame_config.initial_epoch + 2 + return [first_slot_of_epoch(i) for i in sequence(_from, _to)] + + +@pytest.fixture +def start_after_initial_epoch(frame_config: FrameConfig): + _from = frame_config.initial_epoch + 1 + _to = frame_config.initial_epoch + 2 + return [first_slot_of_epoch(i) for i in sequence(_from, _to)] + + +@pytest.fixture +def missed_initial_frame(frame_config: FrameConfig): + _from = frame_config.initial_epoch + frame_config.epochs_per_frame + 1 + _to = _from + 2 + return [first_slot_of_epoch(i) for i in sequence(_from, _to)] + + +@pytest.mark.fork +@pytest.mark.parametrize( + 'module', + [accounting_module, ejector_module], + indirect=True, +) +@pytest.mark.parametrize( + 'running_finalized_slots', + [start_before_initial_epoch, start_after_initial_epoch, missed_initial_frame], + indirect=True, +) +def test_lido_module_report(module, set_oracle_members, running_finalized_slots, account_from): + assert module.report_contract.get_last_processing_ref_slot() == 0, "Last processing ref slot should be 0" + members = set_oracle_members(count=2) + + report_frame = None + + switch_finalized, _ = running_finalized_slots + while switch_finalized(): + for _, private_key in members: + with account_from(private_key): + module.cycle_handler() + report_frame = module.get_initial_or_current_frame( + module._receive_last_finalized_slot() # pylint: disable=protected-access + ) + + last_processing_after_report = module.report_contract.get_last_processing_ref_slot() + assert ( + last_processing_after_report == report_frame.ref_slot + ), "Last processing ref slot should equal to report ref slot" diff --git a/tests/modules/accounting/test_accounting_module.py b/tests/modules/accounting/test_accounting_module.py index c0124b555..c0e475671 100644 --- a/tests/modules/accounting/test_accounting_module.py +++ b/tests/modules/accounting/test_accounting_module.py @@ -157,7 +157,7 @@ def test_get_slots_elapsed_from_initialize(accounting: Accounting): bs = ReferenceBlockStampFactory.build(ref_slot=100) slots_elapsed = accounting._get_slots_elapsed_from_last_report(bs) - assert slots_elapsed == 100 - 32 * 2 + assert slots_elapsed == 100 - 32 * 2 + 1 @pytest.mark.unit