Skip to content
Merged
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
10 changes: 5 additions & 5 deletions aws/owen-infra/resources/owen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Parameters:
Type: String
UnprocessedStatusValue:
Type: String
StorachaBridgeUrl:
IPFSBridgeUrl:
Type: String
# OwenBlobsQueueUrl:
# Type: String
Expand Down Expand Up @@ -59,7 +59,7 @@ Parameters:

Conditions:
OverwriteDdexSequencerAddress: !Not [!Equals [!Ref DdexSequencerAddress, ""]]
OverwriteStorachaBridgeUrl: !Not [!Equals [!Ref StorachaBridgeUrl, ""]]
OverwriteIPFSBridgeUrl: !Not [!Equals [!Ref IPFSBridgeUrl, ""]]

Resources:
LambdaScheduledRule:
Expand Down Expand Up @@ -123,9 +123,9 @@ Resources:
- OverwriteDdexSequencerAddress
- !Ref DdexSequencerAddress
- !Ref "AWS::NoValue"
STORACHA_BRIDGE_URL: !If
- OverwriteStorachaBridgeUrl
- !Ref StorachaBridgeUrl
IPFS_BRIDGE_URL: !If
- OverwriteIPFSBridgeUrl
- !Ref IPFSBridgeUrl
- !Ref "AWS::NoValue"

OwenSignerKmsKey:
Expand Down
2 changes: 1 addition & 1 deletion aws/owen-infra/template-config-dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"Environment": "development",
"OwenLambdaSecretsName": "OwenLambdaSecretsDev",
"DdexSequencerAddress": "75AbeCf07C26368F0f4AA0b0d3637A732E25467e",
"StorachaBridgeUrl": "https://lwdrum6osj.execute-api.us-east-1.amazonaws.com/stage/",
"IPFSBridgeUrl": "https://lwdrum6osj.execute-api.us-east-1.amazonaws.com/stage/",
"SeoaAddress": "18f6d8e8b6b72bd9088dd452c63af0a79e2b58b3"
}
}
8 changes: 4 additions & 4 deletions aws/owen-infra/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Parameters:
DdexSequencerAddress:
Type: String
Default: ""
StorachaBridgeUrl:
IPFSBridgeUrl:
Type: String
Default: ""
BlobsTempStorageBucketPrefix:
Expand Down Expand Up @@ -231,7 +231,7 @@ Resources:
ProcessingStatusAttributeName: !Ref ProcessingStatusAttributeName
MessageFolderAttributeName: !Ref MessageFolderAttributeName
UnprocessedStatusValue: !Ref UnprocessedStatusValue
StorachaBridgeUrl: !Ref StorachaBridgeUrl
IPFSBridgeUrl: !Ref IPFSBridgeUrl
# OwenBlobsQueueUrl: !GetAtt OwenBlobsQueue.Outputs.OwenBlobsQueueUrl
BlobsTempStorageBucketName: !Sub "${BlobsTempStorageBucketPrefix}-${Environment}"

Expand All @@ -252,7 +252,7 @@ Resources:
ProcessingStatusAttributeName: !Ref ProcessingStatusAttributeName
MessageFolderAttributeName: !Ref MessageFolderAttributeName
UnprocessedStatusValue: !Ref UnprocessedStatusValue
StorachaBridgeUrl: !Ref StorachaBridgeUrl
IPFSBridgeUrl: !Ref IPFSBridgeUrl
# OwenBlobsQueueUrl: !GetAtt OwenBlobsQueue.Outputs.OwenBlobsQueueUrl
BlobsTempStorageBucketName: !Sub "${BlobsTempStorageBucketPrefix}-${Environment}"

