-
Notifications
You must be signed in to change notification settings - Fork 2
disambiguator on log table #153
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,11 +13,18 @@ import {LibDataContract, DataContractMemoryContainer} from "rain.datacontract/li | |
| import {LibBytes} from "rain.solmem/lib/LibBytes.sol"; | ||
| import {LibMemCpy, Pointer} from "rain.solmem/lib/LibMemCpy.sol"; | ||
| import {DecimalFloat} from "../../concrete/DecimalFloat.sol"; | ||
| import {LOG_TABLE_DISAMBIGUATOR} from "../table/LibLogTable.sol"; | ||
|
|
||
| library LibDecimalFloatDeploy { | ||
| function combinedTables() internal pure returns (bytes memory) { | ||
| return | ||
| abi.encodePacked(LOG_TABLES, LOG_TABLES_SMALL, LOG_TABLES_SMALL_ALT, ANTI_LOG_TABLES, ANTI_LOG_TABLES_SMALL); | ||
| return abi.encodePacked( | ||
| LOG_TABLES, | ||
| LOG_TABLES_SMALL, | ||
| LOG_TABLES_SMALL_ALT, | ||
| ANTI_LOG_TABLES, | ||
| ANTI_LOG_TABLES_SMALL, | ||
| LOG_TABLE_DISAMBIGUATOR | ||
| ); | ||
|
Comment on lines
+20
to
+27
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial 🧩 Analysis chainClarify the collision scenario and consider alternative approaches. The appended disambiguator successfully alters the deployment address, but the implementation raises some design questions:
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
🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| function dataContract() internal pure returns (DataContractMemoryContainer) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,10 @@ int256 constant ANTILOG_IDX_LAST_INDEX = ANTILOG_IDX_CARDINALITY - 1; | |
| uint256 constant LOG_TABLE_SIZE_BASE = LOG_MANTISSA_IDX_CARDINALITY / 10; | ||
| uint256 constant LOG_TABLE_SIZE_BYTES = LOG_TABLE_SIZE_BASE * 2; | ||
|
|
||
| /// @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"); | ||
|
Comment on lines
+22
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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 |
||
|
|
||
| /// @dev https://icap.org.pk/files/per/students/exam/notices/log-table.pdf | ||
| library LibLogTable { | ||
| function toBytes(uint16[10][90] memory table) internal pure returns (bytes memory) { | ||
|
|
||
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.
🧩 Analysis chain
Verify the deployment at the new address and ensure table data integrity.
The
LOG_TABLES_ADDRESSchange is critical as this constant is used bypow10,log10,pow, andsqrtfunctions. Using an incorrect address or one containing invalid table data would break all logarithmic operations.Please run the following verification steps:
Verify the contract is deployed at the new address and check if it contains the expected disambiguator:
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_ADDRESScontains the expected table data structure.🏁 Script executed:
Length of output: 73
🏁 Script executed:
Length of output: 633
LOG_TABLES_ADDRESS not deployed on mainnet
cast codeshows no contract at0x6421E8a23cdEe2E6E579b2cDebc8C2A514843593on mainnet. This constant underpinspow10,log10,pow, andsqrt—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.