Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,191 changes: 1,102 additions & 1,089 deletions cmd/curio/internal/translations/catalog.go

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions cmd/curio/internal/translations/locales/en/out.gotext.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,27 @@
"translatorComment": "Copied from source.",
"fuzzy": true
},
{
"id": "Downgrade a cluster's daatabase to a previous software version.",
"message": "Downgrade a cluster's daatabase to a previous software version.",
"translation": "Downgrade a cluster's daatabase to a previous software version.",
"translatorComment": "Copied from source.",
"fuzzy": true
},
{
"id": "If, however, the upgrade has a serious bug and you need to downgrade, first shutdown all nodes in your cluster and then run this command. Finally, only start downgraded nodes.",
"message": "If, however, the upgrade has a serious bug and you need to downgrade, first shutdown all nodes in your cluster and then run this command. Finally, only start downgraded nodes.",
"translation": "If, however, the upgrade has a serious bug and you need to downgrade, first shutdown all nodes in your cluster and then run this command. Finally, only start downgraded nodes.",
"translatorComment": "Copied from source.",
"fuzzy": true
},
{
"id": "YYYYMMDD when your cluster had the preferred schema. Ex: 20251128",
"message": "YYYYMMDD when your cluster had the preferred schema. Ex: 20251128",
"translation": "YYYYMMDD when your cluster had the preferred schema. Ex: 20251128",
"translatorComment": "Copied from source.",
"fuzzy": true
},
{
"id": "Manage node config by layers. The layer 'base' will always be applied at Curio start-up.",
"message": "Manage node config by layers. The layer 'base' will always be applied at Curio start-up.",
Expand Down
18 changes: 18 additions & 0 deletions cmd/curio/internal/translations/locales/ko/messages.gotext.json
Original file line number Diff line number Diff line change
Expand Up @@ -2931,6 +2931,24 @@
"translation": "PDP 지갑이 가져와졌습니다",
"message": "PDP wallet imported",
"placeholder": null
},
{
"id": "Downgrade a cluster's daatabase to a previous software version.",
"translation": "클러스터의 데이터베이스를 이전 소프트웨어 버전으로 다운그레이드합니다.",
"message": "Downgrade a cluster's daatabase to a previous software version.",
"placeholder": null
},
{
"id": "If, however, the upgrade has a serious bug and you need to downgrade, first shutdown all nodes in your cluster and then run this command. Finally, only start downgraded nodes.",
"translation": "그러나 업그레이드에 심각한 버그가 있어 다운그레이드해야 한다면, 먼저 클러스터의 모든 노드를 종료한 뒤 이 명령을 실행하십시오. 마지막으로 다운그레이드된 노드만 다시 시작하십시오.",
"message": "If, however, the upgrade has a serious bug and you need to downgrade, first shutdown all nodes in your cluster and then run this command. Finally, only start downgraded nodes.",
"placeholder": null
},
{
"id": "YYYYMMDD when your cluster had the preferred schema. Ex: 20251128",
"translation": "클러스터에 원하는 스키마가 적용되어 있던 YYYYMMDD 날짜입니다. 예: 20251128",
"message": "YYYYMMDD when your cluster had the preferred schema. Ex: 20251128",
"placeholder": null
}
]
}
18 changes: 18 additions & 0 deletions cmd/curio/internal/translations/locales/zh/messages.gotext.json
Original file line number Diff line number Diff line change
Expand Up @@ -2901,6 +2901,24 @@
"translation": "1. 使用以下命令测试您的 PDP 服务:pdptool ping --service-url https://your-domain.com --service-name public",
"message": "1. Test your PDP service with: pdptool ping --service-url https://your-domain.com --service-name public",
"placeholder": null
},
{
"id": "Downgrade a cluster's daatabase to a previous software version.",
"translation": "将集群的数据库降级到之前的软件版本。",
"message": "Downgrade a cluster's daatabase to a previous software version.",
"placeholder": null
},
{
"id": "If, however, the upgrade has a serious bug and you need to downgrade, first shutdown all nodes in your cluster and then run this command. Finally, only start downgraded nodes.",
"translation": "但是,如果升级存在严重缺陷需要降级,请先关闭集群中的所有节点,然后运行此命令。最后,仅启动已降级的节点。",
"message": "If, however, the upgrade has a serious bug and you need to downgrade, first shutdown all nodes in your cluster and then run this command. Finally, only start downgraded nodes.",
"placeholder": null
},
{
"id": "YYYYMMDD when your cluster had the preferred schema. Ex: 20251128",
"translation": "集群拥有首选架构的 YYYYMMDD 日期。例如:20251128",
"message": "YYYYMMDD when your cluster had the preferred schema. Ex: 20251128",
"placeholder": null
}
]
}
33 changes: 33 additions & 0 deletions cmd/curio/toolbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
"net/url"
"strconv"
"strings"

