-
Notifications
You must be signed in to change notification settings - Fork 23
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: helder testnet tx spammer #122
Conversation
WalkthroughThe changes introduce significant enhancements to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Application
participant RegistryContract
participant EthereumProvider
participant BeaconApiClient
User->>Application: Provide configuration and run
Application->>EthereumProvider: Connect to provider URL
Application->>RegistryContract: Query next preconfirmation slot
RegistryContract-->>Application: Return slot data and proposer URL
Application->>BeaconApiClient: Fetch current slot
BeaconApiClient-->>Application: Return current slot
Application->>EthereumProvider: Generate and sign transaction
Application->>EthereumProvider: Send transaction for preconfirmation
EthereumProvider-->>Application: Confirmation response
Application-->>User: Display transaction result
This sequence diagram outlines the primary flow for the 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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this 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 UI
Review profile: ASSERTIVE
Files ignored due to path filters (1)
bolt-spammer-helder/Cargo.lock
is excluded by!**/*.lock
Files selected for processing (9)
- bolt-spammer-helder/.env.example (1 hunks)
- bolt-spammer-helder/.gitignore (1 hunks)
- bolt-spammer-helder/Cargo.toml (1 hunks)
- bolt-spammer-helder/registry_abi.json (1 hunks)
- bolt-spammer-helder/src/constants.rs (1 hunks)
- bolt-spammer-helder/src/contract.rs (1 hunks)
- bolt-spammer-helder/src/lib.rs (1 hunks)
- bolt-spammer-helder/src/main.rs (1 hunks)
- bolt-spammer-helder/src/utils.rs (1 hunks)
Additional comments not posted (47)
bolt-spammer-helder/.gitignore (1)
1-2
: LGTM!The additions to the
.gitignore
file are appropriate and follow best practices.bolt-spammer-helder/src/lib.rs (1)
1-3
: LGTM!The new module declarations improve the modularity and organization of the codebase.
bolt-spammer-helder/.env.example (1)
1-5
: LGTM!The new environment variables provide a clear template for necessary configuration, enhancing ease of setup.
Ensure that the
.env.example
file is up-to-date with all required variables.bolt-spammer-helder/src/constants.rs (1)
1-4
: LGTM!The new constants are essential for the application's configuration and operation.
bolt-spammer-helder/Cargo.toml (12)
9-9
: LGTM! Dependencytokio
is correctly added with appropriate features.
10-10
: LGTM! Dependencyeyre
is correctly added.
11-11
: LGTM! Dependencyethers
is correctly added.
12-12
: LGTM! Dependencyrand
is correctly added.
13-13
: LGTM! Dependencyclap
is correctly added with appropriate features.
14-14
: LGTM! Dependencytracing
is correctly added.
15-15
: LGTM! Dependencytracing-subscriber
is correctly added.
16-16
: LGTM! Dependencyserde
is correctly added with appropriate feature.
17-17
: LGTM! Dependencyserde_json
is correctly added.
18-18
: LGTM! Dependencyreqwest
is correctly added.
19-19
: LGTM! Dependencybeacon-api-client
is correctly added from the specified repository and revision.
20-20
: LGTM! Dependencydotenvy
is correctly added.bolt-spammer-helder/src/utils.rs (3)
13-26
: LGTM! Functiongenerate_random_tx
is correctly implemented.
45-52
: LGTM! Functionprepare_rpc_request
is correctly implemented.
54-63
: LGTM! Functioncurrent_slot
is correctly implemented.bolt-spammer-helder/src/contract.rs (2)
12-64
: LGTM! Functionnext_preconfer_from_registry
is correctly implemented.
66-97
: LGTM! Functiontry_parse_url_from_token
is correctly implemented.bolt-spammer-helder/src/main.rs (6)
1-19
: LGTM! Imports are correctly added and necessary for the functionality.
21-43
: LGTM! StructOpts
is correctly defined with necessary fields.
45-56
: LGTM! Main function setup is correctly implemented.
58-66
: LGTM! Beacon API client initialization and slot retrieval are correctly implemented.
68-90
: LGTM! Proposer duties retrieval and next pre-confirmation slot determination are correctly implemented.
92-131
: LGTM! Transaction generation, signing, and sending are correctly implemented.bolt-spammer-helder/registry_abi.json (20)
3-12
: Constructor looks good.The constructor is defined correctly with a
_minimumCollateral
input of typeuint256
andnonpayable
state mutability.
14-19
: FunctionEXIT_COOLDOWN
looks good.The function correctly returns a
uint256
value withview
state mutability.
20-26
: FunctionMINIMUM_COLLATERAL
looks good.The function correctly returns a
uint256
value withview
state mutability.
27-39
: FunctionconfirmExit
looks good.The function takes an
address payable
input and hasnonpayable
state mutability.
40-46
: Functiondelegations
looks good.The function takes a
uint64
input and returns anaddress
withview
state mutability.
47-102
: FunctiongetOperatorForValidator
looks good.The function takes a
uint64
input and returns a complex data structure withview
state mutability.
103-117
: FunctiongetOperatorStatus
looks good.The function takes an
address
input and returns an enumIBoltRegistry.Status
withview
state mutability.
118-126
: FunctionisActiveOperator
looks good.The function takes an
address
input and returns abool
withview
state mutability.
127-141
: Functionregister
looks good.The function takes
uint64[]
,string
, andbytes
inputs and haspayable
state mutability.
142-171
: Functionregistrants
looks good.The function takes an
address
input and returns a complex data structure withview
state mutability.
172-178
: FunctionstartExit
looks good.The function has no inputs and has
nonpayable
state mutability.
180-207
: EventRegistered
looks good.The event includes indexed and non-indexed fields, which are correctly defined.
208-226
: EventStatusChange
looks good.The event includes indexed and non-indexed fields, which are correctly defined.
227-227
: ErrorAlreadyOptedIn
looks good.The error is correctly defined with no inputs.
228-228
: ErrorBasedProposerDoesNotExist
looks good.The error is correctly defined with no inputs.
229-229
: ErrorCooldownNotElapsed
looks good.The error is correctly defined with no inputs.
230-230
: ErrorInsufficientCollateral
looks good.The error is correctly defined with no inputs.
231-231
: ErrorInvalidStatusChange
looks good.The error is correctly defined with no inputs.
232-232
: ErrorNotFound
looks good.The error is correctly defined with no inputs.
233-233
: ErrorUnauthorized
looks good.The error is correctly defined with no inputs.
/// Signs a [TypedTransaction] with the given [Signer], returning a tuple | ||
/// with the transaction hash and the RLP-encoded signed transaction. | ||
pub async fn sign_transaction<S: Signer>( | ||
signer: &S, | ||
tx: TypedTransaction, | ||
) -> Result<(String, String)> { | ||
let Ok(signature) = signer.sign_transaction(&tx).await else { | ||
eyre::bail!("Failed to sign transaction") | ||
}; | ||
|
||
let rlp_signed_tx = tx.rlp_signed(&signature); | ||
let tx_hash = format!("0x{:x}", tx.hash(&signature)); | ||
let hex_rlp_signed_tx = format!("0x{}", hex::encode(rlp_signed_tx)); | ||
|
||
Ok((tx_hash, hex_rlp_signed_tx)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Function sign_transaction
is correctly implemented but consider a more conventional error handling approach.
The usage of let Ok(signature)
is unconventional. Consider using a match statement for better readability.
let signature = match signer.sign_transaction(&tx).await {
Ok(sig) => sig,
Err(_) => eyre::bail!("Failed to sign transaction"),
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary by CodeRabbit
New Features
Improvements
Cargo.toml
for enhanced functionality and performance.Documentation
Chores
.gitignore
to excludetarget/
directory and.env
file.