-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data further refactor #2574
Data further refactor #2574
Conversation
fn test_cli_add_peer() -> Result<()> { | ||
let temp_dir = TempDir::new()?; | ||
let cache_path = temp_dir.path().join("cache.txt"); | ||
|
||
let peer_addr = format!( | ||
"/ip4/{}/udp/8080/quic-v1/p2p/12D3KooWRBhwfeP2Y4TCx1SM6s9rUoHhR5STiGwxBhgFRcw3UERE", | ||
LOCAL_IP | ||
); | ||
|
||
// ... rest of the test ... | ||
Ok(()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that this would be a nice feature! Maybe add a TODO comment in the tests here so we don't forget them as is?
ant-evm/src/amount.rs
Outdated
/// Converts the Nanos into bytes | ||
pub fn to_bytes(&self) -> Vec<u8> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the comment still refers to Nanos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I missed that one. This file was failing tests mind you, that's the only reason I ended up making changes to it.
@@ -67,7 +67,7 @@ impl AttoTokens { | |||
|
|||
/// Converts the Nanos into bytes | |||
pub fn to_bytes(&self) -> Vec<u8> { | |||
self.0.as_le_bytes().to_vec() | |||
self.0.to_be_bytes::<32>().to_vec() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reasons to move to big endian and 32 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really network type endianness (most significant bit first) The 32 states we want exactly 32bytes (256 bits)
Otherwise we risk returning a variable length vec, well we would if using different types at least. So here we force the 32bytes.
In short we guarantee a 32byte network endian number here really.
ant-networking/Cargo.toml
Outdated
@@ -58,7 +59,6 @@ prometheus-client = { version = "0.22", optional = true } | |||
rand = { version = "~0.8.5", features = ["small_rng"] } | |||
rayon = "1.8.0" | |||
rmp-serde = "1.1.1" | |||
self_encryption = "~0.30.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad we were able to trim dependencies here!
pub fn local(mut self, local: bool) -> Self { | ||
self.local = local; | ||
self | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a GREAT pattern!
# Autonomi JS API | ||
|
||
Note: the JS API is experimental and will be subject to change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure we want to delete these WASM docs now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we gave up on wasm for now. I hope we introduce it at a later stage, but we need to ensure we do not hamper network or disk access when we do
d82ebe6
to
45d510b
Compare
match &self.mode { | ||
ClientMode::ReadWrite(_) => { | ||
let now = ant_networking::target_arch::Instant::now(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why introduce a mode here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is we have a read only client (no wallet etc.) and a full client that can put so needs a wallet
* Add new Pointer type for network addressing * Add PointerAddress type and related network address handling * Implement signature verification for Pointer records * Add validation and storage handling for Pointer records in ant-node * Add log markers for Pointer operations * Make LinkedList outputs field optional by wrapping in Option<Vec> * Update LinkedList constructors and signature calculation to handle optional outputs * Fix transaction tests to use .into() for empty output vectors * Update ant-networking to handle split records for both Pointer and optional outputs * Maintain signature verification and count-based selection for split records * Add InvalidSignature error variant to handle Pointer validation failures This change introduces a new Pointer type for network addressing while also making LinkedList transactions more flexible by allowing them to be created without outputs. The networking layer has been updated to handle both changes, including proper split record handling, signature verification, and storage validation. All changes maintain backward compatibility with existing functionality.
…version numbers, and add tests
…apLevel with direct streaming API usage - Update client utils to use streaming_decrypt_from_storage - Add detailed implementation and schedule documentation - Clean up unused imports and improve error handling - Update archive.rs to work with new self_encryption API
…pe - Remove WASM test file and documentation - Update README to remove WASM references
…cal mode instead of CLOSE_GROUP_SIZE - Remove global address check for local testing - Fix test configuration to properly use local feature - Clean up unused imports and variables
- Refactor LocalNode to use tokio async/await consistently - Add proper timeouts and cleanup in start/stop methods - Improve process handling with kill_on_drop - Remove unused peer discovery and event handling - Clean up imports and remove warnings - Add comprehensive test with proper cleanup
…very - Replace ipfs with antnode binary for node operations - Implement proper mDNS peer discovery - Add proper error handling and logging - Increase test timeouts for node startup - Fix compilation issues and dependencies
- Remove local feature flag dependency, making it a runtime configuration - Ensure bootstrap cache is not written to in local mode - Fix builder pattern usage in NetworkBuilder - Add proper config handling in deprecated connect method - Update tests to work with runtime local mode configuration This change makes the local mode behavior more explicit and configurable at runtime, rather than being a compile-time feature flag. It also ensures that when in local mode, we don't pollute the bootstrap cache with local-only peers.
- Update find_local_ip to use UDP sockets for QUIC protocol\n- Add comprehensive IP validation (non-loopback, private range, etc.)\n- Update multiaddr format to use QUIC instead of TCP\n- Fix error handling in network code and tests\n- Add test coverage for IP validation and QUIC multiaddr format\n\nThis change ensures we use the correct network interface for QUIC connections and validates the IP address meets all requirements for P2P networking.
…rap cache correctly
- Fix command-line argument order for antnode, placing global flags before subcommand - Add stdout/stderr capture to LocalNode for better debugging - Split node startup into first and secondary node functions - Add node status checking to detect early failures - Reduce test timeout from 120s to 30s for faster feedback - Add better logging of node addresses and connection status The test now properly starts two nodes in a local network configuration, with the first node having the --first flag and the second node joining as a peer. Output capturing helps diagnose startup and connection issues.
This commit enhances error handling and test infrastructure across the codebase: Error Handling: - Add Serialization variant to CostError for consistent error handling - Fix error conversions for serialization errors in archive handling - Ensure proper error propagation in client operations Module Organization: - Fix Client import in pointer.rs to use super::Client - Re-export PutError in lib.rs for test accessibility - Clean up import paths for better code organization Method Improvements: - Make check_write_access public for testing purposes - Fix wallet() method access to use proper method call Test Infrastructure: - Add local EVM network configuration for testing - Create EVM testnet data CSV file with test configuration - Fix test environment setup for client mode tests This change improves code maintainability and test reliability while ensuring consistent error handling across the codebase.
- Add tempfile dependency for temporary directory management - Create setup_test_environment function to handle test environment setup - Use temporary directory for EVM testnet data and configuration - Clean up imports and improve code organization
- Added utils module to ant-bootstrap with find_local_ip function - Removed ant-networking dependency from ant-bootstrap to avoid circular dependency - Updated address_format_tests to use the new utils function - Cleaned up unused imports
- Add test-local.sh script for running local tests - Add GitHub Actions workflow for running local tests - Add linked_list tests - Update client implementation for linked list operations - Clean up unused imports and fix linter warnings
- Add cleanup before starting EVM testnet - Set specific RPC port for EVM testnet
- Add port checks before starting EVM testnet - Use consistent port 4343 across scripts - Only clean up antnode processes, preserve EVM network
…hunk store implementations
…usage instructions
45d510b
to
a243be6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devskim found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
/// Errors that can occur during data storage operations | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum PutError { | ||
/// No wallet available for write operations | ||
#[error("Write operations require a wallet. Use upgrade_to_read_write to add a wallet.")] | ||
NoWallet, | ||
/// Network-related error | ||
#[error("Network error: {0}")] | ||
Network(#[from] NetworkError), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a discussion about putting errors were they happen before, instead of all in a single file were they become un-linked to their code.
What's your take on this?
#[derive(Clone)] | ||
pub struct Client { | ||
pub(crate) network: Network, | ||
pub(crate) client_event_sender: Arc<Option<mpsc::Sender<ClientEvent>>>, | ||
pub(crate) evm_network: EvmNetwork, | ||
pub(crate) mode: ClientMode, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason behind mode here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mode is for local network mode (mens) or not.
match record { | ||
Some(record) => { | ||
let (_, pointer): (Vec<u8>, Pointer) = rmp_serde::from_slice(&record.value) | ||
.map_err(|_| PointerError::Serialization)?; | ||
Ok(pointer) | ||
} | ||
None => Err(PointerError::Corrupt), | ||
None => Err(PointerError::FailedVerification), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does FailedVerification
cover all possible errors behind get_local_record
?
I think having at least a String with some information on the actual underlying error would be extremely valuable
let get_chunks = move |xor_names: &[XorName]| -> Result<Vec<Bytes>, SelfEncryptionError> { | ||
let mut chunks = Vec::with_capacity(xor_names.len()); | ||
for xor_name in xor_names { | ||
match futures::executor::block_on(client.chunk_get(*xor_name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just await here instead of block_on
?
pub async fn start() -> Result<Self> { | ||
Self::start_internal(true).await | ||
} | ||
|
||
pub async fn start_secondary() -> Result<Self> { | ||
Self::start_internal(false).await | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what start
and start_secondary
involves here, could this be precised?
let client = Client::init_local().await?; | ||
let client = Client::init_local(true).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not 100% clear what the true
here means, if an option on/off is needed maybe another constructor or the following pattern:
Client::init_local().with_option_AAA().await?;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of great additions! Having docs in here is a real game changer!
Couple of notes and questions but overall excellent work!
…datory - Remove encrypt-records feature flag from ant-networking and ant-node\n- Make record encryption mandatory in record_store.rs\n- Update open-metrics feature to include prometheus-client\n- Remove redundant test steps in CI workflow
…eature flag as filesystem operations are now core functionality - Remove encrypted_records feature flag as encryption is now always enabled - Update tests and workflows to remove feature flag references - Clean up related code in client files and test modules
closing as it's too big and the local flag is leading to confusion here |
wip - this PR is on top of the data_refactor PR