Skip to content

Commit f468afb

Browse files
chore: wrap-up 0.10 (#268)
Co-authored-by: MicaiahReid <[email protected]>
1 parent 2f8b7ad commit f468afb

File tree

8 files changed

+149
-17
lines changed

8 files changed

+149
-17
lines changed

Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace.package]
2-
version = "0.9.6"
2+
version = "0.10.0"
33
edition = "2024"
44
description = "Surfpool is the best place to train before surfing Solana."
55
license = "Apache-2.0"

crates/cli/src/cli/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ pub struct StartSimnet {
183183
/// Path to subgraph's sqlite database (default: :memory:)
184184
#[arg(long = "subgraph-database-path", short = 'd')]
185185
pub subgraph_database_path: Option<String>,
186-
/// Disable Studio (default: false)
187-
#[clap(long = "studio", action=ArgAction::SetFalse)]
188-
pub studio: bool,
186+
/// Disable Studio (default: true)
187+
#[clap(long = "no-studio")]
188+
pub no_studio: bool,
189189
/// Set the Studio port
190190
#[arg(long = "studio-port", short = 's', default_value_t = CHANGE_TO_DEFAULT_STUDIO_PORT_ONCE_SUPERVISOR_MERGED)]
191191
pub studio_port: u16,

crates/cli/src/cli/simnet/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub async fn handle_start_local_surfnet_command(
175175
}
176176
}
177177

