Commit d1aec67a authored by mrekucci's avatar mrekucci Committed by GitHub

fix: reinstate gc test (#2318)

parent 2edc5328
26c26 26c26
< BucketDepth = uint8(16) < BucketDepth = uint8(16)
--- ---
> BucketDepth = uint8(10) > BucketDepth = uint8(2)
43c43 43c43
< var DefaultDepth = uint8(12) // 12 is the testnet depth at the time of merging to master < var DefaultDepth = uint8(12) // 12 is the testnet depth at the time of merging to master
--- ---
> var DefaultDepth = uint8(5) // 12 is the testnet depth at the time of merging to master > var DefaultDepth = uint8(2) // 12 is the testnet depth at the time of merging to master
48c48 48c48
< var Capacity = exp2(22) < var Capacity = exp2(22)
--- ---
> var Capacity = exp2(6) > var Capacity = exp2(4)
...@@ -92,7 +92,7 @@ jobs: ...@@ -92,7 +92,7 @@ jobs:
make beelocal ACTION=uninstall make beelocal ACTION=uninstall
- name: Prepare testing cluster (Node connection and clef enabled) - name: Prepare testing cluster (Node connection and clef enabled)
run: | run: |
timeout 10m make beelocal OPTS='ci skip-vet' timeout 10m make beelocal OPTS='ci skip-vet'
- name: Set kube config - name: Set kube config
run: | run: |
mkdir -p ~/.kube mkdir -p ~/.kube
...@@ -113,6 +113,29 @@ jobs: ...@@ -113,6 +113,29 @@ jobs:
run: | run: |
beekeeper delete bee-cluster --cluster-name local-clef beekeeper delete bee-cluster --cluster-name local-clef
make beelocal ACTION=uninstall make beelocal ACTION=uninstall
- name: Apply patches
run: |
patch pkg/postage/batchstore/reserve.go .github/patches/postagereserve_gc.patch
- name: Prepare testing cluster (storage incentives setup)
run: |
timeout 10m make beelocal OPTS='ci skip-vet'
- name: Set kube config
run: |
mkdir -p ~/.kube
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
- name: Set testing cluster (storage incentives setup)
run: |
timeout 10m make deploylocal BEEKEEPER_CLUSTER=local-gc
- name: Test pingpong
id: pingpong-3
run: until beekeeper check --cluster-name local-gc --checks ci-pingpong; do echo "waiting for pingpong..."; sleep .3; done
- name: Test gc
id: gc-chunk-1
run: beekeeper check --cluster-name local-gc --checks=ci-gc
- name: Destroy the cluster
run: |
beekeeper delete bee-cluster --cluster-name local-gc
make beelocal ACTION=uninstall
- name: Retag Docker image and push for cache - name: Retag Docker image and push for cache
if: success() if: success()
run: | run: |
...@@ -154,6 +177,8 @@ jobs: ...@@ -154,6 +177,8 @@ jobs:
if ${{ steps.settlements-2.outcome=='failure' }}; then FAILED=settlements-2; fi if ${{ steps.settlements-2.outcome=='failure' }}; then FAILED=settlements-2; fi
if ${{ steps.pss.outcome=='failure' }}; then FAILED=pss; fi if ${{ steps.pss.outcome=='failure' }}; then FAILED=pss; fi
if ${{ steps.soc.outcome=='failure' }}; then FAILED=soc; fi if ${{ steps.soc.outcome=='failure' }}; then FAILED=soc; fi
if ${{ steps.pingpong-3.outcome=='failure' }}; then FAILED=pingpong-3; fi
if ${{ steps.gc-chunk-1.outcome=='failure' }}; then FAILED=gc-chunk-1; fi
KEYS=$(curl -sSf -X POST https://eu.relay.tunshell.com/api/sessions) KEYS=$(curl -sSf -X POST https://eu.relay.tunshell.com/api/sessions)
curl -sSf -X POST -H "Content-Type: application/json" -d "{\"text\": \"**${RUN_TYPE}** ${{ github.head_ref }}\nFailed -> \`${FAILED}\`\nDebug -> \`sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} eu.relay.tunshell.com\`\"}" https://beehive.ethswarm.org/hooks/${{ secrets.WEBHOOK_KEY }} curl -sSf -X POST -H "Content-Type: application/json" -d "{\"text\": \"**${RUN_TYPE}** ${{ github.head_ref }}\nFailed -> \`${FAILED}\`\nDebug -> \`sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} eu.relay.tunshell.com\`\"}" https://beehive.ethswarm.org/hooks/${{ secrets.WEBHOOK_KEY }}
echo "Failed test: ${FAILED}" echo "Failed test: ${FAILED}"
......
...@@ -264,10 +264,11 @@ func (s *Service) reserveStateHandler(w http.ResponseWriter, _ *http.Request) { ...@@ -264,10 +264,11 @@ func (s *Service) reserveStateHandler(w http.ResponseWriter, _ *http.Request) {
state := s.batchStore.GetReserveState() state := s.batchStore.GetReserveState()
jsonhttp.OK(w, reserveStateResponse{ jsonhttp.OK(w, reserveStateResponse{
Radius: state.Radius, Radius: state.Radius,
Available: state.Available, StorageRadius: state.StorageRadius,
Outer: bigint.Wrap(state.Outer), Available: state.Available,
Inner: bigint.Wrap(state.Inner), Outer: bigint.Wrap(state.Outer),
Inner: bigint.Wrap(state.Inner),
}) })
} }
......
...@@ -39,9 +39,6 @@ import ( ...@@ -39,9 +39,6 @@ import (
"github.com/ethersphere/bee/pkg/swarm" "github.com/ethersphere/bee/pkg/swarm"
) )
// ErrBatchNotFound is returned when the postage batch is not found or expired
var ErrBatchNotFound = errors.New("postage batch not found or expired")
// DefaultDepth is the initial depth for the reserve // DefaultDepth is the initial depth for the reserve
var DefaultDepth = uint8(12) // 12 is the testnet depth at the time of merging to master var DefaultDepth = uint8(12) // 12 is the testnet depth at the time of merging to master
...@@ -179,7 +176,7 @@ func (s *store) evictExpired() error { ...@@ -179,7 +176,7 @@ func (s *store) evictExpired() error {
return true, err return true, err
} }
s.rs.Available += multiplier * exp2(b.Radius-s.rs.Radius-1) s.rs.Available += multiplier * exp2(uint(b.Radius-s.rs.Radius-1))
// if batch has no value then delete it // if batch has no value then delete it
if b.Value.Cmp(s.cs.TotalAmount) <= 0 { if b.Value.Cmp(s.cs.TotalAmount) <= 0 {
...@@ -236,7 +233,7 @@ func (rs *reserveState) change(oldv, newv *big.Int, oldDepth, newDepth uint8) (i ...@@ -236,7 +233,7 @@ func (rs *reserveState) change(oldv, newv *big.Int, oldDepth, newDepth uint8) (i
// size returns the number of chunks the local node is responsible // size returns the number of chunks the local node is responsible
// to store in its reserve. // to store in its reserve.
func (rs *reserveState) size(depth uint8, t tier) int64 { func (rs *reserveState) size(depth uint8, t tier) int64 {
size := exp2(depth - rs.Radius - 1) size := exp2(uint(depth - rs.Radius - 1))
switch t { switch t {
case inner: case inner:
return size return size
...@@ -354,7 +351,7 @@ func (s *store) evictOuter(last *postage.Batch) error { ...@@ -354,7 +351,7 @@ func (s *store) evictOuter(last *postage.Batch) error {
return true, nil return true, nil
} }
// unreserve outer PO of the lowest priority batch until capacity is back to positive // unreserve outer PO of the lowest priority batch until capacity is back to positive
s.rs.Available += exp2(b.Depth - s.rs.Radius - 1) s.rs.Available += exp2(uint(b.Depth) - uint(s.rs.Radius) - 1)
s.rs.Outer.Set(b.Value) s.rs.Outer.Set(b.Value)
return false, s.unreserveFn(b.ID, s.rs.Radius) return false, s.unreserveFn(b.ID, s.rs.Radius)
}) })
...@@ -409,13 +406,6 @@ func (u *UnreserveItem) UnmarshalBinary(b []byte) error { ...@@ -409,13 +406,6 @@ func (u *UnreserveItem) UnmarshalBinary(b []byte) error {
} }
// exp2 returns the e-th power of 2 // exp2 returns the e-th power of 2
func exp2(e uint8) int64 { func exp2(e uint) int64 {
if e == 0 { return 1 << e
return 1
}
b := int64(2)
for i := uint8(1); i < e; i++ {
b *= 2
}
return b
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment