Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a3fa10c
wip
BretasArthur1 Sep 19, 2025
907b1af
refactor: Simplify Surfpool configuration and enhance validator argum…
BretasArthur1 Sep 19, 2025
806b0c1
feat(cli): Enhance argument handling for Surfpool validator
BretasArthur1 Sep 23, 2025
aab7616
refactor(cli): Update ValidatorType enum and streamline argument hand…
BretasArthur1 Sep 24, 2025
5b752c0
feat(cli): Introduce Surfpool configuration with validator integration
BretasArthur1 Sep 25, 2025
7fceb81
feat(cli): enable tui startup to localnet and fix some typos
BretasArthur1 Sep 25, 2025
5909110
feat(cli): add runbooks startup check to wait for the deployment of …
BretasArthur1 Sep 25, 2025
5d9bd36
chore: remove debug print
BretasArthur1 Sep 25, 2025
f5cca67
refactor(cli): change flags to be compatible with surfpool cli, add t…
BretasArthur1 Sep 27, 2025
c6b9de0
fix(cli): Improve runbook execution handling to consider failures as …
BretasArthur1 Sep 27, 2025
63316ae
clean up runbook execution checking logic
MicaiahReid Oct 9, 2025
758ff6f
augment surfpool config fields
MicaiahReid Oct 9, 2025
26d2508
remove `SURFPOOL_RPC_URL` const
MicaiahReid Oct 9, 2025
9ec4ecf
`remote_rpc_url` -> `datasource_rpc_url`
MicaiahReid Oct 9, 2025
d964a80
use `DEFAULT_RPC_PORT` const
MicaiahReid Oct 9, 2025
0e4899d
fix surfpool command
MicaiahReid Oct 9, 2025
f2848a5
add/use workflow to install surfpool
MicaiahReid Oct 9, 2025
caa0fff
specify surfpool cli version for CI
MicaiahReid Oct 9, 2025
100b058
disable surfpool logs by default; allow configuring in anchor.toml
MicaiahReid Oct 9, 2025
29d85ee
add timeout_minutes to setup surfpool
MicaiahReid Oct 9, 2025
b315a5e
clean up action
MicaiahReid Oct 9, 2025
1d2a706
allow too many arguments for localnet fn
MicaiahReid Oct 9, 2025
3625754
bump surfpool version for CI
MicaiahReid Oct 10, 2025
6c64d33
start surfpool instead of validator in ci
MicaiahReid Oct 10, 2025
cf299ef
update run-test.sh
MicaiahReid Oct 10, 2025
0883944
fix setup-surfpool cache
MicaiahReid Oct 10, 2025
9fac3a4
add `.surfpool` folder to gitignore for `anchor init`
MicaiahReid Oct 14, 2025
db959fa
fix: apply `--offline` flag by default for surfpool
MicaiahReid Oct 14, 2025
59a3b1e
only print message about surfpool logs if logs created
MicaiahReid Oct 14, 2025
ba188a9
feat: add block production mode to Surfpool configuration
MicaiahReid Oct 22, 2025
d8db2ec
bump surfpool versions in CI
MicaiahReid Oct 22, 2025
64e90f7
feat: add block production mode to surfpool config for ido-pool test
MicaiahReid Oct 24, 2025
2a76755
feat: add sleep functionality to log tests for improved reliability
MicaiahReid Oct 24, 2025
f0f8f33
fix: update program log messages to use dynamic identifiers for bette…
MicaiahReid Oct 24, 2025
9278d50
fix: skip mut error test until LiteSVM issue is resolved
MicaiahReid Oct 24, 2025
366285c
fix: update surfpool CLI version to 0.11.2 in workflow files
MicaiahReid Oct 24, 2025
8c308ba
fix: refactor testValidateAssociatedToken calls to use confirmed comm…
MicaiahReid Oct 24, 2025
48c102c
fix: add surfpool block production mode configuration for errors test
MicaiahReid Oct 24, 2025
32b6462
fix: start surfpool in daemon mode for client/example test
MicaiahReid Oct 24, 2025
1337013
fix: add block production mode configuration for surfpool for misc
MicaiahReid Oct 24, 2025
5e059e3
lint
MicaiahReid Oct 24, 2025
4532cc8
fix: add setup step for surfpool in reusable tests workflow
MicaiahReid Oct 24, 2025
a3de4e3
add sleep in run-test.sh to execute runbooks
MicaiahReid Oct 24, 2025
0be8825
disable check_surfpool call in run-test.sh
MicaiahReid Oct 24, 2025
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
24 changes: 24 additions & 0 deletions .github/actions/setup-surfpool/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Setup Surfpool"
description: "Installs and caches the Surfpool CLI"
runs:
using: "composite"
steps:
- uses: actions/cache@v3
name: Cache Surfpool Binary
id: cache-surfpool
with:
path: /usr/local/bin/surfpool
key: surfpool-${{ runner.os }}-v${{ env.SURFPOOL_CLI_VERSION }}

