What changed, and why it matters
This is a small internal code cleanup. A helper function used only in tests is moved from one object to another so it does not become part of a new storage interface. There is no user-facing change and no security fix.
No action required. This is a non-functional refactor with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit removes OpenChannel.revocationLogTailCommitHeight() and updates two test call sites to invoke ChannelStateDB.revocationLogTailCommitHeight(channel) directly. The underlying implementation on ChannelStateDB already existed and is unchanged. This is purely a refactor to keep test-only helpers out of the backend-independent channel-state store contract.
Changed components
channeldb/channel.gochanneldb/channel_test.goInspect captured patch +2 / −15
diff --git a/channeldb/channel.go b/channeldb/channel.go
index b89d5f2..15bc802 100644
--- a/channeldb/channel.go
+++ b/channeldb/channel.go
@@ -3539,19 +3539,6 @@ func (c *ChannelStateDB) RemoveFwdPkgs(channel *OpenChannel,
}, func() {})
}
-// revocationLogTailCommitHeight returns the commit height at the end of the
-// revocation log. This entry represents the last previous state for the remote
-// node's commitment chain. The ChannelDelta returned by this method will
-// always lag one state behind the most current (unrevoked) state of the remote
-// node's commitment chain.
-// NOTE: used in unit test only.
-func (c *OpenChannel) revocationLogTailCommitHeight() (uint64, error) {
- c.RLock()
- defer c.RUnlock()
-
- return c.Db.revocationLogTailCommitHeight(c)
-}
-
// revocationLogTailCommitHeight returns the commit height at the end of the
// revocation log.
func (c *ChannelStateDB) revocationLogTailCommitHeight(
diff --git a/channeldb/channel_test.go b/channeldb/channel_test.go
index f900964..115794b 100644
--- a/channeldb/channel_test.go
+++ b/channeldb/channel_test.go
@@ -878,7 +878,7 @@ func TestChannelStateTransition(t *testing.T) {
// The state number recovered from the tail of the revocation log
// should be identical to this current state.
- logTailHeight, err := channel.revocationLogTailCommitHeight()
+ logTailHeight, err := cdb.revocationLogTailCommitHeight(channel)
require.NoError(t, err, "unable to retrieve log")
if logTailHeight != oldRemoteCommit.CommitHeight {
t.Fatal("update number doesn't match")
@@ -921,7 +921,7 @@ func TestChannelStateTransition(t *testing.T) {
// Once again, state number recovered from the tail of the revocation
// log should be identical to this current state.
- logTailHeight, err = channel.revocationLogTailCommitHeight()
+ logTailHeight, err = cdb.revocationLogTailCommitHeight(channel)
require.NoError(t, err, "unable to retrieve log")
if logTailHeight != oldRemoteCommit.CommitHeight {
t.Fatal("update number doesn't match")
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.