Skip to content

fix(sdk): bug causing error when no tx nonce given#2556

Merged
mergify[bot] merged 1 commit intodevelopfrom
sc/sdk-fix-nonce-bug
May 11, 2022
Merged

fix(sdk): bug causing error when no tx nonce given#2556
mergify[bot] merged 1 commit intodevelopfrom
sc/sdk-fix-nonce-bug

Conversation

@smartcontracts
Copy link
Contributor

Description
Fixes a bug in the SDK that would throw an error when the user did not
provide a nonce along with the transaction (when estimating gas). If no
nonce is provided, will try to find a reasonable nonce or use a default
(large) nonce that will give a good upper bound for the L1 gas cost.

Metadata

@changeset-bot
Copy link

changeset-bot bot commented May 10, 2022

🦋 Changeset detected

Latest commit: f8db278

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@eth-optimism/sdk Patch
@eth-optimism/message-relayer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the A-pkg-sdk Area: packages/sdk label May 10, 2022
@mergify mergify bot requested review from cfromknecht and tuxcanfly May 10, 2022 17:58
@smartcontracts smartcontracts force-pushed the sc/sdk-fix-nonce-bug branch from a025959 to c577880 Compare May 10, 2022 18:01
@tynes
Copy link
Contributor

tynes commented May 10, 2022

Whats up with the diff in the yarn.lock? I don't see any changes in a package.json

Fixes a bug in the SDK that would throw an error when the user did not
provide a nonce along with the transaction (when estimating gas). If no
nonce is provided, will try to find a reasonable nonce or use a default
(large) nonce that will give a good upper bound for the L1 gas cost.
@smartcontracts smartcontracts force-pushed the sc/sdk-fix-nonce-bug branch from c577880 to f8db278 Compare May 10, 2022 22:36
Copy link
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify
Copy link
Contributor

mergify bot commented May 11, 2022

This PR has been added to the merge queue, and will be merged soon.

@mergify mergify bot merged commit 8690155 into develop May 11, 2022
@mergify mergify bot deleted the sc/sdk-fix-nonce-bug branch May 11, 2022 01:59
@mergify
Copy link
Contributor

mergify bot commented May 11, 2022

This PR is next in line to be merged, and will be merged as soon as checks pass.

@mslipper mslipper mentioned this pull request May 12, 2022
nitaliano pushed a commit that referenced this pull request May 20, 2024
Fixes a bug in the SDK that would throw an error when the user did not
provide a nonce along with the transaction (when estimating gas). If no
nonce is provided, will try to find a reasonable nonce or use a default
(large) nonce that will give a good upper bound for the L1 gas cost.
theochap added a commit that referenced this pull request Dec 10, 2025
## Overview

This PR adds comprehensive documentation for the `kona-engine` crate to
improve developer experience and API understanding. The documentation is
cohesive yet concise, staying well under the 500-line limit while
providing complete coverage of the public API.

## Changes Made

### Enhanced README.md (62 lines added)
- **Comprehensive overview** of the engine's purpose and architecture
- **Working code example** demonstrating proper usage with async/await
patterns
- **Engine API compatibility matrix** showing version support across
hardforks
- **Key components documentation** with cross-references to main types

### Improved Crate-Level Documentation (28 lines added)
- Added **architecture diagram** showing component relationships
- Enhanced **module organization** documentation with clear descriptions
- Fixed rustdoc link issues by referencing public types instead of
private modules

### Enhanced API Documentation
- **EngineClient**: Detailed HTTP client docs with JWT authentication
examples
- **EngineSyncState**: Comprehensive safety level explanations with OP
Stack references
- **EngineQueries**: Enhanced query interface documentation with usage
patterns
- **Metrics**: Added Prometheus metrics documentation with practical
examples
- **EngineKind**: Improved client type identification with string
parsing examples
- **AttributesMatch**: Better payload validation documentation with use
cases
- **Version Enums**: Enhanced Engine API version selection with hardfork
mapping

## Technical Accuracy

All documentation includes:
- ✅ **Cross-references** between related types using proper `[Type]`
syntax
- ✅ **Technical accuracy** with references to [OP Stack
specifications](https://specs.optimism.io)
- ✅ **Working code examples** that compile and demonstrate real usage
- ✅ **Hardfork compatibility** explanations for Engine API version
selection

## Verification

- **Documentation builds cleanly** with `RUSTDOCFLAGS="-D warnings"`
- **All doc tests pass** (3 passed, 2 ignored as expected)
- **Total lines added: 281** (well under 500 limit)
- **Comprehensive coverage** of all public APIs

## Example Usage

The enhanced documentation now provides clear guidance:

```rust
use kona_engine::{Engine, EngineClient, EngineState};
use kona_genesis::RollupConfig;
use alloy_rpc_types_engine::JwtSecret;

// Create authenticated Engine API client
let client = EngineClient::new_http(engine_url, l2_url, l1_url, config, jwt);

// Initialize engine with task queue
let state = EngineState::default();
let (state_sender, _) = tokio::sync::watch::channel(state);
let (queue_sender, _) = tokio::sync::watch::channel(0);
let engine = Engine::new(state, state_sender, queue_sender);
```

This documentation improvement makes the kona-engine crate more
accessible to developers while maintaining the existing high code
quality standards.

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: refcell <21288394+refcell@users.noreply.github.com>
Co-authored-by: refcell <abigger87@gmail.com>
Co-authored-by: theochap <80177219+theochap@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-pkg-sdk Area: packages/sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nonce is required in TransactionRequest parameter object in estimateL1Gas & estimateL1GasCost

3 participants