Skip to content

Commit f6ec8f7

Browse files
committed
changed configuration setup to blindbit.example.toml style
* fixed bug related to non-eligible taproot spent taproot outputs causing crashes at count_tweak != 1 check * look out for computational overhead due to constant checks on existing utxos (alternative is to store all spent and periodically prune; and for initial sync after full sync is done)
1 parent 652bbce commit f6ec8f7

File tree

19 files changed

+396
-164
lines changed

19 files changed

+396
-164
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ docker-compose.yaml
1515
/mainnet-test-1/
1616
/_prod_/
1717
/regtest-2/
18+
/bin/
19+
/signet-1/
20+
/dev/

README.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
A GO implementation for a BIP0352 Silent Payments Indexing Server.
44
This backend was focused on serving the BlindBit light clients with tweak data and other simplified data to spend and
5-
receive.
5+
receive. The produced index matches that
6+
of [other implementations](https://github.com/bitcoin/bitcoin/pull/28241#issuecomment-2079270744).
67

78
## Setup
89

@@ -55,7 +56,11 @@ Once the ENV variables are set you can just run the binary.
5556

5657
## Todos
5758

58-
- [ ] Convert env vars into command line args
59+
- [ ] Add flags to control setup
60+
- reindex
61+
- headers only
62+
- tweaks only
63+
- move most env controls to config file or cli flags/args
5964
- [ ] Include [gobip352 module](https://github.com/setavenger/gobip352)
6065
- [ ] Refactor a bunch of stuff to use byte arrays or slices instead of strings for internal uses
6166
- Could potentially reduce the serialisation overhead
@@ -64,28 +69,11 @@ Once the ENV variables are set you can just run the binary.
6469
- [ ] Clean up code (bytes.Equal, parity on big.int with .Bit(), etc.)
6570
- [ ] Update to new test vectors
6671
- [ ] Write operation tests to ensure data integrity
67-
- [ ] Benchmark btcec vs libsecp C library wrapper/binding
68-
- probably need to create my own wrapper
69-
- https://github.com/renproject/secp256k1
70-
- https://github.com/ethereum/go-ethereum/tree/master/crypto/secp256k1/libsecp256k1 (~8 years without update)
7172
- [ ] Periodically recompute filters
7273
- One could implement a periodic re-computation every 144 blocks of filters with the current UTXO set
73-
- [ ] Investigate whether we should change the compound keys to use the height instead of the hash. As keys are sorted
74-
this could potentially give a performance boost due to better order across blocks.
75-
- ON_HOLD: Not reorg resistant unless some extra work and checks are made
7674
- [ ] Document EVERYTHING: especially serialization patterns to easily look them up later.
7775
- Serialisation
7876
- tweak computation methods
79-
- ...
80-
- [x] Redo the storage system. After syncing approximately 5,500 blocks, the estimated storage at 100,000 blocks for
81-
tweaks alone will be somewhere around 40Gb. Additionally, performance is getting worse.
82-
- Done: Switched to LevelDB see here
83-
for [current numbers](https://github.com/setavenger/BIP0352-light-client-specification)
84-
- [x] Investigate whether RPC parallel calls can speed up syncing. Caution: currently the flow is synchronous and hence
85-
there is less complexity. Making parallel calls will change that.
86-
- note: This was mainly limited by a slow home node. First tests a more performant node show that this is not as big
87-
as a problem. Also using parallel calls on a weak node just increases the latency for every individual call
88-
reducing most of the gains from parallel calls.
8977
- [ ] Include redundancy for when RPC calls are failing (probably due to networking issues in a testing home
9078
environment).
9179
- [ ] Review all duplicate key error exemptions and raise to error/warn from debug.
@@ -94,6 +82,10 @@ Once the ENV variables are set you can just run the binary.
9482
- [ ] Convert hardcoded serialisation assertions into constants (?)
9583
- [ ] Use x-only 32 byte public keys instead of scriptPubKey
9684

85+
### Low Priority
86+
- [ ] Index the next couple blocks in mempool
87+
- Every 1-3 minute or so?
88+
9789
## Endpoints
9890

9991
```text

blindbit.example.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# default "./.blindbit-oracle"
2+
base_directory="./blindbit-oracle"
3+
4+
# 0.0.0.0:8000 to expose outside of localhost
5+
host="127.0.0.1:8000"
6+
7+
# (defaults to http://127.0.0.1:8332)
8+
rpc_endpoint="http://127.0.0.1:18443"
9+
10+
rpc_pass="your-rpc-password"
11+
12+
rpc_user="your-rpc-user"
13+
14+
# (has to be >= 1)
15+
sync_start_height=1
16+
17+
# the default for this is 1, but should be set to a higher value to increase performance,
18+
# one should set this in accordance to how many cores one wants to use
19+
max_parallel_tweak_computations=4
20+
21+
# (depends on max-rpc-workers of the underlying full node)
22+
max_parallel_requests=4
23+
24+
#
25+
# optional - will only generate tweaks
26+
# default: 0 set to 1 to activate
27+
tweaks_only=1

go.mod

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module SilentPaymentAppBackend
22

3-
go 1.18
3+
go 1.20
44

55
require (
66
github.com/btcsuite/btcd/btcec/v2 v2.2.0
@@ -9,6 +9,7 @@ require (
99
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
1010
github.com/gin-gonic/gin v1.9.1
1111
github.com/shopspring/decimal v1.3.1
12+
github.com/spf13/viper v1.18.2
1213
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
1314
golang.org/x/crypto v0.17.0
1415
)
@@ -21,31 +22,43 @@ require (
2122
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
2223
github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect
2324
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
24-
github.com/fsnotify/fsnotify v1.6.0 // indirect
25+
github.com/fsnotify/fsnotify v1.7.0 // indirect
2526
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
2627
github.com/gin-contrib/sse v0.1.0 // indirect
2728
github.com/go-playground/locales v0.14.1 // indirect
2829
github.com/go-playground/universal-translator v0.18.1 // indirect
2930
github.com/go-playground/validator/v10 v10.14.0 // indirect
3031
github.com/goccy/go-json v0.10.2 // indirect
3132
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
32-
github.com/google/go-cmp v0.5.9 // indirect
33+
github.com/hashicorp/hcl v1.0.0 // indirect
3334
github.com/json-iterator/go v1.1.12 // indirect
3435
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 // indirect
3536
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
3637
github.com/leodido/go-urn v1.2.4 // indirect
38+
github.com/magiconair/properties v1.8.7 // indirect
3739
github.com/mattn/go-isatty v0.0.19 // indirect
40+
github.com/mitchellh/mapstructure v1.5.0 // indirect
3841
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
3942
github.com/modern-go/reflect2 v1.0.2 // indirect
40-
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
41-
github.com/stretchr/testify v1.8.4 // indirect
43+
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
44+
github.com/sagikazarmark/locafero v0.4.0 // indirect
45+
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
46+
github.com/sourcegraph/conc v0.3.0 // indirect
47+
github.com/spf13/afero v1.11.0 // indirect
48+
github.com/spf13/cast v1.6.0 // indirect
49+
github.com/spf13/pflag v1.0.5 // indirect
50+
github.com/subosito/gotenv v1.6.0 // indirect
4251
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
4352
github.com/ugorji/go/codec v1.2.11 // indirect
53+
go.uber.org/atomic v1.9.0 // indirect
54+
go.uber.org/multierr v1.9.0 // indirect
4455
golang.org/x/arch v0.3.0 // indirect
45-
golang.org/x/net v0.18.0 // indirect
56+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
57+
golang.org/x/net v0.19.0 // indirect
4658
golang.org/x/sys v0.16.0 // indirect
4759
golang.org/x/text v0.14.0 // indirect
48-
google.golang.org/protobuf v1.30.0 // indirect
60+
google.golang.org/protobuf v1.31.0 // indirect
61+
gopkg.in/ini.v1 v1.67.0 // indirect
4962
gopkg.in/yaml.v2 v2.4.0 // indirect
5063
gopkg.in/yaml.v3 v3.0.1 // indirect
5164
)

0 commit comments

Comments
 (0)