Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9a8ba84
Add v4 keystone height hash index
marcopeereboom Jun 10, 2025
93c50e9
decode all keystones
marcopeereboom Jun 10, 2025
6725cbd
Decode the various databases
marcopeereboom Jun 10, 2025
33b0add
encode height to keystone hash
marcopeereboom Jun 10, 2025
cf9ff92
Use abbreviated hash
marcopeereboom Jun 10, 2025
7b14ab6
correct spot
marcopeereboom Jun 10, 2025
19f441c
64 entire bits
marcopeereboom Jun 10, 2025
9f8e579
test this shit real quick
marcopeereboom Jun 10, 2025
33d1de3
remove test code and put results in database
marcopeereboom Jun 10, 2025
93b7a33
Let's start putting this together
marcopeereboom Jun 10, 2025
d0b1651
Show antonio
marcopeereboom Jun 11, 2025
bf14da2
remove fixed XXX
marcopeereboom Jun 11, 2025
f6c6d6f
return height as well with a shortcut
marcopeereboom Jun 11, 2025
efb37e6
add height hash index encoding test
AL-CT Jun 11, 2025
953d45a
fix block missing height error and linter
AL-CT Jun 11, 2025
f73790a
Do we want this antonio?
marcopeereboom Jun 11, 2025
2b36211
oops remove panic
marcopeereboom Jun 11, 2025
73c165d
Here is a better version antonio
marcopeereboom Jun 11, 2025
9a9b734
oops, fix error
marcopeereboom Jun 11, 2025
1d09dc4
minor test fixes for db upgrade
AL-CT Jun 11, 2025
3ba098e
add keystone by height and tests
AL-CT Jun 11, 2025
bcb0fc2
Don't use CloneBytes
marcopeereboom Jun 12, 2025
430fa1b
Cleanup
marcopeereboom Jun 12, 2025
211f1fb
verify height and use found height
marcopeereboom Jun 12, 2025
b236647
Attempt at depth
marcopeereboom Jun 12, 2025
1a2f959
fix height seeking on keystone by hash
AL-CT Jun 12, 2025
8cd2b60
off by one fix and tests
AL-CT Jun 12, 2025
def77d6
add keystonesbyheight to hemictl
AL-CT Jun 12, 2025
ac36984
add keystonesbyheight rpc call
AL-CT Jun 12, 2025
c467c79
try to please codeql for all the unnecessary reasons
marcopeereboom Jun 13, 2025
eaa20aa
Just stop being clever to save 4 bytes per keystone
marcopeereboom Jun 13, 2025
adc9c70
fix upgrade and add testing
AL-CT Jun 13, 2025
e3bff87
Revert "fix upgrade and add testing"
AL-CT Jun 16, 2025
5acc2e6
fix v4 upgrade
AL-CT Jun 16, 2025
6acc0fb
add v4 upgrade test and new v3 test database
AL-CT Jun 16, 2025
668434f
Cleanup a little
marcopeereboom Jun 17, 2025
5cf28d2
fix keystones by height
AL-CT Jun 17, 2025
825ac2c
add extra test
AL-CT Jun 19, 2025
5e9552b
forgot one
AL-CT Jun 19, 2025
4e9684f
fix comments and suggestions
AL-CT Jun 19, 2025
b7ce764
cleanup
AL-CT Jun 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test this shit real quick
  • Loading branch information
marcopeereboom authored and AL-CT committed Jun 24, 2025
commit 9f8e57916eebef7440ea77b379d525f6be03e653
16 changes: 16 additions & 0 deletions database/tbcd/level/level.go
Original file line number Diff line number Diff line change
Expand Up @@ -1973,6 +1973,22 @@ func encodeKeystoneHeightHash(height uint64, hash chainhash.Hash) (e [keystoneHe
return
}

func decodeKeystoneHeightHash(v []byte) (height uint64, hash chainhash.Hash) {
if len(v) != keystoneHeightHashSize {
panic(fmt.Sprintf("invalid length: %v", len(v)))
}
if v[0] != 'h' {
panic("not a keystone height hash index")
}
height = binary.BigEndian.Uint64(v[1 : 1+8])
h := &hash
err := h.SetBytes(v[9:])
if err != nil {
panic(err)
}
return
}

func (l *ldb) BlockKeystoneUpdate(ctx context.Context, direction int, keystones map[chainhash.Hash]tbcd.Keystone, keystoneIndexHash chainhash.Hash) error {
log.Tracef("BlockKeystoneUpdate")
defer log.Tracef("BlockKeystoneUpdate exit")
Expand Down
11 changes: 10 additions & 1 deletion database/tbcd/level/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ func (l *ldb) v4(ctx context.Context) error {
key := i.Key()
value := i.Value()
if len(value) != keystoneSize {
// Index value, not a keystone
// Not a keystone.
continue
}
ks := decodeKeystone(value)
Expand All @@ -582,7 +582,16 @@ func (l *ldb) v4(ctx context.Context) error {
return fmt.Errorf("hash: %w", err)
}
ehh := encodeKeystoneHeightHash(bh.Height, *ksHash)
x, y := decodeKeystoneHeightHash(ebh)
log.Infof("%x: %x -> %x", key, bh.Height, ehh)
_ = x
_ = y
if x != bh.Height {
panic("height")
}
if !y.IsEqual(ksHash) {
panic("hash")
}
}
if i.Error() != nil {
return fmt.Errorf("keystones iterator: %w", i.Error())
Expand Down