Skip to content
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

Add for wind/unwind support to tbc #159

Merged
merged 69 commits into from
Jul 22, 2024
Merged

Add for wind/unwind support to tbc #159

merged 69 commits into from
Jul 22, 2024

Conversation

marcopeereboom
Copy link
Contributor

Summary

This PR adds support for detecting canonical chain and unwinding of indexes during reorgs.

Changes

@marcopeereboom marcopeereboom added type: feature This adds new functionality size: XL This change is very large (+/- <1000) area: tbc This is a change to TBC (Tiny Bitcoin) labels Jun 26, 2024
@marcopeereboom marcopeereboom requested a review from a team as a code owner June 26, 2024 12:18
service/tbc/crawler.go Outdated Show resolved Hide resolved
@marcopeereboom marcopeereboom marked this pull request as draft June 26, 2024 13:36
@github-actions github-actions bot added the area: hemictl This is a change to hemictl label Jul 9, 2024
@marcopeereboom marcopeereboom added status: breaking This is a breaking and non-backwards compatible change size: XXL This change is extremely large (+/- 1000+). Changes this large should be split into multiple PRs and removed size: XL This change is very large (+/- <1000) labels Jul 22, 2024
cmd/hemictl/hemictl.go Outdated Show resolved Hide resolved
database/tbcd/level/level.go Outdated Show resolved Hide resolved
database/tbcd/level/level.go Show resolved Hide resolved
service/tbc/crawler.go Show resolved Hide resolved
service/tbc/crawler.go Show resolved Hide resolved
service/tbc/crawler.go Show resolved Hide resolved
@marcopeereboom marcopeereboom merged commit f09d4e5 into main Jul 22, 2024
6 checks passed
@marcopeereboom marcopeereboom deleted the marco/unwind branch July 22, 2024 18:03
web3cryptoguy pushed a commit to web3cryptoguy/heminetwork that referenced this pull request Nov 1, 2024
* Add function to determine canonical chain

* Refactor tests to simplify calling code

* Add name concept to block so that we can easily match blocks and geometry

* Proper exit tests so that we can multiple fake nodes and tbc clients

* Create odd geometries to hit corner cases

* Detect direction

* I think this fixes the unknown tip issue; code needs to be cleaned up but should go in for backup

* Determine direction and call wind/unwind function

* Flip direction logic around; while it was correct it was difficult to reason about

* Add linear test

* Add not linear error to check against

* unindex transactions

* cache parsed tx's in mined block for easy reference

* Flesh out mustHave to check all cached tx's exist

* ensure iterator does not step pout of bounds; it does :(

* Fix silly reversals

* Make this somewhat work

* ugh go vet being dumb

* Fixup names

* Do not store coinbase in spent transaction cache

* Bring back spent transaction cache test now that we no longer store the coinbase transaction

* Collapse IsLinear function and add callers for the various indexers

* Add utxo unwind

* Attempt at utxo unwind

* tbc: clean up unnecessary use of fmt.Errorf

* XXX

* maybe fix utxo unwind

* try to spend some coinbase tx'

* oops add new tx to mempool

* rebase main fallout

* Add a seperate tx signing test so that we can make this into a function that can be called from various spots in the code; this is too brittle to embed

* Remove cruft

* tbc: value of direction is never used (SA4006)

* tbc: add missing err check in TestBlockHeaderEncodeDecode

* tbc: replace loop with peers = append(peers, moreSeeds...) (S1011)

* tbc: remove unused (*Server).blocksMissing function

* tbcd/level: remove unused bytes2Block function

* tbcd/level: remove unused bytes2Header function

* tbcd/level: fix types being nested in one type block

* Create generic transaction from another transaction lots of help max

* Oops, print hex for scripthash

* Add a non forking test

* Working unwind!!! help from max and joshua

* Make a note that genesis does not produce a spent output

* mostly working forking unwind tests

* Keep track of balances

* disable broken balnce checks

* Note a bug in unwinding utxos

* Note an odd bug

* wait for server to shut down

* wait for port to be open

* do not error if context is canceled

* do not panic on cancel

* tbc: handle err returned by btcutil.NewAddressPubKeyHash in test

* tbc: use errors.New when formatting is not needed

* tbc: improve some spacing, code flow and readability

* tbc: attempt to improve impossible case for direction in TxIndexer

* tbc: remove unnecessary space before : in errors

* tbc: attempt to improve impossible case for direction in UtxoIndexer

* large wtf

* Fix off by one

* remove wait groups, add listener.close, more timing for mine and send

* add longer timing

* The big Spend->Spent rename

* Fix hemictl help

* Bunch of cleanup

* more fixes

* Couple more fixes, lot's of help joshuasing

* Update database/tbcd/database.go

Co-authored-by: Joshua Sing <[email protected]>

---------

Co-authored-by: Joshua Sing <[email protected]>
Co-authored-by: ClaytonNorthey92 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: hemictl This is a change to hemictl area: tbc This is a change to TBC (Tiny Bitcoin) size: XXL This change is extremely large (+/- 1000+). Changes this large should be split into multiple PRs status: breaking This is a breaking and non-backwards compatible change type: feature This adds new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants