-
Notifications
You must be signed in to change notification settings - Fork 118
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
StaticAddr: fix deposit detection #864
StaticAddr: fix deposit detection #864
Conversation
b5cba1f
to
d8953be
Compare
d8953be
to
7b6e602
Compare
staticaddr/address/interface.go
Outdated
@@ -18,7 +18,8 @@ var ( | |||
type Store interface { | |||
// CreateStaticAddress inserts a new static address with its parameters | |||
// into the store. | |||
CreateStaticAddress(ctx context.Context, addrParams *Parameters) error | |||
CreateStaticAddress(ctx context.Context, addrParams *Parameters, | |||
currentHeight int32) error |
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.
Why a separate argument currentHeight
is needed? addrParams
has new field InitiationHeight
.
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.
removed currentHeight
and use the InitiationHeight
.
7b6e602
to
23cc7ca
Compare
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.
LGTM, nice catch! 🎉
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.
LGTM! 🏆
I propose to add a test reproducing the bug being fixed.
@@ -147,6 +171,7 @@ func (m *Manager) NewAddress(ctx context.Context) (*btcutil.AddressTaproot, | |||
ProtocolVersion: version.AddressProtocolVersion( | |||
protocolVersion, | |||
), | |||
InitiationHeight: m.currentHeight, |
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.
Can currentHeight
be uninitialized (0) at this point? IMHO we should either return an error here if currentHeight is 0 (if we are sure that this won't happen) or wait for its initialization (e.g. using a cond var).
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.
For now I've added a check on entry of NewAddress
.
staticaddr/address/manager_test.go
Outdated
@@ -97,7 +97,7 @@ func TestManager(t *testing.T) { | |||
// Start the manager. | |||
go func() { | |||
err := testContext.manager.Run(ctxb) | |||
require.NoError(t, err) | |||
require.ErrorContains(t, err, "context canceled") |
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.
nit: require.ErrorIs(t, err, context.Canceled)
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.
fixed.
23cc7ca
to
b1c19e8
Compare
The height hint for deposit confirmations was previously set to the initiation height of the deposit manager, which does not work in case the manager is restarted before a deposit was confirmed.