Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Jul 26, 2019
1 parent 2ff84df commit e085023
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
7 changes: 3 additions & 4 deletions actors.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ func CollateralForPower(power BytesAmount) TokenAmount {
```sh
type SubmitPost struct {
proofs PoStProof
faults [FaultSet]
faults FaultSet
recovered Bitfield
done Bitfield
} representation tuple
Expand All @@ -661,7 +661,6 @@ func SubmitPost(proofs PoStProof, faults []FaultSet, recovered Bitfield, done Bi
// ensure recovered is a subset of the combined fault sets, and that done
// does not intersect with either, and that all sets only reference sectors
// that currently exist
allFaults = AggregateBitfields(faults)
if !miner.ValidateFaultSets(faults, recovered, done) {
Fatal("fault sets invalid")
}
Expand Down Expand Up @@ -694,7 +693,7 @@ func SubmitPost(proofs PoStProof, faults []FaultSet, recovered Bitfield, done Bi

// combine all the fault set bitfields, and subtract out the recovered
// ones to get the set of sectors permanently lost
permLostSet = allFaults.Subtract(recovered)
permLostSet = faults.Subtract(recovered)

// burn funds for fees and collateral penalization
self.BurnFunds(CollateralForSize(self.SectorSize*permLostSet.Size()) + feesRequired)
Expand All @@ -707,7 +706,7 @@ func SubmitPost(proofs PoStProof, faults []FaultSet, recovered Bitfield, done Bi
// the last proving period.
oldPower := miner.Power

miner.Power = (miner.ProvingSet.Size() - allFaults.Count()) * miner.SectorSize
miner.Power = (miner.ProvingSet.Size() - faults.Count()) * miner.SectorSize
StorageMarket.UpdateStorage(miner.Power - oldPower)

miner.ProvingSet = miner.Sectors
Expand Down
14 changes: 1 addition & 13 deletions mining.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,18 @@ TODO: sectors need to be globally unique. This can be done either by having the

#### Step 2: Proving Storage (PoSt creation)

At the beginning of their proving period, miners collect the proving set (the set of all live sealed sectors on the chain at this point), and then call `ProveStorage`. This process will take the entire proving period to complete.

```go
func ProveStorage(sectorSize BytesAmount, sectors []commR, startTime BlockHeight) (PoStProof, FaultSet) {
seed := GetRandFromBlock(startTime + POST_CHALLENGE_TIME)
GeneratePoSt(sectors, seed)
GeneratePoSt(sectorSize, sectors, seed)
}
```

Note: See ['Proof of Space Time'](proofs.md#proof-of-space-time) for more details.

The proving set remains consistent during the proving period. Any sectors added in the meantime will be included in the next proving set, at the beginning of the next proving period.

```go
// Verify a given PoSt.
func VerifyPost(sectorSize BytesAmount, sectors []commR, startTime BlockHeight, proof PoStProof, faults FaultSet) bool {
seed := GetRandFromBlock(startTime + POST_CHALLENGE_TIME)
challenges := DerivePoStChallenges(seed, faults)

// Verify Snark
VerifyPoStSnark(sectorSize, sectors, proof, faults, challenges)
}
```

#### Step 3: PoSt Submission

When the miner has completed their PoSt, they must submit it to the network by calling [SubmitPoSt](actors.md#submitpost). There are two different times that this *could* be done.
Expand Down
12 changes: 7 additions & 5 deletions proof-of-spacetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ TODO: Add post submission to the diagram.
#### Generation

```go
func GeneratePoSt(sectorSize BytesAmount, sectors []commR) (PoStProof, FaultSet) {
func GeneratePoSt(sectorSize BytesAmount, sectors []commR, seed []byte) (PoStProof, FaultSet) {
// Generate the Merkle Inclusion Proofs + Faults

inclusionProofs := []
challenges := []
faults := NewFaultSet()

for n in 0..POST_CHALLENGES_COUNT {
Expand All @@ -57,6 +58,7 @@ func GeneratePoSt(sectorSize BytesAmount, sectors []commR) (PoStProof, FaultSet)
continue
}

// Leaf index of the selected sector
challenge_value = challenge / sectorSize
inclusionProof, isFault := GenerateMerkleInclusionProof(sector, challenge_value)
if isFault {
Expand All @@ -66,13 +68,12 @@ func GeneratePoSt(sectorSize BytesAmount, sectors []commR) (PoStProof, FaultSet)
} else {
// no fault, move on to the next challenge
inclusionProofs[n] = inclusionProof
challenges[n] = challenge
}
}
}

// Generate the snark
challenges := DerivePoStChallenges(sectorSize, seed, faults)

snark_proof := GeneratePoStSnark(sectorSize, challenges, sectors, inclusionProofs)

proof := PoStProof {
Expand Down Expand Up @@ -131,10 +132,11 @@ func DerivePoStChallenges(sectorSize BytesAmount, seed []byte, faults FaultSet)
}

// Derive a single challenge for PoSt.
func DerivePoStChallenge(seed []byte, n Uint, attempt Uint) []byte {
func DerivePoStChallenge(seed []byte, n Uint, attempt Uint) Uint {
n_bytes := WriteUintToLittleEndian(n)
data := concat(seed, n_bytes, WriteUintToLittleEndian(attempt))
challenge := blake2b(data)
ReadUintLittleEndain(challenge)
}
```

Expand All @@ -154,7 +156,7 @@ func DerivePoStChallenge(seed []byte, n Uint, attempt Uint) []byte {

*Inputs that the prover uses to generate a SNARK proof and that the verifier uses to verify it*

- `CommRs: [POST_CHALLENGES_COUNT]Fr`: The Merkle tree root hashe of all CommRs
- `CommRs: [POST_CHALLENGES_COUNT]Fr`: The Merkle tree root hashes of all CommRs.
- `InclusionPaths: [POST_CHALLENGES_COUNT]Fr`: Inclusion paths for the replica leafs. (Binary packed bools)

{{% notice todo %}}
Expand Down

0 comments on commit e085023

Please sign in to comment.