- uses: nick-fields/retry@v2
if: steps.cache-surfpool.outputs.cache-hit != 'true'
with:
retry_wait_seconds: 300
timeout_minutes: 2
max_attempts: 10
retry_on: error
shell: bash
command: |
echo "Installing Surfpool version ${{ env.SURFPOOL_CLI_VERSION }}"
curl -sL https://run.surfpool.run/ | sudo bash

1 change: 1 addition & 0 deletions .github/workflows/no-caching-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ jobs:
node_version: 20.18.0
cargo_profile: release
anchor_binary_name: anchor-binary-no-caching
surfpool_cli_version: 0.11.2
13 changes: 11 additions & 2 deletions .github/workflows/reusable-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ on:
anchor_binary_name:
required: true
type: string
surfpool_cli_version:
required: true
type: string
env:
CACHE: ${{ inputs.cache }}
SOLANA_CLI_VERSION: ${{ inputs.solana_cli_version }}
NODE_VERSION: ${{ inputs.node_version }}
CARGO_PROFILE: ${{ inputs.cargo_profile }}
ANCHOR_BINARY_NAME: ${{ inputs.anchor_binary_name }}
SURFPOOL_CLI_VERSION: ${{ inputs.surfpool_cli_version }}
CARGO_CACHE_PATH: |
~/.cargo/bin/
~/.cargo/registry/index/
Expand Down Expand Up @@ -111,6 +115,7 @@ jobs:
- uses: ./.github/actions/setup/
- uses: ./.github/actions/setup-solana/
- uses: ./.github/actions/setup-ts/
- uses: ./.github/actions/setup-surfpool/

- uses: actions/cache@v3
if: ${{ env.CACHE != 'false' }}
Expand Down Expand Up @@ -236,6 +241,7 @@ jobs:
path: client/example/target
key: cargo-${{ runner.os }}-client/example-${{ env.ANCHOR_VERSION }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
- uses: ./.github/actions/setup-solana/
- uses: ./.github/actions/setup-surfpool/
- run: cd client/example && ./run-test.sh
- uses: ./.github/actions/git-diff/

Expand All @@ -249,6 +255,7 @@ jobs:
- uses: ./.github/actions/setup/
- uses: ./.github/actions/setup-ts/
- uses: ./.github/actions/setup-solana/
- uses: ./.github/actions/setup-surfpool/

- uses: actions/cache@v3
if: ${{ env.CACHE != 'false' }}
Expand All @@ -272,8 +279,8 @@ jobs:
path: tests/bpf-upgradeable-state/target
key: cargo-${{ runner.os }}-tests/bpf-upgradeable-state-${{ env.ANCHOR_VERSION }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}

- run: solana-test-validator -r --quiet &
name: start validator
- run: surfpool start --ci --offline &
name: start surfpool
- run: cd tests/bpf-upgradeable-state && yarn --frozen-lockfile
- run: cd tests/bpf-upgradeable-state
- run: cd tests/bpf-upgradeable-state && anchor build --skip-lint
Expand Down Expand Up @@ -346,6 +353,7 @@ jobs:
- uses: ./.github/actions/setup/
- uses: ./.github/actions/setup-ts/
- uses: ./.github/actions/setup-solana/
- uses: ./.github/actions/setup-surfpool/

- uses: actions/cache@v3
if: ${{ env.CACHE != 'false' }}
Expand Down Expand Up @@ -467,6 +475,7 @@ jobs:
- uses: ./.github/actions/setup/
- uses: ./.github/actions/setup-ts/
- uses: ./.github/actions/setup-solana/
- uses: ./.github/actions/setup-surfpool/

- uses: actions/cache@v3
if: ${{ env.CACHE != 'false' }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ jobs:
node_version: 20.18.0
cargo_profile: debug
anchor_binary_name: anchor-binary
surfpool_cli_version: 0.11.2
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ shellexpand = "2.1.0"
solana-cli-config = "2"
solana-faucet = "2"
solana-rpc-client = "2"
solana-rpc-client-api = "2"
solana-sdk = "2"
syn = { version = "1.0.60", features = ["full", "extra-traits"] }
tar = "0.4.35"
Expand Down
119 changes: 119 additions & 0 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use std::str::FromStr;
use std::{fmt, io};
use walkdir::WalkDir;

pub const SURFPOOL_HOST: &str = "127.0.0.1";

pub trait Merge: Sized {
fn merge(&mut self, _other: Self) {}
}
Expand Down Expand Up @@ -295,10 +297,19 @@ pub struct Config {
// Separate entry next to test_config because
// "anchor localnet" only has access to the Anchor.toml,
// not the Test.toml files
pub validator: Option<ValidatorType>,
pub test_validator: Option<TestValidator>,
pub test_config: Option<TestConfig>,
pub surfpool_config: Option<SurfpoolConfig>,
}

#[derive(ValueEnum, Parser, Clone, Copy, PartialEq, Eq, Debug)]
pub enum ValidatorType {
/// Use Surfpool validator (default)
Surfpool,
/// Use Solana test validator
Legacy,
}
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ToolchainConfig {
pub anchor_version: Option<String>,
Expand Down Expand Up @@ -405,6 +416,7 @@ pub enum ProgramArch {
Bpf,
Sbf,
}

impl ProgramArch {
pub fn build_subcommand(&self) -> &str {
match self {
Expand Down Expand Up @@ -513,6 +525,7 @@ struct _Config {
workspace: Option<WorkspaceConfig>,
scripts: Option<ScriptsConfig>,
test: Option<_TestValidator>,
surfpool: Option<_SurfpoolConfig>,
}

#[derive(Debug, Serialize, Deserialize)]
Expand Down Expand Up @@ -613,6 +626,7 @@ impl fmt::Display for Config {
programs,
workspace: (!self.workspace.members.is_empty() || !self.workspace.exclude.is_empty())
.then(|| self.workspace.clone()),
surfpool: self.surfpool_config.clone().map(Into::into),
};

let cfg = toml::to_string(&cfg).expect("Must be well formed");
Expand All @@ -635,10 +649,12 @@ impl FromStr for Config {
wallet: shellexpand::tilde(&cfg.provider.wallet).parse()?,
},
scripts: cfg.scripts.unwrap_or_default(),
validator: None, // Will be set based on CLI flags
test_validator: cfg.test.map(Into::into),
test_config: None,
programs: cfg.programs.map_or(Ok(BTreeMap::new()), deser_programs)?,
workspace: cfg.workspace.unwrap_or_default(),
surfpool_config: cfg.surfpool.map(Into::into),
})
}
}
Expand Down Expand Up @@ -723,6 +739,23 @@ pub struct TestValidator {
pub upgradeable: bool,
}

#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct SurfpoolConfig {
pub startup_wait: i32,
pub shutdown_wait: i32,
pub rpc_port: u16,
pub ws_port: Option<u16>,
pub host: String,
pub online: Option<bool>,
pub datasource_rpc_url: Option<String>,
pub airdrop_addresses: Option<Vec<String>>,
pub manifest_file_path: Option<String>,
pub runbooks: Option<Vec<String>>,
pub slot_time: Option<u16>,
pub log_level: Option<String>,
pub block_production_mode: Option<String>,
}

#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct _TestValidator {
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -737,6 +770,75 @@ pub struct _TestValidator {
pub upgradeable: Option<bool>,
}

#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct _SurfpoolConfig {
#[serde(skip_serializing_if = "Option::is_none")]
pub startup_wait: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub shutdown_wait: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub rpc_port: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ws_port: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
pub host: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub online: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub datasource_rpc_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub airdrop_addresses: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_file_path: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub runbooks: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub slot_time: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
pub log_level: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub block_production_mode: Option<String>,
}

