Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update labor #2667

Merged
merged 1 commit into from
Jan 25, 2025
Merged

update labor #2667

merged 1 commit into from
Jan 25, 2025

Conversation

credence0x
Copy link
Collaborator

@credence0x credence0x commented Jan 25, 2025

Summary by CodeRabbit

  • Chores

    • Updated contract class hashes in the Sepolia manifest
    • Simplified production configuration methods across multiple contracts
    • Removed labor cost-related calculations in shard production logic
  • Refactor

    • Streamlined production configuration interfaces
    • Removed unnecessary labor amount parameters in configuration methods

@credence0x credence0x requested a review from bob0005 January 25, 2025 18:10
Copy link
Contributor

mentatbot bot commented Jan 25, 2025

Hi @credence0x! You need to be added as a user to interact with me. Please ask @ponderingdemocritus to add you on the settings page.

You are receiving this comment because I am set to review all PRs. That is configurable here.

Copy link

vercel bot commented Jan 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eternum ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 25, 2025 6:13pm
eternum-docs ❌ Failed (Inspect) Jan 25, 2025 6:13pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
eternum-landing ⬜️ Ignored (Inspect) Jan 25, 2025 6:13pm

Copy link
Contributor

coderabbitai bot commented Jan 25, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/core/src/provider/index.ts

Oops! Something went wrong! :(

ESLint: 9.18.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

Walkthrough

This pull request introduces modifications to several files in the game contracts and core provider. The changes primarily focus on updating contract class hashes in the Sepolia manifest, removing labor cost-related configurations, and simplifying production configuration methods. The modifications streamline the production and resource management logic by eliminating redundant labor calculations and adjusting method signatures across multiple components of the system.

Changes

File Change Summary
contracts/game/manifest_sepolia.json Updated class_hash values for three different contract addresses
contracts/game/src/models/config.cairo Updated comment for labor_cost to mark for removal
contracts/game/src/models/resource/production/production.cairo Introduced RESOURCE_PRECISION constant and simplified labor unit calculations
contracts/game/src/systems/config/contracts.cairo Removed labor_amount parameter from set_production_config method
contracts/game/src/systems/map/map_generation.cairo Simplified get_shards_reward function by removing labor cost calculations
contracts/game/src/utils/testing/config.cairo Removed empty array span from set_production_config method call
packages/core/src/provider/index.ts Simplified set_production_config method call by removing duplicate parameter

Possibly related PRs

Suggested reviewers

  • bob0005
  • aymericdelab

Poem

🐰 Hop, hop, through code's green lane,
Labor costs fade like morning's rain
Class hashes dance, configs refine
Simplicity now starts to shine
A rabbit's code, sleek and bright! 🌟

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link

Failed to generate code suggestions for PR

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: 0

🧹 Nitpick comments (1)
packages/core/src/provider/index.ts (1)

1921-1921: LGTM! Consider adding type safety for calldata arrays.

The simplified production config calldata looks good. The separation of production and labor configs improves code organization.

Consider creating TypeScript types for the calldata arrays to improve type safety:

type ProductionCalldata = [resource_type: number, amount: number];
type LaborCalldata = [resource_type: number, cost_length: number, ...cost: Array<[resource: number, amount: number]>];
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aef638a and a5e7f70.

📒 Files selected for processing (7)
  • contracts/game/manifest_sepolia.json (3 hunks)
  • contracts/game/src/models/config.cairo (1 hunks)
  • contracts/game/src/models/resource/production/production.cairo (2 hunks)
  • contracts/game/src/systems/config/contracts.cairo (2 hunks)
  • contracts/game/src/systems/map/map_generation.cairo (1 hunks)
  • contracts/game/src/utils/testing/config.cairo (1 hunks)
  • packages/core/src/provider/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • contracts/game/src/models/config.cairo
🔇 Additional comments (10)
contracts/game/src/models/resource/production/production.cairo (3)

10-10: LGTM! Added import for RESOURCE_PRECISION constant.

The import aligns with the changes to use a fixed precision value instead of configurable labor costs.


Line range hint 166-166: Simplified labor calculation logic.

The labor calculation has been simplified to directly use the actual production amount. This change aligns with the removal of configurable labor costs.


55-57: Verify the impact of using fixed RESOURCE_PRECISION.

The change from using labor_cost to RESOURCE_PRECISION for divisibility checks could affect existing labor calculations. Please ensure this doesn't break existing functionality.

contracts/game/src/utils/testing/config.cairo (1)

144-144: LGTM! Simplified production config setup.

Removed unnecessary empty array argument, aligning with the updated production config interface.

contracts/game/src/systems/map/map_generation.cairo (1)

166-166: Simplified shard mining labor calculation.

The labor calculation has been simplified to directly use the actual production amount, removing the dependency on production configuration for labor calculations.

✅ Verification successful

Verified: Shard mining labor calculation simplification is properly isolated

The simplified labor calculation that directly uses the actual production amount is correctly implemented and doesn't affect other parts of the codebase. The change is contained within the shard mining system.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any other shard mining related calculations that might need updates
rg -A 5 "get_shards_reward"

Length of output: 1438


Script:

#!/bin/bash
# Search for shard mining and labor-related code
rg -l "EARTHEN_SHARD|labor_amount" contracts/

# Check for any configuration files related to production or mining
fd -e cairo -e toml "config|production|mining" contracts/

Length of output: 5737


Script:

#!/bin/bash
# Check implementation in production and labor models
ast-grep --pattern 'fn $_($$$ labor_amount $$$)' contracts/game/src/models/resource/production/labor.cairo
ast-grep --pattern 'fn $_($$$ labor_amount $$$)' contracts/game/src/models/resource/production/production.cairo

# Check for any other labor calculations that might depend on production config
rg -A 3 "labor_amount.*production" contracts/game/src/

Length of output: 608

contracts/game/src/systems/config/contracts.cairo (2)

134-134: Updated production config interface.

Removed the labor_amount parameter from the trait definition, simplifying the production configuration.


604-607: LGTM! Implementation matches updated interface.

The implementation has been updated to match the simplified interface, removing labor-related configuration.

contracts/game/manifest_sepolia.json (3)

5404-5404: Class hash update for map_generation_systems contract

The class hash for the map generation systems contract has been updated from 0x48a8ae3f6841aed95fb3186cf390db19854c8174fea69fdca19c88fd8c58c63 to 0x1829437a65fddf03e8f1322558035b38be8c06a5dd81f6a863a68569364b4cc.

Let's verify this contract upgrade:

✅ Verification successful

Class hash update for map_generation_systems contract is valid

The updated class hash corresponds to the map generation systems contract implementation found in the codebase. This contract handles critical game mechanics including shard mine discovery and mercenary deployment, and the hash update represents a legitimate contract upgrade.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the map generation systems contract upgrade
# 1. Check if the old class hash exists in git history
# 2. Check for any changes in map generation logic

# Check git history for the old class hash
git log -p | rg "0x48a8ae3f6841aed95fb3186cf390db19854c8174fea69fdca19c88fd8c58c63"

# Check for changes in map generation logic
ast-grep --pattern 'interface IMapGenerationSystems {
  $$$
  discover_shards_mine($$$) {
    $$$
  }
  $$$
}'

Length of output: 112


Script:

#!/bin/bash
# Search for old hash in current files
rg "0x48a8ae3f6841aed95fb3186cf390db19854c8174fea69fdca19c88fd8c58c63"

# Find manifest files
fd manifest.json

# Find map generation related files
fd -t f -e cairo map_generation

Length of output: 175


Script:

#!/bin/bash
# View map generation contract content
cat contracts/game/src/systems/map/map_generation.cairo

# Check recent changes to the file
git log --oneline contracts/game/src/systems/map/map_generation.cairo | head -n 5

Length of output: 11224


6344-6344: Class hash update for production_systems contract

The class hash for the production systems contract has been updated from 0x72be272c9af1769ad38beaf68495533628fdb4ead0a7879760d17b1f6bab196 to 0x580ae58de580e41af4107e2b651ba52fa4ebeb5266568c6658cfa95fdecf48b.

Let's verify this contract upgrade:


2385-2385: Class hash update for config_systems contract

The class hash for the config systems contract has been updated from 0x7fb2e9574aa693d81a15f3734dd0a8612ba8d64057b2aef692bd3117118a446 to 0x37798122f6085a277eedb203c93fe5ee2fbc99afe7427e4508b79000301dc2c.

Let's verify this contract upgrade:

✅ Verification successful

Class hash update verified - No impact on labor costs

The config_systems contract upgrade maintains all existing functionality including labor cost handling. The class hash update appears to be a routine implementation change rather than a feature removal.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the config systems contract upgrade
# 1. Check if the old class hash exists in git history
# 2. Check the contract's interface changes

# Check git history for the old class hash
git log -p | rg "0x7fb2e9574aa693d81a15f3734dd0a8612ba8d64057b2aef692bd3117118a446"

# Check if the contract interface has changed
ast-grep --pattern 'interface IProductionConfig {
  $$$
  set_production_config($$$) {
    $$$
  }
  $$$
}'

Length of output: 109


Script:

#!/bin/bash
# Search for the old class hash in current files
rg "0x7fb2e9574aa693d81a15f3734dd0a8612ba8d64057b2aef692bd3117118a446"

# Find relevant contract files
fd -e cairo -e json "config|production"

# Search for labor cost related patterns
rg -i "labor.*cost|cost.*config" -A 2 -B 2

Length of output: 67676


Script:

#!/bin/bash
# Search for production-related configurations and systems
rg -A 2 "production.*config|config.*production" -g "*.cairo"

# Look for any recent changes in production systems
fd -e cairo "production" --exec head -n 1

Length of output: 4898

@bob0005 bob0005 merged commit 76ff638 into next Jan 25, 2025
6 of 27 checks passed
@bob0005 bob0005 deleted the fix/labor branch January 25, 2025 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants