Repository navigation
feat(base-time): expose the BaseTime predeploy read surface - #238
Merged
Merged
Conversation
Denim installs the BaseTime predeploy at 0x4200...0030, which exposes the millisecond component of the current block timestamp. Add a read-only IBaseTime interface (timestampMillisPart, timestampMs, version) and a new StdPredeploys library with a typed BASE_TIME handle. Predeploys are EVM bytecode rather than native precompiles, so they get their own library instead of extending StdPrecompiles. The depositor-only setter and its errors are left out: only the protocol's tx[1] deposit can call it, so integrators would only ever see it revert. MockBaseTime stores its uint16 at slot 0, deliberately deviating from the ERC-7201 mock convention: storage parity with the real contract is the invariant, and the real predeploy uses the compiler's sequential layout. BaseTest etches the mock only when the address has no code, independent of the precompile live/reference probe, so live runs keep real bytecode. Adds unit tests for each function, selector pins, slot-0 layout tests, reference docs, and a Denim changelog entry. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a11ca1-0972-76cc-9a30-05db0799da5a
3 tasks done
Interface Coverage✅ All interface functions have test coverage. |
📊 Forge Coverage (
|
| File | Lines | Stmts | Branches | Funcs |
|---|---|---|---|---|
| 🟡 B20FactoryLib.sol | 97.70% | 98.00% | 100.00% | 95.00% |
| 🔴 test/lib/ForceFeeder.sol | 0.00% | 0.00% | 100.00% | 0.00% |
| 🔴 test/lib/PrecompileProbe.sol | 0.00% | 0.00% | 0.00% | 0.00% |
| 🟢 MockActivationRegistry.sol | 100.00% | 100.00% | 100.00% | 100.00% |
| 🟢 MockActivationRegistryStorage.sol | 100.00% | 100.00% | 100.00% | 100.00% |
| 🟢 MockB20.sol | 100.00% | 99.68% | 100.00% | 100.00% |
| 🟢 MockB20Asset.sol | 100.00% | 100.00% | 100.00% | 100.00% |
| 🟡 MockB20Factory.sol | 98.96% | 99.10% | 100.00% | 100.00% |
| 🟢 MockB20Stablecoin.sol | 100.00% | 100.00% | 100.00% | 100.00% |
| 🟢 MockB20Storage.sol | 100.00% | 100.00% | 100.00% | 100.00% |
| 🟢 MockBaseTime.sol | 100.00% | 100.00% | 100.00% | 100.00% |
| 🟡 MockPolicyRegistry.sol | 100.00% | 99.58% | 97.78% | 100.00% |
| 🟢 MockPolicyRegistryStorage.sol | 100.00% | 100.00% | 100.00% | 100.00% |
| Total | 97.14% | 97.51% | 98.21% | 97.07% |
Full report: download artifact. To browse locally: make coverage (runs forge coverage + genhtml + opens the HTML report).
|
0x00101010
marked this pull request as ready for review
October 8, 2026 22:49
0x00101010
requested review from
amiecorso,
eric-ships,
ilikesymmetry and
rayyan224
as code owners
October 8, 2026 22:50
amiecorso
approved these changes
Oct 9, 2026
3 tasks
Open
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
IBaseTimeinterface (timestampMillisPart,timestampMs,version) for the BaseTime predeploy that Denim installs at0x4200000000000000000000000000000000000030.StdPredeployswith a typedBASE_TIMEhandle. Predeploys are EVM bytecode rather than native precompiles, so they get their own library instead of extendingStdPrecompiles.tx[1]deposit can call it.MockBaseTimewithuint16 timestampMillisPartat slot 0, matching the real predeploy's sequential layout (a deliberate deviation from the ERC-7201 mock convention).BaseTestetches it only when the address has no code, so runs against a node with the real predeploy keep the real bytecode.CHANGELOG.mdsummary/compatibility update.Companion change in base/contracts (NatSpec/tests only, bytecode unchanged): base/contracts#449.
Test plan
forge build,forge test -v(804 passed, 4 skipped)forge fmt --checkpython3 script/check-coverage.pycast sigmatches the pinned selectors (0x7b2fea99,0x5745a677,0x54fd4d50)make fork-tests) against a node with BaseTime installed