Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

swarm/storage: Filehasher prototypes #969

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ffd7ff8
swarm/storage: filehasher = chunker spit + swarm hash
zelig Jul 12, 2018
5c02b35
chunkhasherstore
zelig Jul 13, 2018
66d7071
swarm/storage: WIP Create splitter test for FileHasher
nolash Jul 16, 2018
b23cbca
swarm/storage: Refactor with read direct into node buffer
nolash Jul 25, 2018
b79bc23
swarm/storage: Add GetBuffer test, level 0 add on fh init
nolash Aug 2, 2018
e73f7cc
swarm/storage: Use and wrap bmt.SectionWriter for use in filehasher
nolash Aug 8, 2018
20a7ae9
swarm/storage: Make Filehasher TestSum pass on complete batch
nolash Aug 8, 2018
02e5b86
swarm/storage: Remove race condition in nodebuffer
nolash Aug 22, 2018
81403c6
swarm/storage: Hashing completes with both 1 and 2 batches
nolash Aug 31, 2018
d559e3c
swarm/storage: Filehasher < 1 * batch correct
nolash Sep 7, 2018
deaac9b
swarm/storage: Passes sum test
nolash Sep 7, 2018
fe6adde
swarm/storage: Filehasher pass with 4096 * (128^2)
nolash Sep 7, 2018
9050bc7
swarm/storage: Possible pyramid fail on chunk*129
nolash Sep 11, 2018
be400d7
swarm/storage: Fix async issue causing different parents for same batch
nolash Sep 12, 2018
8d08b1f
swarm/storage: WIP reference filehasher
nolash Sep 12, 2018
a55d5e8
swarm/storage: Proof of bug in Tree/Pyramid for dangling chunks
nolash Sep 17, 2018
e044164
swarm/storage: Add missing filehasher ref src file
nolash Sep 18, 2018
75ff817
swarm/storage: Correct referencehasher
nolash Sep 20, 2018
a862773
swarm/storage: Clean up logging and add comments
nolash Sep 20, 2018
d655184
swarm/storage: Add alt filehasher impl, ok up to chunk boundary
nolash Sep 27, 2018
4fa31dc
swarm/storage: Correct parent offset calculation
nolash Sep 27, 2018
83b3bb5
swarm/storage: Clean up filehasher test
nolash Sep 27, 2018
fefa180
swarm/storage: Correct on dangling chunk
nolash Sep 27, 2018
b229c8c
swarm/storage: Add comments on altfilehasher
nolash Sep 28, 2018
d10a5e2
swarm/storage: WIP Extend filehasher level buffer to batch size
nolash Oct 14, 2018
2d7a24d
swarm/storage: WIP Correct but hangs
nolash Oct 18, 2018
4f49a03
swarm/storage: Resolve hang
nolash Oct 20, 2018
4759c5c
swarm/storage: Reinstate testdata gens after filehasher rebase
nolash Oct 20, 2018
99142ea
WIP Benchmark file hashers
nolash Oct 23, 2018
25da853
swarm/storage: WIP fix missed dangling hang, but hang on *2/*128+n/*1…
nolash Oct 23, 2018
010cbcc
swarm/storage: WIP pass all tests but altfilehasher sometimes hangs i…
nolash Oct 26, 2018
0b484f4
swarm/storage: Add ReferenceFileHasher benchmark (unnecessary, but ni…
nolash Oct 26, 2018
466ed06
swarm/storage: Resolve hang in AltFileHasher hashing
nolash Mar 7, 2019
596dc4a
swarm/storage: Prune redundant locks
nolash Mar 7, 2019
1eef2a9
swarm/storage: Remove more redundant locks
nolash Mar 8, 2019
55b331c
swarm/storage: WIP hashpool level chan buffer refactor
nolash Mar 9, 2019
07e9efd
swarm/storage: WIP levelWriteC hang on last
nolash Mar 10, 2019
728cc25
swarm/storage: Removed hang up to 4159 bytes
nolash Mar 10, 2019
535365e
swarm/storage: Remove commented code
nolash Mar 10, 2019
48c0c3e
swarm/storage: Fixed all hangs, dangle broken
nolash Mar 10, 2019
1125d16
swarm/storage: Improved trigger propagation
nolash Mar 11, 2019
9fc98db
swarm/storage: Remove redundant log, avoid reset on cancel
nolash Mar 11, 2019
fdb12d9
swarm/storage: Add pyramid hasher compare test
nolash Mar 12, 2019
1aa3c0f
swarm/storage: WIP set up chained writer prototypes
nolash Mar 14, 2019
3a28588
swarm/storage: WIP writethrough implemented
nolash Mar 14, 2019
53bd95d
swarm/storage: WIP disappointing benchmarks
nolash Mar 14, 2019
25e0d41
swarm/storage: WIP better benchmark but far off and hashes wrong
nolash Mar 14, 2019
2bd2b8d
swarm/storage: WIP add missing third attempt file, still disappointed
nolash Mar 15, 2019
10c9e97
swarm/storage: WIP Add comments
nolash Mar 15, 2019
2c0e5d4
swarm/storage: Factor sum to separate function, added write debugs
nolash Mar 15, 2019
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
1 change: 1 addition & 0 deletions cmd/swarm/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var listCommand = cli.Command{
}

func list(ctx *cli.Context) {
fmt.Println("foo\n", ctx.GlobalString("password"))
args := ctx.Args()

if len(args) < 1 {
Expand Down
9 changes: 9 additions & 0 deletions swarm/bmt/bmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,23 @@ import (
"fmt"
"io"
"math/rand"
"os"
"sync"
"sync/atomic"
"testing"
"time"

"github.com/ethereum/go-ethereum/crypto/sha3"
"github.com/ethereum/go-ethereum/log"
)

func init() {
hs := log.StreamHandler(os.Stderr, log.TerminalFormat(true))
hf := log.LvlFilterHandler(1, hs)
h := log.CallerFileHandler(hf)
log.Root().SetHandler(h)
}

// the actual data length generated (could be longer than max datalength of the BMT)
const BufferSize = 4128

Expand Down
3 changes: 2 additions & 1 deletion swarm/storage/chunker.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ func (tc *TreeChunker) split(ctx context.Context, depth int, treeSize int64, add
// dept > 0
// intermediate chunk containing child nodes hashes
branchCnt := (size + treeSize - 1) / treeSize

var chunk = make([]byte, branchCnt*tc.hashSize+8)
var pos, i int64

Expand Down Expand Up @@ -336,6 +335,8 @@ func (tc *TreeChunker) split(ctx context.Context, depth int, treeSize int64, add
case tc.jobC <- &hashJob{addr, chunk, size, parentWg}:
case <-tc.quitC:
}

log.Trace("chunkdata", "d", chunk)
}

func (tc *TreeChunker) runWorker(ctx context.Context) {
Expand Down
50 changes: 50 additions & 0 deletions swarm/storage/chunker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,41 @@ func testRandomBrokenData(n int, tester *chunkerTester) {
tester.t.Logf(" Address = %v\n", key)
}

func testSerialData(usePyramid bool, hash string, n int, tester *chunkerTester) Address {
if tester.inputs == nil {
tester.inputs = make(map[uint64][]byte)
}
input, found := tester.inputs[uint64(n)]
var data io.Reader
if !found {
data, input = generateSerialData(n, 255, 0)
tester.inputs[uint64(n)] = input
} else {
data = io.LimitReader(bytes.NewReader(input), int64(n))
}

putGetter := newTestHasherStore(NewMapChunkStore(), hash)

var addr Address
var wait func(context.Context) error
var err error
ctx := context.TODO()
if usePyramid {
addr, wait, err = PyramidSplit(ctx, data, putGetter, putGetter)
} else {
addr, wait, err = TreeSplit(ctx, data, int64(n), putGetter)
}
if err != nil {
tester.t.Fatalf(err.Error())
}
tester.t.Logf(" Key = %v\n", addr)
err = wait(ctx)
if err != nil {
tester.t.Fatalf(err.Error())
}
return addr
}

func testRandomData(usePyramid bool, hash string, n int, tester *chunkerTester) Address {
if tester.inputs == nil {
tester.inputs = make(map[uint64][]byte)
Expand Down Expand Up @@ -229,6 +264,21 @@ func TestDataAppend(t *testing.T) {
}
}

func TestSerialData(t *testing.T) {
sizes := []int{4096 * 129}
tester := &chunkerTester{t: t}

for _, s := range sizes {
treeChunkerKey := testSerialData(false, BMTHash, s, tester)
// pyramidChunkerKey := testRandomData(true, SHA3Hash, s, tester)
// if treeChunkerKey.String() != pyramidChunkerKey.String() {
// tester.t.Fatalf("tree chunker and pyramid chunker key mismatch for size %v\n TC: %v\n PC: %v\n", s, treeChunkerKey.String(), pyramidChunkerKey.String())
// }
t.Logf("chunker result: %s", treeChunkerKey)
}

}

func TestRandomData(t *testing.T) {
// This test can validate files up to a relatively short length, as tree chunker slows down drastically.
// Validation of longer files is done by TestLocalStoreAndRetrieve in swarm package.
Expand Down
18 changes: 18 additions & 0 deletions swarm/storage/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,24 @@ func mget(store ChunkStore, hs []Address, f func(h Address, chunk Chunk) error)
return err
}

func generateRandomData(l int) (r io.Reader, slice []byte) {
slice = make([]byte, l)
if _, err := rand.Read(slice); err != nil {
panic("rand error")
}
r = io.LimitReader(bytes.NewReader(slice), int64(l))
return
}

func generateSerialData(l int, mod int, offset int) (r io.Reader, slice []byte) {
slice = make([]byte, l)
for i := 0; i < len(slice); i++ {
slice[i] = byte((i + offset) % mod)
}
r = io.LimitReader(bytes.NewReader(slice), int64(l))
return
}

func testDataReader(l int) (r io.Reader) {
return io.LimitReader(rand.Reader, int64(l))
}
Expand Down
Loading