"github.com/docker/go-units"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -36,6 +37,7 @@ var toolboxCmd = &cli.Command{
Subcommands: []*cli.Command{
fixMsgCmd,
registerPDPServiceProviderCmd,
downgradeCmd,
},
}

Expand Down Expand Up @@ -439,3 +441,34 @@ var registerPDPServiceProviderCmd = &cli.Command{
return nil
},
}

var downgradeCmd = &cli.Command{
Name: "downgrade",
Usage: translations.T("Downgrade a cluster's daatabase to a previous software version."),
Description: translations.T("If, however, the upgrade has a serious bug and you need to downgrade, first shutdown all nodes in your cluster and then run this command. Finally, only start downgraded nodes."),
Flags: []cli.Flag{
&cli.IntFlag{
Name: "last_good_date",
Usage: translations.T("YYYYMMDD when your cluster had the preferred schema. Ex: 20251128"),
Required: true,
},
},
Action: func(cctx *cli.Context) error {
db, err := deps.MakeDB(cctx)
if err != nil {
return err
}

var runningMachines []string
if err := db.Select(cctx.Context, &runningMachines, `SELECT host_and_port FROM harmony_machines
WHERE last_contact > CURRENT_TIMESTAMP - INTERVAL '1 MINUTE' `); err != nil {
return err
}

if len(runningMachines) > 0 {
return xerrors.Errorf("All machines must be shutdown before downgrading. Machines seen running in the past 60 seconds: %s", strings.Join(runningMachines, ", "))
}

return db.DowngradeTo(cctx.Context, cctx.Int("last_good_date"))
},
}
17 changes: 17 additions & 0 deletions documentation/en/curio-cli/curio.md
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,7 @@ USAGE:
COMMANDS:
fix-msg Updated DB with message data missing from chain node
register-pdp-service-provider Register a PDP service provider with Filecoin Service Registry Contract
downgrade Downgrade a cluster's daatabase to a previous software version.
help, h Shows a list of commands or help for one command

OPTIONS:
Expand Down Expand Up @@ -1337,3 +1338,19 @@ OPTIONS:
--token-address value Token contract for payment (IERC20(address(0)) for FIL)
--help, -h show help
```

### curio toolbox downgrade
```
NAME:
curio toolbox downgrade - Downgrade a cluster's daatabase to a previous software version.

USAGE:
curio toolbox downgrade [command options]

DESCRIPTION:
If, however, the upgrade has a serious bug and you need to downgrade, first shutdown all nodes in your cluster and then run this command. Finally, only start downgraded nodes.