impl From<_SurfpoolConfig> for SurfpoolConfig {
fn from(_surfpool_config: _SurfpoolConfig) -> Self {
Self {
startup_wait: _surfpool_config.startup_wait.unwrap_or(STARTUP_WAIT),
shutdown_wait: _surfpool_config.shutdown_wait.unwrap_or(SHUTDOWN_WAIT),
rpc_port: _surfpool_config.rpc_port.unwrap_or(DEFAULT_RPC_PORT),
host: _surfpool_config.host.unwrap_or(SURFPOOL_HOST.to_string()),
ws_port: _surfpool_config.ws_port,
online: _surfpool_config.online,
datasource_rpc_url: _surfpool_config.datasource_rpc_url,
airdrop_addresses: _surfpool_config.airdrop_addresses,
manifest_file_path: _surfpool_config.manifest_file_path,
runbooks: _surfpool_config.runbooks,
slot_time: _surfpool_config.slot_time,
log_level: _surfpool_config.log_level,
block_production_mode: _surfpool_config.block_production_mode,
}
}
}

impl From<SurfpoolConfig> for _SurfpoolConfig {
fn from(surfpool_config: SurfpoolConfig) -> Self {
Self {
startup_wait: Some(surfpool_config.startup_wait),
shutdown_wait: Some(surfpool_config.shutdown_wait),
rpc_port: Some(surfpool_config.rpc_port),
ws_port: surfpool_config.ws_port,
host: Some(surfpool_config.host),
online: surfpool_config.online,
datasource_rpc_url: surfpool_config.datasource_rpc_url,
airdrop_addresses: surfpool_config.airdrop_addresses,
manifest_file_path: surfpool_config.manifest_file_path,
runbooks: surfpool_config.runbooks,
slot_time: surfpool_config.slot_time,
log_level: surfpool_config.log_level,
block_production_mode: surfpool_config.block_production_mode,
}
}
}
pub const STARTUP_WAIT: i32 = 5000;
pub const SHUTDOWN_WAIT: i32 = 2000;

Expand Down Expand Up @@ -1354,6 +1456,23 @@ impl AnchorPackage {
}
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SurfnetInfoResponse {
pub runbook_executions: Vec<RunbookExecution>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RunbookExecution {
#[serde(rename = "startedAt")]
pub started_at: u32,
#[serde(rename = "completedAt")]
pub completed_at: Option<u32>,
#[serde(rename = "runbookId")]
pub runbook_id: String,
pub errors: Option<Vec<String>>,
}

#[macro_export]
macro_rules! home_path {
($my_struct:ident, $path:literal) => {
Expand Down
Loading
Loading