Expand All @@ -273,7 +273,7 @@ Resources:
ProcessingStatusAttributeName: !Ref ProcessingStatusAttributeName
MessageFolderAttributeName: !Ref MessageFolderAttributeName
UnprocessedStatusValue: !Ref UnprocessedStatusValue
StorachaBridgeUrl: !Ref StorachaBridgeUrl
IPFSBridgeUrl: !Ref IPFSBridgeUrl
# OwenBlobsQueueUrl: !GetAtt OwenBlobsQueue.Outputs.OwenBlobsQueueUrl
BlobsTempStorageBucketName: !Sub "${BlobsTempStorageBucketPrefix}-${Environment}"

Expand Down
4 changes: 2 additions & 2 deletions owen/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ pub const DDEX_SEQUENCER_ADDRESS: &str = "75AbeCf07C26368F0f4AA0b0d3637A732E2546
pub const IPFS_API_BASE_URL: &str = "http://localhost:5001";
pub const IPFS_API_ADD_FILE: &str = "/api/v0/add";
pub const IPFS_API_CAT_FILE: &str = "/api/v0/cat";
pub const DEFAULT_STORACHA_BRIDGE_URL: &str =
"https://qb9qzwgenl.execute-api.us-east-1.amazonaws.com/prod/";
pub const DEFAULT_IPFS_BRIDGE_URL: &str =
"https://865rz5b07c.execute-api.us-east-1.amazonaws.com/prod/";
pub const CLIENT: &[u8] = b"OWEN";
pub const MAX_DDEX_PER_BLOB: i32 = 50;
#[cfg(any(feature = "local-s3"))]
Expand Down
20 changes: 10 additions & 10 deletions owen/src/ipfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ struct IpfsKuboResponse {
}

#[derive(Debug, Serialize, Deserialize)]
struct StorachaBridgeResponse {
struct IpfsBridgeResponse {
cid: String,
url: String,
}

pub struct IpfsManager<'a> {
local_ipfs: bool,
ipfs_api_base_url: String,
storacha_bridge_url: String,
ipfs_bridge_url: String,
ow_wallet: &'a OwWallet,
}

Expand All @@ -34,7 +34,7 @@ impl<'a> IpfsManager<'a> {
Ok(Self {
local_ipfs: config.local_ipfs.clone(),
ipfs_api_base_url: config.ipfs_api_base_url.clone(),
storacha_bridge_url: config.storacha_bridge_url.clone(),
ipfs_bridge_url: config.ipfs_bridge_url.clone(),
ow_wallet,
})
}
Expand All @@ -43,7 +43,7 @@ impl<'a> IpfsManager<'a> {
if self.local_ipfs {
Ok(self.pin_file_ipfs_kubo(path).await?)
} else {
Ok(self.pin_file_storacha(path).await?)
Ok(self.pin_file_ipfs_bridge(path).await?)
}
}

Expand Down Expand Up @@ -86,28 +86,28 @@ impl<'a> IpfsManager<'a> {
Ok(authorization)
}

