Skip to content

V2 remove redundancy & optimize gas usage#4

Closed
nolnol3 wants to merge 4 commits intomainfrom
v2-remove-redundancy
Closed

V2 remove redundancy & optimize gas usage#4
nolnol3 wants to merge 4 commits intomainfrom
v2-remove-redundancy

Conversation

@nolnol3
Copy link
Copy Markdown
Member

@nolnol3 nolnol3 commented Jan 22, 2026

V2 remove redundancy & optimize gas usage

…etwork

When agent restarts with docker-compose, a new network is created.
Existing containers (created before restart) may not be connected to this new network.
This fix checks and reconnects containers to the correct network when they are reused.
Shorten data URI prefix from 'data:application/json;base64,' (30 bytes)
to 'data:;base64,' (13 bytes), saving 17 bytes per on-chain transaction.

This optimization reduces L1 calldata costs on Arbitrum L2.
The short format is valid per RFC 2397 - MIME type defaults to text/plain.
- Update CommitmentUtils test: remove redundancy, add verifierFee
- Update contracts-mock test: add coordinator and verifierFee fields
- Update PayloadUtils test: expect short data URI format (data:;base64,)
- Update storage test: expect short data URI format
- Update contract ABIs to remove redundancy field from Commitment
- Add verifierFee field to Commitment type
- Update Coordinator and Router wrappers for new contract interface
- Sync typechain generated types with updated ABIs
- Update agent-core to handle new Commitment structure
- Remove redundancy from ComputeSubscription type
- Update tests for new contract structure

All 497 tests passing.
@gemini-code-assist
Copy link
Copy Markdown

Important

Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces significant updates across the SDK, primarily focusing on contract ABI changes, gas optimization, and Docker container management. The 'redundancy' field has been removed from various contract events and internal data structures (e.g., RequestStartedEvent, Commitment, ComputeSubscription), replaced by a direct check for commitment existence using requestCommitments. A new verifierFee field has been added to relevant contract events and data structures. For gas optimization, a CoordinatorContract wrapper is introduced to support auto-generated access lists for reportComputeResult transactions, and data URI formatting for payloads has been shortened (data:;base64,) to reduce on-chain bytes. Docker container management is enhanced with a new ensureContainerNetwork method to ensure containers are connected to the correct network, improving robustness. Additionally, package versions across the monorepo have been bumped to 0.2.1-alpha.1, and logging for request and container IDs now displays full IDs instead of truncated ones. Review comments highlighted the broad catch block in ContainerManager.ts for potential refinement and emphasized the critical nature of the ABI changes in parseCommitment for data integrity and contract interaction.

Comment on lines +241 to +243
} catch (err: any) {
// Log but don't fail - container might still work on default network
console.warn(` ⚠️ Failed to ensure network connection for ${containerName}: ${err.message}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The catch (err: any) block is quite broad. While the comment indicates a conscious decision not to fail, consider if there are specific Docker-related error types that could be caught to allow for more granular logging or handling of transient vs. permanent issues. This would improve the robustness of the network connection logic.

Comment on lines 326 to +334
containerId: commitment.containerId,
client: commitment.client,
wallet: commitment.wallet,
feeToken: commitment.feeToken,
interval: Number(commitment.interval),
useDeliveryInbox: commitment.useDeliveryInbox,
walletAddress: commitment.walletAddress,
feeAmount: BigInt(commitment.feeAmount),
feeToken: commitment.feeToken,
verifier: commitment.verifier,
useDeliveryInbox: commitment.useDeliveryInbox,
coordinator: commitment.coordinator,
verifierFee: BigInt(commitment.verifierFee),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The parseCommitment method has been updated to reflect the new ABI structure, removing client and wallet and adding walletAddress, coordinator, and verifierFee. This is a critical change for data integrity and correct interaction with the updated contracts. Ensure that all parts of the system that rely on this parsed Commitment object are aware of these structural changes.

Comment on lines 319 to 331
return {
requestId: commitment.requestId,
subscriptionId: BigInt(commitment.subscriptionId),
interval: Number(commitment.interval),
redundancy: Number(commitment.redundancy),
containerId: commitment.containerId,
client: commitment.client,
wallet: commitment.wallet,
feeToken: commitment.feeToken,
interval: Number(commitment.interval),
useDeliveryInbox: commitment.useDeliveryInbox,
walletAddress: commitment.walletAddress,
feeAmount: BigInt(commitment.feeAmount),
feeToken: commitment.feeToken,
verifier: commitment.verifier,
useDeliveryInbox: commitment.useDeliveryInbox,
coordinator: commitment.coordinator,
verifierFee: BigInt(commitment.verifierFee),
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The parseCommitment method in RouterContract has been updated to align with the new ABI, removing client and wallet and adding walletAddress, coordinator, and verifierFee. This is crucial for maintaining data consistency and correct contract interactions. Verify that all consuming components correctly handle this updated structure.

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.

1 participant