Skip to content

Commit

Permalink
[pipeline] on init necessary to fund even for fails; fixing yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ochaloup committed Jul 29, 2024
1 parent d8241a0 commit 999f35a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 23 deletions.
18 changes: 16 additions & 2 deletions .buildkite/fund-settlements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ steps:
artifact_paths:
- "./merkle-trees/*"

- label: ":black_nib: Find Discord webhook"
commands:
- |
discord_webhook="$(buildkite-agent meta-data get discord_webhook)"
if [[ -z "$$discord_webhook" ]]; then
# env defined by job definition
discord_webhook="${DISCORD_WEBHOOK}"
fi
if [[ -z "$$discord_webhook" ]]; then
# env defined by buildkite environment
discord_webhook="$${DISCORD_WEBHOOK_VALIDATOR_BONDS}"
fi
echo "Discord webhook: $$discord_webhook"
- wait: ~

- label: ":campfire::arrow_right: Fund settlements"
Expand Down Expand Up @@ -100,7 +114,7 @@ steps:

- label: ":mega: Notification Funding"
commands:
- 'build_result=$(buildkite-agent step get "outcome" --step "fund-settlement")'
- build_result=$(buildkite-agent step get "outcome" --step "fund-settlement")
- |
if [[ -z "$$build_result" || "$$build_result" =~ "failed" ]]; then
notification_result="finished with WARNINGS"
Expand All @@ -112,7 +126,7 @@ steps:
- |
attempts_count=$(buildkite-agent meta-data get attempts_count || echo "UNKNOWN")
buildkite-agent artifact download --include-retried-jobs fund-report.txt . || echo 'UNKNOWN ERROR' > './fund-report.txt'
curl "$$DISCORD_WEBHOOK_VALIDATOR_BONDS" \
curl "$(buildkite-agent meta-data get discord_webhook)" \
-F 'payload_json={
"embeds":[{
"title": "Fund Settlements '"$$notification_result"', '"$$attempts_count"' attempts",
Expand Down
23 changes: 14 additions & 9 deletions .buildkite/init-settlements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ steps:

- label: ":mega: Notification initializing settlements"
commands:
- 'epoch=${EPOCH:-$(buildkite-agent meta-data get epoch)}'
- 'buildkite-agent meta-data set epoch "$$epoch"'
- discord_webhook="${DISCORD_WEBHOOK:-$$DISCORD_WEBHOOK_VALIDATOR_BONDS}"
- epoch=${EPOCH:-$(buildkite-agent meta-data get epoch)}
- buildkite-agent meta-data set epoch "$$epoch"
- buildkite-agent meta-data set discord_webhook "$$discord_webhook"
- 'echo "Epoch: $$epoch"'
- |
curl "$$DISCORD_WEBHOOK_VALIDATOR_BONDS" \
curl "$$discord_webhook" \
-H "Content-Type: application/json" -d '{
"embeds": [
{
Expand Down Expand Up @@ -145,13 +147,14 @@ steps:

- label: ":mega: Notification Initializing Settlements"
commands:
- 'epoch=$(buildkite-agent meta-data get epoch)'
- 'notification_result=$(buildkite-agent meta-data get notification_result || echo "UNKNOWN")'
- 'notification_color=$(buildkite-agent meta-data get notification_color || echo "15158332")'
- 'attempts_count=$(buildkite-agent meta-data get attempts_count || echo "UNKNOWN")'
- 'buildkite-agent artifact download --include-retried-jobs init-report.txt . || echo "UNKNOWN ERROR" > init-report.txt'
- epoch=$(buildkite-agent meta-data get epoch)
- discord_webhook=$(buildkite-agent meta-data get discord_webhook)
- notification_result=$(buildkite-agent meta-data get notification_result || echo "UNKNOWN")
- notification_color=$(buildkite-agent meta-data get notification_color || echo "15158332")
- attempts_count=$(buildkite-agent meta-data get attempts_count || echo "UNKNOWN")
- buildkite-agent artifact download --include-retried-jobs init-report.txt . || echo "UNKNOWN ERROR" > init-report.txt
- |
curl "$$DISCORD_WEBHOOK_VALIDATOR_BONDS" \
curl "$$discord_webhook" \
-F 'payload_json={
"embeds":[{
"title": "Init Settlements '"$notification_result"' for Validator Bonds ('"$$epoch"') after '"$$attempts_count"' attempts",
Expand All @@ -171,6 +174,8 @@ steps:
- 'epoch=$(buildkite-agent meta-data get epoch)'
- 'echo "Epoch: $$epoch"'
- 'buildkite-agent pipeline upload .buildkite/fund-settlements.yml'
depends_on: "init-settlement"
allow_dependency_failure: true

- wait: ~

Expand Down
34 changes: 22 additions & 12 deletions settlement-pipelines/src/bin/init_settlement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async fn init_settlements(

for record in settlement_records {
if record.bond_account.is_none() {
// the existence of the Bond is required for any init Settlement
// the existence of the Bond is required for any init Settlement, when not exists, we skip the init
reporting.add_error_string(format!(
"Cannot find bond account {} for vote account {}, funder {}, claim amount {} SOLs (settlement to init: {})",
record.bond_address,
Expand Down Expand Up @@ -335,25 +335,35 @@ async fn upsize_settlements(
claims.data.len(),
number_of_upsize_calls
);
let vote_account = if let Some(settlement_record) = settlement_records
.iter()
.find(|s| s.settlement_address == *settlement_address)
{
settlement_record.vote_account_address
} else {
reporting.add_error_string(format!(
"CRITICAL [upsize_settlements]: No vote account found for Settlement {}",
settlement_address
));
continue;
};
for _ in 0..number_of_upsize_calls {
let _req = program
let req = program
.request()
.accounts(validator_bonds::accounts::UpsizeSettlementClaims {
settlement_claims: settlement_claims_address,
system_program: system_program::ID,
rent_payer: rent_payer.pubkey(),
})
.args(validator_bonds::instruction::UpsizeSettlementClaims {});
// add_instruction_to_builder(
// &mut transaction_builder,
// &req,
// format!(
// "UpsizeSettlementClaims: {} (settlement: {}, vote account {})",
// settlement_claims_address,
// settlement.settlement_address,
// settlement.vote_account_address
// ),
// )?;
add_instruction_to_builder(
&mut transaction_builder,
&req,
format!(
"UpsizeSettlementClaims: {} (settlement: {}, vote account {})",
settlement_claims_address, settlement_address, vote_account,
),
)?;
reporting
.reportable
.add_upsized_settlement(*settlement_address);
Expand Down

0 comments on commit 999f35a

Please sign in to comment.