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

WIP: Pollard hashes up to populated nodes, not all the way to roots #226

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
03a1fb9
slim down tests
adiabat Nov 14, 2020
8b90d15
replace [3]node with miniTree
adiabat Nov 14, 2020
9b9db11
make verifyBatchProof() a method on Pollard
adiabat Nov 14, 2020
9861d9f
have verifyBatchProof() do it's own reading from the pollard,
adiabat Nov 14, 2020
0e278da
slight changes to formatting and comments
adiabat Nov 14, 2020
3db1d2f
change datadir path (specifies blocks, not bitcoin dir)
adiabat Dec 18, 2020
bb24cfd
remove some unused functions; revert proofs to still include target h…
adiabat Dec 20, 2020
0835f18
structure of compact serialization / deserialization for ublocks
adiabat Dec 21, 2020
e0261ea
add functions for recovering leaf data from block data
adiabat Dec 21, 2020
d2b99ee
compact deserialization needs skiplists, so pass those along
adiabat Dec 22, 2020
af86dc0
obvious fix in UData SerializeCompactSize()
adiabat Dec 22, 2020
f24feb2
compact serialization doesn't crash; but reconstruct wants target hashes
adiabat Dec 22, 2020
611dfee
remove computablePositions from ProofPositions() functions
adiabat Jan 2, 2021
05f9171
compiles / fits but proof hashes don't match up
adiabat Jan 2, 2021
1ffe55a
remove stateless reconstruct / verify of block proofs
adiabat Jan 2, 2021
0fa6964
remove redundant functions from pollard
adiabat Jan 3, 2021
9678cf6
get rid of pollard full
adiabat Jan 3, 2021
72fe405
add comments about changes to IngestBatchProof()
adiabat Jan 4, 2021
8bb472d
add better printfs for debugging
adiabat Jan 29, 2021
248d86b
make tests compile (they don't pass)
adiabat Jan 29, 2021
4739809
aha the test is now wrong
adiabat Jan 29, 2021
939f692
start rewrite of ingest
adiabat Jan 30, 2021
337c75a
building ingestAndCheck but need to change grabPos
adiabat Jan 30, 2021
a015047
revert grabPos, new function to build 2d slice like ProofPositions bu…
adiabat Jan 30, 2021
2e152f4
add notes
adiabat Feb 1, 2021
86c7ad0
more notes on ways to change blockproofs
adiabat Apr 16, 2021
a4b40e6
add proofPositions2
adiabat Apr 17, 2021
4f64761
add notes about hashing to known
adiabat Apr 20, 2021
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
24 changes: 14 additions & 10 deletions bridgenode/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,11 @@ func Parse(args []string) (*Config, error) {
cfg := Config{}

var dataDir string

// set dataDir
if *dataDirCmd == "" { // No custom datadir given by the user
dataDir = btcutil.AppDataDir("bitcoin", true)
} else {
dataDir = *dataDirCmd // set dataDir to the one set by the user
cfg.blockDir = *dataDirCmd // use user sepcified as the full blockdir
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want this to point to the dataDir?
We know where the blocks are if get the datadir and the network type.

}

var bridgeDir string
Expand All @@ -216,26 +215,31 @@ func Parse(args []string) (*Config, error) {
// set network
if *netCmd == "testnet" {
cfg.params = chaincfg.TestNet3Params
cfg.blockDir = filepath.Join(
filepath.Join(dataDir, chaincfg.TestNet3Params.Name),
"blocks")
if *dataDirCmd == "" {
cfg.blockDir = filepath.Join(
filepath.Join(dataDir, chaincfg.TestNet3Params.Name),
"blocks")
}
base := filepath.Join(bridgeDir, chaincfg.TestNet3Params.Name)
cfg.utreeDir = initUtreeDir(base)
} else if *netCmd == "regtest" {
cfg.params = chaincfg.RegressionNetParams
cfg.blockDir = filepath.Join(
filepath.Join(dataDir, chaincfg.RegressionNetParams.Name),
"blocks")
if *dataDirCmd == "" {
cfg.blockDir = filepath.Join(
filepath.Join(dataDir, chaincfg.RegressionNetParams.Name),
"blocks")
}
base := filepath.Join(bridgeDir, chaincfg.RegressionNetParams.Name)
cfg.utreeDir = initUtreeDir(base)
} else if *netCmd == "mainnet" {
cfg.params = chaincfg.MainNetParams
cfg.blockDir = filepath.Join(dataDir, "blocks")
if *dataDirCmd == "" {
cfg.blockDir = filepath.Join(dataDir, "blocks")
}
cfg.utreeDir = initUtreeDir(bridgeDir)
} else {
return nil, errInvalidNetwork(*netCmd)
}

makePaths(cfg.utreeDir)

// set profiling
Expand Down
8 changes: 4 additions & 4 deletions bridgenode/genproofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func BuildProofs(cfg *Config, sig chan bool) error {
forest, height, knownTipHeight, err :=
initBridgeNodeState(cfg, offsetFinished)
if err != nil {
fmt.Printf("initialization error. If your .blk and .dat files are ")
fmt.Printf("not in %s, specify alternate path with -datadir\n.", cfg.blockDir)
fmt.Printf("Can't read blocks in %s ; ", cfg.blockDir)
fmt.Printf("specify path with -datadir\n")
return err
}

Expand All @@ -74,8 +74,8 @@ func BuildProofs(cfg *Config, sig chan bool) error {
}
lvdb, err := leveldb.OpenFile(cfg.utreeDir.ttldb, &o)
if err != nil {
fmt.Printf("initialization error. If your .blk and .dat files are ")
fmt.Printf("not in %s, specify alternate path with -datadir\n.", cfg.blockDir)
fmt.Printf("Can't read blocks in %s ; ", cfg.blockDir)
fmt.Printf("specify path with -datadir\n")
return err
}
defer lvdb.Close()
Expand Down
7 changes: 5 additions & 2 deletions bridgenode/initrestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (
// initBridgeNodeState attempts to load and initialize the chain state from the disk.
// If a chain state is not present, chain is initialized to the genesis
// returns forest, height, lastIndexOffsetHeight, pOffset and error
func initBridgeNodeState(cfg *Config, offsetFinished chan bool) (forest *accumulator.Forest,
func initBridgeNodeState(
cfg *Config, offsetFinished chan bool) (forest *accumulator.Forest,
height int32, knownTipHeight int32, err error) {

// Default behavior is that the user should delete all offsetdata
Expand All @@ -24,7 +25,9 @@ func initBridgeNodeState(cfg *Config, offsetFinished chan bool) (forest *accumul
// anew
// Check if the offsetfiles for both rev*.dat and blk*.dat are present
if util.HasAccess(cfg.utreeDir.offsetDir.offsetFile) {
knownTipHeight, err = restoreLastIndexOffsetHeight(cfg.utreeDir.offsetDir, offsetFinished)
fmt.Printf("has access to %s\n", cfg.utreeDir.offsetDir.offsetFile)
knownTipHeight, err =
restoreLastIndexOffsetHeight(cfg.utreeDir.offsetDir, offsetFinished)
if err != nil {
err = fmt.Errorf("restoreLastIndexOffsetHeight error: %s", err.Error())
return
Expand Down