Skip to content

disambiguator on log table#153

Merged
thedavidmeister merged 3 commits intomainfrom
2025-10-05-debug
Oct 5, 2025
Merged

disambiguator on log table#153
thedavidmeister merged 3 commits intomainfrom
2025-10-05-debug

Conversation

@thedavidmeister
Copy link
Copy Markdown
Contributor

@thedavidmeister thedavidmeister commented Oct 5, 2025

Motivation

Solution

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of log table deployments by adding a deployment disambiguation marker; no interface changes.
  • Documentation
    • Added inline notes describing the behavior and purpose of the new disambiguation marker.
  • Chores
    • Updated the reference to the external log-tables provider to point to the intended deployment.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 5, 2025

Walkthrough

Adds a new LOG_TABLE_DISAMBIGUATOR constant in LibLogTable, updates LibDecimalFloatDeploy.combinedTables() to include it, and changes LibDecimalFloat.LOG_TABLES_ADDRESS to a new address. No function signatures or control flow altered.

Changes

Cohort / File(s) Summary
Log table disambiguator constant
src/lib/table/LibLogTable.sol
Adds bytes32 constant LOG_TABLE_DISAMBIGUATOR (keccak256-derived) with documentation for deterministic log-table disambiguation.
Deploy concatenation update
src/lib/deploy/LibDecimalFloatDeploy.sol
Imports LOG_TABLE_DISAMBIGUATOR and appends it to combinedTables() via abi.encodePacked after ANTI_LOG_TABLES_SMALL; no other logic changes.
Log tables address update
src/lib/LibDecimalFloat.sol
Updates LOG_TABLES_ADDRESS constant from 0xdc56...f54 to 0x6421...3593; no other code changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • move constant #85 — Modifies usage/definition of LOG_TABLES_ADDRESS, directly related to the address change here.
  • sqrt #94 — Updates log-table handling including adding a disambiguator and changing table wiring; closely related to these edits.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “disambiguator on log table” directly references the primary change in this pull request, namely the introduction of a log table disambiguator constant and its inclusion in the combined deployment tables. It is succinct and fully related to the changeset without introducing unrelated or vague terms. As a concise noun phrase, it clearly signals the main feature added by the PR.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 2025-10-05-debug

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5c20822 and 1dbb693.

📒 Files selected for processing (2)
  • src/lib/deploy/LibDecimalFloatDeploy.sol (1 hunks)
  • src/lib/table/LibLogTable.sol (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-30T20:11:57.768Z
Learnt from: thedavidmeister
PR: rainlanguage/rain.math.float#144
File: src/lib/implementation/LibDecimalFloatImplementation.sol:708-732
Timestamp: 2025-09-30T20:11:57.768Z
Learning: In src/lib/implementation/LibDecimalFloatImplementation.sol, the `lookupLogTableVal` internal function intentionally omits bounds checking for gas optimization because all calling functions perform the necessary validation before invocation (e.g., checking against LOG_MANTISSA_LAST_INDEX in log10).

Applied to files:

  • src/lib/deploy/LibDecimalFloatDeploy.sol
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: deploy
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-static)
  • GitHub Check: rainix (ubuntu-latest, test-wasm-build)
  • GitHub Check: rainix (ubuntu-latest, rainix-rs-static)
  • GitHub Check: rainix (macos-latest, rainix-sol-legal)
  • GitHub Check: rainix (ubuntu-latest, rainix-rs-test)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-test)
  • GitHub Check: rainix (macos-latest, rainix-rs-test)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-legal)
  • GitHub Check: git-clean
🔇 Additional comments (1)
src/lib/deploy/LibDecimalFloatDeploy.sol (1)

16-16: LGTM!

The import statement correctly brings in the LOG_TABLE_DISAMBIGUATOR constant from the LibLogTable module.

Comment on lines +20 to +27
return abi.encodePacked(
LOG_TABLES,
LOG_TABLES_SMALL,
LOG_TABLES_SMALL_ALT,
ANTI_LOG_TABLES,
ANTI_LOG_TABLES_SMALL,
LOG_TABLE_DISAMBIGUATOR
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

🧩 Analysis chain

Clarify the collision scenario and consider alternative approaches.

The appended disambiguator successfully alters the deployment address, but the implementation raises some design questions:

  1. Versioning pattern: The constant suffix _1 suggests potential future values (_2, _3, etc.), which could become a maintenance burden. Each new value requires updating both the constant definition and deployment logic.

  2. Cost implications: The extra 32 bytes are stored in the data contract, increasing deployment gas costs. While minimal, this cost is paid on every deployment.

  3. Use case clarity: The comment states it avoids collisions "when we actually want distinct addresses," but it's unclear from the code what scenarios require multiple distinct deployments of the same table data.

Consider documenting the specific use case (e.g., "required when deploying to multiple chains with different table versions" or "enables parallel deployments for testing") to help future maintainers understand when and why this is needed.

Run the following script to check for any additional context about deterministic deployments and how the combined tables are consumed:


🏁 Script executed:

#!/bin/bash
# Description: Search for usages of combinedTables() and dataContract() to understand the deployment flow

# Search for calls to combinedTables() or dataContract()
rg -n --type=sol -A 5 -B 2 'combinedTables\(\)|dataContract\(\)' --glob '!src/lib/deploy/LibDecimalFloatDeploy.sol'

# Search for CREATE2 or deterministic deployment patterns
rg -n --type=sol -A 3 'CREATE2|create2|deterministic'

# Search for comments explaining the deployment strategy
rg -n --type=sol -B 2 -A 2 'collision|disambiguator|distinct address'

Length of output: 83


🏁 Script executed:

#!/bin/bash
# Search for calls to combinedTables() or dataContract() outside the deploy library
rg -n -g '*.sol' -C3 'combinedTables\(\)|dataContract\(\)' --glob '!src/lib/deploy/LibDecimalFloatDeploy.sol'
# Search for CREATE2 or create2 usage
rg -n -g '*.sol' -C3 'CREATE2|create2'
# Search for comments explaining collision or disambiguator usage
rg -n -g '*.sol' -C3 'collision|disambiguator|distinct address'

Length of output: 2725


Reconsider the disambiguator design in combinedTables

  • The _1 suffix in LOG_TABLE_DISAMBIGUATOR implies future versions, adding maintenance overhead.
  • Appending 32 bytes to the payload increases deployment gas; consider leveraging CREATE2’s salt instead of expanding the data.
  • Collision rationale is already documented in src/lib/table/LibLogTable.sol.
🤖 Prompt for AI Agents
In src/lib/deploy/LibDecimalFloatDeploy.sol around lines 20 to 27, the
combinedTables payload currently appends LOG_TABLE_DISAMBIGUATOR (with a _1
suffix) which both bloats deployment calldata and embeds a version-like suffix;
remove the disambiguator from the abi.encodePacked return and stop using the _1
suffix constant here, then switch the uniqueness/collision mechanism to
derive/encode the distinguishing value into the CREATE2 salt at deployment time
instead of into the table payload; update any deployment call sites to pass the
same distinguishing bytes via the CREATE2 salt and remove or rename the
LOG_TABLE_DISAMBIGUATOR constant and its usages so documentation in
src/lib/table/LibLogTable.sol remains the canonical rationale for collision
handling.

Comment on lines +22 to +24
/// @dev As we deterministically deploy the log tables, we can run into
/// collisions when we actually want distinct addresses.
bytes32 constant LOG_TABLE_DISAMBIGUATOR = keccak256("LOG_TABLE_DISAMBIGUATOR_1");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

LGTM with documentation suggestion.

The constant is correctly defined with a deterministic keccak256 hash. The use of _1 in the string suggests a versioning scheme, which aligns with the need to generate different addresses for different deployments.

Consider expanding the documentation to briefly mention the specific scenario(s) that require distinct addresses (e.g., "used when deploying different versions of log tables to the same chain" or "enables multiple test deployments without address conflicts").

🤖 Prompt for AI Agents
In src/lib/table/LibLogTable.sol around lines 22 to 24, expand the comment for
LOG_TABLE_DISAMBIGUATOR to state the specific scenarios needing distinct
addresses (e.g., deploying different versions of log tables to the same chain or
running multiple test deployments) so future readers understand why the
disambiguator/version suffix exists; update the docstring to include one short
sentence listing those scenarios and keep the existing constant unchanged.

Copy link
Copy Markdown
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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1dbb693 and 889badb.

📒 Files selected for processing (1)
  • src/lib/LibDecimalFloat.sol (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-30T20:11:57.768Z
Learnt from: thedavidmeister
PR: rainlanguage/rain.math.float#144
File: src/lib/implementation/LibDecimalFloatImplementation.sol:708-732
Timestamp: 2025-09-30T20:11:57.768Z
Learning: In src/lib/implementation/LibDecimalFloatImplementation.sol, the `lookupLogTableVal` internal function intentionally omits bounds checking for gas optimization because all calling functions perform the necessary validation before invocation (e.g., checking against LOG_MANTISSA_LAST_INDEX in log10).

Applied to files:

  • src/lib/LibDecimalFloat.sol
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: rainix (ubuntu-latest, rainix-rs-test)
  • GitHub Check: rainix (ubuntu-latest, rainix-rs-static)
  • GitHub Check: rainix (ubuntu-latest, test-wasm-build)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-legal)
  • GitHub Check: rainix (macos-latest, rainix-sol-legal)
  • GitHub Check: rainix (macos-latest, rainix-rs-test)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-test)
  • GitHub Check: git-clean

using LibDecimalFloat for Float;

address constant LOG_TABLES_ADDRESS = 0xdc564999251875a2728Eec15962c5456C9259f54;
address constant LOG_TABLES_ADDRESS = 0x6421E8a23cdEe2E6E579b2cDebc8C2A514843593;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify the deployment at the new address and ensure table data integrity.

The LOG_TABLES_ADDRESS change is critical as this constant is used by pow10, log10, pow, and sqrt functions. Using an incorrect address or one containing invalid table data would break all logarithmic operations.

Please run the following verification steps:

  1. Verify the contract is deployed at the new address and check if it contains the expected disambiguator:

  2. Search for deployment scripts or tests that verify the table data:

Additionally, consider documenting the deployment process or adding a verification test that ensures the deployed contract at LOG_TABLES_ADDRESS contains the expected table data structure.


🏁 Script executed:

#!/bin/bash
# Verify deployment and check for LOG_TABLE_DISAMBIGUATOR presence

NEW_ADDR="0x6421E8a23cdEe2E6E579b2cDebc8C2A514843593"

# Check if contract is deployed
CODE=$(cast code "$NEW_ADDR" --rpc-url mainnet 2>/dev/null || echo "")
if [ -z "$CODE" ] || [ "$CODE" = "0x" ]; then
  echo "ERROR: No contract deployed at $NEW_ADDR"
  exit 1
else
  echo "✓ Contract deployed at $NEW_ADDR"
  echo "Code size: ${#CODE} bytes"
fi

# Try to read LOG_TABLE_DISAMBIGUATOR if it's exposed
# This assumes the contract has a public getter for the disambiguator
cast call "$NEW_ADDR" "LOG_TABLE_DISAMBIGUATOR()(bytes32)" --rpc-url mainnet 2>/dev/null || echo "Note: Could not read LOG_TABLE_DISAMBIGUATOR (may not be publicly exposed)"

Length of output: 73


🏁 Script executed:

#!/bin/bash
# Find deployment and verification scripts

echo "=== Deployment scripts ==="
fd -e sol -e js -e ts . | xargs rg -l "LOG_TABLES_ADDRESS|0x6421E8a23cdEe2E6E579b2cDebc8C2A514843593"

echo -e "\n=== Tests for table deployment ==="
fd -e sol -e js -e ts . | xargs rg -l "LibDecimalFloatDeploy|combinedTables"

echo -e "\n=== LOG_TABLE_DISAMBIGUATOR usage ==="
ast-grep --pattern 'LOG_TABLE_DISAMBIGUATOR'

Length of output: 633


LOG_TABLES_ADDRESS not deployed on mainnet

cast code shows no contract at 0x6421E8a23cdEe2E6E579b2cDebc8C2A514843593 on mainnet. This constant underpins pow10, log10, pow, and sqrt—it must point to a live log-table contract. Deploy the tables at this address, update the constant to the correct address, or clarify the target network. Add a test that fails if the address has no deployed code.

@thedavidmeister thedavidmeister merged commit cdb0a36 into main Oct 5, 2025
10 checks passed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Oct 5, 2025

@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment:

S/M/L PR Classification Guidelines:

This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed.

Small (S)

Characteristics:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 5, 2025

Tip

For best results, initiate chat on the files or code changes.

SIZE=M

@coderabbitai coderabbitai Bot mentioned this pull request Jan 31, 2026
4 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Feb 8, 2026
4 tasks
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