async fn pin_file_storacha(&self, file_path: &String) -> anyhow::Result<String> {
log_info!("Pinning {} to IPFS using STORACHA...", file_path);
async fn pin_file_ipfs_bridge(&self, file_path: &String) -> anyhow::Result<String> {
log_info!("Pinning {} to IPFS using Ipfs Bridge...", file_path);

let form = Self::file_to_multipart_form(&file_path, Some("image/avif")).await?;

let authorization = self.sign_authorization_header().await?;

let response = REQWEST_CLIENT
.post(format!("{}w3up/file", self.storacha_bridge_url))
.post(format!("{}pin/file", self.ipfs_bridge_url))
.header("authorization", authorization)
.multipart(form)
.send()
.await
.with_context(|| format_error!("Pinning to Storacha failed"))?;
.with_context(|| format_error!("Pinning to Ipfs Bridge failed"))?;

let res: StorachaBridgeResponse;
let res: IpfsBridgeResponse;

if response.status().is_success() {
res = response.json().await?;
} else {
let reason = response.text().await?;
return Err(format_error!("Storacha Bridge returned error: {}", reason));
return Err(format_error!("Ipfs Bridge returned error: {}", reason));
}

log_info!("Pinned! CID: {}", res.cid);
Expand Down
12 changes: 6 additions & 6 deletions owen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub struct Config {
pub environment: String,
pub ddex_sequencer_address: Address,
pub disable_telemetry: bool,
pub storacha_bridge_url: String,
pub ipfs_bridge_url: String,
pub ipfs_api_base_url: String,
pub use_kms: bool,
pub signer_kms_id: Option<String>,
Expand Down Expand Up @@ -102,11 +102,11 @@ impl Config {
.as_str(),
"1" | "true"
);
let mut storacha_bridge_url = env::var("STORACHA_BRIDGE_URL")
.unwrap_or_else(|_| constants::DEFAULT_STORACHA_BRIDGE_URL.to_string());
let mut ipfs_bridge_url = env::var("IPFS_BRIDGE_URL")
.unwrap_or_else(|_| constants::DEFAULT_IPFS_BRIDGE_URL.to_string());

if !storacha_bridge_url.ends_with("/") {
storacha_bridge_url = format!("{}/", storacha_bridge_url)
if !ipfs_bridge_url.ends_with("/") {
ipfs_bridge_url = format!("{}/", ipfs_bridge_url)
}

let ipfs_api_base_url = env::var("IPFS_API_BASE_URL")
Expand Down Expand Up @@ -145,7 +145,7 @@ impl Config {
username,
ddex_sequencer_address,
disable_telemetry,
storacha_bridge_url,
ipfs_bridge_url,
use_kms,
signer_kms_id,
use_batch_sender,
Expand Down
4 changes: 2 additions & 2 deletions owen/src/output_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ mod tests {
username: String::from_str("user").unwrap(),
ddex_sequencer_address: Address::ZERO,
disable_telemetry: true,
storacha_bridge_url: "ABC".to_string(),
ipfs_bridge_url: "ABC".to_string(),
ipfs_api_base_url: "http://127.0.0.1:5001".to_string(),
use_kms: false,
signer_kms_id: None,
Expand Down Expand Up @@ -445,7 +445,7 @@ mod tests {
username: String::from_str("user").unwrap(),
ddex_sequencer_address: Address::ZERO,
disable_telemetry: true,
storacha_bridge_url: "ABC".to_string(),
ipfs_bridge_url: "ABC".to_string(),
ipfs_api_base_url: "http://127.0.0.1:5001".to_string(),
use_kms: false,
signer_kms_id: None,
Expand Down
2 changes: 1 addition & 1 deletion validator_node/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ SEGMENT_LIMIT_PO2=18
ENVIRONMENT=development
USERNAME=default
DISABLE_TELEMETRY=false # Optional
STORACHA_BRIDGE_URL=https://placeholder # Optional
IPFS_BRIDGE_URL=https://placeholder # Optional
# ALT_IPFS_API_BASE_URL=http://alt-gateway.com # Optional

4 changes: 2 additions & 2 deletions validator_node/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pub const IPFS_API_BASE_URL: &str = "https://w3s.link";
#[allow(dead_code)]
pub const IPFS_API_CAT_FILE: &str = "/ipfs/";
pub const CLIENT: &[u8] = b"VALIDATOR";
pub const DEFAULT_STORACHA_BRIDGE_URL: &str =
"https://qb9qzwgenl.execute-api.us-east-1.amazonaws.com/prod/";
pub const DEFAULT_IPFS_BRIDGE_URL: &str =
"https://865rz5b07c.execute-api.us-east-1.amazonaws.com/prod/";

pub const fn network_name(chain_id: &u64) -> &'static str {
match chain_id {
Expand Down
22 changes: 11 additions & 11 deletions validator_node/src/ipfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ struct BlobMetadata {
}

#[derive(Debug, Serialize, Deserialize)]
struct StorachaBridgeResponse {
struct IpfsBridgeResponse {
cid: String,
url: String,
}

pub struct IpfsManager {
contracts_manager: Arc<ContractsManager>,
blob_folder_path: String,
storacha_bridge_url: String,
ipfs_bridge_url: String,
alt_ipfs_api_base_url: Option<String>,
}

impl IpfsManager {
pub fn build(
contracts_manager: Arc<ContractsManager>,
storacha_bridge_url: String,
ipfs_bridge_url: String,
alt_ipfs_api_base_url: Option<String>,
) -> anyhow::Result<Self> {
let blob_folder_path = Path::new(constants::TEMP_FOLDER)
Expand All @@ -63,7 +63,7 @@ impl IpfsManager {
Ok(Self {
contracts_manager,
blob_folder_path,
storacha_bridge_url,
ipfs_bridge_url,
alt_ipfs_api_base_url,
})
}
Expand Down Expand Up @@ -268,23 +268,23 @@ impl IpfsManager {
.mime_str("application/zip")?;
let form = multipart::Form::new().part("file", file_part);

let res: StorachaBridgeResponse;
let res: IpfsBridgeResponse;

if is_local() {
log::info!("Skipping upload to Storacha Bridge in local mode");
res = StorachaBridgeResponse {
log::info!("Skipping upload to IPFS Bridge in local mode");
res = IpfsBridgeResponse {
cid: "test_cid".to_string(),
url: "test_url".to_string(),
};
} else {
log::info!("Uploading zip to Storacha Bridge...");
log::info!("Uploading zip to IPFS Bridge...");

let proposer_address = self.contracts_manager.get_blob_proposer(&blobhash).await?;

let response = REQWEST_CLIENT
.post(format!(
"{}w3up/dir/{}",
self.storacha_bridge_url,
"{}pin/dir/{}",
self.ipfs_bridge_url,
proposer_address.to_string()
))
.header("authorization", authorization)
Expand All @@ -296,7 +296,7 @@ impl IpfsManager {
res = response.json().await?;
} else {
let reason = response.text().await?;
return Err(format_error!("Storacha Bridge returned error: {}", reason));
return Err(format_error!("Ipfs Bridge returned error: {}", reason));
}

log_info!("Successfully uploaded folder to IPFS. CID: {}", res.cid);
Expand Down
14 changes: 7 additions & 7 deletions validator_node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct Config {
pub segment_limit_po2: u32,
pub ddex_sequencer_address: Address,
pub disable_telemetry: bool,
pub storacha_bridge_url: String,
pub ipfs_bridge_url: String,
pub alt_ipfs_api_base_url: Option<String>,
}

Expand Down Expand Up @@ -77,11 +77,11 @@ impl Config {
.as_str(),
"1" | "true"
);
let mut storacha_bridge_url = env::var("STORACHA_BRIDGE_URL")
.unwrap_or_else(|_| constants::DEFAULT_STORACHA_BRIDGE_URL.to_string());
let mut ipfs_bridge_url = env::var("IPFS_BRIDGE_URL")
.unwrap_or_else(|_| constants::DEFAULT_IPFS_BRIDGE_URL.to_string());

if !storacha_bridge_url.ends_with("/") {
storacha_bridge_url = format!("{}/", storacha_bridge_url)
if !ipfs_bridge_url.ends_with("/") {
ipfs_bridge_url = format!("{}/", ipfs_bridge_url)
}

let alt_ipfs_api_base_url = env::var("ALT_IPFS_API_BASE_URL")
Expand All @@ -98,7 +98,7 @@ impl Config {
segment_limit_po2,
ddex_sequencer_address,
disable_telemetry,
storacha_bridge_url,
ipfs_bridge_url,
alt_ipfs_api_base_url,
}
}
Expand All @@ -117,7 +117,7 @@ pub async fn run(config: &Config) -> anyhow::Result<()> {

let ipfs_manager = IpfsManager::build(
Arc::clone(&contracts_manager),
config.storacha_bridge_url.clone(),
config.ipfs_bridge_url.clone(),
config.alt_ipfs_api_base_url.clone(),
)?;

Expand Down
Loading