OPTIONS:
--last_good_date value YYYYMMDD when your cluster had the preferred schema. Ex: 20251128 (default: 0)
--help, -h show help
```
5 changes: 5 additions & 0 deletions documentation/en/versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ Configurations and the number of machines needed: A: Lotus, Curio (numerous), Yu
* Curio's DEBs include curio-cuda (for Nvidia) and curio-opencl (others like ATI).
* These can be mixed in a Curio cluster as they only relate to the hardware on the box.

## Database Schema Versions
* When the latest Curio starts-up, it applies any upgrades & migrations to Yugabyte's schema.
* This may cause errors on other nodes in your cluster that run the old version (low likelihood), which has the simple solution of completing the upgrade.
* If, however, the upgrade has a serious bug and you need to downgrade, "curio toolbox downgrade --last_good_date=20250515"

## Notes

* Forest (0.19+ & Docker Watchtower) is a light alternative to Lotus Client. It meets Curio's needs, but Boost compatibility is in development.
Expand Down
Empty file.
126 changes: 126 additions & 0 deletions harmony/harmonydb/downgrade/20250811-fix-commit-batching.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@

CREATE OR REPLACE FUNCTION poll_start_batch_commit_msgs(
p_slack_epoch BIGINT, -- "Slack" epoch offset
p_current_height BIGINT, -- Current on-chain height
p_max_batch INT, -- Max sectors per batch
p_new_task_id BIGINT, -- Task ID to set for a chosen batch
p_timeout_secs INT -- If earliest_ready + this > now(), condition is met
)
-- We return a TABLE of (updated_count BIGINT, reason TEXT),
-- but in practice it will yield exactly one row.
RETURNS TABLE (
updated_count BIGINT,
reason TEXT
)
LANGUAGE plpgsql
AS $$
DECLARE
batch_rec RECORD;
cond_slack BOOLEAN;
cond_timeout BOOLEAN;
cond_fee BOOLEAN;
BEGIN
-- Default outputs if we never find a batch
updated_count := 0;
reason := 'NONE';
/*
Single query logic:
(1) Select the rows that need commit assignment.
(2) Partition them by (sp_id, reg_seal_proof), using ROW_NUMBER() to break
them into sub-batches of size p_max_batch.
(3) GROUP those sub-batches to get:
- batch_start_epoch = min(start_epoch)
- earliest_ready_at = min(commit_ready_at)
- sector_nums = array of sector_number
(4) Loop over results, check conditions, update if found, return count.
(5) If we finish the loop, return 0.
*/
FOR batch_rec IN
WITH initial AS (
SELECT
sp_id,
sector_number,
start_epoch,
commit_ready_at,
reg_seal_proof
FROM sectors_sdr_pipeline
WHERE after_porep = TRUE
AND porep_proof IS NOT NULL
AND task_id_commit_msg IS NULL
AND after_commit_msg = FALSE
AND start_epoch IS NOT NULL
ORDER BY sp_id, reg_seal_proof, start_epoch
),
numbered AS (
SELECT
l.*,
ROW_NUMBER() OVER (
PARTITION BY l.sp_id, l.reg_seal_proof
ORDER BY l.commit_ready_at
) AS rn
FROM initial l
),
chunked AS (
SELECT
sp_id,
reg_seal_proof,
FLOOR((rn - 1)::NUMERIC / p_max_batch) AS batch_index,
start_epoch,
commit_ready_at,
sector_number
FROM numbered
),
grouped AS (
SELECT
sp_id,
reg_seal_proof,
batch_index,
MIN(start_epoch) AS batch_start_epoch,
MIN(commit_ready_at) AS earliest_ready_at,
ARRAY_AGG(sector_number) AS sector_nums
FROM chunked
GROUP BY sp_id, reg_seal_proof, batch_index
ORDER BY sp_id, reg_seal_proof, batch_index
)
SELECT
sp_id,
reg_seal_proof,
sector_nums,
batch_start_epoch,
earliest_ready_at
FROM grouped
LOOP
-- Evaluate conditions separately so we can pick a 'reason' if triggered.
cond_slack := ((batch_rec.batch_start_epoch - p_slack_epoch) <= p_current_height);
cond_timeout := (NOW() >= (batch_rec.earliest_ready_at + MAKE_INTERVAL(secs => p_timeout_secs)));

IF (cond_slack OR cond_timeout OR cond_fee) THEN
-- If multiple conditions are true, pick an order of precedence.
IF cond_slack THEN
reason := 'SLACK (min start epoch: ' || batch_rec.batch_start_epoch || ')';
ELSIF cond_timeout THEN
reason := 'TIMEOUT (earliest_ready_at: ' || batch_rec.earliest_ready_at || ')';
END IF;

-- Perform the update
UPDATE sectors_sdr_pipeline t
SET task_id_commit_msg = p_new_task_id
WHERE t.sp_id = batch_rec.sp_id
AND t.reg_seal_proof = batch_rec.reg_seal_proof
AND t.sector_number = ANY(batch_rec.sector_nums)
AND t.after_porep = TRUE
AND t.task_id_commit_msg IS NULL
AND t.after_commit_msg = FALSE;

GET DIAGNOSTICS updated_count = ROW_COUNT;

RETURN NEXT;
RETURN; -- Return immediately with updated_count and reason
END IF;
END LOOP;

-- If we finish the loop with no triggered condition, we return updated_count=0, reason='NONE'
RETURN NEXT;
RETURN;
END;
$$;
2 changes: 2 additions & 0 deletions harmony/harmonydb/downgrade/20250817-balancemgr-pshare.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE balance_manager_addresses DROP CONSTRAINT IF EXISTS subject_not_equal_second;
ALTER TABLE balance_manager_addresses ADD CONSTRAINT subject_not_equal_second CHECK (subject_address != second_address);
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#no need to revert
Empty file.
Loading
Loading