diff --git a/go.mod b/go.mod index 95539b3cbd6..9ca865cf074 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/coreos/go-semver v0.3.0 github.com/ethereum/go-ethereum v1.12.2 github.com/ethersphere/go-price-oracle-abi v0.1.0 - github.com/ethersphere/go-storage-incentives-abi v0.5.0 + github.com/ethersphere/go-storage-incentives-abi v0.6.0-rc3 github.com/ethersphere/go-sw3-abi v0.4.0 github.com/ethersphere/langos v1.0.0 github.com/go-playground/validator/v10 v10.11.1 diff --git a/go.sum b/go.sum index 0668711533d..8b98c44d2ed 100644 --- a/go.sum +++ b/go.sum @@ -223,8 +223,8 @@ github.com/ethereum/go-ethereum v1.12.2 h1:eGHJ4ij7oyVqUQn48LBz3B7pvQ8sV0wGJiIE6 github.com/ethereum/go-ethereum v1.12.2/go.mod h1:1cRAEV+rp/xX0zraSCBnu9Py3HQ+geRMj3HdR+k0wfI= github.com/ethersphere/go-price-oracle-abi v0.1.0 h1:yg/hK8nETNvk+GEBASlbakMFv/CVp7HXiycrHw1pRV8= github.com/ethersphere/go-price-oracle-abi v0.1.0/go.mod h1:sI/Qj4/zJ23/b1enzwMMv0/hLTpPNVNacEwCWjo6yBk= -github.com/ethersphere/go-storage-incentives-abi v0.5.0 h1:dd01OZmPraCjOIiSX5FsCfFFwUR2b9PuTO/LDcYxS+s= -github.com/ethersphere/go-storage-incentives-abi v0.5.0/go.mod h1:SXvJVtM4sEsaSKD0jc1ClpDLw8ErPoROZDme4Wrc/Nc= +github.com/ethersphere/go-storage-incentives-abi v0.6.0-rc3 h1:tXux2FnhuU6DbrY+Z4nVQMGp63JkJPq7pKb5Xi2Sjxo= +github.com/ethersphere/go-storage-incentives-abi v0.6.0-rc3/go.mod h1:SXvJVtM4sEsaSKD0jc1ClpDLw8ErPoROZDme4Wrc/Nc= github.com/ethersphere/go-sw3-abi v0.4.0 h1:T3ANY+ktWrPAwe2U0tZi+DILpkHzto5ym/XwV/Bbz8g= github.com/ethersphere/go-sw3-abi v0.4.0/go.mod h1:BmpsvJ8idQZdYEtWnvxA8POYQ8Rl/NhyCdF0zLMOOJU= github.com/ethersphere/langos v1.0.0 h1:NBtNKzXTTRSue95uOlzPN4py7Aofs0xWPzyj4AI1Vcc= diff --git a/pkg/api/api_test.go b/pkg/api/api_test.go index dd4eaabb25f..21e535f10ac 100644 --- a/pkg/api/api_test.go +++ b/pkg/api/api_test.go @@ -783,7 +783,7 @@ func (m *mockContract) Claim(context.Context, redistribution.ChunkInclusionProof return common.Hash{}, nil } -func (m *mockContract) Commit(context.Context, []byte, *big.Int) (common.Hash, error) { +func (m *mockContract) Commit(context.Context, []byte, uint32) (common.Hash, error) { m.mtx.Lock() defer m.mtx.Unlock() m.callsList = append(m.callsList, commitCall) diff --git a/pkg/api/rchash.go b/pkg/api/rchash.go index 702356d7331..ad7a25f9992 100644 --- a/pkg/api/rchash.go +++ b/pkg/api/rchash.go @@ -4,14 +4,106 @@ package api import ( + "encoding/hex" "net/http" + "strconv" + "time" + "github.com/ethereum/go-ethereum/common" "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/storageincentives" + "github.com/ethersphere/bee/pkg/storageincentives/redistribution" + "github.com/ethersphere/bee/pkg/swarm" "github.com/gorilla/mux" ) -type RCHashResponse storageincentives.SampleWithProofs +type RCHashResponse struct { + Hash swarm.Address `json:"hash"` + Proofs ChunkInclusionProofs `json:"proofs"` + Duration time.Duration `json:"duration"` +} + +type ChunkInclusionProofs struct { + A ChunkInclusionProof `json:"proof1"` + B ChunkInclusionProof `json:"proof2"` + C ChunkInclusionProof `json:"proofLast"` +} + +// ChunkInclusionProof structure must exactly match +// corresponding structure (of the same name) in Redistribution.sol smart contract. +// github.com/ethersphere/storage-incentives/blob/ph_f2/src/Redistribution.sol +// github.com/ethersphere/storage-incentives/blob/master/src/Redistribution.sol (when merged to master) +type ChunkInclusionProof struct { + ProofSegments []string `json:"proofSegments"` + ProveSegment string `json:"proveSegment"` + ProofSegments2 []string `json:"proofSegments2"` + ProveSegment2 string `json:"proveSegment2"` + ChunkSpan uint64 `json:"chunkSpan"` + ProofSegments3 []string `json:"proofSegments3"` + PostageProof PostageProof `json:"postageProof"` + SocProof []SOCProof `json:"socProof"` +} + +// SOCProof structure must exactly match +// corresponding structure (of the same name) in Redistribution.sol smart contract. +type PostageProof struct { + Signature string `json:"signature"` + PostageId string `json:"postageId"` + Index string `json:"index"` + TimeStamp string `json:"timeStamp"` +} + +// SOCProof structure must exactly match +// corresponding structure (of the same name) in Redistribution.sol smart contract. +type SOCProof struct { + Signer string `json:"signer"` + Signature string `json:"signature"` + Identifier string `json:"identifier"` + ChunkAddr string `json:"chunkAddr"` +} + +func renderChunkInclusionProofs(proofs redistribution.ChunkInclusionProofs) ChunkInclusionProofs { + return ChunkInclusionProofs{ + A: renderChunkInclusionProof(proofs.A), + B: renderChunkInclusionProof(proofs.B), + C: renderChunkInclusionProof(proofs.C), + } +} + +func renderChunkInclusionProof(proof redistribution.ChunkInclusionProof) ChunkInclusionProof { + var socProof []SOCProof + if len(proof.SocProof) == 1 { + socProof = []SOCProof{{ + Signer: hex.EncodeToString(proof.SocProof[0].Signer.Bytes()), + Signature: hex.EncodeToString(proof.SocProof[0].Signature[:]), + Identifier: hex.EncodeToString(proof.SocProof[0].Identifier.Bytes()), + ChunkAddr: hex.EncodeToString(proof.SocProof[0].ChunkAddr.Bytes()), + }} + } + + return ChunkInclusionProof{ + ProveSegment: hex.EncodeToString(proof.ProveSegment.Bytes()), + ProofSegments: renderCommonHash(proof.ProofSegments), + ProveSegment2: hex.EncodeToString(proof.ProveSegment2.Bytes()), + ProofSegments2: renderCommonHash(proof.ProofSegments2), + ProofSegments3: renderCommonHash(proof.ProofSegments3), + ChunkSpan: proof.ChunkSpan, + PostageProof: PostageProof{ + Signature: hex.EncodeToString(proof.PostageProof.Signature[:]), + PostageId: hex.EncodeToString(proof.PostageProof.PostageId[:]), + Index: strconv.FormatUint(proof.PostageProof.Index, 16), + TimeStamp: strconv.FormatUint(proof.PostageProof.TimeStamp, 16), + }, + SocProof: socProof, + } +} + +func renderCommonHash(proofSegments []common.Hash) []string { + output := make([]string, len(proofSegments)) + for i, s := range proofSegments { + output[i] = hex.EncodeToString(s.Bytes()) + } + return output +} // This API is kept for testing the sampler. As a result, no documentation or tests are added here. func (s *Service) rchash(w http.ResponseWriter, r *http.Request) { @@ -31,12 +123,18 @@ func (s *Service) rchash(w http.ResponseWriter, r *http.Request) { anchor2 := []byte(paths.Anchor2) - resp, err := s.redistributionAgent.SampleWithProofs(r.Context(), anchor1, anchor2, paths.Depth) + swp, err := s.redistributionAgent.SampleWithProofs(r.Context(), anchor1, anchor2, paths.Depth) if err != nil { logger.Error(err, "failed making sample with proofs") jsonhttp.InternalServerError(w, "failed making sample with proofs") return } - jsonhttp.OK(w, RCHashResponse(resp)) + resp := RCHashResponse{ + Hash: swp.Hash, + Duration: swp.Duration, + Proofs: renderChunkInclusionProofs(swp.Proofs), + } + + jsonhttp.OK(w, resp) } diff --git a/pkg/config/chain.go b/pkg/config/chain.go index 2fd2e6f8fe7..4d7fd19e419 100644 --- a/pkg/config/chain.go +++ b/pkg/config/chain.go @@ -42,7 +42,7 @@ var ( SwarmTokenSymbol: "gBZZ", StakingAddress: common.HexToAddress(abi.TestnetStakingAddress), - PostageStampAddress: common.HexToAddress(abi.TestnetPostageStampStampAddress), + PostageStampAddress: common.HexToAddress(abi.TestnetPostageStampAddress), RedistributionAddress: common.HexToAddress(abi.TestnetRedistributionAddress), SwapPriceOracleAddress: common.HexToAddress("0x0c9de531dcb38b758fe8a2c163444a5e54ee0db2"), CurrentFactoryAddress: common.HexToAddress("0x73c412512E1cA0be3b89b77aB3466dA6A1B9d273"), @@ -51,7 +51,7 @@ var ( }, StakingABI: abi.TestnetStakingABI, - PostageStampABI: abi.TestnetPostageStampStampABI, + PostageStampABI: abi.TestnetPostageStampABI, RedistributionABI: abi.TestnetRedistributionABI, } @@ -84,7 +84,7 @@ func GetByChainID(chainID int64) (ChainConfig, bool) { NativeTokenSymbol: Testnet.NativeTokenSymbol, SwarmTokenSymbol: Testnet.SwarmTokenSymbol, StakingABI: abi.TestnetStakingABI, - PostageStampABI: abi.TestnetPostageStampStampABI, + PostageStampABI: abi.TestnetPostageStampABI, RedistributionABI: abi.TestnetRedistributionABI, }, false } diff --git a/pkg/storageincentives/agent.go b/pkg/storageincentives/agent.go index 68c2b526ec7..ee12c11fab7 100644 --- a/pkg/storageincentives/agent.go +++ b/pkg/storageincentives/agent.go @@ -510,7 +510,7 @@ func (a *Agent) commit(ctx context.Context, sample SampleData, round uint64) err return err } - txHash, err := a.contract.Commit(ctx, obfuscatedHash, big.NewInt(int64(round))) + txHash, err := a.contract.Commit(ctx, obfuscatedHash, uint32(round)) if err != nil { a.metrics.ErrCommit.Inc() return err diff --git a/pkg/storageincentives/agent_test.go b/pkg/storageincentives/agent_test.go index 58a06eaf6eb..70ec3193975 100644 --- a/pkg/storageincentives/agent_test.go +++ b/pkg/storageincentives/agent_test.go @@ -283,7 +283,7 @@ func (m *mockContract) Claim(context.Context, redistribution.ChunkInclusionProof return common.Hash{}, nil } -func (m *mockContract) Commit(context.Context, []byte, *big.Int) (common.Hash, error) { +func (m *mockContract) Commit(context.Context, []byte, uint32) (common.Hash, error) { m.mtx.Lock() defer m.mtx.Unlock() m.callsList = append(m.callsList, commitCall) diff --git a/pkg/storageincentives/proof.go b/pkg/storageincentives/proof.go index e1c84710831..ccc04cd935b 100644 --- a/pkg/storageincentives/proof.go +++ b/pkg/storageincentives/proof.go @@ -55,7 +55,6 @@ func makeInclusionProofs( require2++ } - // TODO: refactor, make it global / anchor (cleanup?) prefixHasherFactory := func() hash.Hash { return swarm.NewPrefixHasher(anchor1) } diff --git a/pkg/storageincentives/proof_test.go b/pkg/storageincentives/proof_test.go index 655582953e9..9ee3745e1af 100644 --- a/pkg/storageincentives/proof_test.go +++ b/pkg/storageincentives/proof_test.go @@ -6,10 +6,10 @@ package storageincentives_test import ( "bytes" + _ "embed" "encoding/json" "fmt" "math/big" - "os" "testing" "github.com/ethersphere/bee/pkg/cac" @@ -38,6 +38,9 @@ func TestMakeInclusionProofs(t *testing.T) { } } +//go:embed testdata/inclusion-proofs.json +var testData []byte + // Test asserts that MakeInclusionProofs will generate the same // output for given sample. func TestMakeInclusionProofsRegression(t *testing.T) { @@ -111,10 +114,12 @@ func TestMakeInclusionProofsRegression(t *testing.T) { t.Fatal(err) } - expectedProofs := redistribution.ChunkInclusionProofs{} + var expectedProofs redistribution.ChunkInclusionProofs - data, _ := os.ReadFile("testdata/inclusion-proofs.json") - _ = json.Unmarshal(data, &expectedProofs) + err = json.Unmarshal(testData, &expectedProofs) + if err != nil { + t.Fatal(err) + } if diff := cmp.Diff(proofs, expectedProofs); diff != "" { t.Fatalf("unexpected inclusion proofs (-want +have):\n%s", diff) diff --git a/pkg/storageincentives/redistribution/inclusionproof.go b/pkg/storageincentives/redistribution/inclusionproof.go index b38c82e56fe..d2e6946ed92 100644 --- a/pkg/storageincentives/redistribution/inclusionproof.go +++ b/pkg/storageincentives/redistribution/inclusionproof.go @@ -6,8 +6,8 @@ package redistribution import ( "encoding/binary" - "encoding/hex" + "github.com/ethereum/go-ethereum/common" "github.com/ethersphere/bee/pkg/bmt" "github.com/ethersphere/bee/pkg/soc" "github.com/ethersphere/bee/pkg/storer" @@ -25,96 +25,81 @@ type ChunkInclusionProofs struct { // github.com/ethersphere/storage-incentives/blob/ph_f2/src/Redistribution.sol // github.com/ethersphere/storage-incentives/blob/master/src/Redistribution.sol (when merged to master) type ChunkInclusionProof struct { - ProofSegments []string `json:"proofSegments"` - ProveSegment string `json:"proveSegment"` - ProofSegments2 []string `json:"proofSegments2"` - ProveSegment2 string `json:"proveSegment2"` - ChunkSpan uint64 `json:"chunkSpan"` - ProofSegments3 []string `json:"proofSegments3"` - PostageProof PostageProof `json:"postageProof"` - SocProof []SOCProof `json:"socProof"` + ProofSegments []common.Hash `json:"proofSegments"` + ProveSegment common.Hash `json:"proveSegment"` + ProofSegments2 []common.Hash `json:"proofSegments2"` + ProveSegment2 common.Hash `json:"proveSegment2"` + ChunkSpan uint64 `json:"chunkSpan"` + ProofSegments3 []common.Hash `json:"proofSegments3"` + PostageProof PostageProof `json:"postageProof"` + SocProof []SOCProof `json:"socProof"` } // SOCProof structure must exactly match // corresponding structure (of the same name) in Redistribution.sol smart contract. type PostageProof struct { - Signature string `json:"signature"` - PostageId string `json:"postageId"` - Index string `json:"index"` - TimeStamp string `json:"timeStamp"` + Signature []byte `json:"signature"` + PostageId common.Hash `json:"postageId"` + Index uint64 `json:"index"` + TimeStamp uint64 `json:"timeStamp"` } // SOCProof structure must exactly match // corresponding structure (of the same name) in Redistribution.sol smart contract. type SOCProof struct { - Signer string `json:"signer"` - Signature string `json:"signature"` - Identifier string `json:"identifier"` - ChunkAddr string `json:"chunkAddr"` + Signer common.Address `json:"signer"` + Signature []byte `json:"signature"` + Identifier common.Hash `json:"identifier"` + ChunkAddr common.Hash `json:"chunkAddr"` } -// NewChunkInclusionProof transforms arguments to ChunkInclusionProof object -func NewChunkInclusionProof(proofp1, proofp2, proofp3 bmt.Proof, sampleItem storer.SampleItem) (ChunkInclusionProof, error) { - proofp1Hex := newHexProofs(proofp1) - proofp2Hex := newHexProofs(proofp2) - proofp3Hex := newHexProofs(proofp3) - +// Transforms arguments to ChunkInclusionProof object +func NewChunkInclusionProof(proofp1, proofp2 bmt.Proof, proofp3 bmt.Proof, sampleItem storer.SampleItem) (ChunkInclusionProof, error) { socProof, err := makeSOCProof(sampleItem) if err != nil { return ChunkInclusionProof{}, err } return ChunkInclusionProof{ - ProofSegments: proofp1Hex.ProofSegments, - ProveSegment: proofp1Hex.ProveSegment, - ProofSegments2: proofp2Hex.ProofSegments, - ProveSegment2: proofp2Hex.ProveSegment, + ProofSegments: toCommonHash(proofp1.ProofSegments), + ProveSegment: common.BytesToHash(proofp1.ProveSegment), + ProofSegments2: toCommonHash(proofp2.ProofSegments), + ProveSegment2: common.BytesToHash(proofp2.ProveSegment), ChunkSpan: binary.LittleEndian.Uint64(proofp2.Span[:swarm.SpanSize]), // should be uint64 on the other size; copied from pkg/api/bytes.go - ProofSegments3: proofp3Hex.ProofSegments, + ProofSegments3: toCommonHash(proofp3.ProofSegments), PostageProof: PostageProof{ - Signature: hex.EncodeToString(sampleItem.Stamp.Sig()), - PostageId: hex.EncodeToString(sampleItem.Stamp.BatchID()), - Index: hex.EncodeToString(sampleItem.Stamp.Index()), - TimeStamp: hex.EncodeToString(sampleItem.Stamp.Timestamp()), + Signature: sampleItem.Stamp.Sig(), + PostageId: common.BytesToHash(sampleItem.Stamp.BatchID()), + Index: binary.BigEndian.Uint64(sampleItem.Stamp.Index()), + TimeStamp: binary.BigEndian.Uint64(sampleItem.Stamp.Timestamp()), }, SocProof: socProof, }, nil } +func toCommonHash(hashes [][]byte) []common.Hash { + output := make([]common.Hash, len(hashes)) + for i, s := range hashes { + output[i] = common.BytesToHash(s) + } + return output +} + func makeSOCProof(sampleItem storer.SampleItem) ([]SOCProof, error) { - var emptySOCProof = make([]SOCProof, 0) ch := swarm.NewChunk(sampleItem.ChunkAddress, sampleItem.ChunkData) if !soc.Valid(ch) { - return emptySOCProof, nil + return []SOCProof{}, nil } socCh, err := soc.FromChunk(ch) if err != nil { - return emptySOCProof, err + return []SOCProof{}, err } return []SOCProof{{ - Signer: hex.EncodeToString(socCh.OwnerAddress()), - Signature: hex.EncodeToString(socCh.Signature()), - Identifier: hex.EncodeToString(socCh.ID()), - ChunkAddr: hex.EncodeToString(socCh.WrappedChunk().Address().Bytes()), + Signer: common.BytesToAddress(socCh.OwnerAddress()), + Signature: socCh.Signature(), + Identifier: common.BytesToHash(socCh.ID()), + ChunkAddr: common.BytesToHash(socCh.WrappedChunk().Address().Bytes()), }}, nil } - -type hexProof struct { - ProofSegments []string - ProveSegment string -} - -// newHexProofs transforms proof object to its hexadecimal representation -func newHexProofs(proof bmt.Proof) hexProof { - proofSegments := make([]string, len(proof.ProofSegments)) - for i := 0; i < len(proof.ProofSegments); i++ { - proofSegments[i] = hex.EncodeToString(proof.ProofSegments[i]) - } - - return hexProof{ - ProveSegment: hex.EncodeToString(proof.ProveSegment), - ProofSegments: proofSegments, - } -} diff --git a/pkg/storageincentives/redistribution/redistribution.go b/pkg/storageincentives/redistribution/redistribution.go index aecc47d1dec..2c163f5a76c 100644 --- a/pkg/storageincentives/redistribution/redistribution.go +++ b/pkg/storageincentives/redistribution/redistribution.go @@ -24,7 +24,7 @@ type Contract interface { IsPlaying(context.Context, uint8) (bool, error) IsWinner(context.Context) (bool, error) Claim(context.Context, ChunkInclusionProofs) (common.Hash, error) - Commit(context.Context, []byte, *big.Int) (common.Hash, error) + Commit(context.Context, []byte, uint32) (common.Hash, error) Reveal(context.Context, uint8, []byte, []byte) (common.Hash, error) } @@ -115,7 +115,7 @@ func (c *contract) Claim(ctx context.Context, proofs ChunkInclusionProofs) (comm } // Commit submits the obfusHash hash by sending a transaction to the blockchain. -func (c *contract) Commit(ctx context.Context, obfusHash []byte, round *big.Int) (common.Hash, error) { +func (c *contract) Commit(ctx context.Context, obfusHash []byte, round uint32) (common.Hash, error) { callData, err := c.incentivesContractABI.Pack("commit", common.BytesToHash(obfusHash), common.BytesToHash(c.overlay.Bytes()), round) if err != nil { return common.Hash{}, err diff --git a/pkg/storageincentives/redistribution/redistribution_test.go b/pkg/storageincentives/redistribution/redistribution_test.go index 321681f7f04..943d3013ba4 100644 --- a/pkg/storageincentives/redistribution/redistribution_test.go +++ b/pkg/storageincentives/redistribution/redistribution_test.go @@ -7,6 +7,7 @@ package redistribution_test import ( "bytes" "context" + "encoding/binary" "errors" "fmt" "math/big" @@ -27,34 +28,35 @@ import ( var redistributionContractABI = abiutil.MustParseABI(chaincfg.Testnet.RedistributionABI) -// TODO uncomment when ABI is updated -// func randChunkInclusionProof(t *testing.T) redistribution.ChunkInclusionProof { -// t.Helper() - -// return redistribution.ChunkInclusionProof{ -// ProofSegments: []string{hex.EncodeToString(testutil.RandBytes(t, 32))}, -// ProveSegment: hex.EncodeToString(testutil.RandBytes(t, 32)), -// ProofSegments2: []string{hex.EncodeToString(testutil.RandBytes(t, 32))}, -// ProveSegment2: hex.EncodeToString(testutil.RandBytes(t, 32)), -// ProofSegments3: []string{hex.EncodeToString(testutil.RandBytes(t, 32))}, -// ChunkSpan: 1, -// Signature: string(testutil.RandBytes(t, 32)), -// ChunkAddr: hex.EncodeToString(testutil.RandBytes(t, 32)), -// PostageId: hex.EncodeToString(testutil.RandBytes(t, 32)), -// Index: hex.EncodeToString(testutil.RandBytes(t, 32)), -// TimeStamp: strconv.Itoa(time.Now().Nanosecond()), -// } -// } - -// func randChunkInclusionProofs(t *testing.T) redistribution.ChunkInclusionProofs { -// t.Helper() - -// return redistribution.ChunkInclusionProofs{ -// A: randChunkInclusionProof(t), -// B: randChunkInclusionProof(t), -// C: randChunkInclusionProof(t), -// } -// } +func randChunkInclusionProof(t *testing.T) redistribution.ChunkInclusionProof { + t.Helper() + + return redistribution.ChunkInclusionProof{ + ProofSegments: []common.Hash{common.BytesToHash(testutil.RandBytes(t, 32))}, + ProveSegment: common.BytesToHash(testutil.RandBytes(t, 32)), + ProofSegments2: []common.Hash{common.BytesToHash(testutil.RandBytes(t, 32))}, + ProveSegment2: common.BytesToHash(testutil.RandBytes(t, 32)), + ProofSegments3: []common.Hash{common.BytesToHash(testutil.RandBytes(t, 32))}, + PostageProof: redistribution.PostageProof{ + Signature: testutil.RandBytes(t, 65), + PostageId: common.BytesToHash(testutil.RandBytes(t, 32)), + Index: binary.BigEndian.Uint64(testutil.RandBytes(t, 8)), + TimeStamp: binary.BigEndian.Uint64(testutil.RandBytes(t, 8)), + }, + ChunkSpan: 1, + SocProof: []redistribution.SOCProof{}, + } +} + +func randChunkInclusionProofs(t *testing.T) redistribution.ChunkInclusionProofs { + t.Helper() + + return redistribution.ChunkInclusionProofs{ + A: randChunkInclusionProof(t), + B: randChunkInclusionProof(t), + C: randChunkInclusionProof(t), + } +} func TestRedistribution(t *testing.T) { t.Parallel() @@ -179,98 +181,93 @@ func TestRedistribution(t *testing.T) { } }) - // t.Run("Claim", func(t *testing.T) { - // t.Parallel() - - // proofs := randChunkInclusionProofs(t) - // // TODO: use this when abi is updated - // // expectedCallData, err := redistributionContractABI.Pack("claim", proofs.A, proofs.B, proofs.C) - - // expectedCallData, err := redistributionContractABI.Pack("claim") - // if err != nil { - // t.Fatal(err) - // } - // contract := redistribution.New( - // owner, - // log.Noop, - // transactionMock.New( - // transactionMock.WithSendFunc(func(ctx context.Context, request *transaction.TxRequest, boost int) (txHash common.Hash, err error) { - // if *request.To == redistributionContractAddress { - // if !bytes.Equal(expectedCallData[:32], request.Data[:32]) { - // return common.Hash{}, fmt.Errorf("got wrong call data. wanted %x, got %x", expectedCallData, request.Data) - // } - // return txHashDeposited, nil - // } - // return common.Hash{}, errors.New("sent to wrong contract") - // }), - // transactionMock.WithWaitForReceiptFunc(func(ctx context.Context, txHash common.Hash) (receipt *types.Receipt, err error) { - // if txHash == txHashDeposited { - // return &types.Receipt{ - // Status: 1, - // }, nil - // } - // return nil, errors.New("unknown tx hash") - // }), - // ), - // redistributionContractAddress, - // redistributionContractABI, - // ) - - // _, err = contract.Claim(ctx, proofs) - // if err != nil { - // t.Fatal(err) - // } - // }) - - // NOTE: skip until storage-incentives-abi gets update - // t.Run("Claim with tx reverted", func(t *testing.T) { - // t.Parallel() - - // proofs := randChunkInclusionProofs(t) - // // TODO_PH4: use this when abi is updated - // // expectedCallData, err := redistributionContractABI.Pack("claim", proofs.A, proofs.B, proofs.C) - // expectedCallData, err := redistributionContractABI.Pack("claim") - // if err != nil { - // t.Fatal(err) - // } - // contract := redistribution.New( - // owner, - // log.Noop, - // transactionMock.New( - // transactionMock.WithSendFunc(func(ctx context.Context, request *transaction.TxRequest, boost int) (txHash common.Hash, err error) { - // if *request.To == redistributionContractAddress { - // if !bytes.Equal(expectedCallData[:32], request.Data[:32]) { - // return common.Hash{}, fmt.Errorf("got wrong call data. wanted %x, got %x", expectedCallData, request.Data) - // } - // return txHashDeposited, nil - // } - // return common.Hash{}, errors.New("sent to wrong contract") - // }), - // transactionMock.WithWaitForReceiptFunc(func(ctx context.Context, txHash common.Hash) (receipt *types.Receipt, err error) { - // if txHash == txHashDeposited { - // return &types.Receipt{ - // Status: 0, - // }, nil - // } - // return nil, errors.New("unknown tx hash") - // }), - // ), - // redistributionContractAddress, - // redistributionContractABI, - // ) - - // _, err = contract.Claim(ctx, proofs) - // if !errors.Is(err, transaction.ErrTransactionReverted) { - // t.Fatal(err) - // } - // }) + t.Run("Claim", func(t *testing.T) { + t.Parallel() + + proofs := randChunkInclusionProofs(t) + + expectedCallData, err := redistributionContractABI.Pack("claim", proofs.A, proofs.B, proofs.C) + if err != nil { + t.Fatal(err) + } + contract := redistribution.New( + owner, + log.Noop, + transactionMock.New( + transactionMock.WithSendFunc(func(ctx context.Context, request *transaction.TxRequest, boost int) (txHash common.Hash, err error) { + if *request.To == redistributionContractAddress { + if !bytes.Equal(expectedCallData[:32], request.Data[:32]) { + return common.Hash{}, fmt.Errorf("got wrong call data. wanted %x, got %x", expectedCallData, request.Data) + } + return txHashDeposited, nil + } + return common.Hash{}, errors.New("sent to wrong contract") + }), + transactionMock.WithWaitForReceiptFunc(func(ctx context.Context, txHash common.Hash) (receipt *types.Receipt, err error) { + if txHash == txHashDeposited { + return &types.Receipt{ + Status: 1, + }, nil + } + return nil, errors.New("unknown tx hash") + }), + ), + redistributionContractAddress, + redistributionContractABI, + ) + + _, err = contract.Claim(ctx, proofs) + if err != nil { + t.Fatal(err) + } + }) + + t.Run("Claim with tx reverted", func(t *testing.T) { + t.Parallel() + + proofs := randChunkInclusionProofs(t) + expectedCallData, err := redistributionContractABI.Pack("claim", proofs.A, proofs.B, proofs.C) + if err != nil { + t.Fatal(err) + } + contract := redistribution.New( + owner, + log.Noop, + transactionMock.New( + transactionMock.WithSendFunc(func(ctx context.Context, request *transaction.TxRequest, boost int) (txHash common.Hash, err error) { + if *request.To == redistributionContractAddress { + if !bytes.Equal(expectedCallData[:32], request.Data[:32]) { + return common.Hash{}, fmt.Errorf("got wrong call data. wanted %x, got %x", expectedCallData, request.Data) + } + return txHashDeposited, nil + } + return common.Hash{}, errors.New("sent to wrong contract") + }), + transactionMock.WithWaitForReceiptFunc(func(ctx context.Context, txHash common.Hash) (receipt *types.Receipt, err error) { + if txHash == txHashDeposited { + return &types.Receipt{ + Status: 0, + }, nil + } + return nil, errors.New("unknown tx hash") + }), + ), + redistributionContractAddress, + redistributionContractABI, + ) + + _, err = contract.Claim(ctx, proofs) + if !errors.Is(err, transaction.ErrTransactionReverted) { + t.Fatal(err) + } + }) t.Run("Commit", func(t *testing.T) { t.Parallel() var obfus [32]byte testobfus := common.Hex2Bytes("hash") copy(obfus[:], testobfus) - expectedCallData, err := redistributionContractABI.Pack("commit", obfus, common.BytesToHash(owner.Bytes()), big.NewInt(0)) + expectedCallData, err := redistributionContractABI.Pack("commit", obfus, common.BytesToHash(owner.Bytes()), uint32(0)) if err != nil { t.Fatal(err) } @@ -300,7 +297,7 @@ func TestRedistribution(t *testing.T) { redistributionContractABI, ) - _, err = contract.Commit(ctx, testobfus, big.NewInt(0)) + _, err = contract.Commit(ctx, testobfus, uint32(0)) if err != nil { t.Fatal(err) } @@ -405,7 +402,7 @@ func TestRedistribution(t *testing.T) { t.Run("invalid call data", func(t *testing.T) { t.Parallel() - expectedCallData, err := redistributionContractABI.Pack("commit", common.BytesToHash(common.Hex2Bytes("some hash")), common.BytesToHash(common.Hex2Bytes("some address")), big.NewInt(0)) + expectedCallData, err := redistributionContractABI.Pack("commit", common.BytesToHash(common.Hex2Bytes("some hash")), common.BytesToHash(common.Hex2Bytes("some address")), uint32(0)) if err != nil { t.Fatal(err) } @@ -427,7 +424,7 @@ func TestRedistribution(t *testing.T) { redistributionContractABI, ) - _, err = contract.Commit(ctx, common.Hex2Bytes("hash"), big.NewInt(0)) + _, err = contract.Commit(ctx, common.Hex2Bytes("hash"), uint32(0)) if err == nil { t.Fatal("expected error") } diff --git a/pkg/storageincentives/testdata/inclusion-proofs.json b/pkg/storageincentives/testdata/inclusion-proofs.json index a5ae32e68b6..fe79666096e 100644 --- a/pkg/storageincentives/testdata/inclusion-proofs.json +++ b/pkg/storageincentives/testdata/inclusion-proofs.json @@ -1,125 +1,125 @@ { "proof1": { "proofSegments": [ - "0875605dea48e812c9685ffba220a2b848bdbafdb95e02d087ba4a32925ea34f", - "f873df729270d5f4064286f3f018385a07cb4228734d8aca794299fee6e3e3e5", - "1fa8767fe303fe7487f5d58e4d72e5e170cf135f58a91b4fe19e4b19e5b67b5a", - "0f64ed713e25291e2c5a0561f584fa78c55a399e31919903d215dd622bcfd0ec", - "34dac0c73538614801c1ad16e272ef57f0b96a972073d15418f38daf9eb401c0", - "0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", - "887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968" + "0x0875605dea48e812c9685ffba220a2b848bdbafdb95e02d087ba4a32925ea34f", + "0xf873df729270d5f4064286f3f018385a07cb4228734d8aca794299fee6e3e3e5", + "0x1fa8767fe303fe7487f5d58e4d72e5e170cf135f58a91b4fe19e4b19e5b67b5a", + "0x0f64ed713e25291e2c5a0561f584fa78c55a399e31919903d215dd622bcfd0ec", + "0x34dac0c73538614801c1ad16e272ef57f0b96a972073d15418f38daf9eb401c0", + "0x0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", + "0x887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968" ], - "proveSegment": "7133885ac59dca7b97773acb740e978d41a4af45bd563067c8a3d863578488f1", + "proveSegment": "0x7133885ac59dca7b97773acb740e978d41a4af45bd563067c8a3d863578488f1", "proofSegments2": [ - "0000000000000000000000000000000000000000000000000000000000000000", - "ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5", - "b4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30", - "21ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85", - "2047b070a295f8d517121d9ac9b3d5f9a944bac6cfab72dd5a7c625ab4558b0a", - "0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", - "887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968" + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0xad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5", + "0xb4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30", + "0x21ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85", + "0x2047b070a295f8d517121d9ac9b3d5f9a944bac6cfab72dd5a7c625ab4558b0a", + "0x0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", + "0x887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968" ], - "proveSegment2": "0000000000000000000000000000000000000000000000000000000000000000", + "proveSegment2": "0x0000000000000000000000000000000000000000000000000000000000000000", "chunkSpan": 26, "proofSegments3": [ - "0000000000000000000000000000000000000000000000000000000000000000", - "a7f526447b68535121d36909a7585c9610d4fe6d4115540464c70499b0d7136d", - "066dd7ce6f4f1c97e78ff1c271916db25cb06128c92f8c8520807a0fa2ba93ff", - "df43c86b00db2156e769e8a8df1f08dc89ab5661c6fbaa9563f96fb9c051fc63", - "7327aecc9178bab420bb6fe482e07b65af69775b55666ec1ac8ab3da5bcec6dc", - "b68323ecaad1185a5e078f41c94c59d0b6dda5d57e109866e64d44acb8702846", - "478adfa93a7bb904d0aa86ff0d559f43aa915ee7865592e717b72a24452181cb" + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0xa7f526447b68535121d36909a7585c9610d4fe6d4115540464c70499b0d7136d", + "0x066dd7ce6f4f1c97e78ff1c271916db25cb06128c92f8c8520807a0fa2ba93ff", + "0xdf43c86b00db2156e769e8a8df1f08dc89ab5661c6fbaa9563f96fb9c051fc63", + "0x7327aecc9178bab420bb6fe482e07b65af69775b55666ec1ac8ab3da5bcec6dc", + "0xb68323ecaad1185a5e078f41c94c59d0b6dda5d57e109866e64d44acb8702846", + "0x478adfa93a7bb904d0aa86ff0d559f43aa915ee7865592e717b72a24452181cb" ], "postageProof": { - "signature": "a7c8d18a8279d3803169ebcf4e5a7dbdd4dffefa591eaad8d1ceaa636a793ad975e7f7b1087bcea4176525b0002edde0acbfda20dbd2dfbbe777cab38968fdc61b", - "postageId": "4c8efc14c8e3cee608174f995d7afe155897bf643a31226e4f1363bc97686aef", - "index": "0000000000080303", - "timeStamp": "0000000000030308" + "signature": "p8jRioJ504AxaevPTlp9vdTf/vpZHqrY0c6qY2p5Otl15/exCHvOpBdlJbAALt3grL/aINvS37vnd8qziWj9xhs=", + "postageId": "0x4c8efc14c8e3cee608174f995d7afe155897bf643a31226e4f1363bc97686aef", + "index": 525059, + "timeStamp": 197384 }, "socProof": [ { - "signer": "827b44d53df2854057713b25cdd653eb70fe36c4", - "signature": "4e9576949338e4c23f4703bf81367256ab859b32934fef4db2ee46a76bf6be354e96ac628b8784b2de0bbeae5975469783192d6d1705485fcaadd8dedde6e2aa1b", - "identifier": "6223cfdd75a40440ccd32d0b11b24f08562ec63b1ea3b8cb1a59dfc3e3c33595", - "chunkAddr": "f32442586d93d8c002372ed41fa2ea1f281f38311c161d535c3665de5d9bfd92" + "signer": "0x827b44d53df2854057713b25cdd653eb70fe36c4", + "signature": "TpV2lJM45MI/RwO/gTZyVquFmzKTT+9Nsu5Gp2v2vjVOlqxii4eEst4Lvq5ZdUaXgxktbRcFSF/Krdje3ebiqhs=", + "identifier": "0x6223cfdd75a40440ccd32d0b11b24f08562ec63b1ea3b8cb1a59dfc3e3c33595", + "chunkAddr": "0xf32442586d93d8c002372ed41fa2ea1f281f38311c161d535c3665de5d9bfd92" } ] }, "proof2": { "proofSegments": [ - "463aeb4ca5f000064c082e56eba387004265d2f47bf1226ef2d86cb163bcca3a", - "829af58b2a2f1c6c156baa196f03be4df510a96419f2dd54c456d3da30166312", - "dee4815ec42efa507b79cf4eb1f272e07be1b526cbd48137a287d9e5b2b2808a", - "0f64ed713e25291e2c5a0561f584fa78c55a399e31919903d215dd622bcfd0ec", - "34dac0c73538614801c1ad16e272ef57f0b96a972073d15418f38daf9eb401c0", - "0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", - "887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968" + "0x463aeb4ca5f000064c082e56eba387004265d2f47bf1226ef2d86cb163bcca3a", + "0x829af58b2a2f1c6c156baa196f03be4df510a96419f2dd54c456d3da30166312", + "0xdee4815ec42efa507b79cf4eb1f272e07be1b526cbd48137a287d9e5b2b2808a", + "0x0f64ed713e25291e2c5a0561f584fa78c55a399e31919903d215dd622bcfd0ec", + "0x34dac0c73538614801c1ad16e272ef57f0b96a972073d15418f38daf9eb401c0", + "0x0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", + "0x887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968" ], - "proveSegment": "535e6df58a122a8f5e6c851c19b3e042f4cd1b5c5a8c499581c9f6d4e3509182", + "proveSegment": "0x535e6df58a122a8f5e6c851c19b3e042f4cd1b5c5a8c499581c9f6d4e3509182", "proofSegments2": [ - "0000000000000000000000000000000000000000000000000000000000000000", - "ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5", - "b4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30", - "21ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85", - "46f43b515833749217540ac60c79e0c6a54c73f3500850b5869b31d5c89d101f", - "0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", - "887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968" + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0xad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5", + "0xb4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30", + "0x21ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85", + "0x46f43b515833749217540ac60c79e0c6a54c73f3500850b5869b31d5c89d101f", + "0x0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", + "0x887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968" ], - "proveSegment2": "0000000000000000000000000000000000000000000000000000000000000000", + "proveSegment2": "0x0000000000000000000000000000000000000000000000000000000000000000", "chunkSpan": 26, "proofSegments3": [ - "0000000000000000000000000000000000000000000000000000000000000000", - "a7f526447b68535121d36909a7585c9610d4fe6d4115540464c70499b0d7136d", - "066dd7ce6f4f1c97e78ff1c271916db25cb06128c92f8c8520807a0fa2ba93ff", - "df43c86b00db2156e769e8a8df1f08dc89ab5661c6fbaa9563f96fb9c051fc63", - "4284c510d7d64c9e052c73bddadb1fca522fd26caf2ebf007faad50a9a0f09fa", - "b68323ecaad1185a5e078f41c94c59d0b6dda5d57e109866e64d44acb8702846", - "478adfa93a7bb904d0aa86ff0d559f43aa915ee7865592e717b72a24452181cb" + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0xa7f526447b68535121d36909a7585c9610d4fe6d4115540464c70499b0d7136d", + "0x066dd7ce6f4f1c97e78ff1c271916db25cb06128c92f8c8520807a0fa2ba93ff", + "0xdf43c86b00db2156e769e8a8df1f08dc89ab5661c6fbaa9563f96fb9c051fc63", + "0x4284c510d7d64c9e052c73bddadb1fca522fd26caf2ebf007faad50a9a0f09fa", + "0xb68323ecaad1185a5e078f41c94c59d0b6dda5d57e109866e64d44acb8702846", + "0x478adfa93a7bb904d0aa86ff0d559f43aa915ee7865592e717b72a24452181cb" ], "postageProof": { - "signature": "b0274fcda59e8aaffee803021971a764a017ce2c0f41c8ceb6eefdea807056f621a98feab5ebf33bb6065e49c050f413ec8840b008fc224d882ce5244ce3e0171c", - "postageId": "4c8efc14c8e3cee608174f995d7afe155897bf643a31226e4f1363bc97686aef", - "index": "0000000000080303", - "timeStamp": "0000000000030308" + "signature": "sCdPzaWeiq/+6AMCGXGnZKAXziwPQcjOtu796oBwVvYhqY/qtevzO7YGXknAUPQT7IhAsAj8Ik2ILOUkTOPgFxw=", + "postageId": "0x4c8efc14c8e3cee608174f995d7afe155897bf643a31226e4f1363bc97686aef", + "index": 525059, + "timeStamp": 197384 }, "socProof": [] }, "proofLast": { "proofSegments": [ - "fee18543782df46a86f85456e62dc973a4c84369b6b1cd4f93e57fe247f9730e", - "23a0858ee2b8b4cb0ba66d3533f468d6b583a6b77df0cc78fc6df64dc735a917", - "b6bffa54dec44ad57349f9aef6cb65a1f8807f15447462ec519751220e5a5bc3", - "553aae9948fc13c33d8b353cf5694ecadc7c40c8316ce09cbd4d864dbb94f026", - "af7db874a9b5addf602b3e899194480a32afec6d6cd4ec0fadf9e065db739dd5", - "0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", - "887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968" + "0xfee18543782df46a86f85456e62dc973a4c84369b6b1cd4f93e57fe247f9730e", + "0x23a0858ee2b8b4cb0ba66d3533f468d6b583a6b77df0cc78fc6df64dc735a917", + "0xb6bffa54dec44ad57349f9aef6cb65a1f8807f15447462ec519751220e5a5bc3", + "0x553aae9948fc13c33d8b353cf5694ecadc7c40c8316ce09cbd4d864dbb94f026", + "0xaf7db874a9b5addf602b3e899194480a32afec6d6cd4ec0fadf9e065db739dd5", + "0x0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", + "0x887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968" ], - "proveSegment": "5ba2c8b912fad4aeb4a11a960946d07b9f66bc40ac54d87224914d75f5aeea5f", + "proveSegment": "0x5ba2c8b912fad4aeb4a11a960946d07b9f66bc40ac54d87224914d75f5aeea5f", "proofSegments2": [ - "0000000000000000000000000000000000000000000000000000000000000000", - "ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5", - "b4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30", - "21ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85", - "7f575db255ef42dcaeb7658df9f33fe5a1aad5d41af51a72a381acea29d98a12", - "0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", - "887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968" + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0xad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5", + "0xb4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30", + "0x21ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85", + "0x7f575db255ef42dcaeb7658df9f33fe5a1aad5d41af51a72a381acea29d98a12", + "0x0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", + "0x887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968" ], - "proveSegment2": "0000000000000000000000000000000000000000000000000000000000000000", + "proveSegment2": "0x0000000000000000000000000000000000000000000000000000000000000000", "chunkSpan": 27, "proofSegments3": [ - "0000000000000000000000000000000000000000000000000000000000000000", - "a7f526447b68535121d36909a7585c9610d4fe6d4115540464c70499b0d7136d", - "066dd7ce6f4f1c97e78ff1c271916db25cb06128c92f8c8520807a0fa2ba93ff", - "df43c86b00db2156e769e8a8df1f08dc89ab5661c6fbaa9563f96fb9c051fc63", - "7683427ba0ef1fbebf97f2fc36859df88ead8123369fe38d7b767b7a7eda5294", - "b68323ecaad1185a5e078f41c94c59d0b6dda5d57e109866e64d44acb8702846", - "478adfa93a7bb904d0aa86ff0d559f43aa915ee7865592e717b72a24452181cb" + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0xa7f526447b68535121d36909a7585c9610d4fe6d4115540464c70499b0d7136d", + "0x066dd7ce6f4f1c97e78ff1c271916db25cb06128c92f8c8520807a0fa2ba93ff", + "0xdf43c86b00db2156e769e8a8df1f08dc89ab5661c6fbaa9563f96fb9c051fc63", + "0x7683427ba0ef1fbebf97f2fc36859df88ead8123369fe38d7b767b7a7eda5294", + "0xb68323ecaad1185a5e078f41c94c59d0b6dda5d57e109866e64d44acb8702846", + "0x478adfa93a7bb904d0aa86ff0d559f43aa915ee7865592e717b72a24452181cb" ], "postageProof": { - "signature": "6747c58ce8613486c696f5bb7393c9c59094371969c3a52bfaf75192c605f4ad7c70c6e71fdd320e20d005e42e94ee32102c234eb465f4f5fd9db60fcad0356b1c", - "postageId": "4c8efc14c8e3cee608174f995d7afe155897bf643a31226e4f1363bc97686aef", - "index": "0000000000080303", - "timeStamp": "0000000000030308" + "signature": "Z0fFjOhhNIbGlvW7c5PJxZCUNxlpw6Ur+vdRksYF9K18cMbnH90yDiDQBeQulO4yECwjTrRl9PX9nbYPytA1axw=", + "postageId": "0x4c8efc14c8e3cee608174f995d7afe155897bf643a31226e4f1363bc97686aef", + "index": 525059, + "timeStamp": 197384 }, "socProof": [] } diff --git a/pkg/storer/sample.go b/pkg/storer/sample.go index f48efad246c..7a37fb62e99 100644 --- a/pkg/storer/sample.go +++ b/pkg/storer/sample.go @@ -17,7 +17,6 @@ import ( "time" "github.com/ethersphere/bee/pkg/bmt" - "github.com/ethersphere/bee/pkg/cac" "github.com/ethersphere/bee/pkg/postage" "github.com/ethersphere/bee/pkg/soc" chunk "github.com/ethersphere/bee/pkg/storage/testing" @@ -293,10 +292,6 @@ func (db *DB) ReserveSample( // ensuring to pass the check order function of redistribution contract if index := contains(item.TransformedAddress); index != -1 { - // TODO change back to SOC - if cac.Valid(ch) { - continue - } // replace the chunk at index sampleItems[index] = item continue