From e9e9b80d95d9e8a83cd3cf0bcb752be4cad2373a Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Wed, 6 Nov 2024 18:40:38 +0100 Subject: [PATCH 01/27] feat: add test for csm on mainnet fork --- assets/HashConsensus.json | 2 +- tests/fork/csm/conftest.py | 0 tests/fork/csm/test_execute_module.py | 361 ++++++++++++++++++++++++++ 3 files changed, 362 insertions(+), 1 deletion(-) create mode 100644 tests/fork/csm/conftest.py create mode 100644 tests/fork/csm/test_execute_module.py 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/tests/fork/csm/conftest.py b/tests/fork/csm/conftest.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/fork/csm/test_execute_module.py b/tests/fork/csm/test_execute_module.py new file mode 100644 index 000000000..21893658c --- /dev/null +++ b/tests/fork/csm/test_execute_module.py @@ -0,0 +1,361 @@ +import subprocess +import time +import json +from dataclasses import dataclass +from typing import cast + +from eth_account import Account +import pytest +from eth_abi.packed import encode_packed +from web3 import Web3 +from web3.middleware import construct_simple_cache_middleware +from web3_multi_provider import MultiProvider + +from src import variables +from src.main import ipfs_providers +from src.modules.csm.checkpoint import FrameCheckpointsIterator +from src.modules.csm.csm import CSOracle, logger +from src.modules.submodules.oracle_module import ModuleExecuteDelay +from src.providers.consensus.client import ConsensusClient, LiteralState +from src.providers.consensus.types import BlockDetailsResponse, BlockRootResponse +from src.providers.execution.contracts.hash_consensus import HashConsensusContract +from src.providers.ipfs import MultiIPFSProvider, CID +from src.types import BlockRoot, SlotNumber +from src.utils.blockstamp import build_blockstamp +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 ( + CSM, + LidoContracts, + LidoValidatorsProvider, + TransactionUtils, + ConsensusClientModule, + KeysAPIClientModule, +) + + +@dataclass +class FrameConfig: + fast_lane: int + frame_size: int + initial_epoch: int + + +frame_config = FrameConfig( + fast_lane=0, + frame_size=10, + initial_epoch=322715, +) + + +@pytest.fixture +def running_slots(request): + slots = request.param + iterator = iter(slots) + current = slots[0] + + def get_current() -> SlotNumber | None: + nonlocal current + return current + + def get_next() -> SlotNumber | None: + nonlocal current + try: + current = next(iterator) + except StopIteration: + current = None + return current + + return get_next, get_current + + +@pytest.fixture() +def adjust_min_checkpoint_step(monkeypatch): + with monkeypatch.context(): + monkeypatch.setattr( + FrameCheckpointsIterator, + "MIN_CHECKPOINT_STEP", + 0, + ) + yield + + +@pytest.fixture() +def pure_cl_client(): + yield 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 el_block_number_to_fork(request, pure_cl_client): + slot_for_fork = request.param + if not slot_for_fork: + raise ValueError("Slot for fork is not set in test parameters") + logger.info(f"Getting block number to fork from slot {slot_for_fork}") + block_details = pure_cl_client.get_block_details(slot_for_fork) + return int(block_details.message.body.execution_payload.block_number) + + +@pytest.fixture() +def run_fork(el_block_number_to_fork): + cli_params = [ + 'anvil', + '--config-out', + 'localhost.json', + '--auto-impersonate', + '-f', + variables.EXECUTION_CLIENT_URI[0], + '--fork-block-number', + str(el_block_number_to_fork), + ] + process = subprocess.Popen(cli_params, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + time.sleep(5) + logger.info(f"Started fork from block {el_block_number_to_fork}") + yield process + process.terminate() + process.wait() + subprocess.run(['rm', 'localhost.json']) + + +@pytest.fixture() +def provider(run_fork): + yield MultiProvider(['http://127.0.0.1:8545'], request_kwargs={'timeout': variables.HTTP_REQUEST_TIMEOUT_EXECUTION}) + + +@pytest.fixture() +def web3(provider) -> Web3: + web3 = Web3(provider) + tweak_w3_contracts(web3) + web3.middleware_onion.add(construct_simple_cache_middleware()) + web3.provider.make_request('anvil_setBlockTimestampInterval', [12]) + yield web3 + + +@pytest.fixture() +def fork_account(monkeypatch, web3): + with open('localhost.json') as f: + data = json.load(f) + address = data['available_accounts'][0] + private_key = data['private_keys'][0] + return web3.to_checksum_address(address), private_key + + +@pytest.fixture() +def set_account_from_fork(monkeypatch, fork_account): + _, private_key = fork_account + with monkeypatch.context(): + monkeypatch.setattr( + variables, + "ACCOUNT", + Account.from_key(private_key), + ) + yield + + +@pytest.fixture() +def consensus(web3): + consensus = cast( + HashConsensusContract, + web3.eth.contract( + # TODO: get from somewhere + address=web3.to_checksum_address("0x71093efF8D8599b5fA340D665Ad60fA7C80688e4"), + ContractFactoryClass=HashConsensusContract, + decode_tuples=True, + ), + ) + yield consensus + + +@pytest.fixture() +def set_frame_config(request, web3, consensus): + if not request.param: + raise ValueError("Frame config is not set in test parameters") + frame_config_tuple = (request.param.fast_lane, request.param.frame_size, request.param.initial_epoch) + encoded = encode_packed(('uint64', 'uint64', 'uint64'), frame_config_tuple).rjust(32, b'\0') + web3.provider.make_request('anvil_setStorageAt', [consensus.address, hex(0), '0x' + encoded.hex()]) + + +@pytest.fixture() +def use_fork_account_as_reporter(web3, consensus, set_account_from_fork, fork_account): + + DEFAULT_ADMIN_ROLE = "0x" + consensus.functions.DEFAULT_ADMIN_ROLE().call().hex() + MANAGE_MEMBERS_AND_QUORUM_ROLE = "0x" + consensus.functions.MANAGE_MEMBERS_AND_QUORUM_ROLE().call().hex() + + hash_consensus_admin = consensus.functions.getRoleMember(DEFAULT_ADMIN_ROLE, 0).call() + + web3.provider.make_request('anvil_setBalance', [hash_consensus_admin, hex(10**18)]) + + address, _ = fork_account + + tx_grant_role = consensus.functions.grantRole(DEFAULT_ADMIN_ROLE, address) + web3.eth.send_transaction(tx_grant_role.build_transaction({'from': hash_consensus_admin})) + + tx_grant_role = consensus.functions.grantRole(MANAGE_MEMBERS_AND_QUORUM_ROLE, address) + web3.eth.send_transaction(tx_grant_role.build_transaction({'from': address})) + + current_quorum = consensus.functions.getQuorum().call() + tx_add_member = consensus.functions.addMember(address, current_quorum + 1) + web3.eth.send_transaction(tx_add_member.build_transaction({'from': address})) + + +@pytest.fixture() +def adjust_cl_client(monkeypatch, web3, running_slots): + + get_next, get_current = running_slots + + def get_block_root(self, state_id: SlotNumber | BlockRoot | LiteralState) -> BlockRootResponse: + """ + Spec: https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockRoot + + There is no cache because this method is used to get finalized and head blocks. + """ + + def _inner(_state_id: SlotNumber | BlockRoot | LiteralState): + data, _ = self._get( + self.API_GET_BLOCK_ROOT, + path_params=(_state_id,), + ) + if not isinstance(data, dict): + raise ValueError("Expected mapping response from getBlockRoot") + return BlockRootResponse.from_response(**data) + + if state_id not in ['head', 'genesis', 'finalized', 'justified']: + return _inner(state_id) + + if state_id == 'finalized': + current = get_current() + if not current: + raise ValueError("No current running slot number available") + return _inner(current) + + if state_id == 'head': + current = get_current() + if not current: + raise ValueError("No current running slot number available") + latest = (((current * 32) + 1) // 32) + 32 + return _inner(SlotNumber(latest)) + + raise ValueError(f"Unknown state_id for patching: {state_id}") + + def get_block_details(self, state_id: SlotNumber | BlockRoot) -> BlockDetailsResponse: + """Spec: https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockV2""" + data, _ = self._get( + self.API_GET_BLOCK_DETAILS, + path_params=(state_id,), + ) + if not isinstance(data, dict): + raise ValueError("Expected mapping response from getBlockV2") + slot_details = BlockDetailsResponse.from_response(**data) + block_from_fork = None + while not block_from_fork: + try: + block_from_fork = web3.eth.get_block(int(slot_details.message.body.execution_payload.block_number)) + except Exception as e: + logger.error(f"Failed to get block from fork: {e}") + if not block_from_fork: + latest = web3.eth.get_block('latest') + diff = int(slot_details.message.body.execution_payload.block_number) - int(latest['number']) + for _ in range(diff): + web3.provider.make_request('evm_mine', []) + logger.info(f"Mined block {web3.eth.block_number}") + 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 + + with monkeypatch.context(): + monkeypatch.setattr( + ConsensusClient, + "get_block_details", + get_block_details, + ) + monkeypatch.setattr( + ConsensusClient, + "get_block_root", + get_block_root, + ) + yield + + +@pytest.fixture() +def adjust_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, + ) + yield + + +@pytest.fixture() +def module(web3, adjust_ipfs_client, adjust_cl_client, adjust_min_checkpoint_step): + cc = ConsensusClientModule(variables.CONSENSUS_CLIENT_URI, web3) + kac = KeysAPIClientModule(variables.KEYS_API_URI, web3) + ipfs = MultiIPFSProvider(ipfs_providers()) + web3.attach_modules( + { + 'lido_contracts': LidoContracts, + 'lido_validators': LidoValidatorsProvider, + 'transaction': TransactionUtils, + 'cc': lambda: cc, # type: ignore[dict-item] + 'kac': lambda: kac, # type: ignore[dict-item] + "ipfs": lambda: ipfs, + "csm": CSM, + } + ) + _module = CSOracle(web3) + yield _module + subprocess.run(['rm', 'cache.pkl']) + + +def first_slot_of_epoch(epoch: int) -> SlotNumber: + return SlotNumber(epoch * 32 - 31) + + +@pytest.mark.mainnet_fork +@pytest.mark.parametrize( + 'el_block_number_to_fork', [SlotNumber((frame_config.initial_epoch - 1) * 32 - 31)], indirect=True +) +@pytest.mark.parametrize('set_frame_config', [frame_config], indirect=True) +@pytest.mark.parametrize( + 'running_slots', + [ + [first_slot_of_epoch(i) for i in range(frame_config.initial_epoch - 1, frame_config.initial_epoch + 4)], + [first_slot_of_epoch(i) for i in range(frame_config.initial_epoch + 1, frame_config.initial_epoch + 4)], + ], + ids=['start_before_initial_epoch', 'start_after_initial_epoch'], + indirect=True, +) +def test_execute_module( + el_block_number_to_fork, + set_frame_config, + set_account_from_fork, + use_fork_account_as_reporter, + running_slots, + module: CSOracle, +): + delay = -1 + + get_next, _ = running_slots + + while sn := get_next(): + block_root = BlockRoot(module.w3.cc.get_block_root(sn).root) + block_details = module.w3.cc.get_block_details(block_root) + bs = build_blockstamp(block_details) + + delay = module.execute_module(last_finalized_blockstamp=bs) + + assert delay == ModuleExecuteDelay.NEXT_SLOT + # TODO: check that report was published From 15672af698cbe9b9b02f933122b39b8cd854178f Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Fri, 8 Nov 2024 11:24:49 +0100 Subject: [PATCH 02/27] fix: make it network-agnostic --- tests/fork/csm/test_execute_module.py | 238 ++++++++++++++++---------- 1 file changed, 143 insertions(+), 95 deletions(-) diff --git a/tests/fork/csm/test_execute_module.py b/tests/fork/csm/test_execute_module.py index 21893658c..1b00dbed4 100644 --- a/tests/fork/csm/test_execute_module.py +++ b/tests/fork/csm/test_execute_module.py @@ -6,7 +6,6 @@ from eth_account import Account import pytest -from eth_abi.packed import encode_packed from web3 import Web3 from web3.middleware import construct_simple_cache_middleware from web3_multi_provider import MultiProvider @@ -15,13 +14,13 @@ from src.main import ipfs_providers from src.modules.csm.checkpoint import FrameCheckpointsIterator from src.modules.csm.csm import CSOracle, logger -from src.modules.submodules.oracle_module import ModuleExecuteDelay from src.providers.consensus.client import ConsensusClient, LiteralState from src.providers.consensus.types import BlockDetailsResponse, BlockRootResponse from src.providers.execution.contracts.hash_consensus import HashConsensusContract from src.providers.ipfs import MultiIPFSProvider, CID from src.types import BlockRoot, SlotNumber from src.utils.blockstamp import build_blockstamp +from src.utils.slot import get_next_non_missed_slot from src.variables import ( HTTP_REQUEST_TIMEOUT_CONSENSUS, HTTP_REQUEST_RETRY_COUNT_CONSENSUS, @@ -45,11 +44,33 @@ class FrameConfig: initial_epoch: int +pure_cl_client = ConsensusClient( + variables.CONSENSUS_CLIENT_URI, + HTTP_REQUEST_TIMEOUT_CONSENSUS, + HTTP_REQUEST_RETRY_COUNT_CONSENSUS, + HTTP_REQUEST_SLEEP_BEFORE_RETRY_IN_SECONDS_CONSENSUS, +) + +genesis_time = int(pure_cl_client.get_genesis().genesis_time) +logger.info(f"Genesis time on CL: {genesis_time}") + +finalized_slot = SlotNumber(int(pure_cl_client.get_block_header('finalized').data.header.message.slot)) +logger.info(f"Finalized slot on CL: {finalized_slot}") + frame_config = FrameConfig( fast_lane=0, frame_size=10, - initial_epoch=322715, + initial_epoch=(finalized_slot // 32) - 20, # step back 20 epochs (~2h) from last finalized epoch ) +logger.info(f"Frame config to set: {frame_config}") + +slot_for_fork = SlotNumber((frame_config.initial_epoch - 3) * 32 - 31) +logger.info(f"Slot to fork {slot_for_fork}") + +el_block_number_to_fork = int( + pure_cl_client.get_block_details(slot_for_fork).message.body.execution_payload.block_number +) +logger.info(f"Block number to fork {el_block_number_to_fork}") @pytest.fixture @@ -74,7 +95,7 @@ def get_next() -> SlotNumber | None: @pytest.fixture() -def adjust_min_checkpoint_step(monkeypatch): +def zero_min_checkpoint_step(monkeypatch): with monkeypatch.context(): monkeypatch.setattr( FrameCheckpointsIterator, @@ -85,27 +106,7 @@ def adjust_min_checkpoint_step(monkeypatch): @pytest.fixture() -def pure_cl_client(): - yield 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 el_block_number_to_fork(request, pure_cl_client): - slot_for_fork = request.param - if not slot_for_fork: - raise ValueError("Slot for fork is not set in test parameters") - logger.info(f"Getting block number to fork from slot {slot_for_fork}") - block_details = pure_cl_client.get_block_details(slot_for_fork) - return int(block_details.message.body.execution_payload.block_number) - - -@pytest.fixture() -def run_fork(el_block_number_to_fork): +def run_fork(): cli_params = [ 'anvil', '--config-out', @@ -140,70 +141,94 @@ def web3(provider) -> Web3: @pytest.fixture() -def fork_account(monkeypatch, web3): +def fork_accounts(monkeypatch, web3): with open('localhost.json') as f: data = json.load(f) - address = data['available_accounts'][0] - private_key = data['private_keys'][0] - return web3.to_checksum_address(address), private_key + addresses = data['available_accounts'] + private_keys = data['private_keys'] + return [web3.to_checksum_address(address) for address in addresses], private_keys @pytest.fixture() -def set_account_from_fork(monkeypatch, fork_account): - _, private_key = fork_account - with monkeypatch.context(): - monkeypatch.setattr( - variables, - "ACCOUNT", - Account.from_key(private_key), - ) - yield +def consensus(web3): + csm = CSM(web3) -@pytest.fixture() -def consensus(web3): - consensus = cast( + # Contract Creation Code from etherscan without last bytes + hash_consensus_bin = "0x60e060405234801562000010575f80fd5b50604051620036f6380380620036f68339810160408190526200003391620005aa565b865f03620000545760405163fb305deb60e01b815260040160405180910390fd5b855f03620000755760405163fb305deb60e01b815260040160405180910390fd5b6200008087620001a3565b6001600160401b03166080526200009786620001a3565b6001600160401b031660a052620000ae85620001a3565b6001600160401b031660c0526001600160a01b038216620000e257604051636b35b1b760e01b815260040160405180910390fd5b6001600160a01b0381166200010a5760405163154f6dd160e31b815260040160405180910390fd5b620001165f83620001e1565b505f6200012a6001600160401b036200023e565b90506200017581868660405180606001604052805f6001600160401b031681526020015f6001600160401b031681526020015f6001600160401b03168152506200025460201b60201c565b50600880546001600160a01b0319166001600160a01b03929092169190911790555062000671945050505050565b5f6001600160401b03821115620001dd57604080516306dfcc6560e41b815260048101919091526024810183905260440160405180910390fd5b5090565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e823717059320008162000210858562000406565b9050801562000234575f858152602083905260409020620002329085620004d6565b505b9150505b92915050565b5f620002386200024e83620004f3565b62000525565b825f03620002755760405163ef3d10c160e01b815260040160405180910390fd5b6080516200028d906001600160401b03168462000621565b821115620002ae576040516385b552e160e01b815260040160405180910390fd5b6040518060600160405280620002ca86620001a360201b60201c565b6001600160401b03168152602001620002e385620001a3565b6001600160401b03168152602001620002fc84620001a3565b6001600160401b0390811690915281515f805460208501516040909501518416600160801b02600160801b600160c01b031995851668010000000000000000026001600160801b0319909216938516939093171793909316179091558151168414158062000377575080602001516001600160401b03168314155b15620003b75760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b0316821462000400576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15b50505050565b5f8281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff16620004cc575f848152602082815260408083206001600160a01b03871684529091529020805460ff19166001179055620004813390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4600191505062000238565b5f91505062000238565b5f620004ec836001600160a01b0384166200053f565b9392505050565b5f60a0516001600160401b031660c0516001600160401b0316836200051991906200063b565b62000238919062000651565b5f6080516001600160401b03168262000238919062000651565b5f8181526001830160205260408120546200058657508154600181810184555f84815260208082209093018490558454848252828601909352604090209190915562000238565b505f62000238565b80516001600160a01b0381168114620005a5575f80fd5b919050565b5f805f805f805f60e0888a031215620005c1575f80fd5b8751965060208801519550604088015194506060880151935060808801519250620005ef60a089016200058e565b9150620005ff60c089016200058e565b905092959891949750929550565b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176200023857620002386200060d565b818103818111156200023857620002386200060d565b5f826200066c57634e487b7160e01b5f52601260045260245ffd5b500490565b60805160a05160c05161301b620006db5f395f81816103d1015281816117c70152612c8201525f81816103ad0152818161179d0152612c4e01525f81816103890152818161128a015281816119c70152818161252b015281816125c70152612ae0015261301b5ff3fe608060405234801561000f575f80fd5b5060043610610213575f3560e01c80636fb1bf661161011f578063ad231cb2116100a9578063d547741f11610079578063d547741f14610619578063e33a8d391461062c578063e76cd4e01461063f578063ea87627d14610652578063fb4209ac14610677575f80fd5b8063ad231cb2146105e3578063c1ba4e59146105eb578063c26c12eb146105fe578063ca15c87314610606575f80fd5b806398041ea3116100ef57806398041ea31461058757806399229f581461059a5780639eab5253146105ad578063a1e07cac146105b5578063a217fddf146105dc575f80fd5b80636fb1bf66146104d157806372f79b13146105135780639010d07c1461053057806391d1485414610543575f80fd5b8063323a41f6116101a0578063606c0c9411610170578063606c0c941461037c5780636095012f1461040f57806360a50a5c1461041757806360e618011461043e5780636d058268146104ac575f80fd5b8063323a41f61461032d57806334aa67531461034057806336568abe14610353578063433ab1f314610366575f80fd5b806320b4d751116101e657806320b4d7511461029c578063239c327f146102af578063248a9ca3146102d65780632f2ff15d146103045780632fd2d75014610317575f80fd5b806301ffc9a714610217578063115a57c41461023f57806316f6f03e146102745780631951c03714610289575b5f80fd5b61022a610225366004612ca7565b61069e565b60405190151581526020015b60405180910390f35b6102667f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe81565b604051908152602001610236565b610287610282366004612ce9565b6106c8565b005b61022a610297366004612d11565b610701565b61022a6102aa366004612d11565b610720565b6102667f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d671781565b6102666102e4366004612d2a565b5f9081525f80516020612fef833981519152602052604090206001015490565b610287610312366004612d41565b61075e565b61031f610794565b604051610236929190612da5565b61028761033b366004612d2a565b6108db565b61028761034e366004612df2565b61099e565b610287610361366004612d41565b610a5e565b61036e610a91565b604051610236929190612e12565b6103f46001600160401b037f00000000000000000000000000000000000000000000000000000000000000008116917f00000000000000000000000000000000000000000000000000000000000000008216917f00000000000000000000000000000000000000000000000000000000000000001690565b60408051938452602084019290925290820152606001610236565b610266610aa6565b6102667f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc081565b61045161044c366004612d11565b610ab8565b60405161023691905f60e082019050825182526020830151602083015260408301511515604083015260608301511515606083015260808301511515608083015260a083015160a083015260c083015160c083015292915050565b6008546001600160a01b03165b6040516001600160a01b039091168152602001610236565b604080516060810182525f546001600160401b03808216808452600160401b8304821660208501819052600160801b90930490911692909301829052906103f4565b61051b610c59565b60408051928352602083019190915201610236565b6104b961053e366004612df2565b610c79565b61022a610551366004612d41565b5f9182525f80516020612fef833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b610287610595366004612ce9565b610cb9565b6102876105a8366004612d2a565b610ced565b61036e610d24565b6102667f66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a5181565b6102665f81565b610287610d30565b6102876105f9366004612d2a565b610d41565b600554610266565b610266610614366004612d2a565b610d52565b610287610627366004612d41565b610d89565b61028761063a366004612e53565b610db9565b61028761064d366004612d11565b610dc4565b61065a610df7565b604080519384526020840192909252151590820152606001610236565b6102667fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e81565b5f6001600160e01b03198216635a05180f60e01b14806106c257506106c282610e2b565b92915050565b7f66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a516106f281610e5f565b6106fc8383610e69565b505050565b6001600160a01b0381165f9081526003602052604081205415156106c2565b6001600160a01b0381165f908152600360205260408120548015801590610757575061075760018203610751611157565b516111bd565b9392505050565b5f8281525f80516020612fef833981519152602052604090206001015461078481610e5f565b61078e83836111f6565b50505050565b60608061079f611157565b602001516004546001600160401b0316146107b8579091565b600754806001600160401b038111156107d3576107d3612e7c565b6040519080825280602002602001820160405280156107fc578160200160208202803683370190505b509250806001600160401b0381111561081757610817612e7c565b604051908082528060200260200182016040528015610840578160200160208202803683370190505b5091505f5b818110156108d5575f81815260066020908152604091829020825180840190935280548084526001909101546001600160401b031691830191909152855186908490811061089557610895612e90565b60200260200101818152505080602001516001600160401b03168483815181106108c1576108c1612e90565b602090810291909101015250600101610845565b50509091565b5f6108e581610e5f565b604080516060810182525f546001600160401b03808216808452600160401b830482166020850152600160801b9092041692820192909252906109274261124b565b10610945576040516329d1e0ff60e01b815260040160405180910390fd5b61096b8382602001516001600160401b031683604001516001600160401b03168461125d565b610973611414565b61097b61147f565b6020015110156106fc576040516323ca23a760e21b815260040160405180910390fd5b7f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe6109c881610e5f565b604080516060810182525f80546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252429190610a0e9083906114e2565b604080516060810182525f546001600160401b038082168352600160401b820481166020840152600160801b9091041691810191909152909150610a579082908790879061125d565b5050505050565b6001600160a01b0381163314610a875760405163334bd91960e11b815260040160405180910390fd5b6106fc82826114f6565b606080610a9e6001611542565b915091509091565b5f610aaf61147f565b60200151905090565b6040805160e0810182525f80825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905290610af8611157565b602081018051845251600554919250610b109161170e565b50506020808401919091526001600160a01b0384165f908152600390915260409081902054801580159285019290925290610c5257806001900390505f60018281548110610b6057610b60612e90565b5f918252602091829020604080518082019091529101546001600160401b03808216808452600160401b909204168284015260a087018190529185015190925014610bab575f610bc9565b6020808201516001600160401b03165f908152600690915260409020545b60c08501525f610bd84261179a565b905083604001518111158015610bf85750610bf1611414565b8460200151115b151560808601528351610c0c9084906111bd565b15801560608701819052610c21575084608001515b15610c4f575f546020850151610c4791600160801b90046001600160401b031690612eb8565b811160808601525b50505b5050919050565b5f805f610c64611157565b90508060200151816040015192509250509091565b5f8281527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000602081905260408220610cb19084611804565b949350505050565b7f66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a51610ce381610e5f565b6106fc838361180f565b7f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d6717610d1781610e5f565b610d2082611987565b5050565b606080610a9e5f611542565b600154610d3f905f1990611a94565b565b600154610d4f908290611a94565b50565b5f8181527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200060208190526040822061075790611bb0565b5f8281525f80516020612fef8339815191526020526040902060010154610daf81610e5f565b61078e83836114f6565b6106fc838383611bb9565b7fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e610dee81610e5f565b610d2082612101565b5f805f610e02611157565b602001519250610e148360055461170e565b50909250839050610e23611414565b149050909192565b5f6001600160e01b03198216637965db0b60e01b14806106c257506301ffc9a760e01b6001600160e01b03198316146106c2565b610d4f8133612300565b5f610e7383612360565b600180549192505f91610e869190612ecb565b905080821115610e9857610e98612ede565b5f60018381548110610eac57610eac612e90565b5f918252602091829020604080518082019091529101546001600160401b038082168352600160401b90910416918101919091529050828214610ff6575f60028381548110610efd57610efd612e90565b5f91825260209091200154600280546001600160a01b039092169250829186908110610f2b57610f2b612e90565b905f5260205f20015f6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060018381548110610f6957610f69612e90565b905f5260205f200160018581548110610f8457610f84612e90565b5f91825260209091208254910180546001600160401b0392831667ffffffffffffffff1982168117835593546001600160801b0319909116909317600160401b93849004909216909202179055610fdc846001612eb8565b6001600160a01b039091165f908152600360205260409020555b600180548061100757611007612ef2565b5f8281526020902081015f1990810180546001600160801b0319169055019055600280548061103857611038612ef2565b5f82815260208082205f19908401810180546001600160a01b03191690559092019092556001600160a01b038716808352600382526040808420939093558251858152918201879052917fa182730913550d27dc6c5813fad297cb0785871bec3d0152c5650e59c5d39d60910160405180910390a280516001600160401b03161561114d575f6110c6611157565b90508060200151825f01516001600160401b03161480156110f1575080602001516110ef611414565b105b1561114b576020808301516001600160401b039081165f90815260069092526040822060010180549092916111269116612f06565b91906101000a8154816001600160401b0302191690836001600160401b031602179055505b505b610a578483611a94565b61117860405180606001604052805f81526020015f81526020015f81525090565b6111b842604080516060810182525f546001600160401b038082168352600160401b820481166020840152600160801b90910416918101919091526123a1565b905090565b6001545f9081806111ce85846123d5565b91509150805f141580156111ec57506111ec8683600184038661240f565b9695505050505050565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000816112238585612450565b90508015610cb1575f8581526020839052604090206112429085612509565b50949350505050565b5f6106c26112588361179a565b61251d565b825f0361127d5760405163ef3d10c160e01b815260040160405180910390fd5b6112b06001600160401b037f00000000000000000000000000000000000000000000000000000000000000001684612f1e565b8211156112d0576040516385b552e160e01b815260040160405180910390fd5b60405180606001604052806112e486612551565b6001600160401b031681526020016112fb85612551565b6001600160401b0316815260200161131284612551565b6001600160401b0390811690915281515f805460208501516040909501518416600160801b0267ffffffffffffffff60801b19958516600160401b026001600160801b03199092169385169390931717939093161790915581511684141580611388575080602001516001600160401b03168314155b156113c75760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b0316821461078e576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a150505050565b60085460408051630d61356760e21b815290515f926001600160a01b031691633584d59c9160048083019260209291908290030181865afa15801561145b573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111b89190612f35565b6114a060405180606001604052805f81526020015f81526020015f81525090565b604080516060810182525f80546001600160401b038082168452600160401b820481166020850152600160801b90910416928201929092526111b8919061258a565b5f6107576114f08484612661565b836126c2565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e823717059320008161152385856126f1565b90508015610cb1575f8581526020839052604090206112429085612782565b60015460609081905f80851561156e5761156461155d611157565b51846123d5565b9092509050611571565b50815b61157b8282612ecb565b6001600160401b0381111561159257611592612e7c565b6040519080825280602002602001820160405280156115bb578160200160208202803683370190505b50945084516001600160401b038111156115d7576115d7612e7c565b604051908082528060200260200182016040528015611600578160200160208202803683370190505b509350815b81811015611705575f6116188583612f60565b90505f6001828154811061162e5761162e612e90565b5f9182526020808320604080518082019091529201546001600160401b038082168452600160401b9091041690820152915061166a8685612ecb565b90506002838154811061167f5761167f612e90565b905f5260205f20015f9054906101000a90046001600160a01b03168982815181106116ac576116ac612e90565b60200260200101906001600160a01b031690816001600160a01b031681525050815f01516001600160401b03168882815181106116eb576116eb612e90565b602002602001018181525050505050806001019050611605565b50505050915091565b6004545f90819081906001600160401b0316851461173457505f91505f19905081611793565b50506007545f91505f19908290815b81811015611790575f818152600660205260409020600101546001600160401b0316868110611787575f828152600660205260409020549550909350915082611790565b50600101611743565b50505b9250925092565b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160401b03167f00000000000000000000000000000000000000000000000000000000000000006001600160401b0316836117fa9190612ecb565b6106c29190612f73565b5f6107578383612796565b6001600160a01b0382165f908152600360205260409020541561184557604051637670720160e11b815260040160405180910390fd5b6001600160a01b03821661186c576040516303988b8160e61b815260040160405180910390fd5b6040805180820182525f808252602080830182815260018054808201825581855294517fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6909501805492516001600160401b03908116600160401b026001600160801b031990941696169590951791909117909355600280548085019091557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0388166001600160a01b03199091168117909155925483835260039091529083902081905591517fe17e0e2cd88e2144dd54f3d823c30d4569092bcac1aabaec1129883e9cc12d2e906119759084908690918252602082015260400190565b60405180910390a26106fc8282611a94565b604080516060810182525f546001600160401b038082168352600160401b8204811660208401819052600160801b9092041692820192909252906119ec907f000000000000000000000000000000000000000000000000000000000000000090612f86565b6001600160401b0316821115611a15576040516385b552e160e01b815260040160405180910390fd5b80604001516001600160401b03168214610d2057611a3282612551565b5f80546001600160401b0392909216600160801b0267ffffffffffffffff60801b199092169190911790556040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15050565b611a9f600282612f73565b8211611ae457611ab0600282612f73565b611abb906001612eb8565b604051632b2dd84d60e01b81526004810191909152602481018390526044015b60405180910390fd5b600554828114611b8e57611b475f198414611b1f577f66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a51611b41565b7f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc05b33612300565b600583905560408051848152602081018490529081018290527f9f40cfd22fe91777c78f252bd21a710f3fb007dc2f321876891e7644ba0ae1759060600160405180910390a15b5f546001600160401b0316611ba24261124b565b106106fc576106fc836127bc565b5f6106c2825490565b825f03611bd957604051631258e44360e01b815260040160405180910390fd5b6001600160401b03831115611c015760405163aac8f00960e01b815260040160405180910390fd5b81611c1e5760405162bf199760e01b815260040160405180910390fd5b5f611c2833612360565b90505f60018281548110611c3e57611c3e612e90565b5f9182526020808320604080518082019091529201546001600160401b038082168452600160401b90910416908201529150611c7861286c565b9050808414611ca457604051632a37dd3d60e11b81526004810182905260248101859052604401611adb565b425f611caf8261179a565b604080516060810182525f80546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252919250611cf484836123a1565b905080602001518a14611d1a57604051631258e44360e01b815260040160405180910390fd5b8060400151831115611d3f57604051637c01d16560e11b815260040160405180910390fd5b81604001516001600160401b03168160200151611d5c9190612eb8565b8311158015611d755750611d7387825f01516111bd565b155b15611d9357604051633e1ca93d60e01b815260040160405180910390fd5b611d9b611414565b8a11611dd75785516001600160401b03168a03611dcb57604051631cf7e8a160e31b815260040160405180910390fd5b50505050505050505050565b6004545f906001600160401b03168b14611e0e57506004805467ffffffffffffffff19166001600160401b038c161790555f611e13565b506007545b5f805b82826001600160401b0316108015611e4557506001600160401b0382165f908152600660205260409020548c14155b15611e5a57611e5382612fb1565b9150611e16565b88516001600160401b03168d03611f325760208901516001600160401b0381168411611e8857611e88612ede565b806001600160401b0316836001600160401b031603611eba5760405163fd10cf7360e01b815260040160405180910390fd5b6001600160401b038082165f9081526006602052604081206001018054919290918391611ee79116612f06565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b031690506001600554611f249190612ecb565b8103611f2f57600192505b50505b5f83836001600160401b03161015611fa0576001600160401b038084165f90815260066020526040812060010180549092611f6d9116612fb1565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b03169050612000565b506040805180820182528d8152600160208083018281526001600160401b038781165f9081526006909352949091209251835551918101805467ffffffffffffffff19169290931691909117909155611ff884612fd6565b600781905593505b60405180604001604052808f6001600160401b03168152602001846001600160401b031681525060018c8154811061203a5761203a612e90565b5f91825260209182902083519101805493909201516001600160401b03908116600160401b026001600160801b031990941691161791909117905561207c3390565b6001600160a01b03168e7f92f77576dabd7bad26f75c36abb3021b5bbb66a3e5688570a0355daddd4174888f6040516120b791815260200190565b60405180910390a360055481106120e2576120dd858e856001600160401b0316846128b3565b6120f1565b81156120f1576120f18561299b565b5050505050505050505050505050565b6008546001600160a01b0390811690821661212f5760405163154f6dd160e31b815260040160405180910390fd5b806001600160a01b0316826001600160a01b0316036121615760405163f1b3699f60e01b815260040160405180910390fd5b600880546001600160a01b0319166001600160a01b03848116918217909255604051918316917f3b59429457a41af89ea682ac9ed8abb8e99eb5c7d3363d5eedfc6bff6271a81e905f90a35f6121b5611157565b90505f60045f0160089054906101000a90046001600160401b03166001600160401b031690505f836001600160a01b0316633584d59c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612218573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061223c9190612f35565b90505f856001600160a01b0316633584d59c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561227b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061229f9190612f35565b90508360200151821080156122b75750836020015181105b80156122c65750836020015183145b156122f857600454600160801b90046001600160401b03165f908152600660205260409020546122f68582612a07565b505b505050505050565b5f8281525f80516020612fef833981519152602090815260408083206001600160a01b038516845290915290205460ff16610d205760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401611adb565b6001600160a01b0381165f9081526003602052604081205480820361239857604051638d35f2ed60e01b815260040160405180910390fd5b5f190192915050565b6123c260405180606001604052805f81526020015f81526020015f81525090565b6107576123cf8484612661565b8361258a565b6005545f9081908381106123ee575f9250839150612407565b6123f88486612f60565b92506124048184612eb8565b91505b509250929050565b5f8161241b8585612ecb565b6124259190612f60565b82856124318289612eb8565b61243b9190612ecb565b6124459190612f60565b111595945050505050565b5f8281525f80516020612fef833981519152602081815260408084206001600160a01b038616855290915282205460ff16612500575f848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556124b63390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506106c2565b5f9150506106c2565b5f610757836001600160a01b038416612a86565b5f6106c26001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683612f73565b5f6001600160401b0382111561258657604080516306dfcc6560e41b8152600481019190915260248101839052604401611adb565b5090565b6125ab60405180606001604052805f81526020015f81526020015f81525090565b5f6125b684846126c2565b90505f6125c282612ad2565b90505f7f000000000000000000000000000000000000000000000000000000000000000085602001516125f59190612f86565b612608906001600160401b031683612eb8565b905060405180606001604052808781526020016001846126289190612ecb565b6001600160401b031681526020015f612642600185612ecb565b61264c9190612ecb565b6001600160401b031690529695505050505050565b5f8061266c8461124b565b83519091506001600160401b031681101561269a5760405163668441f560e11b815260040160405180910390fd5b602083015183516001600160401b03918216916126b8911683612ecb565b610cb19190612f73565b5f81602001516001600160401b0316836126dc9190612f1e565b825161075791906001600160401b0316612eb8565b5f8281525f80516020612fef833981519152602081815260408084206001600160a01b038616855290915282205460ff1615612500575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506106c2565b5f610757836001600160a01b038416612b06565b5f825f0182815481106127ab576127ab612e90565b905f5260205f200154905092915050565b604080516060810182525f80546001600160401b038082168452600160401b820481166020850152600160801b90910416928201929092524291906128029083906123a1565b905080604001516128128361179a565b111561281d57505050565b806020015161282a611414565b1061283457505050565b5f805f61284584602001518761170e565b9250925092505f82126128635761285e848484846128b3565b6122f8565b6122f88461299b565b60085460408051635be2042560e01b815290515f926001600160a01b031691635be204259160048083019260209291908290030181865afa15801561145b573d5f803e3d5ffd5b6020840151600454600160401b90046001600160401b03161415806128ea5750600454600160801b90046001600160401b03168214155b1561078e576020840151600480546001600160401b03858116600160801b0267ffffffffffffffff60801b19918516600160401b02919091167fffffffffffffffff00000000000000000000000000000000ffffffffffffffff909216919091171790556040517f2b6bc782c916fa763822f1e50c6db0f95dade36d6541a8a4cbe070735b8b226d906129899086908590918252602082015260400190565b60405180910390a261078e8484612a07565b6020810151600454600160401b90046001600160401b031603610d4f57600480546fffffffffffffffff00000000000000001916905560208101516040517fde3f4ea5aa67881831e8fad2b0855d47e75aa63a2fae6ef657ffd5f856c4a613905f90a2610d4f81612be0565b600854602083015160408401516001600160a01b039092169163063f36ad918491612a3190612c40565b6040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064015f604051808303815f87803b158015612a74575f80fd5b505af11580156122f8573d5f803e3d5ffd5b5f818152600183016020526040812054612acb57508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556106c2565b505f6106c2565b5f6106c26001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683612f1e565b5f8181526001830160205260408120548015612500575f612b28600183612ecb565b85549091505f90612b3b90600190612ecb565b9050808214612b9a575f865f018281548110612b5957612b59612e90565b905f5260205f200154905080875f018481548110612b7957612b79612e90565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080612bab57612bab612ef2565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f9055600193505050506106c2565b600854602082015160405163d438121760e01b81526001600160a01b039092169163d438121791612c179160040190815260200190565b5f604051808303815f87803b158015612c2e575f80fd5b505af1158015610a57573d5f803e3d5ffd5b5f612c746001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683612f1e565b6106c2906001600160401b037f000000000000000000000000000000000000000000000000000000000000000016612eb8565b5f60208284031215612cb7575f80fd5b81356001600160e01b031981168114610757575f80fd5b80356001600160a01b0381168114612ce4575f80fd5b919050565b5f8060408385031215612cfa575f80fd5b612d0383612cce565b946020939093013593505050565b5f60208284031215612d21575f80fd5b61075782612cce565b5f60208284031215612d3a575f80fd5b5035919050565b5f8060408385031215612d52575f80fd5b82359150612d6260208401612cce565b90509250929050565b5f815180845260208085019450602084015f5b83811015612d9a57815187529582019590820190600101612d7e565b509495945050505050565b604080825283519082018190525f906020906060840190828701845b82811015612ddd57815184529284019290840190600101612dc1565b50505083810360208501526111ec8186612d6b565b5f8060408385031215612e03575f80fd5b50508035926020909101359150565b604080825283519082018190525f906020906060840190828701845b82811015612ddd5781516001600160a01b031684529284019290840190600101612e2e565b5f805f60608486031215612e65575f80fd5b505081359360208301359350604090920135919050565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b808201808211156106c2576106c2612ea4565b818103818111156106c2576106c2612ea4565b634e487b7160e01b5f52600160045260245ffd5b634e487b7160e01b5f52603160045260245ffd5b5f6001600160401b0382168061239857612398612ea4565b80820281158282048414176106c2576106c2612ea4565b5f60208284031215612f45575f80fd5b5051919050565b634e487b7160e01b5f52601260045260245ffd5b5f82612f6e57612f6e612f4c565b500690565b5f82612f8157612f81612f4c565b500490565b6001600160401b03818116838216028082169190828114612fa957612fa9612ea4565b505092915050565b5f6001600160401b03808316818103612fcc57612fcc612ea4565b6001019392505050565b5f60018201612fe757612fe7612ea4565b506001019056fe02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800a164736f6c6343000818000a" + + HashConsensus = web3.eth.contract(ContractFactoryClass=HashConsensusContract, bytecode=hash_consensus_bin) + + report_processor = web3.to_checksum_address(csm.oracle.address) + admin = web3.to_checksum_address(web3.eth.accounts[0]) + + tx = HashConsensus.constructor( + slotsPerEpoch=32, + secondsPerSlot=12, + genesisTime=genesis_time, + epochsPerFrame=frame_config.frame_size, + fastLaneLengthSlots=frame_config.fast_lane, + admin=admin, + reportProcessor=report_processor, + ) + + tx_receipt = web3.eth.wait_for_transaction_receipt(web3.eth.send_transaction(tx.build_transaction({'from': admin}))) + + new_consensus_address = tx_receipt.contractAddress + + new_consensus = web3.eth.contract(address=new_consensus_address, ContractFactoryClass=HashConsensusContract) + + DEFAULT_ADMIN_ROLE = "0x" + new_consensus.functions.DEFAULT_ADMIN_ROLE().call().hex() + default_admin = new_consensus.functions.getRoleMember(DEFAULT_ADMIN_ROLE, 0).call() + + new_initial_epoch = new_consensus.functions.updateInitialEpoch(frame_config.initial_epoch) + web3.eth.send_transaction(new_initial_epoch.build_transaction({'from': default_admin})) + + MANAGE_CONSENSUS_CONTRACT_ROLE = "0x" + csm.oracle.functions.MANAGE_CONSENSUS_CONTRACT_ROLE().call().hex() + oracle_admin = csm.oracle.functions.getRoleMember(DEFAULT_ADMIN_ROLE, 0).call() + web3.provider.make_request('anvil_setBalance', [oracle_admin, hex(10**18)]) + + tx_grant_role = csm.oracle.functions.grantRole(MANAGE_CONSENSUS_CONTRACT_ROLE, admin) + web3.eth.send_transaction(tx_grant_role.build_transaction({'from': oracle_admin})) + + tx = csm.oracle.functions.setConsensusContract(new_consensus_address) + web3.eth.send_transaction(tx.build_transaction({'from': admin})) + + storage_slot = web3.keccak(text="lido.BaseOracle.lastProcessingRefSlot") + web3.provider.make_request('anvil_setStorageAt', [csm.oracle.address, storage_slot, bytes(32)]) + + yield cast( HashConsensusContract, web3.eth.contract( - # TODO: get from somewhere - address=web3.to_checksum_address("0x71093efF8D8599b5fA340D665Ad60fA7C80688e4"), + address=new_consensus_address, ContractFactoryClass=HashConsensusContract, decode_tuples=True, ), ) - yield consensus @pytest.fixture() -def set_frame_config(request, web3, consensus): - if not request.param: - raise ValueError("Frame config is not set in test parameters") - frame_config_tuple = (request.param.fast_lane, request.param.frame_size, request.param.initial_epoch) - encoded = encode_packed(('uint64', 'uint64', 'uint64'), frame_config_tuple).rjust(32, b'\0') - web3.provider.make_request('anvil_setStorageAt', [consensus.address, hex(0), '0x' + encoded.hex()]) - - -@pytest.fixture() -def use_fork_account_as_reporter(web3, consensus, set_account_from_fork, fork_account): +def use_fork_accounts_as_reporters(web3, consensus, fork_accounts): + addresses, private_keys = fork_accounts DEFAULT_ADMIN_ROLE = "0x" + consensus.functions.DEFAULT_ADMIN_ROLE().call().hex() MANAGE_MEMBERS_AND_QUORUM_ROLE = "0x" + consensus.functions.MANAGE_MEMBERS_AND_QUORUM_ROLE().call().hex() hash_consensus_admin = consensus.functions.getRoleMember(DEFAULT_ADMIN_ROLE, 0).call() - web3.provider.make_request('anvil_setBalance', [hash_consensus_admin, hex(10**18)]) + # two first accounts are used for report + for address in addresses[:2]: + tx_grant_role = consensus.functions.grantRole(DEFAULT_ADMIN_ROLE, address) + web3.eth.send_transaction(tx_grant_role.build_transaction({'from': hash_consensus_admin})) - address, _ = fork_account + tx_grant_role = consensus.functions.grantRole(MANAGE_MEMBERS_AND_QUORUM_ROLE, address) + web3.eth.send_transaction(tx_grant_role.build_transaction({'from': address})) - tx_grant_role = consensus.functions.grantRole(DEFAULT_ADMIN_ROLE, address) - web3.eth.send_transaction(tx_grant_role.build_transaction({'from': hash_consensus_admin})) + current_quorum = consensus.functions.getQuorum().call() + tx_add_member = consensus.functions.addMember(address, current_quorum + 1) + web3.eth.send_transaction(tx_add_member.build_transaction({'from': address})) - tx_grant_role = consensus.functions.grantRole(MANAGE_MEMBERS_AND_QUORUM_ROLE, address) - web3.eth.send_transaction(tx_grant_role.build_transaction({'from': address})) - - current_quorum = consensus.functions.getQuorum().call() - tx_add_member = consensus.functions.addMember(address, current_quorum + 1) - web3.eth.send_transaction(tx_add_member.build_transaction({'from': address})) + return private_keys[:2] @pytest.fixture() @@ -227,21 +252,30 @@ def _inner(_state_id: SlotNumber | BlockRoot | LiteralState): raise ValueError("Expected mapping response from getBlockRoot") return BlockRootResponse.from_response(**data) - if state_id not in ['head', 'genesis', 'finalized', 'justified']: + if state_id not in ['justified', 'finalized', 'head']: return _inner(state_id) - if state_id == 'finalized': + if state_id in ['finalized', 'head']: current = get_current() if not current: raise ValueError("No current running slot number available") - return _inner(current) - if state_id == 'head': - current = get_current() - if not current: - raise ValueError("No current running slot number available") - latest = (((current * 32) + 1) // 32) + 32 - return _inner(SlotNumber(latest)) + if state_id == 'finalized': + finalized = get_next_non_missed_slot( + self, + current, + finalized_slot, + ).message.slot + return _inner(SlotNumber(int(finalized))) + + if state_id == 'head': + possible_head = (((current * 32) + 1) // 32) + 32 + head = get_next_non_missed_slot( + self, + SlotNumber(possible_head), + finalized_slot, + ).message.slot + return _inner(SlotNumber(int(head))) raise ValueError(f"Unknown state_id for patching: {state_id}") @@ -259,13 +293,13 @@ def get_block_details(self, state_id: SlotNumber | BlockRoot) -> BlockDetailsRes try: block_from_fork = web3.eth.get_block(int(slot_details.message.body.execution_payload.block_number)) except Exception as e: - logger.error(f"Failed to get block from fork: {e}") + logger.debug(f"FORKED CLIENT: {e}") if not block_from_fork: latest = web3.eth.get_block('latest') diff = int(slot_details.message.body.execution_payload.block_number) - int(latest['number']) for _ in range(diff): web3.provider.make_request('evm_mine', []) - logger.info(f"Mined block {web3.eth.block_number}") + logger.debug(f"FORKED CLIENT: Mined block {web3.eth.block_number}") 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'] @@ -286,7 +320,7 @@ def get_block_details(self, state_id: SlotNumber | BlockRoot) -> BlockDetailsRes @pytest.fixture() -def adjust_ipfs_client(monkeypatch): +def mock_ipfs_client(monkeypatch): def _publish(self, content: bytes, name: str | None = None) -> CID: return CID('Qm' + 'f' * 46) @@ -300,7 +334,7 @@ def _publish(self, content: bytes, name: str | None = None) -> CID: @pytest.fixture() -def module(web3, adjust_ipfs_client, adjust_cl_client, adjust_min_checkpoint_step): +def module(web3, mock_ipfs_client, zero_min_checkpoint_step, adjust_cl_client): cc = ConsensusClientModule(variables.CONSENSUS_CLIENT_URI, web3) kac = KeysAPIClientModule(variables.KEYS_API_URI, web3) ipfs = MultiIPFSProvider(ipfs_providers()) @@ -324,38 +358,52 @@ def first_slot_of_epoch(epoch: int) -> SlotNumber: return SlotNumber(epoch * 32 - 31) -@pytest.mark.mainnet_fork -@pytest.mark.parametrize( - 'el_block_number_to_fork', [SlotNumber((frame_config.initial_epoch - 1) * 32 - 31)], indirect=True -) -@pytest.mark.parametrize('set_frame_config', [frame_config], indirect=True) +@pytest.mark.fork @pytest.mark.parametrize( 'running_slots', [ - [first_slot_of_epoch(i) for i in range(frame_config.initial_epoch - 1, frame_config.initial_epoch + 4)], - [first_slot_of_epoch(i) for i in range(frame_config.initial_epoch + 1, frame_config.initial_epoch + 4)], + [first_slot_of_epoch(i) for i in range(frame_config.initial_epoch - 2, frame_config.initial_epoch + 6)], + [first_slot_of_epoch(i) for i in range(frame_config.initial_epoch + 2, frame_config.initial_epoch + 6)], ], ids=['start_before_initial_epoch', 'start_after_initial_epoch'], indirect=True, ) def test_execute_module( - el_block_number_to_fork, - set_frame_config, - set_account_from_fork, - use_fork_account_as_reporter, + monkeypatch, running_slots, + use_fork_accounts_as_reporters, + consensus, module: CSOracle, ): - delay = -1 get_next, _ = running_slots - while sn := get_next(): - block_root = BlockRoot(module.w3.cc.get_block_root(sn).root) + initial_ref_slot = consensus.get_initial_ref_slot() + to_distribute_before_report = module.w3.csm.fee_distributor.shares_to_distribute() + + while get_next(): + + block_root = BlockRoot(module.w3.cc.get_block_root('finalized').root) block_details = module.w3.cc.get_block_details(block_root) bs = build_blockstamp(block_details) - delay = module.execute_module(last_finalized_blockstamp=bs) - - assert delay == ModuleExecuteDelay.NEXT_SLOT - # TODO: check that report was published + for pk in use_fork_accounts_as_reporters: + if module.w3.csm.oracle.get_last_processing_ref_slot() == initial_ref_slot: + # finished, no need to continue trying to submit reports + break + with monkeypatch.context(): + monkeypatch.setattr( + variables, + "ACCOUNT", + Account.from_key(pk), + ) + module.execute_module(last_finalized_blockstamp=bs) + + last_processing_after_report = module.w3.csm.oracle.get_last_processing_ref_slot() + assert last_processing_after_report == initial_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" From 9d9be46368143cfb918cc556355306c712362519 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Tue, 26 Nov 2024 17:04:20 +0800 Subject: [PATCH 03/27] fix: run_cycle --- tests/fork/csm/test_execute_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fork/csm/test_execute_module.py b/tests/fork/csm/test_execute_module.py index 1b00dbed4..01efc6b08 100644 --- a/tests/fork/csm/test_execute_module.py +++ b/tests/fork/csm/test_execute_module.py @@ -397,7 +397,7 @@ def test_execute_module( "ACCOUNT", Account.from_key(pk), ) - module.execute_module(last_finalized_blockstamp=bs) + module.run_cycle(blockstamp=bs) last_processing_after_report = module.w3.csm.oracle.get_last_processing_ref_slot() assert last_processing_after_report == initial_ref_slot, "Last processing ref slot should equal to initial ref slot" From 074aa88df80fd76b9cada055c68fa2ca6bb93f69 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Tue, 17 Dec 2024 15:30:50 +0100 Subject: [PATCH 04/27] feat: add ejector and accounting fork tests --- tests/fork/{csm/conftest.py => __init__.py} | 0 tests/fork/conftest.py | 342 +++++++++++++++ .../contracts/accounting/HashConsensus_bin | 1 + tests/fork/contracts/csm/HashConsensus_bin | 1 + .../fork/contracts/ejector/HashConsensus_bin | 1 + tests/fork/csm/test_execute_module.py | 409 ------------------ tests/fork/test_accounting_cycle.py | 83 ++++ tests/fork/test_csm_cycle.py | 115 +++++ tests/fork/test_ejector_cycle.py | 83 ++++ 9 files changed, 626 insertions(+), 409 deletions(-) rename tests/fork/{csm/conftest.py => __init__.py} (100%) create mode 100644 tests/fork/conftest.py create mode 100644 tests/fork/contracts/accounting/HashConsensus_bin create mode 100644 tests/fork/contracts/csm/HashConsensus_bin create mode 100644 tests/fork/contracts/ejector/HashConsensus_bin delete mode 100644 tests/fork/csm/test_execute_module.py create mode 100644 tests/fork/test_accounting_cycle.py create mode 100644 tests/fork/test_csm_cycle.py create mode 100644 tests/fork/test_ejector_cycle.py diff --git a/tests/fork/csm/conftest.py b/tests/fork/__init__.py similarity index 100% rename from tests/fork/csm/conftest.py rename to tests/fork/__init__.py diff --git a/tests/fork/conftest.py b/tests/fork/conftest.py new file mode 100644 index 000000000..376c6af90 --- /dev/null +++ b/tests/fork/conftest.py @@ -0,0 +1,342 @@ +import json +import subprocess +import time +from contextlib import contextmanager +from typing import get_args, cast + +import pytest +from eth_account import Account +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 +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.types import SlotNumber, BlockRoot, BlockStamp +from src.utils.blockstamp import build_blockstamp +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 + +logger = logger.getChild("fork") + + +class TestRunningException(Exception): + pass + + +# +# Utils +# + + +@pytest.fixture +def account_from(monkeypatch): + + @contextmanager + def _use(pk: str): + with monkeypatch.context(): + monkeypatch.setattr( + variables, + "ACCOUNT", + Account.from_key(pk), + ) + logger.info(f"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"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"Frame config: {_frame_config}") + return _frame_config + + +@pytest.fixture(params=[-4], ids=["fork 4 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"Blockstamp to fork: {blockstamp}") + return blockstamp + + +@pytest.fixture() +def run_fork(blockstamp_for_forking: BlockStamp): + cli_params = [ + 'anvil', + '--config-out', + 'localhost.json', + '--auto-impersonate', + '-f', + variables.EXECUTION_CLIENT_URI[0], + '--fork-block-number', + str(blockstamp_for_forking.block_number), + ] + process = subprocess.Popen(cli_params) + time.sleep(5) + logger.info(f"Started fork from block {blockstamp_for_forking.block_number}") + yield process + process.terminate() + process.wait() + subprocess.run(['rm', 'localhost.json']) + + +@pytest.fixture() +def forked_web3(run_fork) -> Web3: + web3 = Web3(MultiProvider(['http://127.0.0.1:8545'], 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]) + yield web3 + + +@pytest.fixture() +def accounts_from_fork(forked_web3): + with open('localhost.json') as f: + data = json.load(f) + addresses = data['available_accounts'] + private_keys = data['private_keys'] + return [forked_web3.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] + + def switch() -> SlotNumber | None: + nonlocal current + try: + current = next(iterator) + except StopIteration: + current = None + return current + + return switch, lambda: current + + +@pytest.fixture() +def patched_cl_client(monkeypatch, forked_web3, 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( + super(), + slot_to_find, + real_finalized_slot, + ).message.slot + + return super().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_web3.eth.get_block( + int(slot_details.message.body.execution_payload.block_number) + ) + except Exception as e: + logger.debug(f"FORKED CLIENT: {e}") + if not block_from_fork: + latest_el = int(forked_web3.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"Latest block {latest_el} is ahead block {from_cl}") + for _ in range(diff): + forked_web3.provider.make_request(RPCEndpoint('evm_mine'), []) + logger.debug(f"FORKED CLIENT: Mined block {forked_web3.eth.block_number}") + time.sleep(0.1) + + 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 report_contract(): + raise TestRunningException("`report_contract` fixture should be overriden on tests level") + + +@pytest.fixture() +def hash_consensus_bin(): + raise TestRunningException("`hash_consensus_bin` fixture should be overriden on tests level") + + +@pytest.fixture() +def new_hash_consensus( + forked_web3, + real_cl_client, + frame_config, + accounts_from_fork, + report_contract: BaseOracleContract, + hash_consensus_bin, +): + addresses, _ = accounts_from_fork + admin, *_ = addresses + + HashConsensus = forked_web3.eth.contract(ContractFactoryClass=HashConsensusContract, bytecode=hash_consensus_bin) + new_consensus_address = forked_web3.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_web3.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_web3.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_web3.keccak(text="lido.BaseOracle.lastProcessingRefSlot") + forked_web3.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/accounting/HashConsensus_bin b/tests/fork/contracts/accounting/HashConsensus_bin new file mode 100644 index 000000000..fead30ac3 --- /dev/null +++ b/tests/fork/contracts/accounting/HashConsensus_bin @@ -0,0 +1 @@ +60e06040523480156200001157600080fd5b5060405162003b0a38038062003b0a83398101604081905262000034916200060f565b86620000535760405163fb305deb60e01b815260040160405180910390fd5b85620000725760405163fb305deb60e01b815260040160405180910390fd5b6200008887620001c760201b62000e281760201c565b6001600160401b0316608052620000ab86620001c7602090811b62000e2817901c565b6001600160401b031660a052620000ce85620001c7602090811b62000e2817901c565b6001600160401b031660c0526001600160a01b0382166200010257604051636b35b1b760e01b815260040160405180910390fd5b6001600160a01b0381166200012a5760405163154f6dd160e31b815260040160405180910390fd5b6200013760008362000238565b60006200014b6001600160401b0362000248565b905062000199818686604051806060016040528060006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b03168152506200026560201b60201c565b50600880546001600160a01b0319166001600160a01b039290921691909117905550620006ec945050505050565b60006001600160401b03821115620002345760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b606482015260840160405180910390fd5b5090565b62000244828262000431565b5050565b60006200025f620002598362000492565b620004c5565b92915050565b82620002845760405163ef3d10c160e01b815260040160405180910390fd5b6080516200029c906001600160401b0316846200068d565b821115620002bd576040516385b552e160e01b815260040160405180910390fd5b6040518060600160405280620002de86620001c760201b62000e281760201c565b6001600160401b031681526020016200030285620001c760201b62000e281760201c565b6001600160401b031681526020016200032684620001c760201b62000e281760201c565b6001600160401b0390811690915281516000805460208501516040909501518416600160801b02600160801b600160c01b031995851668010000000000000000026001600160801b03199092169385169390931717939093161790915581511684141580620003a2575080602001516001600160401b03168314155b15620003e25760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b031682146200042b576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15b50505050565b620004488282620004e060201b62000e941760201c565b6200048d817f8f8c450dae5029cd48cd91dd9db65da48fb742893edfc7941250f6721d93cbbe6000858152602091825260409020919062000f0a62000582821b17901c565b505050565b600060a0516001600160401b031660c0516001600160401b031683620004b99190620006af565b6200025f9190620006c9565b60006080516001600160401b0316826200025f9190620006c9565b600082815260008051602062003aea833981519152602090815260408083206001600160a01b038516845290915290205460ff166200024457600082815260008051602062003aea833981519152602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600062000599836001600160a01b038416620005a0565b9392505050565b6000818152600183016020526040812054620005e9575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556200025f565b5060006200025f565b80516001600160a01b03811681146200060a57600080fd5b919050565b600080600080600080600060e0888a0312156200062b57600080fd5b87519650602088015195506040880151945060608801519350608088015192506200065960a08901620005f2565b91506200066960c08901620005f2565b905092959891949750929550565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615620006aa57620006aa62000677565b500290565b600082821015620006c457620006c462000677565b500390565b600082620006e757634e487b7160e01b600052601260045260246000fd5b500490565b60805160a05160c05161338f6200075b600039600081816103c0015281816119230152612e6401526000818161039c015281816118f90152612e30015260008181610378015281816113cc01528181611b2701528181612777015281816127e00152612ca3015261338f6000f3fe608060405234801561001057600080fd5b506004361061021c5760003560e01c80636fb1bf6611610125578063ad231cb2116100ad578063d547741f1161007c578063d547741f146105c8578063e33a8d39146105db578063e76cd4e0146105ee578063ea87627d14610601578063fb4209ac1461062657600080fd5b8063ad231cb214610592578063c1ba4e591461059a578063c26c12eb146105ad578063ca15c873146105b557600080fd5b806398041ea3116100f457806398041ea31461054757806399229f581461055a5780639eab52531461056d578063a1e07cac14610575578063a217fddf1461058a57600080fd5b80636fb1bf66146104c157806372f79b13146105045780639010d07c1461052157806391d148541461053457600080fd5b8063323a41f6116101a8578063606c0c9411610177578063606c0c941461036b5780636095012f146103fe57806360a50a5c1461040657806360e618011461042d5780636d0582681461049c57600080fd5b8063323a41f61461031c57806334aa67531461032f57806336568abe14610342578063433ab1f31461035557600080fd5b806320b4d751116101ef57806320b4d751146102a6578063239c327f146102b9578063248a9ca3146102e05780632f2ff15d146102f35780632fd2d7501461030657600080fd5b806301ffc9a714610221578063115a57c41461024957806316f6f03e1461027e5780631951c03714610293575b600080fd5b61023461022f366004612e89565b61064d565b60405190151581526020015b60405180910390f35b6102707f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe81565b604051908152602001610240565b61029161028c366004612ecf565b610678565b005b6102346102a1366004612ef9565b6106a0565b6102346102b4366004612ef9565b6106c0565b6102707f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d671781565b6102706102ee366004612f14565b6106ff565b610291610301366004612f2d565b610721565b61030e61073e565b604051610240929190612f94565b61029161032a366004612f14565b61088f565b61029161033d366004612fe1565b610955565b610291610350366004612f2d565b610a18565b61035d610a9b565b604051610240929190613003565b6103e36001600160401b037f00000000000000000000000000000000000000000000000000000000000000008116917f00000000000000000000000000000000000000000000000000000000000000008216917f00000000000000000000000000000000000000000000000000000000000000001690565b60408051938452602084019290925290820152606001610240565b610270610ab0565b6102707f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc081565b61044061043b366004612ef9565b610ac3565b6040516102409190600060e082019050825182526020830151602083015260408301511515604083015260608301511515606083015260808301511515608083015260a083015160a083015260c083015160c083015292915050565b6008546001600160a01b03165b6040516001600160a01b039091168152602001610240565b604080516060810182526000546001600160401b03808216808452600160401b8304821660208501819052600160801b90930490911692909301829052906103e3565b61050c610c6c565b60408051928352602083019190915201610240565b6104a961052f366004612fe1565b610c8e565b610234610542366004612f2d565b610cb3565b610291610555366004612ecf565b610ceb565b610291610568366004612f14565b610d0e565b61035d610d42565b6102706000805160206132fa83398151915281565b610270600081565b610291610d4f565b6102916105a8366004612f14565b610d61565b600554610270565b6102706105c3366004612f14565b610d72565b6102916105d6366004612f2d565b610d96565b6102916105e9366004613045565b610db3565b6102916105fc366004612ef9565b610dbe565b610609610df2565b604080519384526020840192909252151590820152606001610240565b6102707fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e81565b60006001600160e01b03198216635a05180f60e01b1480610672575061067282610f1f565b92915050565b6000805160206132fa8339815191526106918133610f54565b61069b8383610fb8565b505050565b6001600160a01b0381166000908152600360205260408120541515610672565b6001600160a01b03811660009081526003602052604081205480158015906106f857506106f8600182036106f26112ba565b51611324565b9392505050565b600090815260008051602061333a833981519152602052604090206001015490565b61072a826106ff565b6107348133610f54565b61069b838361135f565b6060806107496112ba565b602001516004546001600160401b031614610762579091565b600754806001600160401b0381111561077d5761077d613071565b6040519080825280602002602001820160405280156107a6578160200160208202803683370190505b509250806001600160401b038111156107c1576107c1613071565b6040519080825280602002602001820160405280156107ea578160200160208202803683370190505b50915060005b8181101561088957600081815260066020908152604091829020825180840190935280548084526001909101546001600160401b031691830191909152855186908490811061084157610841613087565b60200260200101818152505080602001516001600160401b031684838151811061086d5761086d613087565b602090810291909101015250610882816130b3565b90506107f0565b50509091565b600061089b8133610f54565b604080516060810182526000546001600160401b03808216808452600160401b830482166020850152600160801b9092041692820192909252906108de4261138e565b106108fc576040516329d1e0ff60e01b815260040160405180910390fd5b6109228382602001516001600160401b031683604001516001600160401b0316846113a1565b61092a611558565b6109326115d5565b60200151101561069b576040516323ca23a760e21b815260040160405180910390fd5b7f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe6109808133610f54565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b90910416928201929092524291906109c790839061163c565b604080516060810182526000546001600160401b038082168352600160401b820481166020840152600160801b9091041691810191909152909150610a11908290879087906113a1565b5050505050565b6001600160a01b0381163314610a8d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610a978282611651565b5050565b606080610aa86001611680565b915091509091565b6000610aba6115d5565b60200151905090565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905290610b046112ba565b602081018051845251600554919250610b1c9161185a565b50506020808401919091526001600160a01b0384166000908152600390915260409081902054801580159285019290925290610c655780600190039050600060018281548110610b6e57610b6e613087565b6000918252602091829020604080518082019091529101546001600160401b03808216808452600160401b909204168284015260a087018190529185015190925014610bbb576000610bda565b6020808201516001600160401b03166000908152600690915260409020545b60c08501526000610bea426118f5565b905083604001518111158015610c0a5750610c03611558565b8460200151115b151560808601528351610c1e908490611324565b15801560608701819052610c33575084608001515b15610c62576000546020850151610c5a91600160801b90046001600160401b0316906130ce565b811160808601525b50505b5050919050565b6000806000610c796112ba565b90508060200151816040015192509250509091565b600082815260008051602061331a833981519152602052604081206106f89083611960565b600091825260008051602061333a833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6000805160206132fa833981519152610d048133610f54565b61069b838361196c565b7f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d6717610d398133610f54565b610a9782611ae6565b606080610aa86000611680565b600154610d5f9060001990611bf5565b565b600154610d6f908290611bf5565b50565b600081815260008051602061331a8339815191526020526040812061067290611cfc565b610d9f826106ff565b610da98133610f54565b61069b8383611651565b61069b838383611d06565b7fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e610de98133610f54565b610a978261225f565b6000806000610dff6112ba565b602001519250610e118360055461185a565b50909250839050610e20611558565b149050909192565b60006001600160401b03821115610e905760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b6064820152608401610a84565b5090565b610e9e8282610cb3565b610a9757600082815260008051602061333a833981519152602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b60006106f8836001600160a01b038416612488565b60006001600160e01b03198216637965db0b60e01b148061067257506301ffc9a760e01b6001600160e01b0319831614610672565b610f5e8282610cb3565b610a9757610f76816001600160a01b031660146124d7565b610f818360206124d7565b604051602001610f92929190613112565b60408051601f198184030181529082905262461bcd60e51b8252610a8491600401613187565b6000610fc383612672565b60018054919250600091610fd791906131ba565b905080821115610fe957610fe96131d1565b600060018381548110610ffe57610ffe613087565b6000918252602091829020604080518082019091529101546001600160401b038082168352600160401b909104169181019190915290508282146111525760006002838154811061105157611051613087565b600091825260209091200154600280546001600160a01b03909216925082918690811061108057611080613087565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600183815481106110c1576110c1613087565b90600052602060002001600185815481106110de576110de613087565b600091825260209091208254910180546001600160401b0392831667ffffffffffffffff1982168117835593546001600160801b0319909116909317600160401b938490049092169092021790556111378460016130ce565b6001600160a01b039091166000908152600360205260409020555b6001805480611163576111636131e7565b600082815260209020810160001990810180546001600160801b03191690550190556002805480611196576111966131e7565b60008281526020808220600019908401810180546001600160a01b03191690559092019092556001600160a01b038716808352600382526040808420939093558251858152918201879052917fa182730913550d27dc6c5813fad297cb0785871bec3d0152c5650e59c5d39d60910160405180910390a280516001600160401b0316156112b05760006112276112ba565b9050806020015182600001516001600160401b031614801561125357508060200151611251611558565b105b156112ae576020808301516001600160401b039081166000908152600690925260408220600101805490929161128991166131fd565b91906101000a8154816001600160401b0302191690836001600160401b031602179055505b505b610a118483611bf5565b6112de60405180606001604052806000815260200160008152602001600081525090565b61131f42604080516060810182526000546001600160401b038082168352600160401b820481166020840152600160801b90910416918101919091526126b3565b905090565b600154600090818061133685846126ea565b9150915080600014158015611355575061135586836001840386612726565b9695505050505050565b6113698282610e94565b600082815260008051602061331a8339815191526020526040902061069b9082610f0a565b600061067261139c836118f5565b612768565b826113bf5760405163ef3d10c160e01b815260040160405180910390fd5b6113f26001600160401b037f00000000000000000000000000000000000000000000000000000000000000001684613216565b821115611412576040516385b552e160e01b815260040160405180910390fd5b604051806060016040528061142686610e28565b6001600160401b0316815260200161143d85610e28565b6001600160401b0316815260200161145484610e28565b6001600160401b0390811690915281516000805460208501516040909501518416600160801b0267ffffffffffffffff60801b19958516600160401b026001600160801b031990921693851693909317179390931617909155815116841415806114cb575080602001516001600160401b03168314155b1561150a5760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b03168214611552576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15b50505050565b60085460408051630d61356760e21b815290516000926001600160a01b031691633584d59c916004808301926020929190829003018186803b15801561159d57600080fd5b505afa1580156115b1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131f9190613235565b6115f960405180606001604052806000815260200160008152602001600081525090565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b909104169282019290925261131f919061279d565b60006106f861164b848461287b565b836128e5565b61165b8282612915565b600082815260008051602061331a8339815191526020526040902061069b9082612989565b600154606090819060008085156116ad576116a361169c6112ba565b51846126ea565b90925090506116b0565b50815b6116ba82826131ba565b6001600160401b038111156116d1576116d1613071565b6040519080825280602002602001820160405280156116fa578160200160208202803683370190505b50945084516001600160401b0381111561171657611716613071565b60405190808252806020026020018201604052801561173f578160200160208202803683370190505b509350815b818110156118515760006117588583613264565b905060006001828154811061176f5761176f613087565b60009182526020808320604080518082019091529201546001600160401b038082168452600160401b909104169082015291506117ac86856131ba565b9050600283815481106117c1576117c1613087565b9060005260206000200160009054906101000a90046001600160a01b03168982815181106117f1576117f1613087565b60200260200101906001600160a01b031690816001600160a01b03168152505081600001516001600160401b031688828151811061183157611831613087565b6020026020010181815250505050508061184a906130b3565b9050611744565b50505050915091565b600454600090819081906001600160401b031685146118835750600091506000199050816118ee565b505060075460009150600019908290815b818110156118eb576000818152600660205260409020600101546001600160401b03168681106118da5760008281526006602052604090205495509093509150826118eb565b506118e4816130b3565b9050611894565b50505b9250925092565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160401b03167f00000000000000000000000000000000000000000000000000000000000000006001600160401b03168361195691906131ba565b6106729190613278565b60006106f8838361299e565b6001600160a01b038216600090815260036020526040902054156119a357604051637670720160e11b815260040160405180910390fd5b6001600160a01b0382166119ca576040516303988b8160e61b815260040160405180910390fd5b6040805180820182526000808252602080830182815260018054808201825581855294517fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6909501805492516001600160401b03908116600160401b026001600160801b031990941696169590951791909117909355600280548085019091557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0388166001600160a01b03199091168117909155925483835260039091529083902081905591517fe17e0e2cd88e2144dd54f3d823c30d4569092bcac1aabaec1129883e9cc12d2e90611ad49084908690918252602082015260400190565b60405180910390a261069b8282611bf5565b604080516060810182526000546001600160401b038082168352600160401b8204811660208401819052600160801b909204169282019290925290611b4c907f00000000000000000000000000000000000000000000000000000000000000009061328c565b6001600160401b0316821115611b75576040516385b552e160e01b815260040160405180910390fd5b80604001516001600160401b03168214610a9757611b9282610e28565b600080546001600160401b0392909216600160801b0267ffffffffffffffff60801b199092169190911790556040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15050565b611c00600282613278565b8211611c4057611c11600282613278565b611c1c9060016130ce565b604051632b2dd84d60e01b8152600481019190915260248101839052604401610a84565b600554828114611cd957611c926000198414611c6a576000805160206132fa833981519152611c8c565b7f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc05b33610f54565b600583905560408051848152602081018490529081018290527f9f40cfd22fe91777c78f252bd21a710f3fb007dc2f321876891e7644ba0ae1759060600160405180910390a15b6000546001600160401b0316611cee4261138e565b1061069b5761069b836129c8565b6000610672825490565b82611d2457604051631258e44360e01b815260040160405180910390fd5b6001600160401b03831115611d4c5760405163aac8f00960e01b815260040160405180910390fd5b81611d695760405162bf199760e01b815260040160405180910390fd5b6000611d7433612672565b9050600060018281548110611d8b57611d8b613087565b60009182526020808320604080518082019091529201546001600160401b038082168452600160401b90910416908201529150611dc6612a7c565b9050808414611df257604051632a37dd3d60e11b81526004810182905260248101859052604401610a84565b426000611dfe826118f5565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252919250611e4484836126b3565b905080602001518a14611e6a57604051631258e44360e01b815260040160405180910390fd5b8060400151831115611e8f57604051637c01d16560e11b815260040160405180910390fd5b81604001516001600160401b03168160200151611eac91906130ce565b8311158015611ec65750611ec4878260000151611324565b155b15611ee457604051633e1ca93d60e01b815260040160405180910390fd5b611eec611558565b8a11611f295785516001600160401b03168a1415611f1d57604051631cf7e8a160e31b815260040160405180910390fd5b50505050505050505050565b6004546000906001600160401b03168b14611f6257506004805467ffffffffffffffff19166001600160401b038c161790556000611f67565b506007545b6000805b82826001600160401b0316108015611f9b57506001600160401b0382166000908152600660205260409020548c14155b15611fb057611fa9826132bb565b9150611f6b565b88516001600160401b03168d141561208c5760208901516001600160401b0381168411611fdf57611fdf6131d1565b806001600160401b0316836001600160401b031614156120125760405163fd10cf7360e01b815260040160405180910390fd5b6001600160401b038082166000908152600660205260408120600101805491929091839161204091166131fd565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b03169050600160055461207d91906131ba565b81141561208957600192505b50505b600083836001600160401b031610156120fc576001600160401b038084166000908152600660205260408120600101805490926120c991166132bb565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b0316905061215d565b506040805180820182528d8152600160208083018281526001600160401b0387811660009081526006909352949091209251835551918101805467ffffffffffffffff19169290931691909117909155612155846130b3565b600781905593505b60405180604001604052808f6001600160401b03168152602001846001600160401b031681525060018c8154811061219757612197613087565b600091825260209182902083519101805493909201516001600160401b03908116600160401b026001600160801b03199094169116179190911790556121da3390565b6001600160a01b03168e7f92f77576dabd7bad26f75c36abb3021b5bbb66a3e5688570a0355daddd4174888f60405161221591815260200190565b60405180910390a360055481106122405761223b858e856001600160401b031684612ac1565b61224f565b811561224f5761224f85612ba2565b5050505050505050505050505050565b6008546001600160a01b0390811690821661228d5760405163154f6dd160e31b815260040160405180910390fd5b806001600160a01b0316826001600160a01b031614156122c05760405163f1b3699f60e01b815260040160405180910390fd5b600880546001600160a01b0319166001600160a01b03848116918217909255604051918316917f3b59429457a41af89ea682ac9ed8abb8e99eb5c7d3363d5eedfc6bff6271a81e90600090a360006123166112ba565b90506000600460000160089054906101000a90046001600160401b03166001600160401b031690506000836001600160a01b0316633584d59c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561237957600080fd5b505afa15801561238d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b19190613235565b90506000856001600160a01b0316633584d59c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156123ee57600080fd5b505afa158015612402573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124269190613235565b905083602001518210801561243e5750836020015181105b801561244d5750836020015183145b1561248057600454600160801b90046001600160401b031660009081526006602052604090205461247e8582612c10565b505b505050505050565b60008181526001830160205260408120546124cf57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610672565b506000610672565b606060006124e6836002613216565b6124f19060026130ce565b6001600160401b0381111561250857612508613071565b6040519080825280601f01601f191660200182016040528015612532576020820181803683370190505b509050600360fc1b8160008151811061254d5761254d613087565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061257c5761257c613087565b60200101906001600160f81b031916908160001a90535060006125a0846002613216565b6125ab9060016130ce565b90505b6001811115612623576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106125df576125df613087565b1a60f81b8282815181106125f5576125f5613087565b60200101906001600160f81b031916908160001a90535060049490941c9361261c816132e2565b90506125ae565b5083156106f85760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a84565b6001600160a01b038116600090815260036020526040812054806126a957604051638d35f2ed60e01b815260040160405180910390fd5b6000190192915050565b6126d760405180606001604052806000815260200160008152602001600081525090565b6106f86126e4848461287b565b8361279d565b6005546000908190838110612705576000925083915061271e565b61270f8486613264565b925061271b81846130ce565b91505b509250929050565b60008161273385856131ba565b61273d9190613264565b828561274982896130ce565b61275391906131ba565b61275d9190613264565b111595945050505050565b60006106726001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683613278565b6127c160405180606001604052806000815260200160008152602001600081525090565b60006127cd84846128e5565b905060006127da82612c94565b905060007f0000000000000000000000000000000000000000000000000000000000000000856020015161280e919061328c565b612821906001600160401b0316836130ce565b9050604051806060016040528087815260200160018461284191906131ba565b6001600160401b03168152602001600061285c6001856131ba565b61286691906131ba565b6001600160401b031690529695505050505050565b6000806128878461138e565b83519091506001600160401b03168110156128b55760405163668441f560e11b815260040160405180910390fd5b602083015183516001600160401b03918216916128d39116836131ba565b6128dd9190613278565b949350505050565b600081602001516001600160401b0316836129009190613216565b82516106f891906001600160401b03166130ce565b61291f8282610cb3565b15610a9757600082815260008051602061333a833981519152602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006106f8836001600160a01b038416612cc9565b60008260000182815481106129b5576129b5613087565b9060005260206000200154905092915050565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252429190612a0f9083906126b3565b90508060400151612a1f836118f5565b1115612a2a57505050565b8060200151612a37611558565b10612a4157505050565b6000806000612a5484602001518761185a565b92509250925060008212612a7357612a6e84848484612ac1565b612480565b61248084612ba2565b60085460408051635be2042560e01b815290516000926001600160a01b031691635be20425916004808301926020929190829003018186803b15801561159d57600080fd5b6020840151600454600160401b90046001600160401b0316141580612af85750600454600160801b90046001600160401b03168214155b15611552576020840151600480546001600160401b03858116600160801b0267ffffffffffffffff60801b19918516600160401b029190911677ffffffffffffffffffffffffffffffff000000000000000019909216919091171790556040517f2b6bc782c916fa763822f1e50c6db0f95dade36d6541a8a4cbe070735b8b226d90612b909086908590918252602082015260400190565b60405180910390a26115528484612c10565b6020810151600454600160401b90046001600160401b03161415610d6f57600480546fffffffffffffffff00000000000000001916905560208101516040517fde3f4ea5aa67881831e8fad2b0855d47e75aa63a2fae6ef657ffd5f856c4a61390600090a2610d6f81612dbc565b600854602083015160408401516001600160a01b039092169163063f36ad918491612c3a90612e21565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401600060405180830381600087803b158015612c8057600080fd5b505af1158015612480573d6000803e3d6000fd5b60006106726001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683613216565b60008181526001830160205260408120548015612db2576000612ced6001836131ba565b8554909150600090612d01906001906131ba565b9050818114612d66576000866000018281548110612d2157612d21613087565b9060005260206000200154905080876000018481548110612d4457612d44613087565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612d7757612d776131e7565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610672565b6000915050610672565b600854602082015160405163d438121760e01b81526001600160a01b039092169163d438121791612df39160040190815260200190565b600060405180830381600087803b158015612e0d57600080fd5b505af1158015610a11573d6000803e3d6000fd5b6000612e566001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683613216565b610672906001600160401b037f0000000000000000000000000000000000000000000000000000000000000000166130ce565b600060208284031215612e9b57600080fd5b81356001600160e01b0319811681146106f857600080fd5b80356001600160a01b0381168114612eca57600080fd5b919050565b60008060408385031215612ee257600080fd5b612eeb83612eb3565b946020939093013593505050565b600060208284031215612f0b57600080fd5b6106f882612eb3565b600060208284031215612f2657600080fd5b5035919050565b60008060408385031215612f4057600080fd5b82359150612f5060208401612eb3565b90509250929050565b600081518084526020808501945080840160005b83811015612f8957815187529582019590820190600101612f6d565b509495945050505050565b604080825283519082018190526000906020906060840190828701845b82811015612fcd57815184529284019290840190600101612fb1565b505050838103828501526113558186612f59565b60008060408385031215612ff457600080fd5b50508035926020909101359150565b604080825283519082018190526000906020906060840190828701845b82811015612fcd5781516001600160a01b031684529284019290840190600101613020565b60008060006060848603121561305a57600080fd5b505081359360208301359350604090920135919050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156130c7576130c761309d565b5060010190565b600082198211156130e1576130e161309d565b500190565b60005b838110156131015781810151838201526020016130e9565b838111156115525750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161314a8160178501602088016130e6565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161317b8160288401602088016130e6565b01602801949350505050565b60208152600082518060208401526131a68160408501602087016130e6565b601f01601f19169190910160400192915050565b6000828210156131cc576131cc61309d565b500390565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b60006001600160401b038216806126a9576126a961309d565b60008160001904831182151516156132305761323061309d565b500290565b60006020828403121561324757600080fd5b5051919050565b634e487b7160e01b600052601260045260246000fd5b6000826132735761327361324e565b500690565b6000826132875761328761324e565b500490565b60006001600160401b03808316818516818304811182151516156132b2576132b261309d565b02949350505050565b60006001600160401b03808316818114156132d8576132d861309d565b6001019392505050565b6000816132f1576132f161309d565b50600019019056fe66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a518f8c450dae5029cd48cd91dd9db65da48fb742893edfc7941250f6721d93cbbe9a627a5d4aa7c17f87ff26e3fe9a42c2b6c559e8b41a42282d0ecebb17c0e4d3a264697066735822122098f321a15e730c34a6d98fbc280e4f867ee1796f076d47af61947cde4af9e1a564736f6c634300080900339a627a5d4aa7c17f87ff26e3fe9a42c2b6c559e8b41a42282d0ecebb17c0e4d3 \ No newline at end of file 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/ejector/HashConsensus_bin b/tests/fork/contracts/ejector/HashConsensus_bin new file mode 100644 index 000000000..fead30ac3 --- /dev/null +++ b/tests/fork/contracts/ejector/HashConsensus_bin @@ -0,0 +1 @@ +60e06040523480156200001157600080fd5b5060405162003b0a38038062003b0a83398101604081905262000034916200060f565b86620000535760405163fb305deb60e01b815260040160405180910390fd5b85620000725760405163fb305deb60e01b815260040160405180910390fd5b6200008887620001c760201b62000e281760201c565b6001600160401b0316608052620000ab86620001c7602090811b62000e2817901c565b6001600160401b031660a052620000ce85620001c7602090811b62000e2817901c565b6001600160401b031660c0526001600160a01b0382166200010257604051636b35b1b760e01b815260040160405180910390fd5b6001600160a01b0381166200012a5760405163154f6dd160e31b815260040160405180910390fd5b6200013760008362000238565b60006200014b6001600160401b0362000248565b905062000199818686604051806060016040528060006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b03168152506200026560201b60201c565b50600880546001600160a01b0319166001600160a01b039290921691909117905550620006ec945050505050565b60006001600160401b03821115620002345760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b606482015260840160405180910390fd5b5090565b62000244828262000431565b5050565b60006200025f620002598362000492565b620004c5565b92915050565b82620002845760405163ef3d10c160e01b815260040160405180910390fd5b6080516200029c906001600160401b0316846200068d565b821115620002bd576040516385b552e160e01b815260040160405180910390fd5b6040518060600160405280620002de86620001c760201b62000e281760201c565b6001600160401b031681526020016200030285620001c760201b62000e281760201c565b6001600160401b031681526020016200032684620001c760201b62000e281760201c565b6001600160401b0390811690915281516000805460208501516040909501518416600160801b02600160801b600160c01b031995851668010000000000000000026001600160801b03199092169385169390931717939093161790915581511684141580620003a2575080602001516001600160401b03168314155b15620003e25760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b031682146200042b576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15b50505050565b620004488282620004e060201b62000e941760201c565b6200048d817f8f8c450dae5029cd48cd91dd9db65da48fb742893edfc7941250f6721d93cbbe6000858152602091825260409020919062000f0a62000582821b17901c565b505050565b600060a0516001600160401b031660c0516001600160401b031683620004b99190620006af565b6200025f9190620006c9565b60006080516001600160401b0316826200025f9190620006c9565b600082815260008051602062003aea833981519152602090815260408083206001600160a01b038516845290915290205460ff166200024457600082815260008051602062003aea833981519152602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600062000599836001600160a01b038416620005a0565b9392505050565b6000818152600183016020526040812054620005e9575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556200025f565b5060006200025f565b80516001600160a01b03811681146200060a57600080fd5b919050565b600080600080600080600060e0888a0312156200062b57600080fd5b87519650602088015195506040880151945060608801519350608088015192506200065960a08901620005f2565b91506200066960c08901620005f2565b905092959891949750929550565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615620006aa57620006aa62000677565b500290565b600082821015620006c457620006c462000677565b500390565b600082620006e757634e487b7160e01b600052601260045260246000fd5b500490565b60805160a05160c05161338f6200075b600039600081816103c0015281816119230152612e6401526000818161039c015281816118f90152612e30015260008181610378015281816113cc01528181611b2701528181612777015281816127e00152612ca3015261338f6000f3fe608060405234801561001057600080fd5b506004361061021c5760003560e01c80636fb1bf6611610125578063ad231cb2116100ad578063d547741f1161007c578063d547741f146105c8578063e33a8d39146105db578063e76cd4e0146105ee578063ea87627d14610601578063fb4209ac1461062657600080fd5b8063ad231cb214610592578063c1ba4e591461059a578063c26c12eb146105ad578063ca15c873146105b557600080fd5b806398041ea3116100f457806398041ea31461054757806399229f581461055a5780639eab52531461056d578063a1e07cac14610575578063a217fddf1461058a57600080fd5b80636fb1bf66146104c157806372f79b13146105045780639010d07c1461052157806391d148541461053457600080fd5b8063323a41f6116101a8578063606c0c9411610177578063606c0c941461036b5780636095012f146103fe57806360a50a5c1461040657806360e618011461042d5780636d0582681461049c57600080fd5b8063323a41f61461031c57806334aa67531461032f57806336568abe14610342578063433ab1f31461035557600080fd5b806320b4d751116101ef57806320b4d751146102a6578063239c327f146102b9578063248a9ca3146102e05780632f2ff15d146102f35780632fd2d7501461030657600080fd5b806301ffc9a714610221578063115a57c41461024957806316f6f03e1461027e5780631951c03714610293575b600080fd5b61023461022f366004612e89565b61064d565b60405190151581526020015b60405180910390f35b6102707f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe81565b604051908152602001610240565b61029161028c366004612ecf565b610678565b005b6102346102a1366004612ef9565b6106a0565b6102346102b4366004612ef9565b6106c0565b6102707f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d671781565b6102706102ee366004612f14565b6106ff565b610291610301366004612f2d565b610721565b61030e61073e565b604051610240929190612f94565b61029161032a366004612f14565b61088f565b61029161033d366004612fe1565b610955565b610291610350366004612f2d565b610a18565b61035d610a9b565b604051610240929190613003565b6103e36001600160401b037f00000000000000000000000000000000000000000000000000000000000000008116917f00000000000000000000000000000000000000000000000000000000000000008216917f00000000000000000000000000000000000000000000000000000000000000001690565b60408051938452602084019290925290820152606001610240565b610270610ab0565b6102707f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc081565b61044061043b366004612ef9565b610ac3565b6040516102409190600060e082019050825182526020830151602083015260408301511515604083015260608301511515606083015260808301511515608083015260a083015160a083015260c083015160c083015292915050565b6008546001600160a01b03165b6040516001600160a01b039091168152602001610240565b604080516060810182526000546001600160401b03808216808452600160401b8304821660208501819052600160801b90930490911692909301829052906103e3565b61050c610c6c565b60408051928352602083019190915201610240565b6104a961052f366004612fe1565b610c8e565b610234610542366004612f2d565b610cb3565b610291610555366004612ecf565b610ceb565b610291610568366004612f14565b610d0e565b61035d610d42565b6102706000805160206132fa83398151915281565b610270600081565b610291610d4f565b6102916105a8366004612f14565b610d61565b600554610270565b6102706105c3366004612f14565b610d72565b6102916105d6366004612f2d565b610d96565b6102916105e9366004613045565b610db3565b6102916105fc366004612ef9565b610dbe565b610609610df2565b604080519384526020840192909252151590820152606001610240565b6102707fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e81565b60006001600160e01b03198216635a05180f60e01b1480610672575061067282610f1f565b92915050565b6000805160206132fa8339815191526106918133610f54565b61069b8383610fb8565b505050565b6001600160a01b0381166000908152600360205260408120541515610672565b6001600160a01b03811660009081526003602052604081205480158015906106f857506106f8600182036106f26112ba565b51611324565b9392505050565b600090815260008051602061333a833981519152602052604090206001015490565b61072a826106ff565b6107348133610f54565b61069b838361135f565b6060806107496112ba565b602001516004546001600160401b031614610762579091565b600754806001600160401b0381111561077d5761077d613071565b6040519080825280602002602001820160405280156107a6578160200160208202803683370190505b509250806001600160401b038111156107c1576107c1613071565b6040519080825280602002602001820160405280156107ea578160200160208202803683370190505b50915060005b8181101561088957600081815260066020908152604091829020825180840190935280548084526001909101546001600160401b031691830191909152855186908490811061084157610841613087565b60200260200101818152505080602001516001600160401b031684838151811061086d5761086d613087565b602090810291909101015250610882816130b3565b90506107f0565b50509091565b600061089b8133610f54565b604080516060810182526000546001600160401b03808216808452600160401b830482166020850152600160801b9092041692820192909252906108de4261138e565b106108fc576040516329d1e0ff60e01b815260040160405180910390fd5b6109228382602001516001600160401b031683604001516001600160401b0316846113a1565b61092a611558565b6109326115d5565b60200151101561069b576040516323ca23a760e21b815260040160405180910390fd5b7f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe6109808133610f54565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b90910416928201929092524291906109c790839061163c565b604080516060810182526000546001600160401b038082168352600160401b820481166020840152600160801b9091041691810191909152909150610a11908290879087906113a1565b5050505050565b6001600160a01b0381163314610a8d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610a978282611651565b5050565b606080610aa86001611680565b915091509091565b6000610aba6115d5565b60200151905090565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905290610b046112ba565b602081018051845251600554919250610b1c9161185a565b50506020808401919091526001600160a01b0384166000908152600390915260409081902054801580159285019290925290610c655780600190039050600060018281548110610b6e57610b6e613087565b6000918252602091829020604080518082019091529101546001600160401b03808216808452600160401b909204168284015260a087018190529185015190925014610bbb576000610bda565b6020808201516001600160401b03166000908152600690915260409020545b60c08501526000610bea426118f5565b905083604001518111158015610c0a5750610c03611558565b8460200151115b151560808601528351610c1e908490611324565b15801560608701819052610c33575084608001515b15610c62576000546020850151610c5a91600160801b90046001600160401b0316906130ce565b811160808601525b50505b5050919050565b6000806000610c796112ba565b90508060200151816040015192509250509091565b600082815260008051602061331a833981519152602052604081206106f89083611960565b600091825260008051602061333a833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6000805160206132fa833981519152610d048133610f54565b61069b838361196c565b7f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d6717610d398133610f54565b610a9782611ae6565b606080610aa86000611680565b600154610d5f9060001990611bf5565b565b600154610d6f908290611bf5565b50565b600081815260008051602061331a8339815191526020526040812061067290611cfc565b610d9f826106ff565b610da98133610f54565b61069b8383611651565b61069b838383611d06565b7fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e610de98133610f54565b610a978261225f565b6000806000610dff6112ba565b602001519250610e118360055461185a565b50909250839050610e20611558565b149050909192565b60006001600160401b03821115610e905760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b6064820152608401610a84565b5090565b610e9e8282610cb3565b610a9757600082815260008051602061333a833981519152602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b60006106f8836001600160a01b038416612488565b60006001600160e01b03198216637965db0b60e01b148061067257506301ffc9a760e01b6001600160e01b0319831614610672565b610f5e8282610cb3565b610a9757610f76816001600160a01b031660146124d7565b610f818360206124d7565b604051602001610f92929190613112565b60408051601f198184030181529082905262461bcd60e51b8252610a8491600401613187565b6000610fc383612672565b60018054919250600091610fd791906131ba565b905080821115610fe957610fe96131d1565b600060018381548110610ffe57610ffe613087565b6000918252602091829020604080518082019091529101546001600160401b038082168352600160401b909104169181019190915290508282146111525760006002838154811061105157611051613087565b600091825260209091200154600280546001600160a01b03909216925082918690811061108057611080613087565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600183815481106110c1576110c1613087565b90600052602060002001600185815481106110de576110de613087565b600091825260209091208254910180546001600160401b0392831667ffffffffffffffff1982168117835593546001600160801b0319909116909317600160401b938490049092169092021790556111378460016130ce565b6001600160a01b039091166000908152600360205260409020555b6001805480611163576111636131e7565b600082815260209020810160001990810180546001600160801b03191690550190556002805480611196576111966131e7565b60008281526020808220600019908401810180546001600160a01b03191690559092019092556001600160a01b038716808352600382526040808420939093558251858152918201879052917fa182730913550d27dc6c5813fad297cb0785871bec3d0152c5650e59c5d39d60910160405180910390a280516001600160401b0316156112b05760006112276112ba565b9050806020015182600001516001600160401b031614801561125357508060200151611251611558565b105b156112ae576020808301516001600160401b039081166000908152600690925260408220600101805490929161128991166131fd565b91906101000a8154816001600160401b0302191690836001600160401b031602179055505b505b610a118483611bf5565b6112de60405180606001604052806000815260200160008152602001600081525090565b61131f42604080516060810182526000546001600160401b038082168352600160401b820481166020840152600160801b90910416918101919091526126b3565b905090565b600154600090818061133685846126ea565b9150915080600014158015611355575061135586836001840386612726565b9695505050505050565b6113698282610e94565b600082815260008051602061331a8339815191526020526040902061069b9082610f0a565b600061067261139c836118f5565b612768565b826113bf5760405163ef3d10c160e01b815260040160405180910390fd5b6113f26001600160401b037f00000000000000000000000000000000000000000000000000000000000000001684613216565b821115611412576040516385b552e160e01b815260040160405180910390fd5b604051806060016040528061142686610e28565b6001600160401b0316815260200161143d85610e28565b6001600160401b0316815260200161145484610e28565b6001600160401b0390811690915281516000805460208501516040909501518416600160801b0267ffffffffffffffff60801b19958516600160401b026001600160801b031990921693851693909317179390931617909155815116841415806114cb575080602001516001600160401b03168314155b1561150a5760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b03168214611552576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15b50505050565b60085460408051630d61356760e21b815290516000926001600160a01b031691633584d59c916004808301926020929190829003018186803b15801561159d57600080fd5b505afa1580156115b1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131f9190613235565b6115f960405180606001604052806000815260200160008152602001600081525090565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b909104169282019290925261131f919061279d565b60006106f861164b848461287b565b836128e5565b61165b8282612915565b600082815260008051602061331a8339815191526020526040902061069b9082612989565b600154606090819060008085156116ad576116a361169c6112ba565b51846126ea565b90925090506116b0565b50815b6116ba82826131ba565b6001600160401b038111156116d1576116d1613071565b6040519080825280602002602001820160405280156116fa578160200160208202803683370190505b50945084516001600160401b0381111561171657611716613071565b60405190808252806020026020018201604052801561173f578160200160208202803683370190505b509350815b818110156118515760006117588583613264565b905060006001828154811061176f5761176f613087565b60009182526020808320604080518082019091529201546001600160401b038082168452600160401b909104169082015291506117ac86856131ba565b9050600283815481106117c1576117c1613087565b9060005260206000200160009054906101000a90046001600160a01b03168982815181106117f1576117f1613087565b60200260200101906001600160a01b031690816001600160a01b03168152505081600001516001600160401b031688828151811061183157611831613087565b6020026020010181815250505050508061184a906130b3565b9050611744565b50505050915091565b600454600090819081906001600160401b031685146118835750600091506000199050816118ee565b505060075460009150600019908290815b818110156118eb576000818152600660205260409020600101546001600160401b03168681106118da5760008281526006602052604090205495509093509150826118eb565b506118e4816130b3565b9050611894565b50505b9250925092565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160401b03167f00000000000000000000000000000000000000000000000000000000000000006001600160401b03168361195691906131ba565b6106729190613278565b60006106f8838361299e565b6001600160a01b038216600090815260036020526040902054156119a357604051637670720160e11b815260040160405180910390fd5b6001600160a01b0382166119ca576040516303988b8160e61b815260040160405180910390fd5b6040805180820182526000808252602080830182815260018054808201825581855294517fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6909501805492516001600160401b03908116600160401b026001600160801b031990941696169590951791909117909355600280548085019091557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0388166001600160a01b03199091168117909155925483835260039091529083902081905591517fe17e0e2cd88e2144dd54f3d823c30d4569092bcac1aabaec1129883e9cc12d2e90611ad49084908690918252602082015260400190565b60405180910390a261069b8282611bf5565b604080516060810182526000546001600160401b038082168352600160401b8204811660208401819052600160801b909204169282019290925290611b4c907f00000000000000000000000000000000000000000000000000000000000000009061328c565b6001600160401b0316821115611b75576040516385b552e160e01b815260040160405180910390fd5b80604001516001600160401b03168214610a9757611b9282610e28565b600080546001600160401b0392909216600160801b0267ffffffffffffffff60801b199092169190911790556040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15050565b611c00600282613278565b8211611c4057611c11600282613278565b611c1c9060016130ce565b604051632b2dd84d60e01b8152600481019190915260248101839052604401610a84565b600554828114611cd957611c926000198414611c6a576000805160206132fa833981519152611c8c565b7f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc05b33610f54565b600583905560408051848152602081018490529081018290527f9f40cfd22fe91777c78f252bd21a710f3fb007dc2f321876891e7644ba0ae1759060600160405180910390a15b6000546001600160401b0316611cee4261138e565b1061069b5761069b836129c8565b6000610672825490565b82611d2457604051631258e44360e01b815260040160405180910390fd5b6001600160401b03831115611d4c5760405163aac8f00960e01b815260040160405180910390fd5b81611d695760405162bf199760e01b815260040160405180910390fd5b6000611d7433612672565b9050600060018281548110611d8b57611d8b613087565b60009182526020808320604080518082019091529201546001600160401b038082168452600160401b90910416908201529150611dc6612a7c565b9050808414611df257604051632a37dd3d60e11b81526004810182905260248101859052604401610a84565b426000611dfe826118f5565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252919250611e4484836126b3565b905080602001518a14611e6a57604051631258e44360e01b815260040160405180910390fd5b8060400151831115611e8f57604051637c01d16560e11b815260040160405180910390fd5b81604001516001600160401b03168160200151611eac91906130ce565b8311158015611ec65750611ec4878260000151611324565b155b15611ee457604051633e1ca93d60e01b815260040160405180910390fd5b611eec611558565b8a11611f295785516001600160401b03168a1415611f1d57604051631cf7e8a160e31b815260040160405180910390fd5b50505050505050505050565b6004546000906001600160401b03168b14611f6257506004805467ffffffffffffffff19166001600160401b038c161790556000611f67565b506007545b6000805b82826001600160401b0316108015611f9b57506001600160401b0382166000908152600660205260409020548c14155b15611fb057611fa9826132bb565b9150611f6b565b88516001600160401b03168d141561208c5760208901516001600160401b0381168411611fdf57611fdf6131d1565b806001600160401b0316836001600160401b031614156120125760405163fd10cf7360e01b815260040160405180910390fd5b6001600160401b038082166000908152600660205260408120600101805491929091839161204091166131fd565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b03169050600160055461207d91906131ba565b81141561208957600192505b50505b600083836001600160401b031610156120fc576001600160401b038084166000908152600660205260408120600101805490926120c991166132bb565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b0316905061215d565b506040805180820182528d8152600160208083018281526001600160401b0387811660009081526006909352949091209251835551918101805467ffffffffffffffff19169290931691909117909155612155846130b3565b600781905593505b60405180604001604052808f6001600160401b03168152602001846001600160401b031681525060018c8154811061219757612197613087565b600091825260209182902083519101805493909201516001600160401b03908116600160401b026001600160801b03199094169116179190911790556121da3390565b6001600160a01b03168e7f92f77576dabd7bad26f75c36abb3021b5bbb66a3e5688570a0355daddd4174888f60405161221591815260200190565b60405180910390a360055481106122405761223b858e856001600160401b031684612ac1565b61224f565b811561224f5761224f85612ba2565b5050505050505050505050505050565b6008546001600160a01b0390811690821661228d5760405163154f6dd160e31b815260040160405180910390fd5b806001600160a01b0316826001600160a01b031614156122c05760405163f1b3699f60e01b815260040160405180910390fd5b600880546001600160a01b0319166001600160a01b03848116918217909255604051918316917f3b59429457a41af89ea682ac9ed8abb8e99eb5c7d3363d5eedfc6bff6271a81e90600090a360006123166112ba565b90506000600460000160089054906101000a90046001600160401b03166001600160401b031690506000836001600160a01b0316633584d59c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561237957600080fd5b505afa15801561238d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b19190613235565b90506000856001600160a01b0316633584d59c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156123ee57600080fd5b505afa158015612402573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124269190613235565b905083602001518210801561243e5750836020015181105b801561244d5750836020015183145b1561248057600454600160801b90046001600160401b031660009081526006602052604090205461247e8582612c10565b505b505050505050565b60008181526001830160205260408120546124cf57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610672565b506000610672565b606060006124e6836002613216565b6124f19060026130ce565b6001600160401b0381111561250857612508613071565b6040519080825280601f01601f191660200182016040528015612532576020820181803683370190505b509050600360fc1b8160008151811061254d5761254d613087565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061257c5761257c613087565b60200101906001600160f81b031916908160001a90535060006125a0846002613216565b6125ab9060016130ce565b90505b6001811115612623576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106125df576125df613087565b1a60f81b8282815181106125f5576125f5613087565b60200101906001600160f81b031916908160001a90535060049490941c9361261c816132e2565b90506125ae565b5083156106f85760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a84565b6001600160a01b038116600090815260036020526040812054806126a957604051638d35f2ed60e01b815260040160405180910390fd5b6000190192915050565b6126d760405180606001604052806000815260200160008152602001600081525090565b6106f86126e4848461287b565b8361279d565b6005546000908190838110612705576000925083915061271e565b61270f8486613264565b925061271b81846130ce565b91505b509250929050565b60008161273385856131ba565b61273d9190613264565b828561274982896130ce565b61275391906131ba565b61275d9190613264565b111595945050505050565b60006106726001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683613278565b6127c160405180606001604052806000815260200160008152602001600081525090565b60006127cd84846128e5565b905060006127da82612c94565b905060007f0000000000000000000000000000000000000000000000000000000000000000856020015161280e919061328c565b612821906001600160401b0316836130ce565b9050604051806060016040528087815260200160018461284191906131ba565b6001600160401b03168152602001600061285c6001856131ba565b61286691906131ba565b6001600160401b031690529695505050505050565b6000806128878461138e565b83519091506001600160401b03168110156128b55760405163668441f560e11b815260040160405180910390fd5b602083015183516001600160401b03918216916128d39116836131ba565b6128dd9190613278565b949350505050565b600081602001516001600160401b0316836129009190613216565b82516106f891906001600160401b03166130ce565b61291f8282610cb3565b15610a9757600082815260008051602061333a833981519152602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006106f8836001600160a01b038416612cc9565b60008260000182815481106129b5576129b5613087565b9060005260206000200154905092915050565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252429190612a0f9083906126b3565b90508060400151612a1f836118f5565b1115612a2a57505050565b8060200151612a37611558565b10612a4157505050565b6000806000612a5484602001518761185a565b92509250925060008212612a7357612a6e84848484612ac1565b612480565b61248084612ba2565b60085460408051635be2042560e01b815290516000926001600160a01b031691635be20425916004808301926020929190829003018186803b15801561159d57600080fd5b6020840151600454600160401b90046001600160401b0316141580612af85750600454600160801b90046001600160401b03168214155b15611552576020840151600480546001600160401b03858116600160801b0267ffffffffffffffff60801b19918516600160401b029190911677ffffffffffffffffffffffffffffffff000000000000000019909216919091171790556040517f2b6bc782c916fa763822f1e50c6db0f95dade36d6541a8a4cbe070735b8b226d90612b909086908590918252602082015260400190565b60405180910390a26115528484612c10565b6020810151600454600160401b90046001600160401b03161415610d6f57600480546fffffffffffffffff00000000000000001916905560208101516040517fde3f4ea5aa67881831e8fad2b0855d47e75aa63a2fae6ef657ffd5f856c4a61390600090a2610d6f81612dbc565b600854602083015160408401516001600160a01b039092169163063f36ad918491612c3a90612e21565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401600060405180830381600087803b158015612c8057600080fd5b505af1158015612480573d6000803e3d6000fd5b60006106726001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683613216565b60008181526001830160205260408120548015612db2576000612ced6001836131ba565b8554909150600090612d01906001906131ba565b9050818114612d66576000866000018281548110612d2157612d21613087565b9060005260206000200154905080876000018481548110612d4457612d44613087565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612d7757612d776131e7565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610672565b6000915050610672565b600854602082015160405163d438121760e01b81526001600160a01b039092169163d438121791612df39160040190815260200190565b600060405180830381600087803b158015612e0d57600080fd5b505af1158015610a11573d6000803e3d6000fd5b6000612e566001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683613216565b610672906001600160401b037f0000000000000000000000000000000000000000000000000000000000000000166130ce565b600060208284031215612e9b57600080fd5b81356001600160e01b0319811681146106f857600080fd5b80356001600160a01b0381168114612eca57600080fd5b919050565b60008060408385031215612ee257600080fd5b612eeb83612eb3565b946020939093013593505050565b600060208284031215612f0b57600080fd5b6106f882612eb3565b600060208284031215612f2657600080fd5b5035919050565b60008060408385031215612f4057600080fd5b82359150612f5060208401612eb3565b90509250929050565b600081518084526020808501945080840160005b83811015612f8957815187529582019590820190600101612f6d565b509495945050505050565b604080825283519082018190526000906020906060840190828701845b82811015612fcd57815184529284019290840190600101612fb1565b505050838103828501526113558186612f59565b60008060408385031215612ff457600080fd5b50508035926020909101359150565b604080825283519082018190526000906020906060840190828701845b82811015612fcd5781516001600160a01b031684529284019290840190600101613020565b60008060006060848603121561305a57600080fd5b505081359360208301359350604090920135919050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156130c7576130c761309d565b5060010190565b600082198211156130e1576130e161309d565b500190565b60005b838110156131015781810151838201526020016130e9565b838111156115525750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161314a8160178501602088016130e6565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161317b8160288401602088016130e6565b01602801949350505050565b60208152600082518060208401526131a68160408501602087016130e6565b601f01601f19169190910160400192915050565b6000828210156131cc576131cc61309d565b500390565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b60006001600160401b038216806126a9576126a961309d565b60008160001904831182151516156132305761323061309d565b500290565b60006020828403121561324757600080fd5b5051919050565b634e487b7160e01b600052601260045260246000fd5b6000826132735761327361324e565b500690565b6000826132875761328761324e565b500490565b60006001600160401b03808316818516818304811182151516156132b2576132b261309d565b02949350505050565b60006001600160401b03808316818114156132d8576132d861309d565b6001019392505050565b6000816132f1576132f161309d565b50600019019056fe66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a518f8c450dae5029cd48cd91dd9db65da48fb742893edfc7941250f6721d93cbbe9a627a5d4aa7c17f87ff26e3fe9a42c2b6c559e8b41a42282d0ecebb17c0e4d3a264697066735822122098f321a15e730c34a6d98fbc280e4f867ee1796f076d47af61947cde4af9e1a564736f6c634300080900339a627a5d4aa7c17f87ff26e3fe9a42c2b6c559e8b41a42282d0ecebb17c0e4d3 \ No newline at end of file diff --git a/tests/fork/csm/test_execute_module.py b/tests/fork/csm/test_execute_module.py deleted file mode 100644 index 01efc6b08..000000000 --- a/tests/fork/csm/test_execute_module.py +++ /dev/null @@ -1,409 +0,0 @@ -import subprocess -import time -import json -from dataclasses import dataclass -from typing import cast - -from eth_account import Account -import pytest -from web3 import Web3 -from web3.middleware import construct_simple_cache_middleware -from web3_multi_provider import MultiProvider - -from src import variables -from src.main import ipfs_providers -from src.modules.csm.checkpoint import FrameCheckpointsIterator -from src.modules.csm.csm import CSOracle, logger -from src.providers.consensus.client import ConsensusClient, LiteralState -from src.providers.consensus.types import BlockDetailsResponse, BlockRootResponse -from src.providers.execution.contracts.hash_consensus import HashConsensusContract -from src.providers.ipfs import MultiIPFSProvider, CID -from src.types import BlockRoot, SlotNumber -from src.utils.blockstamp import build_blockstamp -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 ( - CSM, - LidoContracts, - LidoValidatorsProvider, - TransactionUtils, - ConsensusClientModule, - KeysAPIClientModule, -) - - -@dataclass -class FrameConfig: - fast_lane: int - frame_size: int - initial_epoch: int - - -pure_cl_client = ConsensusClient( - variables.CONSENSUS_CLIENT_URI, - HTTP_REQUEST_TIMEOUT_CONSENSUS, - HTTP_REQUEST_RETRY_COUNT_CONSENSUS, - HTTP_REQUEST_SLEEP_BEFORE_RETRY_IN_SECONDS_CONSENSUS, -) - -genesis_time = int(pure_cl_client.get_genesis().genesis_time) -logger.info(f"Genesis time on CL: {genesis_time}") - -finalized_slot = SlotNumber(int(pure_cl_client.get_block_header('finalized').data.header.message.slot)) -logger.info(f"Finalized slot on CL: {finalized_slot}") - -frame_config = FrameConfig( - fast_lane=0, - frame_size=10, - initial_epoch=(finalized_slot // 32) - 20, # step back 20 epochs (~2h) from last finalized epoch -) -logger.info(f"Frame config to set: {frame_config}") - -slot_for_fork = SlotNumber((frame_config.initial_epoch - 3) * 32 - 31) -logger.info(f"Slot to fork {slot_for_fork}") - -el_block_number_to_fork = int( - pure_cl_client.get_block_details(slot_for_fork).message.body.execution_payload.block_number -) -logger.info(f"Block number to fork {el_block_number_to_fork}") - - -@pytest.fixture -def running_slots(request): - slots = request.param - iterator = iter(slots) - current = slots[0] - - def get_current() -> SlotNumber | None: - nonlocal current - return current - - def get_next() -> SlotNumber | None: - nonlocal current - try: - current = next(iterator) - except StopIteration: - current = None - return current - - return get_next, get_current - - -@pytest.fixture() -def zero_min_checkpoint_step(monkeypatch): - with monkeypatch.context(): - monkeypatch.setattr( - FrameCheckpointsIterator, - "MIN_CHECKPOINT_STEP", - 0, - ) - yield - - -@pytest.fixture() -def run_fork(): - cli_params = [ - 'anvil', - '--config-out', - 'localhost.json', - '--auto-impersonate', - '-f', - variables.EXECUTION_CLIENT_URI[0], - '--fork-block-number', - str(el_block_number_to_fork), - ] - process = subprocess.Popen(cli_params, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - time.sleep(5) - logger.info(f"Started fork from block {el_block_number_to_fork}") - yield process - process.terminate() - process.wait() - subprocess.run(['rm', 'localhost.json']) - - -@pytest.fixture() -def provider(run_fork): - yield MultiProvider(['http://127.0.0.1:8545'], request_kwargs={'timeout': variables.HTTP_REQUEST_TIMEOUT_EXECUTION}) - - -@pytest.fixture() -def web3(provider) -> Web3: - web3 = Web3(provider) - tweak_w3_contracts(web3) - web3.middleware_onion.add(construct_simple_cache_middleware()) - web3.provider.make_request('anvil_setBlockTimestampInterval', [12]) - yield web3 - - -@pytest.fixture() -def fork_accounts(monkeypatch, web3): - with open('localhost.json') as f: - data = json.load(f) - addresses = data['available_accounts'] - private_keys = data['private_keys'] - return [web3.to_checksum_address(address) for address in addresses], private_keys - - -@pytest.fixture() -def consensus(web3): - - csm = CSM(web3) - - # Contract Creation Code from etherscan without last bytes - hash_consensus_bin = "0x60e060405234801562000010575f80fd5b50604051620036f6380380620036f68339810160408190526200003391620005aa565b865f03620000545760405163fb305deb60e01b815260040160405180910390fd5b855f03620000755760405163fb305deb60e01b815260040160405180910390fd5b6200008087620001a3565b6001600160401b03166080526200009786620001a3565b6001600160401b031660a052620000ae85620001a3565b6001600160401b031660c0526001600160a01b038216620000e257604051636b35b1b760e01b815260040160405180910390fd5b6001600160a01b0381166200010a5760405163154f6dd160e31b815260040160405180910390fd5b620001165f83620001e1565b505f6200012a6001600160401b036200023e565b90506200017581868660405180606001604052805f6001600160401b031681526020015f6001600160401b031681526020015f6001600160401b03168152506200025460201b60201c565b50600880546001600160a01b0319166001600160a01b03929092169190911790555062000671945050505050565b5f6001600160401b03821115620001dd57604080516306dfcc6560e41b815260048101919091526024810183905260440160405180910390fd5b5090565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e823717059320008162000210858562000406565b9050801562000234575f858152602083905260409020620002329085620004d6565b505b9150505b92915050565b5f620002386200024e83620004f3565b62000525565b825f03620002755760405163ef3d10c160e01b815260040160405180910390fd5b6080516200028d906001600160401b03168462000621565b821115620002ae576040516385b552e160e01b815260040160405180910390fd5b6040518060600160405280620002ca86620001a360201b60201c565b6001600160401b03168152602001620002e385620001a3565b6001600160401b03168152602001620002fc84620001a3565b6001600160401b0390811690915281515f805460208501516040909501518416600160801b02600160801b600160c01b031995851668010000000000000000026001600160801b0319909216938516939093171793909316179091558151168414158062000377575080602001516001600160401b03168314155b15620003b75760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b0316821462000400576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15b50505050565b5f8281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff16620004cc575f848152602082815260408083206001600160a01b03871684529091529020805460ff19166001179055620004813390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4600191505062000238565b5f91505062000238565b5f620004ec836001600160a01b0384166200053f565b9392505050565b5f60a0516001600160401b031660c0516001600160401b0316836200051991906200063b565b62000238919062000651565b5f6080516001600160401b03168262000238919062000651565b5f8181526001830160205260408120546200058657508154600181810184555f84815260208082209093018490558454848252828601909352604090209190915562000238565b505f62000238565b80516001600160a01b0381168114620005a5575f80fd5b919050565b5f805f805f805f60e0888a031215620005c1575f80fd5b8751965060208801519550604088015194506060880151935060808801519250620005ef60a089016200058e565b9150620005ff60c089016200058e565b905092959891949750929550565b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176200023857620002386200060d565b818103818111156200023857620002386200060d565b5f826200066c57634e487b7160e01b5f52601260045260245ffd5b500490565b60805160a05160c05161301b620006db5f395f81816103d1015281816117c70152612c8201525f81816103ad0152818161179d0152612c4e01525f81816103890152818161128a015281816119c70152818161252b015281816125c70152612ae0015261301b5ff3fe608060405234801561000f575f80fd5b5060043610610213575f3560e01c80636fb1bf661161011f578063ad231cb2116100a9578063d547741f11610079578063d547741f14610619578063e33a8d391461062c578063e76cd4e01461063f578063ea87627d14610652578063fb4209ac14610677575f80fd5b8063ad231cb2146105e3578063c1ba4e59146105eb578063c26c12eb146105fe578063ca15c87314610606575f80fd5b806398041ea3116100ef57806398041ea31461058757806399229f581461059a5780639eab5253146105ad578063a1e07cac146105b5578063a217fddf146105dc575f80fd5b80636fb1bf66146104d157806372f79b13146105135780639010d07c1461053057806391d1485414610543575f80fd5b8063323a41f6116101a0578063606c0c9411610170578063606c0c941461037c5780636095012f1461040f57806360a50a5c1461041757806360e618011461043e5780636d058268146104ac575f80fd5b8063323a41f61461032d57806334aa67531461034057806336568abe14610353578063433ab1f314610366575f80fd5b806320b4d751116101e657806320b4d7511461029c578063239c327f146102af578063248a9ca3146102d65780632f2ff15d146103045780632fd2d75014610317575f80fd5b806301ffc9a714610217578063115a57c41461023f57806316f6f03e146102745780631951c03714610289575b5f80fd5b61022a610225366004612ca7565b61069e565b60405190151581526020015b60405180910390f35b6102667f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe81565b604051908152602001610236565b610287610282366004612ce9565b6106c8565b005b61022a610297366004612d11565b610701565b61022a6102aa366004612d11565b610720565b6102667f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d671781565b6102666102e4366004612d2a565b5f9081525f80516020612fef833981519152602052604090206001015490565b610287610312366004612d41565b61075e565b61031f610794565b604051610236929190612da5565b61028761033b366004612d2a565b6108db565b61028761034e366004612df2565b61099e565b610287610361366004612d41565b610a5e565b61036e610a91565b604051610236929190612e12565b6103f46001600160401b037f00000000000000000000000000000000000000000000000000000000000000008116917f00000000000000000000000000000000000000000000000000000000000000008216917f00000000000000000000000000000000000000000000000000000000000000001690565b60408051938452602084019290925290820152606001610236565b610266610aa6565b6102667f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc081565b61045161044c366004612d11565b610ab8565b60405161023691905f60e082019050825182526020830151602083015260408301511515604083015260608301511515606083015260808301511515608083015260a083015160a083015260c083015160c083015292915050565b6008546001600160a01b03165b6040516001600160a01b039091168152602001610236565b604080516060810182525f546001600160401b03808216808452600160401b8304821660208501819052600160801b90930490911692909301829052906103f4565b61051b610c59565b60408051928352602083019190915201610236565b6104b961053e366004612df2565b610c79565b61022a610551366004612d41565b5f9182525f80516020612fef833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b610287610595366004612ce9565b610cb9565b6102876105a8366004612d2a565b610ced565b61036e610d24565b6102667f66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a5181565b6102665f81565b610287610d30565b6102876105f9366004612d2a565b610d41565b600554610266565b610266610614366004612d2a565b610d52565b610287610627366004612d41565b610d89565b61028761063a366004612e53565b610db9565b61028761064d366004612d11565b610dc4565b61065a610df7565b604080519384526020840192909252151590820152606001610236565b6102667fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e81565b5f6001600160e01b03198216635a05180f60e01b14806106c257506106c282610e2b565b92915050565b7f66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a516106f281610e5f565b6106fc8383610e69565b505050565b6001600160a01b0381165f9081526003602052604081205415156106c2565b6001600160a01b0381165f908152600360205260408120548015801590610757575061075760018203610751611157565b516111bd565b9392505050565b5f8281525f80516020612fef833981519152602052604090206001015461078481610e5f565b61078e83836111f6565b50505050565b60608061079f611157565b602001516004546001600160401b0316146107b8579091565b600754806001600160401b038111156107d3576107d3612e7c565b6040519080825280602002602001820160405280156107fc578160200160208202803683370190505b509250806001600160401b0381111561081757610817612e7c565b604051908082528060200260200182016040528015610840578160200160208202803683370190505b5091505f5b818110156108d5575f81815260066020908152604091829020825180840190935280548084526001909101546001600160401b031691830191909152855186908490811061089557610895612e90565b60200260200101818152505080602001516001600160401b03168483815181106108c1576108c1612e90565b602090810291909101015250600101610845565b50509091565b5f6108e581610e5f565b604080516060810182525f546001600160401b03808216808452600160401b830482166020850152600160801b9092041692820192909252906109274261124b565b10610945576040516329d1e0ff60e01b815260040160405180910390fd5b61096b8382602001516001600160401b031683604001516001600160401b03168461125d565b610973611414565b61097b61147f565b6020015110156106fc576040516323ca23a760e21b815260040160405180910390fd5b7f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe6109c881610e5f565b604080516060810182525f80546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252429190610a0e9083906114e2565b604080516060810182525f546001600160401b038082168352600160401b820481166020840152600160801b9091041691810191909152909150610a579082908790879061125d565b5050505050565b6001600160a01b0381163314610a875760405163334bd91960e11b815260040160405180910390fd5b6106fc82826114f6565b606080610a9e6001611542565b915091509091565b5f610aaf61147f565b60200151905090565b6040805160e0810182525f80825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905290610af8611157565b602081018051845251600554919250610b109161170e565b50506020808401919091526001600160a01b0384165f908152600390915260409081902054801580159285019290925290610c5257806001900390505f60018281548110610b6057610b60612e90565b5f918252602091829020604080518082019091529101546001600160401b03808216808452600160401b909204168284015260a087018190529185015190925014610bab575f610bc9565b6020808201516001600160401b03165f908152600690915260409020545b60c08501525f610bd84261179a565b905083604001518111158015610bf85750610bf1611414565b8460200151115b151560808601528351610c0c9084906111bd565b15801560608701819052610c21575084608001515b15610c4f575f546020850151610c4791600160801b90046001600160401b031690612eb8565b811160808601525b50505b5050919050565b5f805f610c64611157565b90508060200151816040015192509250509091565b5f8281527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000602081905260408220610cb19084611804565b949350505050565b7f66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a51610ce381610e5f565b6106fc838361180f565b7f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d6717610d1781610e5f565b610d2082611987565b5050565b606080610a9e5f611542565b600154610d3f905f1990611a94565b565b600154610d4f908290611a94565b50565b5f8181527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200060208190526040822061075790611bb0565b5f8281525f80516020612fef8339815191526020526040902060010154610daf81610e5f565b61078e83836114f6565b6106fc838383611bb9565b7fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e610dee81610e5f565b610d2082612101565b5f805f610e02611157565b602001519250610e148360055461170e565b50909250839050610e23611414565b149050909192565b5f6001600160e01b03198216637965db0b60e01b14806106c257506301ffc9a760e01b6001600160e01b03198316146106c2565b610d4f8133612300565b5f610e7383612360565b600180549192505f91610e869190612ecb565b905080821115610e9857610e98612ede565b5f60018381548110610eac57610eac612e90565b5f918252602091829020604080518082019091529101546001600160401b038082168352600160401b90910416918101919091529050828214610ff6575f60028381548110610efd57610efd612e90565b5f91825260209091200154600280546001600160a01b039092169250829186908110610f2b57610f2b612e90565b905f5260205f20015f6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060018381548110610f6957610f69612e90565b905f5260205f200160018581548110610f8457610f84612e90565b5f91825260209091208254910180546001600160401b0392831667ffffffffffffffff1982168117835593546001600160801b0319909116909317600160401b93849004909216909202179055610fdc846001612eb8565b6001600160a01b039091165f908152600360205260409020555b600180548061100757611007612ef2565b5f8281526020902081015f1990810180546001600160801b0319169055019055600280548061103857611038612ef2565b5f82815260208082205f19908401810180546001600160a01b03191690559092019092556001600160a01b038716808352600382526040808420939093558251858152918201879052917fa182730913550d27dc6c5813fad297cb0785871bec3d0152c5650e59c5d39d60910160405180910390a280516001600160401b03161561114d575f6110c6611157565b90508060200151825f01516001600160401b03161480156110f1575080602001516110ef611414565b105b1561114b576020808301516001600160401b039081165f90815260069092526040822060010180549092916111269116612f06565b91906101000a8154816001600160401b0302191690836001600160401b031602179055505b505b610a578483611a94565b61117860405180606001604052805f81526020015f81526020015f81525090565b6111b842604080516060810182525f546001600160401b038082168352600160401b820481166020840152600160801b90910416918101919091526123a1565b905090565b6001545f9081806111ce85846123d5565b91509150805f141580156111ec57506111ec8683600184038661240f565b9695505050505050565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000816112238585612450565b90508015610cb1575f8581526020839052604090206112429085612509565b50949350505050565b5f6106c26112588361179a565b61251d565b825f0361127d5760405163ef3d10c160e01b815260040160405180910390fd5b6112b06001600160401b037f00000000000000000000000000000000000000000000000000000000000000001684612f1e565b8211156112d0576040516385b552e160e01b815260040160405180910390fd5b60405180606001604052806112e486612551565b6001600160401b031681526020016112fb85612551565b6001600160401b0316815260200161131284612551565b6001600160401b0390811690915281515f805460208501516040909501518416600160801b0267ffffffffffffffff60801b19958516600160401b026001600160801b03199092169385169390931717939093161790915581511684141580611388575080602001516001600160401b03168314155b156113c75760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b0316821461078e576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a150505050565b60085460408051630d61356760e21b815290515f926001600160a01b031691633584d59c9160048083019260209291908290030181865afa15801561145b573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111b89190612f35565b6114a060405180606001604052805f81526020015f81526020015f81525090565b604080516060810182525f80546001600160401b038082168452600160401b820481166020850152600160801b90910416928201929092526111b8919061258a565b5f6107576114f08484612661565b836126c2565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e823717059320008161152385856126f1565b90508015610cb1575f8581526020839052604090206112429085612782565b60015460609081905f80851561156e5761156461155d611157565b51846123d5565b9092509050611571565b50815b61157b8282612ecb565b6001600160401b0381111561159257611592612e7c565b6040519080825280602002602001820160405280156115bb578160200160208202803683370190505b50945084516001600160401b038111156115d7576115d7612e7c565b604051908082528060200260200182016040528015611600578160200160208202803683370190505b509350815b81811015611705575f6116188583612f60565b90505f6001828154811061162e5761162e612e90565b5f9182526020808320604080518082019091529201546001600160401b038082168452600160401b9091041690820152915061166a8685612ecb565b90506002838154811061167f5761167f612e90565b905f5260205f20015f9054906101000a90046001600160a01b03168982815181106116ac576116ac612e90565b60200260200101906001600160a01b031690816001600160a01b031681525050815f01516001600160401b03168882815181106116eb576116eb612e90565b602002602001018181525050505050806001019050611605565b50505050915091565b6004545f90819081906001600160401b0316851461173457505f91505f19905081611793565b50506007545f91505f19908290815b81811015611790575f818152600660205260409020600101546001600160401b0316868110611787575f828152600660205260409020549550909350915082611790565b50600101611743565b50505b9250925092565b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160401b03167f00000000000000000000000000000000000000000000000000000000000000006001600160401b0316836117fa9190612ecb565b6106c29190612f73565b5f6107578383612796565b6001600160a01b0382165f908152600360205260409020541561184557604051637670720160e11b815260040160405180910390fd5b6001600160a01b03821661186c576040516303988b8160e61b815260040160405180910390fd5b6040805180820182525f808252602080830182815260018054808201825581855294517fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6909501805492516001600160401b03908116600160401b026001600160801b031990941696169590951791909117909355600280548085019091557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0388166001600160a01b03199091168117909155925483835260039091529083902081905591517fe17e0e2cd88e2144dd54f3d823c30d4569092bcac1aabaec1129883e9cc12d2e906119759084908690918252602082015260400190565b60405180910390a26106fc8282611a94565b604080516060810182525f546001600160401b038082168352600160401b8204811660208401819052600160801b9092041692820192909252906119ec907f000000000000000000000000000000000000000000000000000000000000000090612f86565b6001600160401b0316821115611a15576040516385b552e160e01b815260040160405180910390fd5b80604001516001600160401b03168214610d2057611a3282612551565b5f80546001600160401b0392909216600160801b0267ffffffffffffffff60801b199092169190911790556040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15050565b611a9f600282612f73565b8211611ae457611ab0600282612f73565b611abb906001612eb8565b604051632b2dd84d60e01b81526004810191909152602481018390526044015b60405180910390fd5b600554828114611b8e57611b475f198414611b1f577f66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a51611b41565b7f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc05b33612300565b600583905560408051848152602081018490529081018290527f9f40cfd22fe91777c78f252bd21a710f3fb007dc2f321876891e7644ba0ae1759060600160405180910390a15b5f546001600160401b0316611ba24261124b565b106106fc576106fc836127bc565b5f6106c2825490565b825f03611bd957604051631258e44360e01b815260040160405180910390fd5b6001600160401b03831115611c015760405163aac8f00960e01b815260040160405180910390fd5b81611c1e5760405162bf199760e01b815260040160405180910390fd5b5f611c2833612360565b90505f60018281548110611c3e57611c3e612e90565b5f9182526020808320604080518082019091529201546001600160401b038082168452600160401b90910416908201529150611c7861286c565b9050808414611ca457604051632a37dd3d60e11b81526004810182905260248101859052604401611adb565b425f611caf8261179a565b604080516060810182525f80546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252919250611cf484836123a1565b905080602001518a14611d1a57604051631258e44360e01b815260040160405180910390fd5b8060400151831115611d3f57604051637c01d16560e11b815260040160405180910390fd5b81604001516001600160401b03168160200151611d5c9190612eb8565b8311158015611d755750611d7387825f01516111bd565b155b15611d9357604051633e1ca93d60e01b815260040160405180910390fd5b611d9b611414565b8a11611dd75785516001600160401b03168a03611dcb57604051631cf7e8a160e31b815260040160405180910390fd5b50505050505050505050565b6004545f906001600160401b03168b14611e0e57506004805467ffffffffffffffff19166001600160401b038c161790555f611e13565b506007545b5f805b82826001600160401b0316108015611e4557506001600160401b0382165f908152600660205260409020548c14155b15611e5a57611e5382612fb1565b9150611e16565b88516001600160401b03168d03611f325760208901516001600160401b0381168411611e8857611e88612ede565b806001600160401b0316836001600160401b031603611eba5760405163fd10cf7360e01b815260040160405180910390fd5b6001600160401b038082165f9081526006602052604081206001018054919290918391611ee79116612f06565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b031690506001600554611f249190612ecb565b8103611f2f57600192505b50505b5f83836001600160401b03161015611fa0576001600160401b038084165f90815260066020526040812060010180549092611f6d9116612fb1565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b03169050612000565b506040805180820182528d8152600160208083018281526001600160401b038781165f9081526006909352949091209251835551918101805467ffffffffffffffff19169290931691909117909155611ff884612fd6565b600781905593505b60405180604001604052808f6001600160401b03168152602001846001600160401b031681525060018c8154811061203a5761203a612e90565b5f91825260209182902083519101805493909201516001600160401b03908116600160401b026001600160801b031990941691161791909117905561207c3390565b6001600160a01b03168e7f92f77576dabd7bad26f75c36abb3021b5bbb66a3e5688570a0355daddd4174888f6040516120b791815260200190565b60405180910390a360055481106120e2576120dd858e856001600160401b0316846128b3565b6120f1565b81156120f1576120f18561299b565b5050505050505050505050505050565b6008546001600160a01b0390811690821661212f5760405163154f6dd160e31b815260040160405180910390fd5b806001600160a01b0316826001600160a01b0316036121615760405163f1b3699f60e01b815260040160405180910390fd5b600880546001600160a01b0319166001600160a01b03848116918217909255604051918316917f3b59429457a41af89ea682ac9ed8abb8e99eb5c7d3363d5eedfc6bff6271a81e905f90a35f6121b5611157565b90505f60045f0160089054906101000a90046001600160401b03166001600160401b031690505f836001600160a01b0316633584d59c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612218573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061223c9190612f35565b90505f856001600160a01b0316633584d59c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561227b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061229f9190612f35565b90508360200151821080156122b75750836020015181105b80156122c65750836020015183145b156122f857600454600160801b90046001600160401b03165f908152600660205260409020546122f68582612a07565b505b505050505050565b5f8281525f80516020612fef833981519152602090815260408083206001600160a01b038516845290915290205460ff16610d205760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401611adb565b6001600160a01b0381165f9081526003602052604081205480820361239857604051638d35f2ed60e01b815260040160405180910390fd5b5f190192915050565b6123c260405180606001604052805f81526020015f81526020015f81525090565b6107576123cf8484612661565b8361258a565b6005545f9081908381106123ee575f9250839150612407565b6123f88486612f60565b92506124048184612eb8565b91505b509250929050565b5f8161241b8585612ecb565b6124259190612f60565b82856124318289612eb8565b61243b9190612ecb565b6124459190612f60565b111595945050505050565b5f8281525f80516020612fef833981519152602081815260408084206001600160a01b038616855290915282205460ff16612500575f848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556124b63390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506106c2565b5f9150506106c2565b5f610757836001600160a01b038416612a86565b5f6106c26001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683612f73565b5f6001600160401b0382111561258657604080516306dfcc6560e41b8152600481019190915260248101839052604401611adb565b5090565b6125ab60405180606001604052805f81526020015f81526020015f81525090565b5f6125b684846126c2565b90505f6125c282612ad2565b90505f7f000000000000000000000000000000000000000000000000000000000000000085602001516125f59190612f86565b612608906001600160401b031683612eb8565b905060405180606001604052808781526020016001846126289190612ecb565b6001600160401b031681526020015f612642600185612ecb565b61264c9190612ecb565b6001600160401b031690529695505050505050565b5f8061266c8461124b565b83519091506001600160401b031681101561269a5760405163668441f560e11b815260040160405180910390fd5b602083015183516001600160401b03918216916126b8911683612ecb565b610cb19190612f73565b5f81602001516001600160401b0316836126dc9190612f1e565b825161075791906001600160401b0316612eb8565b5f8281525f80516020612fef833981519152602081815260408084206001600160a01b038616855290915282205460ff1615612500575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506106c2565b5f610757836001600160a01b038416612b06565b5f825f0182815481106127ab576127ab612e90565b905f5260205f200154905092915050565b604080516060810182525f80546001600160401b038082168452600160401b820481166020850152600160801b90910416928201929092524291906128029083906123a1565b905080604001516128128361179a565b111561281d57505050565b806020015161282a611414565b1061283457505050565b5f805f61284584602001518761170e565b9250925092505f82126128635761285e848484846128b3565b6122f8565b6122f88461299b565b60085460408051635be2042560e01b815290515f926001600160a01b031691635be204259160048083019260209291908290030181865afa15801561145b573d5f803e3d5ffd5b6020840151600454600160401b90046001600160401b03161415806128ea5750600454600160801b90046001600160401b03168214155b1561078e576020840151600480546001600160401b03858116600160801b0267ffffffffffffffff60801b19918516600160401b02919091167fffffffffffffffff00000000000000000000000000000000ffffffffffffffff909216919091171790556040517f2b6bc782c916fa763822f1e50c6db0f95dade36d6541a8a4cbe070735b8b226d906129899086908590918252602082015260400190565b60405180910390a261078e8484612a07565b6020810151600454600160401b90046001600160401b031603610d4f57600480546fffffffffffffffff00000000000000001916905560208101516040517fde3f4ea5aa67881831e8fad2b0855d47e75aa63a2fae6ef657ffd5f856c4a613905f90a2610d4f81612be0565b600854602083015160408401516001600160a01b039092169163063f36ad918491612a3190612c40565b6040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064015f604051808303815f87803b158015612a74575f80fd5b505af11580156122f8573d5f803e3d5ffd5b5f818152600183016020526040812054612acb57508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556106c2565b505f6106c2565b5f6106c26001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683612f1e565b5f8181526001830160205260408120548015612500575f612b28600183612ecb565b85549091505f90612b3b90600190612ecb565b9050808214612b9a575f865f018281548110612b5957612b59612e90565b905f5260205f200154905080875f018481548110612b7957612b79612e90565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080612bab57612bab612ef2565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f9055600193505050506106c2565b600854602082015160405163d438121760e01b81526001600160a01b039092169163d438121791612c179160040190815260200190565b5f604051808303815f87803b158015612c2e575f80fd5b505af1158015610a57573d5f803e3d5ffd5b5f612c746001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683612f1e565b6106c2906001600160401b037f000000000000000000000000000000000000000000000000000000000000000016612eb8565b5f60208284031215612cb7575f80fd5b81356001600160e01b031981168114610757575f80fd5b80356001600160a01b0381168114612ce4575f80fd5b919050565b5f8060408385031215612cfa575f80fd5b612d0383612cce565b946020939093013593505050565b5f60208284031215612d21575f80fd5b61075782612cce565b5f60208284031215612d3a575f80fd5b5035919050565b5f8060408385031215612d52575f80fd5b82359150612d6260208401612cce565b90509250929050565b5f815180845260208085019450602084015f5b83811015612d9a57815187529582019590820190600101612d7e565b509495945050505050565b604080825283519082018190525f906020906060840190828701845b82811015612ddd57815184529284019290840190600101612dc1565b50505083810360208501526111ec8186612d6b565b5f8060408385031215612e03575f80fd5b50508035926020909101359150565b604080825283519082018190525f906020906060840190828701845b82811015612ddd5781516001600160a01b031684529284019290840190600101612e2e565b5f805f60608486031215612e65575f80fd5b505081359360208301359350604090920135919050565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b808201808211156106c2576106c2612ea4565b818103818111156106c2576106c2612ea4565b634e487b7160e01b5f52600160045260245ffd5b634e487b7160e01b5f52603160045260245ffd5b5f6001600160401b0382168061239857612398612ea4565b80820281158282048414176106c2576106c2612ea4565b5f60208284031215612f45575f80fd5b5051919050565b634e487b7160e01b5f52601260045260245ffd5b5f82612f6e57612f6e612f4c565b500690565b5f82612f8157612f81612f4c565b500490565b6001600160401b03818116838216028082169190828114612fa957612fa9612ea4565b505092915050565b5f6001600160401b03808316818103612fcc57612fcc612ea4565b6001019392505050565b5f60018201612fe757612fe7612ea4565b506001019056fe02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800a164736f6c6343000818000a" - - HashConsensus = web3.eth.contract(ContractFactoryClass=HashConsensusContract, bytecode=hash_consensus_bin) - - report_processor = web3.to_checksum_address(csm.oracle.address) - admin = web3.to_checksum_address(web3.eth.accounts[0]) - - tx = HashConsensus.constructor( - slotsPerEpoch=32, - secondsPerSlot=12, - genesisTime=genesis_time, - epochsPerFrame=frame_config.frame_size, - fastLaneLengthSlots=frame_config.fast_lane, - admin=admin, - reportProcessor=report_processor, - ) - - tx_receipt = web3.eth.wait_for_transaction_receipt(web3.eth.send_transaction(tx.build_transaction({'from': admin}))) - - new_consensus_address = tx_receipt.contractAddress - - new_consensus = web3.eth.contract(address=new_consensus_address, ContractFactoryClass=HashConsensusContract) - - DEFAULT_ADMIN_ROLE = "0x" + new_consensus.functions.DEFAULT_ADMIN_ROLE().call().hex() - default_admin = new_consensus.functions.getRoleMember(DEFAULT_ADMIN_ROLE, 0).call() - - new_initial_epoch = new_consensus.functions.updateInitialEpoch(frame_config.initial_epoch) - web3.eth.send_transaction(new_initial_epoch.build_transaction({'from': default_admin})) - - MANAGE_CONSENSUS_CONTRACT_ROLE = "0x" + csm.oracle.functions.MANAGE_CONSENSUS_CONTRACT_ROLE().call().hex() - oracle_admin = csm.oracle.functions.getRoleMember(DEFAULT_ADMIN_ROLE, 0).call() - web3.provider.make_request('anvil_setBalance', [oracle_admin, hex(10**18)]) - - tx_grant_role = csm.oracle.functions.grantRole(MANAGE_CONSENSUS_CONTRACT_ROLE, admin) - web3.eth.send_transaction(tx_grant_role.build_transaction({'from': oracle_admin})) - - tx = csm.oracle.functions.setConsensusContract(new_consensus_address) - web3.eth.send_transaction(tx.build_transaction({'from': admin})) - - storage_slot = web3.keccak(text="lido.BaseOracle.lastProcessingRefSlot") - web3.provider.make_request('anvil_setStorageAt', [csm.oracle.address, storage_slot, bytes(32)]) - - yield cast( - HashConsensusContract, - web3.eth.contract( - address=new_consensus_address, - ContractFactoryClass=HashConsensusContract, - decode_tuples=True, - ), - ) - - -@pytest.fixture() -def use_fork_accounts_as_reporters(web3, consensus, fork_accounts): - addresses, private_keys = fork_accounts - - DEFAULT_ADMIN_ROLE = "0x" + consensus.functions.DEFAULT_ADMIN_ROLE().call().hex() - MANAGE_MEMBERS_AND_QUORUM_ROLE = "0x" + consensus.functions.MANAGE_MEMBERS_AND_QUORUM_ROLE().call().hex() - - hash_consensus_admin = consensus.functions.getRoleMember(DEFAULT_ADMIN_ROLE, 0).call() - - # two first accounts are used for report - for address in addresses[:2]: - tx_grant_role = consensus.functions.grantRole(DEFAULT_ADMIN_ROLE, address) - web3.eth.send_transaction(tx_grant_role.build_transaction({'from': hash_consensus_admin})) - - tx_grant_role = consensus.functions.grantRole(MANAGE_MEMBERS_AND_QUORUM_ROLE, address) - web3.eth.send_transaction(tx_grant_role.build_transaction({'from': address})) - - current_quorum = consensus.functions.getQuorum().call() - tx_add_member = consensus.functions.addMember(address, current_quorum + 1) - web3.eth.send_transaction(tx_add_member.build_transaction({'from': address})) - - return private_keys[:2] - - -@pytest.fixture() -def adjust_cl_client(monkeypatch, web3, running_slots): - - get_next, get_current = running_slots - - def get_block_root(self, state_id: SlotNumber | BlockRoot | LiteralState) -> BlockRootResponse: - """ - Spec: https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockRoot - - There is no cache because this method is used to get finalized and head blocks. - """ - - def _inner(_state_id: SlotNumber | BlockRoot | LiteralState): - data, _ = self._get( - self.API_GET_BLOCK_ROOT, - path_params=(_state_id,), - ) - if not isinstance(data, dict): - raise ValueError("Expected mapping response from getBlockRoot") - return BlockRootResponse.from_response(**data) - - if state_id not in ['justified', 'finalized', 'head']: - return _inner(state_id) - - if state_id in ['finalized', 'head']: - current = get_current() - if not current: - raise ValueError("No current running slot number available") - - if state_id == 'finalized': - finalized = get_next_non_missed_slot( - self, - current, - finalized_slot, - ).message.slot - return _inner(SlotNumber(int(finalized))) - - if state_id == 'head': - possible_head = (((current * 32) + 1) // 32) + 32 - head = get_next_non_missed_slot( - self, - SlotNumber(possible_head), - finalized_slot, - ).message.slot - return _inner(SlotNumber(int(head))) - - raise ValueError(f"Unknown state_id for patching: {state_id}") - - def get_block_details(self, state_id: SlotNumber | BlockRoot) -> BlockDetailsResponse: - """Spec: https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockV2""" - data, _ = self._get( - self.API_GET_BLOCK_DETAILS, - path_params=(state_id,), - ) - if not isinstance(data, dict): - raise ValueError("Expected mapping response from getBlockV2") - slot_details = BlockDetailsResponse.from_response(**data) - block_from_fork = None - while not block_from_fork: - try: - block_from_fork = web3.eth.get_block(int(slot_details.message.body.execution_payload.block_number)) - except Exception as e: - logger.debug(f"FORKED CLIENT: {e}") - if not block_from_fork: - latest = web3.eth.get_block('latest') - diff = int(slot_details.message.body.execution_payload.block_number) - int(latest['number']) - for _ in range(diff): - web3.provider.make_request('evm_mine', []) - logger.debug(f"FORKED CLIENT: Mined block {web3.eth.block_number}") - 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 - - with monkeypatch.context(): - monkeypatch.setattr( - ConsensusClient, - "get_block_details", - get_block_details, - ) - monkeypatch.setattr( - ConsensusClient, - "get_block_root", - get_block_root, - ) - yield - - -@pytest.fixture() -def mock_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, - ) - yield - - -@pytest.fixture() -def module(web3, mock_ipfs_client, zero_min_checkpoint_step, adjust_cl_client): - cc = ConsensusClientModule(variables.CONSENSUS_CLIENT_URI, web3) - kac = KeysAPIClientModule(variables.KEYS_API_URI, web3) - ipfs = MultiIPFSProvider(ipfs_providers()) - web3.attach_modules( - { - 'lido_contracts': LidoContracts, - 'lido_validators': LidoValidatorsProvider, - 'transaction': TransactionUtils, - 'cc': lambda: cc, # type: ignore[dict-item] - 'kac': lambda: kac, # type: ignore[dict-item] - "ipfs": lambda: ipfs, - "csm": CSM, - } - ) - _module = CSOracle(web3) - yield _module - subprocess.run(['rm', 'cache.pkl']) - - -def first_slot_of_epoch(epoch: int) -> SlotNumber: - return SlotNumber(epoch * 32 - 31) - - -@pytest.mark.fork -@pytest.mark.parametrize( - 'running_slots', - [ - [first_slot_of_epoch(i) for i in range(frame_config.initial_epoch - 2, frame_config.initial_epoch + 6)], - [first_slot_of_epoch(i) for i in range(frame_config.initial_epoch + 2, frame_config.initial_epoch + 6)], - ], - ids=['start_before_initial_epoch', 'start_after_initial_epoch'], - indirect=True, -) -def test_execute_module( - monkeypatch, - running_slots, - use_fork_accounts_as_reporters, - consensus, - module: CSOracle, -): - - get_next, _ = running_slots - - initial_ref_slot = consensus.get_initial_ref_slot() - to_distribute_before_report = module.w3.csm.fee_distributor.shares_to_distribute() - - while get_next(): - - block_root = BlockRoot(module.w3.cc.get_block_root('finalized').root) - block_details = module.w3.cc.get_block_details(block_root) - bs = build_blockstamp(block_details) - - for pk in use_fork_accounts_as_reporters: - if module.w3.csm.oracle.get_last_processing_ref_slot() == initial_ref_slot: - # finished, no need to continue trying to submit reports - break - with monkeypatch.context(): - monkeypatch.setattr( - variables, - "ACCOUNT", - Account.from_key(pk), - ) - module.run_cycle(blockstamp=bs) - - last_processing_after_report = module.w3.csm.oracle.get_last_processing_ref_slot() - assert last_processing_after_report == initial_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_accounting_cycle.py b/tests/fork/test_accounting_cycle.py new file mode 100644 index 000000000..f01ae9626 --- /dev/null +++ b/tests/fork/test_accounting_cycle.py @@ -0,0 +1,83 @@ +import pytest + +from src import variables +from src.modules.accounting.accounting import Accounting +from src.web3py.extensions import KeysAPIClientModule, LidoContracts, LidoValidatorsProvider, TransactionUtils +from tests.fork.conftest import first_slot_of_epoch + + +@pytest.fixture() +def module(forked_web3, patched_cl_client): + kac = KeysAPIClientModule(variables.KEYS_API_URI, forked_web3) + forked_web3.attach_modules( + { + 'lido_contracts': LidoContracts, + 'lido_validators': LidoValidatorsProvider, + 'transaction': TransactionUtils, + # "csm": lambda: csm_extension, + 'cc': lambda: patched_cl_client, # type: ignore[dict-item] + 'kac': lambda: kac, # type: ignore[dict-item] + # "ipfs": lambda: _, + } + ) + _module = Accounting(forked_web3) + yield _module + + +@pytest.fixture() +def report_contract(module): + yield module.report_contract + + +@pytest.fixture() +def hash_consensus_bin(): + with open('tests/fork/contracts/accounting/HashConsensus_bin', 'r') as f: + yield f.read() + + +@pytest.fixture +def start_before_initial_epoch(frame_config): + _from = frame_config.initial_epoch - 1 + _to = frame_config.initial_epoch + 3 + return [first_slot_of_epoch(i) for i in range(_from, _to)] + + +@pytest.fixture +def start_after_initial_epoch(frame_config): + _from = frame_config.initial_epoch + 1 + _to = frame_config.initial_epoch + 3 + return [first_slot_of_epoch(i) for i in range(_from, _to)] + + +@pytest.fixture +def missed_initial_frame(frame_config): + _from = frame_config.initial_epoch + frame_config.epochs_per_frame + 1 + _to = _from + 3 + return [first_slot_of_epoch(i) for i in range(_from, _to)] + + +@pytest.mark.fork +@pytest.mark.parametrize( + 'running_finalized_slots', + [start_before_initial_epoch, start_after_initial_epoch, missed_initial_frame], + indirect=True, +) +def test_accounting_report( + forked_web3, set_oracle_members, running_finalized_slots, account_from, module, new_hash_consensus +): + 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 = module.get_initial_or_current_frame(module._receive_last_finalized_slot()) + + switch_finalized, current = running_finalized_slots + while switch_finalized(): + for _, private_key in members: + # NOTE: reporters using the same cache + with account_from(private_key): + module.cycle_handler() + + 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/fork/test_csm_cycle.py b/tests/fork/test_csm_cycle.py new file mode 100644 index 000000000..3cc947e19 --- /dev/null +++ b/tests/fork/test_csm_cycle.py @@ -0,0 +1,115 @@ +import subprocess + +import pytest + +from src import variables +from src.main import ipfs_providers +from src.modules.csm.csm import CSOracle +from src.providers.ipfs import MultiIPFSProvider, CID +from src.web3py.extensions import KeysAPIClientModule, LidoContracts, LidoValidatorsProvider, TransactionUtils, CSM +from tests.fork.conftest import first_slot_of_epoch + + +@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 hash_consensus_bin(): + with open('tests/fork/contracts/csm/HashConsensus_bin', 'r') as f: + yield f.read() + + +@pytest.fixture() +def csm_extension(forked_web3): + yield CSM(forked_web3) + + +@pytest.fixture() +def report_contract(csm_extension): + yield csm_extension.oracle + + +@pytest.fixture() +def module(forked_web3, patched_cl_client, csm_extension, mocked_ipfs_client): + kac = KeysAPIClientModule(variables.KEYS_API_URI, forked_web3) + forked_web3.attach_modules( + { + 'lido_contracts': LidoContracts, + 'lido_validators': LidoValidatorsProvider, + 'transaction': TransactionUtils, + "csm": lambda: csm_extension, + 'cc': lambda: patched_cl_client, # type: ignore[dict-item] + 'kac': lambda: kac, # type: ignore[dict-item] + "ipfs": lambda: mocked_ipfs_client, + } + ) + _module = CSOracle(forked_web3) + yield _module + subprocess.run(['rm', 'cache.pkl']) + + +@pytest.fixture +def start_before_initial_epoch(frame_config): + _from = frame_config.initial_epoch - 2 + _to = frame_config.initial_epoch + 6 + return [first_slot_of_epoch(i) for i in range(_from, _to)] + + +@pytest.fixture +def start_after_initial_epoch(frame_config): + _from = frame_config.initial_epoch + 2 + _to = frame_config.initial_epoch + 6 + return [first_slot_of_epoch(i) for i in range(_from, _to)] + + +@pytest.fixture +def missed_initial_frame(frame_config): + _from = frame_config.initial_epoch + frame_config.epochs_per_frame + 1 + _to = _from + 6 + return [first_slot_of_epoch(i) for i in range(_from, _to)] + + +@pytest.mark.fork +@pytest.mark.parametrize( + 'running_finalized_slots', + [start_before_initial_epoch, start_after_initial_epoch, missed_initial_frame], + indirect=True, +) +def test_execute_module( + running_finalized_slots, + new_hash_consensus, + set_oracle_members, + module: CSOracle, + 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 = module.get_initial_or_current_frame(module._receive_last_finalized_slot()) + to_distribute_before_report = module.w3.csm.fee_distributor.shares_to_distribute() + + switch_finalized, current = running_finalized_slots + while switch_finalized(): + for _, private_key in members: + # NOTE: reporters using the same cache + with account_from(private_key): + module.cycle_handler() + + 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_ejector_cycle.py b/tests/fork/test_ejector_cycle.py new file mode 100644 index 000000000..f2670f929 --- /dev/null +++ b/tests/fork/test_ejector_cycle.py @@ -0,0 +1,83 @@ +import pytest + +from src import variables +from src.modules.ejector.ejector import Ejector +from src.web3py.extensions import KeysAPIClientModule, LidoContracts, LidoValidatorsProvider, TransactionUtils +from tests.fork.conftest import first_slot_of_epoch + + +@pytest.fixture() +def module(forked_web3, patched_cl_client): + kac = KeysAPIClientModule(variables.KEYS_API_URI, forked_web3) + forked_web3.attach_modules( + { + 'lido_contracts': LidoContracts, + 'lido_validators': LidoValidatorsProvider, + 'transaction': TransactionUtils, + # "csm": lambda: csm_extension, + 'cc': lambda: patched_cl_client, # type: ignore[dict-item] + 'kac': lambda: kac, # type: ignore[dict-item] + # "ipfs": lambda: _, + } + ) + _module = Ejector(forked_web3) + yield _module + + +@pytest.fixture() +def report_contract(module): + yield module.report_contract + + +@pytest.fixture() +def hash_consensus_bin(): + with open('tests/fork/contracts/ejector/HashConsensus_bin', 'r') as f: + yield f.read() + + +@pytest.fixture +def start_before_initial_epoch(frame_config): + _from = frame_config.initial_epoch - 1 + _to = frame_config.initial_epoch + 3 + return [first_slot_of_epoch(i) for i in range(_from, _to)] + + +@pytest.fixture +def start_after_initial_epoch(frame_config): + _from = frame_config.initial_epoch + 1 + _to = frame_config.initial_epoch + 3 + return [first_slot_of_epoch(i) for i in range(_from, _to)] + + +@pytest.fixture +def missed_initial_frame(frame_config): + _from = frame_config.initial_epoch + frame_config.epochs_per_frame + 1 + _to = _from + 3 + return [first_slot_of_epoch(i) for i in range(_from, _to)] + + +@pytest.mark.fork +@pytest.mark.parametrize( + 'running_finalized_slots', + [start_before_initial_epoch, start_after_initial_epoch, missed_initial_frame], + indirect=True, +) +def test_ejector_report( + forked_web3, set_oracle_members, running_finalized_slots, account_from, module, new_hash_consensus +): + 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 = module.get_initial_or_current_frame(module._receive_last_finalized_slot()) + + switch_finalized, current = running_finalized_slots + while switch_finalized(): + for _, private_key in members: + # NOTE: reporters using the same cache + with account_from(private_key): + module.cycle_handler() + + 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" From a7577e4a62496be6d27bc37a353226ddd1fd7861 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Tue, 17 Dec 2024 15:31:07 +0100 Subject: [PATCH 05/27] feat: workflow --- .github/workflows/fork_tests.yml | 55 ++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/fork_tests.yml diff --git a/.github/workflows/fork_tests.yml b/.github/workflows/fork_tests.yml new file mode 100644 index 000000000..4705c773e --- /dev/null +++ b/.github/workflows/fork_tests.yml @@ -0,0 +1,55 @@ +name: 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: Fork tests + run: poetry run pytest -m 'fork' 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" + diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7d765b733..e89b672df 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,7 +31,7 @@ jobs: poetry install --no-interaction --with=dev - name: Test with pytest - run: poetry run pytest --cov=src tests + run: poetry run pytest -m 'not fork' --cov=src tests env: EXECUTION_CLIENT_URI: ${{ secrets.EXECUTION_CLIENT_URI }} CONSENSUS_CLIENT_URI: ${{ secrets.CONSENSUS_CLIENT_URI }} From ba92c90af9fcb66b0f27a698c27fba854eba766c Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Wed, 18 Dec 2024 14:41:51 +0100 Subject: [PATCH 06/27] fix: linter --- tests/fork/conftest.py | 96 ++++++++++++------- .../fork/contracts/ejector/HashConsensus_bin | 1 - .../{accounting => lido}/HashConsensus_bin | 0 tests/fork/test_accounting_cycle.py | 83 ---------------- ..._csm_cycle.py => test_csm_oracle_cycle.py} | 58 +++-------- ...tor_cycle.py => test_lido_oracle_cycle.py} | 52 +++++----- 6 files changed, 107 insertions(+), 183 deletions(-) delete mode 100644 tests/fork/contracts/ejector/HashConsensus_bin rename tests/fork/contracts/{accounting => lido}/HashConsensus_bin (100%) delete mode 100644 tests/fork/test_accounting_cycle.py rename tests/fork/{test_csm_cycle.py => test_csm_oracle_cycle.py} (61%) rename tests/fork/{test_ejector_cycle.py => test_lido_oracle_cycle.py} (61%) diff --git a/tests/fork/conftest.py b/tests/fork/conftest.py index 376c6af90..1c182cffb 100644 --- a/tests/fork/conftest.py +++ b/tests/fork/conftest.py @@ -12,12 +12,13 @@ from web3_multi_provider import MultiProvider from src import variables -from src.main import logger +from src.main import logger, ipfs_providers 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.slot import get_next_non_missed_slot @@ -27,6 +28,7 @@ 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, CSM logger = logger.getChild("fork") @@ -49,7 +51,7 @@ def _use(pk: str): monkeypatch.setattr( variables, "ACCOUNT", - Account.from_key(pk), + Account.from_key(private_key=pk), # pylint: disable=no-value-for-parameter ) logger.info(f"Switched to ACCOUNT {variables.ACCOUNT.address}") yield @@ -125,7 +127,7 @@ def blockstamp_for_forking( @pytest.fixture() -def run_fork(blockstamp_for_forking: BlockStamp): +def forked_el_client(blockstamp_for_forking: BlockStamp): cli_params = [ 'anvil', '--config-out', @@ -136,32 +138,60 @@ def run_fork(blockstamp_for_forking: BlockStamp): '--fork-block-number', str(blockstamp_for_forking.block_number), ] - process = subprocess.Popen(cli_params) - time.sleep(5) - logger.info(f"Started fork from block {blockstamp_for_forking.block_number}") - yield process - process.terminate() - process.wait() - subprocess.run(['rm', 'localhost.json']) + with subprocess.Popen(cli_params) as process: + time.sleep(5) + logger.info(f"Started fork from block {blockstamp_for_forking.block_number}") + web3 = Web3(MultiProvider(['http://127.0.0.1:8545'], 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]) + yield web3 + process.terminate() + process.wait() + subprocess.run(['rm', 'localhost.json'], check=True) @pytest.fixture() -def forked_web3(run_fork) -> Web3: - web3 = Web3(MultiProvider(['http://127.0.0.1:8545'], 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]) - yield web3 +def csm_extension(forked_el_client): + return CSM(forked_el_client) @pytest.fixture() -def accounts_from_fork(forked_web3): +def web3(forked_el_client, patched_cl_client, csm_extension, 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": lambda: csm_extension, # 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): with open('localhost.json') as f: data = json.load(f) addresses = data['available_accounts'] private_keys = data['private_keys'] - return [forked_web3.to_checksum_address(address) for address in addresses], private_keys + return [forked_el_client.to_checksum_address(address) for address in addresses], private_keys @pytest.fixture @@ -182,7 +212,7 @@ def switch() -> SlotNumber | None: @pytest.fixture() -def patched_cl_client(monkeypatch, forked_web3, real_cl_client, real_finalized_slot, running_finalized_slots): +def patched_cl_client(monkeypatch, forked_el_client, real_cl_client, real_finalized_slot, running_finalized_slots): _, current = running_finalized_slots @@ -231,20 +261,20 @@ def get_block_details(self, state_id: SlotNumber | BlockRoot) -> BlockDetailsRes block_from_fork = None while not block_from_fork: try: - block_from_fork = forked_web3.eth.get_block( + block_from_fork = forked_el_client.eth.get_block( int(slot_details.message.body.execution_payload.block_number) ) - except Exception as e: + except Exception as e: # pylint: disable=broad-exception-caught logger.debug(f"FORKED CLIENT: {e}") if not block_from_fork: - latest_el = int(forked_web3.eth.get_block('latest')['number']) + 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"Latest block {latest_el} is ahead block {from_cl}") for _ in range(diff): - forked_web3.provider.make_request(RPCEndpoint('evm_mine'), []) - logger.debug(f"FORKED CLIENT: Mined block {forked_web3.eth.block_number}") + forked_el_client.provider.make_request(RPCEndpoint('evm_mine'), []) + logger.debug(f"FORKED CLIENT: Mined block {forked_el_client.eth.block_number}") time.sleep(0.1) slot_details.message.body.execution_payload.block_number = block_from_fork['number'] @@ -272,7 +302,7 @@ def hash_consensus_bin(): @pytest.fixture() def new_hash_consensus( - forked_web3, + forked_el_client, real_cl_client, frame_config, accounts_from_fork, @@ -282,8 +312,10 @@ def new_hash_consensus( addresses, _ = accounts_from_fork admin, *_ = addresses - HashConsensus = forked_web3.eth.contract(ContractFactoryClass=HashConsensusContract, bytecode=hash_consensus_bin) - new_consensus_address = forked_web3.eth.wait_for_transaction_receipt( + 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, @@ -297,7 +329,7 @@ def new_hash_consensus( new_consensus = cast( HashConsensusContract, - forked_web3.eth.contract( + forked_el_client.eth.contract( address=new_consensus_address, ContractFactoryClass=HashConsensusContract, decode_tuples=True ), ) @@ -307,14 +339,14 @@ def new_hash_consensus( new_consensus.functions.updateInitialEpoch(frame_config.initial_epoch).transact({'from': default_admin}) oracle_admin = report_contract.functions.getRoleMember(DEFAULT_ADMIN_ROLE, 0).call() - forked_web3.provider.make_request('anvil_setBalance', [oracle_admin, hex(10**18)]) + 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_web3.keccak(text="lido.BaseOracle.lastProcessingRefSlot") - forked_web3.provider.make_request('anvil_setStorageAt', [report_contract.address, storage_slot, bytes(32)]) + 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 diff --git a/tests/fork/contracts/ejector/HashConsensus_bin b/tests/fork/contracts/ejector/HashConsensus_bin deleted file mode 100644 index fead30ac3..000000000 --- a/tests/fork/contracts/ejector/HashConsensus_bin +++ /dev/null @@ -1 +0,0 @@ -60e06040523480156200001157600080fd5b5060405162003b0a38038062003b0a83398101604081905262000034916200060f565b86620000535760405163fb305deb60e01b815260040160405180910390fd5b85620000725760405163fb305deb60e01b815260040160405180910390fd5b6200008887620001c760201b62000e281760201c565b6001600160401b0316608052620000ab86620001c7602090811b62000e2817901c565b6001600160401b031660a052620000ce85620001c7602090811b62000e2817901c565b6001600160401b031660c0526001600160a01b0382166200010257604051636b35b1b760e01b815260040160405180910390fd5b6001600160a01b0381166200012a5760405163154f6dd160e31b815260040160405180910390fd5b6200013760008362000238565b60006200014b6001600160401b0362000248565b905062000199818686604051806060016040528060006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b03168152506200026560201b60201c565b50600880546001600160a01b0319166001600160a01b039290921691909117905550620006ec945050505050565b60006001600160401b03821115620002345760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b606482015260840160405180910390fd5b5090565b62000244828262000431565b5050565b60006200025f620002598362000492565b620004c5565b92915050565b82620002845760405163ef3d10c160e01b815260040160405180910390fd5b6080516200029c906001600160401b0316846200068d565b821115620002bd576040516385b552e160e01b815260040160405180910390fd5b6040518060600160405280620002de86620001c760201b62000e281760201c565b6001600160401b031681526020016200030285620001c760201b62000e281760201c565b6001600160401b031681526020016200032684620001c760201b62000e281760201c565b6001600160401b0390811690915281516000805460208501516040909501518416600160801b02600160801b600160c01b031995851668010000000000000000026001600160801b03199092169385169390931717939093161790915581511684141580620003a2575080602001516001600160401b03168314155b15620003e25760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b031682146200042b576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15b50505050565b620004488282620004e060201b62000e941760201c565b6200048d817f8f8c450dae5029cd48cd91dd9db65da48fb742893edfc7941250f6721d93cbbe6000858152602091825260409020919062000f0a62000582821b17901c565b505050565b600060a0516001600160401b031660c0516001600160401b031683620004b99190620006af565b6200025f9190620006c9565b60006080516001600160401b0316826200025f9190620006c9565b600082815260008051602062003aea833981519152602090815260408083206001600160a01b038516845290915290205460ff166200024457600082815260008051602062003aea833981519152602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600062000599836001600160a01b038416620005a0565b9392505050565b6000818152600183016020526040812054620005e9575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556200025f565b5060006200025f565b80516001600160a01b03811681146200060a57600080fd5b919050565b600080600080600080600060e0888a0312156200062b57600080fd5b87519650602088015195506040880151945060608801519350608088015192506200065960a08901620005f2565b91506200066960c08901620005f2565b905092959891949750929550565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615620006aa57620006aa62000677565b500290565b600082821015620006c457620006c462000677565b500390565b600082620006e757634e487b7160e01b600052601260045260246000fd5b500490565b60805160a05160c05161338f6200075b600039600081816103c0015281816119230152612e6401526000818161039c015281816118f90152612e30015260008181610378015281816113cc01528181611b2701528181612777015281816127e00152612ca3015261338f6000f3fe608060405234801561001057600080fd5b506004361061021c5760003560e01c80636fb1bf6611610125578063ad231cb2116100ad578063d547741f1161007c578063d547741f146105c8578063e33a8d39146105db578063e76cd4e0146105ee578063ea87627d14610601578063fb4209ac1461062657600080fd5b8063ad231cb214610592578063c1ba4e591461059a578063c26c12eb146105ad578063ca15c873146105b557600080fd5b806398041ea3116100f457806398041ea31461054757806399229f581461055a5780639eab52531461056d578063a1e07cac14610575578063a217fddf1461058a57600080fd5b80636fb1bf66146104c157806372f79b13146105045780639010d07c1461052157806391d148541461053457600080fd5b8063323a41f6116101a8578063606c0c9411610177578063606c0c941461036b5780636095012f146103fe57806360a50a5c1461040657806360e618011461042d5780636d0582681461049c57600080fd5b8063323a41f61461031c57806334aa67531461032f57806336568abe14610342578063433ab1f31461035557600080fd5b806320b4d751116101ef57806320b4d751146102a6578063239c327f146102b9578063248a9ca3146102e05780632f2ff15d146102f35780632fd2d7501461030657600080fd5b806301ffc9a714610221578063115a57c41461024957806316f6f03e1461027e5780631951c03714610293575b600080fd5b61023461022f366004612e89565b61064d565b60405190151581526020015b60405180910390f35b6102707f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe81565b604051908152602001610240565b61029161028c366004612ecf565b610678565b005b6102346102a1366004612ef9565b6106a0565b6102346102b4366004612ef9565b6106c0565b6102707f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d671781565b6102706102ee366004612f14565b6106ff565b610291610301366004612f2d565b610721565b61030e61073e565b604051610240929190612f94565b61029161032a366004612f14565b61088f565b61029161033d366004612fe1565b610955565b610291610350366004612f2d565b610a18565b61035d610a9b565b604051610240929190613003565b6103e36001600160401b037f00000000000000000000000000000000000000000000000000000000000000008116917f00000000000000000000000000000000000000000000000000000000000000008216917f00000000000000000000000000000000000000000000000000000000000000001690565b60408051938452602084019290925290820152606001610240565b610270610ab0565b6102707f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc081565b61044061043b366004612ef9565b610ac3565b6040516102409190600060e082019050825182526020830151602083015260408301511515604083015260608301511515606083015260808301511515608083015260a083015160a083015260c083015160c083015292915050565b6008546001600160a01b03165b6040516001600160a01b039091168152602001610240565b604080516060810182526000546001600160401b03808216808452600160401b8304821660208501819052600160801b90930490911692909301829052906103e3565b61050c610c6c565b60408051928352602083019190915201610240565b6104a961052f366004612fe1565b610c8e565b610234610542366004612f2d565b610cb3565b610291610555366004612ecf565b610ceb565b610291610568366004612f14565b610d0e565b61035d610d42565b6102706000805160206132fa83398151915281565b610270600081565b610291610d4f565b6102916105a8366004612f14565b610d61565b600554610270565b6102706105c3366004612f14565b610d72565b6102916105d6366004612f2d565b610d96565b6102916105e9366004613045565b610db3565b6102916105fc366004612ef9565b610dbe565b610609610df2565b604080519384526020840192909252151590820152606001610240565b6102707fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e81565b60006001600160e01b03198216635a05180f60e01b1480610672575061067282610f1f565b92915050565b6000805160206132fa8339815191526106918133610f54565b61069b8383610fb8565b505050565b6001600160a01b0381166000908152600360205260408120541515610672565b6001600160a01b03811660009081526003602052604081205480158015906106f857506106f8600182036106f26112ba565b51611324565b9392505050565b600090815260008051602061333a833981519152602052604090206001015490565b61072a826106ff565b6107348133610f54565b61069b838361135f565b6060806107496112ba565b602001516004546001600160401b031614610762579091565b600754806001600160401b0381111561077d5761077d613071565b6040519080825280602002602001820160405280156107a6578160200160208202803683370190505b509250806001600160401b038111156107c1576107c1613071565b6040519080825280602002602001820160405280156107ea578160200160208202803683370190505b50915060005b8181101561088957600081815260066020908152604091829020825180840190935280548084526001909101546001600160401b031691830191909152855186908490811061084157610841613087565b60200260200101818152505080602001516001600160401b031684838151811061086d5761086d613087565b602090810291909101015250610882816130b3565b90506107f0565b50509091565b600061089b8133610f54565b604080516060810182526000546001600160401b03808216808452600160401b830482166020850152600160801b9092041692820192909252906108de4261138e565b106108fc576040516329d1e0ff60e01b815260040160405180910390fd5b6109228382602001516001600160401b031683604001516001600160401b0316846113a1565b61092a611558565b6109326115d5565b60200151101561069b576040516323ca23a760e21b815260040160405180910390fd5b7f921f40f434e049d23969cbe68d9cf3ac1013fbe8945da07963af6f3142de6afe6109808133610f54565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b90910416928201929092524291906109c790839061163c565b604080516060810182526000546001600160401b038082168352600160401b820481166020840152600160801b9091041691810191909152909150610a11908290879087906113a1565b5050505050565b6001600160a01b0381163314610a8d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610a978282611651565b5050565b606080610aa86001611680565b915091509091565b6000610aba6115d5565b60200151905090565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905290610b046112ba565b602081018051845251600554919250610b1c9161185a565b50506020808401919091526001600160a01b0384166000908152600390915260409081902054801580159285019290925290610c655780600190039050600060018281548110610b6e57610b6e613087565b6000918252602091829020604080518082019091529101546001600160401b03808216808452600160401b909204168284015260a087018190529185015190925014610bbb576000610bda565b6020808201516001600160401b03166000908152600690915260409020545b60c08501526000610bea426118f5565b905083604001518111158015610c0a5750610c03611558565b8460200151115b151560808601528351610c1e908490611324565b15801560608701819052610c33575084608001515b15610c62576000546020850151610c5a91600160801b90046001600160401b0316906130ce565b811160808601525b50505b5050919050565b6000806000610c796112ba565b90508060200151816040015192509250509091565b600082815260008051602061331a833981519152602052604081206106f89083611960565b600091825260008051602061333a833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6000805160206132fa833981519152610d048133610f54565b61069b838361196c565b7f4af6faa30fabb2c4d8d567d06168f9be8adb583156c1ecb424b4832a7e4d6717610d398133610f54565b610a9782611ae6565b606080610aa86000611680565b600154610d5f9060001990611bf5565b565b600154610d6f908290611bf5565b50565b600081815260008051602061331a8339815191526020526040812061067290611cfc565b610d9f826106ff565b610da98133610f54565b61069b8383611651565b61069b838383611d06565b7fc5219a8d2d0107a57aad00b22081326d173df87bad251126f070df2659770c3e610de98133610f54565b610a978261225f565b6000806000610dff6112ba565b602001519250610e118360055461185a565b50909250839050610e20611558565b149050909192565b60006001600160401b03821115610e905760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b6064820152608401610a84565b5090565b610e9e8282610cb3565b610a9757600082815260008051602061333a833981519152602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b60006106f8836001600160a01b038416612488565b60006001600160e01b03198216637965db0b60e01b148061067257506301ffc9a760e01b6001600160e01b0319831614610672565b610f5e8282610cb3565b610a9757610f76816001600160a01b031660146124d7565b610f818360206124d7565b604051602001610f92929190613112565b60408051601f198184030181529082905262461bcd60e51b8252610a8491600401613187565b6000610fc383612672565b60018054919250600091610fd791906131ba565b905080821115610fe957610fe96131d1565b600060018381548110610ffe57610ffe613087565b6000918252602091829020604080518082019091529101546001600160401b038082168352600160401b909104169181019190915290508282146111525760006002838154811061105157611051613087565b600091825260209091200154600280546001600160a01b03909216925082918690811061108057611080613087565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600183815481106110c1576110c1613087565b90600052602060002001600185815481106110de576110de613087565b600091825260209091208254910180546001600160401b0392831667ffffffffffffffff1982168117835593546001600160801b0319909116909317600160401b938490049092169092021790556111378460016130ce565b6001600160a01b039091166000908152600360205260409020555b6001805480611163576111636131e7565b600082815260209020810160001990810180546001600160801b03191690550190556002805480611196576111966131e7565b60008281526020808220600019908401810180546001600160a01b03191690559092019092556001600160a01b038716808352600382526040808420939093558251858152918201879052917fa182730913550d27dc6c5813fad297cb0785871bec3d0152c5650e59c5d39d60910160405180910390a280516001600160401b0316156112b05760006112276112ba565b9050806020015182600001516001600160401b031614801561125357508060200151611251611558565b105b156112ae576020808301516001600160401b039081166000908152600690925260408220600101805490929161128991166131fd565b91906101000a8154816001600160401b0302191690836001600160401b031602179055505b505b610a118483611bf5565b6112de60405180606001604052806000815260200160008152602001600081525090565b61131f42604080516060810182526000546001600160401b038082168352600160401b820481166020840152600160801b90910416918101919091526126b3565b905090565b600154600090818061133685846126ea565b9150915080600014158015611355575061135586836001840386612726565b9695505050505050565b6113698282610e94565b600082815260008051602061331a8339815191526020526040902061069b9082610f0a565b600061067261139c836118f5565b612768565b826113bf5760405163ef3d10c160e01b815260040160405180910390fd5b6113f26001600160401b037f00000000000000000000000000000000000000000000000000000000000000001684613216565b821115611412576040516385b552e160e01b815260040160405180910390fd5b604051806060016040528061142686610e28565b6001600160401b0316815260200161143d85610e28565b6001600160401b0316815260200161145484610e28565b6001600160401b0390811690915281516000805460208501516040909501518416600160801b0267ffffffffffffffff60801b19958516600160401b026001600160801b031990921693851693909317179390931617909155815116841415806114cb575080602001516001600160401b03168314155b1561150a5760408051858152602081018590527fe343afa5219eaf28c50ce9cd658acd69cbe28b34fa773eb3a523e28007f64afc910160405180910390a15b80604001516001600160401b03168214611552576040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15b50505050565b60085460408051630d61356760e21b815290516000926001600160a01b031691633584d59c916004808301926020929190829003018186803b15801561159d57600080fd5b505afa1580156115b1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131f9190613235565b6115f960405180606001604052806000815260200160008152602001600081525090565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b909104169282019290925261131f919061279d565b60006106f861164b848461287b565b836128e5565b61165b8282612915565b600082815260008051602061331a8339815191526020526040902061069b9082612989565b600154606090819060008085156116ad576116a361169c6112ba565b51846126ea565b90925090506116b0565b50815b6116ba82826131ba565b6001600160401b038111156116d1576116d1613071565b6040519080825280602002602001820160405280156116fa578160200160208202803683370190505b50945084516001600160401b0381111561171657611716613071565b60405190808252806020026020018201604052801561173f578160200160208202803683370190505b509350815b818110156118515760006117588583613264565b905060006001828154811061176f5761176f613087565b60009182526020808320604080518082019091529201546001600160401b038082168452600160401b909104169082015291506117ac86856131ba565b9050600283815481106117c1576117c1613087565b9060005260206000200160009054906101000a90046001600160a01b03168982815181106117f1576117f1613087565b60200260200101906001600160a01b031690816001600160a01b03168152505081600001516001600160401b031688828151811061183157611831613087565b6020026020010181815250505050508061184a906130b3565b9050611744565b50505050915091565b600454600090819081906001600160401b031685146118835750600091506000199050816118ee565b505060075460009150600019908290815b818110156118eb576000818152600660205260409020600101546001600160401b03168681106118da5760008281526006602052604090205495509093509150826118eb565b506118e4816130b3565b9050611894565b50505b9250925092565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160401b03167f00000000000000000000000000000000000000000000000000000000000000006001600160401b03168361195691906131ba565b6106729190613278565b60006106f8838361299e565b6001600160a01b038216600090815260036020526040902054156119a357604051637670720160e11b815260040160405180910390fd5b6001600160a01b0382166119ca576040516303988b8160e61b815260040160405180910390fd5b6040805180820182526000808252602080830182815260018054808201825581855294517fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6909501805492516001600160401b03908116600160401b026001600160801b031990941696169590951791909117909355600280548085019091557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0388166001600160a01b03199091168117909155925483835260039091529083902081905591517fe17e0e2cd88e2144dd54f3d823c30d4569092bcac1aabaec1129883e9cc12d2e90611ad49084908690918252602082015260400190565b60405180910390a261069b8282611bf5565b604080516060810182526000546001600160401b038082168352600160401b8204811660208401819052600160801b909204169282019290925290611b4c907f00000000000000000000000000000000000000000000000000000000000000009061328c565b6001600160401b0316821115611b75576040516385b552e160e01b815260040160405180910390fd5b80604001516001600160401b03168214610a9757611b9282610e28565b600080546001600160401b0392909216600160801b0267ffffffffffffffff60801b199092169190911790556040518281527fab8b22776606cc75c47792d32af7e63ed9ca74e85c9780a7fc7994fdbd6fde2b9060200160405180910390a15050565b611c00600282613278565b8211611c4057611c11600282613278565b611c1c9060016130ce565b604051632b2dd84d60e01b8152600481019190915260248101839052604401610a84565b600554828114611cd957611c926000198414611c6a576000805160206132fa833981519152611c8c565b7f10b016346186602d93fc7a27ace09ba944baf9453611b186d36acd3d3d667dc05b33610f54565b600583905560408051848152602081018490529081018290527f9f40cfd22fe91777c78f252bd21a710f3fb007dc2f321876891e7644ba0ae1759060600160405180910390a15b6000546001600160401b0316611cee4261138e565b1061069b5761069b836129c8565b6000610672825490565b82611d2457604051631258e44360e01b815260040160405180910390fd5b6001600160401b03831115611d4c5760405163aac8f00960e01b815260040160405180910390fd5b81611d695760405162bf199760e01b815260040160405180910390fd5b6000611d7433612672565b9050600060018281548110611d8b57611d8b613087565b60009182526020808320604080518082019091529201546001600160401b038082168452600160401b90910416908201529150611dc6612a7c565b9050808414611df257604051632a37dd3d60e11b81526004810182905260248101859052604401610a84565b426000611dfe826118f5565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252919250611e4484836126b3565b905080602001518a14611e6a57604051631258e44360e01b815260040160405180910390fd5b8060400151831115611e8f57604051637c01d16560e11b815260040160405180910390fd5b81604001516001600160401b03168160200151611eac91906130ce565b8311158015611ec65750611ec4878260000151611324565b155b15611ee457604051633e1ca93d60e01b815260040160405180910390fd5b611eec611558565b8a11611f295785516001600160401b03168a1415611f1d57604051631cf7e8a160e31b815260040160405180910390fd5b50505050505050505050565b6004546000906001600160401b03168b14611f6257506004805467ffffffffffffffff19166001600160401b038c161790556000611f67565b506007545b6000805b82826001600160401b0316108015611f9b57506001600160401b0382166000908152600660205260409020548c14155b15611fb057611fa9826132bb565b9150611f6b565b88516001600160401b03168d141561208c5760208901516001600160401b0381168411611fdf57611fdf6131d1565b806001600160401b0316836001600160401b031614156120125760405163fd10cf7360e01b815260040160405180910390fd5b6001600160401b038082166000908152600660205260408120600101805491929091839161204091166131fd565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b03169050600160055461207d91906131ba565b81141561208957600192505b50505b600083836001600160401b031610156120fc576001600160401b038084166000908152600660205260408120600101805490926120c991166132bb565b91906101000a8154816001600160401b0302191690836001600160401b0316021790556001600160401b0316905061215d565b506040805180820182528d8152600160208083018281526001600160401b0387811660009081526006909352949091209251835551918101805467ffffffffffffffff19169290931691909117909155612155846130b3565b600781905593505b60405180604001604052808f6001600160401b03168152602001846001600160401b031681525060018c8154811061219757612197613087565b600091825260209182902083519101805493909201516001600160401b03908116600160401b026001600160801b03199094169116179190911790556121da3390565b6001600160a01b03168e7f92f77576dabd7bad26f75c36abb3021b5bbb66a3e5688570a0355daddd4174888f60405161221591815260200190565b60405180910390a360055481106122405761223b858e856001600160401b031684612ac1565b61224f565b811561224f5761224f85612ba2565b5050505050505050505050505050565b6008546001600160a01b0390811690821661228d5760405163154f6dd160e31b815260040160405180910390fd5b806001600160a01b0316826001600160a01b031614156122c05760405163f1b3699f60e01b815260040160405180910390fd5b600880546001600160a01b0319166001600160a01b03848116918217909255604051918316917f3b59429457a41af89ea682ac9ed8abb8e99eb5c7d3363d5eedfc6bff6271a81e90600090a360006123166112ba565b90506000600460000160089054906101000a90046001600160401b03166001600160401b031690506000836001600160a01b0316633584d59c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561237957600080fd5b505afa15801561238d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b19190613235565b90506000856001600160a01b0316633584d59c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156123ee57600080fd5b505afa158015612402573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124269190613235565b905083602001518210801561243e5750836020015181105b801561244d5750836020015183145b1561248057600454600160801b90046001600160401b031660009081526006602052604090205461247e8582612c10565b505b505050505050565b60008181526001830160205260408120546124cf57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610672565b506000610672565b606060006124e6836002613216565b6124f19060026130ce565b6001600160401b0381111561250857612508613071565b6040519080825280601f01601f191660200182016040528015612532576020820181803683370190505b509050600360fc1b8160008151811061254d5761254d613087565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061257c5761257c613087565b60200101906001600160f81b031916908160001a90535060006125a0846002613216565b6125ab9060016130ce565b90505b6001811115612623576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106125df576125df613087565b1a60f81b8282815181106125f5576125f5613087565b60200101906001600160f81b031916908160001a90535060049490941c9361261c816132e2565b90506125ae565b5083156106f85760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a84565b6001600160a01b038116600090815260036020526040812054806126a957604051638d35f2ed60e01b815260040160405180910390fd5b6000190192915050565b6126d760405180606001604052806000815260200160008152602001600081525090565b6106f86126e4848461287b565b8361279d565b6005546000908190838110612705576000925083915061271e565b61270f8486613264565b925061271b81846130ce565b91505b509250929050565b60008161273385856131ba565b61273d9190613264565b828561274982896130ce565b61275391906131ba565b61275d9190613264565b111595945050505050565b60006106726001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683613278565b6127c160405180606001604052806000815260200160008152602001600081525090565b60006127cd84846128e5565b905060006127da82612c94565b905060007f0000000000000000000000000000000000000000000000000000000000000000856020015161280e919061328c565b612821906001600160401b0316836130ce565b9050604051806060016040528087815260200160018461284191906131ba565b6001600160401b03168152602001600061285c6001856131ba565b61286691906131ba565b6001600160401b031690529695505050505050565b6000806128878461138e565b83519091506001600160401b03168110156128b55760405163668441f560e11b815260040160405180910390fd5b602083015183516001600160401b03918216916128d39116836131ba565b6128dd9190613278565b949350505050565b600081602001516001600160401b0316836129009190613216565b82516106f891906001600160401b03166130ce565b61291f8282610cb3565b15610a9757600082815260008051602061333a833981519152602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006106f8836001600160a01b038416612cc9565b60008260000182815481106129b5576129b5613087565b9060005260206000200154905092915050565b60408051606081018252600080546001600160401b038082168452600160401b820481166020850152600160801b9091041692820192909252429190612a0f9083906126b3565b90508060400151612a1f836118f5565b1115612a2a57505050565b8060200151612a37611558565b10612a4157505050565b6000806000612a5484602001518761185a565b92509250925060008212612a7357612a6e84848484612ac1565b612480565b61248084612ba2565b60085460408051635be2042560e01b815290516000926001600160a01b031691635be20425916004808301926020929190829003018186803b15801561159d57600080fd5b6020840151600454600160401b90046001600160401b0316141580612af85750600454600160801b90046001600160401b03168214155b15611552576020840151600480546001600160401b03858116600160801b0267ffffffffffffffff60801b19918516600160401b029190911677ffffffffffffffffffffffffffffffff000000000000000019909216919091171790556040517f2b6bc782c916fa763822f1e50c6db0f95dade36d6541a8a4cbe070735b8b226d90612b909086908590918252602082015260400190565b60405180910390a26115528484612c10565b6020810151600454600160401b90046001600160401b03161415610d6f57600480546fffffffffffffffff00000000000000001916905560208101516040517fde3f4ea5aa67881831e8fad2b0855d47e75aa63a2fae6ef657ffd5f856c4a61390600090a2610d6f81612dbc565b600854602083015160408401516001600160a01b039092169163063f36ad918491612c3a90612e21565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401600060405180830381600087803b158015612c8057600080fd5b505af1158015612480573d6000803e3d6000fd5b60006106726001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683613216565b60008181526001830160205260408120548015612db2576000612ced6001836131ba565b8554909150600090612d01906001906131ba565b9050818114612d66576000866000018281548110612d2157612d21613087565b9060005260206000200154905080876000018481548110612d4457612d44613087565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612d7757612d776131e7565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610672565b6000915050610672565b600854602082015160405163d438121760e01b81526001600160a01b039092169163d438121791612df39160040190815260200190565b600060405180830381600087803b158015612e0d57600080fd5b505af1158015610a11573d6000803e3d6000fd5b6000612e566001600160401b037f00000000000000000000000000000000000000000000000000000000000000001683613216565b610672906001600160401b037f0000000000000000000000000000000000000000000000000000000000000000166130ce565b600060208284031215612e9b57600080fd5b81356001600160e01b0319811681146106f857600080fd5b80356001600160a01b0381168114612eca57600080fd5b919050565b60008060408385031215612ee257600080fd5b612eeb83612eb3565b946020939093013593505050565b600060208284031215612f0b57600080fd5b6106f882612eb3565b600060208284031215612f2657600080fd5b5035919050565b60008060408385031215612f4057600080fd5b82359150612f5060208401612eb3565b90509250929050565b600081518084526020808501945080840160005b83811015612f8957815187529582019590820190600101612f6d565b509495945050505050565b604080825283519082018190526000906020906060840190828701845b82811015612fcd57815184529284019290840190600101612fb1565b505050838103828501526113558186612f59565b60008060408385031215612ff457600080fd5b50508035926020909101359150565b604080825283519082018190526000906020906060840190828701845b82811015612fcd5781516001600160a01b031684529284019290840190600101613020565b60008060006060848603121561305a57600080fd5b505081359360208301359350604090920135919050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156130c7576130c761309d565b5060010190565b600082198211156130e1576130e161309d565b500190565b60005b838110156131015781810151838201526020016130e9565b838111156115525750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161314a8160178501602088016130e6565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161317b8160288401602088016130e6565b01602801949350505050565b60208152600082518060208401526131a68160408501602087016130e6565b601f01601f19169190910160400192915050565b6000828210156131cc576131cc61309d565b500390565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b60006001600160401b038216806126a9576126a961309d565b60008160001904831182151516156132305761323061309d565b500290565b60006020828403121561324757600080fd5b5051919050565b634e487b7160e01b600052601260045260246000fd5b6000826132735761327361324e565b500690565b6000826132875761328761324e565b500490565b60006001600160401b03808316818516818304811182151516156132b2576132b261309d565b02949350505050565b60006001600160401b03808316818114156132d8576132d861309d565b6001019392505050565b6000816132f1576132f161309d565b50600019019056fe66a484cf1a3c6ef8dfd59d24824943d2853a29d96f34a01271efc55774452a518f8c450dae5029cd48cd91dd9db65da48fb742893edfc7941250f6721d93cbbe9a627a5d4aa7c17f87ff26e3fe9a42c2b6c559e8b41a42282d0ecebb17c0e4d3a264697066735822122098f321a15e730c34a6d98fbc280e4f867ee1796f076d47af61947cde4af9e1a564736f6c634300080900339a627a5d4aa7c17f87ff26e3fe9a42c2b6c559e8b41a42282d0ecebb17c0e4d3 \ No newline at end of file diff --git a/tests/fork/contracts/accounting/HashConsensus_bin b/tests/fork/contracts/lido/HashConsensus_bin similarity index 100% rename from tests/fork/contracts/accounting/HashConsensus_bin rename to tests/fork/contracts/lido/HashConsensus_bin diff --git a/tests/fork/test_accounting_cycle.py b/tests/fork/test_accounting_cycle.py deleted file mode 100644 index f01ae9626..000000000 --- a/tests/fork/test_accounting_cycle.py +++ /dev/null @@ -1,83 +0,0 @@ -import pytest - -from src import variables -from src.modules.accounting.accounting import Accounting -from src.web3py.extensions import KeysAPIClientModule, LidoContracts, LidoValidatorsProvider, TransactionUtils -from tests.fork.conftest import first_slot_of_epoch - - -@pytest.fixture() -def module(forked_web3, patched_cl_client): - kac = KeysAPIClientModule(variables.KEYS_API_URI, forked_web3) - forked_web3.attach_modules( - { - 'lido_contracts': LidoContracts, - 'lido_validators': LidoValidatorsProvider, - 'transaction': TransactionUtils, - # "csm": lambda: csm_extension, - 'cc': lambda: patched_cl_client, # type: ignore[dict-item] - 'kac': lambda: kac, # type: ignore[dict-item] - # "ipfs": lambda: _, - } - ) - _module = Accounting(forked_web3) - yield _module - - -@pytest.fixture() -def report_contract(module): - yield module.report_contract - - -@pytest.fixture() -def hash_consensus_bin(): - with open('tests/fork/contracts/accounting/HashConsensus_bin', 'r') as f: - yield f.read() - - -@pytest.fixture -def start_before_initial_epoch(frame_config): - _from = frame_config.initial_epoch - 1 - _to = frame_config.initial_epoch + 3 - return [first_slot_of_epoch(i) for i in range(_from, _to)] - - -@pytest.fixture -def start_after_initial_epoch(frame_config): - _from = frame_config.initial_epoch + 1 - _to = frame_config.initial_epoch + 3 - return [first_slot_of_epoch(i) for i in range(_from, _to)] - - -@pytest.fixture -def missed_initial_frame(frame_config): - _from = frame_config.initial_epoch + frame_config.epochs_per_frame + 1 - _to = _from + 3 - return [first_slot_of_epoch(i) for i in range(_from, _to)] - - -@pytest.mark.fork -@pytest.mark.parametrize( - 'running_finalized_slots', - [start_before_initial_epoch, start_after_initial_epoch, missed_initial_frame], - indirect=True, -) -def test_accounting_report( - forked_web3, set_oracle_members, running_finalized_slots, account_from, module, new_hash_consensus -): - 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 = module.get_initial_or_current_frame(module._receive_last_finalized_slot()) - - switch_finalized, current = running_finalized_slots - while switch_finalized(): - for _, private_key in members: - # NOTE: reporters using the same cache - with account_from(private_key): - module.cycle_handler() - - 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/fork/test_csm_cycle.py b/tests/fork/test_csm_oracle_cycle.py similarity index 61% rename from tests/fork/test_csm_cycle.py rename to tests/fork/test_csm_oracle_cycle.py index 3cc947e19..0e38cc226 100644 --- a/tests/fork/test_csm_cycle.py +++ b/tests/fork/test_csm_oracle_cycle.py @@ -2,34 +2,15 @@ import pytest -from src import variables -from src.main import ipfs_providers from src.modules.csm.csm import CSOracle -from src.providers.ipfs import MultiIPFSProvider, CID -from src.web3py.extensions import KeysAPIClientModule, LidoContracts, LidoValidatorsProvider, TransactionUtils, CSM +from src.web3py.types import Web3 from tests.fork.conftest import first_slot_of_epoch @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 hash_consensus_bin(): - with open('tests/fork/contracts/csm/HashConsensus_bin', 'r') as f: - yield f.read() - - -@pytest.fixture() -def csm_extension(forked_web3): - yield CSM(forked_web3) +def module(web3: Web3): + yield CSOracle(web3) + subprocess.run(['rm', 'cache.pkl'], check=True) @pytest.fixture() @@ -38,22 +19,9 @@ def report_contract(csm_extension): @pytest.fixture() -def module(forked_web3, patched_cl_client, csm_extension, mocked_ipfs_client): - kac = KeysAPIClientModule(variables.KEYS_API_URI, forked_web3) - forked_web3.attach_modules( - { - 'lido_contracts': LidoContracts, - 'lido_validators': LidoValidatorsProvider, - 'transaction': TransactionUtils, - "csm": lambda: csm_extension, - 'cc': lambda: patched_cl_client, # type: ignore[dict-item] - 'kac': lambda: kac, # type: ignore[dict-item] - "ipfs": lambda: mocked_ipfs_client, - } - ) - _module = CSOracle(forked_web3) - yield _module - subprocess.run(['rm', 'cache.pkl']) +def hash_consensus_bin(): + with open('tests/fork/contracts/csm/HashConsensus_bin', 'r') as f: + yield f.read() @pytest.fixture @@ -83,25 +51,29 @@ def missed_initial_frame(frame_config): [start_before_initial_epoch, start_after_initial_epoch, missed_initial_frame], indirect=True, ) -def test_execute_module( +def test_csm_report( + set_oracle_members, running_finalized_slots, new_hash_consensus, - set_oracle_members, module: CSOracle, 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 = module.get_initial_or_current_frame(module._receive_last_finalized_slot()) + report_frame = None to_distribute_before_report = module.w3.csm.fee_distributor.shares_to_distribute() - switch_finalized, current = running_finalized_slots + 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 ( diff --git a/tests/fork/test_ejector_cycle.py b/tests/fork/test_lido_oracle_cycle.py similarity index 61% rename from tests/fork/test_ejector_cycle.py rename to tests/fork/test_lido_oracle_cycle.py index f2670f929..c29099afb 100644 --- a/tests/fork/test_ejector_cycle.py +++ b/tests/fork/test_lido_oracle_cycle.py @@ -1,27 +1,26 @@ import pytest -from src import variables +from src.modules.accounting.accounting import Accounting from src.modules.ejector.ejector import Ejector -from src.web3py.extensions import KeysAPIClientModule, LidoContracts, LidoValidatorsProvider, TransactionUtils +from src.modules.submodules.consensus import ConsensusModule +from src.modules.submodules.oracle_module import BaseModule from tests.fork.conftest import first_slot_of_epoch +@pytest.fixture +def accounting_module(web3): + yield Accounting(web3) + + +@pytest.fixture +def ejector_module(web3): + yield Ejector(web3) + + @pytest.fixture() -def module(forked_web3, patched_cl_client): - kac = KeysAPIClientModule(variables.KEYS_API_URI, forked_web3) - forked_web3.attach_modules( - { - 'lido_contracts': LidoContracts, - 'lido_validators': LidoValidatorsProvider, - 'transaction': TransactionUtils, - # "csm": lambda: csm_extension, - 'cc': lambda: patched_cl_client, # type: ignore[dict-item] - 'kac': lambda: kac, # type: ignore[dict-item] - # "ipfs": lambda: _, - } - ) - _module = Ejector(forked_web3) - yield _module +def module(request) -> BaseModule | ConsensusModule: + module = request.getfixturevalue(request.param.__name__) + yield module @pytest.fixture() @@ -31,7 +30,7 @@ def report_contract(module): @pytest.fixture() def hash_consensus_bin(): - with open('tests/fork/contracts/ejector/HashConsensus_bin', 'r') as f: + with open('tests/fork/contracts/lido/HashConsensus_bin', 'r') as f: yield f.read() @@ -57,25 +56,30 @@ def missed_initial_frame(frame_config): @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_ejector_report( - forked_web3, set_oracle_members, running_finalized_slots, account_from, module, new_hash_consensus -): +def test_module_report(set_oracle_members, running_finalized_slots, account_from, module, new_hash_consensus): 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 = module.get_initial_or_current_frame(module._receive_last_finalized_slot()) - - switch_finalized, current = running_finalized_slots + report_frame = None + switch_finalized, _ = running_finalized_slots 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.report_contract.get_last_processing_ref_slot() assert ( From 9ce45b15025023a7047d625be725acde9baf27a7 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Wed, 18 Dec 2024 15:39:38 +0100 Subject: [PATCH 07/27] fix: tests --- tests/fork/conftest.py | 35 ++++++++++-------- tests/fork/test_csm_oracle_cycle.py | 54 +++++++++++++--------------- tests/fork/test_lido_oracle_cycle.py | 49 ++++++++++--------------- 3 files changed, 64 insertions(+), 74 deletions(-) diff --git a/tests/fork/conftest.py b/tests/fork/conftest.py index 1c182cffb..97772073d 100644 --- a/tests/fork/conftest.py +++ b/tests/fork/conftest.py @@ -13,6 +13,8 @@ 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 @@ -28,7 +30,7 @@ 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, CSM +from src.web3py.extensions import KeysAPIClientModule, LidoContracts, LidoValidatorsProvider, TransactionUtils, LazyCSM logger = logger.getChild("fork") @@ -111,7 +113,7 @@ def frame_config(initial_epoch, epochs_per_frame, fast_lane_length_slots): return _frame_config -@pytest.fixture(params=[-4], ids=["fork 4 epochs before initial epoch"]) +@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: @@ -138,7 +140,7 @@ def forked_el_client(blockstamp_for_forking: BlockStamp): '--fork-block-number', str(blockstamp_for_forking.block_number), ] - with subprocess.Popen(cli_params) as process: + with subprocess.Popen(cli_params, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) as process: time.sleep(5) logger.info(f"Started fork from block {blockstamp_for_forking.block_number}") web3 = Web3(MultiProvider(['http://127.0.0.1:8545'], request_kwargs={'timeout': 5 * 60})) @@ -146,6 +148,7 @@ def forked_el_client(blockstamp_for_forking: BlockStamp): 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() @@ -153,19 +156,14 @@ def forked_el_client(blockstamp_for_forking: BlockStamp): @pytest.fixture() -def csm_extension(forked_el_client): - return CSM(forked_el_client) - - -@pytest.fixture() -def web3(forked_el_client, patched_cl_client, csm_extension, mocked_ipfs_client): +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": lambda: csm_extension, # type: ignore[dict-item] + "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, @@ -199,6 +197,7 @@ 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 @@ -206,6 +205,7 @@ def switch() -> SlotNumber | None: current = next(iterator) except StopIteration: current = None + logger.info(f"TESTRUN Switched finalized to slot {current}") return current return switch, lambda: current @@ -246,12 +246,12 @@ def get_block_root(self, state_id: SlotNumber | BlockRoot | LiteralState) -> Blo raise TestRunningException(f"Unknown state_id: {state_id}") existing = get_next_non_missed_slot( - super(), + self, slot_to_find, real_finalized_slot, ).message.slot - return super().get_block_root(SlotNumber(int(existing))) + return self.get_block_root(SlotNumber(int(existing))) def get_block_details(self, state_id: SlotNumber | BlockRoot) -> BlockDetailsResponse: """ @@ -274,7 +274,6 @@ def get_block_details(self, state_id: SlotNumber | BlockRoot) -> BlockDetailsRes raise TestRunningException(f"Latest block {latest_el} is ahead block {from_cl}") for _ in range(diff): forked_el_client.provider.make_request(RPCEndpoint('evm_mine'), []) - logger.debug(f"FORKED CLIENT: Mined block {forked_el_client.eth.block_number}") time.sleep(0.1) slot_details.message.body.execution_payload.block_number = block_from_fork['number'] @@ -291,8 +290,14 @@ def get_block_details(self, state_id: SlotNumber | BlockRoot) -> BlockDetailsRes @pytest.fixture() -def report_contract(): - raise TestRunningException("`report_contract` fixture should be overriden on tests level") +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() diff --git a/tests/fork/test_csm_oracle_cycle.py b/tests/fork/test_csm_oracle_cycle.py index 0e38cc226..92bfb0c30 100644 --- a/tests/fork/test_csm_oracle_cycle.py +++ b/tests/fork/test_csm_oracle_cycle.py @@ -3,61 +3,57 @@ 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 module(web3: Web3): - yield CSOracle(web3) - subprocess.run(['rm', 'cache.pkl'], check=True) - - -@pytest.fixture() -def report_contract(csm_extension): - yield csm_extension.oracle - - @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) + subprocess.run(['rm', 'cache.pkl'], check=True) + + @pytest.fixture -def start_before_initial_epoch(frame_config): - _from = frame_config.initial_epoch - 2 - _to = frame_config.initial_epoch + 6 - return [first_slot_of_epoch(i) for i in range(_from, _to)] +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): - _from = frame_config.initial_epoch + 2 - _to = frame_config.initial_epoch + 6 - return [first_slot_of_epoch(i) for i in range(_from, _to)] +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): +def missed_initial_frame(frame_config: FrameConfig): _from = frame_config.initial_epoch + frame_config.epochs_per_frame + 1 - _to = _from + 6 - return [first_slot_of_epoch(i) for i in range(_from, _to)] + _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_report( - set_oracle_members, - running_finalized_slots, - new_hash_consensus, - module: CSOracle, - account_from, -): +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) diff --git a/tests/fork/test_lido_oracle_cycle.py b/tests/fork/test_lido_oracle_cycle.py index c29099afb..d13c68bb4 100644 --- a/tests/fork/test_lido_oracle_cycle.py +++ b/tests/fork/test_lido_oracle_cycle.py @@ -2,11 +2,17 @@ from src.modules.accounting.accounting import Accounting from src.modules.ejector.ejector import Ejector -from src.modules.submodules.consensus import ConsensusModule -from src.modules.submodules.oracle_module import BaseModule +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) @@ -17,42 +23,25 @@ def ejector_module(web3): yield Ejector(web3) -@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(): - with open('tests/fork/contracts/lido/HashConsensus_bin', 'r') as f: - yield f.read() - - @pytest.fixture -def start_before_initial_epoch(frame_config): +def start_before_initial_epoch(frame_config: FrameConfig): _from = frame_config.initial_epoch - 1 - _to = frame_config.initial_epoch + 3 - return [first_slot_of_epoch(i) for i in range(_from, _to)] + _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): +def start_after_initial_epoch(frame_config: FrameConfig): _from = frame_config.initial_epoch + 1 - _to = frame_config.initial_epoch + 3 - return [first_slot_of_epoch(i) for i in range(_from, _to)] + _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): +def missed_initial_frame(frame_config: FrameConfig): _from = frame_config.initial_epoch + frame_config.epochs_per_frame + 1 - _to = _from + 3 - return [first_slot_of_epoch(i) for i in range(_from, _to)] + _to = _from + 2 + return [first_slot_of_epoch(i) for i in sequence(_from, _to)] @pytest.mark.fork @@ -66,15 +55,15 @@ def missed_initial_frame(frame_config): [start_before_initial_epoch, start_after_initial_epoch, missed_initial_frame], indirect=True, ) -def test_module_report(set_oracle_members, running_finalized_slots, account_from, module, new_hash_consensus): +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: - # NOTE: reporters using the same cache with account_from(private_key): module.cycle_handler() report_frame = module.get_initial_or_current_frame( From 4b403256ae1f039f07bb297894693e7a5bb69da5 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Wed, 18 Dec 2024 18:53:49 +0100 Subject: [PATCH 08/27] fix: `_get_module_id` in CSM module should be on `latest` --- src/modules/csm/csm.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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: From bb19decdd92ccf047b402e0f08cd050a56556def Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Wed, 18 Dec 2024 18:54:33 +0100 Subject: [PATCH 09/27] fix: `_get_slots_elapsed_from_last_report` in accounting Oracle --- src/modules/accounting/accounting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/accounting/accounting.py b/src/modules/accounting/accounting.py index 6369d9409..2459ce9ce 100644 --- a/src/modules/accounting/accounting.py +++ b/src/modules/accounting/accounting.py @@ -298,7 +298,7 @@ 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 + slots_elapsed = max(blockstamp.ref_slot - frame_config.initial_epoch * chain_conf.slots_per_epoch, 0) return slots_elapsed From 1f1afbb0d3d9c1cea26d3344b8f000019153167c Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Wed, 18 Dec 2024 21:42:33 +0100 Subject: [PATCH 10/27] fix: add csm module address --- .github/workflows/fork_tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/fork_tests.yml b/.github/workflows/fork_tests.yml index 4705c773e..2f78eae4b 100644 --- a/.github/workflows/fork_tests.yml +++ b/.github/workflows/fork_tests.yml @@ -52,4 +52,5 @@ jobs: CONSENSUS_CLIENT_URI: ${{ secrets.CONSENSUS_CLIENT_URI }} KEYS_API_URI: ${{ secrets.KEYS_API_URI }} LIDO_LOCATOR_ADDRESS: "0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Eb" + CSM_MODULE_ADDRESS: "0xdA7dE2ECdDfccC6c3AF10108Db212ACBBf9EA83F" From 90b0211f868c40f89688cb68a507ae5481a60d35 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Wed, 18 Dec 2024 22:07:04 +0100 Subject: [PATCH 11/27] fix: epochs_per_frame and initial_epoch --- tests/fork/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fork/conftest.py b/tests/fork/conftest.py index 97772073d..7376d2f94 100644 --- a/tests/fork/conftest.py +++ b/tests/fork/conftest.py @@ -87,12 +87,12 @@ def real_finalized_slot(real_cl_client: ConsensusClient) -> SlotNumber: return finalized_slot -@pytest.fixture(params=[-24], ids=["initial epoch 24 epochs before real finalized epoch"]) +@pytest.fixture(params=[-18], 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"]) +@pytest.fixture(params=[6], ids=["6 epochs per frame"]) def epochs_per_frame(request): return request.param From 992183c16100507348d8a96058a6642d56ce094e Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 19 Dec 2024 13:46:54 +0100 Subject: [PATCH 12/27] fix: subprocess logs --- tests/fork/conftest.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/fork/conftest.py b/tests/fork/conftest.py index 7376d2f94..bec0ca992 100644 --- a/tests/fork/conftest.py +++ b/tests/fork/conftest.py @@ -55,7 +55,7 @@ def _use(pk: str): "ACCOUNT", Account.from_key(private_key=pk), # pylint: disable=no-value-for-parameter ) - logger.info(f"Switched to ACCOUNT {variables.ACCOUNT.address}") + logger.info(f"TESTRUN Switched to ACCOUNT {variables.ACCOUNT.address}") yield return _use @@ -83,16 +83,16 @@ def real_cl_client(): @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"True finalized slot on CL: {finalized_slot}") + logger.info(f"TESTRUN True finalized slot on CL: {finalized_slot}") return finalized_slot -@pytest.fixture(params=[-18], ids=["initial epoch 24 epochs before real finalized epoch"]) +@pytest.fixture(params=[-24], ids=[f"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=[6], ids=["6 epochs per frame"]) +@pytest.fixture(params=[8], ids=["8 epochs per frame"]) def epochs_per_frame(request): return request.param @@ -109,7 +109,7 @@ def frame_config(initial_epoch, epochs_per_frame, fast_lane_length_slots): epochs_per_frame=epochs_per_frame, fast_lane_length_slots=fast_lane_length_slots, ) - logger.info(f"Frame config: {_frame_config}") + logger.info(f"TESTRUN Frame config: {_frame_config}") return _frame_config @@ -124,7 +124,7 @@ def blockstamp_for_forking( real_finalized_slot, ) blockstamp = build_blockstamp(existing) - logger.info(f"Blockstamp to fork: {blockstamp}") + logger.info(f"TESTRUN Blockstamp to fork: {blockstamp}") return blockstamp @@ -140,9 +140,9 @@ def forked_el_client(blockstamp_for_forking: BlockStamp): '--fork-block-number', str(blockstamp_for_forking.block_number), ] - with subprocess.Popen(cli_params, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) as process: + with subprocess.Popen(cli_params, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) as process: time.sleep(5) - logger.info(f"Started fork from block {blockstamp_for_forking.block_number}") + logger.info(f"TESTRUN Started fork from block {blockstamp_for_forking.block_number}") web3 = Web3(MultiProvider(['http://127.0.0.1:8545'], request_kwargs={'timeout': 5 * 60})) tweak_w3_contracts(web3) web3.middleware_onion.add(construct_simple_cache_middleware()) @@ -265,16 +265,16 @@ def get_block_details(self, state_id: SlotNumber | BlockRoot) -> BlockDetailsRes int(slot_details.message.body.execution_payload.block_number) ) except Exception as e: # pylint: disable=broad-exception-caught - logger.debug(f"FORKED CLIENT: {e}") + 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"Latest block {latest_el} is ahead block {from_cl}") + 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.1) + 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() @@ -302,7 +302,7 @@ def report_contract(module): @pytest.fixture() def hash_consensus_bin(): - raise TestRunningException("`hash_consensus_bin` fixture should be overriden on tests level") + raise TestRunningException("TESTRUN `hash_consensus_bin` fixture should be overriden on tests level") @pytest.fixture() From 327816dc49b32d508ffa61685dc35dc3f7e7997e Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 19 Dec 2024 14:28:20 +0100 Subject: [PATCH 13/27] fix: linter --- tests/fork/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fork/conftest.py b/tests/fork/conftest.py index bec0ca992..99b2632b8 100644 --- a/tests/fork/conftest.py +++ b/tests/fork/conftest.py @@ -87,7 +87,7 @@ def real_finalized_slot(real_cl_client: ConsensusClient) -> SlotNumber: return finalized_slot -@pytest.fixture(params=[-24], ids=[f"initial epoch 24 epochs before real finalized epoch"]) +@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 From e0cb44680a141825b1f9f3b05141f0e5d07f7092 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Fri, 20 Dec 2024 13:01:44 +0100 Subject: [PATCH 14/27] fix: log in `_get_non_missed_slot_header` --- src/utils/slot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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.' ) From 442ec867372d7eb1c868022c3af8f7c15e3ba3ca Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 9 Jan 2025 11:23:53 +0100 Subject: [PATCH 15/27] fix: add `clean_global_cache_after_test` fixture --- tests/fork/conftest.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/fork/conftest.py b/tests/fork/conftest.py index 99b2632b8..3a457f1bc 100644 --- a/tests/fork/conftest.py +++ b/tests/fork/conftest.py @@ -23,6 +23,7 @@ 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, @@ -39,6 +40,16 @@ class TestRunningException(Exception): pass +# +# Global +# +@pytest.fixture(autouse=True) +def clean_global_cache_after_test(): + yield + logger.info("TESTRUN Clear global LRU functions cache (Autoused)") + clear_global_cache() + + # # Utils # From c4e7dd2130f2d50fac34f63b73fef1619cb36b4c Mon Sep 17 00:00:00 2001 From: Raman Siamionau <1590415904a@gmail.com> Date: Wed, 22 Jan 2025 10:57:37 +0100 Subject: [PATCH 16/27] Update src/modules/accounting/accounting.py --- src/modules/accounting/accounting.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/accounting/accounting.py b/src/modules/accounting/accounting.py index 2459ce9ce..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 = max(blockstamp.ref_slot - frame_config.initial_epoch * chain_conf.slots_per_epoch, 0) + # 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 From 9afe6fbb2078b34cfbdbec0673975880aca37db3 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 23 Jan 2025 11:04:58 +0100 Subject: [PATCH 17/27] chore: rename workflow --- .github/workflows/{fork_tests.yml => mainnet_fork_tests.yml} | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) rename .github/workflows/{fork_tests.yml => mainnet_fork_tests.yml} (95%) diff --git a/.github/workflows/fork_tests.yml b/.github/workflows/mainnet_fork_tests.yml similarity index 95% rename from .github/workflows/fork_tests.yml rename to .github/workflows/mainnet_fork_tests.yml index 2f78eae4b..eea7f1198 100644 --- a/.github/workflows/fork_tests.yml +++ b/.github/workflows/mainnet_fork_tests.yml @@ -1,4 +1,4 @@ -name: Fork Tests +name: Mainnet Fork Tests on: pull_request: @@ -6,7 +6,6 @@ on: - opened - synchronize - reopened - - edited - closed branches: - main @@ -45,7 +44,7 @@ jobs: - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 - - name: Fork tests + - name: Mainnet Fork Tests run: poetry run pytest -m 'fork' tests env: EXECUTION_CLIENT_URI: ${{ secrets.EXECUTION_CLIENT_URI }} From 19437a0fb7ee6cbc539af073c7b1309a236154a9 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 23 Jan 2025 11:07:46 +0100 Subject: [PATCH 18/27] fix: run with "fork" mark --- .github/workflows/tests.yml | 2 +- pyproject.toml | 2 ++ tests/fork/conftest.py | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e89b672df..7d765b733 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,7 +31,7 @@ jobs: poetry install --no-interaction --with=dev - name: Test with pytest - run: poetry run pytest -m 'not fork' --cov=src tests + run: poetry run pytest --cov=src tests env: EXECUTION_CLIENT_URI: ${{ secrets.EXECUTION_CLIENT_URI }} CONSENSUS_CLIENT_URI: ${{ secrets.CONSENSUS_CLIENT_URI }} diff --git a/pyproject.toml b/pyproject.toml index 201c3743d..1dd626b80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,6 +15,7 @@ authors = [ "Vladimir Gorkavenko", ] license = "GPL 3.0" +package-mode = false [tool.poetry.dependencies] python = "^3.12" @@ -57,6 +58,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/tests/fork/conftest.py b/tests/fork/conftest.py index 3a457f1bc..282c8d771 100644 --- a/tests/fork/conftest.py +++ b/tests/fork/conftest.py @@ -5,6 +5,7 @@ from typing import get_args, cast import pytest +from _pytest.nodes import Item from eth_account import Account from web3 import Web3 from web3.middleware import construct_simple_cache_middleware @@ -40,6 +41,18 @@ 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 # From f74b891dcef0837937fdd68701ce81f81acf8bf9 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 23 Jan 2025 11:23:36 +0100 Subject: [PATCH 19/27] chore: parallel run in CI --- .github/workflows/mainnet_fork_tests.yml | 2 +- tests/fork/conftest.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mainnet_fork_tests.yml b/.github/workflows/mainnet_fork_tests.yml index eea7f1198..5c7675dff 100644 --- a/.github/workflows/mainnet_fork_tests.yml +++ b/.github/workflows/mainnet_fork_tests.yml @@ -45,7 +45,7 @@ jobs: uses: foundry-rs/foundry-toolchain@v1 - name: Mainnet Fork Tests - run: poetry run pytest -m '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 }} diff --git a/tests/fork/conftest.py b/tests/fork/conftest.py index 282c8d771..6e652eb4b 100644 --- a/tests/fork/conftest.py +++ b/tests/fork/conftest.py @@ -7,6 +7,7 @@ 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 @@ -154,8 +155,11 @@ def blockstamp_for_forking( @pytest.fixture() def forked_el_client(blockstamp_for_forking: BlockStamp): + port = Faker().random_int(min=10000, max=20000) cli_params = [ 'anvil', + '--port', + str(port), '--config-out', 'localhost.json', '--auto-impersonate', @@ -167,7 +171,7 @@ def forked_el_client(blockstamp_for_forking: BlockStamp): with subprocess.Popen(cli_params, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) as process: time.sleep(5) logger.info(f"TESTRUN Started fork from block {blockstamp_for_forking.block_number}") - web3 = Web3(MultiProvider(['http://127.0.0.1:8545'], request_kwargs={'timeout': 5 * 60})) + 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]) From dbd3d25e016696c2d0348b28af3e2c5e32da9bad Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 23 Jan 2025 11:25:15 +0100 Subject: [PATCH 20/27] fix: test --- tests/modules/accounting/test_accounting_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From b495084386ad0963f18da25aa8f70eb8788ee684 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 23 Jan 2025 11:26:08 +0100 Subject: [PATCH 21/27] revert: package-mode --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1dd626b80..09fa6315a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,6 @@ authors = [ "Vladimir Gorkavenko", ] license = "GPL 3.0" -package-mode = false [tool.poetry.dependencies] python = "^3.12" From a0c74c2c3ee97bb049f8fe5abea9144a459c5077 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 23 Jan 2025 11:32:42 +0100 Subject: [PATCH 22/27] fix: black --- tests/fork/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/fork/conftest.py b/tests/fork/conftest.py index 6e652eb4b..3df3447df 100644 --- a/tests/fork/conftest.py +++ b/tests/fork/conftest.py @@ -54,6 +54,7 @@ def pytest_collection_modifyitems(items: list[Item]): ) ) + # # Global # From 3a5672300310973b18d25f7183ea1757f49f9622 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 23 Jan 2025 11:40:08 +0100 Subject: [PATCH 23/27] fix: `SUBMIT_DATA_DELAY_IN_SLOTS` and `CYCLE_SLEEP_IN_SECONDS` should be 0 for tests --- tests/fork/conftest.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/fork/conftest.py b/tests/fork/conftest.py index 3df3447df..7e5984a28 100644 --- a/tests/fork/conftest.py +++ b/tests/fork/conftest.py @@ -58,6 +58,8 @@ def pytest_collection_modifyitems(items: list[Item]): # # Global # + + @pytest.fixture(autouse=True) def clean_global_cache_after_test(): yield @@ -65,6 +67,23 @@ def clean_global_cache_after_test(): 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 + + # # Utils # @@ -171,7 +190,7 @@ def forked_el_client(blockstamp_for_forking: BlockStamp): ] with subprocess.Popen(cli_params, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) as process: time.sleep(5) - logger.info(f"TESTRUN Started fork from block {blockstamp_for_forking.block_number}") + 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()) From e676ca20bd9772932df862474a40dadc56ca1718 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 23 Jan 2025 12:37:46 +0100 Subject: [PATCH 24/27] revert: edited --- .github/workflows/mainnet_fork_tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/mainnet_fork_tests.yml b/.github/workflows/mainnet_fork_tests.yml index 5c7675dff..351ccdfba 100644 --- a/.github/workflows/mainnet_fork_tests.yml +++ b/.github/workflows/mainnet_fork_tests.yml @@ -6,6 +6,7 @@ on: - opened - synchronize - reopened + - edited - closed branches: - main From 687cbe760d0e0a0221530163cff00bd0cf81ddc3 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 23 Jan 2025 14:21:33 +0100 Subject: [PATCH 25/27] fix: create uniq path per test --- src/modules/csm/state.py | 4 ++-- tests/fork/conftest.py | 30 ++++++++++++++++++++++++----- tests/fork/test_csm_oracle_cycle.py | 3 --- 3 files changed, 27 insertions(+), 10 deletions(-) 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/tests/fork/conftest.py b/tests/fork/conftest.py index 7e5984a28..62af53a52 100644 --- a/tests/fork/conftest.py +++ b/tests/fork/conftest.py @@ -2,6 +2,7 @@ import subprocess import time from contextlib import contextmanager +from pathlib import Path from typing import get_args, cast import pytest @@ -84,6 +85,26 @@ def set_delay_and_sleep(monkeypatch): 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(testrun_uid): + path = f"./testrun_{testrun_uid}" + subprocess.run(['mkdir', path]) + yield path + subprocess.run(['rm', '-rf', path], check=True) + + # # Utils # @@ -174,14 +195,14 @@ def blockstamp_for_forking( @pytest.fixture() -def forked_el_client(blockstamp_for_forking: BlockStamp): +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', - 'localhost.json', + f'{testrun_path}/localhost.json', '--auto-impersonate', '-f', variables.EXECUTION_CLIENT_URI[0], @@ -200,7 +221,6 @@ def forked_el_client(blockstamp_for_forking: BlockStamp): yield web3 process.terminate() process.wait() - subprocess.run(['rm', 'localhost.json'], check=True) @pytest.fixture() @@ -232,8 +252,8 @@ def _publish(self, content: bytes, name: str | None = None) -> CID: @pytest.fixture() -def accounts_from_fork(forked_el_client): - with open('localhost.json') as f: +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'] diff --git a/tests/fork/test_csm_oracle_cycle.py b/tests/fork/test_csm_oracle_cycle.py index 92bfb0c30..c36d99d70 100644 --- a/tests/fork/test_csm_oracle_cycle.py +++ b/tests/fork/test_csm_oracle_cycle.py @@ -1,5 +1,3 @@ -import subprocess - import pytest from src.modules.csm.csm import CSOracle @@ -18,7 +16,6 @@ def hash_consensus_bin(): @pytest.fixture() def csm_module(web3: Web3): yield CSOracle(web3) - subprocess.run(['rm', 'cache.pkl'], check=True) @pytest.fixture From eaf3a9af2f349d125f7e394e152acad382abaac4 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 23 Jan 2025 14:28:14 +0100 Subject: [PATCH 26/27] fix: linter --- tests/fork/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fork/conftest.py b/tests/fork/conftest.py index 62af53a52..378301661 100644 --- a/tests/fork/conftest.py +++ b/tests/fork/conftest.py @@ -100,7 +100,7 @@ def set_cache_path(monkeypatch, testrun_path): @pytest.fixture def testrun_path(testrun_uid): path = f"./testrun_{testrun_uid}" - subprocess.run(['mkdir', path]) + subprocess.run(['mkdir', path], check=True) yield path subprocess.run(['rm', '-rf', path], check=True) From 039ab2bf5c7846032b62991f51009571f52f6a5f Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 23 Jan 2025 14:37:21 +0100 Subject: [PATCH 27/27] fix: user worker_id --- tests/fork/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fork/conftest.py b/tests/fork/conftest.py index 378301661..b381013d3 100644 --- a/tests/fork/conftest.py +++ b/tests/fork/conftest.py @@ -98,8 +98,8 @@ def set_cache_path(monkeypatch, testrun_path): @pytest.fixture -def testrun_path(testrun_uid): - path = f"./testrun_{testrun_uid}" +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)