-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/cache-reset' of github.com:iotaledger/iota-core in…
…to feat/reactive-chainmanager
- Loading branch information
Showing
193 changed files
with
5,191 additions
and
11,063 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Run Docker Network and Check Health | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths-ignore: | ||
- 'documentation/**' | ||
- 'scripts/**' | ||
- 'tools/**' | ||
|
||
concurrency: | ||
group: run-and-check-group | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
run-and-check: | ||
runs-on: self-hosted | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run network, wait and check health | ||
run: | | ||
set -x | ||
# Run network | ||
cd ./tools/docker-network | ||
timeout 10m ./run.sh 0 0 & | ||
RUN_PID=$! | ||
# Wait for node-4 to be created before querying it | ||
timeout 10m bash -c 'until docker ps | grep docker-network-node-4; do sleep 5; done' & | ||
# Wait for any of the two processes to exit | ||
wait -n || exit 1 | ||
# Additional 10 seconds wait to allow the API to come up | ||
sleep 10 | ||
# Health check | ||
SUCCESS=false | ||
while true; do | ||
OUTPUT=$(curl -o /dev/null -s -w "%{http_code}\n" http://localhost:8080/health) | ||
if [[ $OUTPUT -eq 200 ]]; then | ||
SUCCESS=true | ||
kill -s SIGINT $RUN_PID | ||
break | ||
# curl will return a connection refused when the network is tear down from the timeout. | ||
elif [[ $OUTPUT -eq 000 ]]; then | ||
echo "Connection refused. Failing the action." | ||
break | ||
fi | ||
sleep 5 | ||
done | ||
if [[ ! $SUCCESS ]]; then | ||
echo "Health check never returned 200. Failing the action." | ||
exit 1 | ||
fi | ||
- name: Cleanup | ||
run: | | ||
cd ./tools/docker-network | ||
docker compose kill | ||
docker compose down -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package inx | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/iotaledger/hive.go/ierrors" | ||
inx "github.com/iotaledger/inx/go" | ||
iotago "github.com/iotaledger/iota.go/v4" | ||
) | ||
|
||
func (s *Server) ReadIsValidatorAccount(_ context.Context, accountInfoRequest *inx.AccountInfoRequest) (*inx.BoolResponse, error) { | ||
slot := iotago.SlotIndex(accountInfoRequest.GetAccountSlot()) | ||
accountID, _, err := iotago.AccountIDFromBytes(accountInfoRequest.AccountId) | ||
if err != nil { | ||
return nil, ierrors.Wrap(err, "error when parsing account id") | ||
} | ||
|
||
account, exists, err := deps.Protocol.Engines.Main.Get().Ledger.Account(accountID, slot) | ||
if err != nil { | ||
return nil, ierrors.Wrapf(err, "error when retrieving account data for %s", accountID) | ||
} | ||
|
||
return inx.WrapBoolResponse(exists && account.StakeEndEpoch <= deps.Protocol.APIForSlot(slot).TimeProvider().EpochFromSlot(slot)), nil | ||
} | ||
|
||
func (s *Server) ReadIsCommitteeMember(_ context.Context, accountInfoRequest *inx.AccountInfoRequest) (*inx.BoolResponse, error) { | ||
slot := iotago.SlotIndex(accountInfoRequest.GetAccountSlot()) | ||
accountID, _, err := iotago.AccountIDFromBytes(accountInfoRequest.AccountId) | ||
if err != nil { | ||
return nil, ierrors.Wrap(err, "error when parsing account id") | ||
} | ||
committee, exists := deps.Protocol.Engines.Main.Get().SybilProtection.SeatManager().CommitteeInSlot(slot) | ||
if !exists { | ||
return nil, ierrors.Errorf("committee does not exist for slot %d", slot) | ||
} | ||
|
||
return inx.WrapBoolResponse(committee.HasAccount(accountID)), nil | ||
} | ||
|
||
func (s *Server) ReadIsCandidate(_ context.Context, accountInfoRequest *inx.AccountInfoRequest) (*inx.BoolResponse, error) { | ||
slot := iotago.SlotIndex(accountInfoRequest.GetAccountSlot()) | ||
accountID, _, err := iotago.AccountIDFromBytes(accountInfoRequest.AccountId) | ||
if err != nil { | ||
return nil, ierrors.Wrap(err, "error when parsing account id") | ||
} | ||
|
||
isCandidateActive, err := deps.Protocol.Engines.Main.Get().SybilProtection.IsCandidateActive(accountID, deps.Protocol.APIForSlot(slot).TimeProvider().EpochFromSlot(slot)) | ||
if err != nil { | ||
return nil, ierrors.Wrap(err, "error when checking if candidate is active") | ||
} | ||
|
||
return inx.WrapBoolResponse(isCandidateActive), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.