178-
let displayed_url = if cmd.studio {
178+
let displayed_url = if cmd.no_studio {
179179
DisplayedUrl::Datasource(sanitized_config)
180180
} else {
181181
DisplayedUrl::Studio(sanitized_config)

crates/cli/src/scaffold/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ use txtx_addon_network_svm::templates::{
1313
use txtx_core::{
1414
kit::{helpers::fs::FileLocation, indexmap::indexmap},
1515
manifest::{RunbookMetadata, WorkspaceManifest},
16-
templates::{TXTX_MANIFEST_TEMPLATE, TXTX_README_TEMPLATE, build_manifest_data},
16+
templates::{TXTX_MANIFEST_TEMPLATE, build_manifest_data},
1717
};
1818

1919
use crate::{cli::DEFAULT_SOLANA_KEYPAIR_PATH, types::Framework};
2020

21+
pub const SURFPOOL_README_TEMPLATE: &str = include_str!("./templates/readme.md.mst");
22+
2123
mod anchor;
2224
mod native;
2325
mod pinocchio;
@@ -283,7 +285,7 @@ pub fn scaffold_iac_layout(
283285
format!("Failed to create Runbook README {}: {e}", readme_file_path)
284286
})?;
285287
let readme_file_data = build_manifest_data(&manifest);
286-
let template = mustache::compile_str(TXTX_README_TEMPLATE)
288+
let template = mustache::compile_str(SURFPOOL_README_TEMPLATE)
287289
.map_err(|e| format!("Failed to generate Runbook README: {e}"))?;
288290
template
289291
.render_data(&mut readme_file, &readme_file_data)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# {{ workspace_name }} Runbooks
2+
3+
[![Surfpool](https://img.shields.io/badge/Operated%20with-Surfpool-gree?labelColor=gray)](https://surfpool.run)
4+
5+
## Available Runbooks
6+
7+
{{# runbooks }}
8+
### {{ name }}
9+
{{ description }}
10+
{{/ runbooks }}
11+
12+
## Getting Started
13+
14+
This repository is using [Surfpool](https://surfpool.run) as a part of its development workflow.
15+
16+
Surfpool provides three major upgrades to the Solana development experience:
17+
- **Surfnet**: A local validator that runs on your machine, allowing you fork mainnet on the fly so that you always use the latest chain data when testing your programs.
18+
- **Runbooks**: Bringing the devops best practice of `infrastructure as code` to Solana, Runbooks allow you to have secure, reproducible, and composable scripts for managing on-chain operations & deployments.
19+
- **Surfpool Studio**: An all-local Web UI that gives new levels of introspection into your transactions.
20+
21+
### Installation
22+
23+
Install pre-built binaries:
24+
25+
```console
26+
# macOS (Homebrew)
27+
brew install txtx/taps/surfpool
28+
29+
# Updating surfpool for Homebrew users
30+
brew tap txtx/taps
31+
brew reinstall surfpool
32+
33+
# Linux (Snap Store)
34+
snap install surfpool
35+
```
36+
37+
Install from source:
38+
39+
```console
40+
# Clone repo
41+
git clone https://github.com/txtx/surfpool.git
42+
43+
# Set repo as current directory
44+
cd surfpool
45+
46+
# Build
47+
cargo surfpool-install
48+
```
49+
50+
### Start a Surfnet
51+
52+
```console
53+
$ surfpool start
54+
```
55+
56+
## Resources
57+
58+
Access tutorials and documentation at [docs.surfpool.run](https://docs.surfpool.run) to understand Surfnets and the Runbook syntax, and to discover the powerful features of surfpool.
59+
60+
Additionally, the [Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=txtx.txtx) will make writing runbooks easier.
61+
62+
Our [Surfpool 101 Series](https://www.youtube.com/playlist?list=PL0FMgRjJMRzO1FdunpMS-aUS4GNkgyr3T) is also a great place to start learning about Surfpool and its features:
63+
<a href="https://www.youtube.com/playlist?list=PL0FMgRjJMRzO1FdunpMS-aUS4GNkgyr3T">
64+
<picture>
65+
<source srcset="https://raw.githubusercontent.com/txtx/surfpool/main/doc/assets/youtube.png">
66+
<img alt="Surfpool 101 series" style="max-width: 100%;">
67+
</picture>
68+
</a>
69+
70+
## Quickstart
71+
72+
### List runbooks available in this repository
73+
```console
74+
$ surfpool ls
75+
Name Description
76+
deployment Deploy programs
77+
```
78+
79+
### Start a Surfnet, automatically executing the `deployment` runbook on program recompile:
80+
```console
81+
$ surfpool start --watch
82+
```
83+
84+
### Execute an existing runbook
85+
```console
86+
$ surfpool run deployment
87+
```

crates/core/src/surfnet/locker.rs

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use core::panic;
21
use std::{
32
collections::{BTreeMap, HashMap, HashSet},
43
sync::Arc,
@@ -1141,6 +1140,7 @@ impl SurfnetSvmLocker {
11411140
fn handle_execution_failure(
11421141
&self,
11431142
failed_transaction_metadata: FailedTransactionMetadata,
1143+
simulated_slot: Slot,
11441144
pre_execution_capture: ExecutionCapture,
11451145
status_tx: Sender<TransactionStatusEvent>,
11461146
do_propagate: bool,
@@ -1150,6 +1150,7 @@ impl SurfnetSvmLocker {
11501150
let cus = meta.compute_units_consumed;
11511151
let log_messages = meta.logs.clone();
11521152
let err_string = err.to_string();
1153+
let signature = meta.signature;
11531154

11541155
if do_propagate {
11551156
let meta = convert_transaction_metadata_from_canonical(&meta);
@@ -1159,7 +1160,24 @@ impl SurfnetSvmLocker {
11591160
err
11601161
)));
11611162

1162-
let _ = status_tx.try_send(TransactionStatusEvent::ExecutionFailure((err, meta)));
1163+
let _ = status_tx.try_send(TransactionStatusEvent::ExecutionFailure((
1164+
err.clone(),
1165+
meta,
1166+
)));
1167+
self.with_svm_writer(|svm_writer| {
1168+
svm_writer.notify_signature_subscribers(
1169+
SignatureSubscriptionType::processed(),
1170+
&signature,
1171+
simulated_slot,
1172+
Some(err.clone()),
1173+
);
1174+
svm_writer.notify_logs_subscribers(
1175+
&signature,
1176+
Some(err.clone()),
1177+
log_messages.clone(),
1178+
CommitmentLevel::Processed,
1179+
);
1180+
})
11631181
}
11641182

11651183
ProfileResult::new(
@@ -1175,6 +1193,7 @@ impl SurfnetSvmLocker {
11751193
&self,
11761194
transaction_metadata: TransactionMetadata,
11771195
transaction: VersionedTransaction,
1196+
simulated_slot: Slot,
11781197
pubkeys_from_message: &[Pubkey],
11791198
loaded_addresses: &Option<LoadedAddresses>,
11801199
accounts_before: &[Option<Account>],
@@ -1186,6 +1205,7 @@ impl SurfnetSvmLocker {
11861205
) -> SurfpoolResult<ProfileResult> {
11871206
let cus = transaction_metadata.compute_units_consumed;
11881207
let logs = transaction_metadata.logs.clone();
1208+
let signature = transaction.signatures[0];
11891209

11901210
let post_execution_capture = self.with_svm_writer(|svm_writer| {
11911211
let accounts_after = pubkeys_from_message
@@ -1301,6 +1321,19 @@ impl SurfnetSvmLocker {
13011321
svm_writer
13021322
.transactions_queued_for_confirmation
13031323
.push_back((transaction.clone(), status_tx.clone()));
1324+
1325+
svm_writer.notify_signature_subscribers(
1326+
SignatureSubscriptionType::processed(),
1327+
&signature,
1328+
simulated_slot,
1329+
None,
1330+
);
1331+
svm_writer.notify_logs_subscribers(
1332+
&signature,
1333+
None,
1334+
logs.clone(),
1335+
CommitmentLevel::Processed,
1336+
);
13041337
}
13051338

13061339
Ok::<ExecutionCapture, SurfpoolError>(post_execution_capture)
@@ -1337,6 +1370,7 @@ impl SurfnetSvmLocker {
13371370
.handle_execution_success(
13381371
transaction_metadata,
13391372
transaction,
1373+
self.get_latest_absolute_slot(),
13401374
transaction_accounts,
13411375
&loaded_addresses,
13421376
accounts_before,
@@ -1358,6 +1392,7 @@ impl SurfnetSvmLocker {
13581392
ProcessTransactionResult::ExecutionFailure(failed_transaction_metadata) => self
13591393
.handle_execution_failure(
13601394
failed_transaction_metadata,
1395+
self.get_latest_absolute_slot(),
13611396
pre_execution_capture,
13621397
status_tx.clone(),
13631398
do_propagate,
@@ -1995,7 +2030,7 @@ impl SurfnetSvmLocker {
19952030
}
19962031

19972032
if remapped_instructions.is_empty() {
1998-
panic!("No valid instructions after remapping, skipping partial transaction creation.");
2033+
// panic!("No valid instructions after remapping, skipping partial transaction creation.");
19992034
return None;
20002035
}
20012036

@@ -2513,11 +2548,19 @@ impl SurfnetSvmLocker {
25132548
calculate_time_travel_clock(&config, updated_at, slot_time, &epoch_info)
25142549
.map_err(|e| SurfpoolError::internal(e.to_string()))?;
25152550

2551+
let formated_time = chrono::DateTime::from_timestamp(clock_update.unix_timestamp / 1000, 0)
2552+
.unwrap_or_else(|| chrono::DateTime::from_timestamp(0, 0).unwrap())
2553+
.format("%Y-%m-%d %H:%M:%S")
2554+
.to_string();
25162555
epoch_info.slot_index = clock_update.slot;
25172556
epoch_info.epoch = clock_update.epoch;
25182557
epoch_info.absolute_slot =
25192558
clock_update.slot + clock_update.epoch * epoch_info.slots_in_epoch;
25202559
let _ = simnet_command_tx.send(SimnetCommand::UpdateInternalClock(clock_update));
2560+
let _ = self.simnet_events_tx().send(SimnetEvent::info(format!(
2561+
"Time travel to {} successful (epoch {} / slot {})",
2562+
formated_time, epoch_info.epoch, epoch_info.absolute_slot
2563+
)));
25212564

25222565
Ok(epoch_info)
25232566
}

surfpool.db

-132 KB
Binary file not shown.

0 commit comments

Comments
 (0)