-
Notifications
You must be signed in to change notification settings - Fork 340
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
feat(ph4): inclusion proofs #4059
Conversation
10f9644
to
0a492d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also be good to include a meaningful description of all public structures/functions/methods/types...
0bfbdff
to
d7c93a7
Compare
e012d95
to
54d8bdf
Compare
ffde79e
to
94f2d3f
Compare
ec22e42
to
b14e017
Compare
dc4f540
to
03cf689
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs serious redesign.
Also note. The proofs do not seems to allow proving the virtual 0-s, so bmt package needs update and test short chunks with out of range segment proofs
if err != nil { | ||
a.logger.Info("failed getting anchor after second reveal", "err", err) | ||
} else { | ||
sample.Anchor2 = anchor2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anchor 2 cannot be known at this point
return fmt.Errorf("sample not found") | ||
} | ||
|
||
proofs, err := makeInclusionProofs(sampleData.ReserveSampleItems, sampleData.Anchor1, sampleData.Anchor2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here sampleData.Anchor2 cannot be taken as it was set in reveal
proof creation needds to be delayed to claim phase
only then the reveal anchor (for seed determmines tuth selection and winner selectoin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the claim period is long and doing the computation of the proofs is fast compare to the witness filtering.
Nevertheless, the anchor should be available for the witness proofs after the first reveal on the SC API.
|
||
return true, nil | ||
} | ||
|
||
func (a *Agent) makeSample(ctx context.Context, storageRadius uint8) (SampleData, error) { | ||
salt, err := a.contract.ReserveSalt(ctx) | ||
anchor, err := a.contract.ReserveSalt(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is salt not good?
} | ||
|
||
func (a *Agent) SampleWithProofs( | ||
ctx context.Context, | ||
anchor1 []byte, | ||
anchor2 []byte, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
who sets this ad when?
return SampleWithProofs{}, fmt.Errorf("sample hash: %w", err) | ||
} | ||
|
||
proofs, err := makeInclusionProofs(rSample.Items, anchor1, anchor2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surely impossible to know here
for i := 0; i < workers; i++ { | ||
g.Go(func() error { | ||
wstat := SampleStats{} | ||
hasher := bmt.NewTrHasher(anchor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for each routine you can get a tr hasher and defer put back to pool.
hasher := bmt.NewTrHasher(anchor) | ||
|
||
items := make([]SampleItem, len(chunks)) | ||
for i, ch := range chunks { | ||
tr, err := transformedAddress(hasher, ch, swarm.ChunkTypeContentAddressed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the sample should remember the chunk and the transformed address. no need to calculate it again.
} | ||
|
||
// MakeSampleUsingChunks returns Sample constructed using supplied chunks. | ||
func MakeSampleUsingChunks(chunks []swarm.Chunk, anchor []byte) (Sample, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not needed the iterator should just create a SampleItem
which should be just
struct {
transformedAddress
chunk
}
@@ -17,41 +16,62 @@ import ( | |||
"time" | |||
|
|||
"github.com/ethersphere/bee/pkg/bmt" | |||
"github.com/ethersphere/bee/pkg/cac" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this file under storer and not under storage incentives
hasher, trHasher := bmtpool.Get(), bmt.NewTrHasher(anchor1) | ||
defer bmtpool.Put(hasher) | ||
|
||
anchor2Big := new(big.Int).SetBytes(anchor2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so here you are using the wrong anchor
closing as this is taken care of in #4373 |
Checklist
Description
This PR implements inclusion proofs for claim method of phase 4 redistribution smart contract.
Note: in code there is
// TODO_PH4
which should be handled before PR is merged to master, please go through these markers in code and handle them accordingly.Closes: #3800