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

Feat(cannon): Validators chunk size #330

Merged
merged 6 commits into from
Jun 11, 2024
Merged

Commits on Jun 11, 2024

  1. aider: Made the chunk size in the cannon beacon validators deriver co…

    …nfigurable with a default of 100.
    
    # Aider chat conversation:
    
    USER: Make the chunk size in the cannon beacon valdiators deriver configurable. Default to 100.
    
    ASSISTANT: To make the chunk size in the cannon beacon validators deriver configurable with a default value of 100, we will likely need to edit the following files:
    
    1. `pkg/cannon/deriver/config.go` - To add the new configuration option.
    2. `pkg/cannon/deriver/validators.go` (or similar file where the chunk size is used) - To use the new configuration option.
    
    Please add these files to the chat so I can provide the necessary *SEARCH/REPLACE* blocks.
    
    USER: I added these files to the chat: pkg/cannon/deriver/config.go.
    
    If you need to propose edits to other existing files not already added to the chat, you *MUST* tell the me their full path names and ask me to *add the files to the chat*. End your reply and wait for my approval. You can keep asking if you then decide you need to edit more files.
    
    ASSISTANT: To make the chunk size in the cannon beacon validators deriver configurable with a default value of 100, we need to:
    
    1. Add a new field to the `Config` struct in `pkg/cannon/deriver/config.go`.
    2. Ensure that this new configuration option is used in the appropriate place in the code.
    
    Let's start by adding the new configuration option to `pkg/cannon/deriver/config.go`.
    
    pkg/cannon/deriver/config.go
    ```go
    <<<<<<< SEARCH
    	BeaconValidatorsConfig      v1.BeaconValidatorsDeriverConfig            `yaml:"beaconValidators"`
    =======
    	BeaconValidatorsConfig      v1.BeaconValidatorsDeriverConfig            `yaml:"beaconValidators"`
    	ChunkSize                   int                                         `yaml:"chunkSize" default:"100"`
    >>>>>>> REPLACE
    ```
    
    Next, we need to ensure that this new configuration option is used in the appropriate place in the code. Please add the file where the chunk size is used, likely something like `pkg/cannon/deriver/validators.go`, to the chat.
    samcm committed Jun 11, 2024
    Configuration menu
    Copy the full SHA
    b8da374 View commit details
    Browse the repository at this point in the history
  2. aider: Moved the ChunkSize field to the BeaconValidatorsConfig struct.

    # Aider chat conversation:
    
    USER: move the chunk size tot he BeaconValidatorsConfig struct
    
    ASSISTANT: To move the `ChunkSize` field to the `BeaconValidatorsConfig` struct, we need to:
    
    1. Remove the `ChunkSize` field from the `Config` struct in `pkg/cannon/deriver/config.go`.
    2. Add the `ChunkSize` field to the `BeaconValidatorsConfig` struct in the appropriate file.
    
    Let's start with the changes to `pkg/cannon/deriver/config.go`.
    
    pkg/cannon/deriver/config.go
    ```go
    <<<<<<< SEARCH
    	BeaconValidatorsConfig      v1.BeaconValidatorsDeriverConfig            `yaml:"beaconValidators"`
    	ChunkSize                   int                                         `yaml:"chunkSize" default:"100"`
    =======
    	BeaconValidatorsConfig      v1.BeaconValidatorsDeriverConfig            `yaml:"beaconValidators"`
    >>>>>>> REPLACE
    ```
    
    Next, we need to add the `ChunkSize` field to the `BeaconValidatorsConfig` struct. Please add the file where the `BeaconValidatorsDeriverConfig` struct is defined, likely something like `pkg/cannon/deriver/beacon/eth/v1/config.go`, to the chat.
    samcm committed Jun 11, 2024
    Configuration menu
    Copy the full SHA
    c79d03d View commit details
    Browse the repository at this point in the history
  3. aider: Added ChunkSize to BeaconValidatorsDeriverConfig and updat…

    …ed its usage.
    
    # Aider chat conversation:
    
    USER: Make the beacon validators deriver respect the new config value.
    
    ASSISTANT: To make the beacon validators deriver respect the new `ChunkSize` config value, we need to:
    
    1. Ensure the `ChunkSize` field is added to the `BeaconValidatorsDeriverConfig` struct.
    2. Update the code that uses the chunk size to reference this new config value.
    
    Let's start by adding the `ChunkSize` field to the `BeaconValidatorsDeriverConfig` struct. Please add the file where the `BeaconValidatorsDeriverConfig` struct is defined, likely something like `pkg/cannon/deriver/beacon/eth/v1/config.go`, to the chat.
    
    USER: I added these files to the chat: /Users/samcm/go/src/github.com/ethpandaops/xatu/pkg/cannon/deriver/beacon/eth/v1/beacon_validators.go.
    
    If you need to propose edits to other existing files not already added to the chat, you *MUST* tell the me their full path names and ask me to *add the files to the chat*. End your reply and wait for my approval. You can keep asking if you then decide you need to edit more files.
    
    ASSISTANT: To make the beacon validators deriver respect the new `ChunkSize` config value, we need to:
    
    1. Add the `ChunkSize` field to the `BeaconValidatorsDeriverConfig` struct in `pkg/cannon/deriver/beacon/eth/v1/beacon_validators.go`.
    2. Update the code that uses the chunk size to reference this new config value.
    
    Here are the necessary *SEARCH/REPLACE* blocks:
    
    pkg/cannon/deriver/beacon/eth/v1/beacon_validators.go
    ```go
    <<<<<<< SEARCH
    	Enabled bool `yaml:"enabled" default:"true"`
    =======
    	Enabled  bool `yaml:"enabled" default:"true"`
    	ChunkSize int  `yaml:"chunkSize" default:"100"`
    >>>>>>> REPLACE
    ```
    
    pkg/cannon/deriver/beacon/eth/v1/beacon_validators.go
    ```go
    <<<<<<< SEARCH
    	// Chunk the validators per 1000
    	chunkSize := 1000
    =======
    	// Chunk the validators per the configured chunk size
    	chunkSize := b.cfg.ChunkSize
    >>>>>>> REPLACE
    ```
    
    This will ensure that the chunk size is configurable and defaults to 100 as specified in the configuration.
    samcm committed Jun 11, 2024
    Configuration menu
    Copy the full SHA
    5711930 View commit details
    Browse the repository at this point in the history
  4. aider: Added startup logs to BeaconValidatorsDeriver.

    # Aider chat conversation:
    
    USER: Add logs to the startup of the deriver
    
    ASSISTANT: To add logs to the startup of the deriver, we will add logging statements in the `Start` method of the `BeaconValidatorsDeriver` struct in `pkg/cannon/deriver/beacon/eth/v1/beacon_validators.go`.
    
    Here is the *SEARCH/REPLACE* block:
    
    pkg/cannon/deriver/beacon/eth/v1/beacon_validators.go
    ```go
    <<<<<<< SEARCH
    	if !b.cfg.Enabled {
    		b.log.Info("Validator states deriver disabled")
    
    		return nil
    	}
    
    	b.log.Info("Validator states deriver enabled")
    =======
    	b.log.WithFields(logrus.Fields{
    		"chunk_size": b.cfg.ChunkSize,
    		"enabled":    b.cfg.Enabled,
    	}).Info("Starting BeaconValidatorsDeriver")
    
    	if !b.cfg.Enabled {
    		b.log.Info("Validator states deriver disabled")
    		return nil
    	}
    
    	b.log.Info("Validator states deriver enabled")
    >>>>>>> REPLACE
    ```
    
    This will add a log statement at the start of the `Start` method, logging the chunk size and whether the deriver is enabled.
    samcm committed Jun 11, 2024
    Configuration menu
    Copy the full SHA
    48d2cd0 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    473feb8 View commit details
    Browse the repository at this point in the history
  6. chore: linting

    samcm committed Jun 11, 2024
    Configuration menu
    Copy the full SHA
    8c54458 View commit details
    Browse the repository at this point in the history