Skip to content

Conversation

QYuQianchen
Copy link
Contributor

@QYuQianchen QYuQianchen commented Sep 20, 2024

Description

  • Add "WinningProbability" contract and unit tests
  • Add deployment script and deployment contracts
  • Include two hopli commands to interact with winning probability contract
  • Set winning probability
    hopli win-prob set \
        --network anvil-localhost \
        --contracts-root "../ethereum/contracts" \
        --winning-probability 0.5 \
        --private-key ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
        --provider-url "http://localhost:8545"
    
    • Get winning probability:
    hopli win-prob get \
        --network anvil-localhost \
        --contracts-root "../ethereum/contracts" \
        --provider-url "http://localhost:8545"
    

Deployment

  • Rotsee: 0xC15675d4CCa538D91a91a8D3EcFBB8499C3B047
  • Debug-staging: 0x02e1009fd222917Ee7bdfdBF8AE1e56c4ae3F6f3
  • Dufour: 0x7Eb8d762fe794A108e568aD2097562cc5D3A1359

Closes #6493

@QYuQianchen QYuQianchen added this to the 2.2.0-rc.1 milestone Sep 20, 2024
@QYuQianchen QYuQianchen self-assigned this Sep 20, 2024
Copy link
Contributor

coderabbitai bot commented Sep 20, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes encompass the introduction of a new HoprWinningProbabilityOracle smart contract and its integration across various components of the Ethereum project. This includes updates to configuration files, deployment scripts, and test suites, reflecting the addition of a new oracle for managing winning probabilities. The modifications also involve version updates and adjustments to network address configurations to accommodate the new functionality.

Changes

File Path Change Summary
ethereum/contracts/contracts-addresses.json Updated network addresses for anvil-localhost and anvil-localhost2, added winning_probability_oracle addresses.
ethereum/contracts/src/WinningProbabilityOracle.sol Added HoprWinningProbabilityOracle contract with methods for managing winning probabilities.
ethereum/contracts/test/WinningProbabilityOracle.t.sol Introduced test suite for HoprWinningProbabilityOracle, covering various functionalities and edge cases.
chain/types/src/lib.rs Updated ContractAddresses and ContractInstances structs to include win_prob_oracle field.
hopli/Cargo.toml Updated version from 0.6.0 to 0.7.0 and added hopr-internal-types dependency.
hopli/src/main.rs Introduced new module for handling winning probability commands in the CLI.
hopli/src/win_prob.rs Added CLI commands for setting and getting the winning probability, including asynchronous execution.
hopr/hoprd/src/config.rs Added winning_probability_oracle entry in the configuration for testing.

Assessment against linked issues

Objective Addressed Explanation
Create a HoprWinningProbabilityOracle.sol, which allows managers to adjust the probability itself (#[6493])
Add tests for the contract (#[6493])
Extend the deployment script to deploy this contract (#[6493])
Update the relevant variables to accept this contract address in the configuration (#[6493])
Expand the indexer to listen to the deployed contracts (#[6493]) Indexer updates are not included in this PR.

Possibly related PRs

  • Allow configurable winning probabilities #6494: This PR introduces configurable winning probabilities for tickets, which directly relates to the changes in the main PR that involve updates to the winning_probability_oracle and its integration into various components of the system.
  • Update the toolchain and dependencies #6508: This PR focuses on updating dependencies and the toolchain, which may indirectly relate to ensuring the environment is ready for the new functionalities introduced in the main PR.

Suggested labels

status:in-review, crate:hopr-internal-types, crate:chain-rpc, crate:hoprd-api, crate:hoprd-keypair, crate:hopr-db-api, crate:hopr-db-migration, effort:medium, complexity:normal

Suggested reviewers

  • NumberFour8

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added dependencies Pull requests that update a dependency file toolchain Developer and product happiness crate:hopr-lib smart-contracts crate:bindings labels Sep 20, 2024
@github-actions github-actions bot marked this pull request as draft September 20, 2024 07:51
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 5c56d05 and b0bd520.

Files selected for processing (8)
  • ethereum/bindings/Cargo.toml (1 hunks)
  • ethereum/contracts/contracts-addresses.json (5 hunks)
  • ethereum/contracts/script/DeployAll.s.sol (3 hunks)
  • ethereum/contracts/script/utils/NetworkConfig.s.sol (3 hunks)
  • ethereum/contracts/src/WinningProbabilityOracle.sol (1 hunks)
  • ethereum/contracts/test/WinningProbabilityOracle.t.sol (1 hunks)
  • hopr/hopr-lib/data/protocol-config.json (2 hunks)
  • scripts/protocol-config-anvil.json (2 hunks)
Additional context used
Gitleaks
ethereum/contracts/contracts-addresses.json

13-13: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


29-29: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

Additional comments not posted (30)
ethereum/bindings/Cargo.toml (1)

3-3: Verify that the version increment aligns with the changes in this PR.

Incrementing the patch version from "0.1.0" to "0.1.1" is appropriate if this PR only contains backward-compatible bug fixes or minor changes that do not affect the public API.

Please confirm that the changes in this PR do not introduce any breaking changes or new features, and only include bug fixes or minor changes. If there are any breaking changes or new features, consider incrementing the minor version instead (e.g., "0.2.0").

scripts/protocol-config-anvil.json (2)

13-13: LGTM!

The addition of the "winning_probability_oracle" entry in the configuration file is consistent with the existing structure and aligns with the PR objective of introducing a new contract for winning probability.


35-35: Looks good!

The addition of the "winning_probability_oracle" entry in the "anvil-localhost2" network configuration is consistent with the change made in the "anvil-localhost" configuration.

Observation: The duplication of the entry in both network configurations suggests that the "winning_probability_oracle" contract is intended to be used across multiple local development environments.

ethereum/contracts/src/WinningProbabilityOracle.sol (5)

6-11: LGTM!

The WinProb type and equal function are correctly defined and implemented.


13-16: LGTM!

The HoprWinningProbablityOracleEvents contract correctly defines the WinProbUpdated event.


44-45: LGTM!

The HoprWinningProbablityOracle contract correctly inherits from Ownable2Step and HoprWinningProbablityOracleEvents, and defines the currentWinProb state variable.


54-57: LGTM!

The constructor correctly transfers ownership and sets the initial winning probability.


63-79: LGTM!

The setWinProb and _setWinProb functions are correctly implemented with appropriate access control, input validation, and event emission.

ethereum/contracts/test/WinningProbabilityOracle.t.sol (9)

8-11: LGTM!

The Ownable2StepEvents contract correctly defines the necessary events for the two-step ownership transfer process.


17-20: LGTM!

The setUp function correctly initializes the oracle instance with the specified owner and winning probability.


22-25: LGTM!

The test_setUpWithZero function verifies that the contract can be initialized with a zero winning probability.


27-32: LGTM!

The test_setZero function correctly tests setting the winning probability to zero and verifies the emitted event.


34-38: LGTM!

The testRevert_setSameFails function correctly verifies that setting the same winning probability reverts with the expected error.


40-44: LGTM!

The testRevert_setByNonOwnerFails function correctly verifies that setting the winning probability by a non-owner account reverts with the expected error.


60-69: LGTM!

The test_setALargeValueFails function correctly tests the failure case when trying to set a large value using a low-level call and verifies that the call is unsuccessful.


71-86: LGTM!

The test_transferOwnership function correctly tests the two-step ownership transfer process by initiating the transfer, accepting the ownership, and verifying the emitted events and the new owner.


6-6: Unable to review the HoprWinningProbablityOracle contract.

The HoprWinningProbablityOracle contract is imported on line 6 but not provided in the code for review. Please include the contract code to enable a comprehensive review.

hopr/hopr-lib/data/protocol-config.json (2)

26-26: LGTM!

The new "winning_probability_oracle" entry is added correctly under the "debug-staging" network configuration with a valid Ethereum address.


48-48: LGTM!

The new "winning_probability_oracle" entry is added correctly under the "dufour" network configuration with a valid Ethereum address.

ethereum/contracts/contracts-addresses.json (5)

5-5: LGTM!

The updated announcements address for the anvil-localhost environment looks good.


14-14: LGTM!

The addition of the winning_probability_oracle address for the anvil-localhost environment looks good and aligns with the PR objective.


17-17: LGTM!

The updated indexer_start_block_number for the anvil-localhost environment looks good.


30-30: LGTM!

The addition of the winning_probability_oracle address for the anvil-localhost2 environment looks good and aligns with the PR objective.


47-47: LGTM!

The addition of the winning_probability_oracle addresses for the rotsee, debug-staging, monte_rosa, and dufour environments looks good and aligns with the PR objective. The changes are consistent across all the environments.

Also applies to: 63-63, 79-79, 95-95

ethereum/contracts/script/utils/NetworkConfig.s.sol (3)

29-29: LGTM!

The addition of the new address variable winningProbabilityContractAddress to the addresses struct is consistent with the existing code structure and naming conventions.


111-111: Looks good!

The serialization process is correctly updated to include the new winningProbabilityContractAddress variable. The key name and serialization order are consistent with the existing code.


223-232: Approved!

The code for writing the winningProbabilityContractAddress to a file is implemented correctly. It follows the existing patterns and maintains consistency with the surrounding code.

ethereum/contracts/script/DeployAll.s.sol (3)

11-11: LGTM!

The import statement for the WinProb type is correct and necessary for the _deployHoprWinningProbabilityOracle method.


91-92: LGTM!

The _deployHoprWinningProbabilityOracle method is called with the correct parameters. The default WinProb value of 1.0 (maximum uint56 value) is a reasonable choice for the initial deployment.


286-298: LGTM!

The _deployHoprWinningProbabilityOracle method is implemented correctly. It follows the same deployment logic as other methods in the contract and uses the correct contract name and parameters.

@QYuQianchen QYuQianchen marked this pull request as ready for review September 20, 2024 08:13
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 15

Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between b0bd520 and 45fd0ff.

Files selected for processing (8)
  • chain/api/src/config.rs (4 hunks)
  • chain/types/src/lib.rs (8 hunks)
  • ethereum/contracts/contracts-addresses.json (5 hunks)
  • ethereum/contracts/test/WinningProbabilityOracle.t.sol (1 hunks)
  • hopr/hopr-lib/src/lib.rs (1 hunks)
  • hoprd/hoprd/example_cfg.yaml (1 hunks)
  • hoprd/hoprd/src/config.rs (1 hunks)
  • scripts/protocol-config-anvil.json (2 hunks)
Additional context used
Gitleaks
ethereum/contracts/contracts-addresses.json

13-13: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


29-29: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

Additional comments not posted (18)
scripts/protocol-config-anvil.json (2)

13-13: LGTM!

The addition of the "winning_probability_oracle" entry in the "anvil-localhost" network configuration looks good. The Ethereum address value is likely the address of the deployed "WinningProbability" contract, which aligns with the PR objectives.


35-35: Looks good!

The addition of the "winning_probability_oracle" entry in the "anvil-localhost2" network configuration is consistent with the change made in the "anvil-localhost" network configuration. Using the same Ethereum address value across both configurations ensures uniformity in the system's interaction with the "WinningProbability" contract.

ethereum/contracts/contracts-addresses.json (6)

5-17: LGTM!

The changes in the anvil-localhost environment look good:

  • Updating indexer_start_block_number to 1 is valid for a local environment.
  • The address updates for existing contracts are expected for a fresh local setup.
  • Adding the winning_probability_oracle address aligns with the PR objective.
Tools
Gitleaks

13-13: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-33: LGTM!

The changes in the anvil-localhost2 environment are identical to anvil-localhost and look good for another local environment setup.

Tools
Gitleaks

29-29: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


47-47: LGTM!

Adding the winning_probability_oracle address in the rotsee staging environment looks good and aligns with the PR objective.


63-63: LGTM!

Adding the winning_probability_oracle address in the debug-staging staging environment looks good and aligns with the PR objective.


95-95: LGTM!

Adding the winning_probability_oracle address in the dufour production environment looks good and aligns with the PR objective.


13-13: Dismiss static analysis hints.

The lines flagged by Gitleaks as potential generic API keys are false positives. The flagged values are Ethereum addresses for the winning_probability_oracle in local test environments. Ethereum addresses are not considered sensitive information.

Also applies to: 29-29

Tools
Gitleaks

13-13: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

hoprd/hoprd/example_cfg.yaml (1)

249-249: LGTM!

The addition of the winning_probability_oracle entry in the configuration aligns with the PR objective of introducing a new contract for winning probability. The provided Ethereum address indicates the location of the deployed oracle contract.

chain/api/src/config.rs (4)

101-103: LGTM!

The addition of the winning_probability_oracle field to the Addresses struct is appropriate. The field is correctly typed as Address, is public for external access, and uses the DisplayFromStr format for serialization/deserialization.


142-144: Looks good!

The addition of the winning_probability_oracle field to the ChainNetworkConfig struct is consistent with the changes made to the Addresses struct. The field is correctly typed, publicly accessible, and uses the appropriate serialization format.


211-211: Looks good!

The initialization of the winning_probability_oracle field in the ChainNetworkConfig::new method is consistent with the struct definition. It correctly assigns the value from network.addresses.winning_probability_oracle and creates an owned copy using to_owned().


236-236: Looks good!

The initialization of the win_prob_oracle field in the From<&ChainNetworkConfig> implementation for ContractAddresses is consistent with the changes made to the ChainNetworkConfig struct. It correctly assigns the value from network.winning_probability_oracle.

hoprd/hoprd/src/config.rs (1)

378-378: LGTM!

The addition of the "winning_probability_oracle" entry in the test configuration looks good. It follows the existing pattern of defining oracle and registry addresses, and it should enhance the testing capabilities related to winning probability scenarios.

hopr/hopr-lib/src/lib.rs (1)

552-552: LGTM!

The addition of the win_prob_oracle field to the ContractAddresses struct is a valid enhancement. It allows the Hopr struct to access the winning probability oracle contract address, which may enable new functionality related to retrieving or calculating winning probabilities for tickets.

ethereum/contracts/test/WinningProbabilityOracle.t.sol (2)

40-44: Test correctly ensures only the owner can set win probability.

The test verifies that a non-owner cannot call setWinProb and expects the correct revert message.


70-85: Well-structured ownership transfer test.

The test correctly verifies both the initiation and acceptance of ownership transfer, including event emission and final owner verification.

chain/types/src/lib.rs (1)

239-239: Ensure consistent field naming in the conversion.

Verify that the field win_prob_oracle is consistently named and correctly spelled throughout the conversion.

Run the following script to search for the field usage and check for consistency:

Verification successful

Field naming 'win_prob_oracle' is consistent throughout the codebase.

The verification process confirms that the field 'win_prob_oracle' is consistently named and correctly spelled across multiple files in the Rust codebase. This includes usage in struct definitions, function parameters, and variable assignments. No variations or inconsistencies were found in the naming convention.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent usage of 'win_prob_oracle' in the codebase.

# Test: Search for occurrences of 'win_prob_oracle'. Expect: Consistent naming and correct spelling.
rg --type rust 'win_prob_oracle'

Length of output: 1079

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 45fd0ff and 0bb2e01.

Files selected for processing (4)
  • chain/types/src/lib.rs (8 hunks)
  • ethereum/contracts/script/DeployAll.s.sol (3 hunks)
  • ethereum/contracts/src/WinningProbabilityOracle.sol (1 hunks)
  • ethereum/contracts/test/WinningProbabilityOracle.t.sol (1 hunks)
Additional comments not posted (17)
ethereum/contracts/src/WinningProbabilityOracle.sol (9)

1-2: LGTM: Appropriate license and Solidity version.

The GPL-3.0 license is suitable for an open-source project, and Solidity version 0.8.19 is a recent and stable version.


13-16: LGTM: Well-structured event definition.

The HoprWinningProbabilityOracleEvents abstract contract is a good practice for organizing events. The WinProbUpdated event properly emits both old and new winning probabilities, which is useful for off-chain monitoring and analysis.


18-44: LGTM: Well-structured contract with clear documentation.

The HoprWinningProbabilityOracle contract is well-defined, with appropriate inheritance from Ownable2Step and HoprWinningProbabilityOracleEvents. The detailed comment block provides excellent documentation of the contract's purpose and functionality, which greatly enhances code readability and maintainability.


45-48: LGTM: Appropriate state variable and custom error definition.

The currentWinProb state variable is correctly declared as public, providing easy access to the current winning probability. The custom error WinProbMustNotBeSame is a gas-efficient way to handle the case when the new probability is the same as the current one.


50-57: LGTM: Well-implemented constructor.

The constructor correctly initializes the contract state by transferring ownership and setting the initial winning probability. The use of the internal _setWinProb function for setting the initial probability is a good practice for code reuse and consistency.


59-68: LGTM: Well-implemented public function with proper access control.

The setWinProb function is correctly implemented with the following good practices:

  1. Restricted to the owner using the onlyOwner modifier.
  2. Checks if the new probability is different from the current one, preventing unnecessary updates and gas costs.
  3. Uses the internal _setWinProb function for the actual update, promoting code reuse.

70-79: LGTM: Well-implemented internal function.

The _setWinProb internal function is correctly implemented:

  1. It updates the currentWinProb state variable.
  2. It emits the WinProbUpdated event with both old and new probabilities.
  3. Storing the old probability before updating ensures accurate event emission.

This implementation promotes code reuse and maintains consistency in updating the winning probability.


1-80: Overall assessment: Well-implemented contract meeting PR objectives.

The HoprWinningProbabilityOracle contract successfully implements the winning probability oracle as outlined in the PR objectives and linked issue #6493. Key points:

  1. Proper access control using OpenZeppelin's Ownable2Step.
  2. Clear and efficient custom type definition for WinProb.
  3. Well-structured events for tracking probability updates.
  4. Comprehensive documentation and inline comments.
  5. Efficient state management and update mechanism.
  6. Appropriate error handling and gas optimization.

The contract is well-structured, follows Solidity best practices, and doesn't have any apparent security issues. It's ready for deployment after addressing the minor suggestions in the previous comments.

To ensure full compliance with the PR objectives, please verify that the deployment script and unit tests have been implemented as mentioned in the PR description. You can use the following command to check for the presence of these files:

#!/bin/bash
# Check for deployment script and test files
fd -e js -e ts "deploy|test" --exec echo "Found file: {}"

6-11: LGTM: Custom type definition enhances code clarity.

The custom type WinProb and its equality function are well-implemented, improving code readability and type safety.

Could you please clarify the rationale behind using uint56 for WinProb? Is this choice related to gas optimization or compatibility with other parts of the system? Adding a comment explaining this decision would improve code maintainability.

Verification successful

Verified: uint56 is uniquely used for WinProb, likely for optimization purposes.

The usage of uint56 in the WinProb type is specific to this context and not found elsewhere in Solidity files within the codebase. This suggests that the choice was intentional, possibly for gas optimization or efficient storage. The implementation enhances type safety and readability without introducing unnecessary complexity.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other occurrences of uint56 in the codebase
rg --type solidity "uint56" -C 2

Length of output: 717

ethereum/contracts/test/WinningProbabilityOracle.t.sol (5)

4-6: LGTM: Imports are appropriate for the test file.

The import statements correctly include the necessary dependencies for testing, including the Forge Standard Library, OpenZeppelin's Ownable2Step, and the custom WinningProbabilityOracle contract.


8-11: LGTM: Ownable2StepEvents contract correctly defines ownership transfer events.

The Ownable2StepEvents contract properly defines the events emitted during ownership transfer, which will be useful for testing the ownership transfer functionality.


13-20: LGTM: Test contract setup is well-structured.

The TicketWinningProbabilityOracleTest contract is correctly set up with appropriate inheritance and initialization. The setUp function properly initializes the test environment with a deterministic owner address and a maximum winning probability value.


34-44: LGTM: Revert tests are well-implemented.

The testRevert_setSameFails and testRevert_setByNonOwnerFails functions correctly test the revert conditions for setting the same winning probability value and attempting to set the value by a non-owner. The use of vm.prank and vm.expectRevert is appropriate for these tests.


70-85: LGTM: Ownership transfer test is comprehensive.

The test_transferOwnership function effectively tests the two-step ownership transfer process. It correctly simulates the actions of both the current and new owner, verifies the emission of appropriate events, and checks the final state of ownership. This test provides good coverage for the ownership transfer functionality.

ethereum/contracts/script/DeployAll.s.sol (3)

11-11: Import statement is correct.

The import of WinProb from WinningProbabilityOracle.sol is correctly implemented.


289-298: Deployment function follows established patterns.

The _deployHoprWinningProbabilityOracle function correctly deploys the WinningProbabilityOracle contract and is consistent with the existing deployment functions.


91-93: Verify the default winning probability value.

Ensure that WinProb.wrap(type(uint56).max) accurately represents a winning probability of 1.0 in the WinningProbabilityOracle contract. Confirm that this value aligns with the expected maximum and is correctly interpreted within the contract's logic.

Run the following script to verify that WinProb.wrap(type(uint56).max) corresponds to a winning probability of 1.0:

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 58653a3 and 851957b.

📒 Files selected for processing (1)
  • hopli/src/win_prob.rs (1 hunks)
🧰 Additional context used
📓 Learnings (1)
hopli/src/win_prob.rs (2)
Learnt from: QYuQianchen
PR: hoprnet/hoprnet#6501
File: hopli/src/win_prob.rs:121-123
Timestamp: 2024-09-25T17:18:27.689Z
Learning: If code is only used once, it's acceptable to keep it inline without refactoring it into a helper function.
Learnt from: QYuQianchen
PR: hoprnet/hoprnet#6501
File: hopli/src/win_prob.rs:149-151
Timestamp: 2024-09-25T14:34:42.518Z
Learning: In the `execute_get_win_prob` function in `win_prob.rs`, the winning probability is logged at the `info` level within the function, so additional output in `async_run` is unnecessary.

@ausias-armesto ausias-armesto marked this pull request as draft September 26, 2024 06:28
auto-merge was automatically disabled September 26, 2024 06:28

Pull request was converted to draft

@ausias-armesto ausias-armesto marked this pull request as ready for review September 26, 2024 06:29
@QYuQianchen QYuQianchen merged commit 7335b0d into master Sep 26, 2024
42 of 43 checks passed
@QYuQianchen QYuQianchen deleted the q/win-prob-contract branch September 26, 2024 07:36
Teebor-Choka pushed a commit that referenced this pull request Sep 26, 2024
…th the new contract (#6501)

Co-authored-by: Lukas <lukas.pohanka@inina.net>
@coderabbitai coderabbitai bot mentioned this pull request May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement winning probability oracle SC
3 participants